@dxos/echo-generator 0.8.3 → 0.8.4-main.1da679c

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,27 +1,34 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
- // packages/core/echo/echo-generator/src/data.ts
3
+ // src/data.ts
4
4
  import { next as A } from "@automerge/automerge";
5
5
  import { Schema } from "effect";
6
6
  import { createDocAccessor } from "@dxos/client/echo";
7
7
  import { EchoObject, Ref } from "@dxos/echo-schema";
8
8
  import { faker as faker2 } from "@dxos/random";
9
9
 
10
- // packages/core/echo/echo-generator/src/generator.ts
10
+ // src/generator.ts
11
11
  import { Filter } from "@dxos/client/echo";
12
- import { getTypeAnnotation, EchoSchema, getSchema } from "@dxos/echo-schema";
12
+ import { EchoSchema, getSchema, getTypeAnnotation } from "@dxos/echo-schema";
13
13
  import { invariant } from "@dxos/invariant";
14
- import { live, isLiveObject } from "@dxos/live-object";
14
+ import { isLiveObject, live } from "@dxos/live-object";
15
15
  import { faker } from "@dxos/random";
16
16
  import { entries, range } from "@dxos/util";
17
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
18
- var TestObjectGenerator = class {
19
- // prettier-ignore
20
- constructor(_schemas, _generators, _provider) {
21
- this._schemas = _schemas;
22
- this._generators = _generators;
23
- this._provider = _provider;
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
24
27
  }
28
+ return obj;
29
+ }
30
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
31
+ var TestObjectGenerator = class {
25
32
  get schemas() {
26
33
  return Object.values(this._schemas);
27
34
  }
@@ -59,15 +66,17 @@ var TestObjectGenerator = class {
59
66
  }).flatMap((t) => t);
60
67
  return Promise.all(tasks);
61
68
  }
69
+ // prettier-ignore
70
+ constructor(_schemas, _generators, _provider) {
71
+ _define_property(this, "_schemas", void 0);
72
+ _define_property(this, "_generators", void 0);
73
+ _define_property(this, "_provider", void 0);
74
+ this._schemas = _schemas;
75
+ this._generators = _generators;
76
+ this._provider = _provider;
77
+ }
62
78
  };
63
79
  var SpaceObjectGenerator = class extends TestObjectGenerator {
64
- constructor(_space, schemaMap, generators, _mutations) {
65
- super(schemaMap, generators, async (type) => {
66
- const schema = this.getSchema(type);
67
- const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
68
- return objects;
69
- }), this._space = _space, this._mutations = _mutations;
70
- }
71
80
  async addSchemas() {
72
81
  const result = [];
73
82
  for (const [typename, schema] of Object.entries(this._schemas)) {
@@ -130,9 +139,16 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
130
139
  await this.mutateObject(object, params);
131
140
  }
132
141
  }
142
+ constructor(_space, schemaMap, generators, _mutations) {
143
+ super(schemaMap, generators, async (type) => {
144
+ const schema = this.getSchema(type);
145
+ const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
146
+ return objects;
147
+ }), _define_property(this, "_space", void 0), _define_property(this, "_mutations", void 0), this._space = _space, this._mutations = _mutations;
148
+ }
133
149
  };
134
150
 
