@kubun/graphql 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context.d.ts +31 -2
- package/lib/context.js +620 -1
- package/lib/identifiers.js +42 -1
- package/lib/index.js +8 -1
- package/lib/scalars.js +24 -1
- package/lib/schema.js +2484 -1
- package/lib/types.js +1 -1
- package/lib/utils.js +42 -1
- package/package.json +25 -24
package/lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
/** Model-level access control defaults configuration */ export { };
|
package/lib/utils.js
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
import{fromUTF
|
|
1
|
+
import { fromUTF } from '@sozai/codec';
|
|
2
|
+
export function getUniqueDocValue(fields, data) {
|
|
3
|
+
return fromUTF(fields.map((field)=>String(data[field] ?? '')).join('|'));
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validate that every entry of `dids` is a string with the `did:` prefix.
|
|
7
|
+
* Throws a user-facing error on the first malformed entry. Mirrors
|
|
8
|
+
* `validateDIDs` from `@kubun/engine`'s access-control module — duplicated
|
|
9
|
+
* here because `@kubun/graphql` is upstream of `@kubun/engine` in the
|
|
10
|
+
* dependency graph.
|
|
11
|
+
*/ export function validateDIDs(dids) {
|
|
12
|
+
for (const did of dids){
|
|
13
|
+
if (typeof did !== 'string' || !did.startsWith('did:')) {
|
|
14
|
+
throw new Error(`Invalid DID format: ${String(did)}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate that an identifier (circle or group ID) is a non-empty,
|
|
20
|
+
* non-whitespace string. There is no canonical format helper for circle and
|
|
21
|
+
* group IDs in `@kubun/id` (they are app-supplied opaque strings — Kubun ID
|
|
22
|
+
* helpers cover content-addressed IDs only), so this check rejects only
|
|
23
|
+
* obvious garbage. Downstream membership checks won't match if the format is
|
|
24
|
+
* malformed beyond this — callers should treat malformed IDs as an empty
|
|
25
|
+
* scope.
|
|
26
|
+
*/ export function validateIDs(ids, kind) {
|
|
27
|
+
for (const id of ids){
|
|
28
|
+
if (typeof id !== 'string' || id.trim().length === 0) {
|
|
29
|
+
throw new Error(`Invalid ${kind} ID: must be a non-empty string`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validate the three optional access-control identifier arrays passed to
|
|
35
|
+
* `setModelAccessDefaults` / `setDocumentAccessOverride` resolvers. Returns
|
|
36
|
+
* normally on success; throws a user-facing GraphQL error on malformed
|
|
37
|
+
* input. Each array, when non-null, is checked element-wise.
|
|
38
|
+
*/ export function validateAccessIdentifiers(args) {
|
|
39
|
+
if (args.allowedDIDs != null) validateDIDs(args.allowedDIDs);
|
|
40
|
+
if (args.allowedCircles != null) validateIDs(args.allowedCircles, 'circle');
|
|
41
|
+
if (args.allowedGroups != null) validateIDs(args.allowedGroups, 'group');
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/graphql",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"license": "see LICENSE.md",
|
|
3
|
+
"version": "0.12.0",
|
|
5
4
|
"keywords": [],
|
|
5
|
+
"license": "see LICENSE.md",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"type": "module",
|
|
7
|
-
"main": "lib/index.js",
|
|
8
|
-
"types": "lib/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": "./lib/index.js"
|
|
11
10
|
},
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"types": "lib/index.d.ts",
|
|
12
13
|
"files": [
|
|
13
14
|
"lib/*",
|
|
14
15
|
"LICENSE.md"
|
|
15
16
|
],
|
|
16
|
-
"sideEffects": false,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
18
|
+
"@sozai/async": "^0.2.1",
|
|
19
|
+
"@sozai/codec": "^0.4.0",
|
|
20
|
+
"@sozai/event": "^0.1.3",
|
|
21
|
+
"@sozai/otel": "^0.3.2",
|
|
22
22
|
"change-case": "^5.4.4",
|
|
23
|
-
"graphql": "^16.14.
|
|
23
|
+
"graphql": "^16.14.2",
|
|
24
24
|
"graphql-relay": "^0.10.2",
|
|
25
25
|
"graphql-scalars": "^1.25.0",
|
|
26
|
-
"multiformats": "^14.0.
|
|
27
|
-
"@kubun/
|
|
28
|
-
"@kubun/
|
|
29
|
-
"@kubun/
|
|
26
|
+
"multiformats": "^14.0.5",
|
|
27
|
+
"@kubun/id": "^0.12.0",
|
|
28
|
+
"@kubun/logger": "^0.12.0",
|
|
29
|
+
"@kubun/protocol": "^0.12.0",
|
|
30
|
+
"@kubun/hlc": "^0.12.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@kubun/db": "^0.
|
|
35
|
-
"@kubun/
|
|
36
|
-
"@kubun/
|
|
37
|
-
"@kubun/db-better-sqlite": "^0.
|
|
33
|
+
"@kokuin/capability": "^0.2.1",
|
|
34
|
+
"@kokuin/token": "^0.3.0",
|
|
35
|
+
"@kubun/db": "^0.12.0",
|
|
36
|
+
"@kubun/store-graph": "^0.12.0",
|
|
37
|
+
"@kubun/test-utils": "^0.12.0",
|
|
38
|
+
"@kubun/db-better-sqlite": "^0.12.0"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
41
|
+
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
40
42
|
"build:clean": "del lib",
|
|
41
|
-
"build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
|
|
43
|
+
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
42
44
|
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
43
45
|
"build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
|
|
44
|
-
"
|
|
46
|
+
"test": "pnpm run test:types && pnpm run test:unit",
|
|
45
47
|
"test:types": "tsc --noEmit -p tsconfig.test.json",
|
|
46
|
-
"test:unit": "vitest run"
|
|
47
|
-
"test": "pnpm run test:types && pnpm run test:unit"
|
|
48
|
+
"test:unit": "vitest run"
|
|
48
49
|
}
|
|
49
50
|
}
|