@seed-hypermedia/client 0.0.134 → 0.0.136

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 (48) hide show
  1. package/dist/apps.mjs +6 -6
  2. package/dist/auto-link.mjs +4 -4
  3. package/dist/block-diff.mjs +4 -4
  4. package/dist/blocks-to-markdown.mjs +3 -3
  5. package/dist/capability.mjs +2 -2
  6. package/dist/{chunk-QFIEZZYJ.mjs → chunk-4CLAG2ZO.mjs} +2 -2
  7. package/dist/chunk-5CYFQIM3.mjs +10 -0
  8. package/dist/{chunk-QS6PIRUE.mjs → chunk-5DRX6MJ6.mjs} +1 -1
  9. package/dist/{chunk-H2R4GYNV.mjs → chunk-6HOMACAF.mjs} +1 -1
  10. package/dist/{chunk-FU7FIYHI.mjs → chunk-7SM52PZ4.mjs} +1 -1
  11. package/dist/{chunk-KAZNQFXV.mjs → chunk-BIUZ2PNE.mjs} +1 -1
  12. package/dist/{chunk-YRNPRWYG.mjs → chunk-FQNFKGLA.mjs} +1 -1
  13. package/dist/{chunk-7FPJWOXB.mjs → chunk-HWXF5HWC.mjs} +1 -1
  14. package/dist/{chunk-LDCWJXIP.mjs → chunk-KCSNLBCS.mjs} +1 -1
  15. package/dist/{chunk-O36UBGLF.mjs → chunk-MUV2CJEU.mjs} +3 -3
  16. package/dist/{chunk-Z7VKSY7P.mjs → chunk-PN4FREGN.mjs} +3 -3
  17. package/dist/{chunk-ETIDW7ZJ.mjs → chunk-UYADUQ6I.mjs} +1 -1
  18. package/dist/{chunk-ITUEKIQD.mjs → chunk-WTK4IVK5.mjs} +3 -3
  19. package/dist/{chunk-BRNXLHBP.mjs → chunk-X4I2LH7P.mjs} +47 -2
  20. package/dist/{chunk-Q7CWMEBZ.mjs → chunk-XL4OR2M2.mjs} +1 -1
  21. package/dist/{chunk-HL43SJUP.mjs → chunk-YFIEJK62.mjs} +26 -4
  22. package/dist/{chunk-DGNAMVGH.mjs → chunk-YSTZP4QT.mjs} +19 -1
  23. package/dist/{chunk-IFELP3LQ.mjs → chunk-ZPRXUG5Y.mjs} +1 -1
  24. package/dist/client.mjs +2 -2
  25. package/dist/comment.d.ts +4 -1
  26. package/dist/comment.mjs +2 -2
  27. package/dist/document-state.mjs +2 -2
  28. package/dist/editorblock-to-hmblock.mjs +2 -2
  29. package/dist/hm-resolver.mjs +2 -2
  30. package/dist/hm-types.d.ts +388 -0
  31. package/dist/hm-types.mjs +3 -1
  32. package/dist/hmblock-to-editorblock.mjs +2 -2
  33. package/dist/index.mjs +15 -15
  34. package/dist/pdf-to-blocks.mjs +3 -3
  35. package/dist/prepare-change.mjs +3 -3
  36. package/dist/resource-read.mjs +4 -4
  37. package/dist/schema-engine.d.ts +13 -2
  38. package/dist/schema-engine.mjs +4 -2
  39. package/dist/schema-registry.generated.mjs +1 -1
  40. package/dist/schema-resolve.mjs +4 -4
  41. package/dist/schema-subtypes.d.ts +8 -7
  42. package/dist/schema-subtypes.mjs +20 -13
  43. package/dist/schema-types.generated.d.ts +43 -4
  44. package/dist/signed-blob.mjs +2 -2
  45. package/dist/tei-to-blocks.mjs +2 -2
  46. package/dist/unicode.mjs +1 -1
  47. package/package.json +1 -1
  48. package/dist/chunk-37QDFTT6.mjs +0 -10
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  pdfToBlocks
3
- } from "./chunk-YRNPRWYG.mjs";
4
- import "./chunk-FU7FIYHI.mjs";
3
+ } from "./chunk-FQNFKGLA.mjs";
4
+ import "./chunk-7SM52PZ4.mjs";
5
5
  import "./chunk-2FJBS3V7.mjs";
6
6
  import "./chunk-PPAY4WZX.mjs";
