Skip to content

Commit

Permalink
[repl] extract as new package from css-test-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
elf-pavlik committed Aug 27, 2024
1 parent 36d73aa commit 409ef72
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/css-storage-fixture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"scripts": {
"dev": "community-solid-server -c config.json -l warn -f ./dev",
"test": "community-solid-server -c ../css-test-utils/src/css-config.json -l warn -f ./test -p 3711",
"css:test": "community-solid-server -c ../css-test-utils/src/css-config.json -l warn -f ./test -p 3711",
"clean": "pnpm clean:empty-directories && pnpm clean:notification-channels && pnpm clean:client-credentials",
"clean:empty-directories": "find . -type d -empty -delete",
"clean:notification-channels": "rm -rf ./dev/.internal/notifications/*",
Expand Down
11 changes: 4 additions & 7 deletions packages/css-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@
},
"scripts": {
"build": "tsc -b .",
"repl": "node --import=tsx ./repl.ts",
"clean": "rimraf dist tsconfig.tsbuildinfo"
},
"dependencies": {
"@inrupt/solid-client-authn-core": "^2.0.0",
"@solid/community-server": "^7.1.1"
"@solid/community-server": "^7.1.1",
"n3": "^1.17.1"
},
"devDependencies": {
"@janeirodigital/interop-authorization-agent": "workspace:^1.0.0-rc.24",
"@janeirodigital/interop-data-model": "workspace:^1.0.0-rc.24",
"@janeirodigital/interop-utils": "workspace:^1.0.0-rc.24",
"@paralleldrive/cuid2": "^2.2.2",
"tsx": "^4.17.0"
"@types/n3": "^1.16.2",
"@rdfjs/types": "^1.1.0"
}
}
27 changes: 16 additions & 11 deletions packages/css-test-utils/src/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import { ACL, INTEROP } from '@janeirodigital/interop-utils';
import { DataFactory } from 'n3';
import { NamedNode } from '@rdfjs/types';

import { host } from './config';
import { Account } from './types';

// TODO fix circular depencency with utils package
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export function buildNamespace(base: string): any {
const handler = {
get: (target: { base: string }, property: string): NamedNode => DataFactory.namedNode(target.base + property)
};
return new Proxy({ base }, handler);
}

export const INTEROP = buildNamespace('http://www.w3.org/ns/solid/interop#');
export const ACL = buildNamespace('http://www.w3.org/ns/auth/acl#');

const password = 'password';

Expand All @@ -8,16 +23,6 @@ export const shapeTree = {
Widget: `${host}/solid/trees/Widget`
};

export type Account = {
webId: string;
email: string;
shortName: string;
password: 'password';
registrySet?: string;
auth: string;
data: { [key: string]: string };
};

export type Application = {
clientId: string;
};
Expand Down
7 changes: 4 additions & 3 deletions packages/css-test-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { createApp } from './css-util';
export { SolidTestUtils } from './solid-test-utils';
export * from './accounts';
export * from './css-util';
export * from './solid-test-utils';
export * from './config';
export * from './types';
export * as accounts from './accounts';
2 changes: 1 addition & 1 deletion packages/css-test-utils/src/solid-test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { App } from '@solid/community-server';
import { createApp, getSecret, refreshToken, ISecretData, ITokenData } from './css-util';
import type { Account } from './types';
import { buildAuthenticatedFetch } from '@inrupt/solid-client-authn-core';
import type { Account } from './accounts';

export class SolidTestUtils {
app: App;
Expand Down
9 changes: 9 additions & 0 deletions packages/css-test-utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type Account = {
webId: string;
email: string;
shortName: string;
password: 'password';
registrySet?: string;
auth: string;
data: { [key: string]: string };
};
21 changes: 21 additions & 0 deletions packages/repl/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Janeiro Digital

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions packages/repl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# REPL
43 changes: 43 additions & 0 deletions packages/repl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@janeirodigital/interop-repl",
"private": true,
"version": "1.0.0-rc.24",
"description": "",
"contributors": [
{
"name": "elf Pavlik",
"email": "[email protected]"
},
{
"name": "Maciej Samoraj",
"email": "[email protected]"
}
],
"repository": {
"type": "git",
"url": "https://github.com/janeirodigital/sai-js.git"
},
"license": "MIT",
"type": "module",
"main": "dist/index.js",
"files": [
"dist/",
"src/"
],
"directories": {
"lib": "src",
"test": "test"
},
"scripts": {
"repl": "node --import=tsx ./repl.ts"
},
"dependencies": {
},
"devDependencies": {
"@janeirodigital/interop-authorization-agent": "workspace:^1.0.0-rc.24",
"@janeirodigital/css-test-utils": "^1.0.0-rc.24",
"@janeirodigital/interop-data-model": "workspace:^1.0.0-rc.24",
"@paralleldrive/cuid2": "^2.2.2",
"tsx": "^4.17.0"
}
}
5 changes: 1 addition & 4 deletions packages/css-test-utils/repl.ts → packages/repl/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { init } from '@paralleldrive/cuid2';
import type { CRUDRegistrySet, CRUDRegistrySetData } from '@janeirodigital/interop-data-model';
import { AuthorizationAgent } from '@janeirodigital/interop-authorization-agent';

import { createApp } from './src/css-util';
import { SolidTestUtils } from './src/solid-test-utils';
import * as accounts from './src/accounts';
import type { Account } from './src/accounts';
import { type Account, accounts, createApp, SolidTestUtils } from '@janeirodigital/css-test-utils';

global.shapeTrees = accounts.shapeTree;

Expand Down
10 changes: 10 additions & 0 deletions packages/repl/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "ES2020",
"composite": true,
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}
4 changes: 2 additions & 2 deletions packages/utils/test/discovery.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, test, expect, beforeAll, afterAll, Mock } from 'vitest';
import { DataFactory, Store } from 'n3';
import { SolidTestUtils, host, luka } from '@janeirodigital/css-test-utils';
import { SolidTestUtils, host, accounts } from '@janeirodigital/css-test-utils';
import {
RdfResponse,
discoverAuthorizationAgent,
Expand All @@ -16,7 +16,7 @@ import {

vi.setConfig({ testTimeout: 20_000, hookTimeout: 20_000 });

const stu = new SolidTestUtils(luka);
const stu = new SolidTestUtils(accounts.luka);
beforeAll(async () => stu.beforeAll());
afterAll(async () => stu.afterAll());

Expand Down
42 changes: 27 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 409ef72

Please sign in to comment.