@dxos/echo-generator 0.6.4 → 0.6.5-staging.42fccfe
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 +93 -21
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +94 -21
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/data.d.ts.map +1 -1
- package/dist/types/src/generator.d.ts +13 -10
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +9 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -0
- package/dist/types/src/util.d.ts.map +1 -1
- package/package.json +20 -8
- package/src/data.ts +32 -3
- package/src/generator.test.ts +55 -1
- package/src/generator.ts +62 -27
- package/src/types.ts +12 -2
- package/src/util.ts +10 -0
|
@@ -8,20 +8,34 @@ import {
|
|
|
8
8
|
} from "@dxos/node-std/inject-globals";
|
|
9
9
|
|
|
10
10
|
// packages/core/echo/echo-generator/src/data.ts
|
|
11
|
-
import {
|
|
11
|
+
import { next as A } from "@dxos/automerge/automerge";
|
|
12
|
+
import { createDocAccessor } from "@dxos/client/echo";
|
|
13
|
+
import { create as create2, DynamicSchema as DynamicSchema2, EchoObject, EchoObjectAnnotationId, effectToJsonSchema, getEchoObjectAnnotation as getEchoObjectAnnotation2, ref, S, StoredSchema } from "@dxos/echo-schema";
|
|
12
14
|
import { faker as faker2 } from "@dxos/random";
|
|
13
15
|
|
|
14
16
|
// packages/core/echo/echo-generator/src/generator.ts
|
|
15
17
|
import { Filter } from "@dxos/client/echo";
|
|
18
|
+
import { DynamicSchema, getEchoObjectAnnotation, getSchema } from "@dxos/echo-schema";
|
|
16
19
|
import { create } from "@dxos/echo-schema";
|
|
20
|
+
import { invariant } from "@dxos/invariant";
|
|
17
21
|
import { faker } from "@dxos/random";
|
|
18
22
|
|
|
19
23
|
// packages/core/echo/echo-generator/src/util.ts
|
|
20
24
|
var range = (fn, length) => Array.from({
|
|
21
25
|
length
|
|
22
26
|
}).map((_, i) => fn(i)).filter(Boolean);
|
|
27
|
+
var randomText = (length) => {
|
|
28
|
+
let result = "";
|
|
29
|
+
const characters = "abcdefghijklmnopqrstuvwxyz";
|
|
30
|
+
const charactersLength = characters.length;
|
|
31
|
+
for (let index = 0; index < length; index++) {
|
|
32
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
23
36
|
|
|
24
37
|
// packages/core/echo/echo-generator/src/generator.ts
|
|
38
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
|
|
25
39
|
var TestObjectGenerator = class {
|
|
26
40
|
// prettier-ignore
|
|
27
41
|
constructor(_schemas, _generators, _provider) {
|
|
@@ -33,7 +47,7 @@ var TestObjectGenerator = class {
|
|
|
33
47
|
return Object.values(this._schemas);
|
|
34
48
|
}
|
|
35
49
|
getSchema(type) {
|
|
36
|
-
return this.schemas.find((schema) => schema.typename === type);
|
|
50
|
+
return this.schemas.find((schema) => getEchoObjectAnnotation(schema).typename === type);
|
|
37
51
|
}
|
|
38
52
|
setSchema(type, schema) {
|
|
39
53
|
this._schemas[type] = schema;
|
|
@@ -59,30 +73,23 @@ var TestObjectGenerator = class {
|
|
|
59
73
|
}
|
|
60
74
|
};
|
|
61
75
|
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
62
|
-
constructor(_space, schemaMap, generators) {
|
|
76
|
+
constructor(_space, schemaMap, generators, _mutations) {
|
|
63
77
|
super(schemaMap, generators, async (type) => {
|
|
64
78
|
const schema = this.getSchema(type);
|
|
65
79
|
return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];
|
|
66
80
|
});
|
|
67
81
|
this._space = _space;
|
|
82
|
+
this._mutations = _mutations;
|
|
68
83
|
Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
|
|
69
|
-
|
|
70
|
-
if (schema == null) {
|
|
71
|
-
schema = this._registerSchema(dynamicSchema);
|
|
72
|
-
}
|
|
84
|
+
const schema = this._maybeRegisterSchema(type, dynamicSchema);
|
|
73
85
|
this.setSchema(type, schema);
|
|
74
86
|
});
|
|
75
87
|
}
|
|
76
88
|
addSchemas() {
|
|
77
89
|
const result = [];
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
result.push(this._registerSchema(schema));
|
|
82
|
-
} else {
|
|
83
|
-
result.push(existing);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
90
|
+
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
91
|
+
result.push(this._maybeRegisterSchema(typename, schema));
|
|
92
|
+
}
|
|
86
93
|
return result;
|
|
87
94
|
}
|
|
88
95
|
async createObject({ types } = {}) {
|
|
@@ -90,9 +97,51 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
|
90
97
|
types
|
|
91
98
|
}));
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
_maybeRegisterSchema(typename, schema) {
|
|
101
|
+
if (schema instanceof DynamicSchema) {
|
|
102
|
+
const existingSchema = this._space.db.schema.getSchemaByTypename(typename);
|
|
103
|
+
if (existingSchema != null) {
|
|
104
|
+
return existingSchema;
|
|
105
|
+
}
|
|
106
|
+
this._space.db.add(schema.serializedSchema);
|
|
107
|
+
return this._space.db.schema.registerSchema(schema.serializedSchema);
|
|
108
|
+
} else {
|
|
109
|
+
const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
|
|
110
|
+
if (existingSchema != null) {
|
|
111
|
+
return existingSchema;
|
|
112
|
+
}
|
|
113
|
+
this._space.db.graph.schemaRegistry.addSchema([
|
|
114
|
+
schema
|
|
115
|
+
]);
|
|
116
|
+
return schema;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async mutateObject(object, params) {
|
|
120
|
+
invariant(this._mutations, "Mutations not defined.", {
|
|
121
|
+
F: __dxlog_file,
|
|
122
|
+
L: 128,
|
|
123
|
+
S: this,
|
|
124
|
+
A: [
|
|
125
|
+
"this._mutations",
|
|
126
|
+
"'Mutations not defined.'"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
const type = getEchoObjectAnnotation(getSchema(object)).typename;
|
|
130
|
+
invariant(type && this._mutations?.[type], "Invalid object type.", {
|
|
131
|
+
F: __dxlog_file,
|
|
132
|
+
L: 130,
|
|
133
|
+
S: this,
|
|
134
|
+
A: [
|
|
135
|
+
"type && this._mutations?.[type]",
|
|
136
|
+
"'Invalid object type.'"
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
await this._mutations[type](object, params);
|
|
140
|
+
}
|
|
141
|
+
async mutateObjects(objects, params) {
|
|
142
|
+
for (const object of objects) {
|
|
143
|
+
await this.mutateObject(object, params);
|
|
144
|
+
}
|
|
96
145
|
}
|
|
97
146
|
};
|
|
98
147
|
|
|
@@ -118,7 +167,7 @@ var TestSchemaType;
|
|
|
118
167
|
})(TestSchemaType || (TestSchemaType = {}));
|
|
119
168
|
var createDynamicSchema = (typename, fields) => {
|
|
120
169
|
const typeSchema = S.partial(S.Struct(fields)).pipe(EchoObject(typename, "1.0.0"));
|
|
121
|
-
const typeAnnotation =
|
|
170
|
+
const typeAnnotation = getEchoObjectAnnotation2(typeSchema);
|
|
122
171
|
const schemaToStore = create2(StoredSchema, {
|
|
123
172
|
typename,
|
|
124
173
|
version: "1.0.0",
|
|
@@ -131,7 +180,7 @@ var createDynamicSchema = (typename, fields) => {
|
|
|
131
180
|
}
|
|
132
181
|
});
|
|
133
182
|
schemaToStore.jsonSchema = effectToJsonSchema(updatedSchema);
|
|
134
|
-
return new
|
|
183
|
+
return new DynamicSchema2(schemaToStore);
|
|
135
184
|
};
|
|
136
185
|
var testSchemas = () => {
|
|
137
186
|
const document = createDynamicSchema("example.com/type/document", {
|
|
@@ -209,8 +258,30 @@ var testObjectGenerators = {
|
|
|
209
258
|
active: faker2.datatype.boolean()
|
|
210
259
|
})
|
|
211
260
|
};
|
|
261
|
+
var testObjectMutators = {
|
|
262
|
+
["example.com/type/document"]: async (object, params) => {
|
|
263
|
+
const accessor = createDocAccessor(object, [
|
|
264
|
+
"content"
|
|
265
|
+
]);
|
|
266
|
+
for (let i = 0; i < params.count; i++) {
|
|
267
|
+
const length = object.content?.content?.length ?? 0;
|
|
268
|
+
accessor.handle.change((doc) => {
|
|
269
|
+
A.splice(doc, accessor.path.slice(), 0, params.maxContentLength >= length ? 0 : params.mutationSize, randomText(params.mutationSize));
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
["example.com/type/organization"]: async () => {
|
|
274
|
+
throw new Error("Method not implemented.");
|
|
275
|
+
},
|
|
276
|
+
["example.com/type/contact"]: async () => {
|
|
277
|
+
throw new Error("Method not implemented.");
|
|
278
|
+
},
|
|
279
|
+
["example.com/type/project"]: async () => {
|
|
280
|
+
throw new Error("Method not implemented.");
|
|
281
|
+
}
|
|
282
|
+
};
|
|
212
283
|
var createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
|
|
213
|
-
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);
|
|
284
|
+
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);
|
|
214
285
|
var locations = [
|
|
215
286
|
{
|
|
216
287
|
lat: 139.74946157054467,
|
|
@@ -621,6 +692,7 @@ export {
|
|
|
621
692
|
TestSchemaType,
|
|
622
693
|
createSpaceObjectGenerator,
|
|
623
694
|
createTestObjectGenerator,
|
|
695
|
+
randomText,
|
|
624
696
|
range
|
|
625
697
|
};
|
|
626
698
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { type Space } from '@dxos/client/echo';\nimport {\n create,\n DynamicSchema,\n EchoObject,\n EchoObjectAnnotationId,\n effectToJsonSchema,\n getEchoObjectAnnotation,\n ref,\n S,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\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\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicSchema => {\n const typeSchema = S.partial(S.Struct(fields)).pipe(EchoObject(typename, '1.0.0'));\n const typeAnnotation = getEchoObjectAnnotation(typeSchema);\n const schemaToStore = create(StoredSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: {},\n });\n const updatedSchema = typeSchema.annotations({\n [EchoObjectAnnotationId]: { ...typeAnnotation, schemaId: schemaToStore.id },\n });\n schemaToStore.jsonSchema = effectToJsonSchema(updatedSchema);\n return new DynamicSchema(schemaToStore);\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.String.pipe(S.description('title of the document')),\n content: S.String,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.String.pipe(S.description('name of the company or organization')),\n website: S.String.pipe(S.description('public website URL')),\n description: S.String.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.String.pipe(S.description('name of the person')),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.String.pipe(S.description('name of the project')),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: ref(organization),\n });\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.helpers.arrayElement(locations) : undefined;\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.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\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 ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schema.getSchemaByTypename(type);\n if (schema == null) {\n schema = this._registerSchema(dynamicSchema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schema.getSchemaByTypename(schema.typename);\n if (existing == null) {\n result.push(this._registerSchema(schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _registerSchema(schema: DynamicSchema): DynamicSchema {\n this._space.db.add(schema.serializedSchema);\n return this._space.db.schema.registerSchema(schema.serializedSchema);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;
|
|
6
|
-
"names": ["create", "DynamicSchema", "EchoObject", "EchoObjectAnnotationId", "effectToJsonSchema", "getEchoObjectAnnotation", "ref", "S", "StoredSchema", "faker", "Filter", "create", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport {\n create,\n DynamicSchema,\n EchoObject,\n EchoObjectAnnotationId,\n effectToJsonSchema,\n getEchoObjectAnnotation,\n ref,\n S,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestMutationsMap, type TestGeneratorMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\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\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicSchema => {\n const typeSchema = S.partial(S.Struct(fields)).pipe(EchoObject(typename, '1.0.0'));\n const typeAnnotation = getEchoObjectAnnotation(typeSchema);\n const schemaToStore = create(StoredSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: {},\n });\n const updatedSchema = typeSchema.annotations({\n [EchoObjectAnnotationId]: { ...typeAnnotation, schemaId: schemaToStore.id },\n });\n schemaToStore.jsonSchema = effectToJsonSchema(updatedSchema);\n return new DynamicSchema(schemaToStore);\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.String.pipe(S.description('title of the document')),\n content: S.String,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.String.pipe(S.description('name of the company or organization')),\n website: S.String.pipe(S.description('public website URL')),\n description: S.String.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.String.pipe(S.description('name of the person')),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.String.pipe(S.description('name of the project')),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: ref(organization),\n });\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.helpers.arrayElement(locations) : undefined;\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.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\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\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport {\n type EchoReactiveObject,\n type ReactiveObject,\n DynamicSchema,\n getEchoObjectAnnotation,\n getSchema,\n type S,\n} from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport {\n type TestMutationsMap,\n type TestGeneratorMap,\n type TestObjectProvider,\n type TestSchemaMap,\n type MutationsProviderParams,\n} from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\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(): (DynamicSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getEchoObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\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 return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (DynamicSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as DynamicSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<EchoReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: DynamicSchema | S.Schema<any>): DynamicSchema | S.Schema<any> {\n if (schema instanceof DynamicSchema) {\n const existingSchema = this._space.db.schema.getSchemaByTypename(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.serializedSchema);\n return this._space.db.schema.registerSchema(schema.serializedSchema);\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: EchoReactiveObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getEchoObjectAnnotation(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: EchoReactiveObject<any>[], params: MutationsProviderParams) {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\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 return result;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAOA,SAASA,QAAQC,SAAS;AAC1B,SAASC,yBAAqC;AAC9C,SACEC,UAAAA,SACAC,iBAAAA,gBACAC,YACAC,wBACAC,oBACAC,2BAAAA,0BACAC,KACA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EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
|
|
6
|
+
"names": ["next", "A", "createDocAccessor", "create", "DynamicSchema", "EchoObject", "EchoObjectAnnotationId", "effectToJsonSchema", "getEchoObjectAnnotation", "ref", "S", "StoredSchema", "faker", "Filter", "DynamicSchema", "getEchoObjectAnnotation", "getSchema", "create", "invariant", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "randomText", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getEchoObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "_maybeRegisterSchema", "addSchemas", "result", "push", "add", "DynamicSchema", "existingSchema", "getSchemaByTypename", "serializedSchema", "registerSchema", "graph", "schemaRegistry", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "typename", "fields", "typeSchema", "S", "partial", "Struct", "pipe", "EchoObject", "typeAnnotation", "getEchoObjectAnnotation", "schemaToStore", "create", "StoredSchema", "version", "jsonSchema", "updatedSchema", "annotations", "EchoObjectAnnotationId", "schemaId", "id", "effectToJsonSchema", "DynamicSchema", "testSchemas", "document", "title", "String", "description", "content", "organization", "name", "website", "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", "helpers", "arrayElement", "locations", "person", "fullName", "length", "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
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":
|
|
1
|
+
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":2289,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16603,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":41064,"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1521,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":751,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29027},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","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-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":11548},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3830},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":390},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":16390}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -25,17 +25,32 @@ __export(node_exports, {
|
|
|
25
25
|
TestSchemaType: () => TestSchemaType,
|
|
26
26
|
createSpaceObjectGenerator: () => createSpaceObjectGenerator,
|
|
27
27
|
createTestObjectGenerator: () => createTestObjectGenerator,
|
|
28
|
+
randomText: () => randomText,
|
|
28
29
|
range: () => range
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(node_exports);
|
|
32
|
+
var import_automerge = require("@dxos/automerge/automerge");
|
|
33
|
+
var import_echo = require("@dxos/client/echo");
|
|
31
34
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
32
35
|
var import_random = require("@dxos/random");
|
|
33
|
-
var
|
|
36
|
+
var import_echo2 = require("@dxos/client/echo");
|
|
34
37
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
38
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
39
|
+
var import_invariant = require("@dxos/invariant");
|
|
35
40
|
var import_random2 = require("@dxos/random");
|
|
36
41
|
var range = (fn, length) => Array.from({
|
|
37
42
|
length
|
|
38
43
|
}).map((_, i) => fn(i)).filter(Boolean);
|
|
44
|
+
var randomText = (length) => {
|
|
45
|
+
let result = "";
|
|
46
|
+
const characters = "abcdefghijklmnopqrstuvwxyz";
|
|
47
|
+
const charactersLength = characters.length;
|
|
48
|
+
for (let index = 0; index < length; index++) {
|
|
49
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
|
|
39
54
|
var TestObjectGenerator = class {
|
|
40
55
|
// prettier-ignore
|
|
41
56
|
constructor(_schemas, _generators, _provider) {
|
|
@@ -47,7 +62,7 @@ var TestObjectGenerator = class {
|
|
|
47
62
|
return Object.values(this._schemas);
|
|
48
63
|
}
|
|
49
64
|
getSchema(type) {
|
|
50
|
-
return this.schemas.find((schema) => schema.typename === type);
|
|
65
|
+
return this.schemas.find((schema) => (0, import_echo_schema2.getEchoObjectAnnotation)(schema).typename === type);
|
|
51
66
|
}
|
|
52
67
|
setSchema(type, schema) {
|
|
53
68
|
this._schemas[type] = schema;
|
|
@@ -57,7 +72,7 @@ var TestObjectGenerator = class {
|
|
|
57
72
|
const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
|
|
58
73
|
const data = await this._generators[type](this._provider);
|
|
59
74
|
const schema = this.getSchema(type);
|
|
60
|
-
return schema ? (0,
|
|
75
|
+
return schema ? (0, import_echo_schema3.create)(schema, data) : (0, import_echo_schema3.create)(data);
|
|
61
76
|
}
|
|
62
77
|
// TODO(burdon): Create batch.
|
|
63
78
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
@@ -73,30 +88,23 @@ var TestObjectGenerator = class {
|
|
|
73
88
|
}
|
|
74
89
|
};
|
|
75
90
|
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
76
|
-
constructor(_space, schemaMap, generators) {
|
|
91
|
+
constructor(_space, schemaMap, generators, _mutations) {
|
|
77
92
|
super(schemaMap, generators, async (type) => {
|
|
78
93
|
const schema = this.getSchema(type);
|
|
79
|
-
return (schema && (await this._space.db.query(
|
|
94
|
+
return (schema && (await this._space.db.query(import_echo2.Filter.schema(schema)).run()).objects) ?? [];
|
|
80
95
|
});
|
|
81
96
|
this._space = _space;
|
|
97
|
+
this._mutations = _mutations;
|
|
82
98
|
Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
|
|
83
|
-
|
|
84
|
-
if (schema == null) {
|
|
85
|
-
schema = this._registerSchema(dynamicSchema);
|
|
86
|
-
}
|
|
99
|
+
const schema = this._maybeRegisterSchema(type, dynamicSchema);
|
|
87
100
|
this.setSchema(type, schema);
|
|
88
101
|
});
|
|
89
102
|
}
|
|
90
103
|
addSchemas() {
|
|
91
104
|
const result = [];
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
result.push(this._registerSchema(schema));
|
|
96
|
-
} else {
|
|
97
|
-
result.push(existing);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
105
|
+
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
106
|
+
result.push(this._maybeRegisterSchema(typename, schema));
|
|
107
|
+
}
|
|
100
108
|
return result;
|
|
101
109
|
}
|
|
102
110
|
async createObject({ types } = {}) {
|
|
@@ -104,9 +112,51 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
|
104
112
|
types
|
|
105
113
|
}));
|
|
106
114
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
_maybeRegisterSchema(typename, schema) {
|
|
116
|
+
if (schema instanceof import_echo_schema2.DynamicSchema) {
|
|
117
|
+
const existingSchema = this._space.db.schema.getSchemaByTypename(typename);
|
|
118
|
+
if (existingSchema != null) {
|
|
119
|
+
return existingSchema;
|
|
120
|
+
}
|
|
121
|
+
this._space.db.add(schema.serializedSchema);
|
|
122
|
+
return this._space.db.schema.registerSchema(schema.serializedSchema);
|
|
123
|
+
} else {
|
|
124
|
+
const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
|
|
125
|
+
if (existingSchema != null) {
|
|
126
|
+
return existingSchema;
|
|
127
|
+
}
|
|
128
|
+
this._space.db.graph.schemaRegistry.addSchema([
|
|
129
|
+
schema
|
|
130
|
+
]);
|
|
131
|
+
return schema;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async mutateObject(object, params) {
|
|
135
|
+
(0, import_invariant.invariant)(this._mutations, "Mutations not defined.", {
|
|
136
|
+
F: __dxlog_file,
|
|
137
|
+
L: 128,
|
|
138
|
+
S: this,
|
|
139
|
+
A: [
|
|
140
|
+
"this._mutations",
|
|
141
|
+
"'Mutations not defined.'"
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
const type = (0, import_echo_schema2.getEchoObjectAnnotation)((0, import_echo_schema2.getSchema)(object)).typename;
|
|
145
|
+
(0, import_invariant.invariant)(type && this._mutations?.[type], "Invalid object type.", {
|
|
146
|
+
F: __dxlog_file,
|
|
147
|
+
L: 130,
|
|
148
|
+
S: this,
|
|
149
|
+
A: [
|
|
150
|
+
"type && this._mutations?.[type]",
|
|
151
|
+
"'Invalid object type.'"
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
await this._mutations[type](object, params);
|
|
155
|
+
}
|
|
156
|
+
async mutateObjects(objects, params) {
|
|
157
|
+
for (const object of objects) {
|
|
158
|
+
await this.mutateObject(object, params);
|
|
159
|
+
}
|
|
110
160
|
}
|
|
111
161
|
};
|
|
112
162
|
var Status = [
|
|
@@ -221,8 +271,30 @@ var testObjectGenerators = {
|
|
|
221
271
|
active: import_random.faker.datatype.boolean()
|
|
222
272
|
})
|
|
223
273
|
};
|
|
274
|
+
var testObjectMutators = {
|
|
275
|
+
["example.com/type/document"]: async (object, params) => {
|
|
276
|
+
const accessor = (0, import_echo.createDocAccessor)(object, [
|
|
277
|
+
"content"
|
|
278
|
+
]);
|
|
279
|
+
for (let i = 0; i < params.count; i++) {
|
|
280
|
+
const length = object.content?.content?.length ?? 0;
|
|
281
|
+
accessor.handle.change((doc) => {
|
|
282
|
+
import_automerge.next.splice(doc, accessor.path.slice(), 0, params.maxContentLength >= length ? 0 : params.mutationSize, randomText(params.mutationSize));
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
["example.com/type/organization"]: async () => {
|
|
287
|
+
throw new Error("Method not implemented.");
|
|
288
|
+
},
|
|
289
|
+
["example.com/type/contact"]: async () => {
|
|
290
|
+
throw new Error("Method not implemented.");
|
|
291
|
+
},
|
|
292
|
+
["example.com/type/project"]: async () => {
|
|
293
|
+
throw new Error("Method not implemented.");
|
|
294
|
+
}
|
|
295
|
+
};
|
|
224
296
|
var createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
|
|
225
|
-
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);
|
|
297
|
+
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);
|
|
226
298
|
var locations = [
|
|
227
299
|
{
|
|
228
300
|
lat: 139.74946157054467,
|
|
@@ -634,6 +706,7 @@ var locations = [
|
|
|
634
706
|
TestSchemaType,
|
|
635
707
|
createSpaceObjectGenerator,
|
|
636
708
|
createTestObjectGenerator,
|
|
709
|
+
randomText,
|
|
637
710
|
range
|
|
638
711
|
});
|
|
639
712
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { type Space } from '@dxos/client/echo';\nimport {\n create,\n DynamicSchema,\n EchoObject,\n EchoObjectAnnotationId,\n effectToJsonSchema,\n getEchoObjectAnnotation,\n ref,\n S,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\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\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicSchema => {\n const typeSchema = S.partial(S.Struct(fields)).pipe(EchoObject(typename, '1.0.0'));\n const typeAnnotation = getEchoObjectAnnotation(typeSchema);\n const schemaToStore = create(StoredSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: {},\n });\n const updatedSchema = typeSchema.annotations({\n [EchoObjectAnnotationId]: { ...typeAnnotation, schemaId: schemaToStore.id },\n });\n schemaToStore.jsonSchema = effectToJsonSchema(updatedSchema);\n return new DynamicSchema(schemaToStore);\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.String.pipe(S.description('title of the document')),\n content: S.String,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.String.pipe(S.description('name of the company or organization')),\n website: S.String.pipe(S.description('public website URL')),\n description: S.String.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.String.pipe(S.description('name of the person')),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.String.pipe(S.description('name of the project')),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: ref(organization),\n });\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.helpers.arrayElement(locations) : undefined;\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.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\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 ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schema.getSchemaByTypename(type);\n if (schema == null) {\n schema = this._registerSchema(dynamicSchema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schema.getSchemaByTypename(schema.typename);\n if (existing == null) {\n result.push(this._registerSchema(schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _registerSchema(schema: DynamicSchema): DynamicSchema {\n this._space.db.add(schema.serializedSchema);\n return this._space.db.schema.registerSchema(schema.serializedSchema);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_echo_schema", "import_random", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport {\n create,\n DynamicSchema,\n EchoObject,\n EchoObjectAnnotationId,\n effectToJsonSchema,\n getEchoObjectAnnotation,\n ref,\n S,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestMutationsMap, type TestGeneratorMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\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\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicSchema => {\n const typeSchema = S.partial(S.Struct(fields)).pipe(EchoObject(typename, '1.0.0'));\n const typeAnnotation = getEchoObjectAnnotation(typeSchema);\n const schemaToStore = create(StoredSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: {},\n });\n const updatedSchema = typeSchema.annotations({\n [EchoObjectAnnotationId]: { ...typeAnnotation, schemaId: schemaToStore.id },\n });\n schemaToStore.jsonSchema = effectToJsonSchema(updatedSchema);\n return new DynamicSchema(schemaToStore);\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.String.pipe(S.description('title of the document')),\n content: S.String,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.String.pipe(S.description('name of the company or organization')),\n website: S.String.pipe(S.description('public website URL')),\n description: S.String.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.String.pipe(S.description('name of the person')),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.String.pipe(S.description('name of the project')),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: ref(organization),\n });\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.helpers.arrayElement(locations) : undefined;\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.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\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\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport {\n type EchoReactiveObject,\n type ReactiveObject,\n DynamicSchema,\n getEchoObjectAnnotation,\n getSchema,\n type S,\n} from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport {\n type TestMutationsMap,\n type TestGeneratorMap,\n type TestObjectProvider,\n type TestSchemaMap,\n type MutationsProviderParams,\n} from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\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(): (DynamicSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getEchoObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\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 return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (DynamicSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as DynamicSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<EchoReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: DynamicSchema | S.Schema<any>): DynamicSchema | S.Schema<any> {\n if (schema instanceof DynamicSchema) {\n const existingSchema = this._space.db.schema.getSchemaByTypename(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.serializedSchema);\n return this._space.db.schema.registerSchema(schema.serializedSchema);\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: EchoReactiveObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getEchoObjectAnnotation(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: EchoReactiveObject<any>[], params: MutationsProviderParams) {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\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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K;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAqBE,KAAK;EAAiB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAqBE,KAAK;EAAkB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
|
|
6
|
+
"names": ["import_echo", "import_echo_schema", "import_random", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "randomText", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getEchoObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "_maybeRegisterSchema", "addSchemas", "push", "add", "DynamicSchema", "existingSchema", "getSchemaByTypename", "serializedSchema", "registerSchema", "graph", "schemaRegistry", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "fields", "typeSchema", "S", "partial", "Struct", "pipe", "EchoObject", "typeAnnotation", "schemaToStore", "StoredSchema", "version", "jsonSchema", "updatedSchema", "annotations", "EchoObjectAnnotationId", "schemaId", "id", "effectToJsonSchema", "testSchemas", "document", "title", "String", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "locations", "person", "fullName", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":2289,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16603,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":41064,"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1521,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":751,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29018},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","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-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":11548},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3830},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":390},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":16242}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAQA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAclE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,6BAA6B;IACpC,OAAO,6BAA6B;CACrC;AAsHD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACmC,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { type Space } from '@dxos/client/echo';
|
|
2
|
-
import { type
|
|
2
|
+
import { type EchoReactiveObject, type ReactiveObject, DynamicSchema, type S } from '@dxos/echo-schema';
|
|
3
3
|
import { type TestSchemaType } from './data';
|
|
4
|
-
import { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';
|
|
4
|
+
import { type TestMutationsMap, type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap, type MutationsProviderParams } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Typed object generator.
|
|
7
7
|
*/
|
|
8
8
|
export declare class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
9
|
-
|
|
9
|
+
protected readonly _schemas: TestSchemaMap<T>;
|
|
10
10
|
private readonly _generators;
|
|
11
11
|
private readonly _provider?;
|
|
12
12
|
constructor(_schemas: TestSchemaMap<T>, _generators: TestGeneratorMap<T>, _provider?: TestObjectProvider<T> | undefined);
|
|
13
|
-
get schemas(): DynamicSchema[];
|
|
14
|
-
getSchema(type: T): DynamicSchema | undefined;
|
|
15
|
-
protected setSchema(type: T, schema: DynamicSchema): void;
|
|
13
|
+
get schemas(): (DynamicSchema | S.Schema<any>)[];
|
|
14
|
+
getSchema(type: T): DynamicSchema | S.Schema<any> | undefined;
|
|
15
|
+
protected setSchema(type: T, schema: DynamicSchema | S.Schema<any>): void;
|
|
16
16
|
createObject({ types }?: {
|
|
17
17
|
types?: T[];
|
|
18
18
|
}): Promise<ReactiveObject<any>>;
|
|
@@ -23,11 +23,14 @@ export declare class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
|
23
23
|
*/
|
|
24
24
|
export declare class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {
|
|
25
25
|
private readonly _space;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
private readonly _mutations?;
|
|
27
|
+
constructor(_space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>, _mutations?: TestMutationsMap<T> | undefined);
|
|
28
|
+
addSchemas(): (DynamicSchema | S.Schema<any, any, never>)[];
|
|
28
29
|
createObject({ types }?: {
|
|
29
30
|
types?: T[];
|
|
30
|
-
}): Promise<
|
|
31
|
-
private
|
|
31
|
+
}): Promise<EchoReactiveObject<any>>;
|
|
32
|
+
private _maybeRegisterSchema;
|
|
33
|
+
mutateObject(object: EchoReactiveObject<any>, params: MutationsProviderParams): Promise<void>;
|
|
34
|
+
mutateObjects(objects: EchoReactiveObject<any>[], params: MutationsProviderParams): Promise<void>;
|
|
32
35
|
}
|
|
33
36
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAU,MAAM,mBAAmB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAU,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,aAAa,EAGb,KAAK,CAAC,EACP,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,cA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AA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAI9F,OAAO,CAAC,oBAAoB;IAkBtB,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,uBAAuB;IAQ7E,aAAa,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB;CAKxF"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { type DynamicSchema, type ReactiveObject } from '@dxos/echo-schema';
|
|
1
|
+
import { type EchoReactiveObject, type DynamicSchema, type ReactiveObject, type S } from '@dxos/echo-schema';
|
|
2
2
|
export type TestObject = {
|
|
3
3
|
id: string;
|
|
4
4
|
} & Record<string, any>;
|
|
5
|
-
export type TestSchemaMap<T extends string> = Record<T, DynamicSchema
|
|
5
|
+
export type TestSchemaMap<T extends string> = Record<T, DynamicSchema | S.Schema<any>>;
|
|
6
6
|
export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
|
|
7
7
|
export type TestObjectProvider<T extends string> = (type: T) => Promise<ReactiveObject<any>[]>;
|
|
8
|
+
export type TestMutationsMap<T extends string> = Record<T, TestObjectMutators>;
|
|
9
|
+
export type MutationsProviderParams = {
|
|
10
|
+
count: number;
|
|
11
|
+
mutationSize: number;
|
|
12
|
+
maxContentLength: number;
|
|
13
|
+
};
|
|
14
|
+
export type TestObjectMutators = (object: EchoReactiveObject<any>, params: MutationsProviderParams) => Promise<void>;
|
|
8
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"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,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,UAAU,MAAM,KAAG,CAAC,EAGlD,CAAC"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,UAAW,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,UAAU,MAAM,KAAG,CAAC,EAGlD,CAAC;AAE5B,eAAO,MAAM,UAAU,WAAY,MAAM,WAQxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-generator",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5-staging.42fccfe",
|
|
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
|
"license": "MIT",
|
|
8
8
|
"author": "info@dxos.org",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
12
|
+
"node": {
|
|
13
|
+
"default": "./dist/lib/node/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/types/src/index.d.ts"
|
|
16
|
+
}
|
|
12
17
|
},
|
|
13
18
|
"types": "dist/types/src/index.d.ts",
|
|
19
|
+
"typesVersions": {
|
|
20
|
+
"*": {}
|
|
21
|
+
},
|
|
14
22
|
"files": [
|
|
15
23
|
"dist",
|
|
16
24
|
"src"
|
|
17
25
|
],
|
|
18
26
|
"dependencies": {
|
|
19
|
-
"@dxos/
|
|
20
|
-
"@dxos/
|
|
21
|
-
"@dxos/
|
|
22
|
-
"@dxos/echo-schema": "0.6.
|
|
27
|
+
"@dxos/echo-db": "0.6.5-staging.42fccfe",
|
|
28
|
+
"@dxos/automerge": "0.6.5-staging.42fccfe",
|
|
29
|
+
"@dxos/client": "0.6.5-staging.42fccfe",
|
|
30
|
+
"@dxos/echo-schema": "0.6.5-staging.42fccfe",
|
|
31
|
+
"@dxos/node-std": "0.6.5-staging.42fccfe",
|
|
32
|
+
"@dxos/invariant": "0.6.5-staging.42fccfe",
|
|
33
|
+
"@dxos/random": "0.6.5-staging.42fccfe",
|
|
34
|
+
"@dxos/util": "0.6.5-staging.42fccfe"
|
|
23
35
|
},
|
|
24
36
|
"devDependencies": {},
|
|
25
37
|
"publishConfig": {
|
package/src/data.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.
|
|
6
6
|
// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { next as A } from '@dxos/automerge/automerge';
|
|
9
|
+
import { createDocAccessor, type Space } from '@dxos/client/echo';
|
|
9
10
|
import {
|
|
10
11
|
create,
|
|
11
12
|
DynamicSchema,
|
|
@@ -20,7 +21,8 @@ import {
|
|
|
20
21
|
import { faker } from '@dxos/random';
|
|
21
22
|
|
|
22
23
|
import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
|
|
23
|
-
import { type TestGeneratorMap, type TestSchemaMap } from './types';
|
|
24
|
+
import { type TestMutationsMap, type TestGeneratorMap, type TestSchemaMap } from './types';
|
|
25
|
+
import { randomText } from './util';
|
|
24
26
|
|
|
25
27
|
// TODO(burdon): Handle restricted values.
|
|
26
28
|
export const Status = ['pending', 'active', 'done'];
|
|
@@ -122,10 +124,37 @@ const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
|
|
|
122
124
|
}),
|
|
123
125
|
};
|
|
124
126
|
|
|
127
|
+
const testObjectMutators: TestMutationsMap<TestSchemaType> = {
|
|
128
|
+
[TestSchemaType.document]: async (object, params) => {
|
|
129
|
+
const accessor = createDocAccessor(object, ['content']);
|
|
130
|
+
for (let i = 0; i < params.count; i++) {
|
|
131
|
+
const length = object.content?.content?.length ?? 0;
|
|
132
|
+
accessor.handle.change((doc) => {
|
|
133
|
+
A.splice(
|
|
134
|
+
doc,
|
|
135
|
+
accessor.path.slice(),
|
|
136
|
+
0,
|
|
137
|
+
params.maxContentLength >= length ? 0 : params.mutationSize,
|
|
138
|
+
randomText(params.mutationSize),
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[TestSchemaType.organization]: async () => {
|
|
144
|
+
throw new Error('Method not implemented.');
|
|
145
|
+
},
|
|
146
|
+
[TestSchemaType.contact]: async () => {
|
|
147
|
+
throw new Error('Method not implemented.');
|
|
148
|
+
},
|
|
149
|
+
[TestSchemaType.project]: async () => {
|
|
150
|
+
throw new Error('Method not implemented.');
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
125
154
|
export const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
|
|
126
155
|
|
|
127
156
|
export const createSpaceObjectGenerator = (space: Space) =>
|
|
128
|
-
new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);
|
|
157
|
+
new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);
|
|
129
158
|
|
|
130
159
|
// TODO(burdon): Move to @dxos/random.
|
|
131
160
|
const locations = [
|
package/src/generator.test.ts
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
6
|
|
|
7
|
+
import { next as A } from '@dxos/automerge/automerge';
|
|
7
8
|
import { Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
9
|
+
import { getObjectCore } from '@dxos/echo-db';
|
|
10
|
+
import { getType, S, TypedObject } from '@dxos/echo-schema';
|
|
9
11
|
import { faker } from '@dxos/random';
|
|
10
12
|
import { afterTest, describe, test } from '@dxos/test';
|
|
11
13
|
|
|
12
14
|
import { createSpaceObjectGenerator, createTestObjectGenerator, TestSchemaType } from './data';
|
|
15
|
+
import { SpaceObjectGenerator } from './generator';
|
|
13
16
|
|
|
14
17
|
faker.seed(3);
|
|
15
18
|
|
|
@@ -60,6 +63,57 @@ describe('TestObjectGenerator', () => {
|
|
|
60
63
|
expect(schemaId[0]).to.eq(schemaId[1]);
|
|
61
64
|
});
|
|
62
65
|
|
|
66
|
+
test('mutations', async () => {
|
|
67
|
+
const { space } = await setupTest();
|
|
68
|
+
const generator = createSpaceObjectGenerator(space);
|
|
69
|
+
generator.addSchemas();
|
|
70
|
+
const document = await generator.createObject({ types: [TestSchemaType.document] });
|
|
71
|
+
expect(getType(document)).to.exist;
|
|
72
|
+
|
|
73
|
+
const beforeChangesCount = A.getAllChanges(getObjectCore(document).docHandle!.docSync()).length;
|
|
74
|
+
|
|
75
|
+
// Mutate the document.
|
|
76
|
+
const mutationsCount = 10;
|
|
77
|
+
await generator.mutateObject(document, { count: mutationsCount, maxContentLength: 1000, mutationSize: 10 });
|
|
78
|
+
await space.db.flush();
|
|
79
|
+
|
|
80
|
+
const changesCount = A.getAllChanges(getObjectCore(document).docHandle!.docSync()).length;
|
|
81
|
+
expect(changesCount - beforeChangesCount).to.be.eq(mutationsCount);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('create object with in memory schema', async () => {
|
|
85
|
+
class Todo extends TypedObject({
|
|
86
|
+
typename: 'example.org/type/Todo',
|
|
87
|
+
version: '0.1.0',
|
|
88
|
+
})({
|
|
89
|
+
name: S.optional(S.String),
|
|
90
|
+
}) {}
|
|
91
|
+
|
|
92
|
+
enum Types {
|
|
93
|
+
todo = 'example.org/type/Todo',
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const { space } = await setupTest();
|
|
97
|
+
const generator = new SpaceObjectGenerator<Types>(
|
|
98
|
+
space,
|
|
99
|
+
{ [Types.todo]: Todo },
|
|
100
|
+
{
|
|
101
|
+
[Types.todo]: () => ({ name: 'Default' }),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
[Types.todo]: async (todo, params) => {
|
|
105
|
+
for (const _ in Array.from({ length: params.count })) {
|
|
106
|
+
todo.name = faker.lorem.sentence();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const todo = await generator.createObject({ types: [Types.todo] });
|
|
113
|
+
|
|
114
|
+
expect(getType(todo)).to.exist;
|
|
115
|
+
});
|
|
116
|
+
|
|
63
117
|
const setupTest = async () => {
|
|
64
118
|
const client = new Client();
|
|
65
119
|
await client.initialize();
|
package/src/generator.ts
CHANGED
|
@@ -3,12 +3,26 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Space, Filter } from '@dxos/client/echo';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type EchoReactiveObject,
|
|
8
|
+
type ReactiveObject,
|
|
9
|
+
DynamicSchema,
|
|
10
|
+
getEchoObjectAnnotation,
|
|
11
|
+
getSchema,
|
|
12
|
+
type S,
|
|
13
|
+
} from '@dxos/echo-schema';
|
|
7
14
|
import { create } from '@dxos/echo-schema';
|
|
15
|
+
import { invariant } from '@dxos/invariant';
|
|
8
16
|
import { faker } from '@dxos/random';
|
|
9
17
|
|
|
10
18
|
import { type TestSchemaType } from './data';
|
|
11
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
type TestMutationsMap,
|
|
21
|
+
type TestGeneratorMap,
|
|
22
|
+
type TestObjectProvider,
|
|
23
|
+
type TestSchemaMap,
|
|
24
|
+
type MutationsProviderParams,
|
|
25
|
+
} from './types';
|
|
12
26
|
import { range } from './util';
|
|
13
27
|
|
|
14
28
|
/**
|
|
@@ -17,20 +31,20 @@ import { range } from './util';
|
|
|
17
31
|
export class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
18
32
|
// prettier-ignore
|
|
19
33
|
constructor(
|
|
20
|
-
|
|
34
|
+
protected readonly _schemas: TestSchemaMap<T>,
|
|
21
35
|
private readonly _generators: TestGeneratorMap<T>,
|
|
22
|
-
private readonly _provider?: TestObjectProvider<T
|
|
36
|
+
private readonly _provider?: TestObjectProvider<T>,
|
|
23
37
|
) {}
|
|
24
38
|
|
|
25
|
-
get schemas(): DynamicSchema[] {
|
|
39
|
+
get schemas(): (DynamicSchema | S.Schema<any>)[] {
|
|
26
40
|
return Object.values(this._schemas);
|
|
27
41
|
}
|
|
28
42
|
|
|
29
|
-
getSchema(type: T): DynamicSchema | undefined {
|
|
30
|
-
return this.schemas.find((schema) => schema
|
|
43
|
+
getSchema(type: T): DynamicSchema | S.Schema<any> | undefined {
|
|
44
|
+
return this.schemas.find((schema) => getEchoObjectAnnotation(schema)!.typename === type);
|
|
31
45
|
}
|
|
32
46
|
|
|
33
|
-
protected setSchema(type: T, schema: DynamicSchema) {
|
|
47
|
+
protected setSchema(type: T, schema: DynamicSchema | S.Schema<any>) {
|
|
34
48
|
this._schemas[type] = schema;
|
|
35
49
|
}
|
|
36
50
|
|
|
@@ -44,7 +58,7 @@ export class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
|
44
58
|
|
|
45
59
|
// TODO(burdon): Create batch.
|
|
46
60
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
47
|
-
async createObjects(map: Partial<Record<T, number>>)
|
|
61
|
+
async createObjects(map: Partial<Record<T, number>>) {
|
|
48
62
|
const tasks = Object.entries<number>(map as any)
|
|
49
63
|
.map(([type, count]) => {
|
|
50
64
|
return range(() => this.createObject({ types: [type as T] }), count);
|
|
@@ -63,6 +77,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
63
77
|
private readonly _space: Space,
|
|
64
78
|
schemaMap: TestSchemaMap<T>,
|
|
65
79
|
generators: TestGeneratorMap<T>,
|
|
80
|
+
private readonly _mutations?: TestMutationsMap<T>,
|
|
66
81
|
) {
|
|
67
82
|
super(schemaMap, generators, async (type: T) => {
|
|
68
83
|
const schema = this.getSchema(type);
|
|
@@ -71,35 +86,55 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
71
86
|
|
|
72
87
|
// TODO(burdon): Map initially are objects that have not been added to the space.
|
|
73
88
|
// Merge existing schema in space with defaults.
|
|
74
|
-
Object.entries<DynamicSchema
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
schema = this._registerSchema(dynamicSchema);
|
|
78
|
-
}
|
|
89
|
+
Object.entries<DynamicSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {
|
|
90
|
+
const schema = this._maybeRegisterSchema(type, dynamicSchema);
|
|
91
|
+
|
|
79
92
|
this.setSchema(type as T, schema);
|
|
80
93
|
});
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
addSchemas() {
|
|
84
|
-
const result: DynamicSchema[] = [];
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
result.push(this._registerSchema(schema));
|
|
89
|
-
} else {
|
|
90
|
-
result.push(existing);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
97
|
+
const result: (DynamicSchema | S.Schema<any>)[] = [];
|
|
98
|
+
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
99
|
+
result.push(this._maybeRegisterSchema(typename, schema as DynamicSchema | S.Schema<any>));
|
|
100
|
+
}
|
|
93
101
|
|
|
94
102
|
return result;
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
override async createObject({ types }: { types?: T[] } = {}): Promise<
|
|
105
|
+
override async createObject({ types }: { types?: T[] } = {}): Promise<EchoReactiveObject<any>> {
|
|
98
106
|
return this._space.db.add(await super.createObject({ types }));
|
|
99
107
|
}
|
|
100
108
|
|
|
101
|
-
private
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
private _maybeRegisterSchema(typename: string, schema: DynamicSchema | S.Schema<any>): DynamicSchema | S.Schema<any> {
|
|
110
|
+
if (schema instanceof DynamicSchema) {
|
|
111
|
+
const existingSchema = this._space.db.schema.getSchemaByTypename(typename);
|
|
112
|
+
if (existingSchema != null) {
|
|
113
|
+
return existingSchema;
|
|
114
|
+
}
|
|
115
|
+
this._space.db.add(schema.serializedSchema);
|
|
116
|
+
return this._space.db.schema.registerSchema(schema.serializedSchema);
|
|
117
|
+
} else {
|
|
118
|
+
const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
|
|
119
|
+
if (existingSchema != null) {
|
|
120
|
+
return existingSchema;
|
|
121
|
+
}
|
|
122
|
+
this._space.db.graph.schemaRegistry.addSchema([schema]);
|
|
123
|
+
return schema;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async mutateObject(object: EchoReactiveObject<any>, params: MutationsProviderParams) {
|
|
128
|
+
invariant(this._mutations, 'Mutations not defined.');
|
|
129
|
+
const type = getEchoObjectAnnotation(getSchema(object)!)!.typename as T;
|
|
130
|
+
invariant(type && this._mutations?.[type], 'Invalid object type.');
|
|
131
|
+
|
|
132
|
+
await this._mutations;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async mutateObjects(objects: EchoReactiveObject<any>[], params: MutationsProviderParams) {
|
|
136
|
+
for (const object of objects) {
|
|
137
|
+
await this.mutateObject(object, params);
|
|
138
|
+
}
|
|
104
139
|
}
|
|
105
140
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,12 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type DynamicSchema, type ReactiveObject } from '@dxos/echo-schema';
|
|
5
|
+
import { type EchoReactiveObject, type DynamicSchema, type ReactiveObject, type S } from '@dxos/echo-schema';
|
|
6
6
|
|
|
7
7
|
export type TestObject = { id: string } & Record<string, any>;
|
|
8
8
|
|
|
9
|
-
export type TestSchemaMap<T extends string> = Record<T, DynamicSchema
|
|
9
|
+
export type TestSchemaMap<T extends string> = Record<T, DynamicSchema | S.Schema<any>>;
|
|
10
10
|
|
|
11
11
|
export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
|
|
12
12
|
|
|
13
13
|
export type TestObjectProvider<T extends string> = (type: T) => Promise<ReactiveObject<any>[]>;
|
|
14
|
+
|
|
15
|
+
export type TestMutationsMap<T extends string> = Record<T, TestObjectMutators>;
|
|
16
|
+
|
|
17
|
+
export type MutationsProviderParams = {
|
|
18
|
+
count: number;
|
|
19
|
+
mutationSize: number;
|
|
20
|
+
maxContentLength: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type TestObjectMutators = (object: EchoReactiveObject<any>, params: MutationsProviderParams) => Promise<void>;
|
package/src/util.ts
CHANGED
|
@@ -7,3 +7,13 @@ export const range = <T>(fn: (i: number) => T | undefined, length: number): T[]
|
|
|
7
7
|
Array.from({ length })
|
|
8
8
|
.map((_, i) => fn(i))
|
|
9
9
|
.filter(Boolean) as T[];
|
|
10
|
+
|
|
11
|
+
export const randomText = (length: number) => {
|
|
12
|
+
let result = '';
|
|
13
|
+
const characters = 'abcdefghijklmnopqrstuvwxyz';
|
|
14
|
+
const charactersLength = characters.length;
|
|
15
|
+
for (let index = 0; index < length; index++) {
|
|
16
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
};
|