@dxos/echo-generator 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/{browser → neutral}/index.mjs +80 -120
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/types/src/data.d.ts +4 -4
- package/dist/types/src/data.d.ts.map +1 -1
- package/dist/types/src/generator.d.ts +10 -13
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -8
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/data.ts +31 -30
- package/src/generator.test.ts +18 -18
- package/src/generator.ts +36 -38
- package/src/types.ts +5 -9
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -317
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-generator",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.effb148878",
|
|
4
4
|
"description": "ECHO data generator for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "info@dxos.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
17
|
"source": "./src/index.ts",
|
|
14
18
|
"types": "./dist/types/src/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
17
20
|
}
|
|
18
21
|
},
|
|
19
22
|
"types": "dist/types/src/index.d.ts",
|
|
20
|
-
"typesVersions": {
|
|
21
|
-
"*": {}
|
|
22
|
-
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
25
|
"src"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@automerge/automerge": "3.
|
|
29
|
-
"effect": "3.
|
|
30
|
-
"@dxos/client": "0.8.4-main.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/echo
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/node-std": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
28
|
+
"@automerge/automerge": "3.2.6",
|
|
29
|
+
"effect": "3.20.0",
|
|
30
|
+
"@dxos/client": "0.8.4-main.effb148878",
|
|
31
|
+
"@dxos/context": "0.8.4-main.effb148878",
|
|
32
|
+
"@dxos/echo": "0.8.4-main.effb148878",
|
|
33
|
+
"@dxos/echo-db": "0.8.4-main.effb148878",
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.effb148878",
|
|
35
|
+
"@dxos/node-std": "0.8.4-main.effb148878",
|
|
36
|
+
"@dxos/util": "0.8.4-main.effb148878",
|
|
37
|
+
"@dxos/log": "0.8.4-main.effb148878"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@dxos/random": "0.8.4-main.
|
|
40
|
+
"@dxos/random": "0.8.4-main.effb148878"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"effect": "
|
|
44
|
-
"@dxos/random": "0.8.4-main.
|
|
43
|
+
"effect": "3.20.0",
|
|
44
|
+
"@dxos/random": "0.8.4-main.effb148878"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
package/src/data.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import { next as A } from '@automerge/automerge';
|
|
6
6
|
import * as Schema from 'effect/Schema';
|
|
7
7
|
|
|
8
|
-
import { type Space
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { type Space } from '@dxos/client/echo';
|
|
9
|
+
import { DXN, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
11
12
|
|
|
12
13
|
import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
|
|
13
14
|
import { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';
|
|
@@ -24,10 +25,10 @@ export const Priority = [1, 2, 3, 4, 5];
|
|
|
24
25
|
* @deprecated
|
|
25
26
|
*/
|
|
26
27
|
export enum TestSchemaType {
|
|
27
|
-
document = 'example.
|
|
28
|
-
organization = 'example.
|
|
29
|
-
contact = 'example.
|
|
30
|
-
project = 'example.
|
|
28
|
+
document = 'com.example.type.document',
|
|
29
|
+
organization = 'com.example.type.organization',
|
|
30
|
+
contact = 'com.example.type.person',
|
|
31
|
+
project = 'com.example.type.project',
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -37,21 +38,21 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
|
|
|
37
38
|
const document = Schema.Struct({
|
|
38
39
|
title: Schema.String.annotations({ description: 'title of the document' }),
|
|
39
40
|
content: Schema.String,
|
|
40
|
-
}).pipe(
|
|
41
|
+
}).pipe(Type.makeObject(DXN.make(TestSchemaType.document, '0.1.0')));
|
|
41
42
|
|
|
42
43
|
const organization = Schema.Struct({
|
|
43
44
|
name: Schema.String.annotations({ description: 'name of the company or organization' }),
|
|
44
45
|
website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),
|
|
45
46
|
description: Schema.String.annotations({ description: 'short summary of the company' }),
|
|
46
|
-
}).pipe(
|
|
47
|
+
}).pipe(Type.makeObject(DXN.make(TestSchemaType.organization, '0.1.0')));
|
|
47
48
|
|
|
48
49
|
const contact = Schema.Struct({
|
|
49
50
|
name: Schema.String.annotations({ description: 'name of the person' }),
|
|
50
51
|
email: Schema.optional(Schema.String),
|
|
51
|
-
org: Schema.optional(Ref(organization)),
|
|
52
|
+
org: Schema.optional(Ref.Ref(organization)),
|
|
52
53
|
lat: Schema.optional(Schema.Number),
|
|
53
54
|
lng: Schema.optional(Schema.Number),
|
|
54
|
-
}).pipe(
|
|
55
|
+
}).pipe(Type.makeObject(DXN.make(TestSchemaType.contact, '0.1.0')));
|
|
55
56
|
|
|
56
57
|
const project = Schema.Struct({
|
|
57
58
|
name: Schema.String.annotations({ description: 'name of the project' }),
|
|
@@ -61,8 +62,8 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
|
|
|
61
62
|
status: Schema.String,
|
|
62
63
|
priority: Schema.Number,
|
|
63
64
|
active: Schema.Boolean,
|
|
64
|
-
org: Schema.optional(Ref(organization)),
|
|
65
|
-
}).pipe(
|
|
65
|
+
org: Schema.optional(Ref.Ref(organization)),
|
|
66
|
+
}).pipe(Type.makeObject(DXN.make(TestSchemaType.project, '0.1.0')));
|
|
66
67
|
|
|
67
68
|
return {
|
|
68
69
|
[TestSchemaType.document]: document,
|
|
@@ -74,39 +75,39 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
|
|
|
74
75
|
|
|
75
76
|
const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
|
|
76
77
|
[TestSchemaType.document]: async () => ({
|
|
77
|
-
title:
|
|
78
|
-
content:
|
|
78
|
+
title: random.lorem.sentence(3),
|
|
79
|
+
content: random.lorem.sentences({ min: 1, max: random.number.int({ min: 1, max: 3 }) }),
|
|
79
80
|
}),
|
|
80
81
|
|
|
81
82
|
[TestSchemaType.organization]: async () => ({
|
|
82
|
-
name:
|
|
83
|
-
website:
|
|
84
|
-
description:
|
|
83
|
+
name: random.company.name(),
|
|
84
|
+
website: random.datatype.boolean({ probability: 0.3 }) ? random.internet.url() : undefined,
|
|
85
|
+
description: random.lorem.sentences(),
|
|
85
86
|
}),
|
|
86
87
|
|
|
87
88
|
[TestSchemaType.contact]: async (provider) => {
|
|
88
89
|
const organizations = await provider?.(TestSchemaType.organization);
|
|
89
|
-
const location =
|
|
90
|
+
const location = random.datatype.boolean() ? random.geo.airport() : {};
|
|
90
91
|
|
|
91
92
|
return {
|
|
92
|
-
name:
|
|
93
|
-
email:
|
|
93
|
+
name: random.person.fullName(),
|
|
94
|
+
email: random.datatype.boolean({ probability: 0.5 }) ? random.internet.email() : undefined,
|
|
94
95
|
org:
|
|
95
|
-
organizations?.length &&
|
|
96
|
-
? Ref.make(
|
|
96
|
+
organizations?.length && random.datatype.boolean({ probability: 0.8 })
|
|
97
|
+
? Ref.make(random.helpers.arrayElement(organizations))
|
|
97
98
|
: undefined,
|
|
98
99
|
...location,
|
|
99
100
|
};
|
|
100
101
|
},
|
|
101
102
|
|
|
102
103
|
[TestSchemaType.project]: async () => ({
|
|
103
|
-
name:
|
|
104
|
-
repo:
|
|
105
|
-
status:
|
|
106
|
-
description:
|
|
107
|
-
website:
|
|
108
|
-
priority:
|
|
109
|
-
active:
|
|
104
|
+
name: random.commerce.productName(),
|
|
105
|
+
repo: random.internet.url(),
|
|
106
|
+
status: random.helpers.arrayElement(Status),
|
|
107
|
+
description: random.lorem.sentences(),
|
|
108
|
+
website: random.internet.url(),
|
|
109
|
+
priority: random.helpers.arrayElement(Priority),
|
|
110
|
+
active: random.datatype.boolean(),
|
|
110
111
|
}),
|
|
111
112
|
};
|
|
112
113
|
|
package/src/generator.test.ts
CHANGED
|
@@ -7,14 +7,14 @@ import * as Schema from 'effect/Schema';
|
|
|
7
7
|
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
8
8
|
|
|
9
9
|
import { Client } from '@dxos/client';
|
|
10
|
-
import {
|
|
10
|
+
import { DXN, Obj, Type } from '@dxos/echo';
|
|
11
11
|
import { getObjectCore } from '@dxos/echo-db';
|
|
12
|
-
import {
|
|
12
|
+
import { random } from '@dxos/random';
|
|
13
13
|
|
|
14
14
|
import { TestSchemaType, createSpaceObjectGenerator, createTestObjectGenerator } from './data';
|
|
15
15
|
import { SpaceObjectGenerator } from './generator';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
random.seed(3);
|
|
18
18
|
|
|
19
19
|
describe('TestObjectGenerator', () => {
|
|
20
20
|
// TODO(burdon): Use TestBuilder.
|
|
@@ -43,7 +43,7 @@ describe('TestObjectGenerator', () => {
|
|
|
43
43
|
|
|
44
44
|
// Create org object.
|
|
45
45
|
const organization = await generator.createObject({ types: [TestSchemaType.organization] });
|
|
46
|
-
expect(
|
|
46
|
+
expect(Obj.getTypeURI(organization)).to.exist;
|
|
47
47
|
|
|
48
48
|
// Expect at least one person object with a linked org reference.
|
|
49
49
|
const objects = await generator.createObjects({ [TestSchemaType.contact]: 10 });
|
|
@@ -59,26 +59,27 @@ describe('TestObjectGenerator', () => {
|
|
|
59
59
|
const generator = createSpaceObjectGenerator(space);
|
|
60
60
|
await generator.addSchemas();
|
|
61
61
|
const organization = await generator.createObject({ types: [TestSchemaType.organization] });
|
|
62
|
-
schemaId.push(
|
|
62
|
+
schemaId.push(Obj.getTypeURI(organization)!.toString());
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
{
|
|
66
66
|
const generator = createSpaceObjectGenerator(space);
|
|
67
67
|
await generator.addSchemas();
|
|
68
68
|
const organization = await generator.createObject({ types: [TestSchemaType.organization] });
|
|
69
|
-
schemaId.push(
|
|
69
|
+
schemaId.push(Obj.getTypeURI(organization)!.toString());
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
expect(schemaId[0]).not.to.be.undefined;
|
|
73
73
|
expect(schemaId[0]).to.eq(schemaId[1]);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
// flaky
|
|
77
|
+
test.skip('mutations', async () => {
|
|
77
78
|
const { space } = await setupTest();
|
|
78
79
|
const generator = createSpaceObjectGenerator(space);
|
|
79
80
|
await generator.addSchemas();
|
|
80
81
|
const document = await generator.createObject({ types: [TestSchemaType.document] });
|
|
81
|
-
expect(
|
|
82
|
+
expect(Obj.getTypeURI(document)).to.exist;
|
|
82
83
|
|
|
83
84
|
const beforeChangesCount = A.getAllChanges(getObjectCore(document).docHandle!.doc()).length;
|
|
84
85
|
|
|
@@ -92,28 +93,27 @@ describe('TestObjectGenerator', () => {
|
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
test('create object with in memory schema', async () => {
|
|
95
|
-
|
|
96
|
-
typename: 'example.org/type/Task',
|
|
97
|
-
version: '0.1.0',
|
|
98
|
-
})({
|
|
96
|
+
const Task = Schema.Struct({
|
|
99
97
|
name: Schema.optional(Schema.String),
|
|
100
|
-
})
|
|
98
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.task', '0.1.0')));
|
|
101
99
|
|
|
102
100
|
enum Types {
|
|
103
|
-
task = 'example.
|
|
101
|
+
task = 'com.example.type.task',
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
const { space } = await setupTest();
|
|
107
105
|
const generator = new SpaceObjectGenerator<Types>(
|
|
108
106
|
space,
|
|
109
|
-
{
|
|
107
|
+
{
|
|
108
|
+
[Types.task]: Task,
|
|
109
|
+
},
|
|
110
110
|
{
|
|
111
111
|
[Types.task]: () => ({ name: 'Default' }),
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
[Types.task]: async (task, params) => {
|
|
115
115
|
for (const _ in Array.from({ length: params.count })) {
|
|
116
|
-
task.name =
|
|
116
|
+
task.name = random.lorem.sentence();
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
},
|
|
@@ -121,7 +121,7 @@ describe('TestObjectGenerator', () => {
|
|
|
121
121
|
await generator.addSchemas();
|
|
122
122
|
|
|
123
123
|
const todo = await generator.createObject({ types: [Types.task] });
|
|
124
|
-
expect(
|
|
124
|
+
expect(Obj.getTypeURI(todo)).to.exist;
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
test('references', async () => {
|
|
@@ -141,7 +141,7 @@ describe('TestObjectGenerator', () => {
|
|
|
141
141
|
test('create project', async () => {
|
|
142
142
|
const generator = createTestObjectGenerator();
|
|
143
143
|
const project = await generator.createObject({ types: [TestSchemaType.project] });
|
|
144
|
-
expect(
|
|
144
|
+
expect(Obj.getTypeURI(project)).to.exist;
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
test('create object with not type', async () => {
|
package/src/generator.ts
CHANGED
|
@@ -2,20 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo/internal';
|
|
10
|
-
import { type AnyLiveObject } from '@dxos/echo-db';
|
|
5
|
+
import { type Space } from '@dxos/client/echo';
|
|
6
|
+
import { Filter, Obj, Type } from '@dxos/echo';
|
|
7
|
+
import { isProxy } from '@dxos/echo/internal';
|
|
11
8
|
import { invariant } from '@dxos/invariant';
|
|
12
|
-
import {
|
|
13
|
-
import { faker } from '@dxos/random';
|
|
9
|
+
import { random } from '@dxos/random';
|
|
14
10
|
import { entries, range } from '@dxos/util';
|
|
15
11
|
|
|
16
12
|
import { type TestSchemaType } from './data';
|
|
17
13
|
import {
|
|
18
|
-
type
|
|
14
|
+
type MutationsProviderProps,
|
|
19
15
|
type TestGeneratorMap,
|
|
20
16
|
type TestMutationsMap,
|
|
21
17
|
type TestObjectProvider,
|
|
@@ -29,37 +25,38 @@ import {
|
|
|
29
25
|
export class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
30
26
|
// prettier-ignore
|
|
31
27
|
constructor(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
protected readonly _schemas: TestSchemaMap<T>,
|
|
29
|
+
private readonly _generators: TestGeneratorMap<T>,
|
|
30
|
+
private readonly _provider?: TestObjectProvider<T>,
|
|
31
|
+
) {}
|
|
36
32
|
|
|
37
|
-
get schemas():
|
|
33
|
+
get schemas(): Type.AnyObj[] {
|
|
38
34
|
return Object.values(this._schemas);
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
getSchema(type: T):
|
|
42
|
-
return this.schemas.find((schema) =>
|
|
37
|
+
getSchema(type: T): Type.AnyObj | undefined {
|
|
38
|
+
return this.schemas.find((schema) => Type.getTypename(schema) === type);
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
protected setSchema(type: T, schema:
|
|
41
|
+
protected setSchema(type: T, schema: Type.AnyEntity): void {
|
|
46
42
|
this._schemas[type] = schema;
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
async createObject({ types }: { types?: T[] } = {}): Promise<
|
|
50
|
-
const type =
|
|
45
|
+
async createObject({ types }: { types?: T[] } = {}): Promise<any> {
|
|
46
|
+
const type = random.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));
|
|
51
47
|
const data = await this._generators[type](this._provider);
|
|
52
|
-
if (
|
|
48
|
+
if (isProxy(data)) {
|
|
53
49
|
return data;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
const schema = this.getSchema(type);
|
|
57
|
-
|
|
53
|
+
invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);
|
|
54
|
+
return Obj.make(schema, data);
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
61
58
|
async createObjects(map: Partial<Record<T, number>>) {
|
|
62
|
-
const results:
|
|
59
|
+
const results: any[] = [];
|
|
63
60
|
for (const [type, count] of entries(map)) {
|
|
64
61
|
results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));
|
|
65
62
|
}
|
|
@@ -86,15 +83,15 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
86
83
|
) {
|
|
87
84
|
super(schemaMap, generators, async (type: T) => {
|
|
88
85
|
const schema = this.getSchema(type);
|
|
89
|
-
const
|
|
86
|
+
const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
|
|
90
87
|
return objects;
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
async addSchemas() {
|
|
95
|
-
const result:
|
|
92
|
+
const result: Type.AnyEntity[] = [];
|
|
96
93
|
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
97
|
-
const echoSchema = await this._maybeRegisterSchema(typename, schema as
|
|
94
|
+
const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.AnyObj);
|
|
98
95
|
this.setSchema(typename as T, echoSchema);
|
|
99
96
|
result.push(echoSchema);
|
|
100
97
|
}
|
|
@@ -102,40 +99,41 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
102
99
|
return result;
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
override async createObject({
|
|
102
|
+
override async createObject({
|
|
103
|
+
types,
|
|
104
|
+
}: {
|
|
105
|
+
types?: T[];
|
|
106
|
+
} = {}): Promise<Obj.Any> {
|
|
106
107
|
return this._space.db.add(await super.createObject({ types }));
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
private async _maybeRegisterSchema(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
): Promise<EchoSchema | Schema.Schema.AnyNoContext> {
|
|
113
|
-
if (schema instanceof EchoSchema) {
|
|
114
|
-
const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
|
|
110
|
+
private async _maybeRegisterSchema(typename: string, schema: Type.AnyEntity): Promise<Type.AnyEntity> {
|
|
111
|
+
if (Type.getDatabase(schema) != null) {
|
|
112
|
+
const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
|
|
115
113
|
if (existingSchema != null) {
|
|
116
114
|
return existingSchema;
|
|
117
115
|
}
|
|
118
|
-
const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);
|
|
116
|
+
const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);
|
|
119
117
|
return registeredSchema;
|
|
120
118
|
} else {
|
|
121
|
-
const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
|
|
119
|
+
const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);
|
|
122
120
|
if (existingSchema != null) {
|
|
123
121
|
return existingSchema;
|
|
124
122
|
}
|
|
125
|
-
this._space.db.graph.schemaRegistry.
|
|
123
|
+
await this._space.internal.db.graph.schemaRegistry.register([schema]);
|
|
126
124
|
return schema;
|
|
127
125
|
}
|
|
128
126
|
}
|
|
129
127
|
|
|
130
|
-
async mutateObject(object:
|
|
128
|
+
async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {
|
|
131
129
|
invariant(this._mutations, 'Mutations not defined.');
|
|
132
|
-
const type =
|
|
130
|
+
const type = Type.getTypename(Obj.getType(object)!) as T;
|
|
133
131
|
invariant(type && this._mutations?.[type], 'Invalid object type.');
|
|
134
132
|
|
|
135
133
|
await this._mutations;
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
async mutateObjects(objects:
|
|
136
|
+
async mutateObjects(objects: Obj.Any[], params: MutationsProviderProps): Promise<void> {
|
|
139
137
|
for (const object of objects) {
|
|
140
138
|
await this.mutateObject(object, params);
|
|
141
139
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
|
|
7
|
-
import { type EchoSchema } from '@dxos/echo/internal';
|
|
8
|
-
import { type AnyLiveObject } from '@dxos/echo-db';
|
|
9
|
-
import { type Live } from '@dxos/live-object';
|
|
5
|
+
import { type Obj, type Type } from '@dxos/echo';
|
|
10
6
|
|
|
11
7
|
// TODO(burdon): Use echo-schema types.
|
|
12
8
|
export type TestObject = { id: string } & Record<string, any>;
|
|
13
9
|
|
|
14
|
-
export type TestSchemaMap<T extends string = string> = Record<T,
|
|
10
|
+
export type TestSchemaMap<T extends string = string> = Record<T, Type.AnyEntity>;
|
|
15
11
|
|
|
16
|
-
export type TestObjectProvider<T extends string = string> = (type: T) => Promise<
|
|
12
|
+
export type TestObjectProvider<T extends string = string> = (type: T) => Promise<any[]>;
|
|
17
13
|
|
|
18
14
|
export type TestGeneratorMap<T extends string = string> = Record<
|
|
19
15
|
T,
|
|
@@ -22,10 +18,10 @@ export type TestGeneratorMap<T extends string = string> = Record<
|
|
|
22
18
|
|
|
23
19
|
export type TestMutationsMap<T extends string = string> = Record<T, TestObjectMutators>;
|
|
24
20
|
|
|
25
|
-
export type
|
|
21
|
+
export type MutationsProviderProps = {
|
|
26
22
|
count: number;
|
|
27
23
|
mutationSize: number;
|
|
28
24
|
maxContentLength: number;
|
|
29
25
|
};
|
|
30
26
|
|
|
31
|
-
export type TestObjectMutators = (object:
|
|
27
|
+
export type TestObjectMutators = (object: Obj.Any, params: MutationsProviderProps) => Promise<void>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport * as Schema from 'effect/Schema';\n\nimport { type Space, createDocAccessor } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo/internal';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { type Live, isLiveObject, live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? Obj.make(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations;\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAExB,SAAqBC,yBAAyB;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AACnC,SAASC,WAAW;AACpB,SAASC,YAAYC,WAAWC,yBAAyB;AAEzD,SAASC,iBAAiB;AAC1B,SAAoBC,cAAcC,YAAY;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;;;;;;;;;;;;;;AAexB,IAAMC,sBAAN,MAAMA;EAQX,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKC,QAAQ;EACpC;EAEAZ,UAAUa,MAA8D;AACtE,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWd,kBAAkBc,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAuD;AAClF,SAAKH,SAASC,IAAAA,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAuB;AACtE,UAAMN,OAAOR,MAAMe,QAAQC,aAAaF,SAAUT,OAAOY,KAAK,KAAKV,QAAQ,CAAA;AAC3E,UAAMW,OAAO,MAAM,KAAKC,YAAYX,IAAAA,EAAM,KAAKY,SAAS;AACxD,QAAItB,aAAaoB,IAAAA,GAAO;AACtB,aAAOA;IACT;AAEA,UAAMR,SAAS,KAAKf,UAAUa,IAAAA;AAC9B,WAAOE,SAASjB,IAAI4B,KAAKX,QAAQQ,IAAAA,IAAQnB,KAAKmB,IAAAA;EAChD;;EAGA,MAAMI,cAAcC,KAAiC;AACnD,UAAMC,UAAuB,CAAA;AAC7B,eAAW,CAAChB,MAAMiB,KAAAA,KAAUxB,QAAQsB,GAAAA,GAAM;AAC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,MAAMM,OAAMY,SAASC,IAAG;IACxBlB,QAAQK,OAAMwB,QAAQC,aAAa1D,MAAAA;IACnCS,aAAawB,OAAMC,MAAME,UAAS;IAClCnB,SAASgB,OAAMY,SAASC,IAAG;IAC3BjB,UAAUI,OAAMwB,QAAQC,aAAazD,QAAAA;IACrC6B,QAAQG,OAAMS,SAASC,QAAO;EAChC;AACF;AAEA,IAAMkB,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOC,QAAQC,WAAAA;AACxC,UAAMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMX,SAASO,OAAOpD,SAASA,SAAS6C,UAAU;AAClDS,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe6B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe6B,sBAAsB6B,kBAAAA;",
|
|
6
|
-
"names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "Obj", "EchoSchema", "getSchema", "getTypeAnnotation", "invariant", "isLiveObject", "live", "faker", "entries", "range", "TestObjectGenerator", "schemas", "Object", "values", "_schemas", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "_generators", "_provider", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "_space", "db", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "_mutations", "mutateObjects", "objects", "schemaMap", "generators", "query", "nothing", "run", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/generator.ts":{"bytes":17256,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19489,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18943},"dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4823},"src/generator.ts":{"bytesInOutput":4471},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9901}}}
|