@dxos/echo-generator 0.4.10-main.b3cf40d → 0.4.10-main.bb9f1bf

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.
@@ -8,14 +8,12 @@ import {
8
8
  } from "@dxos/node-std/inject-globals";
9
9
 
10
10
  // packages/core/echo/echo-generator/src/data.ts
11
- import * as S from "@effect/schema/Schema";
12
- import * as E2 from "@dxos/echo-schema";
13
- import { DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema } from "@dxos/echo-schema";
11
+ import { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create as create2, ref, echoObject } from "@dxos/echo-schema";
14
12
  import { faker as faker2 } from "@dxos/random";
15
13
 
16
14
  // packages/core/echo/echo-generator/src/generator.ts
17
- import { Filter } from "@dxos/echo-schema";
18
- import * as E from "@dxos/echo-schema";
15
+ import { Filter } from "@dxos/client/echo";
16
+ import { create } from "@dxos/echo-schema";
19
17
  import { faker } from "@dxos/random";
20
18
 
21
19
  // packages/core/echo/echo-generator/src/util.ts
@@ -41,36 +39,34 @@ var TestObjectGenerator = class {
41
39
  this._schemas[type] = schema;
42
40
  }
43
41
  // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).
44
- createObject({ types } = {}) {
42
+ async createObject({ types } = {}) {
45
43
  const type = faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
46
- const data = this._generators[type](this._provider);
44
+ const data = await this._generators[type](this._provider);
47
45
  const schema = this.getSchema(type);
48
- return schema ? E.object(schema, data) : E.object(data);
46
+ return schema ? create(schema, data) : create(data);
49
47
  }
50
48
  // TODO(burdon): Create batch.
51
49
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
52
- createObjects(map) {
53
- const objects = [];
54
- Object.entries(map).forEach(([type, count]) => {
55
- range(() => objects.push(this.createObject({
50
+ async createObjects(map) {
51
+ const tasks = Object.entries(map).map(([type, count]) => {
52
+ return range(() => this.createObject({
56
53
  types: [
57
54
  type
58
55
  ]
59
- })), count);
60
- });
61
- return objects;
56
+ }), count);
57
+ }).flatMap((t) => t);
58
+ return Promise.all(tasks);
62
59
  }
63
60
  };
64
61
  var SpaceObjectGenerator = class extends TestObjectGenerator {
65
62
  constructor(_space, schemaMap, generators) {
66
- super(schemaMap, generators, (type) => {
63
+ super(schemaMap, generators, async (type) => {
67
64
  const schema = this.getSchema(type);
68
- return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];
65
+ return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];
69
66
  });
70
67
  this._space = _space;
71
- const schemas = this._space.db.schemaRegistry.getAll();
72
68
  Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
73
- let schema = schemas.find((object3) => object3.typename === type);
69
+ let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);
74
70
  if (schema == null) {
75
71
  schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);
76
72
  }
@@ -79,9 +75,8 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
79
75
  }
80
76
  addSchemas() {
81
77
  const result = [];
82
- const dbSchemas = this._space.db.schemaRegistry.getAll();
83
78
  this.schemas.forEach((schema) => {
84
- const existing = dbSchemas.find((object3) => object3.typename === schema.typename);
79
+ const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);
85
80
  if (existing == null) {
86
81
  result.push(this._space.db.schemaRegistry.add(schema.schema));
87
82
  } else {
@@ -90,8 +85,8 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
90
85
  });
91
86
  return result;
92
87
  }
