@kubun/graphql 0.10.0 → 0.11.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/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 as t}from"@enkaku/codec";export function getUniqueDocValue(e,o){return t(e.map(t=>String(o[t]??"")).join("|"))}export function validateDIDs(t){for(let e of t)if("string"!=typeof e||!e.startsWith("did:"))throw Error(`Invalid DID format: ${String(e)}`)}export function validateIDs(t,e){for(let o of t)if("string"!=typeof o||0===o.trim().length)throw Error(`Invalid ${e} ID: must be a non-empty string`)}export function validateAccessIdentifiers(t){null!=t.allowedDIDs&&validateDIDs(t.allowedDIDs),null!=t.allowedCircles&&validateIDs(t.allowedCircles,"circle"),null!=t.allowedGroups&&validateIDs(t.allowedGroups,"group")}
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/graphql",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "license": "see LICENSE.md",
5
5
  "keywords": [],
6
6
  "type": "module",
@@ -15,30 +15,31 @@
15
15
  ],
16
16
  "sideEffects": false,
17
17
  "dependencies": {
18
- "@enkaku/async": "^0.16.0",
19
- "@enkaku/codec": "^0.16.0",
20
- "@enkaku/event": "^0.16.0",
21
- "@enkaku/otel": "^0.16.0",
18
+ "@sozai/async": "^0.1.0",
19
+ "@sozai/codec": "^0.1.0",
20
+ "@sozai/event": "^0.1.0",
21
+ "@sozai/otel": "^0.2.0",
22
22
  "change-case": "^5.4.4",
23
- "graphql": "^16.13.2",
23
+ "graphql": "^16.14.2",
24
24
  "graphql-relay": "^0.10.2",
25
25
  "graphql-scalars": "^1.25.0",
26
- "multiformats": "^14.0.0",
27
- "@kubun/hlc": "^0.10.0",
28
- "@kubun/protocol": "^0.10.0",
29
- "@kubun/id": "^0.10.0"
26
+ "multiformats": "^14.0.4",
27
+ "@kubun/hlc": "^0.11.0",
28
+ "@kubun/id": "^0.11.0",
29
+ "@kubun/logger": "^0.11.0",
30
+ "@kubun/protocol": "^0.11.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@enkaku/capability": "^0.16.0",
33
- "@enkaku/token": "^0.16.0",
34
- "@kubun/store-graph": "^0.10.0",
35
- "@kubun/db-better-sqlite": "^0.10.0",
36
- "@kubun/test-utils": "^0.10.0",
37
- "@kubun/db": "^0.10.0"
33
+ "@kokuin/capability": "^0.1.0",
34
+ "@kokuin/token": "^0.1.1",
35
+ "@kubun/db-better-sqlite": "^0.11.0",
36
+ "@kubun/db": "^0.11.0",
37
+ "@kubun/store-graph": "^0.11.0",
38
+ "@kubun/test-utils": "^0.11.0"
38
39
  },
39
40
  "scripts": {
40
41
  "build:clean": "del lib",
41
- "build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
42
+ "build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
42
43
  "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
43
44
  "build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
44
45
  "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",