7
- import "./chunk-DGNAMVGH.mjs";
7
+ import "./chunk-YSTZP4QT.mjs";
8
8
  import "./chunk-AHQWDCHV.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
@@ -10,14 +10,14 @@ import {
10
10
  nativeBlockToProtoBlock,
11
11
  preparableDocumentChanges,
12
12
  prepareDocumentUpdateBlobs
13
- } from "./chunk-KAZNQFXV.mjs";
14
- import "./chunk-QS6PIRUE.mjs";
13
+ } from "./chunk-BIUZ2PNE.mjs";
14
+ import "./chunk-5DRX6MJ6.mjs";
15
15
  import "./chunk-CBELM7KX.mjs";
16
16
  import "./chunk-KM2NR4YA.mjs";
17
17
  import "./chunk-PJ2RFT5A.mjs";
18
18
  import "./chunk-LVAHHQIK.mjs";
19
19
  import "./chunk-DR3HJ6BV.mjs";
20
- import "./chunk-DGNAMVGH.mjs";
20
+ import "./chunk-YSTZP4QT.mjs";
21
21
  import "./chunk-AHQWDCHV.mjs";
22
22
  import "./chunk-7P6ASYW6.mjs";
23
23
  export {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  resolveIdWithClient
3
- } from "./chunk-Z7VKSY7P.mjs";
4
- import "./chunk-H2R4GYNV.mjs";
3
+ } from "./chunk-PN4FREGN.mjs";
4
+ import "./chunk-6HOMACAF.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-KM2NR4YA.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-Q7CWMEBZ.mjs";
11
- import "./chunk-DGNAMVGH.mjs";
10
+ import "./chunk-XL4OR2M2.mjs";
11
+ import "./chunk-YSTZP4QT.mjs";
12
12
  import "./chunk-AHQWDCHV.mjs";
13
13
  import "./chunk-7P6ASYW6.mjs";
