@seed-hypermedia/client 0.0.89 → 0.0.91

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.
Files changed (50) hide show
  1. package/dist/auto-link.mjs +3 -3
  2. package/dist/blocks-to-markdown.mjs +2 -2
  3. package/dist/capability.mjs +2 -2
  4. package/dist/{chunk-GIO2JLKT.mjs → chunk-2X45222K.mjs} +34 -1
  5. package/dist/{chunk-7QKG43UV.mjs → chunk-5H44WPFO.mjs} +1 -1
  6. package/dist/{chunk-IW5GLPEG.mjs → chunk-5ZHBEPRC.mjs} +1 -1
  7. package/dist/{chunk-BMPK76B2.mjs → chunk-6FBJVBS6.mjs} +3 -3
  8. package/dist/{chunk-J45O2Y7E.mjs → chunk-EBGUVS7T.mjs} +2 -2
  9. package/dist/{chunk-ZVJGJE2L.mjs → chunk-GOKN5MFV.mjs} +1 -1
  10. package/dist/{chunk-I273FRIR.mjs → chunk-HMTFZNX7.mjs} +1 -1
  11. package/dist/{chunk-OOSTK7CM.mjs → chunk-IS7QPOMQ.mjs} +3 -3
  12. package/dist/chunk-JSNDXUPG.mjs +407 -0
  13. package/dist/{chunk-GN76IN3M.mjs → chunk-LZOORGGJ.mjs} +1 -1
  14. package/dist/{chunk-STKAE4YB.mjs → chunk-OIL62HNH.mjs} +1 -1
  15. package/dist/{chunk-7OWFPOHI.mjs → chunk-P5R4E4AU.mjs} +1 -1
  16. package/dist/{chunk-XB6E7EVC.mjs → chunk-QVRJGK77.mjs} +1 -1
  17. package/dist/{chunk-W3MTG26Q.mjs → chunk-RPXAWYOC.mjs} +4 -1
  18. package/dist/chunk-TZMLZHCZ.mjs +230 -0
  19. package/dist/{chunk-DVJ3XGXS.mjs → chunk-UQL3R7WC.mjs} +1 -1
  20. package/dist/chunk-VWSAFDOL.mjs +110 -0
  21. package/dist/chunk-ZWKMAGDU.mjs +10 -0
  22. package/dist/client.mjs +2 -2
  23. package/dist/comment.mjs +2 -2
  24. package/dist/dag-json.d.ts +52 -0
  25. package/dist/dag-json.mjs +23 -0
  26. package/dist/document-state.mjs +2 -2
  27. package/dist/editorblock-to-hmblock.mjs +2 -2
  28. package/dist/hm-resolver.mjs +2 -2
  29. package/dist/hm-types.d.ts +2031 -49
  30. package/dist/hm-types.mjs +9 -1
  31. package/dist/hmblock-to-editorblock.mjs +2 -2
  32. package/dist/index.mjs +27 -27
  33. package/dist/markdown-to-blocks.mjs +1 -1
  34. package/dist/pdf-to-blocks.mjs +3 -3
  35. package/dist/resource-read.mjs +4 -4
  36. package/dist/schema-engine.d.ts +127 -0
  37. package/dist/schema-engine.mjs +83 -0
  38. package/dist/schema-registry.generated.d.ts +8 -0
  39. package/dist/schema-registry.generated.mjs +11 -0
  40. package/dist/schema-resolve.d.ts +135 -0
  41. package/dist/schema-resolve.mjs +45 -0
  42. package/dist/schema-subtypes.d.ts +36 -0
  43. package/dist/schema-subtypes.mjs +94 -0
  44. package/dist/schema-types.generated.d.ts +1598 -0
  45. package/dist/schema-types.generated.mjs +0 -0
  46. package/dist/signed-blob.d.ts +63 -0
  47. package/dist/signed-blob.mjs +123 -0
  48. package/dist/tei-to-blocks.mjs +2 -2
  49. package/dist/unicode.mjs +1 -1
  50. package/package.json +1 -1
