@seed-hypermedia/client 0.0.90 → 0.0.92
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/dist/auto-link.mjs +3 -3
- package/dist/blocks-to-markdown.mjs +2 -2
- package/dist/capability.mjs +2 -2
- package/dist/{chunk-T7WF36LU.mjs → chunk-7RJYOV4D.mjs} +1 -1
- package/dist/{chunk-ZNV6NTUU.mjs → chunk-BRMAKS6Z.mjs} +1 -1
- package/dist/{chunk-XXUI3VKA.mjs → chunk-EB45YSE7.mjs} +1 -1
- package/dist/{chunk-Z72PGJKG.mjs → chunk-HEATDM6O.mjs} +1 -1
- package/dist/{chunk-W7AGZEC2.mjs → chunk-IB26JMU5.mjs} +1 -1
- package/dist/{chunk-4HP5N4I7.mjs → chunk-IJOMB2VD.mjs} +3 -3
- package/dist/{chunk-HNQDRHGQ.mjs → chunk-IO44LDKK.mjs} +2 -2
- package/dist/{chunk-Z2S7TL5U.mjs → chunk-J6LPZ3QP.mjs} +1 -1
- package/dist/{chunk-RRXP7SCF.mjs → chunk-J6N6AF3R.mjs} +1 -1
- package/dist/{chunk-UTZ42CJC.mjs → chunk-JOFKLKIC.mjs} +1 -1
- package/dist/chunk-JSNDXUPG.mjs +407 -0
- package/dist/{chunk-JODNNMBZ.mjs → chunk-M6GKXROC.mjs} +2 -2
- package/dist/{chunk-VNZHLLJE.mjs → chunk-MK35Y35R.mjs} +148 -2
- package/dist/{chunk-XB6E7EVC.mjs → chunk-QVRJGK77.mjs} +1 -1
- package/dist/chunk-RWKSRJA3.mjs +230 -0
- package/dist/chunk-VWSAFDOL.mjs +110 -0
- package/dist/{chunk-UFLGAJWJ.mjs → chunk-WY7T2TES.mjs} +3 -3
- package/dist/chunk-ZWKMAGDU.mjs +10 -0
- package/dist/client.mjs +2 -2
- package/dist/comment.mjs +2 -2
- package/dist/dag-json.d.ts +52 -0
- package/dist/dag-json.mjs +23 -0
- package/dist/document-state.mjs +2 -2
- package/dist/editorblock-to-hmblock.mjs +2 -2
- package/dist/explore-query.d.ts +112 -0
- package/dist/explore-query.mjs +455 -0
- package/dist/hm-resolver.mjs +2 -2
- package/dist/hm-types.d.ts +2953 -0
- package/dist/hm-types.mjs +33 -1
- package/dist/hmblock-to-editorblock.mjs +2 -2
- package/dist/index.mjs +27 -27
- package/dist/markdown-to-blocks.mjs +1 -1
- package/dist/pdf-to-blocks.mjs +3 -3
- package/dist/resource-read.mjs +4 -4
- package/dist/schema-engine.d.ts +127 -0
- package/dist/schema-engine.mjs +83 -0
- package/dist/schema-registry.generated.d.ts +8 -0
- package/dist/schema-registry.generated.mjs +11 -0
- package/dist/schema-resolve.d.ts +135 -0
- package/dist/schema-resolve.mjs +45 -0
- package/dist/schema-subtypes.d.ts +36 -0
- package/dist/schema-subtypes.mjs +94 -0
- package/dist/schema-types.generated.d.ts +1598 -0
- package/dist/schema-types.generated.mjs +0 -0
- package/dist/signed-blob.d.ts +63 -0
- package/dist/signed-blob.mjs +123 -0
- package/dist/tei-to-blocks.mjs +2 -2
- package/dist/unicode.mjs +1 -1
- package/package.json +1 -1
package/dist/hm-types.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
HMActivitySummarySchema,
|
|
16
16
|
HMAnnotationSchema,
|
|
17
17
|
HMAnnotationsSchema,
|
|
18
|
+
HMAttributeValueSchema,
|
|
18
19
|
HMBlockButtonAlignmentSchema,
|
|
19
20
|
HMBlockButtonSchema,
|
|
20
21
|
HMBlockChildrenTypeSchema,
|
|
@@ -40,6 +41,7 @@ import {
|
|
|
40
41
|
HMBlockVideoSchema,
|
|
41
42
|
HMBlockWebEmbedSchema,
|
|
42
43
|
HMBreadcrumbSchema,
|
|
44
|
+
HMBuiltinSortAttributeSchema,
|
|
43
45
|
HMCapabilitySchema,
|
|
44
46
|
HMCitationSchema,
|
|
45
47
|
HMCommentDraftSchema,
|
|
@@ -53,9 +55,13 @@ import {
|
|
|
53
55
|
HMDiscoveryStatusInputSchema,
|
|
54
56
|
HMDiscoveryStatusOutputSchema,
|
|
55
57
|
HMDiscoveryStatusRequestSchema,
|
|
58
|
+
HMDocumentAttributeKindSchema,
|
|
59
|
+
HMDocumentFilterComparisonOperatorSchema,
|
|
60
|
+
HMDocumentFilterSchema,
|
|
56
61
|
HMDocumentInfoSchema,
|
|
57
62
|
HMDocumentMetadataSchema,
|
|
58
63
|
HMDocumentSchema,
|
|
64
|
+
HMDocumentSortSchema,
|
|
59
65
|
HMDomainInfoSchema,
|
|
60
66
|
HMDraftContentSchema,
|
|
61
67
|
HMDraftMetaSchema,
|
|
@@ -100,6 +106,12 @@ import {
|
|
|
100
106
|
HMListDiscussionsInputSchema,
|
|
101
107
|
HMListDiscussionsOutputSchema,
|
|
102
108
|
HMListDiscussionsRequestSchema,
|
|
109
|
+
HMListDocumentAttributeNamesInputSchema,
|
|
110
|
+
HMListDocumentAttributeNamesOutputSchema,
|
|
111
|
+
HMListDocumentAttributeNamesRequestSchema,
|
|
112
|
+
HMListDocumentAttributeValuesInputSchema,
|
|
113
|
+
HMListDocumentAttributeValuesOutputSchema,
|
|
114
|
+
HMListDocumentAttributeValuesRequestSchema,
|
|
103
115
|
HMListDocumentCollaboratorsInputSchema,
|
|
104
116
|
HMListDocumentCollaboratorsOutputSchema,
|
|
105
117
|
HMListDocumentCollaboratorsRequestSchema,
|
|
@@ -131,6 +143,9 @@ import {
|
|
|
131
143
|
HMQueryBlockItemSummarySchema,
|
|
132
144
|
HMQueryBlockPayloadSchema,
|
|
133
145
|
HMQueryBlockRequestSchema,
|
|
146
|
+
HMQueryDocumentsInputSchema,
|
|
147
|
+
HMQueryDocumentsOutputSchema,
|
|
148
|
+
HMQueryDocumentsRequestSchema,
|
|
134
149
|
HMQueryInclusionSchema,
|
|
135
150
|
HMQueryRequestSchema,
|
|
136
151
|
HMQueryResultSchema,
|
|
@@ -140,6 +155,7 @@ import {
|
|
|
140
155
|
HMRawCapabilitySchema,
|
|
141
156
|
HMRawCitationSchema,
|
|
142
157
|
HMRawDocumentChangeSchema,
|
|
158
|
+
HMRawDocumentInfoSchema,
|
|
143
159
|
HMRawRefSchema,
|
|
144
160
|
HMRedirectInfoSchema,
|
|
145
161
|
HMRequestSchema,
|
|
@@ -194,7 +210,7 @@ import {
|
|
|
194
210
|
toNumber,
|
|
195
211
|
unpackHmId,
|
|
196
212
|
unpackedHmIdSchema
|
|
197
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-MK35Y35R.mjs";
|
|
198
214
|
import "./chunk-7P6ASYW6.mjs";
|
|
199
215
|
export {
|
|
200
216
|
BUILTIN_METADATA_KEYS,
|
|
@@ -213,6 +229,7 @@ export {
|
|
|
213
229
|
HMActivitySummarySchema,
|
|
214
230
|
HMAnnotationSchema,
|
|
215
231
|
HMAnnotationsSchema,
|
|
232
|
+
HMAttributeValueSchema,
|
|
216
233
|
HMBlockButtonAlignmentSchema,
|
|
217
234
|
HMBlockButtonSchema,
|
|
218
235
|
HMBlockChildrenTypeSchema,
|
|
@@ -238,6 +255,7 @@ export {
|
|
|
238
255
|
HMBlockVideoSchema,
|
|
239
256
|
HMBlockWebEmbedSchema,
|
|
240
257
|
HMBreadcrumbSchema,
|
|
258
|
+
HMBuiltinSortAttributeSchema,
|
|
241
259
|
HMCapabilitySchema,
|
|
242
260
|
HMCitationSchema,
|
|
243
261
|
HMCommentDraftSchema,
|
|
@@ -251,9 +269,13 @@ export {
|
|
|
251
269
|
HMDiscoveryStatusInputSchema,
|
|
252
270
|
HMDiscoveryStatusOutputSchema,
|
|
253
271
|
HMDiscoveryStatusRequestSchema,
|
|
272
|
+
HMDocumentAttributeKindSchema,
|
|
273
|
+
HMDocumentFilterComparisonOperatorSchema,
|
|
274
|
+
HMDocumentFilterSchema,
|
|
254
275
|
HMDocumentInfoSchema,
|
|
255
276
|
HMDocumentMetadataSchema,
|
|
256
277
|
HMDocumentSchema,
|
|
278
|
+
HMDocumentSortSchema,
|
|
257
279
|
HMDomainInfoSchema,
|
|
258
280
|
HMDraftContentSchema,
|
|
259
281
|
HMDraftMetaSchema,
|
|
@@ -298,6 +320,12 @@ export {
|
|
|
298
320
|
HMListDiscussionsInputSchema,
|
|
299
321
|
HMListDiscussionsOutputSchema,
|
|
300
322
|
HMListDiscussionsRequestSchema,
|
|
323
|
+
HMListDocumentAttributeNamesInputSchema,
|
|
324
|
+
HMListDocumentAttributeNamesOutputSchema,
|
|
325
|
+
HMListDocumentAttributeNamesRequestSchema,
|
|
326
|
+
HMListDocumentAttributeValuesInputSchema,
|
|
327
|
+
HMListDocumentAttributeValuesOutputSchema,
|
|
328
|
+
HMListDocumentAttributeValuesRequestSchema,
|
|
301
329
|
HMListDocumentCollaboratorsInputSchema,
|
|
302
330
|
HMListDocumentCollaboratorsOutputSchema,
|
|
303
331
|
HMListDocumentCollaboratorsRequestSchema,
|
|
@@ -329,6 +357,9 @@ export {
|
|
|
329
357
|
HMQueryBlockItemSummarySchema,
|
|
330
358
|
HMQueryBlockPayloadSchema,
|
|
331
359
|
HMQueryBlockRequestSchema,
|
|
360
|
+
HMQueryDocumentsInputSchema,
|
|
361
|
+
HMQueryDocumentsOutputSchema,
|
|
362
|
+
HMQueryDocumentsRequestSchema,
|
|
332
363
|
HMQueryInclusionSchema,
|
|
333
364
|
HMQueryRequestSchema,
|
|
334
365
|
HMQueryResultSchema,
|
|
@@ -338,6 +369,7 @@ export {
|
|
|
338
369
|
HMRawCapabilitySchema,
|
|
339
370
|
HMRawCitationSchema,
|
|
340
371
|
HMRawDocumentChangeSchema,
|
|
372
|
+
HMRawDocumentInfoSchema,
|
|
341
373
|
HMRawRefSchema,
|
|
342
374
|
HMRedirectInfoSchema,
|
|
343
375
|
HMRequestSchema,
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
annotationContains,
|
|
3
3
|
hmBlockToEditorBlock,
|
|
4
4
|
hmBlocksToEditorContent
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-HEATDM6O.mjs";
|
|
6
|
+
import "./chunk-MK35Y35R.mjs";
|
|
7
7
|
import "./chunk-7P6ASYW6.mjs";
|
|
8
8
|
export {
|
|
9
9
|
annotationContains,
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveIdWithClient
|
|
3
|
+
} from "./chunk-IJOMB2VD.mjs";
|
|
4
|
+
import {
|
|
5
|
+
annotationContains,
|
|
6
|
+
hmBlockToEditorBlock,
|
|
7
|
+
hmBlocksToEditorContent
|
|
8
|
+
} from "./chunk-HEATDM6O.mjs";
|
|
1
9
|
import {
|
|
2
10
|
keyfile_exports
|
|
3
11
|
} from "./chunk-EY6RQVAP.mjs";
|
|
@@ -7,19 +15,20 @@ import {
|
|
|
7
15
|
parseFrontmatter,
|
|
8
16
|
parseInlineFormatting,
|
|
9
17
|
parseMarkdown
|
|
10
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QVRJGK77.mjs";
|
|
11
19
|
import {
|
|
12
20
|
pdfToBlocks
|
|
13
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-BRMAKS6Z.mjs";
|
|
14
22
|
import {
|
|
15
23
|
teiToBlocks
|
|
16
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-IB26JMU5.mjs";
|
|
17
25
|
import {
|
|
18
26
|
embeddedPdfToBlocks
|
|
19
27
|
} from "./chunk-2FJBS3V7.mjs";
|
|
20
28
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
editorBlockToHMBlock,
|
|
30
|
+
editorBlocksToHMBlockNodes
|
|
31
|
+
} from "./chunk-EB45YSE7.mjs";
|
|
23
32
|
import {
|
|
24
33
|
encryption_exports
|
|
25
34
|
} from "./chunk-UOL3F6XQ.mjs";
|
|
@@ -37,15 +46,10 @@ import {
|
|
|
37
46
|
import {
|
|
38
47
|
resolveHypermediaUrl,
|
|
39
48
|
resolveId
|
|
40
|
-
} from "./chunk-
|
|
41
|
-
import {
|
|
42
|
-
annotationContains,
|
|
43
|
-
hmBlockToEditorBlock,
|
|
44
|
-
hmBlocksToEditorContent
|
|
45
|
-
} from "./chunk-Z72PGJKG.mjs";
|
|
49
|
+
} from "./chunk-J6LPZ3QP.mjs";
|
|
46
50
|
import {
|
|
47
51
|
createSeedClient
|
|
48
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-M6GKXROC.mjs";
|
|
49
53
|
import {
|
|
50
54
|
SeedClientError,
|
|
51
55
|
SeedNetworkError,
|
|
@@ -57,7 +61,12 @@ import {
|
|
|
57
61
|
deleteComment,
|
|
58
62
|
trimTrailingEmptyBlocks,
|
|
59
63
|
updateComment
|
|
60
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-7RJYOV4D.mjs";
|
|
65
|
+
import {
|
|
66
|
+
AnnotationSet,
|
|
67
|
+
addSpanToAnnotation,
|
|
68
|
+
pushSpanToAnnotation
|
|
69
|
+
} from "./chunk-JKKS35IS.mjs";
|
|
61
70
|
import {
|
|
62
71
|
contactRecordIdFromBlob,
|
|
63
72
|
createContact,
|
|
@@ -67,22 +76,13 @@ import {
|
|
|
67
76
|
import {
|
|
68
77
|
createDocumentBlobs
|
|
69
78
|
} from "./chunk-WD332LPF.mjs";
|
|
70
|
-
import {
|
|
71
|
-
editorBlockToHMBlock,
|
|
72
|
-
editorBlocksToHMBlockNodes
|
|
73
|
-
} from "./chunk-XXUI3VKA.mjs";
|
|
74
|
-
import {
|
|
75
|
-
AnnotationSet,
|
|
76
|
-
addSpanToAnnotation,
|
|
77
|
-
pushSpanToAnnotation
|
|
78
|
-
} from "./chunk-JKKS35IS.mjs";
|
|
79
79
|
import {
|
|
80
80
|
autoLinkChildToParent,
|
|
81
81
|
createAutoLinkOps,
|
|
82
82
|
documentContainsLinkToChild,
|
|
83
83
|
documentHasSelfQuery,
|
|
84
84
|
shouldAutoLinkParent
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-IO44LDKK.mjs";
|
|
86
86
|
import {
|
|
87
87
|
createChange,
|
|
88
88
|
createChangeOps,
|
|
@@ -104,7 +104,7 @@ import {
|
|
|
104
104
|
followToDocument,
|
|
105
105
|
resolveDocumentState,
|
|
106
106
|
resolveEditableDocument
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-JOFKLKIC.mjs";
|
|
108
108
|
import "./chunk-2MD3FXKB.mjs";
|
|
109
109
|
import {
|
|
110
110
|
computeReplaceOps,
|
|
@@ -123,11 +123,11 @@ import {
|
|
|
123
123
|
emitFrontmatter,
|
|
124
124
|
parseDraftFilename,
|
|
125
125
|
slugify
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-WY7T2TES.mjs";
|
|
127
127
|
import {
|
|
128
128
|
createCapability,
|
|
129
129
|
resolveCapability
|
|
130
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-J6N6AF3R.mjs";
|
|
131
131
|
import "./chunk-LVAHHQIK.mjs";
|
|
132
132
|
import "./chunk-NBCHK76Q.mjs";
|
|
133
133
|
import {
|
|
@@ -147,7 +147,7 @@ import {
|
|
|
147
147
|
parseFragment,
|
|
148
148
|
serializeBlockRange,
|
|
149
149
|
unpackHmId
|
|
150
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-MK35Y35R.mjs";
|
|
151
151
|
import "./chunk-3TPCJCVO.mjs";
|
|
152
152
|
import "./chunk-7P6ASYW6.mjs";
|
|
153
153
|
export {
|
package/dist/pdf-to-blocks.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pdfToBlocks
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-BRMAKS6Z.mjs";
|
|
4
|
+
import "./chunk-IB26JMU5.mjs";
|
|
5
5
|
import "./chunk-2FJBS3V7.mjs";
|
|
6
6
|
import "./chunk-PPAY4WZX.mjs";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-MK35Y35R.mjs";
|
|
8
8
|
import "./chunk-7P6ASYW6.mjs";
|
|
9
9
|
export {
|
|
10
10
|
pdfToBlocks
|
package/dist/resource-read.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIdWithClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-IJOMB2VD.mjs";
|
|
4
|
+
import "./chunk-J6LPZ3QP.mjs";
|
|
5
|
+
import "./chunk-M6GKXROC.mjs";
|
|
6
6
|
import "./chunk-CBELM7KX.mjs";
|
|
7
7
|
import "./chunk-O5MHN2EO.mjs";
|
|
8
8
|
import "./chunk-PJ2RFT5A.mjs";
|
|
9
9
|
import "./chunk-LVAHHQIK.mjs";
|
|
10
10
|
import "./chunk-DR3HJ6BV.mjs";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-MK35Y35R.mjs";
|
|
12
12
|
import "./chunk-7P6ASYW6.mjs";
|
|
13
13
|
export {
|
|
14
14
|
resolveIdWithClient
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { HM_SCHEMA_MANIFEST, HM_SCHEMAS } from './schema-registry.generated';
|
|
2
|
+
export type HypermediaSchema = Record<string, any>;
|
|
3
|
+
/** schema name (its path in hypermedia/) -> schema, e.g. "string", "schema/map-schema", "block/image". A caller may pass a
|
|
4
|
+
* custom registry to resolve refs that aren't in the bundled standard library. */
|
|
5
|
+
export type SchemaRegistry = Record<string, HypermediaSchema>;
|
|
6
|
+
/** The authority of the bundled schema library in hm:// URLs. */
|
|
7
|
+
export declare const LIBRARY_AUTHORITY = "hyper.media";
|
|
8
|
+
export declare const KINDS: string[];
|
|
9
|
+
/** The type language's own schemas: the kind primitives, the meta-schema and its
|
|
10
|
+
* variants, and the built-in refinements — as opposed to the network's blob
|
|
11
|
+
* schemas at the root and elsewhere under schema/, the API read models (rpc/) and the examples (example/). */
|
|
12
|
+
export declare const LIBRARY_CORE: ReadonlySet<string>;
|
|
13
|
+
export declare const isLibraryCore: (name: string) => boolean;
|
|
14
|
+
/** hm:// URL (or bare name) -> bundled-schema key (basename, no .json). */
|
|
15
|
+
export declare function refToName(ref: string): string;
|
|
16
|
+
/** bundled-schema key (basename) -> its canonical library URL, hm://hyper.media/<name>. */
|
|
17
|
+
export declare function nameToUrl(name: string): string | null;
|
|
18
|
+
/** The canonical kind URL for a primitive kind (map, list, string, …). Schemas
|
|
19
|
+
* authored in-app must use this so they validate against the meta-schema. */
|
|
20
|
+
export declare function kindUrl(kind: string): string;
|
|
21
|
+
/** The map kind URL (the shape every struct/metadata schema declares). */
|
|
22
|
+
export declare const MAP_URL: string;
|
|
23
|
+
/** The struct kind: a map with known, named fields (`properties`). Same bytes as a map. */
|
|
24
|
+
export declare const STRUCT_URL: string;
|
|
25
|
+
/** Published DAG-CBOR CID for a schema, by basename or ANY hm:// URL form
|
|
26
|
+
* — normalized through the bundle. */
|
|
27
|
+
export declare function schemaCid(nameOrUrl: string): string | undefined;
|
|
28
|
+
/** A bundled schema's basename for a published CID (accepts a bare CID or an ipfs://<cid> URL). */
|
|
29
|
+
export declare function nameForCid(cidOrUrl: string): string | undefined;
|
|
30
|
+
/** The bundled Hypermedia schema for a published CID (or ipfs://<cid> URL), if known. */
|
|
31
|
+
export declare function schemaForCid(cidOrUrl: string): HypermediaSchema | undefined;
|
|
32
|
+
export declare function loadFrom(registry: SchemaRegistry, ref: string): HypermediaSchema | undefined;
|
|
33
|
+
/** Resolve a ref against the bundled standard library. */
|
|
34
|
+
export declare const load: (ref: string) => HypermediaSchema | undefined;
|
|
35
|
+
export declare const isLink: (d: any) => boolean;
|
|
36
|
+
export declare const isBytes: (d: any) => boolean;
|
|
37
|
+
export declare function typeOf(d: any): string;
|
|
38
|
+
export declare const kindOf: (t: string) => string;
|
|
39
|
+
/** True for a literal schema: a bare scalar, or `{value, description?}` with no other schema keys. */
|
|
40
|
+
export declare function isLiteralSchema(s: any): boolean;
|
|
41
|
+
/** The scalars a literal can be. */
|
|
42
|
+
export type HMLiteral = string | number | boolean | null;
|
|
43
|
+
/** A bare literal, typed as the schema it is. (`HypermediaSchema` is the map shape
|
|
44
|
+
* for static typing; at runtime a bare scalar is a schema too.) */
|
|
45
|
+
export declare const literalSchema: (v: HMLiteral) => HypermediaSchema;
|
|
46
|
+
/** The one value a literal schema accepts (either spelling). */
|
|
47
|
+
export declare const literalValue: (s: any) => unknown;
|
|
48
|
+
export type LiteralMember = {
|
|
49
|
+
value: unknown;
|
|
50
|
+
description?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The members of a literal schema (one) or a union whose every arm is a literal
|
|
54
|
+
* (each arm), in order — the options a form offers for the field. Null when the
|
|
55
|
+
* schema is anything else.
|
|
56
|
+
*/
|
|
57
|
+
export declare function literalMembers(schema: HypermediaSchema, reg?: SchemaRegistry): LiteralMember[] | null;
|
|
58
|
+
/** A struct field entry: the field's schema, whether a value must include it, what it is for. */
|
|
59
|
+
export type PropertyEntry = {
|
|
60
|
+
value: HypermediaSchema;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
description?: string;
|
|
63
|
+
};
|
|
64
|
+
/** A struct field. */
|
|
65
|
+
export type StructField = {
|
|
66
|
+
name: string;
|
|
67
|
+
schema: HypermediaSchema;
|
|
68
|
+
required: boolean;
|
|
69
|
+
description?: string;
|
|
70
|
+
};
|
|
71
|
+
/** A struct's fields, in declaration order. A `properties` entry always wraps its
|
|
72
|
+
* field's schema in `value` (a field whose schema is the literal `"x"` is `{value: "x"}`). */
|
|
73
|
+
export declare function structFields(schema: HypermediaSchema | undefined): StructField[];
|
|
74
|
+
/** The schema of one field, or undefined when the struct has no such field. */
|
|
75
|
+
export declare function fieldSchema(schema: HypermediaSchema | undefined, name: string): HypermediaSchema | undefined;
|
|
76
|
+
/** The names of the fields a value must include. */
|
|
77
|
+
export declare function requiredFieldNames(schema: HypermediaSchema | undefined): string[];
|
|
78
|
+
/** `properties` in the current shape. */
|
|
79
|
+
export declare function fieldsToProperties(fields: StructField[]): Record<string, PropertyEntry>;
|
|
80
|
+
/** Merge an extension node's refinements over its (resolved) parent — a subtype. */
|
|
81
|
+
export declare function mergeExtend(parent: HypermediaSchema, ext: HypermediaSchema): HypermediaSchema;
|
|
82
|
+
export type Resolved = {
|
|
83
|
+
schema: HypermediaSchema;
|
|
84
|
+
env: Record<string, any>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Resolve a node to a concrete schema, following var / params / ref+args
|
|
88
|
+
* (application) / ref+refinements (extension) / bare ref (include). `env` binds
|
|
89
|
+
* type variables. `reg` supplies additional (non-bundled) schemas.
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* The schema a node NAMES, when it names one rather than grounding in a kind: `type` holding any
|
|
93
|
+
* schema URL that is not one of the nine kinds. `ref` is the older spelling of the same thing and
|
|
94
|
+
* still resolves, so schemas published before the two keys merged keep working.
|
|
95
|
+
*/
|
|
96
|
+
export declare function namedSchemaUrl(schema: HypermediaSchema): string | null;
|
|
97
|
+
export declare function resolveSchema(schema: HypermediaSchema, env?: Record<string, any>, reg?: SchemaRegistry): Resolved;
|
|
98
|
+
/** Returns a list of error strings. Empty == valid. `env` binds type variables. */
|
|
99
|
+
export declare function validate(schema0: HypermediaSchema, data: any, path?: string, env0?: Record<string, any>, reg?: SchemaRegistry): string[];
|
|
100
|
+
/** Advisory (warn-don't-block) validation — identical checks to validate(). */
|
|
101
|
+
export declare const validateAdvisory: typeof validate;
|
|
102
|
+
/**
|
|
103
|
+
* True when a value is itself a Hypermedia schema — i.e. it validates against the
|
|
104
|
+
* meta-schema (`schema`). Replaces v1's `isSchemaBlob` (which matched a
|
|
105
|
+
* reserved `schema` link to a fixed meta-schema CID); here a blob IS a schema
|
|
106
|
+
* iff it conforms to the discriminated-union meta-schema.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isHypermediaSchema(value: unknown, reg?: SchemaRegistry): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* What a schema IS, as a page to open: a union, a type parameter, a core type
|
|
111
|
+
* (Struct, Map, String…), or the type it extends. Null when nothing names it.
|
|
112
|
+
*/
|
|
113
|
+
export declare function schemaShape(schema: HypermediaSchema | undefined): {
|
|
114
|
+
label: string;
|
|
115
|
+
slug: string;
|
|
116
|
+
} | null;
|
|
117
|
+
/**
|
|
118
|
+
* All schemas a schema node mentions (recursively), as basenames: every `type` — whether it names a
|
|
119
|
+
* core kind (a struct depends on `struct`, a map on `map`, so a kind's page lists who builds on it)
|
|
120
|
+
* or another schema — plus a reference's `target`, and the older `ref` spelling.
|
|
121
|
+
*/
|
|
122
|
+
export declare function collectRefs(schema: any, acc?: Set<string>): Set<string>;
|
|
123
|
+
/** Direct dependencies (schemas this one references), sorted, self excluded. */
|
|
124
|
+
export declare function dependencies(name: string, registry?: SchemaRegistry): string[];
|
|
125
|
+
/** Reverse dependencies (schemas that reference this one), sorted. */
|
|
126
|
+
export declare function dependents(name: string, registry?: SchemaRegistry): string[];
|
|
127
|
+
export { HM_SCHEMAS, HM_SCHEMA_MANIFEST };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KINDS,
|
|
3
|
+
LIBRARY_AUTHORITY,
|
|
4
|
+
LIBRARY_CORE,
|
|
5
|
+
MAP_URL,
|
|
6
|
+
STRUCT_URL,
|
|
7
|
+
collectRefs,
|
|
8
|
+
dependencies,
|
|
9
|
+
dependents,
|
|
10
|
+
fieldSchema,
|
|
11
|
+
fieldsToProperties,
|
|
12
|
+
isBytes,
|
|
13
|
+
isHypermediaSchema,
|
|
14
|
+
isLibraryCore,
|
|
15
|
+
isLink,
|
|
16
|
+
isLiteralSchema,
|
|
17
|
+
kindOf,
|
|
18
|
+
kindUrl,
|
|
19
|
+
literalMembers,
|
|
20
|
+
literalSchema,
|
|
21
|
+
literalValue,
|
|
22
|
+
load,
|
|
23
|
+
loadFrom,
|
|
24
|
+
mergeExtend,
|
|
25
|
+
nameForCid,
|
|
26
|
+
nameToUrl,
|
|
27
|
+
namedSchemaUrl,
|
|
28
|
+
refToName,
|
|
29
|
+
requiredFieldNames,
|
|
30
|
+
resolveSchema,
|
|
31
|
+
schemaCid,
|
|
32
|
+
schemaForCid,
|
|
33
|
+
schemaShape,
|
|
34
|
+
structFields,
|
|
35
|
+
typeOf,
|
|
36
|
+
validate,
|
|
37
|
+
validateAdvisory
|
|
38
|
+
} from "./chunk-JSNDXUPG.mjs";
|
|
39
|
+
import {
|
|
40
|
+
HM_SCHEMAS,
|
|
41
|
+
HM_SCHEMA_MANIFEST
|
|
42
|
+
} from "./chunk-ZWKMAGDU.mjs";
|
|
43
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
44
|
+
export {
|
|
45
|
+
HM_SCHEMAS,
|
|
46
|
+
HM_SCHEMA_MANIFEST,
|
|
47
|
+
KINDS,
|
|
48
|
+
LIBRARY_AUTHORITY,
|
|
49
|
+
LIBRARY_CORE,
|
|
50
|
+
MAP_URL,
|
|
51
|
+
STRUCT_URL,
|
|
52
|
+
collectRefs,
|
|
53
|
+
dependencies,
|
|
54
|
+
dependents,
|
|
55
|
+
fieldSchema,
|
|
56
|
+
fieldsToProperties,
|
|
57
|
+
isBytes,
|
|
58
|
+
isHypermediaSchema,
|
|
59
|
+
isLibraryCore,
|
|
60
|
+
isLink,
|
|
61
|
+
isLiteralSchema,
|
|
62
|
+
kindOf,
|
|
63
|
+
kindUrl,
|
|
64
|
+
literalMembers,
|
|
65
|
+
literalSchema,
|
|
66
|
+
literalValue,
|
|
67
|
+
load,
|
|
68
|
+
loadFrom,
|
|
69
|
+
mergeExtend,
|
|
70
|
+
nameForCid,
|
|
71
|
+
nameToUrl,
|
|
72
|
+
namedSchemaUrl,
|
|
73
|
+
refToName,
|
|
74
|
+
requiredFieldNames,
|
|
75
|
+
resolveSchema,
|
|
76
|
+
schemaCid,
|
|
77
|
+
schemaForCid,
|
|
78
|
+
schemaShape,
|
|
79
|
+
structFields,
|
|
80
|
+
typeOf,
|
|
81
|
+
validate,
|
|
82
|
+
validateAdvisory
|
|
83
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const HM_SCHEMA_MANIFEST: Record<string, string>;
|
|
2
|
+
/** schema name (its path in hypermedia/) -> the name and summary of the page that defines it. */
|
|
3
|
+
export declare const HM_SCHEMA_PAGES: Record<string, {
|
|
4
|
+
name: string;
|
|
5
|
+
summary?: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** schema name (its path in hypermedia/) -> schema object, e.g. "schema/map-schema", "example/person", "change". */
|
|
8
|
+
export declare const HM_SCHEMAS: Record<string, any>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { SeedClient } from './client';
|
|
2
|
+
import type { HMMetadata, UnpackedHypermediaId } from './hm-types';
|
|
3
|
+
import { type SchemaRegistry, type HypermediaSchema } from './schema-engine';
|
|
4
|
+
/** The bare DAG-CBOR CID of an `ipfs://<cid>` (or bare-CID) string, else null. */
|
|
5
|
+
export declare function bareCid(ref: string): string | null;
|
|
6
|
+
export type RefKind = {
|
|
7
|
+
kind: 'none';
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'cid';
|
|
10
|
+
cid: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'hm-bundled';
|
|
13
|
+
name: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'hm-doc';
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
/** Classify a schema reference without fetching anything. Accepts an `hm://`
|
|
19
|
+
* URL, an ipfs CID, OR a gateway/web URL (`https://host/hm/uid/path`) — the last
|
|
20
|
+
* is normalized to its `hm://` form so a pasted or search-picked web link
|
|
21
|
+
* resolves the same as the canonical URL. */
|
|
22
|
+
export declare function classifyRef(ref: string | null | undefined): RefKind;
|
|
23
|
+
/**
|
|
24
|
+
* An attributes schema, resolved: the struct a typed document's metadata is checked against.
|
|
25
|
+
* An `attributesSchema` names a struct of attributes directly (a person has a `surname`); there
|
|
26
|
+
* is no document wrapper to unwrap. Returns undefined for no schema.
|
|
27
|
+
*/
|
|
28
|
+
export declare function metadataSchemaOf(schema: HypermediaSchema | undefined, reg?: SchemaRegistry): HypermediaSchema | undefined;
|
|
29
|
+
/** The CID a document's `schemaDefinition` points at (`ipfs://<cid>`), if any. */
|
|
30
|
+
export declare function schemaDefinitionCid(metadata: unknown): string | null;
|
|
31
|
+
/** A client that can answer the two requests resolution needs. */
|
|
32
|
+
export type SchemaFetchClient = Pick<SeedClient, 'request'>;
|
|
33
|
+
/**
|
|
34
|
+
* The decoded blob at a CID, when it is a DAG-CBOR map (dag-json form, as the API returns it).
|
|
35
|
+
* A schema blob published with a `schema` link of its own (to the meta-schema, typically) is a
|
|
36
|
+
* conforming object like any other: the link is set aside, it is not part of the schema.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fetchSchemaBlob(client: SchemaFetchClient, cid: string): Promise<HypermediaSchema | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* The schema a document's metadata is checked against: the base document metadata
|
|
41
|
+
* (`metadata` — name, summary, icon, the schema-binding keys, …) extended by the
|
|
42
|
+
* type's metadata fields, kept OPEN (`values: {}`) so the binding keys and arbitrary extras are
|
|
43
|
+
* allowed. Standard fields keep their semantic types; the type's required fields stay required.
|
|
44
|
+
* The one rule every surface shares: the app's Attributes editor, the CLI's `document validate`
|
|
45
|
+
* and `space import --check`, and an agent's reads and writes. `extraProps` folds in any
|
|
46
|
+
* schema-keyed (`ipfs://<cid>`) fields.
|
|
47
|
+
*/
|
|
48
|
+
export declare function documentMetadataSchema(typeMetadataSchema: HypermediaSchema | undefined, extraProps?: Record<string, HypermediaSchema>, registry?: SchemaRegistry): HypermediaSchema;
|
|
49
|
+
export type ResolvedSchemaRef = {
|
|
50
|
+
kind: RefKind['kind'];
|
|
51
|
+
/** The schema, when the reference resolved. */
|
|
52
|
+
schema?: HypermediaSchema;
|
|
53
|
+
/** The schema blob's CID, when known — what a conforming blob links to via its `schema` key. */
|
|
54
|
+
cid?: string;
|
|
55
|
+
/** For an `hm-doc` reference: the type document's canonical URL. */
|
|
56
|
+
documentUrl?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Resolve one schema reference to its schema. Bundled references resolve without a fetch; a CID
|
|
60
|
+
* fetches the blob (bundled if known); a document URL fetches the document and follows its
|
|
61
|
+
* `schemaDefinition`. An unresolvable reference yields `schema: undefined`, never a throw —
|
|
62
|
+
* validation is advisory, and a type you cannot fetch is not a reason to refuse a write.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveSchemaRef(client: SchemaFetchClient, ref: string): Promise<ResolvedSchemaRef>;
|
|
65
|
+
/**
|
|
66
|
+
* The references a schema makes to schemas outside the bundled library — `hm://` document URLs
|
|
67
|
+
* and `ipfs://` blobs — in the order they appear, each once. What `hydrateSchemaRegistry` will
|
|
68
|
+
* fetch, so a caller can key a cache on it without fetching anything.
|
|
69
|
+
*/
|
|
70
|
+
export declare function externalSchemaRefs(schema: HypermediaSchema | undefined): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Fetch every reference a schema makes that the registry (and the bundled library) cannot
|
|
73
|
+
* already answer, recursively, so `resolveSchema` / `validate` can follow `ref`s to types
|
|
74
|
+
* published under any account. Returns the registry (mutated and returned for chaining).
|
|
75
|
+
*/
|
|
76
|
+
export declare function hydrateSchemaRegistry(client: SchemaFetchClient, schema: HypermediaSchema | undefined, registry?: SchemaRegistry): Promise<SchemaRegistry>;
|
|
77
|
+
export type EffectiveSchemaRef = {
|
|
78
|
+
ref: string | null;
|
|
79
|
+
source: 'own' | 'inherited' | 'none';
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The reference to a document's EFFECTIVE attributes schema: its own metadata `attributesSchema`,
|
|
83
|
+
* else its parent's `childAttributesSchema` (one level: a folder types its direct children), else none.
|
|
84
|
+
*/
|
|
85
|
+
export declare function effectiveSchemaRef(client: SchemaFetchClient, id: UnpackedHypermediaId, metadata: HMMetadata | Record<string, unknown> | undefined): Promise<EffectiveSchemaRef>;
|
|
86
|
+
/** The canonical `hm://` URL of a document id, for messages. */
|
|
87
|
+
export declare const documentUrlOf: (id: UnpackedHypermediaId) => string;
|
|
88
|
+
/** True when a value is (or is spelled as) a literal that a form has nothing to edit for. */
|
|
89
|
+
export declare const isFixedLiteral: (schema: HypermediaSchema | undefined) => boolean;
|
|
90
|
+
export type LoadedSchemaRef = {
|
|
91
|
+
schema: HypermediaSchema;
|
|
92
|
+
/** The schema blob's CID when known — a conforming blob links to it via `schema`. */
|
|
93
|
+
cid?: string;
|
|
94
|
+
/** Every type the schema references, fetched, so validation can follow refs. */
|
|
95
|
+
registry: SchemaRegistry;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A schema by reference — a bundled library name or URL, an `ipfs://<cid>`, or a type document's
|
|
99
|
+
* `hm://` URL — or given inline as an object, with every reference it makes fetched into a
|
|
100
|
+
* registry. Throws with a reason when the reference cannot be resolved.
|
|
101
|
+
*/
|
|
102
|
+
export declare function loadSchemaRef(client: SchemaFetchClient, ref: string | HypermediaSchema): Promise<LoadedSchemaRef>;
|
|
103
|
+
export type DocumentSchemaCheck = {
|
|
104
|
+
/** The reference the document's effective schema came from, or null when it has none. */
|
|
105
|
+
schema: string | null;
|
|
106
|
+
via: 'own' | 'inherited' | 'none';
|
|
107
|
+
/** The metadata fields the type requires, and those the document lacks. */
|
|
108
|
+
required: string[];
|
|
109
|
+
missing: string[];
|
|
110
|
+
/** Violations of the metadata (or of the whole document, with `content`). */
|
|
111
|
+
violations: string[];
|
|
112
|
+
/** Set when the schema could not be resolved; the check is then inconclusive, not failed. */
|
|
113
|
+
error?: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Check a document against its effective attributes schema: its own `attributesSchema`, else the
|
|
117
|
+
* parent's `childAttributesSchema`. Advisory: an unresolvable type is reported in `error`, never
|
|
118
|
+
* thrown. With `content`, the block tree is also checked against the base document's content schema.
|
|
119
|
+
*/
|
|
120
|
+
export declare function checkDocumentSchema(client: SchemaFetchClient, id: UnpackedHypermediaId, metadata: Record<string, unknown> | undefined, content?: unknown): Promise<DocumentSchemaCheck>;
|
|
121
|
+
/** Whether a dag-json value is a plain map (the only shape that can carry a schema link). */
|
|
122
|
+
export declare const isPlainMap: (value: unknown) => value is Record<string, unknown>;
|
|
123
|
+
/** The `schema` link a blob carries (`{"/": <cid>}` or a URL string), if any. */
|
|
124
|
+
export declare function blobSchemaRef(value: unknown): string | null;
|
|
125
|
+
/**
|
|
126
|
+
* The value without its `schema` link. A published object links to its type through a `schema`
|
|
127
|
+
* key that the type itself does not declare, so the link is set aside before validating — the
|
|
128
|
+
* same rule the app's blob editor follows.
|
|
129
|
+
*/
|
|
130
|
+
export declare function withoutSchemaLink(value: unknown): unknown;
|
|
131
|
+
/**
|
|
132
|
+
* Whether the schema a document's `schemaDefinition` points at is a valid Hypermedia schema: the
|
|
133
|
+
* violations of the meta-schema, or the reason the reference could not be loaded. Empty when fine.
|
|
134
|
+
*/
|
|
135
|
+
export declare function checkSchemaDefinition(client: SchemaFetchClient, ref: string): Promise<string[]>;
|