93
- createObject({ types } = {}) {
94
- return this._space.db.add(super.createObject({
88
+ async createObject({ types } = {}) {
89
+ return this._space.db.add(await super.createObject({
95
90
  types
96
91
  }));
97
92
  }
@@ -118,8 +113,8 @@ var TestSchemaType;
118
113
  TestSchemaType2["project"] = "example.com/schema/project";
119
114
  })(TestSchemaType || (TestSchemaType = {}));
120
115
  var createDynamicSchema = (typename, fields) => {
121
- const typeSchema = S.partial(S.struct(fields)).pipe(E2.echoObject(typename, "1.0.0"));
122
- return new DynamicEchoSchema(E2.object(StoredEchoSchema, {
116
+ const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, "1.0.0"));
117
+ return new DynamicEchoSchema(create2(StoredEchoSchema, {
123
118
  typename,
124
119
  version: "1.0.0",
125
120
  jsonSchema: effectToJsonSchema(typeSchema)
@@ -138,7 +133,7 @@ var testSchemas = () => {
138
133
  const contact = createDynamicSchema("example.com/schema/contact", {
139
134
  name: S.string.pipe(S.description("name of the person")),
140
135
  email: S.string,
141
- org: E2.ref(organization),
136
+ org: ref(organization),
142
137
  lat: S.number,
143
138
  lng: S.number
144
139
  });
@@ -150,7 +145,7 @@ var testSchemas = () => {
150
145
  status: S.string,
151
146
  priority: S.number,
152
147
  active: S.boolean,
153
- org: E2.ref(organization)
148
+ org: ref(organization)
154
149
  });
155
150
  return {
156
151
  ["example.com/schema/document"]: document,
@@ -160,7 +155,7 @@ var testSchemas = () => {
160
155
  };
161
156
  };
162
157
  var testObjectGenerators = {
163
- ["example.com/schema/document"]: () => ({
158
+ ["example.com/schema/document"]: async () => ({
164
159
  title: faker2.lorem.sentence(3),
165
160
  content: faker2.lorem.sentences({
166
161
  min: 1,
@@ -170,15 +165,15 @@ var testObjectGenerators = {
170
165
  })
171
166
  })
172
167
  }),
173
- ["example.com/schema/organization"]: () => ({
168
+ ["example.com/schema/organization"]: async () => ({
174
169
  name: faker2.company.name(),
175
170
  website: faker2.datatype.boolean({
176
171
  probability: 0.3
177
172
  }) ? faker2.internet.url() : void 0,
178
173
  description: faker2.lorem.sentences()
179
174
  }),
180
- ["example.com/schema/contact"]: (provider) => {
181
- const organizations = provider?.("example.com/schema/organization");
175
+ ["example.com/schema/contact"]: async (provider) => {
176
+ const organizations = await provider?.("example.com/schema/organization");
182
177
  const location = faker2.datatype.boolean() ? faker2.helpers.arrayElement(locations) : void 0;
183
178
  return {
184
179
  name: faker2.person.fullName(),
@@ -191,7 +186,7 @@ var testObjectGenerators = {
191
186
  ...location
192
187
  };
193
188
  },
194
- ["example.com/schema/project"]: () => ({
189
+ ["example.com/schema/project"]: async () => ({
195
190
  name: faker2.commerce.productName(),
196
191
  repo: faker2.datatype.boolean({
197
192
  probability: 0.3
@@ -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\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\nimport * as S from '@effect/schema/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport * as E from '@dxos/echo-schema';\nimport { DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\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/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(E.echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n E.object(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: E.ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.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: E.ref(organization),\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]: () => ({\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]: () => ({\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]: (provider) => {\n const organizations = provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: () => ({\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\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, Filter, type ReactiveObject } from '@dxos/echo-schema';\nimport * as E from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? E.object(schema, data) : E.object(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n createObjects(map: Partial<Record<T, number>>): ReactiveObject<any>[] {\n const objects: ReactiveObject<any>[] = [];\n Object.entries<number>(map as any).forEach(([type, count]) => {\n range(() => objects.push(this.createObject({ types: [type as T] })), count);\n });\n\n return objects;\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 ) {\n super(schemaMap, generators, (type: T) => {\n const schema = this.getSchema(type);\n return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n const schemas = this._space.db.schemaRegistry.getAll();\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = schemas.find((object) => object.typename === type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n const dbSchemas = this._space.db.schemaRegistry.getAll();\n this.schemas.forEach((schema) => {\n const existing = dbSchemas.find((object) => object.typename === schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
5
- "mappings": ";;;;;;;;;;AAOA,YAAYA,OAAO;AAGnB,YAAYC,QAAO;AACnB,SAASC,mBAAmBC,oBAAoBC,wBAAwB;AACxE,SAASC,SAAAA,cAAa;;;ACPtB,SAAiCC,cAAmC;AACpE,YAAYC,OAAO;AACnB,SAASC,aAAa;;;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADQL,IAAMC,sBAAN,MAAMA;;EAEXC,YACmBC,UACAC,aACAC,WACjB;SAHiBF,WAAAA;SACAC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA+B;AACjC,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAwC;AAChD,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWA,OAAOC,aAAaH,IAAAA;EAC3D;EAEUI,UAAUJ,MAASE,QAA2B;AACtD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;;EAGAG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAwB;AACjE,UAAMN,OAAOO,MAAMC,QAAQC,aAAaH,SAAUT,OAAOa,KAAK,KAAKjB,QAAQ,CAAA;AAC3E,UAAMkB,OAAO,KAAKjB,YAAYM,IAAAA,EAAM,KAAKL,SAAS;AAClD,UAAMO,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EF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAqBE,KAAK;EAAmB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAqBE,KAAK;EAAiB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAqBE,KAAK;EAAkB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
6
- "names": ["S", "E", "DynamicEchoSchema", "effectToJsonSchema", "StoredEchoSchema", "faker", "Filter", "E", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "object", "createObjects", "map", "objects", "entries", "forEach", "count", "range", "push", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "schemaRegistry", "getAll", "dynamicSchema", "add", "addSchemas", "result", "dbSchemas", "existing", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "typename", "fields", "typeSchema", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "object", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "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", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "length", "commerce", "productName", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { type Space } from '@dxos/client/echo';\nimport { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\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/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.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 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.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
5
+ "mappings": ";;;;;;;;;;AAQA,SAASA,GAAGC,mBAAmBC,oBAAoBC,kBAAkBC,UAAAA,SAAQC,KAAKC,kBAAkB;AACpG,SAASC,SAAAA,cAAa;;;ACLtB,SAAqBC,cAAc;AAEnC,SAASC,cAAc;AACvB,SAASC,aAAa;;;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADQL,IAAMC,sBAAN,MAAMA;;EAEXC,YACmBC,UACAC,aACAC,WACjB;SAHiBF,WAAAA;SACAC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA+B;AACjC,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAwC;AAChD,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWA,OAAOC,aAAaH,IAAAA;EAC3D;EAEUI,UAAUJ,MAASE,QAA2B;AACtD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;;EAGA,MAAMG,aAAa,EAAEC,MAAK,IAAs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6
+ "names": ["S", "DynamicEchoSchema", "effectToJsonSchema", "StoredEchoSchema", "create", "ref", "echoObject", "faker", "Filter", "create", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "schemaRegistry", "getRegisteredByTypename", "add", "addSchemas", "result", "existing", "push", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "typename", "fields", "typeSchema", "S", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "create", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "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", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "length", "commerce", "productName", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11864,"imports":[{"path":"@dxos/echo-schema","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/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35783,"imports":[{"path":"@effect/schema/Schema","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/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":993,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"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"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23320},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@effect/schema/Schema","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/random","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/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10337},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2478},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13514}}}
1
+ {"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"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/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35633,"imports":[{"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":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1005,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"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"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23478},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","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/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10310},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2426},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13435}}}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var node_exports = {};
30
20
  __export(node_exports, {
@@ -38,12 +28,10 @@ __export(node_exports, {
38
28
  range: () => range
39
29
  });
40
30
  module.exports = __toCommonJS(node_exports);
41
- var S = __toESM(require("@effect/schema/Schema"));
42
- var E2 = __toESM(require("@dxos/echo-schema"));
43
31
  var import_echo_schema = require("@dxos/echo-schema");
44
32
  var import_random = require("@dxos/random");
33
+ var import_echo = require("@dxos/client/echo");
45
34
  var import_echo_schema2 = require("@dxos/echo-schema");
46
- var E = __toESM(require("@dxos/echo-schema"));
47
35
  var import_random2 = require("@dxos/random");
48
36
  var range = (fn, length) => Array.from({
49
37
  length
@@ -65,36 +53,34 @@ var TestObjectGenerator = class {
65
53
  this._schemas[type] = schema;
66
54
  }
67
55
  // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).
68
- createObject({ types } = {}) {
56
+ async createObject({ types } = {}) {
69
57
  const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
70
- const data = this._generators[type](this._provider);
58
+ const data = await this._generators[type](this._provider);
71
59
  const schema = this.getSchema(type);
72
- return schema ? E.object(schema, data) : E.object(data);
60
+ return schema ? (0, import_echo_schema2.create)(schema, data) : (0, import_echo_schema2.create)(data);
73
61
  }
74
62
  // TODO(burdon): Create batch.
75
63
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
76
- createObjects(map) {
77
- const objects = [];
78
- Object.entries(map).forEach(([type, count]) => {
79
- range(() => objects.push(this.createObject({
64
+ async createObjects(map) {
65
+ const tasks = Object.entries(map).map(([type, count]) => {
66
+ return range(() => this.createObject({
80
67
  types: [
81
68
  type
82
69
  ]
83
- })), count);
84
- });
85
- return objects;
70
+ }), count);
71
+ }).flatMap((t) => t);
72
+ return Promise.all(tasks);
86
73
  }
87
74
  };
88
75
  var SpaceObjectGenerator = class extends TestObjectGenerator {
89
76
  constructor(_space, schemaMap, generators) {
90
- super(schemaMap, generators, (type) => {
77
+ super(schemaMap, generators, async (type) => {
91
78
  const schema = this.getSchema(type);
92
- return (schema && this._space.db.query(import_echo_schema2.Filter.schema(schema)).objects) ?? [];
79
+ return (schema && (await this._space.db.query(import_echo.Filter.schema(schema)).run()).objects) ?? [];
93
80
  });
94
81
  this._space = _space;
95
- const schemas = this._space.db.schemaRegistry.getAll();
96
82
  Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
97
- let schema = schemas.find((object3) => object3.typename === type);
83
+ let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);
98
84
  if (schema == null) {
99
85
  schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);
100
86
  }
@@ -103,9 +89,8 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
103
89
  }
104
90
  addSchemas() {
105
91
  const result = [];
106
- const dbSchemas = this._space.db.schemaRegistry.getAll();
107
92
  this.schemas.forEach((schema) => {
108
- const existing = dbSchemas.find((object3) => object3.typename === schema.typename);
93
+ const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);
109
94
  if (existing == null) {
110
95
  result.push(this._space.db.schemaRegistry.add(schema.schema));
111
96
  } else {
@@ -114,8 +99,8 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
114
99
  });
115
100
  return result;
116
101
  }
117
- createObject({ types } = {}) {
118
- return this._space.db.add(super.createObject({
102
+ async createObject({ types } = {}) {
103
+ return this._space.db.add(await super.createObject({
119
104
  types
120
105
  }));
121
106
  }
@@ -140,8 +125,8 @@ var TestSchemaType;
140
125
  TestSchemaType2["project"] = "example.com/schema/project";
141
126
  })(TestSchemaType || (TestSchemaType = {}));
142
127
  var createDynamicSchema = (typename, fields) => {
143
- const typeSchema = S.partial(S.struct(fields)).pipe(E2.echoObject(typename, "1.0.0"));
144
- return new import_echo_schema.DynamicEchoSchema(E2.object(import_echo_schema.StoredEchoSchema, {
128
+ const typeSchema = import_echo_schema.S.partial(import_echo_schema.S.struct(fields)).pipe((0, import_echo_schema.echoObject)(typename, "1.0.0"));
129
+ return new import_echo_schema.DynamicEchoSchema((0, import_echo_schema.create)(import_echo_schema.StoredEchoSchema, {
145
130
  typename,
146
131
  version: "1.0.0",
147
132
  jsonSchema: (0, import_echo_schema.effectToJsonSchema)(typeSchema)
@@ -149,30 +134,30 @@ var createDynamicSchema = (typename, fields) => {
149
134
  };
150
135
  var testSchemas = () => {
151
136
  const document = createDynamicSchema("example.com/schema/document", {
152
- title: S.string.pipe(S.description("title of the document")),
153
- content: S.string
137
+ title: import_echo_schema.S.string.pipe(import_echo_schema.S.description("title of the document")),
138
+ content: import_echo_schema.S.string
154
139
  });
155
140
  const organization = createDynamicSchema("example.com/schema/organization", {
156
- name: S.string.pipe(S.description("name of the company or organization")),
157
- website: S.string.pipe(S.description("public website URL")),
158
- description: S.string.pipe(S.description("short summary of the company"))
141
+ name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the company or organization")),
142
+ website: import_echo_schema.S.string.pipe(import_echo_schema.S.description("public website URL")),
143
+ description: import_echo_schema.S.string.pipe(import_echo_schema.S.description("short summary of the company"))
159
144
  });
160
145
  const contact = createDynamicSchema("example.com/schema/contact", {
161
- name: S.string.pipe(S.description("name of the person")),
162
- email: S.string,
163
- org: E2.ref(organization),
164
- lat: S.number,
165
- lng: S.number
146
+ name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the person")),
147
+ email: import_echo_schema.S.string,
148
+ org: (0, import_echo_schema.ref)(organization),
149
+ lat: import_echo_schema.S.number,
150
+ lng: import_echo_schema.S.number
166
151
  });
167
152
  const project = createDynamicSchema("example.com/schema/project", {
168
- name: S.string.pipe(S.description("name of the project")),
169
- description: S.string,
170
- website: S.string,
171
- repo: S.string,
172
- status: S.string,
173
- priority: S.number,
174
- active: S.boolean,
175
- org: E2.ref(organization)
153
+ name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the project")),
154
+ description: import_echo_schema.S.string,
155
+ website: import_echo_schema.S.string,
156
+ repo: import_echo_schema.S.string,
157
+ status: import_echo_schema.S.string,
158
+ priority: import_echo_schema.S.number,
159
+ active: import_echo_schema.S.boolean,
160
+ org: (0, import_echo_schema.ref)(organization)
176
161
  });
177
162
  return {
178
163
  ["example.com/schema/document"]: document,
@@ -182,7 +167,7 @@ var testSchemas = () => {
182
167
  };
183
168
  };
184
169
  var testObjectGenerators = {
185
- ["example.com/schema/document"]: () => ({
170
+ ["example.com/schema/document"]: async () => ({
186
171
  title: import_random.faker.lorem.sentence(3),
187
172
  content: import_random.faker.lorem.sentences({
188
173
  min: 1,
@@ -192,15 +177,15 @@ var testObjectGenerators = {
192
177
  })
193
178
  })
194
179
  }),
195
- ["example.com/schema/organization"]: () => ({
180
+ ["example.com/schema/organization"]: async () => ({
196
181
  name: import_random.faker.company.name(),
197
182
  website: import_random.faker.datatype.boolean({
198
183
  probability: 0.3
199
184
  }) ? import_random.faker.internet.url() : void 0,
200
185
  description: import_random.faker.lorem.sentences()
201
186
  }),
202
- ["example.com/schema/contact"]: (provider) => {
203
- const organizations = provider?.("example.com/schema/organization");
187
+ ["example.com/schema/contact"]: async (provider) => {
188
+ const organizations = await provider?.("example.com/schema/organization");
204
189
  const location = import_random.faker.datatype.boolean() ? import_random.faker.helpers.arrayElement(locations) : void 0;
205
190
  return {
206
191
  name: import_random.faker.person.fullName(),
@@ -213,7 +198,7 @@ var testObjectGenerators = {
213
198
  ...location
214
199
  };
215
200
  },
216
- ["example.com/schema/project"]: () => ({
201
+ ["example.com/schema/project"]: async () => ({
217
202
  name: import_random.faker.commerce.productName(),
218
203
  repo: import_random.faker.datatype.boolean({
219
204
  probability: 0.3
@@ -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\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\nimport * as S from '@effect/schema/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport * as E from '@dxos/echo-schema';\nimport { DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\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/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(E.echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n E.object(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: E.ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.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: E.ref(organization),\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]: () => ({\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]: () => ({\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]: (provider) => {\n const organizations = provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: () => ({\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\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, Filter, type ReactiveObject } from '@dxos/echo-schema';\nimport * as E from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? E.object(schema, data) : E.object(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n createObjects(map: Partial<Record<T, number>>): ReactiveObject<any>[] {\n const objects: ReactiveObject<any>[] = [];\n Object.entries<number>(map as any).forEach(([type, count]) => {\n range(() => objects.push(this.createObject({ types: [type as T] })), count);\n });\n\n return objects;\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 ) {\n super(schemaMap, generators, (type: T) => {\n const schema = this.getSchema(type);\n return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n const schemas = this._space.db.schemaRegistry.getAll();\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = schemas.find((object) => object.typename === type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n const dbSchemas = this._space.db.schemaRegistry.getAll();\n this.schemas.forEach((schema) => {\n const existing = dbSchemas.find((object) => object.typename === schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;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EAAkB;EACjD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAqBE,KAAK;EAAmB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAqBE,KAAK;EAAiB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAqBE,KAAK;EAAkB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
6
- "names": ["import_echo_schema", "import_random", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "object", "createObjects", "objects", "entries", "forEach", "count", "push", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "schemaRegistry", "getAll", "dynamicSchema", "add", "addSchemas", "result", "dbSchemas", "existing", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "fields", "typeSchema", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "number", "lng", "project", "repo", "status", "priority", "active", "boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "locations", "person", "fullName", "commerce", "productName", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\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\nimport { type Space } from '@dxos/client/echo';\nimport { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\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/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.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 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.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,yBAAoG;AACpG,oBAAsB;ACLtB,kBAAmC;AAEnC,IAAAA,sBAAuB;AACvB,IAAAC,iBAAsB;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;ADQL,IAAMC,sBAAN,MAAMA;;EAEXC,YACmBC,UACAC,aACAC,WACjB;SAHiBF,WAAAA;SACAC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA+B;AACjC,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAwC;AAChD,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWA,OAAOC,aAAaH,IAAAA;EAC3D;EAEUI,UAAUJ,MAASE,QAA2B;AACtD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;;EAGA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiC;AAChF,UAAMN,OAAOO,qBAAMC,QAAQC,aAAaH,SAAUT,OAAOa,KAAK,KAAKjB,QAAQ,CAAA;AAC3E,UAAMkB,OAAO,MAAM,KAAKjB,YAAYM,IAAAA,EAAM,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AAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
6
+ "names": ["import_echo_schema", "import_random", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "schemaRegistry", "getRegisteredByTypename", "add", "addSchemas", "result", "existing", "push", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "fields", "typeSchema", "S", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "number", "lng", "project", "repo", "status", "priority", "active", "boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "locations", "person", "fullName", "commerce", "productName", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11864,"imports":[{"path":"@dxos/echo-schema","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/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35783,"imports":[{"path":"@effect/schema/Schema","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/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":993,"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/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23311},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@effect/schema/Schema","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/random","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/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10337},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2478},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13366}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"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/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35633,"imports":[{"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"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1005,"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/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23469},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"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/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10310},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2426},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13287}}}
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,gCAAgC;IACxC,YAAY,oCAAoC;IAChD,OAAO,+BAA+B;IACtC,OAAO,+BAA+B;CACvC;AAuFD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACe,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,gCAAgC;IACxC,YAAY,oCAAoC;IAChD,OAAO,+BAA+B;IACtC,OAAO,+BAA+B;CACvC;AAuFD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACe,CAAC"}
@@ -15,8 +15,8 @@ export declare class TestObjectGenerator<T extends string = TestSchemaType> {
15
15
  protected setSchema(type: T, schema: DynamicEchoSchema): void;
16
16
  createObject({ types }?: {
17
17
  types?: T[];
18
- }): ReactiveObject<any>;
19
- createObjects(map: Partial<Record<T, number>>): ReactiveObject<any>[];
18
+ }): Promise<ReactiveObject<any>>;
19
+ createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]>;
20
20
  }
21
21
  /**
22
22
  * Typed object generator for a space.
@@ -27,6 +27,6 @@ export declare class SpaceObjectGenerator<T extends string> extends TestObjectGe
27
27
  addSchemas(): DynamicEchoSchema[];
28
28
  createObject({ types }?: {
29
29
  types?: T[];
30
- }): ReactiveObject<any>;
30
+ }): Promise<ReactiveObject<any>>;
31
31
  }
32
32
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,iBAAiB,EAAU,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7F;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc;IAG9D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAFV,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAChC,SAAS,CAAC,mCAAuB;IAGpD,IAAI,OAAO,IAAI,iBAAiB,EAAE,CAEjC;IAED,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,iBAAiB,GAAG,SAAS;IAIjD,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB;IAKtD,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,cAAc,CAAC,GAAG,CAAC;IASlE,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,MAA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AiB,GAAG,SAAS;IAIjD,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB;IAKhD,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAS3E,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;CASrF;AAED;;GAEG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,KAAK,EAC9B,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAkBjC,UAAU;IAcK,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;CAG3F"}
@@ -4,5 +4,5 @@ export type TestObject = {
4
4
  } & Record<string, any>;
5
5
  export type TestSchemaMap<T extends string> = Record<T, DynamicEchoSchema>;
6
6
  export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
7
- export type TestObjectProvider<T extends string> = (type: T) => ReactiveObject<any>[];
7
+ export type TestObjectProvider<T extends string> = (type: T) => Promise<ReactiveObject<any>[]>;
8
8
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAm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"@dxos/echo-generator",
3
- "version": "0.4.10-main.b3cf40d",
3
+ "version": "0.4.10-main.bb9f1bf",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -16,12 +16,10 @@
16
16
  "src"
17
17
  ],
18
18
  "dependencies": {
19
- "@effect/schema": "0.64.7",
20
- "effect": "2.4.9",
21
- "@dxos/client": "0.4.10-main.b3cf40d",
22
- "@dxos/echo-schema": "0.4.10-main.b3cf40d",
23
- "@dxos/node-std": "0.4.10-main.b3cf40d",
24
- "@dxos/random": "0.4.10-main.b3cf40d"
19
+ "@dxos/echo-schema": "0.4.10-main.bb9f1bf",
20
+ "@dxos/client": "0.4.10-main.bb9f1bf",
21
+ "@dxos/node-std": "0.4.10-main.bb9f1bf",
22
+ "@dxos/random": "0.4.10-main.bb9f1bf"
25
23
  },
26
24
  "devDependencies": {},
27
25
  "publishConfig": {
package/src/data.ts CHANGED
@@ -5,11 +5,8 @@
5
5
  // TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.
6
6
  // TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).
7
7
 
8
- import * as S from '@effect/schema/Schema';
9
-
10
8
  import { type Space } from '@dxos/client/echo';
11
- import * as E from '@dxos/echo-schema';
12
- import { DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema } from '@dxos/echo-schema';
9
+ import { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';
13
10
  import { faker } from '@dxos/random';
14
11
 
15
12
  import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
@@ -27,9 +24,9 @@ export enum TestSchemaType {
27
24
  }
28
25
 
29
26
  const createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {
30
- const typeSchema = S.partial(S.struct(fields)).pipe(E.echoObject(typename, '1.0.0'));
27
+ const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));
31
28
  return new DynamicEchoSchema(
32
- E.object(StoredEchoSchema, {
29
+ create(StoredEchoSchema, {
33
30
  typename,
34
31
  version: '1.0.0',
35
32
  jsonSchema: effectToJsonSchema(typeSchema),
@@ -52,7 +49,7 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
52
49
  const contact = createDynamicSchema(TestSchemaType.contact, {
53
50
  name: S.string.pipe(S.description('name of the person')),
54
51
  email: S.string,
55
- org: E.ref(organization),
52
+ org: ref(organization),
56
53
  lat: S.number,
57
54
  lng: S.number,
58
55
  });
@@ -65,7 +62,7 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
65
62
  status: S.string,
66
63
  priority: S.number,
67
64
  active: S.boolean,
68
- org: E.ref(organization),
65
+ org: ref(organization),
69
66
  });
70
67
 
71
68
  return {
@@ -77,19 +74,19 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
77
74
  };
78
75
 
79
76
  const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
80
- [TestSchemaType.document]: () => ({
77
+ [TestSchemaType.document]: async () => ({
81
78
  title: faker.lorem.sentence(3),
82
79
  content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),
83
80
  }),
84
81
 
85
- [TestSchemaType.organization]: () => ({
82
+ [TestSchemaType.organization]: async () => ({
86
83
  name: faker.company.name(),
87
84
  website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
88
85
  description: faker.lorem.sentences(),
89
86
  }),
90
87
 
91
- [TestSchemaType.contact]: (provider) => {
92
- const organizations = provider?.(TestSchemaType.organization);
88
+ [TestSchemaType.contact]: async (provider) => {
89
+ const organizations = await provider?.(TestSchemaType.organization);
93
90
  const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;
94
91
  return {
95
92
  name: faker.person.fullName(),
@@ -102,7 +99,7 @@ const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
102
99
  };
103
100
  },
104
101
 
105
- [TestSchemaType.project]: () => ({
102
+ [TestSchemaType.project]: async () => ({
106
103
  name: faker.commerce.productName(),
107
104
  repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
108
105
  status: faker.helpers.arrayElement(Status),
@@ -5,8 +5,7 @@
5
5
  import { expect } from 'chai';
6
6
 
7
7
  import { Client } from '@dxos/client';
8
- import { debug } from '@dxos/client/echo';
9
- import * as E from '@dxos/echo-schema';
8
+ import { getType } from '@dxos/echo-schema';
10
9
  import { faker } from '@dxos/random';
11
10
  import { afterTest, describe, test } from '@dxos/test';
12
11
 
@@ -15,11 +14,11 @@ import { createSpaceObjectGenerator, createTestObjectGenerator, TestSchemaType }
15
14
  faker.seed(3);
16
15
 
17
16
  describe('TestObjectGenerator', () => {
18
- test('basic', () => {
17
+ test('basic', async () => {
19
18
  const generator = createTestObjectGenerator();
20
19
 
21
20
  // Create raw object.
22
- const object = generator.createObject({ types: [TestSchemaType.contact] });
21
+ const object = await generator.createObject({ types: [TestSchemaType.contact] });
23
22
  expect(object).to.exist;
24
23
  });
25
24
 
@@ -30,11 +29,11 @@ describe('TestObjectGenerator', () => {
30
29
  generator.addSchemas();
31
30
 
32
31
  // Create org object.
33
- const organization = generator.createObject({ types: [TestSchemaType.organization] });
34
- expect(E.typeOf(organization)).to.exist;
32
+ const organization = await generator.createObject({ types: [TestSchemaType.organization] });
33
+ expect(getType(organization)).to.exist;
35
34
 
36
35
  // Expect at least one person object with a linked org reference.
37
- const objects = generator.createObjects({ [TestSchemaType.contact]: 10 });
36
+ const objects = await generator.createObjects({ [TestSchemaType.contact]: 10 });
38
37
  expect(objects.some((object) => object.org === organization)).to.be.true;
39
38
  });
40
39
 
@@ -46,23 +45,19 @@ describe('TestObjectGenerator', () => {
46
45
  {
47
46
  const generator = createSpaceObjectGenerator(space);
48
47
  generator.addSchemas();
49
- const organization = generator.createObject({ types: [TestSchemaType.organization] });
50
- schemaId.push(E.typeOf(organization)!.itemId);
48
+ const organization = await generator.createObject({ types: [TestSchemaType.organization] });
49
+ schemaId.push(getType(organization)!.itemId);
51
50
  }
52
51
 
53
52
  {
54
53
  const generator = createSpaceObjectGenerator(space);
55
54
  generator.addSchemas();
56
- const organization = generator.createObject({ types: [TestSchemaType.organization] });
57
- schemaId.push(E.typeOf(organization)!.itemId);
55
+ const organization = await generator.createObject({ types: [TestSchemaType.organization] });
56
+ schemaId.push(getType(organization)!.itemId);
58
57
  }
59
58
 
60
59
  expect(schemaId[0]).not.to.be.undefined;
61
60
  expect(schemaId[0]).to.eq(schemaId[1]);
62
-
63
- {
64
- console.log(space.db.objects.map((object) => object[debug]));
65
- }
66
61
  });
67
62
 
68
63
  const setupTest = async () => {
package/src/generator.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Space } from '@dxos/client/echo';
6
- import { type DynamicEchoSchema, Filter, type ReactiveObject } from '@dxos/echo-schema';
7
- import * as E from '@dxos/echo-schema';
5
+ import { type Space, Filter } from '@dxos/client/echo';
6
+ import { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';
7
+ import { create } from '@dxos/echo-schema';
8
8
  import { faker } from '@dxos/random';
9
9
 
10
10
  import { type TestSchemaType } from './data';
@@ -35,22 +35,23 @@ export class TestObjectGenerator<T extends string = TestSchemaType> {
35
35
  }
36
36
 
37
37
  // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).
38
- createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {
38
+ async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {
39
39
  const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));
40
- const data = this._generators[type](this._provider);
40
+ const data = await this._generators[type](this._provider);
41
41
  const schema = this.getSchema(type);
42
- return schema ? E.object(schema, data) : E.object(data);
42
+ return schema ? create(schema, data) : create(data);
43
43
  }
44
44
 
45
45
  // TODO(burdon): Create batch.
46
46
  // TODO(burdon): Based on dependencies (e.g., organization before contact).
47
- createObjects(map: Partial<Record<T, number>>): ReactiveObject<any>[] {
48
- const objects: ReactiveObject<any>[] = [];
49
- Object.entries<number>(map as any).forEach(([type, count]) => {
50
- range(() => objects.push(this.createObject({ types: [type as T] })), count);
51
- });
47
+ async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {
48
+ const tasks = Object.entries<number>(map as any)
49
+ .map(([type, count]) => {
50
+ return range(() => this.createObject({ types: [type as T] }), count);
51
+ })
52
+ .flatMap((t) => t);
52
53
 
53
- return objects;
54
+ return Promise.all(tasks);
54
55
  }
55
56
  }
56
57
 
@@ -63,16 +64,15 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
63
64
  schemaMap: TestSchemaMap<T>,
64
65
  generators: TestGeneratorMap<T>,
65
66
  ) {
66
- super(schemaMap, generators, (type: T) => {
67
+ super(schemaMap, generators, async (type: T) => {
67
68
  const schema = this.getSchema(type);
68
- return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];
69
+ return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];
69
70
  });
70
71
 
71
72
  // TODO(burdon): Map initially are objects that have not been added to the space.
72
73
  // Merge existing schema in space with defaults.
73
- const schemas = this._space.db.schemaRegistry.getAll();
74
74
  Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {
75
- let schema = schemas.find((object) => object.typename === type);
75
+ let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);
76
76
  if (schema == null) {
77
77
  schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);
78
78
  }
@@ -82,9 +82,8 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
82
82
 
83
83
  addSchemas() {
84
84
  const result: DynamicEchoSchema[] = [];
85
- const dbSchemas = this._space.db.schemaRegistry.getAll();
86
85
  this.schemas.forEach((schema) => {
87
- const existing = dbSchemas.find((object) => object.typename === schema.typename);
86
+ const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);
88
87
  if (existing == null) {
89
88
  result.push(this._space.db.schemaRegistry.add(schema.schema));
90
89
  } else {
@@ -95,7 +94,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
95
94
  return result;
96
95
  }
97
96
 
98
- override createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {
99
- return this._space.db.add(super.createObject({ types }));
97
+ override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {
98
+ return this._space.db.add(await super.createObject({ types }));
100
99
  }
101
100
  }
package/src/types.ts CHANGED
@@ -10,4 +10,4 @@ export type TestSchemaMap<T extends string> = Record<T, DynamicEchoSchema>;
10
10
 
11
11
  export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
12
12
 
13
- export type TestObjectProvider<T extends string> = (type: T) => ReactiveObject<any>[];
13
+ export type TestObjectProvider<T extends string> = (type: T) => Promise<ReactiveObject<any>[]>;