@openlfcp/shared-objects 0.2.1 → 0.3.0

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.
@@ -1,3 +1,4 @@
1
+ import { IDENTITY_PROFILE_ID } from "../identity/values.js";
1
2
  import { PROFILE_ID } from "../values.js";
2
3
  import { SECTIONS_PROFILE_ID } from "./values.js";
3
4
  /**
@@ -9,12 +10,18 @@ import { SECTIONS_PROFILE_ID } from "./values.js";
9
10
  * textual shape.
10
11
  */
11
12
  /** The models this package implements, by Data Profile. */
12
- export const SUPPORTED_DATA_PROFILES = Object.freeze([PROFILE_ID, SECTIONS_PROFILE_ID]);
13
+ export const SUPPORTED_DATA_PROFILES = Object.freeze([
14
+ PROFILE_ID,
15
+ SECTIONS_PROFILE_ID,
16
+ IDENTITY_PROFILE_ID,
17
+ ]);
13
18
  /**
14
19
  * The model of a Resource whose validated Genesis (its Control Chain state)
15
20
  * names `dataProfile`. Exact match only: no prefix, version or case folding.
16
21
  */
17
22
  export function profileModel(dataProfile) {
23
+ if (dataProfile === IDENTITY_PROFILE_ID)
24
+ return Object.freeze({ kind: "identity", dataProfile });
18
25
  if (dataProfile === PROFILE_ID)
19
26
  return Object.freeze({ kind: "shared-objects", dataProfile });
20
27
  if (dataProfile === SECTIONS_PROFILE_ID)
@@ -28,6 +35,12 @@ export function profileModel(dataProfile) {
28
35
  * Shared Objects Task.
29
36
  */
30
37
  export function taskRefModel(resourceDataProfile) {
38
+ if (resourceDataProfile === IDENTITY_PROFILE_ID)
39
+ return Object.freeze({
40
+ kind: "profile-unsupported",
41
+ code: "PROFILE_UNSUPPORTED",
42
+ dataProfile: resourceDataProfile,
43
+ });
31
44
  return profileModel(resourceDataProfile);
32
45
  }
33
46
  //# sourceMappingURL=dispatch.js.map
@@ -8,7 +8,7 @@
8
8
  * shared `@openlfcp/shared-objects/admission` with SECTIONS_ACTOR_DOMAIN.
9
9
  */
10
10
  export { ADMISSION_ORDER, type AdmissionDiagnostic, SectionAdmissionError, } from "./admission.js";
11
- export { type SectionsApplyResult, type SectionsBatchResult, type SectionsCheckpoint, type SectionsCodec, type SectionsCommitBinding, type SectionsExcludeResult, type SectionsNodesChanged, type SectionsSnapshotBinding, type SectionsSnapshotCodec, type SectionsStagedOperation, type SectionsUnit, SharedSectionsDataProfile, } from "./data-profile.js";
11
+ export { type SectionsApplyResult, type SectionsBatchResult, type SectionsCheckpoint, type SectionsCodec, type SectionsCommitBinding, type SectionsExcludeResult, type SectionsListenerFailure, type SectionsNodesChanged, type SectionsSnapshotBinding, type SectionsSnapshotCodec, type SectionsStagedOperation, type SectionsUnit, SharedSectionsDataProfile, } from "./data-profile.js";
12
12
  export { type ProfileModel, profileModel, SUPPORTED_DATA_PROFILES, taskRefModel, } from "./dispatch.js";
13
13
  export { SectionDocument, type ValueType } from "./document.js";
14
14
  export { AUTHORING_BUDGET, type SectionIntent, type SectionIntentCode, SectionIntentError, type SectionLocalChange, type SectionReceiveResult, type SectionRefusal, SectionReplica, type SectionReplicaOptions, type SectionSnapshot, type SectionSnapshotNode, type SectionUnit, type StagedSectionChange, type TextEdit, } from "./replica.js";
@@ -101,7 +101,7 @@ const str = (v) => A.isImmutableString(v) ? v.toString() : typeof v === "string"
101
101
  const isListStyle = (s) => typeof s === "string" && LIST_STYLES.includes(s);
102
102
  const revisionOf = (doc) => [...A.getHeads(doc)].sort().join(",");
103
103
  /** `changes` without those of `batch` (by hash), in their order. */
104
- const withoutBatch = (changes, batch) => changes.filter((c) => !batch.has(A.decodeChange(c).hash));
104
+ const withoutBatch = (changes, batch) => changes.filter((c) => !batch.has(checkChange(c).hash));
105
105
  /** Rebuilds a section document from the changes it held before an aborted apply. */
106
106
  function restoreSection(changes, actor, revision) {
107
107
  let restored;
@@ -198,7 +198,7 @@ export class SectionReplica {
198
198
  */
199
199
  rebuildWithout(exclude) {
200
200
  const out = new Set(exclude);
201
- const kept = A.getAllChanges(this.#doc).filter((c) => !out.has(A.decodeChange(c).hash));
201
+ const kept = A.getAllChanges(this.#doc).filter((c) => !out.has(checkChange(c).hash));
202
202
  return SectionReplica.fromChanges(kept, {
203
203
  resource: this.resource,
204
204
  principal: this.#principal,
@@ -379,8 +379,7 @@ export class SectionReplica {
379
379
  #sequences() {
380
380
  if (this.#seqs === undefined) {
381
381
  this.#seqs = new Map();
382
- for (const bytes of A.getAllChanges(this.#doc)) {
383
- const c = A.decodeChange(bytes);
382
+ for (const c of A.getChangesMetaSince(this.#doc, [])) {
384
383
  if (c.seq > (this.#seqs.get(c.actor) ?? 0))
385
384
  this.#seqs.set(c.actor, c.seq);
386
385
  }
@@ -1,4 +1,5 @@
1
1
  import * as A from "@automerge/automerge";
2
+ import { checkChange, decodedOf } from "../admission/framing.js";
2
3
  import { distinctValues } from "../concurrent.js";
3
4
  import { validateSection } from "./schema.js";
4
5
  /** The Task scalar fields whose concurrent values tree() reports. */
@@ -183,7 +184,7 @@ export function deriveTree(doc, validation = validateSection(doc)) {
183
184
  });
184
185
  }
185
186
  const summarise = (bytes) => {
186
- const c = A.decodeChange(bytes);
187
+ const c = decodedOf(checkChange(bytes));
187
188
  return {
188
189
  hash: c.hash,
189
190
  deps: c.deps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openlfcp/shared-objects",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "SHARED-OBJECTS-PROFILE-01 (org.openlfcp.shared-objects.v1) implementation.",
5
5
  "keywords": [
6
6
  "openlfcp",
@@ -39,6 +39,10 @@
39
39
  "./sections": {
40
40
  "types": "./dist/sections/index.d.ts",
41
41
  "import": "./dist/sections/index.js"
42
+ },
43
+ "./identity": {
44
+ "types": "./dist/identity/index.d.ts",
45
+ "import": "./dist/identity/index.js"
42
46
  }
43
47
  },
44
48
  "files": [
@@ -53,8 +57,8 @@
53
57
  "dependencies": {
54
58
  "@automerge/automerge": "3.5.0",
55
59
  "fflate": "0.8.3",
56
- "@openlfcp/core": "^0.2.1",
57
- "@openlfcp/crypto": "^0.2.1"
60
+ "@openlfcp/core": "^0.3.0",
61
+ "@openlfcp/crypto": "^0.3.0"
58
62
  },
59
63
  "devDependencies": {
60
64
  "fast-check": "4.10.2"