@dxos/echo-generator 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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.
@@ -4,8 +4,7 @@ import "@dxos/node-std/globals";
4
4
  import { next as A } from "@automerge/automerge";
5
5
  import { Schema } from "effect";
6
6
  import { createDocAccessor } from "@dxos/client/echo";
7
- import { Ref } from "@dxos/echo-schema";
8
- import { createEchoSchema } from "@dxos/live-object";
7
+ import { EchoObject, Ref } from "@dxos/echo-schema";
9
8
  import { faker as faker2 } from "@dxos/random";
10
9
 
11
10
  // packages/core/echo/echo-generator/src/generator.ts
@@ -14,7 +13,7 @@ import { getTypeAnnotation, EchoSchema, getSchema } from "@dxos/echo-schema";
14
13
  import { invariant } from "@dxos/invariant";
15
14
  import { live, isLiveObject } from "@dxos/live-object";
16
15
  import { faker } from "@dxos/random";
17
- import { range } from "@dxos/util";
16
+ import { entries, range } from "@dxos/util";
18
17
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
19
18
  var TestObjectGenerator = class {
20
19
  // prettier-ignore
@@ -43,6 +42,14 @@ var TestObjectGenerator = class {
43
42
  }
44
43
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
45
44
  async createObjects(map) {
45
+ const results = [];
46
+ for (const [type, count] of entries(map)) {
47
+ results.push(...await Promise.all(range(count ?? 0, () => this.createObject({
48
+ types: [
49
+ type
50
+ ]
51
+ }))));
52
+ }
46
53
  const tasks = Object.entries(map).map(([type, count]) => {
47
54
  return range(count, () => this.createObject({
48
55
  types: [
@@ -57,10 +64,9 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
57
64
  constructor(_space, schemaMap, generators, _mutations) {
58
65
  super(schemaMap, generators, async (type) => {
59
66
  const schema = this.getSchema(type);
60
- return (schema && (await this._space.db.query(Filter.type(schema)).run()).objects) ?? [];
61
- });
62
- this._space = _space;
63
- this._mutations = _mutations;
67
+ const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
68
+ return objects;
69
+ }), this._space = _space, this._mutations = _mutations;
64
70
  }
65
71
  async addSchemas() {
66
72
  const result = [];
@@ -100,7 +106,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
100
106
  async mutateObject(object, params) {
101
107
  invariant(this._mutations, "Mutations not defined.", {
102
108
  F: __dxlog_file,
103
- L: 123,
109
+ L: 130,
104
110
  S: this,
105
111
  A: [
106
112
  "this._mutations",
@@ -110,7 +116,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
110
116
  const type = getTypeAnnotation(getSchema(object)).typename;
111
117
  invariant(type && this._mutations?.[type], "Invalid object type.", {
112
118
  F: __dxlog_file,
113
- L: 125,
119
+ L: 132,
114
120
  S: this,
115
121
  A: [
116
122
  "type && this._mutations?.[type]",
@@ -150,53 +156,50 @@ var Priority = [
150
156
  4,
151
157
  5
152
158
  ];
153
- var TestSchemaType;
154
- (function(TestSchemaType2) {
155
- TestSchemaType2["document"] = "example.com/type/document";
156
- TestSchemaType2["organization"] = "example.com/type/organization";
157
- TestSchemaType2["contact"] = "example.com/type/contact";
158
- TestSchemaType2["project"] = "example.com/type/project";
159
- })(TestSchemaType || (TestSchemaType = {}));
159
+ var TestSchemaType = /* @__PURE__ */ function(TestSchemaType2) {
160
+ TestSchemaType2["document"] = "example.com/type/Document";
161
+ TestSchemaType2["organization"] = "example.com/type/Organization";
162
+ TestSchemaType2["contact"] = "example.com/type/Contact";
163
+ TestSchemaType2["project"] = "example.com/type/Project";
164
+ return TestSchemaType2;
165
+ }({});
160
166
  var testSchemas = () => {
161
- const document = createEchoSchema({
162
- typename: "example.com/type/document",
163
- version: "0.1.0"
164
- }, {
167
+ const document = Schema.Struct({
165
168
  title: Schema.String.annotations({
166
169
  description: "title of the document"
167
170
  }),
168
171
  content: Schema.String
169
- });
170
- const organization = createEchoSchema({
171
- typename: "example.com/type/organization",
172
+ }).pipe(EchoObject({
173
+ typename: "example.com/type/Document",
172
174
  version: "0.1.0"
173
- }, {
175
+ }));
176
+ const organization = Schema.Struct({
174
177
  name: Schema.String.annotations({
175
178
  description: "name of the company or organization"
176
179
  }),
177
- website: Schema.String.annotations({
180
+ website: Schema.optional(Schema.String.annotations({
178
181
  description: "public website URL"
179
- }),
182
+ })),
180
183
  description: Schema.String.annotations({
181
184
  description: "short summary of the company"
182
185
  })
183
- });
184
- const contact = createEchoSchema({
185
- typename: "example.com/type/contact",
186
+ }).pipe(EchoObject({
187
+ typename: "example.com/type/Organization",
186
188
  version: "0.1.0"
187
- }, {
189
+ }));
190
+ const contact = Schema.Struct({
188
191
  name: Schema.String.annotations({
189
192
  description: "name of the person"
190
193
  }),
191
- email: Schema.String,
192
- org: Ref(organization),
193
- lat: Schema.Number,
194
- lng: Schema.Number
195
- });
196
- const project = createEchoSchema({
197
- typename: "example.com/type/project",
194
+ email: Schema.optional(Schema.String),
195
+ org: Schema.optional(Ref(organization)),
196
+ lat: Schema.optional(Schema.Number),
197
+ lng: Schema.optional(Schema.Number)
198
+ }).pipe(EchoObject({
199
+ typename: "example.com/type/Contact",
198
200
  version: "0.1.0"
199
- }, {
201
+ }));
202
+ const project = Schema.Struct({
200
203
  name: Schema.String.annotations({
201
204
  description: "name of the project"
202
205
  }),
@@ -206,17 +209,20 @@ var testSchemas = () => {
206
209
  status: Schema.String,
207
210
  priority: Schema.Number,
208
211
  active: Schema.Boolean,
209
- org: Ref(organization)
210
- });
212
+ org: Schema.optional(Ref(organization))
213
+ }).pipe(EchoObject({
214
+ typename: "example.com/type/Project",
215
+ version: "0.1.0"
216
+ }));
211
217
  return {
212
- ["example.com/type/document"]: document,
213
- ["example.com/type/organization"]: organization,
214
- ["example.com/type/contact"]: contact,
215
- ["example.com/type/project"]: project
218
+ ["example.com/type/Document"]: document,
219
+ ["example.com/type/Organization"]: organization,
220
+ ["example.com/type/Contact"]: contact,
221
+ ["example.com/type/Project"]: project
216
222
  };
217
223
  };
218
224
  var testObjectGenerators = {
219
- ["example.com/type/document"]: async () => ({
225
+ ["example.com/type/Document"]: async () => ({
220
226
  title: faker2.lorem.sentence(3),
221
227
  content: faker2.lorem.sentences({
222
228
  min: 1,
@@ -226,39 +232,39 @@ var testObjectGenerators = {
226
232
  })
227
233
  })
228
234
  }),
229
- ["example.com/type/organization"]: async () => ({
235
+ ["example.com/type/Organization"]: async () => ({
230
236
  name: faker2.company.name(),
231
237
  website: faker2.datatype.boolean({
232
238
  probability: 0.3
233
239
  }) ? faker2.internet.url() : void 0,
234
240
  description: faker2.lorem.sentences()
235
241
  }),
236
- ["example.com/type/contact"]: async (provider) => {
237
- const organizations = await provider?.("example.com/type/organization");
238
- const { location } = faker2.datatype.boolean() ? faker2.geo.airport() : {};
242
+ ["example.com/type/Contact"]: async (provider) => {
243
+ const organizations = await provider?.("example.com/type/Organization");
244
+ const location = faker2.datatype.boolean() ? faker2.geo.airport() : {};
239
245
  return {
240
246
  name: faker2.person.fullName(),
241
247
  email: faker2.datatype.boolean({
242
248
  probability: 0.5
243
249
  }) ? faker2.internet.email() : void 0,
244
250
  org: organizations?.length && faker2.datatype.boolean({
245
- probability: 0.3
251
+ probability: 0.8
246
252
  }) ? Ref.make(faker2.helpers.arrayElement(organizations)) : void 0,
247
253
  ...location
248
254
  };
249
255
  },
250
- ["example.com/type/project"]: async () => ({
256
+ ["example.com/type/Project"]: async () => ({
251
257
  name: faker2.commerce.productName(),
252
- repo: faker2.datatype.boolean({
253
- probability: 0.3
254
- }) ? faker2.internet.url() : void 0,
258
+ repo: faker2.internet.url(),
255
259
  status: faker2.helpers.arrayElement(Status),
260
+ description: faker2.lorem.sentences(),
261
+ website: faker2.internet.url(),
256
262
  priority: faker2.helpers.arrayElement(Priority),
257
263
  active: faker2.datatype.boolean()
258
264
  })
259
265
  };
260
266
  var testObjectMutators = {
261
- ["example.com/type/document"]: async (object, params) => {
267
+ ["example.com/type/Document"]: async (object, params) => {
262
268
  const accessor = createDocAccessor(object, [
263
269
  "content"
264
270
  ]);
@@ -269,13 +275,13 @@ var testObjectMutators = {
269
275
  });
270
276
  }
271
277
  },
272
- ["example.com/type/organization"]: async () => {
278
+ ["example.com/type/Organization"]: async () => {
273
279
  throw new Error("Method not implemented.");
274
280
  },
275
- ["example.com/type/contact"]: async () => {
281
+ ["example.com/type/Contact"]: async () => {
276
282
  throw new Error("Method not implemented.");
277
283
  },
278
- ["example.com/type/project"]: async () => {
284
+ ["example.com/type/Project"]: async () => {
279
285
  throw new Error("Method not implemented.");
280
286
  }
281
287
  };
@@ -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 '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { Ref } from '@dxos/echo-schema';\nimport { createEchoSchema } 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 = createEchoSchema(\n {\n typename: TestSchemaType.document,\n version: '0.1.0',\n },\n {\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n },\n );\n\n const organization = createEchoSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.String.annotations({ description: 'public website URL' }),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createEchoSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.String,\n org: Ref(organization),\n lat: Schema.Number,\n lng: Schema.Number,\n },\n );\n\n const project = createEchoSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: 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 ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.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 Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { live, isLiveObject, type Live } 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(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext) {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const 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.type(schema)).run()).objects) ?? [];\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams) {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<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,cAAc;AAEvB,SAASC,yBAAqC;AAC9C,SAASC,WAAW;AACpB,SAASC,wBAAwB;AACjC,SAASC,SAAAA,cAAa;;;ACJtB,SAASC,cAA0B;AAEnC,SAASC,mBAAmBC,YAAYC,iBAAiB;AACzD,SAASC,iBAAiB;AAC1B,SAASC,MAAMC,oBAA+B;AAC9C,SAASC,aAAa;AACtB,SAASC,aAAa;;AAcf,IAAMC,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAR,UAAUc,MAA8D;AACtE,WAAO,KAAKH,QAAQI,KAAK,CAACC,WAAWlB,kBAAkBkB,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAiD;AAC5E,SAAKR,SAASM,IAAAA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AAI,CAAA,IAAKX,OAAMY,SAASC,IAAG,IAAKC;IAC5EnB,QAAQK,OAAMwB,QAAQC,aAAaxD,MAAAA;IACnC2B,UAAUI,OAAMwB,QAAQC,aAAavD,QAAAA;IACrC2B,QAAQG,OAAMS,SAASC,QAAO;EAChC;AACF;AAEA,IAAMkB,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOC,QAAQC,WAAAA;AACxC,UAAMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMX,SAASO,OAAO/C,SAASA,SAASwC,UAAU;AAClDS,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB3E,YAAAA,GAAe2B,oBAAAA;AAE/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO7E,YAAAA,GAAe2B,sBAAsB6B,kBAAAA;",
6
- "names": ["next", "A", "Schema", "createDocAccessor", "Ref", "createEchoSchema", "faker", "Filter", "getTypeAnnotation", "EchoSchema", "getSchema", "invariant", "live", "isLiveObject", "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", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "push", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createEchoSchema", "typename", "version", "title", "Schema", "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", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { live, isLiveObject, type Live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,cAAc;AAEvB,SAASC,yBAAqC;AAC9C,SAASC,YAA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AAUI,OAAMwB,QAAQC,aAAa1D,QAAAA;IACrC8B,QAAQG,OAAMS,SAASC,QAAO;EAChC;AACF;AAEA,IAAMkB,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOC,QAAQC,WAAAA;AACxC,UAAMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMX,SAASO,OAAOpD,SAASA,SAAS6C,UAAU;AAClDS,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB9E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAOhF,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
6
+ "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "getTypeAnnotation", "EchoSchema", "getSchema", "invariant", "live", "isLiveObject", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15771,"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":18883,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","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":1745,"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":18020},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","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":4683},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3707},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9133}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16612,"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":1580,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":19484,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","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":1713,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"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":18940},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","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/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":4811},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3960},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9514}}}
@@ -32,12 +32,11 @@ var import_automerge = require("@automerge/automerge");
32
32
  var import_effect = require("effect");
33
33
  var import_echo = require("@dxos/client/echo");
34
34
  var import_echo_schema = require("@dxos/echo-schema");
35
- var import_live_object = require("@dxos/live-object");
36
35
  var import_random = require("@dxos/random");
37
36
  var import_echo2 = require("@dxos/client/echo");
38
37
  var import_echo_schema2 = require("@dxos/echo-schema");
39
38
  var import_invariant = require("@dxos/invariant");
40
- var import_live_object2 = require("@dxos/live-object");
39
+ var import_live_object = require("@dxos/live-object");
41
40
  var import_random2 = require("@dxos/random");
42
41
  var import_util = require("@dxos/util");
43
42
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
@@ -60,14 +59,22 @@ var TestObjectGenerator = class {
60
59
  async createObject({ types } = {}) {
61
60
  const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
62
61
  const data = await this._generators[type](this._provider);
63
- if ((0, import_live_object2.isLiveObject)(data)) {
62
+ if ((0, import_live_object.isLiveObject)(data)) {
64
63
  return data;
65
64
  }
66
65
  const schema = this.getSchema(type);
67
- return schema ? (0, import_live_object2.live)(schema, data) : (0, import_live_object2.live)(data);
66
+ return schema ? (0, import_live_object.live)(schema, data) : (0, import_live_object.live)(data);
68
67
  }
69
68
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
70
69
  async createObjects(map) {
70
+ const results = [];
71
+ for (const [type, count] of (0, import_util.entries)(map)) {
72
+ results.push(...await Promise.all((0, import_util.range)(count ?? 0, () => this.createObject({
73
+ types: [
74
+ type
75
+ ]
76
+ }))));
77
+ }
71
78
  const tasks = Object.entries(map).map(([type, count]) => {
72
79
  return (0, import_util.range)(count, () => this.createObject({
73
80
  types: [
@@ -82,10 +89,9 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
82
89
  constructor(_space, schemaMap, generators, _mutations) {
83
90
  super(schemaMap, generators, async (type) => {
84
91
  const schema = this.getSchema(type);
85
- return (schema && (await this._space.db.query(import_echo2.Filter.type(schema)).run()).objects) ?? [];
86
- });
87
- this._space = _space;
88
- this._mutations = _mutations;
92
+ const { objects } = await this._space.db.query(schema ? import_echo2.Filter.type(schema) : import_echo2.Filter.nothing()).run();
93
+ return objects;
94
+ }), this._space = _space, this._mutations = _mutations;
89
95
  }
90
96
  async addSchemas() {
91
97
  const result = [];
@@ -125,7 +131,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
125
131
  async mutateObject(object, params) {
126
132
  (0, import_invariant.invariant)(this._mutations, "Mutations not defined.", {
127
133
  F: __dxlog_file,
128
- L: 123,
134
+ L: 130,
129
135
  S: this,
130
136
  A: [
131
137
  "this._mutations",
@@ -135,7 +141,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
135
141
  const type = (0, import_echo_schema2.getTypeAnnotation)((0, import_echo_schema2.getSchema)(object)).typename;
136
142
  (0, import_invariant.invariant)(type && this._mutations?.[type], "Invalid object type.", {
137
143
  F: __dxlog_file,
138
- L: 125,
144
+ L: 132,
139
145
  S: this,
140
146
  A: [
141
147
  "type && this._mutations?.[type]",
@@ -171,53 +177,50 @@ var Priority = [
171
177
  4,
172
178
  5
173
179
  ];
174
- var TestSchemaType;
175
- (function(TestSchemaType2) {
176
- TestSchemaType2["document"] = "example.com/type/document";
177
- TestSchemaType2["organization"] = "example.com/type/organization";
178
- TestSchemaType2["contact"] = "example.com/type/contact";
179
- TestSchemaType2["project"] = "example.com/type/project";
180
- })(TestSchemaType || (TestSchemaType = {}));
180
+ var TestSchemaType = /* @__PURE__ */ function(TestSchemaType2) {
181
+ TestSchemaType2["document"] = "example.com/type/Document";
182
+ TestSchemaType2["organization"] = "example.com/type/Organization";
183
+ TestSchemaType2["contact"] = "example.com/type/Contact";
184
+ TestSchemaType2["project"] = "example.com/type/Project";
185
+ return TestSchemaType2;
186
+ }({});
181
187
  var testSchemas = () => {
182
- const document = (0, import_live_object.createEchoSchema)({
183
- typename: "example.com/type/document",
184
- version: "0.1.0"
185
- }, {
188
+ const document = import_effect.Schema.Struct({
186
189
  title: import_effect.Schema.String.annotations({
187
190
  description: "title of the document"
188
191
  }),
189
192
  content: import_effect.Schema.String
190
- });
191
- const organization = (0, import_live_object.createEchoSchema)({
192
- typename: "example.com/type/organization",
193
+ }).pipe((0, import_echo_schema.EchoObject)({
194
+ typename: "example.com/type/Document",
193
195
  version: "0.1.0"
194
- }, {
196
+ }));
197
+ const organization = import_effect.Schema.Struct({
195
198
  name: import_effect.Schema.String.annotations({
196
199
  description: "name of the company or organization"
197
200
  }),
198
- website: import_effect.Schema.String.annotations({
201
+ website: import_effect.Schema.optional(import_effect.Schema.String.annotations({
199
202
  description: "public website URL"
200
- }),
203
+ })),
201
204
  description: import_effect.Schema.String.annotations({
202
205
  description: "short summary of the company"
203
206
  })
204
- });
205
- const contact = (0, import_live_object.createEchoSchema)({
206
- typename: "example.com/type/contact",
207
+ }).pipe((0, import_echo_schema.EchoObject)({
208
+ typename: "example.com/type/Organization",
207
209
  version: "0.1.0"
208
- }, {
210
+ }));
211
+ const contact = import_effect.Schema.Struct({
209
212
  name: import_effect.Schema.String.annotations({
210
213
  description: "name of the person"
211
214
  }),
212
- email: import_effect.Schema.String,
213
- org: (0, import_echo_schema.Ref)(organization),
214
- lat: import_effect.Schema.Number,
215
- lng: import_effect.Schema.Number
216
- });
217
- const project = (0, import_live_object.createEchoSchema)({
218
- typename: "example.com/type/project",
215
+ email: import_effect.Schema.optional(import_effect.Schema.String),
216
+ org: import_effect.Schema.optional((0, import_echo_schema.Ref)(organization)),
217
+ lat: import_effect.Schema.optional(import_effect.Schema.Number),
218
+ lng: import_effect.Schema.optional(import_effect.Schema.Number)
219
+ }).pipe((0, import_echo_schema.EchoObject)({
220
+ typename: "example.com/type/Contact",
219
221
  version: "0.1.0"
220
- }, {
222
+ }));
223
+ const project = import_effect.Schema.Struct({
221
224
  name: import_effect.Schema.String.annotations({
222
225
  description: "name of the project"
223
226
  }),
@@ -227,17 +230,20 @@ var testSchemas = () => {
227
230
  status: import_effect.Schema.String,
228
231
  priority: import_effect.Schema.Number,
229
232
  active: import_effect.Schema.Boolean,
230
- org: (0, import_echo_schema.Ref)(organization)
231
- });
233
+ org: import_effect.Schema.optional((0, import_echo_schema.Ref)(organization))
234
+ }).pipe((0, import_echo_schema.EchoObject)({
235
+ typename: "example.com/type/Project",
236
+ version: "0.1.0"
237
+ }));
232
238
  return {
233
- ["example.com/type/document"]: document,
234
- ["example.com/type/organization"]: organization,
235
- ["example.com/type/contact"]: contact,
236
- ["example.com/type/project"]: project
239
+ ["example.com/type/Document"]: document,
240
+ ["example.com/type/Organization"]: organization,
241
+ ["example.com/type/Contact"]: contact,
242
+ ["example.com/type/Project"]: project
237
243
  };
238
244
  };
239
245
  var testObjectGenerators = {
240
- ["example.com/type/document"]: async () => ({
246
+ ["example.com/type/Document"]: async () => ({
241
247
  title: import_random.faker.lorem.sentence(3),
242
248
  content: import_random.faker.lorem.sentences({
243
249
  min: 1,
@@ -247,39 +253,39 @@ var testObjectGenerators = {
247
253
  })
248
254
  })
249
255
  }),
250
- ["example.com/type/organization"]: async () => ({
256
+ ["example.com/type/Organization"]: async () => ({
251
257
  name: import_random.faker.company.name(),
252
258
  website: import_random.faker.datatype.boolean({
253
259
  probability: 0.3
254
260
  }) ? import_random.faker.internet.url() : void 0,
255
261
  description: import_random.faker.lorem.sentences()
256
262
  }),
257
- ["example.com/type/contact"]: async (provider) => {
258
- const organizations = await provider?.("example.com/type/organization");
259
- const { location } = import_random.faker.datatype.boolean() ? import_random.faker.geo.airport() : {};
263
+ ["example.com/type/Contact"]: async (provider) => {
264
+ const organizations = await provider?.("example.com/type/Organization");
265
+ const location = import_random.faker.datatype.boolean() ? import_random.faker.geo.airport() : {};
260
266
  return {
261
267
  name: import_random.faker.person.fullName(),
262
268
  email: import_random.faker.datatype.boolean({
263
269
  probability: 0.5
264
270
  }) ? import_random.faker.internet.email() : void 0,
265
271
  org: organizations?.length && import_random.faker.datatype.boolean({
266
- probability: 0.3
272
+ probability: 0.8
267
273
  }) ? import_echo_schema.Ref.make(import_random.faker.helpers.arrayElement(organizations)) : void 0,
268
274
  ...location
269
275
  };
270
276
  },
271
- ["example.com/type/project"]: async () => ({
277
+ ["example.com/type/Project"]: async () => ({
272
278
  name: import_random.faker.commerce.productName(),
273
- repo: import_random.faker.datatype.boolean({
274
- probability: 0.3
275
- }) ? import_random.faker.internet.url() : void 0,
279
+ repo: import_random.faker.internet.url(),
276
280
  status: import_random.faker.helpers.arrayElement(Status),
281
+ description: import_random.faker.lorem.sentences(),
282
+ website: import_random.faker.internet.url(),
277
283
  priority: import_random.faker.helpers.arrayElement(Priority),
278
284
  active: import_random.faker.datatype.boolean()
279
285
  })
280
286
  };
281
287
  var testObjectMutators = {
282
- ["example.com/type/document"]: async (object, params) => {
288
+ ["example.com/type/Document"]: async (object, params) => {
283
289
  const accessor = (0, import_echo.createDocAccessor)(object, [
284
290
  "content"
285
291
  ]);
@@ -290,13 +296,13 @@ var testObjectMutators = {
290
296
  });
291
297
  }
292
298
  },
293
- ["example.com/type/organization"]: async () => {
299
+ ["example.com/type/Organization"]: async () => {
294
300
  throw new Error("Method not implemented.");
295
301
  },
296
- ["example.com/type/contact"]: async () => {
302
+ ["example.com/type/Contact"]: async () => {
297
303
  throw new Error("Method not implemented.");
298
304
  },
299
- ["example.com/type/project"]: async () => {
305
+ ["example.com/type/Project"]: async () => {
300
306
  throw new Error("Method not implemented.");
301
307
  }
302
308
  };