@seed-hypermedia/client 0.0.133 → 0.0.134
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/{chunk-T7SWLR32.mjs → chunk-37QDFTT6.mjs} +3 -3
- package/dist/{chunk-NEUDKUBC.mjs → chunk-BRNXLHBP.mjs} +108 -2
- package/dist/{chunk-JQKYF5NB.mjs → chunk-ITUEKIQD.mjs} +19 -5
- package/dist/schema-engine.d.ts +46 -2
- package/dist/schema-engine.mjs +18 -4
- package/dist/schema-registry.generated.mjs +1 -1
- package/dist/schema-resolve.d.ts +10 -1
- package/dist/schema-resolve.mjs +5 -3
- package/dist/schema-subtypes.mjs +3 -3
- package/dist/schema-types.generated.d.ts +34 -2
- package/dist/signed-blob.mjs +2 -2
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
HM_SCHEMAS,
|
|
3
3
|
HM_SCHEMA_MANIFEST,
|
|
4
4
|
HM_SCHEMA_PAGES
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-37QDFTT6.mjs";
|
|
6
6
|
|
|
7
7
|
// src/schema-engine.ts
|
|
8
8
|
var LIBRARY_AUTHORITY = "hyper.media";
|
|
@@ -158,7 +158,8 @@ function structFields(schema) {
|
|
|
158
158
|
name,
|
|
159
159
|
schema: (entry == null ? void 0 : entry.value) === void 0 ? {} : entry.value,
|
|
160
160
|
required: (entry == null ? void 0 : entry.required) === true,
|
|
161
|
-
description: typeof (entry == null ? void 0 : entry.description) === "string" ? entry.description : void 0
|
|
161
|
+
description: typeof (entry == null ? void 0 : entry.description) === "string" ? entry.description : void 0,
|
|
162
|
+
...entry && typeof entry === "object" && entry.default !== void 0 ? { default: entry.default } : {}
|
|
162
163
|
}));
|
|
163
164
|
}
|
|
164
165
|
function fieldSchema(schema, name) {
|
|
@@ -176,6 +177,7 @@ function fieldsToProperties(fields) {
|
|
|
176
177
|
const e = { value: f.schema };
|
|
177
178
|
if (f.required) e.required = true;
|
|
178
179
|
if (f.description) e.description = f.description;
|
|
180
|
+
if (f.default !== void 0) e.default = f.default;
|
|
179
181
|
out[f.name] = e;
|
|
180
182
|
}
|
|
181
183
|
return out;
|
|
@@ -310,6 +312,99 @@ function validate(schema0, data, path = "$", env0 = {}, reg = {}) {
|
|
|
310
312
|
return errors;
|
|
311
313
|
}
|
|
312
314
|
var validateAdvisory = validate;
|
|
315
|
+
var cloneValue = (v) => v !== null && typeof v === "object" ? JSON.parse(JSON.stringify(v)) : v;
|
|
316
|
+
function seedValue(schema, registry = {}) {
|
|
317
|
+
return seedWithEnv(schema, {}, registry);
|
|
318
|
+
}
|
|
319
|
+
function seedWithEnv(schema0, env, reg) {
|
|
320
|
+
return seedAt(schema0, env, reg, 0);
|
|
321
|
+
}
|
|
322
|
+
var MAX_SEED_DEPTH = 24;
|
|
323
|
+
function seedAt(schema0, env, reg, depth) {
|
|
324
|
+
const { schema, env: e } = resolveSchema(schema0, env, reg);
|
|
325
|
+
if (isLiteralSchema(schema)) return schema.value;
|
|
326
|
+
if (schema.anyOf) return schema.anyOf.length ? seedAt(schema.anyOf[0], e, reg, depth + 1) : void 0;
|
|
327
|
+
const kind = schema.type ? kindOf(schema.type) : null;
|
|
328
|
+
switch (kind) {
|
|
329
|
+
case "map":
|
|
330
|
+
case "struct": {
|
|
331
|
+
const o = {};
|
|
332
|
+
for (const f of structFields(schema)) {
|
|
333
|
+
if (f.default !== void 0) o[f.name] = cloneValue(f.default);
|
|
334
|
+
else if (f.required && depth < MAX_SEED_DEPTH) o[f.name] = seedAt(f.schema, e, reg, depth + 1);
|
|
335
|
+
}
|
|
336
|
+
return o;
|
|
337
|
+
}
|
|
338
|
+
case "list":
|
|
339
|
+
return [];
|
|
340
|
+
case "string":
|
|
341
|
+
return "";
|
|
342
|
+
case "integer":
|
|
343
|
+
case "float":
|
|
344
|
+
return 0;
|
|
345
|
+
case "boolean":
|
|
346
|
+
return false;
|
|
347
|
+
case "null":
|
|
348
|
+
return null;
|
|
349
|
+
case "link":
|
|
350
|
+
return { "/": "" };
|
|
351
|
+
case "bytes":
|
|
352
|
+
return { "/": { bytes: "" } };
|
|
353
|
+
default:
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function seedField(field, env = {}, reg = {}) {
|
|
358
|
+
return field.default !== void 0 ? cloneValue(field.default) : seedWithEnv(field.schema, env, reg);
|
|
359
|
+
}
|
|
360
|
+
function propertyDefaults(schema, registry = {}) {
|
|
361
|
+
if (!schema) return {};
|
|
362
|
+
const { schema: resolved } = resolveSchema(schema, {}, registry);
|
|
363
|
+
const out = {};
|
|
364
|
+
for (const f of structFields(resolved)) if (f.default !== void 0) out[f.name] = cloneValue(f.default);
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
function missingPropertyDefaults(schema, current, registry = {}) {
|
|
368
|
+
const defaults = propertyDefaults(schema, registry);
|
|
369
|
+
const held = current ?? {};
|
|
370
|
+
for (const key of Object.keys(defaults)) if (key in held && held[key] !== void 0) delete defaults[key];
|
|
371
|
+
return defaults;
|
|
372
|
+
}
|
|
373
|
+
function validateDefaults(schema, path = "$", env = {}, reg = {}) {
|
|
374
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return [];
|
|
375
|
+
let scope = env;
|
|
376
|
+
if (schema.params && typeof schema.params === "object") {
|
|
377
|
+
scope = { ...env };
|
|
378
|
+
for (const [p, def] of Object.entries(schema.params)) if (scope[p] === void 0) scope[p] = def;
|
|
379
|
+
}
|
|
380
|
+
const errors = [];
|
|
381
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
382
|
+
for (const [name, entry] of Object.entries(schema.properties)) {
|
|
383
|
+
if (!entry || typeof entry !== "object") continue;
|
|
384
|
+
const at = `${path}.properties.${name}`;
|
|
385
|
+
const value = entry.value === void 0 ? {} : entry.value;
|
|
386
|
+
if (entry.default !== void 0) errors.push(...validate(value, entry.default, `${at}.default`, scope, reg));
|
|
387
|
+
errors.push(...validateDefaults(value, `${at}.value`, scope, reg));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (schema.items) errors.push(...validateDefaults(schema.items, `${path}.items`, scope, reg));
|
|
391
|
+
if (schema.values) errors.push(...validateDefaults(schema.values, `${path}.values`, scope, reg));
|
|
392
|
+
if (Array.isArray(schema.anyOf))
|
|
393
|
+
schema.anyOf.forEach(
|
|
394
|
+
(arm, i) => errors.push(...validateDefaults(arm, `${path}.anyOf[${i}]`, scope, reg))
|
|
395
|
+
);
|
|
396
|
+
if (schema.params && typeof schema.params === "object")
|
|
397
|
+
for (const [p, def] of Object.entries(schema.params))
|
|
398
|
+
errors.push(...validateDefaults(def, `${path}.params.${p}`, scope, reg));
|
|
399
|
+
return errors;
|
|
400
|
+
}
|
|
401
|
+
function schemaErrors(value, reg = {}) {
|
|
402
|
+
const meta = HM_SCHEMAS["schema"];
|
|
403
|
+
if (!meta) return [];
|
|
404
|
+
const errors = validate(meta, value, "$", {}, reg);
|
|
405
|
+
if (errors.length || !value || typeof value !== "object") return errors;
|
|
406
|
+
return validateDefaults(value, "$", {}, reg);
|
|
407
|
+
}
|
|
313
408
|
function isHypermediaSchema(value, reg = {}) {
|
|
314
409
|
const meta = HM_SCHEMAS["schema"];
|
|
315
410
|
if (!meta || !value || typeof value !== "object") return false;
|
|
@@ -350,6 +445,10 @@ function collectRefs(schema, acc = /* @__PURE__ */ new Set()) {
|
|
|
350
445
|
if (typeof schema.target === "string") acc.add(refToName(schema.target));
|
|
351
446
|
for (const [k, v] of Object.entries(schema)) {
|
|
352
447
|
if (k === "ref" || k === "type" || k === "target") continue;
|
|
448
|
+
if (k === "properties" && v && typeof v === "object" && !Array.isArray(v)) {
|
|
449
|
+
for (const entry of Object.values(v)) collectRefs(entry == null ? void 0 : entry.value, acc);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
353
452
|
if (v && typeof v === "object") collectRefs(v, acc);
|
|
354
453
|
}
|
|
355
454
|
return acc;
|
|
@@ -400,6 +499,13 @@ export {
|
|
|
400
499
|
resolveSchema,
|
|
401
500
|
validate,
|
|
402
501
|
validateAdvisory,
|
|
502
|
+
seedValue,
|
|
503
|
+
seedWithEnv,
|
|
504
|
+
seedField,
|
|
505
|
+
propertyDefaults,
|
|
506
|
+
missingPropertyDefaults,
|
|
507
|
+
validateDefaults,
|
|
508
|
+
schemaErrors,
|
|
403
509
|
isHypermediaSchema,
|
|
404
510
|
schemaShape,
|
|
405
511
|
collectRefs,
|
|
@@ -4,16 +4,18 @@ import {
|
|
|
4
4
|
fieldsToProperties,
|
|
5
5
|
isLiteralSchema,
|
|
6
6
|
loadFrom,
|
|
7
|
+
missingPropertyDefaults,
|
|
7
8
|
refToName,
|
|
8
9
|
resolveSchema,
|
|
9
10
|
schemaCid,
|
|
11
|
+
schemaErrors,
|
|
10
12
|
schemaForCid,
|
|
11
13
|
structFields,
|
|
12
14
|
validate
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BRNXLHBP.mjs";
|
|
14
16
|
import {
|
|
15
17
|
HM_SCHEMAS
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-37QDFTT6.mjs";
|
|
17
19
|
import {
|
|
18
20
|
parseCidString
|
|
19
21
|
} from "./chunk-VWSAFDOL.mjs";
|
|
@@ -92,7 +94,9 @@ function referencesOf(schema, out = []) {
|
|
|
92
94
|
const node = schema;
|
|
93
95
|
for (const [key, value] of Object.entries(node)) {
|
|
94
96
|
if ((key === "ref" || key === "type") && typeof value === "string") out.push(value);
|
|
95
|
-
else if (key === "
|
|
97
|
+
else if (key === "properties" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
98
|
+
for (const entry of Object.values(value)) referencesOf(entry == null ? void 0 : entry.value, out);
|
|
99
|
+
} else if (key === "description" || key === "target" || key === "format" || key === "value") {
|
|
96
100
|
if (key === "value" && value && typeof value === "object") referencesOf(value, out);
|
|
97
101
|
} else if (value && typeof value === "object") referencesOf(value, out);
|
|
98
102
|
}
|
|
@@ -183,6 +187,16 @@ async function checkDocumentSchema(client, id, metadata, content) {
|
|
|
183
187
|
}
|
|
184
188
|
return { ...base, required, missing, violations };
|
|
185
189
|
}
|
|
190
|
+
async function newDocumentDefaults(client, id, metadata) {
|
|
191
|
+
try {
|
|
192
|
+
const effective = await effectiveSchemaRef(client, id, metadata);
|
|
193
|
+
if (!effective.ref || effective.source === "none") return {};
|
|
194
|
+
const loaded = await loadSchemaRef(client, effective.ref);
|
|
195
|
+
return missingPropertyDefaults(metadataSchemaOf(loaded.schema, loaded.registry), metadata, loaded.registry);
|
|
196
|
+
} catch {
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
186
200
|
var isPlainMap = (value) => !!value && typeof value === "object" && !Array.isArray(value) && !("/" in value);
|
|
187
201
|
function blobSchemaRef(value) {
|
|
188
202
|
if (!isPlainMap(value)) return null;
|
|
@@ -199,10 +213,9 @@ function withoutSchemaLink(value) {
|
|
|
199
213
|
return rest;
|
|
200
214
|
}
|
|
201
215
|
async function checkSchemaDefinition(client, ref) {
|
|
202
|
-
const meta = HM_SCHEMAS["schema"];
|
|
203
216
|
try {
|
|
204
217
|
const loaded = await loadSchemaRef(client, ref);
|
|
205
|
-
return
|
|
218
|
+
return schemaErrors(loaded.schema, loaded.registry);
|
|
206
219
|
} catch (error) {
|
|
207
220
|
return [error.message];
|
|
208
221
|
}
|
|
@@ -223,6 +236,7 @@ export {
|
|
|
223
236
|
isFixedLiteral,
|
|
224
237
|
loadSchemaRef,
|
|
225
238
|
checkDocumentSchema,
|
|
239
|
+
newDocumentDefaults,
|
|
226
240
|
isPlainMap,
|
|
227
241
|
blobSchemaRef,
|
|
228
242
|
withoutSchemaLink,
|
package/dist/schema-engine.d.ts
CHANGED
|
@@ -55,18 +55,24 @@ export type LiteralMember = {
|
|
|
55
55
|
* schema is anything else.
|
|
56
56
|
*/
|
|
57
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
|
|
58
|
+
/** A struct field entry: the field's schema, whether a value must include it, what it is for, and the
|
|
59
|
+
* value a new struct starts with. */
|
|
59
60
|
export type PropertyEntry = {
|
|
60
61
|
value: HypermediaSchema;
|
|
61
62
|
required?: boolean;
|
|
62
63
|
description?: string;
|
|
64
|
+
default?: unknown;
|
|
63
65
|
};
|
|
64
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* A struct field. `default` is the value an editor writes into a NEW struct for this field; absent
|
|
68
|
+
* (undefined) means the field has none. It is never a fallback for a value that lacks the field.
|
|
69
|
+
*/
|
|
65
70
|
export type StructField = {
|
|
66
71
|
name: string;
|
|
67
72
|
schema: HypermediaSchema;
|
|
68
73
|
required: boolean;
|
|
69
74
|
description?: string;
|
|
75
|
+
default?: unknown;
|
|
70
76
|
};
|
|
71
77
|
/** A struct's fields, in declaration order. A `properties` entry always wraps its
|
|
72
78
|
* field's schema in `value` (a field whose schema is the literal `"x"` is `{value: "x"}`). */
|
|
@@ -99,6 +105,44 @@ export declare function resolveSchema(schema: HypermediaSchema, env?: Record<str
|
|
|
99
105
|
export declare function validate(schema0: HypermediaSchema, data: any, path?: string, env0?: Record<string, any>, reg?: SchemaRegistry): string[];
|
|
100
106
|
/** Advisory (warn-don't-block) validation — identical checks to validate(). */
|
|
101
107
|
export declare const validateAdvisory: typeof validate;
|
|
108
|
+
/**
|
|
109
|
+
* The value a new instance of a schema starts with. A struct gets every property that has a
|
|
110
|
+
* `default` (required or optional) set to a copy of it, and every required property without one
|
|
111
|
+
* seeded from its own schema, so nested structs pick up their own defaults. Optional properties
|
|
112
|
+
* without a default are left out. A property's default is used whole: it is not merged with the
|
|
113
|
+
* defaults of a nested struct, and it is never dereferenced when it is a link or a reference.
|
|
114
|
+
* A list starts empty; each item added later is seeded from the item schema. A union starts as
|
|
115
|
+
* its first arm.
|
|
116
|
+
*/
|
|
117
|
+
export declare function seedValue(schema: HypermediaSchema, registry?: SchemaRegistry): unknown;
|
|
118
|
+
/** {@link seedValue} under bound type variables (the form passes its own `env` down). */
|
|
119
|
+
export declare function seedWithEnv(schema0: HypermediaSchema, env: Record<string, any>, reg: SchemaRegistry): unknown;
|
|
120
|
+
/** The value a field starts with when it is added to a struct: its property default, else a seed of its schema. */
|
|
121
|
+
export declare function seedField(field: StructField, env?: Record<string, any>, reg?: SchemaRegistry): unknown;
|
|
122
|
+
/**
|
|
123
|
+
* The declared defaults of a struct's own properties, by field name, each a fresh copy. Only what
|
|
124
|
+
* the schema states: nothing is synthesized for a property without a default. This is what a new
|
|
125
|
+
* typed document's attributes start with.
|
|
126
|
+
*/
|
|
127
|
+
export declare function propertyDefaults(schema: HypermediaSchema | undefined, registry?: SchemaRegistry): Record<string, unknown>;
|
|
128
|
+
/**
|
|
129
|
+
* The property defaults a NEW value still lacks: every declared default whose key `current` has
|
|
130
|
+
* never held. A key that is present counts as held whatever its value, a `null` tombstone included
|
|
131
|
+
* (the author removed it), so applying this twice never brings a removed field back.
|
|
132
|
+
*/
|
|
133
|
+
export declare function missingPropertyDefaults(schema: HypermediaSchema | undefined, current: Record<string, unknown> | null | undefined, registry?: SchemaRegistry): Record<string, unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* The violations of every property `default` in a schema against that property's `value` schema,
|
|
136
|
+
* at any depth (nested structs, list items, map values, union arms, type-parameter defaults).
|
|
137
|
+
* The meta-schema cannot say this, since the type of `default` depends on a sibling key, so it is
|
|
138
|
+
* its own check. Schemas the node only names (`type: <url>`) are checked where they are defined.
|
|
139
|
+
*/
|
|
140
|
+
export declare function validateDefaults(schema: HypermediaSchema, path?: string, env?: Record<string, any>, reg?: SchemaRegistry): string[];
|
|
141
|
+
/**
|
|
142
|
+
* Everything wrong with a value as a schema: its violations of the meta-schema, then, when it is
|
|
143
|
+
* well formed, the property defaults that do not match their own property's schema.
|
|
144
|
+
*/
|
|
145
|
+
export declare function schemaErrors(value: unknown, reg?: SchemaRegistry): string[];
|
|
102
146
|
/**
|
|
103
147
|
* True when a value is itself a Hypermedia schema — i.e. it validates against the
|
|
104
148
|
* meta-schema (`schema`). Replaces v1's `isSchemaBlob` (which matched a
|
package/dist/schema-engine.mjs
CHANGED
|
@@ -22,24 +22,31 @@ import {
|
|
|
22
22
|
load,
|
|
23
23
|
loadFrom,
|
|
24
24
|
mergeExtend,
|
|
25
|
+
missingPropertyDefaults,
|
|
25
26
|
nameForCid,
|
|
26
27
|
nameToUrl,
|
|
27
28
|
namedSchemaUrl,
|
|
29
|
+
propertyDefaults,
|
|
28
30
|
refToName,
|
|
29
31
|
requiredFieldNames,
|
|
30
32
|
resolveSchema,
|
|
31
33
|
schemaCid,
|
|
34
|
+
schemaErrors,
|
|
32
35
|
schemaForCid,
|
|
33
36
|
schemaShape,
|
|
37
|
+
seedField,
|
|
38
|
+
seedValue,
|
|
39
|
+
seedWithEnv,
|
|
34
40
|
structFields,
|
|
35
41
|
typeOf,
|
|
36
42
|
validate,
|
|
37
|
-
validateAdvisory
|
|
38
|
-
|
|
43
|
+
validateAdvisory,
|
|
44
|
+
validateDefaults
|
|
45
|
+
} from "./chunk-BRNXLHBP.mjs";
|
|
39
46
|
import {
|
|
40
47
|
HM_SCHEMAS,
|
|
41
48
|
HM_SCHEMA_MANIFEST
|
|
42
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-37QDFTT6.mjs";
|
|
43
50
|
import "./chunk-7P6ASYW6.mjs";
|
|
44
51
|
export {
|
|
45
52
|
HM_SCHEMAS,
|
|
@@ -67,17 +74,24 @@ export {
|
|
|
67
74
|
load,
|
|
68
75
|
loadFrom,
|
|
69
76
|
mergeExtend,
|
|
77
|
+
missingPropertyDefaults,
|
|
70
78
|
nameForCid,
|
|
71
79
|
nameToUrl,
|
|
72
80
|
namedSchemaUrl,
|
|
81
|
+
propertyDefaults,
|
|
73
82
|
refToName,
|
|
74
83
|
requiredFieldNames,
|
|
75
84
|
resolveSchema,
|
|
76
85
|
schemaCid,
|
|
86
|
+
schemaErrors,
|
|
77
87
|
schemaForCid,
|
|
78
88
|
schemaShape,
|
|
89
|
+
seedField,
|
|
90
|
+
seedValue,
|
|
91
|
+
seedWithEnv,
|
|
79
92
|
structFields,
|
|
80
93
|
typeOf,
|
|
81
94
|
validate,
|
|
82
|
-
validateAdvisory
|
|
95
|
+
validateAdvisory,
|
|
96
|
+
validateDefaults
|
|
83
97
|
};
|
package/dist/schema-resolve.d.ts
CHANGED
|
@@ -118,6 +118,14 @@ export type DocumentSchemaCheck = {
|
|
|
118
118
|
* thrown. With `content`, the block tree is also checked against the base document's content schema.
|
|
119
119
|
*/
|
|
120
120
|
export declare function checkDocumentSchema(client: SchemaFetchClient, id: UnpackedHypermediaId, metadata: Record<string, unknown> | undefined, content?: unknown): Promise<DocumentSchemaCheck>;
|
|
121
|
+
/**
|
|
122
|
+
* The attributes a NEW document starts with: the property defaults of its effective attributes
|
|
123
|
+
* schema (its own `attributesSchema`, else the parent's `childAttributesSchema`) for every key
|
|
124
|
+
* `metadata` does not already hold. Only for a document being created. A document that already
|
|
125
|
+
* exists is never given a default, however its schema changes. An unresolvable type yields no
|
|
126
|
+
* defaults, never a throw.
|
|
127
|
+
*/
|
|
128
|
+
export declare function newDocumentDefaults(client: SchemaFetchClient, id: UnpackedHypermediaId, metadata: Record<string, unknown> | undefined): Promise<Record<string, unknown>>;
|
|
121
129
|
/** Whether a dag-json value is a plain map (the only shape that can carry a schema link). */
|
|
122
130
|
export declare const isPlainMap: (value: unknown) => value is Record<string, unknown>;
|
|
123
131
|
/** The `schema` link a blob carries (`{"/": <cid>}` or a URL string), if any. */
|
|
@@ -130,6 +138,7 @@ export declare function blobSchemaRef(value: unknown): string | null;
|
|
|
130
138
|
export declare function withoutSchemaLink(value: unknown): unknown;
|
|
131
139
|
/**
|
|
132
140
|
* Whether the schema a document's `schemaDefinition` points at is a valid Hypermedia schema: the
|
|
133
|
-
* violations of the meta-schema
|
|
141
|
+
* violations of the meta-schema and any property default that does not match its property, or the
|
|
142
|
+
* reason the reference could not be loaded. Empty when fine.
|
|
134
143
|
*/
|
|
135
144
|
export declare function checkSchemaDefinition(client: SchemaFetchClient, ref: string): Promise<string[]>;
|
package/dist/schema-resolve.mjs
CHANGED
|
@@ -14,12 +14,13 @@ import {
|
|
|
14
14
|
isPlainMap,
|
|
15
15
|
loadSchemaRef,
|
|
16
16
|
metadataSchemaOf,
|
|
17
|
+
newDocumentDefaults,
|
|
17
18
|
resolveSchemaRef,
|
|
18
19
|
schemaDefinitionCid,
|
|
19
20
|
withoutSchemaLink
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-ITUEKIQD.mjs";
|
|
22
|
+
import "./chunk-BRNXLHBP.mjs";
|
|
23
|
+
import "./chunk-37QDFTT6.mjs";
|
|
23
24
|
import "./chunk-VWSAFDOL.mjs";
|
|
24
25
|
import "./chunk-DGNAMVGH.mjs";
|
|
25
26
|
import "./chunk-AHQWDCHV.mjs";
|
|
@@ -40,6 +41,7 @@ export {
|
|
|
40
41
|
isPlainMap,
|
|
41
42
|
loadSchemaRef,
|
|
42
43
|
metadataSchemaOf,
|
|
44
|
+
newDocumentDefaults,
|
|
43
45
|
resolveSchemaRef,
|
|
44
46
|
schemaDefinitionCid,
|
|
45
47
|
withoutSchemaLink
|
package/dist/schema-subtypes.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
classifyRef
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ITUEKIQD.mjs";
|
|
4
4
|
import {
|
|
5
5
|
kindOf,
|
|
6
6
|
nameForCid,
|
|
7
7
|
nameToUrl,
|
|
8
8
|
schemaCid
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BRNXLHBP.mjs";
|
|
10
10
|
import {
|
|
11
11
|
HM_SCHEMAS
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-37QDFTT6.mjs";
|
|
13
13
|
import "./chunk-VWSAFDOL.mjs";
|
|
14
14
|
import {
|
|
15
15
|
unpackHmId
|
|
@@ -1119,6 +1119,36 @@ export type HMExampleStatus = 'draft' | 'published' | 'archived';
|
|
|
1119
1119
|
* Schema: hm://hyper.media/example/tags
|
|
1120
1120
|
*/
|
|
1121
1121
|
export type HMExampleTags = string[];
|
|
1122
|
+
/**
|
|
1123
|
+
* Example: Task Document
|
|
1124
|
+
* A document type for a task that shows property defaults: a new task starts as todo with priority 2, no tags and an unfinished checklist.
|
|
1125
|
+
* A document type for a task, showing property defaults: the values a new task starts with.
|
|
1126
|
+
* Schema: hm://hyper.media/example/task-doc
|
|
1127
|
+
*/
|
|
1128
|
+
export type HMExampleTaskDoc = {
|
|
1129
|
+
/** Where the task stands. A new task starts as `todo`. · default: "todo" */
|
|
1130
|
+
status: HMExampleTaskStatus;
|
|
1131
|
+
/** 1 is most urgent and 3 is least. A new task starts in the middle. · minimum: 1 · maximum: 3 · default: 2 */
|
|
1132
|
+
priority?: number;
|
|
1133
|
+
/** Labels for the task. A new task starts with an empty list. · default: [] */
|
|
1134
|
+
tags?: string[];
|
|
1135
|
+
/** The steps of the task. It has no default of its own, so a new task builds it from the defaults of its fields. */
|
|
1136
|
+
checklist: {
|
|
1137
|
+
/** Whether every step is finished. · default: false */
|
|
1138
|
+
done: boolean;
|
|
1139
|
+
/** The steps, in order. */
|
|
1140
|
+
steps: string[];
|
|
1141
|
+
};
|
|
1142
|
+
/** The day the task is due. It has no default, so a new task leaves it out. */
|
|
1143
|
+
due?: HMDate;
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* Example: Task Status
|
|
1147
|
+
* The state of a task: todo, doing, or done.
|
|
1148
|
+
* The state of a task: `todo`, `doing` or `done`.
|
|
1149
|
+
* Schema: hm://hyper.media/example/task-status
|
|
1150
|
+
*/
|
|
1151
|
+
export type HMExampleTaskStatus = 'todo' | 'doing' | 'done';
|
|
1122
1152
|
/**
|
|
1123
1153
|
* Example: Tree
|
|
1124
1154
|
* A node holding an integer value and links to child nodes.
|
|
@@ -1556,8 +1586,8 @@ export type HMSchemaMapSchema = {
|
|
|
1556
1586
|
};
|
|
1557
1587
|
/**
|
|
1558
1588
|
* Property
|
|
1559
|
-
* One field of a struct, holding its value schema, whether a value must include it,
|
|
1560
|
-
* One field of a struct: the schema its value must match, whether it is required,
|
|
1589
|
+
* One field of a struct, holding its value schema, whether a value must include it, a description of what it is for, and the default a new value starts with.
|
|
1590
|
+
* One field of a struct: the schema its value must match, whether it is required, what it is for, and the value a new struct starts with.
|
|
1561
1591
|
* Schema: hm://hyper.media/schema/property
|
|
1562
1592
|
*/
|
|
1563
1593
|
export type HMSchemaProperty = {
|
|
@@ -1567,6 +1597,8 @@ export type HMSchemaProperty = {
|
|
|
1567
1597
|
required?: boolean;
|
|
1568
1598
|
/** What the field is for, for people and for the editors that show it. */
|
|
1569
1599
|
description?: string;
|
|
1600
|
+
/** The value an editor writes into a new struct for this field. It must match `value`. It only initializes: a struct that lacks the field is not read as if it had this value. */
|
|
1601
|
+
default?: unknown;
|
|
1570
1602
|
};
|
|
1571
1603
|
/**
|
|
1572
1604
|
* Scalar schema
|
package/dist/signed-blob.mjs
CHANGED