@dxos/echo-generator 0.8.2-main.5885341 → 0.8.2-main.600d381

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.
@@ -1,16 +1,16 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/core/echo/echo-generator/src/data.ts
4
+ import { Schema } from "effect";
4
5
  import { next as A } from "@dxos/automerge/automerge";
5
6
  import { createDocAccessor } from "@dxos/client/echo";
6
- import { Ref, S } from "@dxos/echo-schema";
7
+ import { Ref } from "@dxos/echo-schema";
7
8
  import { createEchoSchema } from "@dxos/live-object";
8
9
  import { faker as faker2 } from "@dxos/random";
9
10
 
10
11
  // packages/core/echo/echo-generator/src/generator.ts
11
12
  import { Filter } from "@dxos/client/echo";
12
- import { getTypeAnnotation, EchoSchema } from "@dxos/echo-schema";
13
- import { getSchema } from "@dxos/echo-schema";
13
+ import { getTypeAnnotation, EchoSchema, getSchema } from "@dxos/echo-schema";
14
14
  import { invariant } from "@dxos/invariant";
15
15
  import { live, isLiveObject } from "@dxos/live-object";
16
16
  import { faker } from "@dxos/random";
@@ -100,7 +100,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
100
100
  async mutateObject(object, params) {
101
101
  invariant(this._mutations, "Mutations not defined.", {
102
102
  F: __dxlog_file,
103
- L: 122,
103
+ L: 123,
104
104
  S: this,
105
105
  A: [
106
106
  "this._mutations",
@@ -110,7 +110,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
110
110
  const type = getTypeAnnotation(getSchema(object)).typename;
111
111
  invariant(type && this._mutations?.[type], "Invalid object type.", {
112
112
  F: __dxlog_file,
113
- L: 124,
113
+ L: 125,
114
114
  S: this,
115
115
  A: [
116
116
  "type && this._mutations?.[type]",
@@ -162,22 +162,22 @@ var testSchemas = () => {
162
162
  typename: "example.com/type/document",
163
163
  version: "0.1.0"
164
164
  }, {
165
- title: S.String.annotations({
165
+ title: Schema.String.annotations({
166
166
  description: "title of the document"
167
167
  }),
168
- content: S.String
168
+ content: Schema.String
169
169
  });
170
170
  const organization = createEchoSchema({
171
171
  typename: "example.com/type/organization",
172
172
  version: "0.1.0"
173
173
  }, {
174
- name: S.String.annotations({
174
+ name: Schema.String.annotations({
175
175
  description: "name of the company or organization"
176
176
  }),
177
- website: S.String.annotations({
177
+ website: Schema.String.annotations({
178
178
  description: "public website URL"
179
179
  }),
180
- description: S.String.annotations({
180
+ description: Schema.String.annotations({
181
181
  description: "short summary of the company"
182
182
  })
183
183
  });
@@ -185,27 +185,27 @@ var testSchemas = () => {
185
185
  typename: "example.com/type/contact",
186
186
  version: "0.1.0"
187
187
  }, {
188
- name: S.String.annotations({
188
+ name: Schema.String.annotations({
189
189
  description: "name of the person"
190
190
  }),
191
- email: S.String,
191
+ email: Schema.String,
192
192
  org: Ref(organization),
193
- lat: S.Number,
194
- lng: S.Number
193
+ lat: Schema.Number,
194
+ lng: Schema.Number
195
195
  });
196
196
  const project = createEchoSchema({
197
197
  typename: "example.com/type/project",
198
198
  version: "0.1.0"
199
199
  }, {
200
- name: S.String.annotations({
200
+ name: Schema.String.annotations({
201
201
  description: "name of the project"
202
202
  }),
203
- description: S.String,
204
- website: S.String,
205
- repo: S.String,
206
- status: S.String,
207
- priority: S.Number,
208
- active: S.Boolean,
203
+ description: Schema.String,
204
+ website: Schema.String,
205
+ repo: Schema.String,
206
+ status: Schema.String,
207
+ priority: Schema.Number,
208
+ active: Schema.Boolean,
209
209
  org: Ref(organization)
210
210
  });
211
211
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { Ref, S } 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: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createEchoSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createEchoSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: Ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createEchoSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the project' }),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: Ref(organization),\n },\n );\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const { location } = faker.datatype.boolean() ? faker.geo.airport() : {};\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? 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 { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, type S } from '@dxos/echo-schema';\nimport { 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 | S.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | S.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | S.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.schema(schema)).run()).objects) ?? [];\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | S.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | S.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<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | S.Schema.AnyNoContext,\n ): Promise<EchoSchema | S.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: ReactiveEchoObject<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: ReactiveEchoObject<any>[], params: MutationsProviderParams) {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,yBAAqC;AAC9C,SAASC,KAAKC,SAAS;A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,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", "createDocAccessor", "Ref", "S", "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", "S", "String", "annotations", "description", "content", "organization", "name", "website", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "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 { Schema } from 'effect';\n\nimport { next as A } from '@dxos/automerge/automerge';\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.schema(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,cAAc;AAEvB,SAASC,QAAQC,SAAS;AAC1B,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,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAuB;AACtE,UAAMN,OAAOV,MAAMiB,QAAQC,aAAaF,SAAUR,OAAOW,KAAK,KAAKf,QAAQ,CAAA;AAC3E,UAAMgB,OAAO,MAAM,KAAKf,YAAYK,IAAAA,EAAM,KAAKJ,SAAS;AACxD,QAAIP,aAAaqB,IAAAA,GAAO;AACtB,aAAOA;IACT;AAEA,UAAMR,SAAS,KAAKhB,UAAUc,IAAAA;AAC9B,WAAOE,SAASd,KAAKc,QAAQQ,IAAAA,IAAQtB,KAAKsB,IAAAA;EAC5C;;EA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AASwC,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": ["Schema", "next", "A", "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"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15821,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/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":18582,"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1705,"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":17891},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4578},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3745},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9066}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15773,"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":18896,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":18027},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4688},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3709},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9140}}}
@@ -28,6 +28,7 @@ __export(node_exports, {
28
28
  randomText: () => randomText
29
29
  });
30
30
  module.exports = __toCommonJS(node_exports);
31
+ var import_effect = require("effect");
31
32
  var import_automerge = require("@dxos/automerge/automerge");
32
33
  var import_echo = require("@dxos/client/echo");
33
34
  var import_echo_schema = require("@dxos/echo-schema");
@@ -35,7 +36,6 @@ var import_live_object = require("@dxos/live-object");
35
36
  var import_random = require("@dxos/random");
36
37
  var import_echo2 = require("@dxos/client/echo");
37
38
  var import_echo_schema2 = require("@dxos/echo-schema");
38
- var import_echo_schema3 = require("@dxos/echo-schema");
39
39
  var import_invariant = require("@dxos/invariant");
40
40
  var import_live_object2 = require("@dxos/live-object");
41
41
  var import_random2 = require("@dxos/random");
@@ -125,17 +125,17 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
125
125
  async mutateObject(object, params) {
126
126
  (0, import_invariant.invariant)(this._mutations, "Mutations not defined.", {
127
127
  F: __dxlog_file,
128
- L: 122,
128
+ L: 123,
129
129
  S: this,
130
130
  A: [
131
131
  "this._mutations",
132
132
  "'Mutations not defined.'"
133
133
  ]
134
134
  });
135
- const type = (0, import_echo_schema2.getTypeAnnotation)((0, import_echo_schema3.getSchema)(object)).typename;
135
+ const type = (0, import_echo_schema2.getTypeAnnotation)((0, import_echo_schema2.getSchema)(object)).typename;
136
136
  (0, import_invariant.invariant)(type && this._mutations?.[type], "Invalid object type.", {
137
137
  F: __dxlog_file,
138
- L: 124,
138
+ L: 125,
139
139
  S: this,
140
140
  A: [
141
141
  "type && this._mutations?.[type]",
@@ -183,22 +183,22 @@ var testSchemas = () => {
183
183
  typename: "example.com/type/document",
184
184
  version: "0.1.0"
185
185
  }, {
186
- title: import_echo_schema.S.String.annotations({
186
+ title: import_effect.Schema.String.annotations({
187
187
  description: "title of the document"
188
188
  }),
189
- content: import_echo_schema.S.String
189
+ content: import_effect.Schema.String
190
190
  });
191
191
  const organization = (0, import_live_object.createEchoSchema)({
192
192
  typename: "example.com/type/organization",
193
193
  version: "0.1.0"
194
194
  }, {
195
- name: import_echo_schema.S.String.annotations({
195
+ name: import_effect.Schema.String.annotations({
196
196
  description: "name of the company or organization"
197
197
  }),
198
- website: import_echo_schema.S.String.annotations({
198
+ website: import_effect.Schema.String.annotations({
199
199
  description: "public website URL"
200
200
  }),
201
- description: import_echo_schema.S.String.annotations({
201
+ description: import_effect.Schema.String.annotations({
202
202
  description: "short summary of the company"
203
203
  })
204
204
  });
@@ -206,27 +206,27 @@ var testSchemas = () => {
206
206
  typename: "example.com/type/contact",
207
207
  version: "0.1.0"
208
208
  }, {
209
- name: import_echo_schema.S.String.annotations({
209
+ name: import_effect.Schema.String.annotations({
210
210
  description: "name of the person"
211
211
  }),
212
- email: import_echo_schema.S.String,
212
+ email: import_effect.Schema.String,
213
213
  org: (0, import_echo_schema.Ref)(organization),
214
- lat: import_echo_schema.S.Number,
215
- lng: import_echo_schema.S.Number
214
+ lat: import_effect.Schema.Number,
215
+ lng: import_effect.Schema.Number
216
216
  });
217
217
  const project = (0, import_live_object.createEchoSchema)({
218
218
  typename: "example.com/type/project",
219
219
  version: "0.1.0"
220
220
  }, {
221
- name: import_echo_schema.S.String.annotations({
221
+ name: import_effect.Schema.String.annotations({
222
222
  description: "name of the project"
223
223
  }),
224
- description: import_echo_schema.S.String,
225
- website: import_echo_schema.S.String,
226
- repo: import_echo_schema.S.String,
227
- status: import_echo_schema.S.String,
228
- priority: import_echo_schema.S.Number,
229
- active: import_echo_schema.S.Boolean,
224
+ description: import_effect.Schema.String,
225
+ website: import_effect.Schema.String,
226
+ repo: import_effect.Schema.String,
227
+ status: import_effect.Schema.String,
228
+ priority: import_effect.Schema.Number,
229
+ active: import_effect.Schema.Boolean,
230
230
  org: (0, import_echo_schema.Ref)(organization)
231
231
  });
232
232
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { Ref, S } 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: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createEchoSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createEchoSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: Ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createEchoSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the project' }),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: Ref(organization),\n },\n );\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const { location } = faker.datatype.boolean() ? faker.geo.airport() : {};\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? 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 { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, type S } from '@dxos/echo-schema';\nimport { 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 | S.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | S.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | S.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.schema(schema)).run()).objects) ?? [];\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | S.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | S.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<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | S.Schema.AnyNoContext,\n ): Promise<EchoSchema | S.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: ReactiveEchoObject<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: ReactiveEchoObject<any>[], params: MutationsProviderParams) {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAA0B;AAC1B,kBAA8C;AAC9C,yBAAuB;AACvB,yBAAiC;AACjC,oBAAsB;ACJtB,IAAAA,eAAmC;AAEnC,IAAAC,sBAAsD;AACtD,IAAAA,sBAA0B;AAC1B,uBAA0B;AAC1B,IAAAC,sBAA8C;AAC9C,IAAAC,iBAAsB;AACtB,kBAAsB;;AAcf,IAAMC,sBAAN,MAAMA;;EAEXC,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAAkD;AACpD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAyD;AACjE,WAAO,KAAKJ,QAAQK,KAAK,CAACC,eAAWC,uCAAkBD,MAAAA,EAASE,aAAaJ,IAAAA;EAC/E;EAEUK,UAAUL,MAASE,QAA4C;AACvE,SAAKT,SAASO,IAAAA,IAAQE;EACxB;EAEA,MAAMI,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAuB;AACtE,UAAMP,OAAOQ,qBAAMC,QAAQC,aAAaH,SAAUV,OAAOc,KAAK,KAAKlB,QAAQ,CAAA;AAC3E,UAAMmB,OAAO,MAAM,KAAKlB,YAAYM,IAAAA,EAAM,KAAKL,SAAS;AACxD,YAAIkB,kCAAaD,IAAAA,GAAO;AACtB,aAAOA;IACT;A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,aAAaoD,MAAAA;IACnC0B,UAAUhF,cAAAA,MAAMC,QAAQC,aAAaqD,QAAAA;IACrC0B,QAAQjF,cAAAA,MAAM4F,SAASC,QAAO;EAChC;AACF;AAEA,IAAMe,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOnE,QAAQC,WAAAA;AACxC,UAAMmE,eAAWC,+BAAkBrE,QAAQ;MAAC;KAAU;AACtD,aAASsE,IAAI,GAAGA,IAAIrE,OAAO/B,OAAOoG,KAAK;AACrC,YAAMjE,SAASL,OAAOyB,SAASA,SAASpB,UAAU;AAClD+D,eAASG,OAAOC,OAAO,CAACC,QAAAA;AACtBC,yBAAAA,KAAEC,OACAF,KACAL,SAASQ,KAAKC,MAAK,GACnB,GACA5E,OAAO6E,oBAAoBzE,SAAS,IAAIJ,OAAO8E,cAC/C3E,WAAWH,OAAO8E,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIC,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAEO,IAAMC,4BAA4B,MAAM,IAAI3I,oBAAoB0E,YAAAA,GAAe0B,oBAAAA;AAE/E,IAAMwC,6BAA6B,CAACC,UACzC,IAAI3G,qBAAqB2G,OAAOnE,YAAAA,GAAe0B,sBAAsByB,kBAAAA;",
6
- "names": ["import_echo", "import_echo_schema", "import_live_object", "import_random", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getTypeAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isLiveObject", "live", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "Filter", "run", "objects", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "push", "add", "EchoSchema", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "randomText", "length", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createEchoSchema", "version", "title", "S", "String", "annotations", "description", "content", "organization", "name", "website", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "make", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "i", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { next as A } from '@dxos/automerge/automerge';\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.schema(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,oBAAuB;AAEvB,uBAA0B;AAC1B,kBAA8C;AAC9C,yBAAoB;AACpB,yBAAiC;AACjC,oBAAsB;ACJtB,IAAAA,eAAmC;AAEnC,IAAAC,sBAAyD;AACzD,uBAA0B;AAC1B,IAAAC,sBAA8C;AAC9C,IAAAC,iBAAsB;AACtB,kBAAsB;;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;EAEAM,UAAUC,MAA8D;AACtE,WAAO,KAAKJ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AoB0E,YAAAA,GAAe0B,oBAAAA;AAE/E,IAAMwC,6BAA6B,CAACC,UACzC,IAAI3G,qBAAqB2G,OAAOnE,YAAAA,GAAe0B,sBAAsByB,kBAAAA;",
6
+ "names": ["import_echo", "import_echo_schema", "import_live_object", "import_random", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getTypeAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isLiveObject", "live", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "db", "query", "Filter", "run", "objects", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "push", "add", "EchoSchema", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "randomText", "length", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "createEchoSchema", "version", "title", "Schema", "String", "annotations", "description", "content", "organization", "name", "website", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "make", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "i", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15821,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/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":18582,"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1705,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":751,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17889},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4578},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3745},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9032}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15773,"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":18896,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18025},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4688},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3709},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9106}}}
@@ -1,16 +1,16 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // packages/core/echo/echo-generator/src/data.ts
4
+ import { Schema } from "effect";
4
5
  import { next as A } from "@dxos/automerge/automerge";
5
6
  import { createDocAccessor } from "@dxos/client/echo";
6
- import { Ref, S } from "@dxos/echo-schema";
7
+ import { Ref } from "@dxos/echo-schema";
7
8
  import { createEchoSchema } from "@dxos/live-object";
8
9
  import { faker as faker2 } from "@dxos/random";
9
10
 
10
11
  // packages/core/echo/echo-generator/src/generator.ts
11
12
  import { Filter } from "@dxos/client/echo";
12
- import { getTypeAnnotation, EchoSchema } from "@dxos/echo-schema";
13
- import { getSchema } from "@dxos/echo-schema";
13
+ import { getTypeAnnotation, EchoSchema, getSchema } from "@dxos/echo-schema";
14
14
  import { invariant } from "@dxos/invariant";
15
15
  import { live, isLiveObject } from "@dxos/live-object";
16
16
  import { faker } from "@dxos/random";
@@ -100,7 +100,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
100
100
  async mutateObject(object, params) {
101
101
  invariant(this._mutations, "Mutations not defined.", {
102
102
  F: __dxlog_file,
103
- L: 122,
103
+ L: 123,
104
104
  S: this,
105
105
  A: [
106
106
  "this._mutations",
@@ -110,7 +110,7 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
110
110
  const type = getTypeAnnotation(getSchema(object)).typename;
111
111
  invariant(type && this._mutations?.[type], "Invalid object type.", {
112
112
  F: __dxlog_file,
113
- L: 124,
113
+ L: 125,
114
114
  S: this,
115
115
  A: [
116
116
  "type && this._mutations?.[type]",
@@ -162,22 +162,22 @@ var testSchemas = () => {
162
162
  typename: "example.com/type/document",
163
163
  version: "0.1.0"
164
164
  }, {
165
- title: S.String.annotations({
165
+ title: Schema.String.annotations({
166
166
  description: "title of the document"
167
167
  }),
168
- content: S.String
168
+ content: Schema.String
169
169
  });
170
170
  const organization = createEchoSchema({
171
171
  typename: "example.com/type/organization",
172
172
  version: "0.1.0"
173
173
  }, {
174
- name: S.String.annotations({
174
+ name: Schema.String.annotations({
175
175
  description: "name of the company or organization"
176
176
  }),
177
- website: S.String.annotations({
177
+ website: Schema.String.annotations({
178
178
  description: "public website URL"
179
179
  }),
180
- description: S.String.annotations({
180
+ description: Schema.String.annotations({
181
181
  description: "short summary of the company"
182
182
  })
183
183
  });
@@ -185,27 +185,27 @@ var testSchemas = () => {
185
185
  typename: "example.com/type/contact",
186
186
  version: "0.1.0"
187
187
  }, {
188
- name: S.String.annotations({
188
+ name: Schema.String.annotations({
189
189
  description: "name of the person"
190
190
  }),
191
- email: S.String,
191
+ email: Schema.String,
192
192
  org: Ref(organization),
193
- lat: S.Number,
194
- lng: S.Number
193
+ lat: Schema.Number,
194
+ lng: Schema.Number
195
195
  });
196
196
  const project = createEchoSchema({
197
197
  typename: "example.com/type/project",
198
198
  version: "0.1.0"
199
199
  }, {
200
- name: S.String.annotations({
200
+ name: Schema.String.annotations({
201
201
  description: "name of the project"
202
202
  }),
203
- description: S.String,
204
- website: S.String,
205
- repo: S.String,
206
- status: S.String,
207
- priority: S.Number,
208
- active: S.Boolean,
203
+ description: Schema.String,
204
+ website: Schema.String,
205
+ repo: Schema.String,
206
+ status: Schema.String,
207
+ priority: Schema.Number,
208
+ active: Schema.Boolean,
209
209
  org: Ref(organization)
210
210
  });
211
211
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@dxos/automerge/automerge';\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { Ref, S } 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: S.String.annotations({ description: 'title of the document' }),\n content: S.String,\n },\n );\n\n const organization = createEchoSchema(\n {\n typename: TestSchemaType.organization,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the company or organization' }),\n website: S.String.annotations({ description: 'public website URL' }),\n description: S.String.annotations({ description: 'short summary of the company' }),\n },\n );\n\n const contact = createEchoSchema(\n {\n typename: TestSchemaType.contact,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the person' }),\n email: S.String,\n org: Ref(organization),\n lat: S.Number,\n lng: S.Number,\n },\n );\n\n const project = createEchoSchema(\n {\n typename: TestSchemaType.project,\n version: '0.1.0',\n },\n {\n name: S.String.annotations({ description: 'name of the project' }),\n description: S.String,\n website: S.String,\n repo: S.String,\n status: S.String,\n priority: S.Number,\n active: S.Boolean,\n org: Ref(organization),\n },\n );\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const { location } = faker.datatype.boolean() ? faker.geo.airport() : {};\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? 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 { Filter, type Space } from '@dxos/client/echo';\nimport { type ReactiveEchoObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, type S } from '@dxos/echo-schema';\nimport { 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 | S.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | S.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | S.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.schema(schema)).run()).objects) ?? [];\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | S.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | S.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<ReactiveEchoObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | S.Schema.AnyNoContext,\n ): Promise<EchoSchema | S.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: ReactiveEchoObject<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: ReactiveEchoObject<any>[], params: MutationsProviderParams) {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,yBAAqC;AAC9C,SAASC,KAAKC,SAAS;AACvB,SAASC,wBAAwB;AACjC,SAASC,SAAAA,cAAa;;;ACJtB,SAASC,cAA0B;AAEnC,SAASC,mBAAmBC,kBAA0B;AACtD,SAASC,iBAAiB;AAC1B,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,UAAkD;AACpD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAR,UAAUc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AAA,IACpCF;MACN,GAAGG;IACL;EACF;EAEA,CAAA,0BAAA,GAA0B,aAAa;IACrCjC,MAAMgB,OAAM0B,SAASC,YAAW;IAChCjC,MAAMM,OAAMS,SAASC,QAAQ;MAAEC,aAAa;IAAI,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", "createDocAccessor", "Ref", "S", "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", "S", "String", "annotations", "description", "content", "organization", "name", "website", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "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 { Schema } from 'effect';\n\nimport { next as A } from '@dxos/automerge/automerge';\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.schema(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,cAAc;AAEvB,SAASC,QAAQC,SAAS;AAC1B,SAASC,yBAAqC;AAC9C,SAASC,WAAW;AACpB,SAASC,wBAAwB;AACjC,SAASC,SAAAA,cAAa;;;ACJtB,SAASC,cAA0B;AAEnC,SAASC,mBAAmBC,YAAYC,iBA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AAM,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": ["Schema", "next", "A", "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"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15821,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/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":18582,"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1705,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":751,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17891},"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4578},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3745},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9125}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":15773,"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":18896,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18027},"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/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":4688},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3709},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9199}}}
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,6BAA6B;IACpC,OAAO,6BAA6B;CACrC;AA+HD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACmC,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,6BAA6B;IACpC,OAAO,6BAA6B;CACrC;AA+HD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,GAAI,OAAO,KAAK,yCACmC,CAAC"}
@@ -1,6 +1,7 @@
1
+ import { type Schema } from 'effect';
1
2
  import { type Space } from '@dxos/client/echo';
2
- import { type ReactiveEchoObject } from '@dxos/echo-db';
3
- import { EchoSchema, type S } from '@dxos/echo-schema';
3
+ import { type AnyLiveObject } from '@dxos/echo-db';
4
+ import { EchoSchema } from '@dxos/echo-schema';
4
5
  import { type Live } from '@dxos/live-object';
5
6
  import { type TestSchemaType } from './data';
6
7
  import { type MutationsProviderParams, type TestGeneratorMap, type TestMutationsMap, type TestObjectProvider, type TestSchemaMap } from './types';
@@ -12,9 +13,9 @@ export declare class TestObjectGenerator<T extends string = TestSchemaType> {
12
13
  private readonly _generators;
13
14
  private readonly _provider?;
14
15
  constructor(_schemas: TestSchemaMap<T>, _generators: TestGeneratorMap<T>, _provider?: TestObjectProvider<T> | undefined);
15
- get schemas(): (EchoSchema | S.Schema.AnyNoContext)[];
16
- getSchema(type: T): EchoSchema | S.Schema.AnyNoContext | undefined;
17
- protected setSchema(type: T, schema: EchoSchema | S.Schema.AnyNoContext): void;
16
+ get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[];
17
+ getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined;
18
+ protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void;
18
19
  createObject({ types }?: {
19
20
  types?: T[];
20
21
  }): Promise<Live<any>>;
@@ -27,12 +28,12 @@ export declare class SpaceObjectGenerator<T extends string> extends TestObjectGe
27
28
  private readonly _space;
28
29
  private readonly _mutations?;
29
30
  constructor(_space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>, _mutations?: TestMutationsMap<T> | undefined);
30
- addSchemas(): Promise<(S.Schema.AnyNoContext | EchoSchema<any, any>)[]>;
31
+ addSchemas(): Promise<(Schema.Schema.AnyNoContext | EchoSchema<any, any>)[]>;
31
32
  createObject({ types }?: {
32
33
  types?: T[];
33
- }): Promise<ReactiveEchoObject<any>>;
34
+ }): Promise<AnyLiveObject<any>>;
34
35
  private _maybeRegisterSchema;
35
- mutateObject(object: ReactiveEchoObject<any>, params: MutationsProviderParams): Promise<void>;
36
- mutateObjects(objects: ReactiveEchoObject<any>[], params: MutationsProviderParams): Promise<void>;
36
+ mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void>;
37
+ mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void>;
37
38
  }
38
39
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAA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C,CAAC,EAC3B,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACd,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,YAAA;IAQ7C,UAAU;IAWD,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAI3E,oBAAoB;IAqB5B,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,uBAAuB;IAQxE,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB;CAKnF"}
@@ -1,10 +1,11 @@
1
- import { type ReactiveEchoObject } from '@dxos/echo-db';
2
- import { type EchoSchema, type S } from '@dxos/echo-schema';
1
+ import { type Schema } from 'effect';
2
+ import { type AnyLiveObject } from '@dxos/echo-db';
3
+ import { type EchoSchema } from '@dxos/echo-schema';
3
4
  import { type Live } from '@dxos/live-object';
4
5
  export type TestObject = {
5
6
  id: string;
6
7
  } & Record<string, any>;
7
- export type TestSchemaMap<T extends string = string> = Record<T, EchoSchema | S.Schema.AnyNoContext>;
8
+ export type TestSchemaMap<T extends string = string> = Record<T, EchoSchema | Schema.Schema.AnyNoContext>;
8
9
  export type TestObjectProvider<T extends string = string> = (type: T) => Promise<Live<any>[]>;
9
10
  export type TestGeneratorMap<T extends string = string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
10
11
  export type TestMutationsMap<T extends string = string> = Record<T, TestObjectMutators>;
@@ -13,5 +14,5 @@ export type MutationsProviderParams = {
13
14
  mutationSize: number;
14
15
  maxContentLength: number;
15
16
  };
16
- export type TestObjectMutators = (object: ReactiveEchoObject<any>, params: MutationsProviderParams) => Promise<void>;
17
+ export type TestObjectMutators = (object: AnyLiveObject<any>, params: MutationsProviderParams) => Promise<void>;
17
18
  //# sourceMappingURL=types.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,EAAE,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,WAAY,MAAM,WASxC,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,WASxC,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.3"}
1
+ {"version":"5.8.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-generator",
3
- "version": "0.8.2-main.5885341",
3
+ "version": "0.8.2-main.600d381",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -24,21 +24,23 @@
24
24
  "src"
25
25
  ],
26
26
  "dependencies": {
27
- "@dxos/automerge": "0.8.2-main.5885341",
28
- "@dxos/echo-db": "0.8.2-main.5885341",
29
- "@dxos/echo-schema": "0.8.2-main.5885341",
30
- "@dxos/client": "0.8.2-main.5885341",
31
- "@dxos/live-object": "0.8.2-main.5885341",
32
- "@dxos/node-std": "0.8.2-main.5885341",
33
- "@dxos/invariant": "0.8.2-main.5885341",
34
- "@dxos/schema": "0.8.2-main.5885341",
35
- "@dxos/util": "0.8.2-main.5885341"
27
+ "effect": "3.14.21",
28
+ "@dxos/automerge": "0.8.2-main.600d381",
29
+ "@dxos/client": "0.8.2-main.600d381",
30
+ "@dxos/echo-db": "0.8.2-main.600d381",
31
+ "@dxos/echo-schema": "0.8.2-main.600d381",
32
+ "@dxos/invariant": "0.8.2-main.600d381",
33
+ "@dxos/node-std": "0.8.2-main.600d381",
34
+ "@dxos/live-object": "0.8.2-main.600d381",
35
+ "@dxos/schema": "0.8.2-main.600d381",
36
+ "@dxos/util": "0.8.2-main.600d381"
36
37
  },
37
38
  "devDependencies": {
38
- "@dxos/random": "0.8.2-main.5885341"
39
+ "@dxos/random": "0.8.2-main.600d381"
39
40
  },
40
41
  "peerDependencies": {
41
- "@dxos/random": "0.8.2-main.5885341"
42
+ "effect": "^3.13.3",
43
+ "@dxos/random": "0.8.2-main.600d381"
42
44
  },
43
45
  "publishConfig": {
44
46
  "access": "public"
package/src/data.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Schema } from 'effect';
6
+
5
7
  import { next as A } from '@dxos/automerge/automerge';
6
8
  import { createDocAccessor, type Space } from '@dxos/client/echo';
7
- import { Ref, S } from '@dxos/echo-schema';
9
+ import { Ref } from '@dxos/echo-schema';
8
10
  import { createEchoSchema } from '@dxos/live-object';
9
11
  import { faker } from '@dxos/random';
10
12
 
@@ -33,8 +35,8 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
33
35
  version: '0.1.0',
34
36
  },
35
37
  {
36
- title: S.String.annotations({ description: 'title of the document' }),
37
- content: S.String,
38
+ title: Schema.String.annotations({ description: 'title of the document' }),
39
+ content: Schema.String,
38
40
  },
39
41
  );
40
42
 
@@ -44,9 +46,9 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
44
46
  version: '0.1.0',
45
47
  },
46
48
  {
47
- name: S.String.annotations({ description: 'name of the company or organization' }),
48
- website: S.String.annotations({ description: 'public website URL' }),
49
- description: S.String.annotations({ description: 'short summary of the company' }),
49
+ name: Schema.String.annotations({ description: 'name of the company or organization' }),
50
+ website: Schema.String.annotations({ description: 'public website URL' }),
51
+ description: Schema.String.annotations({ description: 'short summary of the company' }),
50
52
  },
51
53
  );
52
54
 
@@ -56,11 +58,11 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
56
58
  version: '0.1.0',
57
59
  },
58
60
  {
59
- name: S.String.annotations({ description: 'name of the person' }),
60
- email: S.String,
61
+ name: Schema.String.annotations({ description: 'name of the person' }),
62
+ email: Schema.String,
61
63
  org: Ref(organization),
62
- lat: S.Number,
63
- lng: S.Number,
64
+ lat: Schema.Number,
65
+ lng: Schema.Number,
64
66
  },
65
67
  );
66
68
 
@@ -70,13 +72,13 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
70
72
  version: '0.1.0',
71
73
  },
72
74
  {
73
- name: S.String.annotations({ description: 'name of the project' }),
74
- description: S.String,
75
- website: S.String,
76
- repo: S.String,
77
- status: S.String,
78
- priority: S.Number,
79
- active: S.Boolean,
75
+ name: Schema.String.annotations({ description: 'name of the project' }),
76
+ description: Schema.String,
77
+ website: Schema.String,
78
+ repo: Schema.String,
79
+ status: Schema.String,
80
+ priority: Schema.Number,
81
+ active: Schema.Boolean,
80
82
  org: Ref(organization),
81
83
  },
82
84
  );
@@ -2,12 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Schema } from 'effect';
5
6
  import { describe, expect, onTestFinished, test } from 'vitest';
6
7
 
7
8
  import { next as A } from '@dxos/automerge/automerge';
8
9
  import { Client } from '@dxos/client';
9
10
  import { getObjectCore } from '@dxos/echo-db';
10
- import { S, TypedObject } from '@dxos/echo-schema';
11
+ import { TypedObject } from '@dxos/echo-schema';
11
12
  import { getType } from '@dxos/live-object';
12
13
  import { faker } from '@dxos/random';
13
14
 
@@ -96,7 +97,7 @@ describe('TestObjectGenerator', () => {
96
97
  typename: 'example.org/type/Task',
97
98
  version: '0.1.0',
98
99
  })({
99
- name: S.optional(S.String),
100
+ name: Schema.optional(Schema.String),
100
101
  }) {}
101
102
 
102
103
  enum Types {
package/src/generator.ts CHANGED
@@ -2,10 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { type Schema } from 'effect';
6
+
5
7
  import { Filter, type Space } from '@dxos/client/echo';
6
- import { type ReactiveEchoObject } from '@dxos/echo-db';
7
- import { getTypeAnnotation, EchoSchema, type S } from '@dxos/echo-schema';
8
- import { getSchema } from '@dxos/echo-schema';
8
+ import { type AnyLiveObject } from '@dxos/echo-db';
9
+ import { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';
9
10
  import { invariant } from '@dxos/invariant';
10
11
  import { live, isLiveObject, type Live } from '@dxos/live-object';
11
12
  import { faker } from '@dxos/random';
@@ -31,15 +32,15 @@ export class TestObjectGenerator<T extends string = TestSchemaType> {
31
32
  private readonly _provider?: TestObjectProvider<T>,
32
33
  ) {}
33
34
 
34
- get schemas(): (EchoSchema | S.Schema.AnyNoContext)[] {
35
+ get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {
35
36
  return Object.values(this._schemas);
36
37
  }
37
38
 
38
- getSchema(type: T): EchoSchema | S.Schema.AnyNoContext | undefined {
39
+ getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {
39
40
  return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);
40
41
  }
41
42
 
42
- protected setSchema(type: T, schema: EchoSchema | S.Schema.AnyNoContext) {
43
+ protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext) {
43
44
  this._schemas[type] = schema;
44
45
  }
45
46
 
@@ -83,9 +84,9 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
83
84
  }
84
85
 
85
86
  async addSchemas() {
86
- const result: (EchoSchema | S.Schema.AnyNoContext)[] = [];
87
+ const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];
87
88
  for (const [typename, schema] of Object.entries(this._schemas)) {
88
- const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | S.Schema.AnyNoContext);
89
+ const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);
89
90
  this.setSchema(typename as T, echoSchema);
90
91
  result.push(echoSchema);
91
92
  }
@@ -93,14 +94,14 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
93
94
  return result;
94
95
  }
95
96
 
96
- override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveEchoObject<any>> {
97
+ override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {
97
98
  return this._space.db.add(await super.createObject({ types }));
98
99
  }
99
100
 
100
101
  private async _maybeRegisterSchema(
101
102
  typename: string,
102
- schema: EchoSchema | S.Schema.AnyNoContext,
103
- ): Promise<EchoSchema | S.Schema.AnyNoContext> {
103
+ schema: EchoSchema | Schema.Schema.AnyNoContext,
104
+ ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {
104
105
  if (schema instanceof EchoSchema) {
105
106
  const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
106
107
  if (existingSchema != null) {
@@ -118,7 +119,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
118
119
  }
119
120
  }
120
121
 
121
- async mutateObject(object: ReactiveEchoObject<any>, params: MutationsProviderParams) {
122
+ async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams) {
122
123
  invariant(this._mutations, 'Mutations not defined.');
123
124
  const type = getTypeAnnotation(getSchema(object)!)!.typename as T;
124
125
  invariant(type && this._mutations?.[type], 'Invalid object type.');
@@ -126,7 +127,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
126
127
  await this._mutations![type](object, params);
127
128
  }
128
129
 
129
- async mutateObjects(objects: ReactiveEchoObject<any>[], params: MutationsProviderParams) {
130
+ async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams) {
130
131
  for (const object of objects) {
131
132
  await this.mutateObject(object, params);
132
133
  }
package/src/types.ts CHANGED
@@ -2,14 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type ReactiveEchoObject } from '@dxos/echo-db';
6
- import { type EchoSchema, type S } from '@dxos/echo-schema';
5
+ import { type Schema } from 'effect';
6
+
7
+ import { type AnyLiveObject } from '@dxos/echo-db';
8
+ import { type EchoSchema } from '@dxos/echo-schema';
7
9
  import { type Live } from '@dxos/live-object';
8
10
 
9
11
  // TODO(burdon): Use echo-schema types.
10
12
  export type TestObject = { id: string } & Record<string, any>;
11
13
 
12
- export type TestSchemaMap<T extends string = string> = Record<T, EchoSchema | S.Schema.AnyNoContext>;
14
+ export type TestSchemaMap<T extends string = string> = Record<T, EchoSchema | Schema.Schema.AnyNoContext>;
13
15
 
14
16
  export type TestObjectProvider<T extends string = string> = (type: T) => Promise<Live<any>[]>;
15
17
 
@@ -26,4 +28,4 @@ export type MutationsProviderParams = {
26
28
  maxContentLength: number;
27
29
  };
28
30
 
29
- export type TestObjectMutators = (object: ReactiveEchoObject<any>, params: MutationsProviderParams) => Promise<void>;
31
+ export type TestObjectMutators = (object: AnyLiveObject<any>, params: MutationsProviderParams) => Promise<void>;