@dxos/migrations 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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/lib/browser/index.mjs +22 -51
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +22 -51
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/migration-builder.d.ts +1 -1
- package/dist/types/src/migration-builder.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/migration-builder.ts +5 -5
- package/src/migrations.test.ts +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/migrations",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ae835ea",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@automerge/automerge": "3.1.2",
|
|
29
|
-
"@automerge/automerge-repo": "2.
|
|
30
|
-
"@dxos/client": "0.8.4-main.
|
|
31
|
-
"@dxos/echo
|
|
32
|
-
"@dxos/echo-
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/protocols": "0.8.4-main.
|
|
36
|
-
"@dxos/util": "0.8.4-main.
|
|
37
|
-
"@dxos/log": "0.8.4-main.
|
|
29
|
+
"@automerge/automerge-repo": "2.4.0",
|
|
30
|
+
"@dxos/client": "0.8.4-main.ae835ea",
|
|
31
|
+
"@dxos/echo": "0.8.4-main.ae835ea",
|
|
32
|
+
"@dxos/echo-db": "0.8.4-main.ae835ea",
|
|
33
|
+
"@dxos/echo-protocol": "0.8.4-main.ae835ea",
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
35
|
+
"@dxos/protocols": "0.8.4-main.ae835ea",
|
|
36
|
+
"@dxos/util": "0.8.4-main.ae835ea",
|
|
37
|
+
"@dxos/log": "0.8.4-main.ae835ea"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {},
|
|
40
40
|
"publishConfig": {
|
package/src/migration-builder.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { next as A, type Doc } from '@automerge/automerge';
|
|
6
6
|
import { type AnyDocumentId, type DocumentId } from '@automerge/automerge-repo';
|
|
7
|
-
import
|
|
7
|
+
import type * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
9
|
import { type Space } from '@dxos/client/echo';
|
|
10
10
|
import { CreateEpochRequest } from '@dxos/client/halo';
|
|
11
|
+
import { requireTypeReference } from '@dxos/echo/internal';
|
|
11
12
|
import { type DocHandleProxy, ObjectCore, type RepoProxy, migrateDocument } from '@dxos/echo-db';
|
|
12
13
|
import {
|
|
13
14
|
type DatabaseDirectory,
|
|
@@ -16,7 +17,6 @@ import {
|
|
|
16
17
|
SpaceDocVersion,
|
|
17
18
|
encodeReference,
|
|
18
19
|
} from '@dxos/echo-protocol';
|
|
19
|
-
import { requireTypeReference } from '@dxos/echo-schema';
|
|
20
20
|
import { invariant } from '@dxos/invariant';
|
|
21
21
|
import { type MaybePromise } from '@dxos/util';
|
|
22
22
|
|
|
@@ -101,7 +101,7 @@ export class MigrationBuilder {
|
|
|
101
101
|
},
|
|
102
102
|
};
|
|
103
103
|
const migratedDoc = migrateDocument(oldHandle.doc() as Doc<DatabaseDirectory>, newState);
|
|
104
|
-
const newHandle = this._repo.import<DatabaseDirectory>(
|
|
104
|
+
const newHandle = this._repo.import<DatabaseDirectory>(A.save(migratedDoc));
|
|
105
105
|
this._newLinks[id] = newHandle.url;
|
|
106
106
|
this._addHandleToFlushList(newHandle);
|
|
107
107
|
}
|
|
@@ -168,7 +168,7 @@ export class MigrationBuilder {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
for (const [id, url] of Object.entries(this._newLinks)) {
|
|
171
|
-
links[id] = new
|
|
171
|
+
links[id] = new A.RawString(url);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
this._newRoot = this._repo.create<DatabaseDirectory>({
|
package/src/migrations.test.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
|
-
import { Filter, type Space
|
|
8
|
+
import { Filter, type Space } from '@dxos/client/echo';
|
|
9
9
|
import { TestBuilder } from '@dxos/client/testing';
|
|
10
|
-
import {
|
|
10
|
+
import { Obj, Type } from '@dxos/echo';
|
|
11
|
+
import { Expando } from '@dxos/echo/internal';
|
|
11
12
|
|
|
12
13
|
import { Migrations } from './migrations';
|
|
13
14
|
|
|
@@ -75,7 +76,7 @@ describe('Migrations', () => {
|
|
|
75
76
|
|
|
76
77
|
test('if some migrations have been run before, runs only the remaining migrations', async () => {
|
|
77
78
|
space.properties['test.version'] = '1970-01-02';
|
|
78
|
-
space.db.add(
|
|
79
|
+
space.db.add(Obj.make(Type.Expando, { namespace: 'test', count: 5 }));
|
|
79
80
|
await Migrations.migrate(space);
|
|
80
81
|
const { objects } = await space.db.query(Filter.type(Expando, { namespace: 'test' })).run();
|
|
81
82
|
expect(objects).to.have.length(1);
|