14
14
  export {
@@ -85,14 +85,25 @@ export declare function requiredFieldNames(schema: HypermediaSchema | undefined)
85
85
  export declare function fieldsToProperties(fields: StructField[]): Record<string, PropertyEntry>;
86
86
  /** Merge an extension node's refinements over its (resolved) parent — a subtype. */
87
87
  export declare function mergeExtend(parent: HypermediaSchema, ext: HypermediaSchema): HypermediaSchema;
88
+ /**
89
+ * Merge the (resolved) arms of an `allOf` into one struct — an intersection written as a merge, the
90
+ * way extension already is, so two closed structs combine instead of contradicting each other (a
91
+ * value cannot satisfy two closed field sets at once, so checking each arm in turn would accept
92
+ * nothing). Every arm must resolve to a struct or map; the fields are united; a field is required
93
+ * when any arm requires it; a field two arms define must be defined the same way; the result is
94
+ * closed when any arm is closed, and otherwise keeps the arms' shared `values`. Returns
95
+ * `{__invalid: reason}` for arms that cannot be merged.
96
+ */
97
+ export declare function mergeAllOf(arms: HypermediaSchema[]): HypermediaSchema;
88
98
  export type Resolved = {
89
99
  schema: HypermediaSchema;
90
100
  env: Record<string, any>;
91
101
  };
92
102
  /**
93
103
  * Resolve a node to a concrete schema, following var / params / ref+args
94
- * (application) / ref+refinements (extension) / bare ref (include). `env` binds
95
- * type variables. `reg` supplies additional (non-bundled) schemas.
104
+ * (application) / ref+refinements (extension) / bare ref (include) / allOf
105
+ * (intersection: the struct arms merged). `env` binds type variables. `reg`
106
+ * supplies additional (non-bundled) schemas.
96
107
  */
97
108
  /**
98
109
  * The schema a node NAMES, when it names one rather than grounding in a kind: `type` holding any
@@ -21,6 +21,7 @@ import {
21
21
  literalValue,
22
22
  load,
23
23
  loadFrom,
24
+ mergeAllOf,
24
25
  mergeExtend,
25
26
  missingPropertyDefaults,
26
27
  nameForCid,
@@ -42,11 +43,11 @@ import {
42
43
  validate,
43
44
  validateAdvisory,
44
45
  validateDefaults
45
- } from "./chunk-BRNXLHBP.mjs";
46
+ } from "./chunk-X4I2LH7P.mjs";
46
47
  import {
47
48
  HM_SCHEMAS,
48
49
  HM_SCHEMA_MANIFEST
49
- } from "./chunk-37QDFTT6.mjs";
50
+ } from "./chunk-5CYFQIM3.mjs";
50
51
  import "./chunk-7P6ASYW6.mjs";
51
52
  export {
52
53
  HM_SCHEMAS,
@@ -73,6 +74,7 @@ export {
73
74
  literalValue,
74
75
  load,
75
76
  loadFrom,
77
+ mergeAllOf,
76
78
  mergeExtend,
77
79
  missingPropertyDefaults,
78
80
  nameForCid,
@@ -2,7 +2,7 @@ import {
2
2
  HM_SCHEMAS,
3
3
  HM_SCHEMA_MANIFEST,
4
4
  HM_SCHEMA_PAGES
5
- } from "./chunk-37QDFTT6.mjs";
5
+ } from "./chunk-5CYFQIM3.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  HM_SCHEMAS,
@@ -18,11 +18,11 @@ import {
18
18
  resolveSchemaRef,
19
19
  schemaDefinitionCid,
20
20
  withoutSchemaLink
21
- } from "./chunk-ITUEKIQD.mjs";
22
- import "./chunk-BRNXLHBP.mjs";
23
- import "./chunk-37QDFTT6.mjs";
21
+ } from "./chunk-WTK4IVK5.mjs";
22
+ import "./chunk-X4I2LH7P.mjs";
23
+ import "./chunk-5CYFQIM3.mjs";
24
24
  import "./chunk-VWSAFDOL.mjs";
25
- import "./chunk-DGNAMVGH.mjs";
25
+ import "./chunk-YSTZP4QT.mjs";
26
26
  import "./chunk-AHQWDCHV.mjs";
27
27
  import "./chunk-7P6ASYW6.mjs";
28
28
  export {
@@ -6,16 +6,17 @@ import { type HypermediaSchema } from './schema-engine';
6
6
  */
7
7
  export declare function schemaRefKey(ref: string | null | undefined): string | null;
8
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.
9
+ * The schemas this schema extends or includes: its `type` when that names another schema rather
10
+ * than a kind, or, for an intersection, every arm's parent. A union, a literal or a kind-grounded
11
+ * node has no parent.
11
12
  */
12
- export declare function extensionParentRef(schema: HypermediaSchema | undefined): string | null;
13
+ export declare function extensionParentRefs(schema: HypermediaSchema | undefined): string[];
13
14
  /** A schema the closure may include: every spelling that names it, and what it extends. */
14
15
  export type SchemaCandidate = {
15
16
  /** Every reference string that names this schema (document URL, `ipfs://` CID, library URL). */
16
17
  refs: string[];
17
- /** The reference this schema extends or includes, if any. */
18
- parent: string | null;
18
+ /** The references this schema extends or includes: one for an extension, several for an intersection. */
19
+ parents: string[];
19
20
  };
20
21
  /** The bundled library as candidates: each schema under its library URL and published CID. */
21
22
  export declare function libraryCandidates(): SchemaCandidate[];
@@ -26,8 +27,8 @@ export type SubtypeClosure = {
26
27
  refs: string[];
27
28
  };
28
29
  /**
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)
30
+ * The target plus every candidate whose extension chain reaches it (through any arm of an
31
+ * intersection), with every spelling of each collected. Candidates that merely re-spell a member (the target's own document and blob, say)
31
32
  * contribute their spellings too. Cycles and unresolvable parents are harmless: the loop only ever
32
33
  * adds, and stops when a pass adds nothing.
33
34
  */
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  classifyRef
3
- } from "./chunk-ITUEKIQD.mjs";
3
+ } from "./chunk-WTK4IVK5.mjs";
4
4
  import {
5
5
  kindOf,
6
6
  nameForCid,
7
7
  nameToUrl,
8
8
  schemaCid
9
- } from "./chunk-BRNXLHBP.mjs";
9
+ } from "./chunk-X4I2LH7P.mjs";
10
10
  import {
11
11
  HM_SCHEMAS
12
- } from "./chunk-37QDFTT6.mjs";
12
+ } from "./chunk-5CYFQIM3.mjs";
13
13
  import "./chunk-VWSAFDOL.mjs";
14
14
  import {
15
15
  unpackHmId
16
- } from "./chunk-DGNAMVGH.mjs";
16
+ } from "./chunk-YSTZP4QT.mjs";
17
17
  import "./chunk-AHQWDCHV.mjs";
18
18
  import "./chunk-7P6ASYW6.mjs";
19
19
 
@@ -36,11 +36,18 @@ function schemaRefKey(ref) {
36
36
  }
37
37
  }
38
38
  }