135
- // packages/core/echo/echo-generator/src/util.ts
151
+ // src/util.ts
136
152
  var randomText = (length) => {
137
153
  let result = "";
138
154
  const characters = "abcdefghijklmnopqrstuvwxyz";
@@ -143,7 +159,7 @@ var randomText = (length) => {
143
159
  return result;
144
160
  };
145
161
 
146
- // packages/core/echo/echo-generator/src/data.ts
162
+ // src/data.ts
147
163
  var Status = [
148
164
  "pending",
149
165
  "active",
@@ -156,13 +172,13 @@ var Priority = [
156
172
  4,
157
173
  5
158
174
  ];
159
- var TestSchemaType = /* @__PURE__ */ function(TestSchemaType2) {
175
+ var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
160
176
  TestSchemaType2["document"] = "example.com/type/Document";
161
177
  TestSchemaType2["organization"] = "example.com/type/Organization";
162
178
  TestSchemaType2["contact"] = "example.com/type/Contact";
163
179
  TestSchemaType2["project"] = "example.com/type/Project";
164
180
  return TestSchemaType2;
165
- }({});
181
+ })({});
166
182
  var testSchemas = () => {
167
183
  const document = Schema.Struct({
168
184
  title: Schema.String.annotations({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { live, isLiveObject, type Live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,cAAc;AAEvB,SAASC,yBAAqC;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AAEnC,SAASC,mBAAmBC,YAAYC,iBAAiB;AACzD,SAASC,iBAAiB;AAC1B,SAASC,MAAMC,oBAA+B;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;EAEX,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAR,UAAUc,MAA8D;AACtE,WAAO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ACAX,OAAOY,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB9E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAOhF,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
6
- "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "getTypeAnnotation", "EchoSchema", "getSchema", "invariant", "live", "isLiveObject", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { type Space, createDocAccessor } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { type Live, isLiveObject, live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,cAAc;AAEvB,SAAqBC,yBAAyB;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AAEnC,SAASC,YAAYC,WAAWC,yBAAyB;AACzD,SAASC,iBAAiB;AAC1B,SAAoBC,cAAcC,YAAY;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;;;;;;;;;;;;;;AAexB,IAAMC,sBAAN,MAAMA;EAQX,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKC,QAAQ;EACpC;EAEAZ,UAAUa,MAA8D;AACtE,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWd,kBAAkBc,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAuD;AAClF,SAAKH,SAASC,IAAAA,IAAQE;EACxB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Y,oBAAoBpB,SAAS,IAAIQ,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB9E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMiD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAOhF,YAAAA,GAAe8B,sBAAsB6B,kBAAAA;",
6
+ "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "EchoSchema", "getSchema", "getTypeAnnotation", "invariant", "isLiveObject", "live", "faker", "entries", "range", "TestObjectGenerator", "schemas", "Object", "values", "_schemas", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "_generators", "_provider", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "_space", "db", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "_mutations", "mutateObjects", "objects", "schemaMap", "generators", "query", "nothing", "run", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16612,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1580,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":19484,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1713,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18940},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4811},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3960},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9514}}}
1
+ {"inputs":{"src/generator.ts":{"bytes":17076,"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"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19471,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18999},"dist/lib/browser/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4813},"src/generator.ts":{"bytesInOutput":4431},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9851}}}
@@ -1,27 +1,34 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // packages/core/echo/echo-generator/src/data.ts
3
+ // src/data.ts
4
4
  import { next as A } from "@automerge/automerge";
5
5
  import { Schema } from "effect";
6
6
  import { createDocAccessor } from "@dxos/client/echo";
7
7
  import { EchoObject, Ref } from "@dxos/echo-schema";
8
8
  import { faker as faker2 } from "@dxos/random";
9
9
 
10
- // packages/core/echo/echo-generator/src/generator.ts
10
+ // src/generator.ts
11
11
  import { Filter } from "@dxos/client/echo";
12
- import { getTypeAnnotation, EchoSchema, getSchema } from "@dxos/echo-schema";
12
+ import { EchoSchema, getSchema, getTypeAnnotation } from "@dxos/echo-schema";
13
13
  import { invariant } from "@dxos/invariant";
14
- import { live, isLiveObject } from "@dxos/live-object";
14
+ import { isLiveObject, live } from "@dxos/live-object";
15
15
  import { faker } from "@dxos/random";
16
16
  import { entries, range } from "@dxos/util";
17
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
18
- var TestObjectGenerator = class {
19
- // prettier-ignore
20
- constructor(_schemas, _generators, _provider) {
21
- this._schemas = _schemas;
22
- this._generators = _generators;
23
- this._provider = _provider;
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
24
27
  }
28
+ return obj;
29
+ }
30
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
31
+ var TestObjectGenerator = class {
25
32
  get schemas() {
26
33
  return Object.values(this._schemas);
27
34
  }
@@ -59,15 +66,17 @@ var TestObjectGenerator = class {
59
66
  }).flatMap((t) => t);
60
67
  return Promise.all(tasks);
61
68
  }
69
+ // prettier-ignore
70
+ constructor(_schemas, _generators, _provider) {
71
+ _define_property(this, "_schemas", void 0);
72
+ _define_property(this, "_generators", void 0);
73
+ _define_property(this, "_provider", void 0);
74
+ this._schemas = _schemas;
75
+ this._generators = _generators;
76
+ this._provider = _provider;
77
+ }
62
78
  };
