@seed-hypermedia/client 0.0.132 → 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/apps.mjs +10 -7
- package/dist/auto-link.mjs +3 -3
- package/dist/block-diff.d.ts +37 -0
- package/dist/block-diff.mjs +10 -1
- package/dist/block-edits.d.ts +33 -0
- package/dist/block-edits.mjs +9 -0
- package/dist/blocks-to-markdown.d.ts +21 -6
- package/dist/blocks-to-markdown.mjs +1 -1
- package/dist/{chunk-T7SWLR32.mjs → chunk-37QDFTT6.mjs} +3 -3
- package/dist/{chunk-SUVJSSHG.mjs → chunk-4ELQ4LJL.mjs} +68 -9
- package/dist/chunk-53PY4AWT.mjs +163 -0
- package/dist/{chunk-3KLY2B27.mjs → chunk-7FPJWOXB.mjs} +148 -1
- package/dist/{chunk-NEUDKUBC.mjs → chunk-BRNXLHBP.mjs} +108 -2
- package/dist/{chunk-JQKYF5NB.mjs → chunk-ITUEKIQD.mjs} +19 -5
- package/dist/{chunk-325UCLMT.mjs → chunk-O36UBGLF.mjs} +1 -1
- package/dist/{chunk-Y4PWAEJ5.mjs → chunk-QFIEZZYJ.mjs} +213 -328
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +53 -39
- package/dist/markdown-to-blocks.d.ts +25 -5
- package/dist/markdown-to-blocks.mjs +7 -3
- package/dist/prepare-change.mjs +2 -2
- package/dist/resource-read.mjs +1 -1
- 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
- package/dist/{chunk-6QBB3P3Q.mjs → chunk-KAZNQFXV.mjs} +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -31,15 +31,17 @@ export { resolveIdWithClient } from './resource-read';
|
|
|
31
31
|
export type { ResolveIdWithClientOptions, ResolvedIdWithClient } from './resource-read';
|
|
32
32
|
export { fileToIpfsBlobs, filesToIpfsBlobs, directoryToIpfsBlobs, normalizeDirectoryFilePath, resolveFileLinksInBlocks, hasFileLinks, } from './file-to-ipfs';
|
|
33
33
|
export type { CollectedBlob, IpfsDirectoryFile } from './file-to-ipfs';
|
|
34
|
-
export { parseMarkdown, flattenToOperations, parseInlineFormatting, parseFrontmatter, markdownBlockNodesToHMBlockNodes, hmAccountMentionUid, MarkdownFrontmatterError, } from './markdown-to-blocks';
|
|
34
|
+
export { parseMarkdown, flattenToOperations, parseInlineFormatting, parseFrontmatter, markdownBlockNodesToHMBlockNodes, hmAccountMentionUid, MarkdownFrontmatterError, MarkdownResolvedRangeError, stripResolvedRanges, } from './markdown-to-blocks';
|
|
35
35
|
export type { BlockNode, SeedBlock, Annotation, ParseMarkdownOptions } from './markdown-to-blocks';
|
|
36
36
|
export { collectMermaidBlocks, validateMermaidBlocks, assertValidMermaid, InvalidMermaidError, } from './mermaid-validation';
|
|
37
37
|
export type { MermaidParser, MermaidDiagramError, MermaidBlockLike } from './mermaid-validation';
|
|
38
38
|
export { blocksToMarkdown, emitFrontmatter, slugify, draftFilename, parseDraftFilename, documentToResolvedMarkdown, commentToResolvedMarkdown, contentToResolvedMarkdown, } from './blocks-to-markdown';
|
|
39
39
|
export type { ResolvedMarkdownOptions } from './blocks-to-markdown';
|
|
40
40
|
export type { BlocksToMarkdownOptions } from './blocks-to-markdown';
|
|
41
|
-
export { createBlocksMap, matchBlockIds, computeReplaceOps, hmBlockNodeToBlockNode, rebindTableIdentities, toAPIBlockNode, } from './block-diff';
|
|
42
|
-
export type { APIBlockNode, APIBlock } from './block-diff';
|
|
41
|
+
export { createBlocksMap, matchBlockIds, computeReplaceOps, hmBlockNodeToBlockNode, rebindTableIdentities, toAPIBlockNode, markdownUpdateTree, describeContentChange, } from './block-diff';
|
|
42
|
+
export type { APIBlockNode, APIBlock, ContentChange } from './block-diff';
|
|
43
|
+
export { applyBlockEdits, BlockEditError } from './block-edits';
|
|
44
|
+
export type { BlockEditResult } from './block-edits';
|
|
43
45
|
export { autoLinkChildToParent, createAutoLinkOps, documentContainsLinkToChild, documentHasSelfQuery, shouldAutoLinkParent, } from './auto-link';
|
|
44
46
|
export type { AutoLinkChildToParentOptions } from './auto-link';
|
|
45
47
|
export { clientBuiltDocumentUpdateBlobs, DEFAULT_MAX_PREPARED_CHANGE_BYTES, DEFAULT_PREPARE_TIMEOUT_MS, documentOperationsToChanges, documentUpdateBlobs, implausiblePreparedChange, isEmptyPreparedChange, nativeBlockToProtoBlock, preparableDocumentChanges, prepareDocumentUpdateBlobs, UnpreparableDocumentUpdateError, } from './prepare-change';
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InvalidMermaidError,
|
|
3
|
+
assertValidMermaid,
|
|
4
|
+
collectMermaidBlocks,
|
|
5
|
+
validateMermaidBlocks
|
|
6
|
+
} from "./chunk-TGCGGVEU.mjs";
|
|
1
7
|
import {
|
|
2
8
|
pdfToBlocks
|
|
3
9
|
} from "./chunk-YRNPRWYG.mjs";
|
|
@@ -18,21 +24,6 @@ import {
|
|
|
18
24
|
import {
|
|
19
25
|
keyfile_exports
|
|
20
26
|
} from "./chunk-EY6RQVAP.mjs";
|
|
21
|
-
import {
|
|
22
|
-
MarkdownFrontmatterError,
|
|
23
|
-
flattenToOperations,
|
|
24
|
-
hmAccountMentionUid,
|
|
25
|
-
markdownBlockNodesToHMBlockNodes,
|
|
26
|
-
parseFrontmatter,
|
|
27
|
-
parseInlineFormatting,
|
|
28
|
-
parseMarkdown
|
|
29
|
-
} from "./chunk-SUVJSSHG.mjs";
|
|
30
|
-
import {
|
|
31
|
-
InvalidMermaidError,
|
|
32
|
-
assertValidMermaid,
|
|
33
|
-
collectMermaidBlocks,
|
|
34
|
-
validateMermaidBlocks
|
|
35
|
-
} from "./chunk-TGCGGVEU.mjs";
|
|
36
27
|
import {
|
|
37
28
|
editorBlockToHMBlock,
|
|
38
29
|
editorBlocksToHMBlockNodes
|
|
@@ -53,6 +44,10 @@ import {
|
|
|
53
44
|
isGrobidAvailable,
|
|
54
45
|
processFulltextDocument
|
|
55
46
|
} from "./chunk-PPAY4WZX.mjs";
|
|
47
|
+
import {
|
|
48
|
+
createCapability,
|
|
49
|
+
resolveCapability
|
|
50
|
+
} from "./chunk-LDCWJXIP.mjs";
|
|
56
51
|
import {
|
|
57
52
|
createSeedClient
|
|
58
53
|
} from "./chunk-H2R4GYNV.mjs";
|
|
@@ -83,7 +78,7 @@ import {
|
|
|
83
78
|
documentContainsLinkToChild,
|
|
84
79
|
documentHasSelfQuery,
|
|
85
80
|
shouldAutoLinkParent
|
|
86
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-O36UBGLF.mjs";
|
|
87
82
|
import {
|
|
88
83
|
DEFAULT_MAX_PREPARED_CHANGE_BYTES,
|
|
89
84
|
DEFAULT_PREPARE_TIMEOUT_MS,
|
|
@@ -96,7 +91,16 @@ import {
|
|
|
96
91
|
nativeBlockToProtoBlock,
|
|
97
92
|
preparableDocumentChanges,
|
|
98
93
|
prepareDocumentUpdateBlobs
|
|
99
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-KAZNQFXV.mjs";
|
|
95
|
+
import {
|
|
96
|
+
describeRedirect,
|
|
97
|
+
editRefGeneration,
|
|
98
|
+
followRedirects,
|
|
99
|
+
followToDocument,
|
|
100
|
+
resolveDocumentState,
|
|
101
|
+
resolveEditableDocument,
|
|
102
|
+
sameDocumentVersion
|
|
103
|
+
} from "./chunk-QS6PIRUE.mjs";
|
|
100
104
|
import {
|
|
101
105
|
SeedClientError,
|
|
102
106
|
SeedNetworkError,
|
|
@@ -117,24 +121,39 @@ import {
|
|
|
117
121
|
createTombstoneRef,
|
|
118
122
|
createVersionRef
|
|
119
123
|
} from "./chunk-PJ2RFT5A.mjs";
|
|
120
|
-
import
|
|
121
|
-
describeRedirect,
|
|
122
|
-
editRefGeneration,
|
|
123
|
-
followRedirects,
|
|
124
|
-
followToDocument,
|
|
125
|
-
resolveDocumentState,
|
|
126
|
-
resolveEditableDocument,
|
|
127
|
-
sameDocumentVersion
|
|
128
|
-
} from "./chunk-QS6PIRUE.mjs";
|
|
124
|
+
import "./chunk-LVAHHQIK.mjs";
|
|
129
125
|
import "./chunk-2MD3FXKB.mjs";
|
|
126
|
+
import "./chunk-GBSWXJGU.mjs";
|
|
127
|
+
import "./chunk-3TPCJCVO.mjs";
|
|
128
|
+
import {
|
|
129
|
+
toHMSigner,
|
|
130
|
+
toPrincipalSigner
|
|
131
|
+
} from "./chunk-DR3HJ6BV.mjs";
|
|
130
132
|
import {
|
|
131
133
|
computeReplaceOps,
|
|
132
134
|
createBlocksMap,
|
|
135
|
+
describeContentChange,
|
|
133
136
|
hmBlockNodeToBlockNode,
|
|
137
|
+
markdownUpdateTree,
|
|
134
138
|
matchBlockIds,
|
|
135
139
|
rebindTableIdentities,
|
|
136
140
|
toAPIBlockNode
|
|
137
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-7FPJWOXB.mjs";
|
|
142
|
+
import {
|
|
143
|
+
MarkdownFrontmatterError,
|
|
144
|
+
MarkdownResolvedRangeError,
|
|
145
|
+
flattenToOperations,
|
|
146
|
+
hmAccountMentionUid,
|
|
147
|
+
markdownBlockNodesToHMBlockNodes,
|
|
148
|
+
parseFrontmatter,
|
|
149
|
+
parseInlineFormatting,
|
|
150
|
+
parseMarkdown,
|
|
151
|
+
stripResolvedRanges
|
|
152
|
+
} from "./chunk-4ELQ4LJL.mjs";
|
|
153
|
+
import {
|
|
154
|
+
BlockEditError,
|
|
155
|
+
applyBlockEdits
|
|
156
|
+
} from "./chunk-53PY4AWT.mjs";
|
|
138
157
|
import {
|
|
139
158
|
blocksToMarkdown,
|
|
140
159
|
commentToResolvedMarkdown,
|
|
@@ -144,24 +163,13 @@ import {
|
|
|
144
163
|
emitFrontmatter,
|
|
145
164
|
parseDraftFilename,
|
|
146
165
|
slugify
|
|
147
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-QFIEZZYJ.mjs";
|
|
148
167
|
import {
|
|
149
168
|
extractCommentIdFromUrl,
|
|
150
169
|
hmDomainUrlToWebUrl,
|
|
151
170
|
resolveHypermediaUrl,
|
|
152
171
|
resolveId
|
|
153
172
|
} from "./chunk-Q7CWMEBZ.mjs";
|
|
154
|
-
import {
|
|
155
|
-
createCapability,
|
|
156
|
-
resolveCapability
|
|
157
|
-
} from "./chunk-LDCWJXIP.mjs";
|
|
158
|
-
import "./chunk-LVAHHQIK.mjs";
|
|
159
|
-
import "./chunk-GBSWXJGU.mjs";
|
|
160
|
-
import "./chunk-3TPCJCVO.mjs";
|
|
161
|
-
import {
|
|
162
|
-
toHMSigner,
|
|
163
|
-
toPrincipalSigner
|
|
164
|
-
} from "./chunk-DR3HJ6BV.mjs";
|
|
165
173
|
import {
|
|
166
174
|
HYPERMEDIA_SCHEME,
|
|
167
175
|
codePointLength,
|
|
@@ -180,18 +188,21 @@ import "./chunk-AHQWDCHV.mjs";
|
|
|
180
188
|
import "./chunk-7P6ASYW6.mjs";
|
|
181
189
|
export {
|
|
182
190
|
AnnotationSet,
|
|
191
|
+
BlockEditError,
|
|
183
192
|
DEFAULT_GROBID_URL,
|
|
184
193
|
DEFAULT_MAX_PREPARED_CHANGE_BYTES,
|
|
185
194
|
DEFAULT_PREPARE_TIMEOUT_MS,
|
|
186
195
|
HYPERMEDIA_SCHEME,
|
|
187
196
|
InvalidMermaidError,
|
|
188
197
|
MarkdownFrontmatterError,
|
|
198
|
+
MarkdownResolvedRangeError,
|
|
189
199
|
SeedClientError,
|
|
190
200
|
SeedNetworkError,
|
|
191
201
|
SeedValidationError,
|
|
192
202
|
UnpreparableDocumentUpdateError,
|
|
193
203
|
addSpanToAnnotation,
|
|
194
204
|
annotationContains,
|
|
205
|
+
applyBlockEdits,
|
|
195
206
|
assertValidMermaid,
|
|
196
207
|
autoLinkChildToParent,
|
|
197
208
|
blocksToMarkdown,
|
|
@@ -221,6 +232,7 @@ export {
|
|
|
221
232
|
createVersionRef,
|
|
222
233
|
deleteComment,
|
|
223
234
|
deleteContact,
|
|
235
|
+
describeContentChange,
|
|
224
236
|
describeRedirect,
|
|
225
237
|
directoryToIpfsBlobs,
|
|
226
238
|
documentContainsLinkToChild,
|
|
@@ -256,6 +268,7 @@ export {
|
|
|
256
268
|
encryption_exports as keyEncryption,
|
|
257
269
|
keyfile_exports as keyfile,
|
|
258
270
|
markdownBlockNodesToHMBlockNodes,
|
|
271
|
+
markdownUpdateTree,
|
|
259
272
|
matchBlockIds,
|
|
260
273
|
nativeBlockToProtoBlock,
|
|
261
274
|
normalizeDirectoryFilePath,
|
|
@@ -286,6 +299,7 @@ export {
|
|
|
286
299
|
signDocumentChange,
|
|
287
300
|
signPreparedChange,
|
|
288
301
|
slugify,
|
|
302
|
+
stripResolvedRanges,
|
|
289
303
|
teiToBlocks,
|
|
290
304
|
toAPIBlockNode,
|
|
291
305
|
toHMSigner,
|
|
@@ -86,20 +86,40 @@ export type ParseMarkdownOptions = {
|
|
|
86
86
|
* paths that must render whatever they are given.
|
|
87
87
|
*/
|
|
88
88
|
strictFrontmatter?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* `true` (default) throws {@link MarkdownResolvedRangeError} on a `<!-- resolved -->` range that
|
|
91
|
+
* is never closed. `false` drops everything after it, for display paths.
|
|
92
|
+
*/
|
|
93
|
+
strictResolvedRanges?: boolean;
|
|
89
94
|
};
|
|
90
95
|
export declare function parseFrontmatter(markdown: string, options?: ParseMarkdownOptions): {
|
|
91
96
|
content: string;
|
|
92
97
|
metadata: HMMetadata;
|
|
93
98
|
};
|
|
94
99
|
/**
|
|
95
|
-
* Turns each
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
+
* Turns each embed written the earlier way back into the embed it came from. Resolved markdown used
|
|
101
|
+
* to print an embed as its target's content between `<!-- embed: URL; title: …; view: … -->` and
|
|
102
|
+
* `<!-- /embed: URL -->`; it now writes the embed block itself and shows the content in a
|
|
103
|
+
* `<!-- resolved -->` range ({@link stripResolvedRanges}). Markdown read before that change is
|
|
104
|
+
* still written back, so the old range still becomes the Embed block, not paragraphs copied out of
|
|
105
|
+
* the embedded document. Nested embeds inside the range belong to the embedded document and go
|
|
100
106
|
* with it. Lines inside code fences are left alone.
|
|
101
107
|
*/
|
|
102
108
|
export declare function collapseResolvedEmbeds(markdown: string): string;
|
|
109
|
+
/** Thrown when a `<!-- resolved -->` range is never closed: what follows it cannot be told from what it shows. */
|
|
110
|
+
export declare class MarkdownResolvedRangeError extends Error {
|
|
111
|
+
constructor(message: string);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Drops what resolved markdown shows for the reader. `documentToResolvedMarkdown` follows an embed
|
|
115
|
+
* with its target's content, and a query with its results, between `<!-- resolved: … -->` and
|
|
116
|
+
* `<!-- /resolved -->`. None of that is part of the document: the embed or query block on the line
|
|
117
|
+
* above is. Ranges nest (an embedded document has embeds of its own), and a marker inside a code
|
|
118
|
+
* or math block is text.
|
|
119
|
+
*/
|
|
120
|
+
export declare function stripResolvedRanges(markdown: string, options?: {
|
|
121
|
+
strict?: boolean;
|
|
122
|
+
}): string;
|
|
103
123
|
export declare function parseMarkdown(markdown: string, options?: ParseMarkdownOptions): {
|
|
104
124
|
tree: BlockNode[];
|
|
105
125
|
metadata: HMMetadata;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MarkdownFrontmatterError,
|
|
3
|
+
MarkdownResolvedRangeError,
|
|
3
4
|
collapseResolvedEmbeds,
|
|
4
5
|
flattenToOperations,
|
|
5
6
|
hmAccountMentionUid,
|
|
@@ -7,11 +8,13 @@ import {
|
|
|
7
8
|
mergeAdjacentAnnotations,
|
|
8
9
|
parseFrontmatter,
|
|
9
10
|
parseInlineFormatting,
|
|
10
|
-
parseMarkdown
|
|
11
|
-
|
|
11
|
+
parseMarkdown,
|
|
12
|
+
stripResolvedRanges
|
|
13
|
+
} from "./chunk-4ELQ4LJL.mjs";
|
|
12
14
|
import "./chunk-7P6ASYW6.mjs";
|
|
13
15
|
export {
|
|
14
16
|
MarkdownFrontmatterError,
|
|
17
|
+
MarkdownResolvedRangeError,
|
|
15
18
|
collapseResolvedEmbeds,
|
|
16
19
|
flattenToOperations,
|
|
17
20
|
hmAccountMentionUid,
|
|
@@ -19,5 +22,6 @@ export {
|
|
|
19
22
|
mergeAdjacentAnnotations,
|
|
20
23
|
parseFrontmatter,
|
|
21
24
|
parseInlineFormatting,
|
|
22
|
-
parseMarkdown
|
|
25
|
+
parseMarkdown,
|
|
26
|
+
stripResolvedRanges
|
|
23
27
|
};
|
package/dist/prepare-change.mjs
CHANGED
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
nativeBlockToProtoBlock,
|
|
11
11
|
preparableDocumentChanges,
|
|
12
12
|
prepareDocumentUpdateBlobs
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KAZNQFXV.mjs";
|
|
14
|
+
import "./chunk-QS6PIRUE.mjs";
|
|
14
15
|
import "./chunk-CBELM7KX.mjs";
|
|
15
16
|
import "./chunk-KM2NR4YA.mjs";
|
|
16
17
|
import "./chunk-PJ2RFT5A.mjs";
|
|
17
|
-
import "./chunk-QS6PIRUE.mjs";
|
|
18
18
|
import "./chunk-LVAHHQIK.mjs";
|
|
19
19
|
import "./chunk-DR3HJ6BV.mjs";
|
|
20
20
|
import "./chunk-DGNAMVGH.mjs";
|
package/dist/resource-read.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import "./chunk-H2R4GYNV.mjs";
|
|
|
5
5
|
import "./chunk-CBELM7KX.mjs";
|
|
6
6
|
import "./chunk-KM2NR4YA.mjs";
|
|
7
7
|
import "./chunk-PJ2RFT5A.mjs";
|
|
8
|
-
import "./chunk-Q7CWMEBZ.mjs";
|
|
9
8
|
import "./chunk-LVAHHQIK.mjs";
|
|
10
9
|
import "./chunk-DR3HJ6BV.mjs";
|
|
10
|
+
import "./chunk-Q7CWMEBZ.mjs";
|
|
11
11
|
import "./chunk-DGNAMVGH.mjs";
|
|
12
12
|
import "./chunk-AHQWDCHV.mjs";
|
|
13
13
|
import "./chunk-7P6ASYW6.mjs";
|
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
package/package.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sameDocumentVersion
|
|
3
|
+
} from "./chunk-QS6PIRUE.mjs";
|
|
1
4
|
import {
|
|
2
5
|
SeedClientError
|
|
3
6
|
} from "./chunk-CBELM7KX.mjs";
|
|
@@ -10,9 +13,6 @@ import {
|
|
|
10
13
|
import {
|
|
11
14
|
createVersionRef
|
|
12
15
|
} from "./chunk-PJ2RFT5A.mjs";
|
|
13
|
-
import {
|
|
14
|
-
sameDocumentVersion
|
|
15
|
-
} from "./chunk-QS6PIRUE.mjs";
|
|
16
16
|
|
|
17
17
|
// src/prepare-change.ts
|
|
18
18
|
import { decode as cborDecode } from "@ipld/dag-cbor";
|