39
- function extensionParentRef(schema) {
40
- if (!schema || typeof schema !== "object" || Array.isArray(schema)) return null;
41
- const type = schema.type;
42
- if (typeof type !== "string" || !type) return null;
43
- return kindOf(type) === type ? type : null;
39
+ function extensionParentRefs(schema) {
40
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) return [];
41
+ const node = schema;
42
+ if (Array.isArray(node.allOf)) {
43
+ const out = [];
44
+ for (const arm of node.allOf)
45
+ for (const ref of extensionParentRefs(arm)) if (!out.includes(ref)) out.push(ref);
46
+ return out;
47
+ }
48
+ const type = node.type;
49
+ if (typeof type !== "string" || !type) return [];
50
+ return kindOf(type) === type ? [type] : [];
44
51
  }
45
52
  function libraryCandidates() {
46
53
  return Object.entries(HM_SCHEMAS).map(([name, schema]) => {
@@ -48,7 +55,7 @@ function libraryCandidates() {
48
55
  const url = nameToUrl(name);
49
56
  return {
50
57
  refs: [...url ? [url] : [], ...cid ? [`ipfs://${cid}`] : []],
51
- parent: extensionParentRef(schema)
58
+ parents: extensionParentRefs(schema)
52
59
  };
53
60
  });
54
61
  }
@@ -64,14 +71,14 @@ function closeOverSubtypes(target, candidates) {
64
71
  add(target, targetKey);
65
72
  const keyed = candidates.map((candidate) => ({
66
73
  refs: candidate.refs.map((ref) => [ref, schemaRefKey(ref)]).filter((pair) => !!pair[1]),
67
- parentKey: candidate.parent ? schemaRefKey(candidate.parent) : null
74
+ parentKeys: candidate.parents.map(schemaRefKey).filter((key) => !!key)
68
75
  })).filter((candidate) => candidate.refs.length > 0);
69
76
  let grew = true;
70
77
  while (grew) {
71
78
  grew = false;
72
79
  for (const candidate of keyed) {
73
80
  const known = candidate.refs.some(([, key]) => keys.has(key));
74
- const inherits = !!candidate.parentKey && keys.has(candidate.parentKey);
81
+ const inherits = candidate.parentKeys.some((key) => keys.has(key));
75
82
  if (!known && !inherits) continue;
76
83
  for (const [ref, key] of candidate.refs) {
77
84
  if (keys.has(key) && refs.includes(ref)) continue;
@@ -88,7 +95,7 @@ function inClosure(closure, ref) {
88
95
  }
89
96
  export {
90
97
  closeOverSubtypes,
91
- extensionParentRef,
98
+ extensionParentRefs,
92
99
  inClosure,
93
100
  libraryCandidates,
94
101
  schemaRefKey
@@ -640,7 +640,7 @@ export type HMCid = HMLink;
640
640
  /**
641
641
  * Comment
642
642
  * A signed comment on a document version, threaded through threadRoot and replyParent, with a body that is a tree of comment blocks.
643
- * A signed comment on a document version, threaded through `threadRoot` and `replyParent`, with a body of comment blocks.
643
+ * A signed comment on a document version, optionally written by an authorized agent for a stable account authority.
644
644
  * Schema: hm://hyper.media/comment
645
645
  */
646
646
  export type HMComment = HMBlob & {
@@ -649,12 +649,14 @@ export type HMComment = HMBlob & {
649
649
  id?: string;
650
650
  /** Deprecated and ignored; some old comment blobs still carry it. */
651
651
  capability?: HMCid;
652
+ /** Stable account authority represented by a delegated signer; omitted when it equals the signer. */
653
+ account?: HMPrincipal;
652
654
  /** Space of the commented document; omitted when it equals the signer. */
653
655
  space?: HMPrincipal;
654
656
  /** Path of the commented document within `space`. */
655
657
  path?: string;
656
- /** CIDs of the document heads the author was looking at; empty means the document at this path. */
657
- version?: HMCid[];
658
+ /** CIDs of the document heads the author was looking at; a comment without them is invalid. */
659
+ version: HMCid[];
658
660
  /** CID of the first comment of the thread; present on every reply. */
659
661
  threadRoot?: HMCid;
660
662
  /** CID of the comment this one replies to; omitted when it equals `threadRoot`. */
@@ -850,6 +852,18 @@ export type HMExampleConstrained = {
850
852
  /** One to three string tags. */
851
853
  tags?: string[];
852
854
  };
855
+ /**
856
+ * Example: Contact
857
+ * Ways to reach someone, a required email and an optional phone number.
858
+ * Ways to reach someone: a required email and an optional phone number.
859
+ * Schema: hm://hyper.media/example/contact
860
+ */
861
+ export type HMExampleContact = {
862
+ /** The address to write to. */
863
+ email: string;
864
+ /** A telephone number, in any format. */
865
+ phone?: string;
866
+ };
853
867
  /**
854
868
  * Example: Counts
855
869
  * A map from string keys to integers: Map<Integer>.
@@ -1087,6 +1101,13 @@ export type HMExamplePollBlock = HMBlockBase & {
1087
1101
  export type HMExampleRegistry = {
1088
1102
  [key: string]: HMLink;
1089
1103
  };
1104
+ /**
1105
+ * Example: Staff Member
1106
+ * An employee who is also a contact, the intersection of the two.
1107
+ * An employee who is also a contact: every field of both, with name, employeeId and email required.
1108
+ * Schema: hm://hyper.media/example/staff-member
1109
+ */
1110
+ export type HMExampleStaffMember = HMExampleEmployee & HMExampleContact;
1090
1111
  /**
1091
1112
  * Character Stats
1092
1113
  * A character’s stats object, stored as its own DAG-CBOR blob linked by `ipfs://` so it can hold the integers and enums document metadata cannot.
@@ -1460,7 +1481,25 @@ export type HMRole = 'WRITER' | 'AGENT';
1460
1481
  * The meta-schema: the union of every shape a schema can take, itself a valid instance of this type.
1461
1482
  * Schema: hm://hyper.media/schema
1462
1483
  */
1463
- export type HMSchema = HMSchemaStructSchema | HMSchemaMapSchema | HMSchemaListSchema | HMSchemaScalarSchema | HMSchemaLinkSchema | HMSchemaIncludeSchema | HMSchemaAnyof | HMSchemaVarSchema | HMSchemaLiteralSchema | string | number | boolean | null;
1484
+ export type HMSchema = HMSchemaStructSchema | HMSchemaMapSchema | HMSchemaListSchema | HMSchemaScalarSchema | HMSchemaLinkSchema | HMSchemaIncludeSchema | HMSchemaAnyof | HMSchemaAllof | HMSchemaVarSchema | HMSchemaLiteralSchema | string | number | boolean | null;
1485
+ /**
1486
+ * Intersection schema
1487
+ * The variant for an intersection, which accepts a value that satisfies every schema listed under allOf, by merging its struct arms into one.
1488
+ * An intersection schema: a value is valid if it satisfies every schema listed under `allOf`. The arms are structs, and they merge into one.
1489
+ * Schema: hm://hyper.media/schema/allof
1490
+ */
1491
+ export type HMSchemaAllof = {
1492
+ /** The schemas to combine; a value must satisfy every one. Each arm must be a struct or map (or name one); their fields merge into one struct. */
1493
+ allOf: HMSchema[];
1494
+ /** What the intersection is for, when it is written inline; a published schema is described by its page. */
1495
+ description?: string;
1496
+ /** Type parameters that make this schema generic, each with its default schema. */
1497
+ params?: {
1498
+ [key: string]: HMSchema;
1499
+ };
1500
+ /** Legacy: a name some published schemas still carry. New schemas are named by their page. */
1501
+ name?: string;
1502
+ };
1464
1503
  /**
1465
1504
  * Union schema
1466
1505
  * The variant for a union, which accepts a value that matches any one of the schemas listed under anyOf.
@@ -5,8 +5,8 @@ import {
5
5
  literalValue,
6
6
  resolveSchema,
7
7
  structFields
8
- } from "./chunk-BRNXLHBP.mjs";
9
- import "./chunk-37QDFTT6.mjs";
8
+ } from "./chunk-X4I2LH7P.mjs";
9
+ import "./chunk-5CYFQIM3.mjs";
10
10
  import {
11
11
  dagJsonToIpld,
12
12
  findSeedIndexerCollision
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-FU7FIYHI.mjs";
4
- import "./chunk-DGNAMVGH.mjs";
3
+ } from "./chunk-7SM52PZ4.mjs";
4
+ import "./chunk-YSTZP4QT.mjs";
5
5
  import "./chunk-AHQWDCHV.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
package/dist/unicode.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  codePointLength,
9
9
  isSurrogate
10
- } from "./chunk-DGNAMVGH.mjs";
10
+ } from "./chunk-YSTZP4QT.mjs";
11
11
  import "./chunk-AHQWDCHV.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.134",
3
+ "version": "0.0.136",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",