package/dist/hm-types.mjs CHANGED
@@ -109,6 +109,9 @@ import {
109
109
  HMListEventsInputSchema,
110
110
  HMListEventsOutputSchema,
111
111
  HMListEventsRequestSchema,
112
+ HMListRefsInputSchema,
113
+ HMListRefsOutputSchema,
114
+ HMListRefsRequestSchema,
112
115
  HMListedCommentDraftSchema,
113
116
  HMListedDraftReadSchema,
114
117
  HMListedDraftSchema,
@@ -137,6 +140,7 @@ import {
137
140
  HMRawCapabilitySchema,
138
141
  HMRawCitationSchema,
139
142
  HMRawDocumentChangeSchema,
143
+ HMRawRefSchema,
140
144
  HMRedirectInfoSchema,
141
145
  HMRequestSchema,
142
146
  HMResolvedResourceSchema,
@@ -190,7 +194,7 @@ import {
190
194
  toNumber,
191
195
  unpackHmId,
192
196
  unpackedHmIdSchema
193
- } from "./chunk-GIO2JLKT.mjs";
197
+ } from "./chunk-2X45222K.mjs";
194
198
  import "./chunk-7P6ASYW6.mjs";
195
199
  export {
196
200
  BUILTIN_METADATA_KEYS,
@@ -303,6 +307,9 @@ export {
303
307
  HMListEventsInputSchema,
304
308
  HMListEventsOutputSchema,
305
309
  HMListEventsRequestSchema,
310
+ HMListRefsInputSchema,
311
+ HMListRefsOutputSchema,
312
+ HMListRefsRequestSchema,
306
313
  HMListedCommentDraftSchema,
307
314
  HMListedDraftReadSchema,
308
315
  HMListedDraftSchema,
@@ -331,6 +338,7 @@ export {
331
338
  HMRawCapabilitySchema,
332
339
  HMRawCitationSchema,
333
340
  HMRawDocumentChangeSchema,
341
+ HMRawRefSchema,
334
342
  HMRedirectInfoSchema,
335
343
  HMRequestSchema,
336
344
  HMResolvedResourceSchema,
@@ -2,8 +2,8 @@ import {
2
2
  annotationContains,
3
3
  hmBlockToEditorBlock,
4
4
  hmBlocksToEditorContent
5
- } from "./chunk-IW5GLPEG.mjs";
6
- import "./chunk-GIO2JLKT.mjs";
5
+ } from "./chunk-5ZHBEPRC.mjs";
6
+ import "./chunk-2X45222K.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-6FBJVBS6.mjs";
4
+ import {
5
+ annotationContains,
6
+ hmBlockToEditorBlock,
7
+ hmBlocksToEditorContent
8
+ } from "./chunk-5ZHBEPRC.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-XB6E7EVC.mjs";
18
+ } from "./chunk-QVRJGK77.mjs";
11
19
  import {
12
20
  pdfToBlocks
13
- } from "./chunk-7OWFPOHI.mjs";
21
+ } from "./chunk-P5R4E4AU.mjs";
14
22
  import {
15
23
  teiToBlocks
16
- } from "./chunk-ZVJGJE2L.mjs";
24
+ } from "./chunk-GOKN5MFV.mjs";
17
25
  import {
18
26
  embeddedPdfToBlocks
19
27
  } from "./chunk-2FJBS3V7.mjs";
20
28
  import {
21
- resolveIdWithClient
22
- } from "./chunk-BMPK76B2.mjs";
29
+ editorBlockToHMBlock,
30
+ editorBlocksToHMBlockNodes
31
+ } from "./chunk-LZOORGGJ.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-DVJ3XGXS.mjs";
41
- import {
42
- annotationContains,
43
- hmBlockToEditorBlock,
44
- hmBlocksToEditorContent
45
- } from "./chunk-IW5GLPEG.mjs";
49
+ } from "./chunk-UQL3R7WC.mjs";
46
50
  import {
47
51
  createSeedClient
48
- } from "./chunk-W3MTG26Q.mjs";
52
+ } from "./chunk-RPXAWYOC.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-7QKG43UV.mjs";
64
+ } from "./chunk-5H44WPFO.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-GN76IN3M.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-J45O2Y7E.mjs";
85
+ } from "./chunk-EBGUVS7T.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-STKAE4YB.mjs";
107
+ } from "./chunk-OIL62HNH.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-OOSTK7CM.mjs";
126
+ } from "./chunk-IS7QPOMQ.mjs";
127
127
  import {
128
128
  createCapability,
129
129
  resolveCapability
130
- } from "./chunk-I273FRIR.mjs";
130
+ } from "./chunk-HMTFZNX7.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-GIO2JLKT.mjs";
150
+ } from "./chunk-2X45222K.mjs";
151
151
  import "./chunk-3TPCJCVO.mjs";
152
152
  import "./chunk-7P6ASYW6.mjs";
153
153
  export {
@@ -5,7 +5,7 @@ import {
5
5
  parseFrontmatter,
6
6
  parseInlineFormatting,
7
7
  parseMarkdown
8
- } from "./chunk-XB6E7EVC.mjs";
8
+ } from "./chunk-QVRJGK77.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  flattenToOperations,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  pdfToBlocks
3
- } from "./chunk-7OWFPOHI.mjs";
4
- import "./chunk-ZVJGJE2L.mjs";
3
+ } from "./chunk-P5R4E4AU.mjs";
4
+ import "./chunk-GOKN5MFV.mjs";
5
5
  import "./chunk-2FJBS3V7.mjs";
6
6
  import "./chunk-PPAY4WZX.mjs";
7
- import "./chunk-GIO2JLKT.mjs";
7
+ import "./chunk-2X45222K.mjs";
8
8
  import "./chunk-7P6ASYW6.mjs";