63
79
  var SpaceObjectGenerator = class extends TestObjectGenerator {
64
- constructor(_space, schemaMap, generators, _mutations) {
65
- super(schemaMap, generators, async (type) => {
66
- const schema = this.getSchema(type);
67
- const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
68
- return objects;
69
- }), this._space = _space, this._mutations = _mutations;
70
- }
71
80
  async addSchemas() {
72
81
  const result = [];
73
82
  for (const [typename, schema] of Object.entries(this._schemas)) {
@@ -130,9 +139,16 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
130
139
  await this.mutateObject(object, params);
131
140
  }
132
141
  }
142
+ constructor(_space, schemaMap, generators, _mutations) {
143
+ super(schemaMap, generators, async (type) => {
144
+ const schema = this.getSchema(type);
145
+ const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
146
+ return objects;
147
+ }), _define_property(this, "_space", void 0), _define_property(this, "_mutations", void 0), this._space = _space, this._mutations = _mutations;
148
+ }
133
149
  };
134
150
 
135
- // packages/core/echo/echo-generator/src/util.ts
151
+ // src/util.ts
136
152
  var randomText = (length) => {
137
153
  let result = "";
138
154
  const characters = "abcdefghijklmnopqrstuvwxyz";
@@ -143,7 +159,7 @@ var randomText = (length) => {
143
159
  return result;
144
160
  };
145
161
 
146
- // packages/core/echo/echo-generator/src/data.ts
162
+ // src/data.ts
147
163
  var Status = [
148
164
  "pending",
149
165
  "active",
@@ -156,13 +172,13 @@ var Priority = [
156
172
  4,
157
173
  5
158
174
  ];
159
- var TestSchemaType = /* @__PURE__ */ function(TestSchemaType2) {
175
+ var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
160
176
  TestSchemaType2["document"] = "example.com/type/Document";
161
177
  TestSchemaType2["organization"] = "example.com/type/Organization";
162
178
  TestSchemaType2["contact"] = "example.com/type/Contact";
163
179
  TestSchemaType2["project"] = "example.com/type/Project";
164
180
  return TestSchemaType2;
165
- }({});
181
+ })({});
166
182
  var testSchemas = () => {
167
183
  const document = Schema.Struct({
168
184
  title: Schema.String.annotations({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { live, isLiveObject, type Live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,cAAc;AAEvB,SAASC,yBAAqC;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AAEnC,SAASC,mBAAmBC,YAAYC,iBAAiB;AACzD,SAASC,iBAAiB;AAC1B,SAASC,MAAMC,oBAA+B;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;AAexB,IAAMC,sBAAN,MAAMA;;EAEX,YACqBC,UACFC,aACAC,WACjB;SAHmBF,WAAAA;SACFC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAR,UAAUc,MAA8D;AACtE,WAAO,KAAKH,QAAQI,KAAK,CAACC,WAAWlB,kBAAkBkB,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAuD;AAClF,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,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A;",
6
- "names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "getTypeAnnotation", "EchoSchema", "getSchema", "invariant", "live", "isLiveObject", "faker", "entries", "range", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "mutateObjects", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { type Space, createDocAccessor } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { type Live, isLiveObject, live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,QAAQC,SAAS;AAC1B,SAASC,cAAc;AAEvB,SAAqBC,yBAAyB;AAC9C,SAASC,YAAYC,WAAW;AAChC,SAASC,SAAAA,cAAa;;;ACHtB,SAASC,cAA0B;AAEnC,SAASC,YAAYC,WAAWC,yBAAyB;AACzD,SAASC,iBAAiB;AAC1B,SAAoBC,cAAcC,YAAY;AAC9C,SAASC,aAAa;AACtB,SAASC,SAASC,aAAa;;;;;;;;;;;;;;;AAexB,IAAMC,sBAAN,MAAMA;EAQX,IAAIC,UAAuD;AACzD,WAAOC,OAAOC,OAAO,KAAKC,QAAQ;EACpC;EAEAZ,UAAUa,MAA8D;AACtE,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWd,kBAAkBc,MAAAA,EAASC,aAAaH,IAAAA;EAC/E;EAEUI,UAAUJ,MAASE,QAAuD;AAClF,SAAKH,SAASC,IAAAA,IAAQE;EACxB;EAEA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAuB;AACtE,UAAMN,OAAOR,MAAMe,QAAQC,aAAaF,SAAUT,OAAOY,KAAK,KAAKV,QAAQ,CAAA;AAC3E,UAAMW,OAAO,MAAM,KAAKC,YAAYX,IAAAA,EAAM,KAAKY,SAAS;AACxD,QAAItB,aAAaoB,IAAAA,GAAO;AACtB,aAAOA;IACT;AAEA,UAAMR,SAAS,KAAKf,UAAUa,IAAAA;AAC9B,WAAOE,SAASX,KAAKW,QAAQQ,IAAAA,IAAQnB,KAAKmB,IAAAA;EAC5C;;EAGA,MAAMG,cAAcC,KAAiC;AACnD,UAAMC,UAAuB,CAAA;AAC7B,eAAW,CAACf,MAAMgB,KAAAA,KAAUvB,QAAQqB,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"names": ["next", "A", "Schema", "createDocAccessor", "EchoObject", "Ref", "faker", "Filter", "EchoSchema", "getSchema", "getTypeAnnotation", "invariant", "isLiveObject", "live", "faker", "entries", "range", "TestObjectGenerator", "schemas", "Object", "values", "_schemas", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "helpers", "arrayElement", "keys", "data", "_generators", "_provider", "createObjects", "map", "results", "count", "push", "Promise", "all", "tasks", "flatMap", "t", "SpaceObjectGenerator", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "_space", "db", "add", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "_mutations", "mutateObjects", "objects", "schemaMap", "generators", "query", "nothing", "run", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "typename", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "make", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16612,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1580,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":19484,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1713,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18940},"packages/core/echo/echo-generator/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4811},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3960},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9573}}}
1
+ {"inputs":{"src/generator.ts":{"bytes":17076,"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"},"src/util.ts":{"bytes":1567,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19471,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":661,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18999},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4813},"src/generator.ts":{"bytesInOutput":4431},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9910}}}
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC;;GAEG;AACH,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,6BAA6B;IACpC,OAAO,6BAA6B;CACrC;AA6GD;;GAEG;AACH,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,KAAK,yCACmC,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AAIlE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC;;GAEG;AACH,oBAAY,cAAc;IACxB,QAAQ,8BA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AAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAYjE,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAcpD;AAED;;GAEG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAHX,MAAM,EAAE,KAAK,EAC9B,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACd,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,YAAA;IAS7C,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,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxF,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnG"}
@@ -1,5 +1,5 @@
1
1
  export * from './data';
2
2
  export * from './generator';
3
- export * from './types';
3
+ export type * from './types';
4
4
  export * from './util';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,mBAAmB,SAAS,CAAC;AAC7B,cAAc,QAAQ,CAAC"}