@kubun/scalars 0.11.0 → 0.13.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/index.d.ts CHANGED
@@ -1,7 +1,40 @@
1
1
  import type { JSONSchema } from 'json-schema-typed';
2
- export declare const attachmentIDSchema: JSONSchema.String;
3
- export declare const docIDSchema: JSONSchema.String;
4
- export declare const urlSchema: JSONSchema.String;
2
+ /**
3
+ * The hand-written schemas below are `as const satisfies` rather than annotated.
4
+ *
5
+ * An annotation widens `type` back to `JSONSchema.String['type']`, which is
6
+ * optional — and `DocumentModel['schema']` is generated from a JSON schema, so
7
+ * its property union requires the literal `'string'`. Annotated, these constants
8
+ * type-check everywhere except the one place they are for: a model literal.
9
+ */
10
+ export declare const attachmentIDSchema: {
11
+ readonly type: "string";
12
+ readonly title: "AttachmentID";
13
+ readonly pattern: "^k[0-9a-z]{10,120}$";
14
+ };
15
+ /**
16
+ * A reference to a credential entry, which is all a document ever holds of one:
17
+ * the plaintext is not in the graph and does not resolve through a field.
18
+ *
19
+ * The pattern is the shared `KubunID` one and separates nothing — a document id
20
+ * and a credential key id both match it. Only the decoded type varint tells them
21
+ * apart, which is `GraphQLCredentialEntryID`'s job at the boundary.
22
+ */
23
+ export declare const credentialEntryIDSchema: {
24
+ readonly type: "string";
25
+ readonly title: "CredentialEntryID";
26
+ readonly pattern: "^k[0-9a-z]{10,120}$";
27
+ };
28
+ export declare const docIDSchema: {
29
+ readonly type: "string";
30
+ readonly title: "DocID";
31
+ readonly pattern: "^k[0-9a-z]{10,120}$";
32
+ };
33
+ export declare const urlSchema: {
34
+ readonly type: "string";
35
+ readonly format: "uri";
36
+ readonly title: "URL";
37
+ };
5
38
  export declare const bigIntSchema: JSONSchema.Integer;
6
39
  export declare const didSchema: JSONSchema.String;
7
40
  export declare const dateTimeSchema: JSONSchema.String;
package/lib/index.js CHANGED
@@ -5,11 +5,30 @@ function createScalarSchema(type) {
5
5
  title: type.name
6
6
  };
7
7
  }
8
- export const attachmentIDSchema = {
8
+ /**
9
+ * The hand-written schemas below are `as const satisfies` rather than annotated.
10
+ *
11
+ * An annotation widens `type` back to `JSONSchema.String['type']`, which is
12
+ * optional — and `DocumentModel['schema']` is generated from a JSON schema, so
13
+ * its property union requires the literal `'string'`. Annotated, these constants
14
+ * type-check everywhere except the one place they are for: a model literal.
15
+ */ export const attachmentIDSchema = {
9
16
  type: 'string',
10
17
  title: 'AttachmentID',
11
18
  pattern: '^k[0-9a-z]{10,120}$'
12
19
  };
20
+ /**
21
+ * A reference to a credential entry, which is all a document ever holds of one:
22
+ * the plaintext is not in the graph and does not resolve through a field.
23
+ *
24
+ * The pattern is the shared `KubunID` one and separates nothing — a document id
25
+ * and a credential key id both match it. Only the decoded type varint tells them
26
+ * apart, which is `GraphQLCredentialEntryID`'s job at the boundary.
27
+ */ export const credentialEntryIDSchema = {
28
+ type: 'string',
29
+ title: 'CredentialEntryID',
30
+ pattern: '^k[0-9a-z]{10,120}$'
31
+ };
13
32
  export const docIDSchema = {
14
33
  type: 'string',
15
34
  title: 'DocID',
package/package.json CHANGED
@@ -1,33 +1,36 @@
1
1
  {
2
2
  "name": "@kubun/scalars",
3
- "version": "0.11.0",
4
- "license": "see LICENSE.md",
3
+ "version": "0.13.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
- "graphql-scalars": "^1.25.0"
18
+ "graphql-scalars": "^2.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "json-schema-typed": "^8.0.2"
22
22
  },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
23
26
  "scripts": {
27
+ "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
24
28
  "build:clean": "del lib",
25
29
  "build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
26
30
  "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
27
31
  "build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
28
- "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
32
+ "test": "pnpm run test:types && pnpm run test:unit",
29
33
  "test:types": "tsc --noEmit",
30
- "test:unit": "vitest run",
31
- "test": "pnpm run test:types && pnpm run test:unit"
34
+ "test:unit": "vitest run"
32
35
  }
33
36
  }