@dxos/echo-generator 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

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,16 +3,16 @@ import "@dxos/node-std/globals";
3
3
  // src/data.ts
4
4
  import { next as A } from "@automerge/automerge";
5
5
  import * as Schema from "effect/Schema";
6
- import { createDocAccessor } from "@dxos/client/echo";
7
- import { EchoObject, Ref } from "@dxos/echo/internal";
6
+ import { Ref, Type } from "@dxos/echo";
7
+ import { createDocAccessor } from "@dxos/echo-db";
8
8
  import { faker as faker2 } from "@dxos/random";
9
9
 
10
10
  // src/generator.ts
11
11
  import { Filter } from "@dxos/client/echo";
12
12
  import { Obj } from "@dxos/echo";
13
- import { EchoSchema, getSchema, getTypeAnnotation } from "@dxos/echo/internal";
13
+ import { EchoSchema, getTypeAnnotation } from "@dxos/echo/internal";
14
+ import { isProxy } from "@dxos/echo/internal";
14
15
  import { invariant } from "@dxos/invariant";
15
- import { isLiveObject, live } from "@dxos/live-object";
16
16
  import { faker } from "@dxos/random";
17
17
  import { entries, range } from "@dxos/util";
18
18
  var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
@@ -38,11 +38,20 @@ var TestObjectGenerator = class {
38
38
  async createObject({ types } = {}) {
39
39
  const type = faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
40
40
  const data = await this._generators[type](this._provider);
41
- if (isLiveObject(data)) {
41
+ if (isProxy(data)) {
42
42
  return data;
43
43
  }
44
44
  const schema = this.getSchema(type);
45
- return schema ? Obj.make(schema, data) : live(data);
45
+ invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`, {
46
+ F: __dxlog_file,
47
+ L: 54,
48
+ S: this,
49
+ A: [
50
+ "schema",
51
+ "`Schema is required for type: ${type}. Register a schema for this type.`"
52
+ ]
53
+ });
54
+ return Obj.make(schema, data);
46
55
  }
47
56
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
48
57
  async createObjects(map) {
@@ -70,7 +79,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
70
79
  constructor(_space, schemaMap, generators, _mutations) {
71
80
  super(schemaMap, generators, async (type) => {
72
81
  const schema = this.getSchema(type);
73
- const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
82
+ const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
74
83
  return objects;
75
84
  }), this._space = _space, this._mutations = _mutations;
76
85
  }
@@ -90,20 +99,20 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
90
99
  }
91
100
  async _maybeRegisterSchema(typename, schema) {
92
101
  if (schema instanceof EchoSchema) {
93
- const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
102
+ const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
94
103
  if (existingSchema != null) {
95
104
  return existingSchema;
96
105
  }
97
- const [registeredSchema] = await this._space.db.schemaRegistry.register([
106
+ const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([
98
107
  schema
99
108
  ]);
100
109
  return registeredSchema;
101
110
  } else {
102
- const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
111
+ const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);
103
112
  if (existingSchema != null) {
104
113
  return existingSchema;
105
114
  }
106
- this._space.db.graph.schemaRegistry.addSchema([
115
+ await this._space.internal.db.graph.schemaRegistry.register([
107
116
  schema
108
117
  ]);
109
118
  return schema;
@@ -112,17 +121,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
112
121
  async mutateObject(object, params) {
113
122
  invariant(this._mutations, "Mutations not defined.", {
114
123
  F: __dxlog_file,
115
- L: 131,
124
+ L: 130,
116
125
  S: this,
117
126
  A: [
118
127
  "this._mutations",
119
128
  "'Mutations not defined.'"
120
129
  ]
121
130
  });
122
- const type = getTypeAnnotation(getSchema(object)).typename;
131
+ const type = getTypeAnnotation(Obj.getSchema(object)).typename;
123
132
  invariant(type && this._mutations?.[type], "Invalid object type.", {
124
133
  F: __dxlog_file,
125
- L: 133,
134
+ L: 132,
126
135
  S: this,
127
136
  A: [
128
137
  "type && this._mutations?.[type]",
@@ -165,7 +174,7 @@ var Priority = [
165
174
  var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
166
175
  TestSchemaType2["document"] = "example.com/type/Document";
167
176
  TestSchemaType2["organization"] = "example.com/type/Organization";
168
- TestSchemaType2["contact"] = "example.com/type/Contact";
177
+ TestSchemaType2["contact"] = "example.com/type/Person";
169
178
  TestSchemaType2["project"] = "example.com/type/Project";
170
179
  return TestSchemaType2;
171
180
  })({});
@@ -175,7 +184,7 @@ var testSchemas = () => {
175
184
  description: "title of the document"
176
185
  }),
177
186
  content: Schema.String
178
- }).pipe(EchoObject({
187
+ }).pipe(Type.object({
179
188
  typename: "example.com/type/Document",
180
189
  version: "0.1.0"
181
190
  }));
@@ -189,7 +198,7 @@ var testSchemas = () => {
189
198
  description: Schema.String.annotations({
190
199
  description: "short summary of the company"
191
200
  })
192
- }).pipe(EchoObject({
201
+ }).pipe(Type.object({
193
202
  typename: "example.com/type/Organization",
194
203
  version: "0.1.0"
195
204
  }));
@@ -198,11 +207,11 @@ var testSchemas = () => {
198
207
  description: "name of the person"
199
208
  }),
200
209
  email: Schema.optional(Schema.String),
201
- org: Schema.optional(Ref(organization)),
210
+ org: Schema.optional(Type.Ref(organization)),
202
211
  lat: Schema.optional(Schema.Number),
203
212
  lng: Schema.optional(Schema.Number)
204
- }).pipe(EchoObject({
205
- typename: "example.com/type/Contact",
213
+ }).pipe(Type.object({
214
+ typename: "example.com/type/Person",
206
215
  version: "0.1.0"
207
216
  }));
208
217
  const project = Schema.Struct({
@@ -215,15 +224,15 @@ var testSchemas = () => {
215
224
  status: Schema.String,
216
225
  priority: Schema.Number,
217
226
  active: Schema.Boolean,
218
- org: Schema.optional(Ref(organization))
219
- }).pipe(EchoObject({
227
+ org: Schema.optional(Type.Ref(organization))
228
+ }).pipe(Type.object({
220
229
  typename: "example.com/type/Project",
221
230
  version: "0.1.0"
222
231
  }));
223
232
  return {
224
233
  ["example.com/type/Document"]: document,
225
234
  ["example.com/type/Organization"]: organization,
226
- ["example.com/type/Contact"]: contact,
235
+ ["example.com/type/Person"]: contact,
227
236
  ["example.com/type/Project"]: project
228
237
  };
229
238
  };
@@ -245,7 +254,7 @@ var testObjectGenerators = {
245
254
  }) ? faker2.internet.url() : void 0,
246
255
  description: faker2.lorem.sentences()
247
256
  }),
248
- ["example.com/type/Contact"]: async (provider) => {
257
+ ["example.com/type/Person"]: async (provider) => {
249
258
  const organizations = await provider?.("example.com/type/Organization");
250
259
  const location = faker2.datatype.boolean() ? faker2.geo.airport() : {};
251
260
  return {
@@ -284,7 +293,7 @@ var testObjectMutators = {
284
293
  ["example.com/type/Organization"]: async () => {
285
294
  throw new Error("Method not implemented.");
286
295
  },
287
- ["example.com/type/Contact"]: async () => {
296
+ ["example.com/type/Person"]: async () => {
288
297
  throw new Error("Method not implemented.");
289
298
  },
290
299
  ["example.com/type/Project"]: async () => {
@@ -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 * as Schema from 'effect/Schema';\n\nimport { type Space, createDocAccessor } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo/internal';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { type Live, isLiveObject, live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? Obj.make(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![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": ";;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,QAAO;EAChC;AACF;AAEA,IAAMkB,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOC,QAAQC,WAAAA;AACxC,UAAMC,WAAWC,kBAAkBH,QAAQ;MAAC;KAAU;AACtD,aAASI,IAAI,GAAGA,IAAIH,OAAOI,OAAOD,KAAK;AACrC,YAAMX,SAASO,OAAOpD,SAASA,SAAS6C,UAAU;AAClDS,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe6B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe6B,sBAAsB6B,kBAAAA;",
6
- "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "Obj", "EchoSchema", "getSchema", "getTypeAnnotation", "invariant", "isLiveObject", "live", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "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"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { Ref, Type } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Person',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(Type.object({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(Type.object({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Type.Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(Type.object({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Type.Ref(organization)),\n }).pipe(Type.object({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj, type Type } from '@dxos/echo';\nimport { EchoSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { isProxy } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderProps,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n\t\tprotected readonly _schemas: TestSchemaMap<T>,\n\t\tprivate readonly _generators: TestGeneratorMap<T>,\n\t\tprivate readonly _provider?: TestObjectProvider<T>,\n\t) {}\n\n get schemas(): Type.Obj.Any[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): Type.Obj.Any | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: Type.Obj.Any): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isProxy(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);\n return Obj.make(schema, data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: any[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: Type.Obj.Any[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.Obj.Any);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({\n types,\n }: {\n types?: T[];\n } = {}): Promise<Obj.Any> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(typename: string, schema: Type.Obj.Any): Promise<Type.Obj.Any> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n await this._space.internal.db.graph.schemaRegistry.register([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(Obj.getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: Obj.Any[], params: MutationsProviderProps): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAGxB,SAASC,KAAKC,YAAY;AAC1B,SAASC,yBAAyB;AAClC,SAASC,SAAAA,cAAa;;;ACNtB,SAASC,cAA0B;AACnC,SAASC,WAAsB;AAC/B,SAASC,YAAYC,yBAAyB;AAC9C,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;;;;EAEX,YACmBC,UAC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S8C,UAAU;AAClDQ,eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBnB,SAAS,IAAIO,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,yBAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
6
+ "names": ["next", "A", "Schema", "Ref", "Type", "createDocAccessor", "faker", "Filter", "Obj", "EchoSchema", "getTypeAnnotation", "isProxy", "invariant", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "internal", "schemaRegistry", "registeredSchema", "register", "graph", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "Type", "object", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/generator.ts":{"bytes":16771,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19489,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18884},"dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4823},"src/generator.ts":{"bytesInOutput":4051},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9481}}}
1
+ {"inputs":{"src/generator.ts":{"bytes":16828,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19599,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18711},"dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4813},"src/generator.ts":{"bytesInOutput":4322},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9742}}}
@@ -3,16 +3,16 @@ import { createRequire } from 'node:module';const require = createRequire(import
3
3
  // src/data.ts
4
4
  import { next as A } from "@automerge/automerge";
5
5
  import * as Schema from "effect/Schema";
6
- import { createDocAccessor } from "@dxos/client/echo";
7
- import { EchoObject, Ref } from "@dxos/echo/internal";
6
+ import { Ref, Type } from "@dxos/echo";
7
+ import { createDocAccessor } from "@dxos/echo-db";
8
8
  import { faker as faker2 } from "@dxos/random";
9
9
 
10
10
  // src/generator.ts
11
11
  import { Filter } from "@dxos/client/echo";
12
12
  import { Obj } from "@dxos/echo";
13
- import { EchoSchema, getSchema, getTypeAnnotation } from "@dxos/echo/internal";
13
+ import { EchoSchema, getTypeAnnotation } from "@dxos/echo/internal";
14
+ import { isProxy } from "@dxos/echo/internal";
14
15
  import { invariant } from "@dxos/invariant";
15
- import { isLiveObject, live } from "@dxos/live-object";
16
16
  import { faker } from "@dxos/random";
17
17
  import { entries, range } from "@dxos/util";
18
18
  var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
@@ -38,11 +38,20 @@ var TestObjectGenerator = class {
38
38
  async createObject({ types } = {}) {
39
39
  const type = faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
40
40
  const data = await this._generators[type](this._provider);
41
- if (isLiveObject(data)) {
41
+ if (isProxy(data)) {
42
42
  return data;
43
43
  }
44
44
  const schema = this.getSchema(type);
45
- return schema ? Obj.make(schema, data) : live(data);
45
+ invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`, {
46
+ F: __dxlog_file,
47
+ L: 54,
48
+ S: this,
49
+ A: [
50
+ "schema",
51
+ "`Schema is required for type: ${type}. Register a schema for this type.`"
52
+ ]
53
+ });
54
+ return Obj.make(schema, data);
46
55
  }
47
56
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
48
57
  async createObjects(map) {
@@ -70,7 +79,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
70
79
  constructor(_space, schemaMap, generators, _mutations) {
71
80
  super(schemaMap, generators, async (type) => {
72
81
  const schema = this.getSchema(type);
73
- const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
82
+ const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
74
83
  return objects;
75
84
  }), this._space = _space, this._mutations = _mutations;
76
85
  }
@@ -90,20 +99,20 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
90
99
  }
91
100
  async _maybeRegisterSchema(typename, schema) {
92
101
  if (schema instanceof EchoSchema) {
93
- const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
102
+ const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
94
103
  if (existingSchema != null) {
95
104
  return existingSchema;
96
105
  }
97
- const [registeredSchema] = await this._space.db.schemaRegistry.register([
106
+ const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([
98
107
  schema
99
108
  ]);
100
109
  return registeredSchema;
101
110
  } else {
102
- const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
111
+ const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);
103
112
  if (existingSchema != null) {
104
113
  return existingSchema;
105
114
  }
106
- this._space.db.graph.schemaRegistry.addSchema([
115
+ await this._space.internal.db.graph.schemaRegistry.register([
107
116
  schema
108
117
  ]);
109
118
  return schema;
@@ -112,17 +121,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
112
121
  async mutateObject(object, params) {
113
122
  invariant(this._mutations, "Mutations not defined.", {
114
123
  F: __dxlog_file,
115
- L: 131,
124
+ L: 130,
116
125
  S: this,
117
126
  A: [
118
127
  "this._mutations",
119
128
  "'Mutations not defined.'"
120
129
  ]
121
130
  });
122
- const type = getTypeAnnotation(getSchema(object)).typename;
131
+ const type = getTypeAnnotation(Obj.getSchema(object)).typename;
123
132
  invariant(type && this._mutations?.[type], "Invalid object type.", {
124
133
  F: __dxlog_file,
125
- L: 133,
134
+ L: 132,
126
135
  S: this,
127
136
  A: [
128
137
  "type && this._mutations?.[type]",
@@ -165,7 +174,7 @@ var Priority = [
165
174
  var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
166
175
  TestSchemaType2["document"] = "example.com/type/Document";
167
176
  TestSchemaType2["organization"] = "example.com/type/Organization";
168
- TestSchemaType2["contact"] = "example.com/type/Contact";
177
+ TestSchemaType2["contact"] = "example.com/type/Person";
169
178
  TestSchemaType2["project"] = "example.com/type/Project";
170
179
  return TestSchemaType2;
171
180
  })({});
@@ -175,7 +184,7 @@ var testSchemas = () => {
175
184
  description: "title of the document"
176
185
  }),
177
186
  content: Schema.String
178
- }).pipe(EchoObject({
187
+ }).pipe(Type.object({
179
188
  typename: "example.com/type/Document",
180
189
  version: "0.1.0"
181
190
  }));
@@ -189,7 +198,7 @@ var testSchemas = () => {
189
198
  description: Schema.String.annotations({
190
199
  description: "short summary of the company"
191
200
  })
192
- }).pipe(EchoObject({
201
+ }).pipe(Type.object({
193
202
  typename: "example.com/type/Organization",
194
203
  version: "0.1.0"
195
204
  }));
@@ -198,11 +207,11 @@ var testSchemas = () => {
198
207
  description: "name of the person"
199
208
  }),
200
209
  email: Schema.optional(Schema.String),
201
- org: Schema.optional(Ref(organization)),
210
+ org: Schema.optional(Type.Ref(organization)),
202
211
  lat: Schema.optional(Schema.Number),
203
212
  lng: Schema.optional(Schema.Number)
204
- }).pipe(EchoObject({
205
- typename: "example.com/type/Contact",
213
+ }).pipe(Type.object({
214
+ typename: "example.com/type/Person",
206
215
  version: "0.1.0"
207
216
  }));
208
217
  const project = Schema.Struct({
@@ -215,15 +224,15 @@ var testSchemas = () => {
215
224
  status: Schema.String,
216
225
  priority: Schema.Number,
217
226
  active: Schema.Boolean,
218
- org: Schema.optional(Ref(organization))
219
- }).pipe(EchoObject({
227
+ org: Schema.optional(Type.Ref(organization))
228
+ }).pipe(Type.object({
220
229
  typename: "example.com/type/Project",
221
230
  version: "0.1.0"
222
231
  }));
223
232
  return {
224
233
  ["example.com/type/Document"]: document,
225
234
  ["example.com/type/Organization"]: organization,
226
- ["example.com/type/Contact"]: contact,
235
+ ["example.com/type/Person"]: contact,
227
236
  ["example.com/type/Project"]: project
228
237
  };
229
238
  };
@@ -245,7 +254,7 @@ var testObjectGenerators = {
245
254
  }) ? faker2.internet.url() : void 0,
246
255
  description: faker2.lorem.sentences()
247
256
  }),
248
- ["example.com/type/Contact"]: async (provider) => {
257
+ ["example.com/type/Person"]: async (provider) => {
249
258
  const organizations = await provider?.("example.com/type/Organization");
250
259
  const location = faker2.datatype.boolean() ? faker2.geo.airport() : {};
251
260
  return {
@@ -284,7 +293,7 @@ var testObjectMutators = {
284
293
  ["example.com/type/Organization"]: async () => {
285
294
  throw new Error("Method not implemented.");
286
295
  },
287
- ["example.com/type/Contact"]: async () => {
296
+ ["example.com/type/Person"]: async () => {
288
297
  throw new Error("Method not implemented.");
289
298
  },
290
299
  ["example.com/type/Project"]: async () => {
@@ -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 * as Schema from 'effect/Schema';\n\nimport { type Space, createDocAccessor } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo/internal';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { type Live, isLiveObject, live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? Obj.make(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![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,YAAYC,YAAY;AAExB,SAAqBC,yBAAyB;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AACnC,SAASC,WAAW;AACpB,SAASC,YAAYC,WAAWC,yBAAyB;AAEzD,SAASC,iBAAiB;AAC1B,SAAoBC,cAAcC,YAAY;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;;;;EAEX,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAT,UAAUe,MAA8D;AACtE,WAAO,KAAKH,QAAQI,KAAK,CAACC,WAAWhB,kBAAkBgB,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAuD;AAClF,SAAKR,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AM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe6B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe6B,sBAAsB6B,kBAAAA;",
6
- "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "Obj", "EchoSchema", "getSchema", "getTypeAnnotation", "invariant", "isLiveObject", "live", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "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"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { Ref, Type } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Person',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(Type.object({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(Type.object({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Type.Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(Type.object({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Type.Ref(organization)),\n }).pipe(Type.object({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { Obj, type Type } from '@dxos/echo';\nimport { EchoSchema, getTypeAnnotation } from '@dxos/echo/internal';\nimport { isProxy } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderProps,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n\t\tprotected readonly _schemas: TestSchemaMap<T>,\n\t\tprivate readonly _generators: TestGeneratorMap<T>,\n\t\tprivate readonly _provider?: TestObjectProvider<T>,\n\t) {}\n\n get schemas(): Type.Obj.Any[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): Type.Obj.Any | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: Type.Obj.Any): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isProxy(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);\n return Obj.make(schema, data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: any[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: Type.Obj.Any[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.Obj.Any);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({\n types,\n }: {\n types?: T[];\n } = {}): Promise<Obj.Any> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(typename: string, schema: Type.Obj.Any): Promise<Type.Obj.Any> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n await this._space.internal.db.graph.schemaRegistry.register([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(Obj.getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: Obj.Any[], params: MutationsProviderProps): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAGxB,SAASC,KAAKC,YAAY;AAC1B,SAASC,yBAAyB;AAClC,SAASC,SAAAA,cAAa;;;ACNtB,SAASC,cAA0B;AACnC,SAASC,WAAsB;AAC/B,SAASC,YAAYC,yBAAyB;AAC9C,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;;;;EAEX,YACmBC,UACFC,aACAC,WAChB;SAHkBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EACf;EAEF,IAAIC,UAA0B;AAC5B,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAmC;AAC3C,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWhB,kBAAkBgB,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAA4B;AACvD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiB;AAChE,UAAMN,OAAOX,MAAMkB,QAAQC,aAAaF,SAAUT,OAAOY,KAAK,KAAKhB,QAAQ,CAAA;AAC3E,UAAMiB,OAAO,MAAM,KAAKhB,YAAYM,IAAAA,EAAM,KAAKL,SAAS;AACxD,QAAIR,QAAQuB,IAAAA,GAAO;AACjB,aAAOA;IACT;AAEA,UAAMR,SAAS,KAAKH,UAAUC,IAAAA;AAC9BZ,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ccessor", "faker", "Filter", "Obj", "EchoSchema", "getTypeAnnotation", "isProxy", "invariant", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "make", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "internal", "schemaRegistry", "registeredSchema", "register", "graph", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "Type", "object", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }