@kubun/scalars 0.12.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 +36 -3
- package/lib/index.js +20 -1
- package/package.json +5 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import type { JSONSchema } from 'json-schema-typed';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/scalars",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"graphql-scalars": "^
|
|
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": {
|
|
24
27
|
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
25
28
|
"build:clean": "del lib",
|