@dxos/migrations 0.10.0 → 0.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/migrations",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -16,8 +16,7 @@
16
16
  ".": {
17
17
  "source": "./src/index.ts",
18
18
  "types": "./dist/types/src/index.d.ts",
19
- "browser": "./dist/lib/browser/index.mjs",
20
- "node": "./dist/lib/node-esm/index.mjs"
19
+ "import": "./dist/lib/index.mjs"
21
20
  }
22
21
  },
23
22
  "types": "dist/types/src/index.d.ts",
@@ -27,16 +26,16 @@
27
26
  ],
28
27
  "dependencies": {
29
28
  "@automerge/automerge": "3.3.0-fragments.2",
30
- "@automerge/automerge-repo": "2.6.0-subduction.37",
29
+ "@automerge/automerge-repo": "2.6.0-subduction.40",
31
30
  "@effect-atom/atom": "^0.5.3",
32
31
  "effect": "3.21.4",
33
- "@dxos/client": "0.10.0",
34
- "@dxos/echo-client": "0.10.0",
35
- "@dxos/echo": "0.10.0",
36
- "@dxos/invariant": "0.10.0",
37
- "@dxos/keys": "0.10.0",
38
- "@dxos/echo-protocol": "0.10.0",
39
- "@dxos/util": "0.10.0"
32
+ "@dxos/client": "0.11.0",
33
+ "@dxos/echo": "0.11.0",
34
+ "@dxos/echo-client": "0.11.0",
35
+ "@dxos/echo-protocol": "0.11.0",
36
+ "@dxos/invariant": "0.11.0",
37
+ "@dxos/keys": "0.11.0",
38
+ "@dxos/util": "0.11.0"
40
39
  },
