@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.
- package/dist/auto-link.mjs +3 -3
- package/dist/blocks-to-markdown.mjs +2 -2
- package/dist/capability.mjs +2 -2
- package/dist/{chunk-GIO2JLKT.mjs → chunk-2X45222K.mjs} +34 -1
- package/dist/{chunk-7QKG43UV.mjs → chunk-5H44WPFO.mjs} +1 -1
- package/dist/{chunk-IW5GLPEG.mjs → chunk-5ZHBEPRC.mjs} +1 -1
- package/dist/{chunk-BMPK76B2.mjs → chunk-6FBJVBS6.mjs} +3 -3
- package/dist/{chunk-J45O2Y7E.mjs → chunk-EBGUVS7T.mjs} +2 -2
- package/dist/{chunk-ZVJGJE2L.mjs → chunk-GOKN5MFV.mjs} +1 -1
- package/dist/{chunk-I273FRIR.mjs → chunk-HMTFZNX7.mjs} +1 -1
- package/dist/{chunk-OOSTK7CM.mjs → chunk-IS7QPOMQ.mjs} +3 -3
- package/dist/chunk-JSNDXUPG.mjs +407 -0
- package/dist/{chunk-GN76IN3M.mjs → chunk-LZOORGGJ.mjs} +1 -1
- package/dist/{chunk-STKAE4YB.mjs → chunk-OIL62HNH.mjs} +1 -1
- package/dist/{chunk-7OWFPOHI.mjs → chunk-P5R4E4AU.mjs} +1 -1
- package/dist/{chunk-XB6E7EVC.mjs → chunk-QVRJGK77.mjs} +1 -1
- package/dist/{chunk-W3MTG26Q.mjs → chunk-RPXAWYOC.mjs} +4 -1
- package/dist/chunk-TZMLZHCZ.mjs +230 -0
- package/dist/{chunk-DVJ3XGXS.mjs → chunk-UQL3R7WC.mjs} +1 -1
- package/dist/chunk-VWSAFDOL.mjs +110 -0
- 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/hm-resolver.mjs +2 -2
- package/dist/hm-types.d.ts +2031 -49
- package/dist/hm-types.mjs +9 -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/auto-link.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
documentContainsLinkToChild,
|
|
5
5
|
documentHasSelfQuery,
|
|
6
6
|
shouldAutoLinkParent
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EBGUVS7T.mjs";
|
|
8
8
|
import "./chunk-O5MHN2EO.mjs";
|
|
9
9
|
import "./chunk-PJ2RFT5A.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-OIL62HNH.mjs";
|
|
11
11
|
import "./chunk-LVAHHQIK.mjs";
|
|
12
12
|
import "./chunk-DR3HJ6BV.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-2X45222K.mjs";
|
|
14
14
|
import "./chunk-7P6ASYW6.mjs";
|
|
15
15
|
export {
|
|
16
16
|
autoLinkChildToParent,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
emitFrontmatter,
|
|
8
8
|
parseDraftFilename,
|
|
9
9
|
slugify
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-IS7QPOMQ.mjs";
|
|
11
|
+
import "./chunk-2X45222K.mjs";
|
|
12
12
|
import "./chunk-7P6ASYW6.mjs";
|
|
13
13
|
export {
|
|
14
14
|
blocksToMarkdown,
|
package/dist/capability.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCapability,
|
|
3
3
|
resolveCapability
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HMTFZNX7.mjs";
|
|
5
5
|
import "./chunk-LVAHHQIK.mjs";
|
|
6
6
|
import "./chunk-NBCHK76Q.mjs";
|
|
7
7
|
import "./chunk-DR3HJ6BV.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-2X45222K.mjs";
|
|
9
9
|
import "./chunk-3TPCJCVO.mjs";
|
|
10
10
|
import "./chunk-7P6ASYW6.mjs";
|
|
11
11
|
export {
|
|
@@ -307,7 +307,9 @@ var HMDocumentMetadataSchema = z.object({
|
|
|
307
307
|
}).optional(),
|
|
308
308
|
// Import taxonomy fields (comma-separated values from external sources like WordPress)
|
|
309
309
|
importCategories: z.string().optional(),
|
|
310
|
-
importTags: z.string().optional()
|
|
310
|
+
importTags: z.string().optional(),
|
|
311
|
+
// JSON-stringified schema definition; present iff this document describes a schema (see notes/schema-as-document.md).
|
|
312
|
+
schemaDefinition: z.string().optional()
|
|
311
313
|
}).passthrough();
|
|
312
314
|
function hmMetadataJsonCorrection(metadata) {
|
|
313
315
|
if (typeof metadata.theme === "string") {
|
|
@@ -1085,6 +1087,31 @@ var HMListCapabilitiesRequestSchema = z.object({
|
|
|
1085
1087
|
input: HMListCapabilitiesInputSchema,
|
|
1086
1088
|
output: HMListCapabilitiesOutputSchema
|
|
1087
1089
|
});
|
|
1090
|
+
var HMRawRefSchema = z.object({
|
|
1091
|
+
id: z.string().optional(),
|
|
1092
|
+
account: z.string().optional(),
|
|
1093
|
+
path: z.string().optional(),
|
|
1094
|
+
target: z.object({
|
|
1095
|
+
version: z.object({ genesis: z.string().optional(), version: z.string().optional() }).optional(),
|
|
1096
|
+
redirect: z.object({ account: z.string().optional(), path: z.string().optional(), republish: z.boolean().optional() }).optional(),
|
|
1097
|
+
tombstone: z.object({}).optional()
|
|
1098
|
+
}).optional(),
|
|
1099
|
+
signer: z.string().optional(),
|
|
1100
|
+
capability: z.string().optional(),
|
|
1101
|
+
timestamp: z.string().optional(),
|
|
1102
|
+
generationInfo: z.object({ genesis: z.string().optional(), generation: z.string().optional() }).optional()
|
|
1103
|
+
});
|
|
1104
|
+
var HMListRefsOutputSchema = z.object({
|
|
1105
|
+
refs: z.array(HMRawRefSchema)
|
|
1106
|
+
});
|
|
1107
|
+
var HMListRefsInputSchema = z.object({
|
|
1108
|
+
targetId: unpackedHmIdSchema
|
|
1109
|
+
});
|
|
1110
|
+
var HMListRefsRequestSchema = z.object({
|
|
1111
|
+
key: z.literal("ListRefs"),
|
|
1112
|
+
input: HMListRefsInputSchema,
|
|
1113
|
+
output: HMListRefsOutputSchema
|
|
1114
|
+
});
|
|
1088
1115
|
var HMListDocumentCollaboratorsInputSchema = z.object({
|
|
1089
1116
|
targetId: unpackedHmIdSchema
|
|
1090
1117
|
});
|
|
@@ -1295,6 +1322,7 @@ var HMGetRequestSchema = z.discriminatedUnion("key", [
|
|
|
1295
1322
|
HMListCitationsRequestSchema,
|
|
1296
1323
|
HMListChangesRequestSchema,
|
|
1297
1324
|
HMListCapabilitiesRequestSchema,
|
|
1325
|
+
HMListRefsRequestSchema,
|
|
1298
1326
|
HMListDocumentCollaboratorsRequestSchema,
|
|
1299
1327
|
HMInteractionSummaryRequestSchema,
|
|
1300
1328
|
HMListCommentVersionsRequestSchema,
|
|
@@ -1328,6 +1356,7 @@ var HMRequestSchema = z.discriminatedUnion("key", [
|
|
|
1328
1356
|
HMListCitationsRequestSchema,
|
|
1329
1357
|
HMListChangesRequestSchema,
|
|
1330
1358
|
HMListCapabilitiesRequestSchema,
|
|
1359
|
+
HMListRefsRequestSchema,
|
|
1331
1360
|
HMListDocumentCollaboratorsRequestSchema,
|
|
1332
1361
|
HMInteractionSummaryRequestSchema,
|
|
1333
1362
|
HMListCommentVersionsRequestSchema,
|
|
@@ -1642,6 +1671,10 @@ export {
|
|
|
1642
1671
|
HMListCapabilitiesOutputSchema,
|
|
1643
1672
|
HMListCapabilitiesInputSchema,
|
|
1644
1673
|
HMListCapabilitiesRequestSchema,
|
|
1674
|
+
HMRawRefSchema,
|
|
1675
|
+
HMListRefsOutputSchema,
|
|
1676
|
+
HMListRefsInputSchema,
|
|
1677
|
+
HMListRefsRequestSchema,
|
|
1645
1678
|
HMListDocumentCollaboratorsInputSchema,
|
|
1646
1679
|
HMListDocumentCollaboratorsOutputSchema,
|
|
1647
1680
|
HMListDocumentCollaboratorsRequestSchema,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UQL3R7WC.mjs";
|
|
4
4
|
import {
|
|
5
5
|
createSeedClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RPXAWYOC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
unpackHmId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2X45222K.mjs";
|
|
10
10
|
|
|
11
11
|
// src/resource-read.ts
|
|
12
12
|
async function resolveIdWithClient(rawId, options = {}) {
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
} from "./chunk-PJ2RFT5A.mjs";
|
|
8
8
|
import {
|
|
9
9
|
resolveDocumentState
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OIL62HNH.mjs";
|
|
11
11
|
import {
|
|
12
12
|
entityQueryPathToHmIdPath,
|
|
13
13
|
packHmId,
|
|
14
14
|
unpackHmId
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2X45222K.mjs";
|
|
16
16
|
|
|
17
17
|
// src/auto-link.ts
|
|
18
18
|
import { CID } from "multiformats/cid";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeQuerySort,
|
|
3
3
|
unpackHmId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2X45222K.mjs";
|
|
5
5
|
|
|
6
6
|
// src/blocks-to-markdown.ts
|
|
7
7
|
import { stringify as stringifyYaml } from "yaml";
|
|
@@ -12,8 +12,8 @@ var FM_KEY_ORDER = [
|
|
|
12
12
|
"cover",
|
|
13
13
|
"displayAuthor",
|
|
14
14
|
"displayPublishTime",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"attributesSchema",
|
|
16
|
+
"childAttributesSchema",
|
|
17
17
|
"schemaDefinition",
|
|
18
18
|
"siteUrl",
|
|
19
19
|
"layout",
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HM_SCHEMAS,
|
|
3
|
+
HM_SCHEMA_MANIFEST,
|
|
4
|
+
HM_SCHEMA_PAGES
|
|
5
|
+
} from "./chunk-ZWKMAGDU.mjs";
|
|
6
|
+
|
|
7
|
+
// src/schema-engine.ts
|
|
8
|
+
var LIBRARY_AUTHORITY = "hyper.media";
|
|
9
|
+
var KINDS = ["null", "boolean", "integer", "float", "string", "bytes", "list", "map", "struct", "link"];
|
|
10
|
+
var LIBRARY_CORE = new Set(
|
|
11
|
+
[
|
|
12
|
+
...KINDS,
|
|
13
|
+
"any",
|
|
14
|
+
"none",
|
|
15
|
+
"date",
|
|
16
|
+
"date-time",
|
|
17
|
+
"property",
|
|
18
|
+
"schema",
|
|
19
|
+
"anyof",
|
|
20
|
+
"literal-schema",
|
|
21
|
+
"struct-schema",
|
|
22
|
+
"map-schema",
|
|
23
|
+
"list-schema",
|
|
24
|
+
"scalar-schema",
|
|
25
|
+
"link-schema",
|
|
26
|
+
"include-schema",
|
|
27
|
+
"var-schema"
|
|
28
|
+
].map((k) => KINDS.includes(k) || k === "schema" || k === "none" ? k : `schema/${k}`)
|
|
29
|
+
// kinds and the meta-schema live at the root,
|
|
30
|
+
);
|
|
31
|
+
var isLibraryCore = (name) => LIBRARY_CORE.has(name);
|
|
32
|
+
var KIND_URL = /^hm:\/\/hyper\.media\/([a-z]+)$/;
|
|
33
|
+
function refToName(ref) {
|
|
34
|
+
const m = /^hm:\/\/([^/]+)\/(.+)$/.exec(ref);
|
|
35
|
+
if (!m) return ref.replace(/\.schema\.json$|\.json$/, "");
|
|
36
|
+
const [, auth = "", name = ""] = m;
|
|
37
|
+
return auth === LIBRARY_AUTHORITY ? name : ref;
|
|
38
|
+
}
|
|
39
|
+
function nameToUrl(name) {
|
|
40
|
+
return `hm://${LIBRARY_AUTHORITY}/${name}`;
|
|
41
|
+
}
|
|
42
|
+
function kindUrl(kind) {
|
|
43
|
+
return `hm://${LIBRARY_AUTHORITY}/${kind}`;
|
|
44
|
+
}
|
|
45
|
+
var MAP_URL = kindUrl("map");
|
|
46
|
+
var STRUCT_URL = kindUrl("struct");
|
|
47
|
+
function schemaCid(nameOrUrl) {
|
|
48
|
+
const name = refToName(nameOrUrl);
|
|
49
|
+
const url = nameToUrl(name);
|
|
50
|
+
return url ? HM_SCHEMA_MANIFEST[url] : void 0;
|
|
51
|
+
}
|
|
52
|
+
var CID_TO_NAME = (() => {
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [url, cid] of Object.entries(HM_SCHEMA_MANIFEST)) {
|
|
55
|
+
const name = refToName(url);
|
|
56
|
+
if (name) out[cid] = name;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
})();
|
|
60
|
+
function nameForCid(cidOrUrl) {
|
|
61
|
+
const cid = cidOrUrl.replace(/^ipfs:\/\//i, "").split("/")[0] ?? "";
|
|
62
|
+
return CID_TO_NAME[cid];
|
|
63
|
+
}
|
|
64
|
+
function schemaForCid(cidOrUrl) {
|
|
65
|
+
const name = nameForCid(cidOrUrl);
|
|
66
|
+
return name ? HM_SCHEMAS[name] : void 0;
|
|
67
|
+
}
|
|
68
|
+
function loadFrom(registry, ref) {
|
|
69
|
+
const name = refToName(ref);
|
|
70
|
+
return registry[name] ?? HM_SCHEMAS[name];
|
|
71
|
+
}
|
|
72
|
+
var load = (ref) => loadFrom(HM_SCHEMAS, ref);
|
|
73
|
+
var isLink = (d) => d && typeof d === "object" && !Array.isArray(d) && Object.keys(d).length === 1 && typeof d["/"] === "string";
|
|
74
|
+
var isBytes = (d) => d && typeof d === "object" && !Array.isArray(d) && Object.keys(d).length === 1 && d["/"] && typeof d["/"] === "object" && Object.keys(d["/"]).length === 1 && typeof d["/"].bytes === "string";
|
|
75
|
+
function typeOf(d) {
|
|
76
|
+
if (d === null) return "null";
|
|
77
|
+
if (Array.isArray(d)) return "list";
|
|
78
|
+
if (typeof d === "object") return isLink(d) ? "link" : isBytes(d) ? "bytes" : "map";
|
|
79
|
+
if (typeof d === "number") return Number.isInteger(d) ? "integer" : "float";
|
|
80
|
+
return typeof d;
|
|
81
|
+
}
|
|
82
|
+
var kindOf = (t) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const k = (_a = KIND_URL.exec(t)) == null ? void 0 : _a[1];
|
|
85
|
+
return k && KINDS.includes(k) ? k : t;
|
|
86
|
+
};
|
|
87
|
+
function typeMatches(type, d) {
|
|
88
|
+
switch (type) {
|
|
89
|
+
case "null":
|
|
90
|
+
return d === null;
|
|
91
|
+
case "boolean":
|
|
92
|
+
return typeof d === "boolean";
|
|
93
|
+
case "integer":
|
|
94
|
+
return typeof d === "number" && Number.isInteger(d);
|
|
95
|
+
case "float":
|
|
96
|
+
return typeof d === "number";
|
|
97
|
+
// JSON can't distinguish 3.0 from 3
|
|
98
|
+
case "string":
|
|
99
|
+
return typeof d === "string";
|
|
100
|
+
case "bytes":
|
|
101
|
+
return isBytes(d);
|
|
102
|
+
case "list":
|
|
103
|
+
return Array.isArray(d);
|
|
104
|
+
case "map":
|
|
105
|
+
case "struct":
|
|
106
|
+
return typeOf(d) === "map";
|
|
107
|
+
case "link":
|
|
108
|
+
return isLink(d);
|
|
109
|
+
default:
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
var REFINE = [
|
|
114
|
+
"properties",
|
|
115
|
+
"required",
|
|
116
|
+
"values",
|
|
117
|
+
"items",
|
|
118
|
+
"format",
|
|
119
|
+
"pattern",
|
|
120
|
+
"minLength",
|
|
121
|
+
"maxLength",
|
|
122
|
+
"minimum",
|
|
123
|
+
"maximum",
|
|
124
|
+
"minItems",
|
|
125
|
+
"maxItems",
|
|
126
|
+
"target"
|
|
127
|
+
];
|
|
128
|
+
function isLiteralSchema(s) {
|
|
129
|
+
if (s === void 0) return false;
|
|
130
|
+
if (s === null || typeof s !== "object") return true;
|
|
131
|
+
if (Array.isArray(s)) return false;
|
|
132
|
+
return "value" in s && !("type" in s || "ref" in s || "anyOf" in s || "var" in s || "params" in s);
|
|
133
|
+
}
|
|
134
|
+
var literalSchema = (v) => v;
|
|
135
|
+
var literalValue = (s) => s !== null && typeof s === "object" ? s.value : s;
|
|
136
|
+
var literalNode = (s) => s !== null && typeof s === "object" ? s : { value: s };
|
|
137
|
+
function literalMembers(schema, reg = {}) {
|
|
138
|
+
const { schema: r } = resolveSchema(schema, {}, reg);
|
|
139
|
+
if (!r || r.__missing || r.__unbound) return null;
|
|
140
|
+
const member = (node) => ({
|
|
141
|
+
value: node.value,
|
|
142
|
+
description: typeof node.description === "string" ? node.description : void 0
|
|
143
|
+
});
|
|
144
|
+
if (isLiteralSchema(r)) return [member(r)];
|
|
145
|
+
if (!Array.isArray(r.anyOf) || r.anyOf.length === 0) return null;
|
|
146
|
+
const out = [];
|
|
147
|
+
for (const arm of r.anyOf) {
|
|
148
|
+
const { schema: a } = resolveSchema(arm, {}, reg);
|
|
149
|
+
if (!a || !isLiteralSchema(a)) return null;
|
|
150
|
+
out.push(member(a));
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function structFields(schema) {
|
|
155
|
+
if (!schema || !schema.properties || typeof schema.properties !== "object") return [];
|
|
156
|
+
return Object.entries(schema.properties).map(([name, entry]) => ({
|
|
157
|
+
name,
|
|
158
|
+
schema: (entry == null ? void 0 : entry.value) === void 0 ? {} : entry.value,
|
|
159
|
+
required: (entry == null ? void 0 : entry.required) === true,
|
|
160
|
+
description: typeof (entry == null ? void 0 : entry.description) === "string" ? entry.description : void 0
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
function fieldSchema(schema, name) {
|
|
164
|
+
var _a;
|
|
165
|
+
const entry = (_a = schema == null ? void 0 : schema.properties) == null ? void 0 : _a[name];
|
|
166
|
+
if (entry === void 0) return void 0;
|
|
167
|
+
return (entry == null ? void 0 : entry.value) === void 0 ? {} : entry.value;
|
|
168
|
+
}
|
|
169
|
+
function requiredFieldNames(schema) {
|
|
170
|
+
return structFields(schema).filter((f) => f.required).map((f) => f.name);
|
|
171
|
+
}
|
|
172
|
+
function fieldsToProperties(fields) {
|
|
173
|
+
const out = {};
|
|
174
|
+
for (const f of fields) {
|
|
175
|
+
const e = { value: f.schema };
|
|
176
|
+
if (f.required) e.required = true;
|
|
177
|
+
if (f.description) e.description = f.description;
|
|
178
|
+
out[f.name] = e;
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
function mergeExtend(parent, ext) {
|
|
183
|
+
const merged = { type: parent.type };
|
|
184
|
+
const byName = /* @__PURE__ */ new Map();
|
|
185
|
+
for (const f of structFields(parent)) byName.set(f.name, f);
|
|
186
|
+
for (const f of structFields(ext)) byName.set(f.name, f);
|
|
187
|
+
if (byName.size) merged.properties = fieldsToProperties(Array.from(byName.values()));
|
|
188
|
+
const values = ext.values ?? parent.values;
|
|
189
|
+
if (values) merged.values = values;
|
|
190
|
+
const items = ext.items ?? parent.items;
|
|
191
|
+
if (items) merged.items = items;
|
|
192
|
+
for (const k of LEAF_KEYS) {
|
|
193
|
+
const v = ext[k] ?? parent[k];
|
|
194
|
+
if (v !== void 0) merged[k] = v;
|
|
195
|
+
}
|
|
196
|
+
return merged;
|
|
197
|
+
}
|
|
198
|
+
var LEAF_KEYS = [
|
|
199
|
+
"format",
|
|
200
|
+
"pattern",
|
|
201
|
+
"minLength",
|
|
202
|
+
"maxLength",
|
|
203
|
+
"minimum",
|
|
204
|
+
"maximum",
|
|
205
|
+
"minItems",
|
|
206
|
+
"maxItems",
|
|
207
|
+
"target"
|
|
208
|
+
];
|
|
209
|
+
function namedSchemaUrl(schema) {
|
|
210
|
+
if (typeof schema.type === "string") return kindOf(schema.type) === schema.type ? schema.type : null;
|
|
211
|
+
return typeof schema.ref === "string" ? schema.ref : null;
|
|
212
|
+
}
|
|
213
|
+
function resolveSchema(schema, env = {}, reg = {}) {
|
|
214
|
+
if (isLiteralSchema(schema)) return { schema: literalNode(schema), env };
|
|
215
|
+
if (schema.params) {
|
|
216
|
+
const penv = { ...env };
|
|
217
|
+
for (const [p, def] of Object.entries(schema.params)) if (penv[p] === void 0) penv[p] = def;
|
|
218
|
+
const { params, ...body } = schema;
|
|
219
|
+
return resolveSchema(body, penv, reg);
|
|
220
|
+
}
|
|
221
|
+
if (schema.var !== void 0) {
|
|
222
|
+
const bound = env[schema.var];
|
|
223
|
+
if (bound === void 0) return { schema: { __unbound: schema.var }, env: {} };
|
|
224
|
+
return resolveSchema(bound, {}, reg);
|
|
225
|
+
}
|
|
226
|
+
const named = namedSchemaUrl(schema);
|
|
227
|
+
if (named && schema.anyOf === void 0) {
|
|
228
|
+
const target = loadFrom(reg, named);
|
|
229
|
+
if (!target) return { schema: { __missing: named }, env: {} };
|
|
230
|
+
if (schema.args) {
|
|
231
|
+
const argsEnv = {};
|
|
232
|
+
for (const [k, v] of Object.entries(schema.args)) argsEnv[k] = v && v.var !== void 0 ? env[v.var] : v;
|
|
233
|
+
return resolveSchema(target, argsEnv, reg);
|
|
234
|
+
}
|
|
235
|
+
const parent = resolveSchema(target, env, reg);
|
|
236
|
+
if (REFINE.some((k) => schema[k] !== void 0)) {
|
|
237
|
+
if (parent.schema.anyOf || parent.schema.__unbound) return parent;
|
|
238
|
+
return { schema: mergeExtend(parent.schema, schema), env: parent.env };
|
|
239
|
+
}
|
|
240
|
+
return parent;
|
|
241
|
+
}
|
|
242
|
+
return { schema, env };
|
|
243
|
+
}
|
|
244
|
+
var deepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
245
|
+
function validate(schema0, data, path = "$", env0 = {}, reg = {}) {
|
|
246
|
+
const { schema, env } = resolveSchema(schema0, env0, reg);
|
|
247
|
+
if (schema.__unbound) return [`${path}: unbound type variable "${schema.__unbound}"`];
|
|
248
|
+
if (schema.__missing) return [`${path}: unresolved reference "${schema.__missing}"`];
|
|
249
|
+
if (isLiteralSchema(schema))
|
|
250
|
+
return deepEqual(schema.value, data) ? [] : [`${path}: expected ${JSON.stringify(schema.value)}, got ${JSON.stringify(data)}`];
|
|
251
|
+
if (schema.anyOf) {
|
|
252
|
+
if (schema.anyOf.length === 0) return [`${path}: no value matches an empty union (none)`];
|
|
253
|
+
const attempts = schema.anyOf.map((v) => validate(v, data, path, env, reg));
|
|
254
|
+
if (attempts.some((e) => e.length === 0)) return [];
|
|
255
|
+
const topLevel = (errs) => errs.some((e) => e.startsWith(`${path}: expected`));
|
|
256
|
+
const best = attempts.slice().sort((a, b) => Number(topLevel(a)) - Number(topLevel(b)) || a.length - b.length)[0];
|
|
257
|
+
return [`${path}: matches none of the ${schema.anyOf.length} variants`, ...best];
|
|
258
|
+
}
|
|
259
|
+
const errors = [];
|
|
260
|
+
const kind = schema.type ? kindOf(schema.type) : null;
|
|
261
|
+
if (kind && !typeMatches(kind, data)) {
|
|
262
|
+
errors.push(`${path}: expected ${kind}, got ${typeOf(data)}`);
|
|
263
|
+
return errors;
|
|
264
|
+
}
|
|
265
|
+
if (kind === "map" || kind === "struct") {
|
|
266
|
+
for (const key of requiredFieldNames(schema))
|
|
267
|
+
if (!(key in data) || data[key] === void 0) errors.push(`${path}: missing required "${key}"`);
|
|
268
|
+
const closed = schema.properties && !schema.values;
|
|
269
|
+
for (const [key, value] of Object.entries(data)) {
|
|
270
|
+
if (value === void 0) continue;
|
|
271
|
+
const child = fieldSchema(schema, key) ?? schema.values;
|
|
272
|
+
if (child) errors.push(...validate(child, value, `${path}.${key}`, env, reg));
|
|
273
|
+
else if (closed) errors.push(`${path}: unexpected key "${key}"`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (kind === "list") {
|
|
277
|
+
if (schema.items)
|
|
278
|
+
data.forEach((item, i) => errors.push(...validate(schema.items, item, `${path}[${i}]`, env, reg)));
|
|
279
|
+
if (typeof schema.minItems === "number" && data.length < schema.minItems)
|
|
280
|
+
errors.push(`${path}: expected at least ${schema.minItems} items`);
|
|
281
|
+
if (typeof schema.maxItems === "number" && data.length > schema.maxItems)
|
|
282
|
+
errors.push(`${path}: expected at most ${schema.maxItems} items`);
|
|
283
|
+
}
|
|
284
|
+
if (kind === "string") {
|
|
285
|
+
const len = [...data].length;
|
|
286
|
+
if (typeof schema.minLength === "number" && len < schema.minLength)
|
|
287
|
+
errors.push(`${path}: expected at least ${schema.minLength} characters`);
|
|
288
|
+
if (typeof schema.maxLength === "number" && len > schema.maxLength)
|
|
289
|
+
errors.push(`${path}: expected at most ${schema.maxLength} characters`);
|
|
290
|
+
if (typeof schema.pattern === "string") {
|
|
291
|
+
let re = null;
|
|
292
|
+
try {
|
|
293
|
+
re = new RegExp(schema.pattern);
|
|
294
|
+
} catch {
|
|
295
|
+
re = null;
|
|
296
|
+
}
|
|
297
|
+
if (re && !re.test(data))
|
|
298
|
+
errors.push(
|
|
299
|
+
typeof schema.format === "string" ? `${path}: does not match pattern for format "${schema.format}"` : `${path}: does not match pattern`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (kind === "integer" || kind === "float") {
|
|
304
|
+
if (typeof schema.minimum === "number" && data < schema.minimum)
|
|
305
|
+
errors.push(`${path}: expected a value >= ${schema.minimum}`);
|
|
306
|
+
if (typeof schema.maximum === "number" && data > schema.maximum)
|
|
307
|
+
errors.push(`${path}: expected a value <= ${schema.maximum}`);
|
|
308
|
+
}
|
|
309
|
+
return errors;
|
|
310
|
+
}
|
|
311
|
+
var validateAdvisory = validate;
|
|
312
|
+
function isHypermediaSchema(value, reg = {}) {
|
|
313
|
+
const meta = HM_SCHEMAS["schema"];
|
|
314
|
+
if (!meta || !value || typeof value !== "object") return false;
|
|
315
|
+
return validate(meta, value, "$", {}, reg).length === 0;
|
|
316
|
+
}
|
|
317
|
+
function schemaShape(schema) {
|
|
318
|
+
var _a, _b;
|
|
319
|
+
if (schema === void 0) return null;
|
|
320
|
+
if (isLiteralSchema(schema)) return { label: "Literal", slug: "schema/literal-schema" };
|
|
321
|
+
if (typeof schema !== "object") return null;
|
|
322
|
+
if (Array.isArray(schema.anyOf)) return { label: "Union", slug: "schema/anyof" };
|
|
323
|
+
if (typeof schema.var === "string") return { label: `\u27E8${schema.var}\u27E9`, slug: "schema/var-schema" };
|
|
324
|
+
if (typeof schema.type === "string") {
|
|
325
|
+
const kind = kindOf(schema.type);
|
|
326
|
+
const slug = kind !== schema.type ? kind : refToName(schema.type);
|
|
327
|
+
if (HM_SCHEMAS[slug]) return { label: ((_a = HM_SCHEMA_PAGES[slug]) == null ? void 0 : _a.name) ?? slug, slug };
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
if (typeof schema.ref === "string") {
|
|
331
|
+
const slug = refToName(schema.ref);
|
|
332
|
+
return HM_SCHEMAS[slug] ? { label: ((_b = HM_SCHEMA_PAGES[slug]) == null ? void 0 : _b.name) ?? slug, slug } : null;
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
function collectRefs(schema, acc = /* @__PURE__ */ new Set()) {
|
|
337
|
+
if (!schema || typeof schema !== "object") return acc;
|
|
338
|
+
if (Array.isArray(schema)) {
|
|
339
|
+
for (const s of schema) collectRefs(s, acc);
|
|
340
|
+
return acc;
|
|
341
|
+
}
|
|
342
|
+
if (typeof schema.ref === "string") acc.add(refToName(schema.ref));
|
|
343
|
+
if (typeof schema.type === "string") {
|
|
344
|
+
const kind = kindOf(schema.type);
|
|
345
|
+
if (kind !== schema.type) {
|
|
346
|
+
if (HM_SCHEMAS[kind]) acc.add(kind);
|
|
347
|
+
} else acc.add(refToName(schema.type));
|
|
348
|
+
}
|
|
349
|
+
if (typeof schema.target === "string") acc.add(refToName(schema.target));
|
|
350
|
+
for (const [k, v] of Object.entries(schema)) {
|
|
351
|
+
if (k === "ref" || k === "type" || k === "target") continue;
|
|
352
|
+
if (v && typeof v === "object") collectRefs(v, acc);
|
|
353
|
+
}
|
|
354
|
+
return acc;
|
|
355
|
+
}
|
|
356
|
+
function dependencies(name, registry = HM_SCHEMAS) {
|
|
357
|
+
const schema = registry[name] ?? HM_SCHEMAS[name];
|
|
358
|
+
if (!schema) return [];
|
|
359
|
+
return Array.from(collectRefs(schema)).filter((n) => n !== name && (registry[n] || HM_SCHEMAS[n])).sort();
|
|
360
|
+
}
|
|
361
|
+
function dependents(name, registry = HM_SCHEMAS) {
|
|
362
|
+
const out = [];
|
|
363
|
+
for (const [other, schema] of Object.entries(registry)) {
|
|
364
|
+
if (other === name) continue;
|
|
365
|
+
if (collectRefs(schema).has(name)) out.push(other);
|
|
366
|
+
}
|
|
367
|
+
return out.sort();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export {
|
|
371
|
+
LIBRARY_AUTHORITY,
|
|
372
|
+
KINDS,
|
|
373
|
+
LIBRARY_CORE,
|
|
374
|
+
isLibraryCore,
|
|
375
|
+
refToName,
|
|
376
|
+
nameToUrl,
|
|
377
|
+
kindUrl,
|
|
378
|
+
MAP_URL,
|
|
379
|
+
STRUCT_URL,
|
|
380
|
+
schemaCid,
|
|
381
|
+
nameForCid,
|
|
382
|
+
schemaForCid,
|
|
383
|
+
loadFrom,
|
|
384
|
+
load,
|
|
385
|
+
isLink,
|
|
386
|
+
isBytes,
|
|
387
|
+
typeOf,
|
|
388
|
+
kindOf,
|
|
389
|
+
isLiteralSchema,
|
|
390
|
+
literalSchema,
|
|
391
|
+
literalValue,
|
|
392
|
+
literalMembers,
|
|
393
|
+
structFields,
|
|
394
|
+
fieldSchema,
|
|
395
|
+
requiredFieldNames,
|
|
396
|
+
fieldsToProperties,
|
|
397
|
+
mergeExtend,
|
|
398
|
+
namedSchemaUrl,
|
|
399
|
+
resolveSchema,
|
|
400
|
+
validate,
|
|
401
|
+
validateAdvisory,
|
|
402
|
+
isHypermediaSchema,
|
|
403
|
+
schemaShape,
|
|
404
|
+
collectRefs,
|
|
405
|
+
dependencies,
|
|
406
|
+
dependents
|
|
407
|
+
};
|
|
@@ -371,7 +371,7 @@ function createImageNode(alt, url, comment) {
|
|
|
371
371
|
function createTypedNode(visible, comment) {
|
|
372
372
|
const block = baseBlock(comment.type, comment);
|
|
373
373
|
const v = visible.trim();
|
|
374
|
-
const linkOnly = /^<([a-zA-Z][a-zA-Z0-9+.-]
|
|
374
|
+
const linkOnly = /^<((?:[a-zA-Z][a-zA-Z0-9+.-]*:|\.{1,2}\/)[^\s<>]*)>$/.exec(v);
|
|
375
375
|
const labeled = v.startsWith("[") ? readLink(v, 0) : null;
|
|
376
376
|
if (linkOnly) {
|
|
377
377
|
block.link = linkOnly[1];
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
HMActionSchema,
|
|
16
16
|
HMRequestSchema,
|
|
17
17
|
packHmId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2X45222K.mjs";
|
|
19
19
|
|
|
20
20
|
// src/client.ts
|
|
21
21
|
import { encode as cborEncode } from "@ipld/dag-cbor";
|
|
@@ -81,6 +81,9 @@ var QUERY_PARAM_SERIALIZERS = {
|
|
|
81
81
|
ListCapabilities: (input) => ({
|
|
82
82
|
targetId: packHmId(input.targetId)
|
|
83
83
|
}),
|
|
84
|
+
ListRefs: (input) => ({
|
|
85
|
+
targetId: packHmId(input.targetId)
|
|
86
|
+
}),
|
|
84
87
|
DiscoveryStatus: (input) => ({
|
|
85
88
|
uid: input.uid,
|
|
86
89
|
path: input.path.join("/"),
|