@dxos/echo-generator 0.7.2 → 0.7.3-staging.971cd8d

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.
@@ -3,30 +3,17 @@ import "@dxos/node-std/globals";
3
3
  // packages/core/echo/echo-generator/src/data.ts
4
4
  import { next as A } from "@dxos/automerge/automerge";
5
5
  import { createDocAccessor } from "@dxos/client/echo";
6
- import { createMutableSchema, ref, S } from "@dxos/echo-schema";
6
+ import { ref, S } from "@dxos/echo-schema";
7
+ import { createMutableSchema } from "@dxos/live-object";
7
8
  import { faker as faker2 } from "@dxos/random";
8
9
 
9
10
  // packages/core/echo/echo-generator/src/generator.ts
10
11
  import { Filter } from "@dxos/client/echo";
11
- import { create, getObjectAnnotation, getSchema, isReactiveObject, MutableSchema } from "@dxos/echo-schema";
12
+ import { getObjectAnnotation, MutableSchema } from "@dxos/echo-schema";
12
13
  import { invariant } from "@dxos/invariant";
14
+ import { create, getSchema, isReactiveObject } from "@dxos/live-object";
13
15
  import { faker } from "@dxos/random";
14
-
15
- // packages/core/echo/echo-generator/src/util.ts
16
- var range = (fn, length) => Array.from({
17
- length
18
- }).map((_, i) => fn(i)).filter(Boolean);
19
- var randomText = (length) => {
20
- let result = "";
21
- const characters = "abcdefghijklmnopqrstuvwxyz";
22
- const charactersLength = characters.length;
23
- for (let index = 0; index < length; index++) {
24
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
25
- }
26
- return result;
27
- };
28
-
29
- // packages/core/echo/echo-generator/src/generator.ts
16
+ import { range } from "@dxos/util";
30
17
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
31
18
  var TestObjectGenerator = class {
32
19
  // prettier-ignore
@@ -56,11 +43,11 @@ var TestObjectGenerator = class {
56
43
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
57
44
  async createObjects(map) {
58
45
  const tasks = Object.entries(map).map(([type, count]) => {
59
- return range(() => this.createObject({
46
+ return range(count, () => this.createObject({
60
47
  types: [
61
48
  type
62
49
  ]
63
- }), count);
50
+ }));
64
51
  }).flatMap((t) => t);
65
52
  return Promise.all(tasks);
66
53
  }
@@ -112,7 +99,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
112
99
  async mutateObject(object, params) {
113
100
  invariant(this._mutations, "Mutations not defined.", {
114
101
  F: __dxlog_file,
115
- L: 130,
102
+ L: 123,
116
103
  S: this,
117
104
  A: [
118
105
  "this._mutations",
@@ -122,7 +109,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
122
109
  const type = getObjectAnnotation(getSchema(object)).typename;
123
110
  invariant(type && this._mutations?.[type], "Invalid object type.", {
124
111
  F: __dxlog_file,
125
- L: 132,
112
+ L: 125,
126
113
  S: this,
127
114
  A: [
128
115
  "type && this._mutations?.[type]",
@@ -138,6 +125,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
138
125
  }
139
126
  };
140
127
 
128
+ // packages/core/echo/echo-generator/src/util.ts
129
+ var randomText = (length) => {
130
+ let result = "";
131
+ const characters = "abcdefghijklmnopqrstuvwxyz";
132
+ const charactersLength = characters.length;
133
+ for (let index = 0; index < length; index++) {
134
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
135
+ }
136
+ return result;
137
+ };
138
+
141
139
  // packages/core/echo/echo-generator/src/data.ts
142
140
  var Status = [
143
141
  "pending",
@@ -290,7 +288,6 @@ export {
290
288
  TestSchemaType,
291
289
  createSpaceObjectGenerator,
292
290
  createTestObjectGenerator,
293
- randomText,
294
- range
291
+ randomText
295
292
  };
296
293
  //# 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\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { createMutableSchema, ref, S } 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): 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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport {\n create,\n getObjectAnnotation,\n getSchema,\n isReactiveObject,\n MutableSchema,\n type ReactiveObject,\n type S,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,yBAAqC;AAC9C,SAASC,qBAAqBC,KAAKC,SAAS;AAC5C,SAASC,SAAAA,cAAa;;;ACHtB,SAAqBC,cAAc;AAEnC,SACEC,QACAC,qBACAC,WACAC,kBACAC,qBAGK;AACP,SAASC,iBAAiB;AAC1B,SAASC,aAAa;;;ACXf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;AAEL,IAAMC,aAAa,CAACR,WAAAA;AACzB,MAAIS,SAAS;AACb,QAAMC,aAAa;AACnB,QAAMC,mBAAmBD,WAAWV;AACpC,WAASY,QAAQ,GAAGA,QAAQZ,QAAQY,SAAS;AAC3CH,cAAUC,WAAWG,OAAOC,KAAKC,MAAMD,KAAKE,OAAM,IAAKL,gBAAAA,CAAAA;EACzD;AAEA,SAAOF;AACT;;;;ADYO,IAAMQ,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA6C;AAC/C,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAoD;AAC5D,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWC,oBAAoBD,MAAAA,EAASE,aAAaJ,IAAAA;EACjF;EAEUK,UAAUL,MAASE,QAAuC;AAClE,SAAKT,SAASO,IAAAA,IAAQE;EACxB;EAEA,MAAMI,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiC;AAChF,UAAMP,OAAOQ,MAAMC,QAAQC,aAAaH,SAAUV,O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AMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMV,SAASM,OAAO9C,SAASA,SAASwC,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,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB1E,YAAAA,GAAe2B,oBAAAA;AAE/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO5E,YAAAA,GAAe2B,sBAAsB4B,kBAAAA;",
6
- "names": ["next", "A", "createDocAccessor", "createMutableSchema", "ref", "S", "faker", "Filter", "create", "getObjectAnnotation", "getSchema", "isReactiveObject", "MutableSchema", "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", "getObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isReactiveObject", "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", "MutableSchema", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "typename", "version", "title", "S", "String", "annotations", "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", "geo", "airport", "person", "fullName", "length", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { ref, S } from '@dxos/echo-schema';\nimport { createMutableSchema } from '@dxos/live-object';\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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getObjectAnnotation, MutableSchema, type S } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { create, getSchema, isReactiveObject, type ReactiveObject } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n */\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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(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 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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\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,SAASC,yBAAqC;AAC9C,SAASC,KAAKC,SAAS;AACvB,SAASC,2BAA2B;AACpC,SAASC,SAAAA,cAAa;;;ACJtB,SAASC,cAA0B;AAEnC,SAASC,qBAAqBC,qBAA6B;AAC3D,SAASC,iBAAiB;AAC1B,SAASC,QAAQC,WAAWC,wBAA6C;AACzE,SAASC,aAAa;AACtB,SAASC,aAAa;;AAcf,IAAMC,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA6C;AAC/C,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAN,UAAUY,MAAoD;AAC5D,WAAO,KAAKH,QAAQI,KA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", "S", "createMutableSchema", "faker", "Filter", "getObjectAnnotation", "MutableSchema", "invariant", "create", "getSchema", "isReactiveObject", "faker", "range", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "createObjects", "map", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "run", "objects", "forEach", "dynamicSchema", "_maybeRegisterSchema", "addSchemas", "result", "push", "add", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "typename", "version", "title", "S", "String", "annotations", "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", "geo", "airport", "person", "fullName", "length", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":2293,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16430,"imports":[{"path":"@dxos/client/echo","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":18451,"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":1681,"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/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18621},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"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/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":4547},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3735},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":390},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9180}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16518,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1624,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":18563,"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/live-object","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":1729,"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/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18205},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"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/live-object","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/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4583},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3807},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9133}}}
@@ -25,30 +25,20 @@ __export(node_exports, {
25
25
  TestSchemaType: () => TestSchemaType,
26
26
  createSpaceObjectGenerator: () => createSpaceObjectGenerator,
27
27
  createTestObjectGenerator: () => createTestObjectGenerator,
28
- randomText: () => randomText,
29
- range: () => range
28
+ randomText: () => randomText
30
29
  });
31
30
  module.exports = __toCommonJS(node_exports);
32
31
  var import_automerge = require("@dxos/automerge/automerge");
33
32
  var import_echo = require("@dxos/client/echo");
34
33
  var import_echo_schema = require("@dxos/echo-schema");
34
+ var import_live_object = require("@dxos/live-object");
35
35
  var import_random = require("@dxos/random");
36
36
  var import_echo2 = require("@dxos/client/echo");
37
37
  var import_echo_schema2 = require("@dxos/echo-schema");
38
38
  var import_invariant = require("@dxos/invariant");
39
+ var import_live_object2 = require("@dxos/live-object");
39
40
  var import_random2 = require("@dxos/random");
40
- var range = (fn, length) => Array.from({
41
- length
42
- }).map((_, i) => fn(i)).filter(Boolean);
43
- var randomText = (length) => {
44
- let result = "";
45
- const characters = "abcdefghijklmnopqrstuvwxyz";
46
- const charactersLength = characters.length;
47
- for (let index = 0; index < length; index++) {
48
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
49
- }
50
- return result;
51
- };
41
+ var import_util = require("@dxos/util");
52
42
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
53
43
  var TestObjectGenerator = class {
54
44
  // prettier-ignore
@@ -69,20 +59,20 @@ var TestObjectGenerator = class {
69
59
  async createObject({ types } = {}) {
70
60
  const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
71
61
  const data = await this._generators[type](this._provider);
72
- if ((0, import_echo_schema2.isReactiveObject)(data)) {
62
+ if ((0, import_live_object2.isReactiveObject)(data)) {
73
63
  return data;
74
64
  }
75
65
  const schema = this.getSchema(type);
76
- return schema ? (0, import_echo_schema2.create)(schema, data) : (0, import_echo_schema2.create)(data);
66
+ return schema ? (0, import_live_object2.create)(schema, data) : (0, import_live_object2.create)(data);
77
67
  }
78
68
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
79
69
  async createObjects(map) {
80
70
  const tasks = Object.entries(map).map(([type, count]) => {
81
- return range(() => this.createObject({
71
+ return (0, import_util.range)(count, () => this.createObject({
82
72
  types: [
83
73
  type
84
74
  ]
85
- }), count);
75
+ }));
86
76
  }).flatMap((t) => t);
87
77
  return Promise.all(tasks);
88
78
  }
@@ -134,17 +124,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
134
124
  async mutateObject(object, params) {
135
125
  (0, import_invariant.invariant)(this._mutations, "Mutations not defined.", {
136
126
  F: __dxlog_file,
137
- L: 130,
127
+ L: 123,
138
128
  S: this,
139
129
  A: [
140
130
  "this._mutations",
141
131
  "'Mutations not defined.'"
142
132
  ]
143
133
  });
144
- const type = (0, import_echo_schema2.getObjectAnnotation)((0, import_echo_schema2.getSchema)(object)).typename;
134
+ const type = (0, import_echo_schema2.getObjectAnnotation)((0, import_live_object2.getSchema)(object)).typename;
145
135
  (0, import_invariant.invariant)(type && this._mutations?.[type], "Invalid object type.", {
146
136
  F: __dxlog_file,
147
- L: 132,
137
+ L: 125,
148
138
  S: this,
149
139
  A: [
150
140
  "type && this._mutations?.[type]",
@@ -159,6 +149,15 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
159
149
  }
160
150
  }
161
151
  };
152
+ var randomText = (length) => {
153
+ let result = "";
154
+ const characters = "abcdefghijklmnopqrstuvwxyz";
155
+ const charactersLength = characters.length;
156
+ for (let index = 0; index < length; index++) {
157
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
158
+ }
159
+ return result;
160
+ };
162
161
  var Status = [
163
162
  "pending",
164
163
  "active",
@@ -179,7 +178,7 @@ var TestSchemaType;
179
178
  TestSchemaType2["project"] = "example.com/type/project";
180
179
  })(TestSchemaType || (TestSchemaType = {}));
181
180
  var testSchemas = () => {
182
- const document = (0, import_echo_schema.createMutableSchema)({
181
+ const document = (0, import_live_object.createMutableSchema)({
183
182
  typename: "example.com/type/document",
184
183
  version: "0.1.0"
185
184
  }, {
@@ -188,7 +187,7 @@ var testSchemas = () => {
188
187
  }),
189
188
  content: import_echo_schema.S.String
190
189
  });
191
- const organization = (0, import_echo_schema.createMutableSchema)({
190
+ const organization = (0, import_live_object.createMutableSchema)({
192
191
  typename: "example.com/type/organization",
193
192
  version: "0.1.0"
194
193
  }, {
@@ -202,7 +201,7 @@ var testSchemas = () => {
202
201
  description: "short summary of the company"
203
202
  })
204
203
  });
205
- const contact = (0, import_echo_schema.createMutableSchema)({
204
+ const contact = (0, import_live_object.createMutableSchema)({
206
205
  typename: "example.com/type/contact",
207
206
  version: "0.1.0"
208
207
  }, {
@@ -214,7 +213,7 @@ var testSchemas = () => {
214
213
  lat: import_echo_schema.S.Number,
215
214
  lng: import_echo_schema.S.Number
216
215
  });
217
- const project = (0, import_echo_schema.createMutableSchema)({
216
+ const project = (0, import_live_object.createMutableSchema)({
218
217
  typename: "example.com/type/project",
219
218
  version: "0.1.0"
220
219
  }, {
@@ -311,7 +310,6 @@ var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, test
311
310
  TestSchemaType,
312
311
  createSpaceObjectGenerator,
313
312
  createTestObjectGenerator,
314
- randomText,
315
- range
313
+ randomText
316
314
  });
317
315
  //# 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\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { createMutableSchema, ref, S } 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): 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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport {\n create,\n getObjectAnnotation,\n getSchema,\n isReactiveObject,\n MutableSchema,\n type ReactiveObject,\n type S,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\n return result;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAA0B;AAC1B,kBAA8C;AAC9C,yBAA4C;AAC5C,oBAAsB;ACHtB,IAAAA,eAAmC;AAEnC,IAAAC,sBAQO;AACP,uBAA0B;AAC1B,IAAAC,iBAAsB;ACXf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;AAEL,IAAMC,aAAa,CAACR,WAAAA;AACzB,MAAIS,SAAS;AACb,QAAMC,aAAa;AACnB,QAAMC,mBAAmBD,WAAWV;AACpC,WAASY,QAAQ,GAAGA,QAAQZ,QAAQY,SAAS;AAC3CH,cAAUC,WAAWG,OAAOC,KAAKC,MAAMD,KAAKE,OAAM,IAAKL,gBAAAA,CAAAA;EACzD;AAEA,SAAOF;AACT;;ADYO,IAAMQ,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAA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B,oBAAAA;AAE/E,IAAMsC,6BAA6B,CAACC,UACzC,IAAI/F,qBAAqB+F,OAAOhE,YAAAA,GAAeyB,sBAAsBwB,kBAAAA;",
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", "getObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isReactiveObject", "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", "MutableSchema", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "version", "title", "S", "String", "annotations", "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", "geo", "airport", "person", "fullName", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { ref, S } from '@dxos/echo-schema';\nimport { createMutableSchema } from '@dxos/live-object';\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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getObjectAnnotation, MutableSchema, type S } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { create, getSchema, isReactiveObject, type ReactiveObject } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n */\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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(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 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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\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,uBAA0B;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AASL,OAAOyB,SAASA,SAASpB,UAAU;AAClD8D,eAASG,OAAOC,OAAO,CAACC,QAAAA;AACtBC,yBAAAA,KAAEC,OACAF,KACAL,SAASQ,KAAKC,MAAK,GACnB,GACA3E,OAAO4E,oBAAoBxE,SAAS,IAAIJ,OAAO6E,cAC/C1E,WAAWH,OAAO6E,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIC,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAI3I,oBAAoB2E,YAAAA,GAAe0B,oBAAAA;AAE/E,IAAMuC,6BAA6B,CAACC,UACzC,IAAI3G,qBAAqB2G,OAAOlE,YAAAA,GAAe0B,sBAAsBwB,kBAAAA;",
6
+ "names": ["import_echo", "import_echo_schema", "import_live_object", "import_random", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isReactiveObject", "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", "MutableSchema", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "randomText", "length", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "version", "title", "S", "String", "annotations", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "i", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":2293,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16430,"imports":[{"path":"@dxos/client/echo","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":18451,"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":1681,"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":18619},"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/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":4547},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3735},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":390},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9146}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16518,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1624,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":18563,"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/live-object","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":1729,"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":18203},"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/live-object","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/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4583},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3807},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9099}}}
@@ -3,30 +3,17 @@ import { createRequire } from 'node:module';const require = createRequire(import
3
3
  // packages/core/echo/echo-generator/src/data.ts
4
4
  import { next as A } from "@dxos/automerge/automerge";
5
5
  import { createDocAccessor } from "@dxos/client/echo";
6
- import { createMutableSchema, ref, S } from "@dxos/echo-schema";
6
+ import { ref, S } from "@dxos/echo-schema";
7
+ import { createMutableSchema } from "@dxos/live-object";
7
8
  import { faker as faker2 } from "@dxos/random";
8
9
 
9
10
  // packages/core/echo/echo-generator/src/generator.ts
10
11
  import { Filter } from "@dxos/client/echo";
11
- import { create, getObjectAnnotation, getSchema, isReactiveObject, MutableSchema } from "@dxos/echo-schema";
12
+ import { getObjectAnnotation, MutableSchema } from "@dxos/echo-schema";
12
13
  import { invariant } from "@dxos/invariant";
14
+ import { create, getSchema, isReactiveObject } from "@dxos/live-object";
13
15
  import { faker } from "@dxos/random";
14
-
15
- // packages/core/echo/echo-generator/src/util.ts
16
- var range = (fn, length) => Array.from({
17
- length
18
- }).map((_, i) => fn(i)).filter(Boolean);
19
- var randomText = (length) => {
20
- let result = "";
21
- const characters = "abcdefghijklmnopqrstuvwxyz";
22
- const charactersLength = characters.length;
23
- for (let index = 0; index < length; index++) {
24
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
25
- }
26
- return result;
27
- };
28
-
29
- // packages/core/echo/echo-generator/src/generator.ts
16
+ import { range } from "@dxos/util";
30
17
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
31
18
  var TestObjectGenerator = class {
32
19
  // prettier-ignore
@@ -56,11 +43,11 @@ var TestObjectGenerator = class {
56
43
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
57
44
  async createObjects(map) {
58
45
  const tasks = Object.entries(map).map(([type, count]) => {
59
- return range(() => this.createObject({
46
+ return range(count, () => this.createObject({
60
47
  types: [
61
48
  type
62
49
  ]
63
- }), count);
50
+ }));
64
51
  }).flatMap((t) => t);
65
52
  return Promise.all(tasks);
66
53
  }
@@ -112,7 +99,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
112
99
  async mutateObject(object, params) {
113
100
  invariant(this._mutations, "Mutations not defined.", {
114
101
  F: __dxlog_file,
115
- L: 130,
102
+ L: 123,
116
103
  S: this,
117
104
  A: [
118
105
  "this._mutations",
@@ -122,7 +109,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
122
109
  const type = getObjectAnnotation(getSchema(object)).typename;
123
110
  invariant(type && this._mutations?.[type], "Invalid object type.", {
124
111
  F: __dxlog_file,
125
- L: 132,
112
+ L: 125,
126
113
  S: this,
127
114
  A: [
128
115
  "type && this._mutations?.[type]",
@@ -138,6 +125,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
138
125
  }
139
126
  };
140
127
 
128
+ // packages/core/echo/echo-generator/src/util.ts
129
+ var randomText = (length) => {
130
+ let result = "";
131
+ const characters = "abcdefghijklmnopqrstuvwxyz";
132
+ const charactersLength = characters.length;
133
+ for (let index = 0; index < length; index++) {
134
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
135
+ }
136
+ return result;
137
+ };
138
+
141
139
  // packages/core/echo/echo-generator/src/data.ts
142
140
  var Status = [
143
141
  "pending",
@@ -290,7 +288,6 @@ export {
290
288
  TestSchemaType,
291
289
  createSpaceObjectGenerator,
292
290
  createTestObjectGenerator,
293
- randomText,
294
- range
291
+ randomText
295
292
  };
296
293
  //# 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\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { createMutableSchema, ref, S } 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): 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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport {\n create,\n getObjectAnnotation,\n getSchema,\n isReactiveObject,\n MutableSchema,\n type ReactiveObject,\n type S,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC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,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,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB1E,YAAAA,GAAe2B,oBAAAA;AAE/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO5E,YAAAA,GAAe2B,sBAAsB4B,kBAAAA;",
6
- "names": ["next", "A", "createDocAccessor", "createMutableSchema", "ref", "S", "faker", "Filter", "create", "getObjectAnnotation", "getSchema", "isReactiveObject", "MutableSchema", "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", "getObjectAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isReactiveObject", "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", "MutableSchema", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "typename", "version", "title", "S", "String", "annotations", "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", "geo", "airport", "person", "fullName", "length", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { ref, S } from '@dxos/echo-schema';\nimport { createMutableSchema } from '@dxos/live-object';\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\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 testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createMutableSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createMutableSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createMutableSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createMutableSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ 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\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 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// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getObjectAnnotation, MutableSchema, type S } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { create, getSchema, isReactiveObject, type ReactiveObject } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n */\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(): (MutableSchema | S.Schema<any>)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): MutableSchema | S.Schema<any> | undefined {\n return this.schemas.find((schema) => getObjectAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: MutableSchema | S.Schema<any>) {\n this._schemas[type] = schema;\n }\n\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 if (isReactiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\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(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 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<MutableSchema | S.Schema<any>>(schemaMap).forEach(([type, dynamicSchema]) => {\n const schema = this._maybeRegisterSchema(type, dynamicSchema);\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: (MutableSchema | S.Schema<any>)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n result.push(this._maybeRegisterSchema(typename, schema as MutableSchema | S.Schema<any>));\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private _maybeRegisterSchema(typename: string, schema: MutableSchema | S.Schema<any>): MutableSchema | S.Schema<any> {\n if (schema instanceof MutableSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.add(schema.storedSchema);\n return this._space.db.schemaRegistry.registerSchema(schema.storedSchema);\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: ReactiveEchoObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getObjectAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: ReactiveEchoObject<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\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,SAASC,yBAAqC;AAC9C,SAASC,KAAKC,SAAS;AACvB,SAASC,2BAA2B;AACpC,SAASC,SAAAA,cAAa;;;ACJtB,SAASC,cAA0B;AAEnC,SAASC,qBAAqBC,qBAA6B;AAC3D,SAASC,iBAAiB;AAC1B,SAASC,QAAQC,WAAWC,wBAA6C;AACzE,SAASC,aAAa;AACtB,SAASC,aAAa;;AAcf,IAAMC,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA6C;AAC/C,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAN,UAAUY,MAAoD;AAC5D,WAAO,KAAKH,QAAQI,KAAK,CAACC,WAAWlB,oBAAoBkB,MAAAA,EAASC,aAAaH,IAAAA;EACjF;EAEUI,UAAUJ,MAASE,QAAuC;AAClE,SAAKR,SAASM,IAAAA,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAA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yB,SAASC,YAAW;IAChChC,MAAMM,OAAMS,SAASC,QAAQ;MAAEC,aAAa;IAAI,CAAA,IAAKX,OAAMY,SAASC,IAAG,IAAKC;IAC5EnB,QAAQK,OAAMuB,QAAQC,aAAavD,MAAAA;IACnC2B,UAAUI,OAAMuB,QAAQC,aAAatD,QAAAA;IACrC2B,QAAQG,OAAMS,SAASC,QAAO;EAChC;AACF;AAEA,IAAMiB,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOC,QAAQC,WAAAA;AACxC,UAAMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMV,SAASM,OAAO9C,SAASA,SAASwC,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,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB1E,YAAAA,GAAe2B,oBAAAA;AAE/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO5E,YAAAA,GAAe2B,sBAAsB4B,kBAAAA;",
6
+ "names": ["next", "A", "createDocAccessor", "ref", "S", "createMutableSchema", "faker", "Filter", "getObjectAnnotation", "MutableSchema", "invariant", "create", "getSchema", "isReactiveObject", "faker", "range", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "createObjects", "map", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "run", "objects", "forEach", "dynamicSchema", "_maybeRegisterSchema", "addSchemas", "result", "push", "add", "existingSchema", "schemaRegistry", "storedSchema", "registerSchema", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createMutableSchema", "typename", "version", "title", "S", "String", "annotations", "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", "geo", "airport", "person", "fullName", "length", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":2293,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16430,"imports":[{"path":"@dxos/client/echo","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":18451,"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":1681,"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-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18621},"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs":{"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/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":4547},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3735},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":390},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9239}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16518,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1624,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":18563,"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/live-object","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":1729,"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-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18205},"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs":{"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/live-object","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/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4583},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3807},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9192}}}
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,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;AA+HD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACmC,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,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;AA+HD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACmC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { type Space } from '@dxos/client/echo';
2
2
  import { type ReactiveEchoObject } from '@dxos/echo-db';
3
- import { MutableSchema, type ReactiveObject, type S } from '@dxos/echo-schema';
3
+ import { MutableSchema, type S } from '@dxos/echo-schema';
4
+ import { type ReactiveObject } from '@dxos/live-object';
4
5
  import { type TestSchemaType } from './data';
5
6
  import { type MutationsProviderParams, type TestGeneratorMap, type TestMutationsMap, type TestObjectProvider, type TestSchemaMap } from './types';
6
7
  /**
@@ -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,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAKL,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,CAAC,EACP,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc;IAG9D,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAFR,QAAQ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SAAS;IAI7D,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAI5D,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAY3E,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CASpD;AAED;;GAEG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAHX,MAAM,EAAE,KAAK,EAC9B,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACd,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,YAAA;IAenD,UAAU;IASK,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;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,5 +1,6 @@
1
1
  import { type ReactiveEchoObject } from '@dxos/echo-db';
2
- import { type MutableSchema, type ReactiveObject, type S } from '@dxos/echo-schema';
2
+ import { type MutableSchema, type S } from '@dxos/echo-schema';
3
+ import { type ReactiveObject } from '@dxos/live-object';
3
4
  export type TestObject = {
4
5
  id: string;
5
6
  } & Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGpF,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAEhG,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAExG,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAC9D,CAAC,EACD,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,GAAG,CACrD,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAExF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,uBA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M,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,3 +1,2 @@
1
- export declare const range: <T>(fn: (i: number) => T | undefined, length: number) => T[];
2
1
  export declare const randomText: (length: number) => string;
3
2
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,GAAI,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,UAAU,MAAM,KAAG,CAAC,EAGlD,CAAC;AAE5B,eAAO,MAAM,UAAU,WAAY,MAAM,WASxC,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,WAAY,MAAM,WASxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-generator",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-staging.971cd8d",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,19 +23,21 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "@dxos/automerge": "0.7.2",
27
- "@dxos/client": "0.7.2",
28
- "@dxos/echo-db": "0.7.2",
29
- "@dxos/echo-schema": "0.7.2",
30
- "@dxos/invariant": "0.7.2",
31
- "@dxos/node-std": "0.7.2",
32
- "@dxos/schema": "0.7.2"
26
+ "@dxos/automerge": "0.7.3-staging.971cd8d",
27
+ "@dxos/client": "0.7.3-staging.971cd8d",
28
+ "@dxos/echo-db": "0.7.3-staging.971cd8d",
29
+ "@dxos/echo-schema": "0.7.3-staging.971cd8d",
30
+ "@dxos/invariant": "0.7.3-staging.971cd8d",
31
+ "@dxos/live-object": "0.7.3-staging.971cd8d",
32
+ "@dxos/schema": "0.7.3-staging.971cd8d",
33
+ "@dxos/util": "0.7.3-staging.971cd8d",
34
+ "@dxos/node-std": "0.7.3-staging.971cd8d"
33
35
  },
34
36
  "devDependencies": {
35
- "@dxos/random": "0.7.2"
37
+ "@dxos/random": "0.7.3-staging.971cd8d"
36
38
  },
37
39
  "peerDependencies": {
38
- "@dxos/random": "0.7.2"
40
+ "@dxos/random": "0.7.3-staging.971cd8d"
39
41
  },
40
42
  "publishConfig": {
41
43
  "access": "public"
package/src/data.ts CHANGED
@@ -4,11 +4,12 @@
4
4
 
5
5
  import { next as A } from '@dxos/automerge/automerge';
6
6
  import { createDocAccessor, type Space } from '@dxos/client/echo';
7
- import { createMutableSchema, ref, S } from '@dxos/echo-schema';
7
+ import { ref, S } from '@dxos/echo-schema';
8
+ import { createMutableSchema } from '@dxos/live-object';
8
9
  import { faker } from '@dxos/random';
9
10
 
10
11
  import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
11
- import { type TestMutationsMap, type TestGeneratorMap, type TestSchemaMap } from './types';
12
+ import { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';
12
13
  import { randomText } from './util';
13
14
 
14
15
  // TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.
@@ -2,12 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, describe, expect, test } from 'vitest';
5
+ import { describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { next as A } from '@dxos/automerge/automerge';
8
8
  import { Client } from '@dxos/client';
9
9
  import { getObjectCore } from '@dxos/echo-db';
10
- import { getType, S, TypedObject } from '@dxos/echo-schema';
10
+ import { S, TypedObject } from '@dxos/echo-schema';
11
+ import { getType } from '@dxos/live-object';
11
12
  import { faker } from '@dxos/random';
12
13
 
13
14
  import { createSpaceObjectGenerator, createTestObjectGenerator, TestSchemaType } from './data';
package/src/generator.ts CHANGED
@@ -2,19 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Space, Filter } from '@dxos/client/echo';
5
+ import { Filter, type Space } from '@dxos/client/echo';
6
6
  import { type ReactiveEchoObject } from '@dxos/echo-db';
7
- import {
8
- create,
9
- getObjectAnnotation,
10
- getSchema,
11
- isReactiveObject,
12
- MutableSchema,
13
- type ReactiveObject,
14
- type S,
15
- } from '@dxos/echo-schema';
7
+ import { getObjectAnnotation, MutableSchema, type S } from '@dxos/echo-schema';
16
8
  import { invariant } from '@dxos/invariant';
9
+ import { create, getSchema, isReactiveObject, type ReactiveObject } from '@dxos/live-object';
17
10
  import { faker } from '@dxos/random';
11
+ import { range } from '@dxos/util';
18
12
 
19
13
  import { type TestSchemaType } from './data';
20
14
  import {
@@ -24,7 +18,6 @@ import {
24
18
  type TestObjectProvider,
25
19
  type TestSchemaMap,
26
20
  } from './types';
27
- import { range } from './util';
28
21
 
29
22
  /**
30
23
  * Typed object generator.
@@ -64,7 +57,7 @@ export class TestObjectGenerator<T extends string = TestSchemaType> {
64
57
  async createObjects(map: Partial<Record<T, number>>) {
65
58
  const tasks = Object.entries<number>(map as any)
66
59
  .map(([type, count]) => {
67
- return range(() => this.createObject({ types: [type as T] }), count);
60
+ return range(count, () => this.createObject({ types: [type as T] }));
68
61
  })
69
62
  .flatMap((t) => t);
70
63
 
package/src/types.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  //
4
4
 
5
5
  import { type ReactiveEchoObject } from '@dxos/echo-db';
6
- import { type MutableSchema, type ReactiveObject, type S } from '@dxos/echo-schema';
6
+ import { type MutableSchema, type S } from '@dxos/echo-schema';
7
+ import { type ReactiveObject } from '@dxos/live-object';
7
8
 
8
9
  // TODO(burdon): Use echo-schema types.
9
10
  export type TestObject = { id: string } & Record<string, any>;
package/src/util.ts CHANGED
@@ -2,12 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- // TODO(burdon): Util.
6
- export const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>
7
- Array.from({ length })
8
- .map((_, i) => fn(i))
9
- .filter(Boolean) as T[];
10
-
11
5
  export const randomText = (length: number) => {
12
6
  let result = '';
13
7
  const characters = 'abcdefghijklmnopqrstuvwxyz';