41
40
  "publishConfig": {
42
41
  "access": "public"
@@ -2,12 +2,15 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
+ import { type AnyDocumentId } from '@automerge/automerge-repo';
5
6
  import { describe, expect, test } from 'vitest';
6
7
 
7
8
  import { Client } from '@dxos/client';
8
9
  import { TestBuilder } from '@dxos/client/testing';
9
10
  import { Filter, Obj } from '@dxos/echo';
11
+ import { type DatabaseDirectory } from '@dxos/echo-protocol';
10
12
  import { TestSchema } from '@dxos/echo/testing';
13
+ import { invariant } from '@dxos/invariant';
11
14
 
12
15
  import { compactDocumentsEpochMigration } from './document-compaction';
13
16
 
@@ -39,6 +42,21 @@ describe('document compaction', () => {
39
42
 
40
43
  const epochsAfter = await space.internal.getEpochs();
41
44
  expect(epochsAfter.length).toBe(epochsBefore.length + 1);
45
+
46
+ // The re-created root and linked documents carry the space identifiers.
47
+ // Epoch credentials and root links store automerge URLs as plain strings, so the
48
+ // branded AnyDocumentId casts below are the only way to hand them back to the repo.
49
+ const repo = space.internal.db._repo;
50
+ const rootUrl = String(epochsAfter[epochsAfter.length - 1]?.subject.assertion.automergeRoot);
51
+ const rootHandle = repo.find<DatabaseDirectory>(rootUrl as AnyDocumentId);
52
+ await rootHandle.whenReady();
53
+ expect(rootHandle.doc()?.access?.spaceId).toBe(space.id);
54
+ const linkUrl = rootHandle.doc()?.links?.[object.id]?.toString();
55
+ invariant(linkUrl, 'Compacted object link missing from new root');
56
+ const linkedHandle = repo.find<DatabaseDirectory>(linkUrl as AnyDocumentId);
57
+ await linkedHandle.whenReady();
58
+ expect(linkedHandle.doc()?.access?.spaceId).toBe(space.id);
59
+ expect(linkedHandle.doc()?.access?.spaceKey).toBe(space.key.toHex());
42
60
  } finally {
43
61
  await client.destroy();
44
62
  }
@@ -81,9 +81,7 @@ export class MigrationBuilder {
81
81
 
82
82
  const newState: DatabaseDirectory = {
83
83
  version: SpaceDocVersion.CURRENT,
84
- access: {
85
- spaceKey: this._space.key.toHex(),
86
- },
84
+ access: this._makeAccess(),
87
85
  objects: {
88
86
  [id]: {
89
87
  system: {
@@ -137,6 +135,8 @@ export class MigrationBuilder {
137
135
 
138
136
  await oldHandle.whenReady();
139
137
  const materialized = toJS(oldHandle.doc()!) as DatabaseDirectory;
138
+ // Re-stamp access so documents that predate access.spaceId pick it up during compaction.
139
+ materialized.access = this._makeAccess();
140
140
  const newHandle = this._repo.create<DatabaseDirectory>(materialized);
141
141
  await newHandle.whenReady();
142
142
  invariant(newHandle.url, 'Compacted document URL not available after whenReady');
@@ -204,9 +204,7 @@ export class MigrationBuilder {
204
204
 
205
205
  this._newRoot = this._repo.create<DatabaseDirectory>({
206
206
  version: SpaceDocVersion.CURRENT,
207
- access: {
208
- spaceKey: this._space.key.toHex(),
209
- },
207
+ access: this._makeAccess(),
210
208
  objects: this._rootDoc.objects,
211
209
  links,
212
210
  });
@@ -232,9 +230,7 @@ export class MigrationBuilder {
232
230
  core.setType(EncodedReference.fromURI(getSchemaURI(schema)!));
233
231
  const newHandle = this._repo.create<DatabaseDirectory>({
234
232
  version: SpaceDocVersion.CURRENT,
235
- access: {
236
- spaceKey: this._space.key.toHex(),
237
- },
233
+ access: this._makeAccess(),
238
234
  objects: {
239
235
  [core.id]: core.getDoc() as EntityStructure,
240
236
  },
@@ -246,6 +242,14 @@ export class MigrationBuilder {
246
242
  return core;
247
243
  }
248
244
 
245
+ private _makeAccess(): NonNullable<DatabaseDirectory['access']> {
246
+ return {
247
+ spaceId: this._space.id,
248
+ // spaceKey is deprecated but still written so older clients can resolve the owning space.
249
+ spaceKey: this._space.key.toHex(),
250
+ };
251
+ }
252
+
249
253
  private _addHandleToFlushList(id: DocumentId): void {
250
254
  this._flushIds.push(id);
251
255
  }
@@ -1,307 +0,0 @@
1
- // src/annotations.ts
2
- import * as Schema from "effect/Schema";
3
- import { Annotation } from "@dxos/echo";
4
- var MigrationVersionAnnotation = Annotation.make({
5
- id: "org.dxos.migrations.version",
6
- schema: Schema.String
7
- });
8
-
9
- // src/document-compaction.ts
10
- import { SpaceState } from "@dxos/client/echo";
11
- import { invariant as invariant2 } from "@dxos/invariant";
12
-
13
- // src/migration-builder.ts
14
- import { next as A, toJS } from "@automerge/automerge";
15
- import { CreateEpochRequest } from "@dxos/client/halo";
16
- import { ObjectCore, migrateDocument } from "@dxos/echo-client/internal";
17
- import { EncodedReference, SpaceDocVersion } from "@dxos/echo-protocol";
18
- import { getSchemaURI } from "@dxos/echo/internal";
19
- import * as Type from "@dxos/echo/Type";
20
- import { invariant } from "@dxos/invariant";
21
- import { EID, EntityId } from "@dxos/keys";
22
- var __dxlog_file = "/__w/dxos/dxos/packages/sdk/migrations/src/migration-builder.ts";
23
- var MigrationBuilder = class {
24
- _space;
25
- _repo;
26
- _rootDoc;
27
- // echoUri -> automergeUrl
28
- _newLinks = {};
29
- _flushIds = [];
30
- _deleteObjects = [];
31
- _newRoot = void 0;
32
- constructor(_space) {
33
- this._space = _space;
34
- this._repo = this._space.internal.db._repo;
35
- const rootDoc = this._space.internal.db._getSpaceRootDocHandle().doc();
36
- invariant(rootDoc, "Space root document must be available when creating MigrationBuilder", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 41, S: this, A: ["rootDoc", "'Space root document must be available when creating MigrationBuilder'"] });
37
- this._rootDoc = rootDoc;
38
- }
39
- async findObject(id) {
40
- const documentId = (this._rootDoc.links?.[id] || this._newLinks[id])?.toString();
41
- const docHandle = documentId && this._repo.find(documentId);
42
- if (!docHandle) {
43
- return void 0;
44
- }
45
- await docHandle.whenReady();
46
- const doc = docHandle.doc();
47
- return doc.objects?.[id];
48
- }
49
- async migrateObject(id, migrate) {
50
- const objectStructure = await this.findObject(id);
51
- if (!objectStructure) {
52
- return;
53
- }
54
- const { type, props } = await migrate(objectStructure);
55
- const schema = Type.getSchema(type);
56
- const oldHandle = await this._findObjectContainingHandle(id);
57
- invariant(oldHandle, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 62, S: this, A: ["oldHandle", ""] });
58
- const newState = {
59
- version: SpaceDocVersion.CURRENT,
60
- access: {
61
- spaceKey: this._space.key.toHex()
62
- },
63
- objects: {
64
- [id]: {
65
- system: {
66
- type: EncodedReference.fromURI(getSchemaURI(schema))
67
- },
68
- data: props,
69
- meta: {
70
- keys: []
71
- }
72
- }
73
- }
74
- };
75
- const migratedDoc = migrateDocument(oldHandle.doc(), newState);
76
- const newHandle = this._repo.import(A.save(migratedDoc));
77
- await newHandle.whenReady();
78
- invariant(newHandle.url, "Migrated document URL not available after whenReady", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 83, S: this, A: ["newHandle.url", "'Migrated document URL not available after whenReady'"] });
79
- this._newLinks[id] = newHandle.url;
80
- this._addHandleToFlushList(newHandle.documentId);
81
- }
82
- async addObject(type, props) {
83
- const resolved = Type.getSchema(type);
84
- const core = await this._createObject({
85
- schema: resolved,
86
- props
87
- });
88
- return core.id;
89
- }
90
- createReference(id) {
91
- invariant(EntityId.isValid(id), "Invalid EntityId.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 96, S: this, A: ["EntityId.isValid(id)", "'Invalid EntityId.'"] });
92
- return EncodedReference.fromURI(EID.make({
93
- entityId: id
94
- }));
95
- }
96
- deleteObject(id) {
97
- this._deleteObjects.push(id);
98
- }
99
- /**
100
- * Re-materializes linked object documents into fresh Automerge docs without history.
101
- * Call {@link _commit} to publish a new space epoch with updated root links.
102
- */
103
- async compactLinkedDocuments(objectIds) {
104
- const linkIds = objectIds ?? Object.keys(this._rootDoc.links ?? {});
105
- const compacted = [];
106
- const skipped = [];
107
- for (const id of linkIds) {
108
- const oldHandle = await this._findObjectContainingHandle(id);
109
- if (!oldHandle) {
110
- skipped.push(id);
111
- continue;
112
- }
113
- await oldHandle.whenReady();
114
- const materialized = toJS(oldHandle.doc());
115
- const newHandle = this._repo.create(materialized);
116
- await newHandle.whenReady();
117
- invariant(newHandle.url, "Compacted document URL not available after whenReady", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 121, S: this, A: ["newHandle.url", "'Compacted document URL not available after whenReady'"] });
118
- this._newLinks[id] = newHandle.url;
119
- this._addHandleToFlushList(newHandle.documentId);
120
- compacted.push(id);
121
- }
122
- return {
123
- compacted,
124
- skipped
125
- };
126
- }
127
- async changeProperties(changeFn) {
128
- if (!this._newRoot) {
129
- await this._buildNewRoot();
130
- }
131
- invariant(this._newRoot, "New root not created", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 135, S: this, A: ["this._newRoot", "'New root not created'"] });
132
- this._newRoot.change((doc) => {
133
- const propertiesStructure = doc.objects?.[this._space.properties.id];
134
- propertiesStructure && changeFn(propertiesStructure);
135
- });
136
- await this._newRoot.whenReady();
137
- this._addHandleToFlushList(this._newRoot.documentId);
138
- }
139
- /**
140
- * @internal
141
- */
142
- async _commit() {
143
- if (!this._newRoot) {
144
- await this._buildNewRoot();
145
- }
146
- invariant(this._newRoot, "New root not created", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 149, S: this, A: ["this._newRoot", "'New root not created'"] });
147
- await this._space.db.flush();
148
- invariant(this._newRoot.url, "New root URL not available", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 152, S: this, A: ["this._newRoot.url", "'New root URL not available'"] });
149
- await this._space.internal.createEpoch({
150
- migration: CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT,
151
- automergeRootUrl: this._newRoot.url
152
- });
153
- }
154
- async _findObjectContainingHandle(id) {
155
- const documentId = (this._rootDoc.links?.[id] || this._newLinks[id])?.toString();
156
- const docHandle = documentId && this._repo.find(documentId);
157
- if (!docHandle) {
158
- return void 0;
159
- }
160
- await docHandle.whenReady();
161
- return docHandle;
162
- }
163
- async _buildNewRoot() {
164
- const links = {
165
- ...this._rootDoc.links ?? {}
166
- };
167
- for (const id of this._deleteObjects) {
168
- delete links[id];
169
- }
170
- for (const [id, url] of Object.entries(this._newLinks)) {
171
- links[id] = new A.RawString(url);
172
- }
173
- this._newRoot = this._repo.create({
174
- version: SpaceDocVersion.CURRENT,
175
- access: {
176
- spaceKey: this._space.key.toHex()
177
- },
178
- objects: this._rootDoc.objects,
179
- links
180
- });
181
- await this._newRoot.whenReady();
182
- this._addHandleToFlushList(this._newRoot.documentId);
183
- }
184
- async _createObject({ id, schema, props }) {
185
- const core = new ObjectCore();
186
- if (id) {
187
- core.id = id;
188
- }
189
- core.initNewObject(props);
190
- core.setType(EncodedReference.fromURI(getSchemaURI(schema)));
191
- const newHandle = this._repo.create({
192
- version: SpaceDocVersion.CURRENT,
193
- access: {
194
- spaceKey: this._space.key.toHex()
195
- },
196
- objects: {
197
- [core.id]: core.getDoc()
198
- }
199
- });
200
- await newHandle.whenReady();
201
- this._newLinks[core.id] = newHandle.url;
202
- this._addHandleToFlushList(newHandle.documentId);
203
- return core;
204
- }
205
- _addHandleToFlushList(id) {
206
- this._flushIds.push(id);
207
- }
208
- };
209
-
210
- // src/document-compaction.ts
211
- var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/migrations/src/document-compaction.ts";
212
- var compactDocumentsEpochMigration = async (space, options = {}) => {
213
- invariant2(space.state.get() === SpaceState.SPACE_READY, "Space must be open and ready before compaction.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 11, S: void 0, A: ["space.state.get() === SpaceState.SPACE_READY", "'Space must be open and ready before compaction.'"] });
214
- const builder = new MigrationBuilder(space);
215
- const { compacted, skipped } = await builder.compactLinkedDocuments(options.objectIds);
216
- await builder._commit();
217
- const epochs = await space.internal.getEpochs();
218
- const lastEpoch = epochs[epochs.length - 1];
219
- const epochNumber = lastEpoch?.subject.assertion.number ?? 0;
220
- return {
221
- compacted,
222
- skipped,
223
- epochNumber
224
- };
225
- };
226
-
227
- // src/migrations.ts
228
- import { Atom } from "@effect-atom/atom";
229
- import * as Registry from "@effect-atom/atom/Registry";
230
- import * as Option from "effect/Option";
231
- import { SpaceState as SpaceState2 } from "@dxos/client/echo";
232
- import { Annotation as Annotation2, Obj } from "@dxos/echo";
233
- import { invariant as invariant3 } from "@dxos/invariant";
234
- var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/migrations/src/migrations.ts";
235
- var Migrations = class {
236
- static namespace;
237
- static migrations = [];
238
- static _registry = Registry.make();
239
- static _stateAtom = Atom.make({
240
- running: []
241
- }).pipe(Atom.keepAlive);
242
- /**
243
- * @deprecated Use `MigrationVersionAnnotation` via `Annotation.get/set` on space properties.
244
- */
245
- static get versionProperty() {
246
- return this.namespace && `${this.namespace}.version`;
247
- }
248
- static get targetVersion() {
249
- return this.migrations[this.migrations.length - 1]?.version;
250
- }
251
- static running(space) {
252
- const state = this._registry.get(this._stateAtom);
253
- return state.running.includes(space.key.toHex());
254
- }
255
- static define(namespace, migrations) {
256
- this.namespace = namespace;
257
- this.migrations = migrations;
258
- }
259
- static async migrate(space, targetVersion) {
260
- invariant3(!this.running(space), "Migration already running", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 36, S: this, A: ["!this.running(space)", "'Migration already running'"] });
261
- invariant3(space.state.get() === SpaceState2.SPACE_READY, "Space not ready", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 37, S: this, A: ["space.state.get() === SpaceState.SPACE_READY", "'Space not ready'"] });
262
- const currentVersion = Annotation2.get(space.properties, MigrationVersionAnnotation).pipe(Option.getOrUndefined);
263
- const currentIndex = this.migrations.findIndex((m) => m.version === currentVersion) + 1;
264
- const i = this.migrations.findIndex((m) => m.version === targetVersion);
265
- const targetIndex = i === -1 ? this.migrations.length : i + 1;
266
- if (currentIndex === targetIndex) {
267
- return false;
268
- }
269
- const spaceKey = space.key.toHex();
270
- const currentState = this._registry.get(this._stateAtom);
271
- this._registry.set(this._stateAtom, {
272
- running: [
273
- ...currentState.running,
274
- spaceKey
275
- ]
276
- });
277
- try {
278
- if (targetIndex > currentIndex) {
279
- const migrations = this.migrations.slice(currentIndex, targetIndex);
280
- for (const migration of migrations) {
281
- const builder = new MigrationBuilder(space);
282
- await migration.next({
283
- space,
284
- builder
285
- });
286
- await builder._commit();
287
- Obj.update(space.properties, (properties) => {
288
- Annotation2.set(properties, MigrationVersionAnnotation, migration.version);
289
- });
290
- }
291
- }
292
- } finally {
293
- const finalState = this._registry.get(this._stateAtom);
294
- this._registry.set(this._stateAtom, {
295
- running: finalState.running.filter((key) => key !== spaceKey)
296
- });
297
- }
298
- return true;
299
- }
300
- };
301
- export {
302
- MigrationBuilder,
303
- MigrationVersionAnnotation,
304
- Migrations,
305
- compactDocumentsEpochMigration
306
- };
307
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/annotations.ts", "../../../src/document-compaction.ts", "../../../src/migration-builder.ts", "../../../src/migrations.ts"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation } from '@dxos/echo';\n\n/** Migration version stored on space properties meta. */\nexport const MigrationVersionAnnotation = Annotation.make({\n id: 'org.dxos.migrations.version',\n schema: Schema.String,\n});\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Space, SpaceState } from '@dxos/client/echo';\nimport { invariant } from '@dxos/invariant';\n\nimport { MigrationBuilder } from './migration-builder';\n\nexport type CompactDocumentsOptions = {\n /**\n * Entity ids whose linked Automerge documents should be compacted.\n * Defaults to all ids in the space root `links` map.\n */\n objectIds?: string[];\n};\n\nexport type CompactDocumentsResult = {\n compacted: string[];\n skipped: string[];\n epochNumber: number;\n};\n\n/**\n * Re-materializes linked object documents into fresh Automerge docs (no history) and commits\n * a new space epoch with {@link CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT}.\n */\nexport const compactDocumentsEpochMigration = async (\n space: Space,\n options: CompactDocumentsOptions = {},\n): Promise<CompactDocumentsResult> => {\n invariant(space.state.get() === SpaceState.SPACE_READY, 'Space must be open and ready before compaction.');\n\n const builder = new MigrationBuilder(space);\n const { compacted, skipped } = await builder.compactLinkedDocuments(options.objectIds);\n await builder._commit();\n\n const epochs = await space.internal.getEpochs();\n const lastEpoch = epochs[epochs.length - 1];\n const epochNumber = lastEpoch?.subject.assertion.number ?? 0;\n\n return { compacted, skipped, epochNumber };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { next as A, type Doc, toJS } from '@automerge/automerge';\nimport { type AnyDocumentId, type DocumentId } from '@automerge/automerge-repo';\nimport type * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { CreateEpochRequest } from '@dxos/client/halo';\nimport { type DocHandleProxy, ObjectCore, type RepoProxy, migrateDocument } from '@dxos/echo-client/internal';\nimport { type DatabaseDirectory, EncodedReference, type EntityStructure, SpaceDocVersion } from '@dxos/echo-protocol';\nimport { getSchemaURI } from '@dxos/echo/internal';\nimport * as Type from '@dxos/echo/Type';\nimport { invariant } from '@dxos/invariant';\nimport { EID, EntityId } from '@dxos/keys';\nimport { type MaybePromise } from '@dxos/util';\n\n/*\n\nConsidering a better API for this:\n\n```ts\nconst migration = space.db.beginMigration(); // all actions are not visible to queries and are only applied once you call `apply`\n\nmigration.applyObjectMigration(defineMigration(From, To, { ... }));\n\nmigration.delete(id);\nmigration.add(obj);\n\nawait migration.apply(); // Will create new epoch.\n```\n\n*/\n\n// TODO(dmaretskyi): We no longer need to hook into ECHO internals, with the changes to echo APIs.\nexport class MigrationBuilder {\n private readonly _repo: RepoProxy;\n private readonly _rootDoc: Doc<DatabaseDirectory>;\n\n // echoUri -> automergeUrl\n private readonly _newLinks: Record<string, string> = {};\n private readonly _flushIds: DocumentId[] = [];\n private readonly _deleteObjects: string[] = [];\n\n private _newRoot?: DocHandleProxy<DatabaseDirectory> = undefined;\n\n constructor(private readonly _space: Space) {\n this._repo = this._space.internal.db._repo;\n const rootDoc = this._space.internal.db._getSpaceRootDocHandle().doc();\n invariant(rootDoc, 'Space root document must be available when creating MigrationBuilder');\n this._rootDoc = rootDoc;\n }\n\n async findObject(id: string): Promise<EntityStructure | undefined> {\n const documentId = (this._rootDoc.links?.[id] || this._newLinks[id])?.toString() as AnyDocumentId | undefined;\n const docHandle = documentId && this._repo.find(documentId);\n if (!docHandle) {\n return undefined;\n }\n\n await docHandle.whenReady();\n const doc = docHandle.doc() as Doc<DatabaseDirectory>;\n return doc.objects?.[id];\n }\n\n async migrateObject(\n id: string,\n migrate: (objectStructure: EntityStructure) => MaybePromise<{ type: Type.AnyEntity; props: any }>,\n ): Promise<void> {\n const objectStructure = await this.findObject(id);\n if (!objectStructure) {\n return;\n }\n\n const { type, props } = await migrate(objectStructure);\n const schema = Type.getSchema(type);\n\n const oldHandle = await this._findObjectContainingHandle(id);\n invariant(oldHandle);\n\n const newState: DatabaseDirectory = {\n version: SpaceDocVersion.CURRENT,\n access: {\n spaceKey: this._space.key.toHex(),\n },\n objects: {\n [id]: {\n system: {\n type: EncodedReference.fromURI(getSchemaURI(schema)!),\n },\n data: props,\n meta: {\n keys: [],\n },\n },\n },\n };\n const migratedDoc = migrateDocument(oldHandle.doc() as Doc<DatabaseDirectory>, newState);\n const newHandle = this._repo.import<DatabaseDirectory>(A.save(migratedDoc));\n await newHandle.whenReady();\n invariant(newHandle.url, 'Migrated document URL not available after whenReady');\n this._newLinks[id] = newHandle.url;\n this._addHandleToFlushList(newHandle.documentId!);\n }\n\n async addObject(type: Type.AnyEntity, props: any): Promise<string> {\n const resolved = Type.getSchema(type);\n const core = await this._createObject({ schema: resolved, props });\n return core.id;\n }\n\n createReference(id: string) {\n invariant(EntityId.isValid(id), 'Invalid EntityId.');\n return EncodedReference.fromURI(EID.make({ entityId: id }));\n }\n\n deleteObject(id: string): void {\n this._deleteObjects.push(id);\n }\n\n /**\n * Re-materializes linked object documents into fresh Automerge docs without history.\n * Call {@link _commit} to publish a new space epoch with updated root links.\n */\n async compactLinkedDocuments(objectIds?: string[]): Promise<{ compacted: string[]; skipped: string[] }> {\n const linkIds = objectIds ?? Object.keys(this._rootDoc.links ?? {});\n const compacted: string[] = [];\n const skipped: string[] = [];\n\n for (const id of linkIds) {\n const oldHandle = await this._findObjectContainingHandle(id);\n if (!oldHandle) {\n skipped.push(id);\n continue;\n }\n\n await oldHandle.whenReady();\n const materialized = toJS(oldHandle.doc()!) as DatabaseDirectory;\n const newHandle = this._repo.create<DatabaseDirectory>(materialized);\n await newHandle.whenReady();\n invariant(newHandle.url, 'Compacted document URL not available after whenReady');\n this._newLinks[id] = newHandle.url;\n this._addHandleToFlushList(newHandle.documentId!);\n compacted.push(id);\n }\n\n return { compacted, skipped };\n }\n\n async changeProperties(changeFn: (properties: EntityStructure) => void): Promise<void> {\n if (!this._newRoot) {\n await this._buildNewRoot();\n }\n invariant(this._newRoot, 'New root not created');\n\n this._newRoot.change((doc: DatabaseDirectory) => {\n const propertiesStructure = doc.objects?.[this._space.properties.id];\n propertiesStructure && changeFn(propertiesStructure);\n });\n await this._newRoot.whenReady();\n this._addHandleToFlushList(this._newRoot.documentId!);\n }\n\n /**\n * @internal\n */\n async _commit(): Promise<void> {\n if (!this._newRoot) {\n await this._buildNewRoot();\n }\n invariant(this._newRoot, 'New root not created');\n\n await this._space.db.flush();\n\n // Create new epoch.\n invariant(this._newRoot.url, 'New root URL not available');\n await this._space.internal.createEpoch({\n migration: CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT,\n automergeRootUrl: this._newRoot.url,\n });\n }\n\n private async _findObjectContainingHandle(id: string): Promise<DocHandleProxy<DatabaseDirectory> | undefined> {\n const documentId = (this._rootDoc.links?.[id] || this._newLinks[id])?.toString() as AnyDocumentId | undefined;\n const docHandle = documentId && this._repo.find(documentId);\n if (!docHandle) {\n return undefined;\n }\n\n await docHandle.whenReady();\n return docHandle;\n }\n\n private async _buildNewRoot(): Promise<void> {\n const links = { ...(this._rootDoc.links ?? {}) };\n for (const id of this._deleteObjects) {\n delete links[id];\n }\n\n for (const [id, url] of Object.entries(this._newLinks)) {\n links[id] = new A.RawString(url);\n }\n\n this._newRoot = this._repo.create<DatabaseDirectory>({\n version: SpaceDocVersion.CURRENT,\n access: {\n spaceKey: this._space.key.toHex(),\n },\n objects: this._rootDoc.objects,\n links,\n });\n await this._newRoot.whenReady();\n this._addHandleToFlushList(this._newRoot.documentId!);\n }\n\n private async _createObject({\n id,\n schema,\n props,\n }: {\n id?: string;\n schema: Schema.Schema.AnyNoContext;\n props: any;\n }): Promise<ObjectCore> {\n const core = new ObjectCore();\n if (id) {\n core.id = id;\n }\n\n core.initNewObject(props);\n core.setType(EncodedReference.fromURI(getSchemaURI(schema)!));\n const newHandle = this._repo.create<DatabaseDirectory>({\n version: SpaceDocVersion.CURRENT,\n access: {\n spaceKey: this._space.key.toHex(),\n },\n objects: {\n [core.id]: core.getDoc() as EntityStructure,\n },\n });\n await newHandle.whenReady();\n this._newLinks[core.id] = newHandle.url!;\n this._addHandleToFlushList(newHandle.documentId!);\n\n return core;\n }\n\n private _addHandleToFlushList(id: DocumentId): void {\n this._flushIds.push(id);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Atom } from '@effect-atom/atom';\nimport * as Registry from '@effect-atom/atom/Registry';\nimport * as Option from 'effect/Option';\n\nimport { type Space, SpaceState } from '@dxos/client/echo';\nimport { Annotation, Obj } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { MigrationVersionAnnotation } from './annotations';\nimport { MigrationBuilder } from './migration-builder';\n\nexport type MigrationContext = {\n space: Space;\n builder: MigrationBuilder;\n};\n\nexport type Migration = {\n version: string;\n next: (context: MigrationContext) => MaybePromise<void>;\n};\n\nexport class Migrations {\n static namespace?: string;\n static migrations: Migration[] = [];\n private static _registry = Registry.make();\n private static _stateAtom = Atom.make<{ running: string[] }>({ running: [] }).pipe(Atom.keepAlive);\n\n /**\n * @deprecated Use `MigrationVersionAnnotation` via `Annotation.get/set` on space properties.\n */\n static get versionProperty() {\n return this.namespace && `${this.namespace}.version`;\n }\n\n static get targetVersion() {\n return this.migrations[this.migrations.length - 1]?.version;\n }\n\n static running(space: Space): boolean {\n const state = this._registry.get(this._stateAtom);\n return state.running.includes(space.key.toHex());\n }\n\n static define(namespace: string, migrations: Migration[]): void {\n this.namespace = namespace;\n this.migrations = migrations;\n }\n\n static async migrate(space: Space, targetVersion?: string | number): Promise<boolean> {\n invariant(!this.running(space), 'Migration already running');\n invariant(space.state.get() === SpaceState.SPACE_READY, 'Space not ready');\n const currentVersion = Annotation.get(space.properties, MigrationVersionAnnotation).pipe(Option.getOrUndefined);\n const currentIndex = this.migrations.findIndex((m) => m.version === currentVersion) + 1;\n const i = this.migrations.findIndex((m) => m.version === targetVersion);\n const targetIndex = i === -1 ? this.migrations.length : i + 1;\n if (currentIndex === targetIndex) {\n return false;\n }\n\n const spaceKey = space.key.toHex();\n const currentState = this._registry.get(this._stateAtom);\n this._registry.set(this._stateAtom, { running: [...currentState.running, spaceKey] });\n try {\n if (targetIndex > currentIndex) {\n const migrations = this.migrations.slice(currentIndex, targetIndex);\n for (const migration of migrations) {\n const builder = new MigrationBuilder(space);\n await migration.next({ space, builder });\n await builder._commit();\n Obj.update(space.properties, (properties) => {\n Annotation.set(properties, MigrationVersionAnnotation, migration.version);\n });\n }\n }\n } finally {\n const finalState = this._registry.get(this._stateAtom);\n this._registry.set(this._stateAtom, { running: finalState.running.filter((key) => key !== spaceKey) });\n }\n\n return true;\n }\n}\n"],
5
- "mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAGpB,IAAMC,6BAA6BD,WAAWE,KAAK;EACxDC,IAAI;EACJC,QAAeC;AACjB,CAAA;;;ACRA,SAAqBC,kBAAkB;AACvC,SAASC,aAAAA,kBAAiB;;;ACD1B,SAASC,QAAQC,GAAaC,YAAY;AAK1C,SAASC,0BAA0B;AACnC,SAA8BC,YAA4BC,uBAAuB;AACjF,SAAiCC,kBAAwCC,uBAAuB;AAChG,SAASC,oBAAoB;AAC7B,YAAYC,UAAU;AACtB,SAASC,iBAAiB;AAC1B,SAASC,KAAKC,gBAAgB;AAG9B,IAAA,eAAA;AAmBmBC,IAAiB,mBAAjBA,MAAiB;EACjBC;EAEjB;EACiBC;;EAEAC,YAAAA,CAAAA;EAETC,YAA+CC,CAAAA;EAEvD,iBAA6BC,CAAa;aAAbA;cACtBN,QAAQ;AACb,SAAA,SAAMO;AACNV,SAAAA,QAAUU,KAAAA,OAAS,S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,mBAAYP,EAAAA,YAAkB,YAAA,GAAAhB,eAAA,GAAA,IAAA,GAAA,MAAA,GAAA,CAAA,gDAAA,mBAAA,EAAA,CAAA;AACtF,UAAMwB,iBAAStB,YAAWoB,IAAWG,MAAQF,YAAYf,0BAAAA,EAAAA,KAAAA,qBAAAA;AACzD,UAAMkB,eAAcF,KAAM,WAAUtB,UAAWyB,CAAAA,MAAAA,EAAM,YAAO,cAAA,IAAA;AAC5D,UAAIN,IAAAA,KAAAA,WAAiBK,UAAa,CAAA,MAAA,EAAA,YAAA,aAAA;UAChC,cAAO,MAAA,KAAA,KAAA,WAAA,SAAA,IAAA;AACT,QAAA,iBAAA,aAAA;AAEA,aAAME;IACN;AACA,UAAKzB,WAAU0B,MAAQ,IAACzB,MAAAA;UAAcE,eAAS,KAAA,UAAA,IAAA,KAAA,UAAA;mBAAIwB,IAAAA,KAAaxB,YAAO;eAAEsB;QAAS,GAAA,aAAA;QAAC;MAC/E;;;UAGA,cAAWG,cAAa7B;cACtB,aAAM8B,KAAcC,WAAAA,MAAiBxB,cAAAA,WAAAA;mBAC/BsB,aAAc,YAAC;gBAAEtB,UAAAA,IAAAA,iBAAAA,KAAAA;gBAAOuB,UAAAA,KAAAA;YAAQ;YACtC;UACAE,CAAAA;gBACEjB,QAAAA,QAAekB;AACjB,cAAA,OAAA,MAAA,YAAA,CAAA,eAAA;AACF,YAAAlB,YAAA,IAAA,YAAA,4BAAA,UAAA,OAAA;UACF,CAAA;QACF;MACE;;YACsCX,aAAS8B,KAAW9B,UAAQ+B,IAAM,KAAEC,UAAQA;AAAkB,WAAA,UAAA,IAAA,KAAA,YAAA;QACtG,SAAA,WAAA,QAAA,OAAA,CAAA,QAAA,QAAA,QAAA;MAEA,CAAA;IACF;AACF,WAAA;;;",
6
- "names": ["Schema", "Annotation", "MigrationVersionAnnotation", "make", "id", "schema", "String", "SpaceState", "invariant", "next", "A", "toJS", "CreateEpochRequest", "ObjectCore", "migrateDocument", "EncodedReference", "SpaceDocVersion", "getSchemaURI", "Type", "invariant", "EID", "EntityId", "_repo", "_rootDoc", "_newLinks", "_deleteObjects", "_newRoot", "undefined", "_space", "rootDoc", "findObject", "docHandle", "objects", "migrateObject", "migrate", "objectStructure", "oldHandle", "_findObjectContainingHandle", "newState", "version", "access", "spaceKey", "system", "data", "props", "meta", "keys", "newHandle", "whenReady", "id", "_addHandleToFlushList", "addObject", "core", "_createObject", "schema", "resolved", "createReference", "entityId", "deleteObject", "skipped", "linkIds", "compacted", "_buildNewRoot", "propertiesStructure", "properties", "changeFn", "migration", "REPLACE_AUTOMERGE_ROOT", "automergeRootUrl", "documentId", "url", "create", "links", "initNewObject", "CURRENT", "__dxlog_file", "builder", "space", "invariant", "compacted", "skipped", "compactLinkedDocuments", "_commit", "epochs", "internal", "getEpochs", "lastEpoch", "epochNumber", "subject", "assertion", "Atom", "Registry", "Option", "SpaceState", "Annotation", "Obj", "invariant", "__dxlog_file", "Migrations", "migrations", "_registry", "_stateAtom", "Atom", "running", "keepAlive", "targetVersion", "space", "state", "define", "namespace", "invariant", "get", "SpaceState", "currentVersion", "Annotation", "MigrationVersionAnnotation", "pipe", "getOrUndefined", "currentIndex", "findIndex", "version", "i", "m", "targetIndex", "length", "spaceKey", "set", "currentState", "migration", "builder", "MigrationBuilder", "Obj", "properties", "finalState", "filter", "key"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"src/annotations.ts":{"bytes":1241,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/migration-builder.ts":{"bytes":28104,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/halo","kind":"import-statement","external":true},{"path":"@dxos/echo-client/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/Type","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/document-compaction.ts":{"bytes":4389,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/migration-builder.ts","kind":"import-statement","original":"./migration-builder"}],"format":"esm"},"src/migrations.ts":{"bytes":11492,"imports":[{"path":"@effect-atom/atom","kind":"import-statement","external":true},{"path":"@effect-atom/atom/Registry","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/annotations.ts","kind":"import-statement","original":"./annotations"},{"path":"src/migration-builder.ts","kind":"import-statement","original":"./migration-builder"}],"format":"esm"},"src/index.ts":{"bytes":789,"imports":[{"path":"src/annotations.ts","kind":"import-statement","original":"./annotations"},{"path":"src/document-compaction.ts","kind":"import-statement","original":"./document-compaction"},{"path":"src/migration-builder.ts","kind":"import-statement","original":"./migration-builder"},{"path":"src/migrations.ts","kind":"import-statement","original":"./migrations"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":21776},"dist/lib/browser/index.mjs":{"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/halo","kind":"import-statement","external":true},{"path":"@dxos/echo-client/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/Type","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@effect-atom/atom","kind":"import-statement","external":true},{"path":"@effect-atom/atom/Registry","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["MigrationBuilder","MigrationVersionAnnotation","Migrations","compactDocumentsEpochMigration"],"entryPoint":"src/index.ts","inputs":{"src/annotations.ts":{"bytesInOutput":198},"src/index.ts":{"bytesInOutput":0},"src/document-compaction.ts":{"bytesInOutput":936},"src/migration-builder.ts":{"bytesInOutput":7116},"src/migrations.ts":{"bytesInOutput":2999}},"bytes":11528}}}