9
9
  export {
10
10
  pdfToBlocks
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  resolveIdWithClient
3
- } from "./chunk-BMPK76B2.mjs";
4
- import "./chunk-DVJ3XGXS.mjs";
5
- import "./chunk-W3MTG26Q.mjs";
3
+ } from "./chunk-6FBJVBS6.mjs";
4
+ import "./chunk-UQL3R7WC.mjs";
5
+ import "./chunk-RPXAWYOC.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-GIO2JLKT.mjs";
11
+ import "./chunk-2X45222K.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,11 @@
1
+ import {
2
+ HM_SCHEMAS,
3
+ HM_SCHEMA_MANIFEST,
4
+ HM_SCHEMA_PAGES
5
+ } from "./chunk-ZWKMAGDU.mjs";
6
+ import "./chunk-7P6ASYW6.mjs";
7
+ export {
8
+ HM_SCHEMAS,
9
+ HM_SCHEMA_MANIFEST,
10
+ HM_SCHEMA_PAGES
11
+ };
@@ -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[]>;
@@ -0,0 +1,45 @@
1
+ import {
2
+ bareCid,
3
+ blobSchemaRef,
4
+ checkDocumentSchema,
5
+ checkSchemaDefinition,
6
+ classifyRef,
7
+ documentMetadataSchema,
8
+ documentUrlOf,
9
+ effectiveSchemaRef,
10
+ externalSchemaRefs,
11
+ fetchSchemaBlob,
12
+ hydrateSchemaRegistry,
13
+ isFixedLiteral,
14
+ isPlainMap,
15
+ loadSchemaRef,
16
+ metadataSchemaOf,
17
+ resolveSchemaRef,
18
+ schemaDefinitionCid,
19
+ withoutSchemaLink
20
+ } from "./chunk-TZMLZHCZ.mjs";
21
+ import "./chunk-JSNDXUPG.mjs";
22
+ import "./chunk-ZWKMAGDU.mjs";
23
+ import "./chunk-VWSAFDOL.mjs";
24
+ import "./chunk-2X45222K.mjs";
25
+ import "./chunk-7P6ASYW6.mjs";
26
+ export {
27
+ bareCid,
28
+ blobSchemaRef,
29
+ checkDocumentSchema,
30
+ checkSchemaDefinition,
31
+ classifyRef,
32
+ documentMetadataSchema,
33
+ documentUrlOf,
34
+ effectiveSchemaRef,
35
+ externalSchemaRefs,
36
+ fetchSchemaBlob,
37
+ hydrateSchemaRegistry,
38
+ isFixedLiteral,
39
+ isPlainMap,
40
+ loadSchemaRef,
41
+ metadataSchemaOf,
42
+ resolveSchemaRef,
43
+ schemaDefinitionCid,
44
+ withoutSchemaLink
45
+ };
@@ -0,0 +1,36 @@
1
+ import { type HypermediaSchema } from './schema-engine';
2
+ /**
3
+ * One key per schema, whatever spelling names it: a library name (`hm://hyper.media/x`, a legacy
4
+ * authority, or its published CID), a raw blob CID, or a canonical document URL (any version,
5
+ * gateway or `hm://` form). Null for a value that names no schema.
6
+ */
7
+ export declare function schemaRefKey(ref: string | null | undefined): string | null;
8
+ /**
9
+ * The schema this schema extends or includes: its `type` when that names another schema rather
10
+ * than a kind. A union, a literal or a kind-grounded node has no parent.
11
+ */
12
+ export declare function extensionParentRef(schema: HypermediaSchema | undefined): string | null;
13
+ /** A schema the closure may include: every spelling that names it, and what it extends. */
14
+ export type SchemaCandidate = {
15
+ /** Every reference string that names this schema (document URL, `ipfs://` CID, library URL). */
16
+ refs: string[];
17
+ /** The reference this schema extends or includes, if any. */
18
+ parent: string | null;
19
+ };
20
+ /** The bundled library as candidates: each schema under its library URL and published CID. */
21
+ export declare function libraryCandidates(): SchemaCandidate[];
22
+ export type SubtypeClosure = {
23
+ /** Normalized keys (`schemaRefKey`) of every schema in the closure. */
24
+ keys: Set<string>;
25
+ /** Every spelling of every schema in the closure — what a stored `attributesSchema` may equal. */
26
+ refs: string[];
27
+ };
28
+ /**
29
+ * The target plus every candidate whose extension chain reaches it, with every spelling of each
30
+ * collected. Candidates that merely re-spell a member (the target's own document and blob, say)
31
+ * contribute their spellings too. Cycles and unresolvable parents are harmless: the loop only ever
32
+ * adds, and stops when a pass adds nothing.
33
+ */
34
+ export declare function closeOverSubtypes(target: string, candidates: SchemaCandidate[]): SubtypeClosure;
35
+ /** Whether a document's effective attributes schema reference lies in the closure. */
36
+ export declare function inClosure(closure: SubtypeClosure | undefined, ref: string | null | undefined): boolean;