@dxos/echo-generator 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 → neutral}/index.mjs +23 -23
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/meta.json +1 -1
- package/dist/types/src/data.d.ts +4 -4
- package/dist/types/src/generator.d.ts +3 -3
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/data.ts +6 -6
- package/src/generator.test.ts +4 -3
- package/src/generator.ts +6 -6
- package/src/types.ts +1 -1
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -315
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-generator",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bcb3aa67d6",
|
|
4
4
|
"description": "ECHO data generator for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"source": "./src/index.ts",
|
|
18
18
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -30,21 +29,22 @@
|
|
|
30
29
|
],
|
|
31
30
|
"dependencies": {
|
|
32
31
|
"@automerge/automerge": "3.2.3",
|
|
33
|
-
"effect": "3.
|
|
34
|
-
"@dxos/client": "0.8.4-main.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/echo-db": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
32
|
+
"effect": "3.20.0",
|
|
33
|
+
"@dxos/client": "0.8.4-main.bcb3aa67d6",
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.bcb3aa67d6",
|
|
35
|
+
"@dxos/echo-db": "0.8.4-main.bcb3aa67d6",
|
|
36
|
+
"@dxos/context": "0.8.4-main.bcb3aa67d6",
|
|
37
|
+
"@dxos/node-std": "0.8.4-main.bcb3aa67d6",
|
|
38
|
+
"@dxos/util": "0.8.4-main.bcb3aa67d6",
|
|
39
|
+
"@dxos/log": "0.8.4-main.bcb3aa67d6",
|
|
40
|
+
"@dxos/echo": "0.8.4-main.bcb3aa67d6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@dxos/random": "0.8.4-main.
|
|
43
|
+
"@dxos/random": "0.8.4-main.bcb3aa67d6"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"effect": "3.
|
|
47
|
-
"@dxos/random": "0.8.4-main.
|
|
46
|
+
"effect": "3.20.0",
|
|
47
|
+
"@dxos/random": "0.8.4-main.bcb3aa67d6"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
package/src/data.ts
CHANGED
|
@@ -25,10 +25,10 @@ export const Priority = [1, 2, 3, 4, 5];
|
|
|
25
25
|
* @deprecated
|
|
26
26
|
*/
|
|
27
27
|
export enum TestSchemaType {
|
|
28
|
-
document = 'example.
|
|
29
|
-
organization = 'example.
|
|
30
|
-
contact = 'example.
|
|
31
|
-
project = 'example.
|
|
28
|
+
document = 'com.example.type.document',
|
|
29
|
+
organization = 'com.example.type.organization',
|
|
30
|
+
contact = 'com.example.type.person',
|
|
31
|
+
project = 'com.example.type.project',
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -49,7 +49,7 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
|
|
|
49
49
|
const contact = Schema.Struct({
|
|
50
50
|
name: Schema.String.annotations({ description: 'name of the person' }),
|
|
51
51
|
email: Schema.optional(Schema.String),
|
|
52
|
-
org: Schema.optional(
|
|
52
|
+
org: Schema.optional(Ref.Ref(organization)),
|
|
53
53
|
lat: Schema.optional(Schema.Number),
|
|
54
54
|
lng: Schema.optional(Schema.Number),
|
|
55
55
|
}).pipe(Type.object({ typename: TestSchemaType.contact, version: '0.1.0' }));
|
|
@@ -62,7 +62,7 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
|
|
|
62
62
|
status: Schema.String,
|
|
63
63
|
priority: Schema.Number,
|
|
64
64
|
active: Schema.Boolean,
|
|
65
|
-
org: Schema.optional(
|
|
65
|
+
org: Schema.optional(Ref.Ref(organization)),
|
|
66
66
|
}).pipe(Type.object({ typename: TestSchemaType.project, version: '0.1.0' }));
|
|
67
67
|
|
|
68
68
|
return {
|
package/src/generator.test.ts
CHANGED
|
@@ -73,7 +73,8 @@ describe('TestObjectGenerator', () => {
|
|
|
73
73
|
expect(schemaId[0]).to.eq(schemaId[1]);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
// flaky
|
|
77
|
+
test.skip('mutations', async () => {
|
|
77
78
|
const { space } = await setupTest();
|
|
78
79
|
const generator = createSpaceObjectGenerator(space);
|
|
79
80
|
await generator.addSchemas();
|
|
@@ -96,13 +97,13 @@ describe('TestObjectGenerator', () => {
|
|
|
96
97
|
name: Schema.optional(Schema.String),
|
|
97
98
|
}).pipe(
|
|
98
99
|
Type.object({
|
|
99
|
-
typename: 'example.
|
|
100
|
+
typename: 'com.example.type.task',
|
|
100
101
|
version: '0.1.0',
|
|
101
102
|
}),
|
|
102
103
|
);
|
|
103
104
|
|
|
104
105
|
enum Types {
|
|
105
|
-
task = 'example.
|
|
106
|
+
task = 'com.example.type.task',
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
const { space } = await setupTest();
|
package/src/generator.ts
CHANGED
|
@@ -31,15 +31,15 @@ export class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
|
31
31
|
private readonly _provider?: TestObjectProvider<T>,
|
|
32
32
|
) {}
|
|
33
33
|
|
|
34
|
-
get schemas(): Type.
|
|
34
|
+
get schemas(): Type.AnyObj[] {
|
|
35
35
|
return Object.values(this._schemas);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
getSchema(type: T): Type.
|
|
38
|
+
getSchema(type: T): Type.AnyObj | undefined {
|
|
39
39
|
return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
protected setSchema(type: T, schema: Type.
|
|
42
|
+
protected setSchema(type: T, schema: Type.AnyObj): void {
|
|
43
43
|
this._schemas[type] = schema;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -90,9 +90,9 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
async addSchemas() {
|
|
93
|
-
const result: Type.
|
|
93
|
+
const result: Type.AnyObj[] = [];
|
|
94
94
|
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
95
|
-
const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.
|
|
95
|
+
const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.AnyObj);
|
|
96
96
|
this.setSchema(typename as T, echoSchema);
|
|
97
97
|
result.push(echoSchema);
|
|
98
98
|
}
|
|
@@ -108,7 +108,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
|
|
|
108
108
|
return this._space.db.add(await super.createObject({ types }));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
private async _maybeRegisterSchema(typename: string, schema: Type.
|
|
111
|
+
private async _maybeRegisterSchema(typename: string, schema: Type.AnyObj): Promise<Type.AnyObj> {
|
|
112
112
|
if (schema instanceof EchoSchema) {
|
|
113
113
|
const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
|
|
114
114
|
if (existingSchema != null) {
|
package/src/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type Obj, type Type } from '@dxos/echo';
|
|
|
7
7
|
// TODO(burdon): Use echo-schema types.
|
|
8
8
|
export type TestObject = { id: string } & Record<string, any>;
|
|
9
9
|
|
|
10
|
-
export type TestSchemaMap<T extends string = string> = Record<T, Type.
|
|
10
|
+
export type TestSchemaMap<T extends string = string> = Record<T, Type.AnyObj>;
|
|
11
11
|
|
|
12
12
|
export type TestObjectProvider<T extends string = string> = (type: T) => Promise<any[]>;
|
|
13
13
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { Ref, Type } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Person',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(Type.object({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(Type.object({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Type.Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(Type.object({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Type.Ref(organization)),\n }).pipe(Type.object({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj, type Type } from '@dxos/echo';\nimport { EchoSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { isProxy } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderProps,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n\t\tprotected readonly _schemas: TestSchemaMap<T>,\n\t\tprivate readonly _generators: TestGeneratorMap<T>,\n\t\tprivate readonly _provider?: TestObjectProvider<T>,\n\t) {}\n\n get schemas(): Type.Obj.Any[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): Type.Obj.Any | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: Type.Obj.Any): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isProxy(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);\n return Obj.make(schema, data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: any[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: Type.Obj.Any[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.Obj.Any);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({\n types,\n }: {\n types?: T[];\n } = {}): Promise<Obj.Any> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(typename: string, schema: Type.Obj.Any): Promise<Type.Obj.Any> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n await this._space.internal.db.graph.schemaRegistry.register([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(Obj.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: Obj.Any[], params: MutationsProviderProps): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAGxB,SAASC,KAAKC,YAAY;AAC1B,SAASC,yBAAyB;AAClC,SAASC,SAAAA,cAAa;;;ACNtB,SAASC,cAA0B;AACnC,SAASC,WAAsB;AAC/B,SAASC,YAAYC,yBAAyB;AAC9C,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,aAAa;AACtB,S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IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMV,SAAS3C,OAAOH,SAASA,SAAS8C,UAAU;AAClDQ,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBnB,SAAS,IAAIO,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,yBAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
|
|
6
|
-
"names": ["next", "A", "Schema", "Ref", "Type", "createDocAccessor", "faker", "Filter", "Obj", "EchoSchema", "getTypeAnnotation", "isProxy", "invariant", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "internal", "schemaRegistry", "registeredSchema", "register", "graph", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "Type", "object", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
|
-
}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/data.ts
|
|
4
|
-
import { next as A } from "@automerge/automerge";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
|
-
import { Ref, Type } from "@dxos/echo";
|
|
7
|
-
import { createDocAccessor } from "@dxos/echo-db";
|
|
8
|
-
import { faker as faker2 } from "@dxos/random";
|
|
9
|
-
|
|
10
|
-
// src/generator.ts
|
|
11
|
-
import { Filter } from "@dxos/client/echo";
|
|
12
|
-
import { Obj } from "@dxos/echo";
|
|
13
|
-
import { EchoSchema, getTypeAnnotation } from "@dxos/echo/internal";
|
|
14
|
-
import { isProxy } from "@dxos/echo/internal";
|
|
15
|
-
import { invariant } from "@dxos/invariant";
|
|
16
|
-
import { faker } from "@dxos/random";
|
|
17
|
-
import { entries, range } from "@dxos/util";
|
|
18
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
|
|
19
|
-
var TestObjectGenerator = class {
|
|
20
|
-
_schemas;
|
|
21
|
-
_generators;
|
|
22
|
-
_provider;
|
|
23
|
-
// prettier-ignore
|
|
24
|
-
constructor(_schemas, _generators, _provider) {
|
|
25
|
-
this._schemas = _schemas;
|
|
26
|
-
this._generators = _generators;
|
|
27
|
-
this._provider = _provider;
|
|
28
|
-
}
|
|
29
|
-
get schemas() {
|
|
30
|
-
return Object.values(this._schemas);
|
|
31
|
-
}
|
|
32
|
-
getSchema(type) {
|
|
33
|
-
return this.schemas.find((schema) => getTypeAnnotation(schema).typename === type);
|
|
34
|
-
}
|
|
35
|
-
setSchema(type, schema) {
|
|
36
|
-
this._schemas[type] = schema;
|
|
37
|
-
}
|
|
38
|
-
async createObject({ types } = {}) {
|
|
39
|
-
const type = faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
|
|
40
|
-
const data = await this._generators[type](this._provider);
|
|
41
|
-
if (isProxy(data)) {
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
const schema = this.getSchema(type);
|
|
45
|
-
invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`, {
|
|
46
|
-
F: __dxlog_file,
|
|
47
|
-
L: 54,
|
|
48
|
-
S: this,
|
|
49
|
-
A: [
|
|
50
|
-
"schema",
|
|
51
|
-
"`Schema is required for type: ${type}. Register a schema for this type.`"
|
|
52
|
-
]
|
|
53
|
-
});
|
|
54
|
-
return Obj.make(schema, data);
|
|
55
|
-
}
|
|
56
|
-
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
57
|
-
async createObjects(map) {
|
|
58
|
-
const results = [];
|
|
59
|
-
for (const [type, count] of entries(map)) {
|
|
60
|
-
results.push(...await Promise.all(range(count ?? 0, () => this.createObject({
|
|
61
|
-
types: [
|
|
62
|
-
type
|
|
63
|
-
]
|
|
64
|
-
}))));
|
|
65
|
-
}
|
|
66
|
-
const tasks = Object.entries(map).map(([type, count]) => {
|
|
67
|
-
return range(count, () => this.createObject({
|
|
68
|
-
types: [
|
|
69
|
-
type
|
|
70
|
-
]
|
|
71
|
-
}));
|
|
72
|
-
}).flatMap((t) => t);
|
|
73
|
-
return Promise.all(tasks);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
77
|
-
_space;
|
|
78
|
-
_mutations;
|
|
79
|
-
constructor(_space, schemaMap, generators, _mutations) {
|
|
80
|
-
super(schemaMap, generators, async (type) => {
|
|
81
|
-
const schema = this.getSchema(type);
|
|
82
|
-
const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
|
|
83
|
-
return objects;
|
|
84
|
-
}), this._space = _space, this._mutations = _mutations;
|
|
85
|
-
}
|
|
86
|
-
async addSchemas() {
|
|
87
|
-
const result = [];
|
|
88
|
-
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
89
|
-
const echoSchema = await this._maybeRegisterSchema(typename, schema);
|
|
90
|
-
this.setSchema(typename, echoSchema);
|
|
91
|
-
result.push(echoSchema);
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
async createObject({ types } = {}) {
|
|
96
|
-
return this._space.db.add(await super.createObject({
|
|
97
|
-
types
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
async _maybeRegisterSchema(typename, schema) {
|
|
101
|
-
if (schema instanceof EchoSchema) {
|
|
102
|
-
const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
|
|
103
|
-
if (existingSchema != null) {
|
|
104
|
-
return existingSchema;
|
|
105
|
-
}
|
|
106
|
-
const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([
|
|
107
|
-
schema
|
|
108
|
-
]);
|
|
109
|
-
return registeredSchema;
|
|
110
|
-
} else {
|
|
111
|
-
const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);
|
|
112
|
-
if (existingSchema != null) {
|
|
113
|
-
return existingSchema;
|
|
114
|
-
}
|
|
115
|
-
await this._space.internal.db.graph.schemaRegistry.register([
|
|
116
|
-
schema
|
|
117
|
-
]);
|
|
118
|
-
return schema;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async mutateObject(object, params) {
|
|
122
|
-
invariant(this._mutations, "Mutations not defined.", {
|
|
123
|
-
F: __dxlog_file,
|
|
124
|
-
L: 130,
|
|
125
|
-
S: this,
|
|
126
|
-
A: [
|
|
127
|
-
"this._mutations",
|
|
128
|
-
"'Mutations not defined.'"
|
|
129
|
-
]
|
|
130
|
-
});
|
|
131
|
-
const type = getTypeAnnotation(Obj.getSchema(object)).typename;
|
|
132
|
-
invariant(type && this._mutations?.[type], "Invalid object type.", {
|
|
133
|
-
F: __dxlog_file,
|
|
134
|
-
L: 132,
|
|
135
|
-
S: this,
|
|
136
|
-
A: [
|
|
137
|
-
"type && this._mutations?.[type]",
|
|
138
|
-
"'Invalid object type.'"
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
await this._mutations[type](object, params);
|
|
142
|
-
}
|
|
143
|
-
async mutateObjects(objects, params) {
|
|
144
|
-
for (const object of objects) {
|
|
145
|
-
await this.mutateObject(object, params);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// src/util.ts
|
|
151
|
-
var randomText = (length) => {
|
|
152
|
-
let result = "";
|
|
153
|
-
const characters = "abcdefghijklmnopqrstuvwxyz";
|
|
154
|
-
const charactersLength = characters.length;
|
|
155
|
-
for (let index = 0; index < length; index++) {
|
|
156
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
157
|
-
}
|
|
158
|
-
return result;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// src/data.ts
|
|
162
|
-
var Status = [
|
|
163
|
-
"pending",
|
|
164
|
-
"active",
|
|
165
|
-
"done"
|
|
166
|
-
];
|
|
167
|
-
var Priority = [
|
|
168
|
-
1,
|
|
169
|
-
2,
|
|
170
|
-
3,
|
|
171
|
-
4,
|
|
172
|
-
5
|
|
173
|
-
];
|
|
174
|
-
var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
|
|
175
|
-
TestSchemaType2["document"] = "example.com/type/Document";
|
|
176
|
-
TestSchemaType2["organization"] = "example.com/type/Organization";
|
|
177
|
-
TestSchemaType2["contact"] = "example.com/type/Person";
|
|
178
|
-
TestSchemaType2["project"] = "example.com/type/Project";
|
|
179
|
-
return TestSchemaType2;
|
|
180
|
-
})({});
|
|
181
|
-
var testSchemas = () => {
|
|
182
|
-
const document = Schema.Struct({
|
|
183
|
-
title: Schema.String.annotations({
|
|
184
|
-
description: "title of the document"
|
|
185
|
-
}),
|
|
186
|
-
content: Schema.String
|
|
187
|
-
}).pipe(Type.object({
|
|
188
|
-
typename: "example.com/type/Document",
|
|
189
|
-
version: "0.1.0"
|
|
190
|
-
}));
|
|
191
|
-
const organization = Schema.Struct({
|
|
192
|
-
name: Schema.String.annotations({
|
|
193
|
-
description: "name of the company or organization"
|
|
194
|
-
}),
|
|
195
|
-
website: Schema.optional(Schema.String.annotations({
|
|
196
|
-
description: "public website URL"
|
|
197
|
-
})),
|
|
198
|
-
description: Schema.String.annotations({
|
|
199
|
-
description: "short summary of the company"
|
|
200
|
-
})
|
|
201
|
-
}).pipe(Type.object({
|
|
202
|
-
typename: "example.com/type/Organization",
|
|
203
|
-
version: "0.1.0"
|
|
204
|
-
}));
|
|
205
|
-
const contact = Schema.Struct({
|
|
206
|
-
name: Schema.String.annotations({
|
|
207
|
-
description: "name of the person"
|
|
208
|
-
}),
|
|
209
|
-
email: Schema.optional(Schema.String),
|
|
210
|
-
org: Schema.optional(Type.Ref(organization)),
|
|
211
|
-
lat: Schema.optional(Schema.Number),
|
|
212
|
-
lng: Schema.optional(Schema.Number)
|
|
213
|
-
}).pipe(Type.object({
|
|
214
|
-
typename: "example.com/type/Person",
|
|
215
|
-
version: "0.1.0"
|
|
216
|
-
}));
|
|
217
|
-
const project = Schema.Struct({
|
|
218
|
-
name: Schema.String.annotations({
|
|
219
|
-
description: "name of the project"
|
|
220
|
-
}),
|
|
221
|
-
description: Schema.String,
|
|
222
|
-
website: Schema.String,
|
|
223
|
-
repo: Schema.String,
|
|
224
|
-
status: Schema.String,
|
|
225
|
-
priority: Schema.Number,
|
|
226
|
-
active: Schema.Boolean,
|
|
227
|
-
org: Schema.optional(Type.Ref(organization))
|
|
228
|
-
}).pipe(Type.object({
|
|
229
|
-
typename: "example.com/type/Project",
|
|
230
|
-
version: "0.1.0"
|
|
231
|
-
}));
|
|
232
|
-
return {
|
|
233
|
-
["example.com/type/Document"]: document,
|
|
234
|
-
["example.com/type/Organization"]: organization,
|
|
235
|
-
["example.com/type/Person"]: contact,
|
|
236
|
-
["example.com/type/Project"]: project
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
var testObjectGenerators = {
|
|
240
|
-
["example.com/type/Document"]: async () => ({
|
|
241
|
-
title: faker2.lorem.sentence(3),
|
|
242
|
-
content: faker2.lorem.sentences({
|
|
243
|
-
min: 1,
|
|
244
|
-
max: faker2.number.int({
|
|
245
|
-
min: 1,
|
|
246
|
-
max: 3
|
|
247
|
-
})
|
|
248
|
-
})
|
|
249
|
-
}),
|
|
250
|
-
["example.com/type/Organization"]: async () => ({
|
|
251
|
-
name: faker2.company.name(),
|
|
252
|
-
website: faker2.datatype.boolean({
|
|
253
|
-
probability: 0.3
|
|
254
|
-
}) ? faker2.internet.url() : void 0,
|
|
255
|
-
description: faker2.lorem.sentences()
|
|
256
|
-
}),
|
|
257
|
-
["example.com/type/Person"]: async (provider) => {
|
|
258
|
-
const organizations = await provider?.("example.com/type/Organization");
|
|
259
|
-
const location = faker2.datatype.boolean() ? faker2.geo.airport() : {};
|
|
260
|
-
return {
|
|
261
|
-
name: faker2.person.fullName(),
|
|
262
|
-
email: faker2.datatype.boolean({
|
|
263
|
-
probability: 0.5
|
|
264
|
-
}) ? faker2.internet.email() : void 0,
|
|
265
|
-
org: organizations?.length && faker2.datatype.boolean({
|
|
266
|
-
probability: 0.8
|
|
267
|
-
}) ? Ref.make(faker2.helpers.arrayElement(organizations)) : void 0,
|
|
268
|
-
...location
|
|
269
|
-
};
|
|
270
|
-
},
|
|
271
|
-
["example.com/type/Project"]: async () => ({
|
|
272
|
-
name: faker2.commerce.productName(),
|
|
273
|
-
repo: faker2.internet.url(),
|
|
274
|
-
status: faker2.helpers.arrayElement(Status),
|
|
275
|
-
description: faker2.lorem.sentences(),
|
|
276
|
-
website: faker2.internet.url(),
|
|
277
|
-
priority: faker2.helpers.arrayElement(Priority),
|
|
278
|
-
active: faker2.datatype.boolean()
|
|
279
|
-
})
|
|
280
|
-
};
|
|
281
|
-
var testObjectMutators = {
|
|
282
|
-
["example.com/type/Document"]: async (object, params) => {
|
|
283
|
-
const accessor = createDocAccessor(object, [
|
|
284
|
-
"content"
|
|
285
|
-
]);
|
|
286
|
-
for (let i = 0; i < params.count; i++) {
|
|
287
|
-
const length = object.content?.content?.length ?? 0;
|
|
288
|
-
accessor.handle.change((doc) => {
|
|
289
|
-
A.splice(doc, accessor.path.slice(), 0, params.maxContentLength >= length ? 0 : params.mutationSize, randomText(params.mutationSize));
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
["example.com/type/Organization"]: async () => {
|
|
294
|
-
throw new Error("Method not implemented.");
|
|
295
|
-
},
|
|
296
|
-
["example.com/type/Person"]: async () => {
|
|
297
|
-
throw new Error("Method not implemented.");
|
|
298
|
-
},
|
|
299
|
-
["example.com/type/Project"]: async () => {
|
|
300
|
-
throw new Error("Method not implemented.");
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
var createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
|
|
304
|
-
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);
|
|
305
|
-
export {
|
|
306
|
-
Priority,
|
|
307
|
-
SpaceObjectGenerator,
|
|
308
|
-
Status,
|
|
309
|
-
TestObjectGenerator,
|
|
310
|
-
TestSchemaType,
|
|
311
|
-
createSpaceObjectGenerator,
|
|
312
|
-
createTestObjectGenerator,
|
|
313
|
-
randomText
|
|
314
|
-
};
|
|
315
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { Ref, Type } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Person',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(Type.object({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(Type.object({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Type.Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(Type.object({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Type.Ref(organization)),\n }).pipe(Type.object({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj, type Type } from '@dxos/echo';\nimport { EchoSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { isProxy } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderProps,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n\t\tprotected readonly _schemas: TestSchemaMap<T>,\n\t\tprivate readonly _generators: TestGeneratorMap<T>,\n\t\tprivate readonly _provider?: TestObjectProvider<T>,\n\t) {}\n\n get schemas(): Type.Obj.Any[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): Type.Obj.Any | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: Type.Obj.Any): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isProxy(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);\n return Obj.make(schema, data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: any[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: Type.Obj.Any[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.Obj.Any);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({\n types,\n }: {\n types?: T[];\n } = {}): Promise<Obj.Any> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(typename: string, schema: Type.Obj.Any): Promise<Type.Obj.Any> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n await this._space.internal.db.graph.schemaRegistry.register([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(Obj.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: Obj.Any[], params: MutationsProviderProps): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAGxB,SAASC,KAAKC,YAAY;AAC1B,SAASC,yBAAyB;AAClC,SAASC,SAAAA,cAAa;;;ACNtB,SAASC,cAA0B;AACnC,SAASC,WAAsB;AAC/B,SAASC,YAAYC,yBAAyB;AAC9C,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;;;;EAEX,YACmBC,UACFC,aACAC,WAChB;SAHkBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EACf;EAEF,IAAIC,UAA0B;AAC5B,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAmC;AAC3C,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWhB,kBAAkBgB,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAA4B;AACvD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiB;AAChE,UAAMN,OAAOX,MAAMkB,QAAQC,aAAaF,SAAUT,OAAOY,KAAK,KAAKhB,QAAQ,CAAA;AAC3E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B7E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
|
|
6
|
-
"names": ["next", "A", "Schema", "Ref", "Type", "createDocAccessor", "faker", "Filter", "Obj", "EchoSchema", "getTypeAnnotation", "isProxy", "invariant", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "internal", "schemaRegistry", "registeredSchema", "register", "graph", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "Type", "object", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/generator.ts":{"bytes":16828,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19599,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18711},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4813},"src/generator.ts":{"bytesInOutput":4322},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9801}}}
|