@dxos/echo-generator 0.3.6 → 0.3.7-main.0ee8374

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.
@@ -2,11 +2,11 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/core/echo/echo-generator/src/data.ts
4
4
  import { faker as faker2 } from "@faker-js/faker";
5
- import { Schema, TextObject } from "@dxos/client/echo";
5
+ import { Schema as Schema2, TextObject } from "@dxos/client/echo";
6
6
 
7
7
  // packages/core/echo/echo-generator/src/generator.ts
8
8
  import { faker } from "@faker-js/faker";
9
- import { Expando } from "@dxos/client/echo";
9
+ import { Expando, Schema } from "@dxos/client/echo";
10
10
 
11
11
  // packages/core/echo/echo-generator/src/util.ts
12
12
  var range = (fn, length) => Array.from({
@@ -29,28 +29,34 @@ var TestObjectGenerator = class {
29
29
  }
30
30
  createObject({ types } = {}) {
31
31
  const type = faker.helpers.arrayElement(types ?? Object.keys(this.schema));
32
- const factory = this._generators[type];
33
- const data = factory(this._provider);
32
+ const data = this._generators[type](this._provider);
34
33
  return new Expando(data, {
35
34
  schema: this.schema[type]
36
35
  });
37
36
  }
38
37
  // TODO(burdon): Create batch.
39
- createObjects({ types, count }) {
40
- return range(() => this.createObject({
41
- types
42
- }), count);
38
+ // TODO(burdon): Based on dependencies (e.g., organization before contact).
39
+ createObjects(map) {
40
+ const objects = [];
41
+ Object.entries(map).forEach(([type, count]) => {
42
+ range(() => objects.push(this.createObject({
43
+ types: [
44
+ type
45
+ ]
46
+ })), count);
47
+ });
48
+ return objects;
43
49
  }
44
50
  };
45
51
  var SpaceObjectGenerator = class extends TestObjectGenerator {
46
- constructor(_space, schema, generators) {
47
- super(schema, generators, (type) => {
52
+ constructor(space, schemaMap, generators) {
53
+ super(mergeSchemaMap(space, schemaMap), generators, (type) => {
48
54
  const { objects } = this._space.db.query((object) => {
49
- return object.__schema === schema[type];
55
+ return object.__schema === schemaMap[type];
50
56
  });
51
57
  return objects;
52
58
  });
53
- this._space = _space;
59
+ this._space = space;
54
60
  }
55
61
  addSchemas() {
56
62
  this.schemas.forEach((schema) => this._space.db.add(schema));
@@ -62,6 +68,16 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
62
68
  }));
63
69
  }
64
70
  };
71
+ var mergeSchemaMap = (space, schemaMap) => {
72
+ const { objects } = space.db.query(Schema.filter());
73
+ Object.keys(schemaMap).forEach((type) => {
74
+ const schema = objects.find((object) => object.typename === type);
75
+ if (schema) {
76
+ schemaMap[type] = schema;
77
+ }
78
+ });
79
+ return schemaMap;
80
+ };
65
81
 
66
82
  // packages/core/echo/echo-generator/src/data.ts
67
83
  var Status = [
@@ -76,101 +92,109 @@ var Priority = [
76
92
  4,
77
93
  5
78
94
  ];
95
+ var TestSchemaType;
96
+ (function(TestSchemaType2) {
97
+ TestSchemaType2["document"] = "example.com/schema/document";
98
+ TestSchemaType2["organization"] = "example.com/schema/organization";
99
+ TestSchemaType2["contact"] = "example.com/schema/contact";
100
+ TestSchemaType2["project"] = "example.com/schema/project";
101
+ })(TestSchemaType || (TestSchemaType = {}));
79
102
  var testSchemas = () => {
80
- const document = new Schema({
103
+ const document = new Schema2({
104
+ typename: TestSchemaType.document,
81
105
  props: [
82
106
  {
83
107
  id: "name",
84
- type: Schema.PropType.STRING
108
+ type: Schema2.PropType.STRING
85
109
  },
86
110
  {
87
111
  id: "content",
88
- type: Schema.PropType.STRING
112
+ type: Schema2.PropType.STRING
89
113
  }
90
114
  ]
91
115
  });
92
- const organization = new Schema({
93
- typename: "example.com/schema/organization",
116
+ const organization = new Schema2({
117
+ typename: TestSchemaType.organization,
94
118
  props: [
95
119
  {
96
120
  id: "name",
97
- type: Schema.PropType.STRING
121
+ type: Schema2.PropType.STRING
98
122
  },
99
123
  {
100
124
  id: "website",
101
- type: Schema.PropType.STRING
125
+ type: Schema2.PropType.STRING
102
126
  },
103
127
  {
104
128
  id: "description",
105
- type: Schema.PropType.STRING
129
+ type: Schema2.PropType.STRING
106
130
  }
107
131
  ]
108
132
  });
109
- const person = new Schema({
110
- typename: "example.com/schema/person",
133
+ const contact = new Schema2({
134
+ typename: TestSchemaType.contact,
111
135
  props: [
112
136
  {
113
137
  id: "name",
114
- type: Schema.PropType.STRING
138
+ type: Schema2.PropType.STRING
115
139
  },
116
140
  {
117
141
  id: "email",
118
- type: Schema.PropType.STRING
142
+ type: Schema2.PropType.STRING
119
143
  },
120
144
  {
121
145
  id: "org",
122
- type: Schema.PropType.REF,
146
+ type: Schema2.PropType.REF,
123
147
  ref: organization
124
148
  },
125
149
  // TODO(burdon): Convert to object with nested props.
126
150
  {
127
151
  id: "lat",
128
- type: Schema.PropType.NUMBER
152
+ type: Schema2.PropType.NUMBER
129
153
  },
130
154
  {
131
155
  id: "lng",
132
- type: Schema.PropType.NUMBER
156
+ type: Schema2.PropType.NUMBER
133
157
  }
134
158
  ]
135
159
  });
136
- const project = new Schema({
137
- typename: "example.com/schema/project",
160
+ const project = new Schema2({
161
+ typename: TestSchemaType.project,
138
162
  props: [
139
163
  {
140
164
  id: "title",
141
- type: Schema.PropType.STRING
165
+ type: Schema2.PropType.STRING
142
166
  },
143
167
  {
144
168
  id: "description",
145
- type: Schema.PropType.STRING
169
+ type: Schema2.PropType.STRING
146
170
  },
147
171
  {
148
172
  id: "repo",
149
- type: Schema.PropType.STRING
173
+ type: Schema2.PropType.STRING
150
174
  },
151
175
  {
152
176
  id: "status",
153
- type: Schema.PropType.STRING
177
+ type: Schema2.PropType.STRING
154
178
  },
155
179
  {
156
180
  id: "priority",
157
- type: Schema.PropType.NUMBER
181
+ type: Schema2.PropType.NUMBER
158
182
  },
159
183
  {
160
184
  id: "active",
161
- type: Schema.PropType.BOOLEAN
185
+ type: Schema2.PropType.BOOLEAN
162
186
  }
163
187
  ]
164
188
  });
165
189
  return {
166
- document,
167
- organization,
168
- person,
169
- project
190
+ [TestSchemaType.document]: document,
191
+ [TestSchemaType.organization]: organization,
192
+ [TestSchemaType.contact]: contact,
193
+ [TestSchemaType.project]: project
170
194
  };
171
195
  };
172
196
  var testObjectGenerators = {
173
- document: () => ({
197
+ [TestSchemaType.document]: () => ({
174
198
  title: faker2.lorem.sentence(3),
175
199
  content: faker2.lorem.sentences({
176
200
  min: 1,
@@ -180,15 +204,15 @@ var testObjectGenerators = {
180
204
  })
181
205
  })
182
206
  }),
183
- organization: () => ({
207
+ [TestSchemaType.organization]: () => ({
184
208
  name: faker2.company.name(),
185
209
  website: faker2.datatype.boolean({
186
210
  probability: 0.3
187
211
  }) ? faker2.internet.url() : void 0,
188
212
  description: new TextObject(faker2.lorem.sentences())
189
213
  }),
190
- person: (provider) => {
191
- const organizations = provider?.("organization");
214
+ [TestSchemaType.contact]: (provider) => {
215
+ const organizations = provider?.(TestSchemaType.organization);
192
216
  const location = faker2.datatype.boolean() ? faker2.helpers.arrayElement(locations) : void 0;
193
217
  return {
194
218
  name: faker2.person.fullName(),
@@ -201,7 +225,7 @@ var testObjectGenerators = {
201
225
  ...location
202
226
  };
203
227
  },
204
- project: () => ({
228
+ [TestSchemaType.project]: () => ({
205
229
  title: faker2.commerce.productName(),
206
230
  repo: faker2.datatype.boolean({
207
231
  probability: 0.3
@@ -606,13 +630,13 @@ var locations = [
606
630
  lat: 3.048606670909237,
607
631
  lng: 36.765010656628135
608
632
  },
609
- {
610
- lat: 12.481312562873995,
611
- lng: 41.89790148509894
612
- },
613
633
  {
614
634
  lat: 125.75274485499392,
615
635
  lng: 39.02138455800434
636
+ },
637
+ {
638
+ lat: 12.481312562873995,
639
+ lng: 41.89790148509894
616
640
  }
617
641
  ];
618
642
  export {
@@ -620,6 +644,7 @@ export {
620
644
  SpaceObjectGenerator,
621
645
  Status,
622
646
  TestObjectGenerator,
647
+ TestSchemaType,
623
648
  createSpaceObjectGenerator,
624
649
  createTestObjectGenerator,
625
650
  range,
@@ -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 { faker } from '@faker-js/faker';\n\nimport { Schema, type Space, TextObject } from '@dxos/client/echo';\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 type TestSchemaType = 'document' | 'organization' | 'person' | 'project';\n\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n // TODO(burdon): primary: true,\n },\n {\n id: 'content',\n type: Schema.PropType.STRING, // TODO(burdon): Rich text.\n },\n ],\n });\n\n const organization = new Schema({\n typename: 'example.com/schema/organization',\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING,\n },\n ],\n });\n\n const person = new Schema({\n typename: 'example.com/schema/person',\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'email',\n type: Schema.PropType.STRING,\n },\n {\n id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\n },\n // TODO(burdon): Convert to object with nested props.\n {\n id: 'lat',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'lng',\n type: Schema.PropType.NUMBER,\n },\n ],\n });\n\n const project = new Schema({\n typename: 'example.com/schema/project',\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING, // TODO(burdon): Text.\n },\n {\n id: 'repo',\n type: Schema.PropType.STRING,\n },\n {\n id: 'status',\n type: Schema.PropType.STRING,\n },\n {\n id: 'priority',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'active',\n type: Schema.PropType.BOOLEAN,\n },\n ],\n });\n\n return { document, organization, person, project };\n};\n\nexport const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n 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 organization: () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: new TextObject(faker.lorem.sentences()),\n }),\n\n person: (provider) => {\n const organizations = provider?.('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 project: () => ({\n title: 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\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: 12.481312562873995, lng: 41.89790148509894 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n];\n", "//\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 { faker } from '@faker-js/faker';\n\nimport { Expando, type Schema, type Space } from '@dxos/client/echo';\n\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> {\n // prettier-ignore\n constructor(\n public readonly schema: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this.schema);\n }\n\n getSchema(typename: string) {\n return this.schemas.find((schema) => schema.typename === typename);\n }\n\n createObject({ types }: { types?: T[] } = {}): Expando {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));\n const factory = this._generators[type];\n const data = factory(this._provider);\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n return new Expando(data, { schema: this.schema[type] });\n }\n\n // TODO(burdon): Create batch.\n createObjects({ types, count }: { types?: T[]; count: number }): Expando[] {\n return range(() => this.createObject({ types }), count);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(private readonly _space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {\n super(schema, generators, (type: T) => {\n // TODO(burdon): Query by schema.\n const { objects } = this._space.db.query((object) => {\n return object.__schema === schema[type];\n });\n\n return objects;\n });\n }\n\n addSchemas() {\n this.schemas.forEach((schema) => this._space.db.add(schema));\n return this.schemas;\n }\n\n override createObject({ types }: { types?: T[] } = {}): Expando {\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,SAASA,SAAAA,cAAa;AAEtB,SAASC,QAAoBC,kBAAkB;;;ACF/C,SAASC,aAAa;AAEtB,SAASC,eAAwC;;;ACJ1C,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADSL,IAAMC,sBAAN,MAAMA;;EAEXC,YACkBC,QACCC,aACAC,WACjB;kBAHgBF;uBACCC;qBACAC;EAChB;EAEH,IAAIC,UAAoB;AACtB,WAAOC,OAAOC,OAAO,KAAKL,MAAM;EAClC;EAEAM,UAAUC,UAAkB;AAC1B,WAAO,KAAKJ,QAAQK,KAAK,CAACR,WAAWA,OAAOO,aAAaA,QAAAA;EAC3D;EAEAE,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAY;AACrD,UAAMC,OAAOC,MAAMC,QAAQC,aAAaJ,SAAUN,OAAOW,KAAK,KAAKf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K;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;;",
6
- "names": ["faker", "Schema", "TextObject", "faker", "Expando", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "schema", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "typename", "find", "createObject", "types", "type", "faker", "helpers", "arrayElement", "keys", "factory", "data", "Expando", "createObjects", "count", "range", "SpaceObjectGenerator", "_space", "generators", "objects", "db", "query", "object", "__schema", "addSchemas", "forEach", "add", "Status", "Priority", "testSchemas", "document", "Schema", "props", "id", "type", "PropType", "STRING", "organization", "typename", "person", "REF", "ref", "NUMBER", "project", "BOOLEAN", "testObjectGenerators", "title", "faker", "lorem", "sentence", "content", "sentences", "min", "max", "number", "int", "name", "company", "website", "datatype", "boolean", "probability", "internet", "url", "undefined", "description", "TextObject", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "fullName", "email", "org", "length", "commerce", "productName", "repo", "status", "priority", "active", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator", "lat", "lng"]
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 { faker } from '@faker-js/faker';\n\nimport { Schema, type Space, TextObject } from '@dxos/client/echo';\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\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n typename: TestSchemaType.document,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'content',\n type: Schema.PropType.STRING, // TODO(burdon): Rich text.\n },\n ],\n });\n\n const organization = new Schema({\n typename: TestSchemaType.organization,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING,\n },\n ],\n });\n\n const contact = new Schema({\n typename: TestSchemaType.contact,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'email',\n type: Schema.PropType.STRING,\n },\n {\n id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\n },\n // TODO(burdon): Convert to object with nested props.\n {\n id: 'lat',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'lng',\n type: Schema.PropType.NUMBER,\n },\n ],\n });\n\n const project = new Schema({\n typename: TestSchemaType.project,\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING, // TODO(burdon): Text.\n },\n {\n id: 'repo',\n type: Schema.PropType.STRING,\n },\n {\n id: 'status',\n type: Schema.PropType.STRING,\n },\n {\n id: 'priority',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'active',\n type: Schema.PropType.BOOLEAN,\n },\n ],\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nexport const 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: new TextObject(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 title: 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\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\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 { faker } from '@faker-js/faker';\n\nimport { Expando, type TypedObject, Schema, type Space } from '@dxos/client/echo';\n\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> {\n // prettier-ignore\n constructor(\n public readonly schema: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this.schema);\n }\n\n getSchema(typename: string) {\n return this.schemas.find((schema) => schema.typename === typename);\n }\n\n createObject({ types }: { types?: T[] } = {}): TypedObject {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));\n const data = this._generators[type](this._provider);\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n return new Expando(data, { schema: this.schema[type] });\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>>): Expando[] {\n const objects: Expando[] = [];\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 private readonly _space: Space;\n\n constructor(space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {\n super(mergeSchemaMap(space, schemaMap), generators, (type: T) => {\n const { objects } = this._space.db.query((object) => {\n return object.__schema === schemaMap[type];\n });\n\n return objects;\n });\n\n this._space = space;\n }\n\n addSchemas() {\n this.schemas.forEach((schema) => this._space.db.add(schema));\n return this.schemas;\n }\n\n override createObject({ types }: { types?: T[] } = {}): Expando {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n\n/**\n * Merge existing schema in space with defaults.\n */\nconst mergeSchemaMap = <T extends string>(space: Space, schemaMap: TestSchemaMap<T>) => {\n const { objects } = space.db.query(Schema.filter());\n Object.keys(schemaMap).forEach((type) => {\n const schema = objects.find((object) => object.typename === type);\n if (schema) {\n (schemaMap as any)[type] = schema;\n }\n });\n\n return schemaMap;\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,SAASA,SAAAA,cAAa;AAEtB,SAASC,UAAAA,SAAoBC,kBAAkB;;;ACF/C,SAASC,aAAa;AAEtB,SAASC,SAA2BC,cAA0B;;;ACJvD,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADSL,IAAMC,sBAAN,MAAMA;;EAEXC,YACkBC,QACCC,aACAC,WACjB;kBAHgBF;uBACCC;qBACAC;EAChB;EAEH,IAAIC,UAAoB;AACtB,WAAOC,OAAOC,OAAO,KAAKL,MAAM;EAClC;EAEAM,UAAUC,UAAkB;AAC1B,WAAO,KAAKJ,QAAQK,KAAK,CAACR,WAAWA,OAAOO,aAAaA,QAAAA;EAC3D;EAEAE,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAgB;AACzD,UAAMC,OAAOC,MAAMC,QAAQC,aAAaJ,S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;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAASC,KAAK;EAAiB;EACtC;IAAED,KAAK;IAAmBC,KAAK;EAAkB;EACjD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAqBC,KAAK;EAAmB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAqBC,KAAK;EAAiB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAqBC,KAAK;EAAkB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;;",
6
+ "names": ["faker", "Schema", "TextObject", "faker", "Expando", "Schema", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "schema", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "typename", "find", "createObject", "types", "type", "faker", "helpers", "arrayElement", "keys", "data", "Expando", "createObjects", "map", "objects", "entries", "forEach", "count", "range", "push", "SpaceObjectGenerator", "space", "schemaMap", "generators", "mergeSchemaMap", "_space", "db", "query", "object", "__schema", "addSchemas", "add", "Schema", "filter", "Status", "Priority", "TestSchemaType", "document", "organization", "contact", "project", "testSchemas", "Schema", "typename", "props", "id", "type", "PropType", "STRING", "REF", "ref", "NUMBER", "BOOLEAN", "testObjectGenerators", "title", "faker", "lorem", "sentence", "content", "sentences", "min", "max", "number", "int", "name", "company", "website", "datatype", "boolean", "probability", "internet", "url", "undefined", "description", "TextObject", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "email", "org", "length", "commerce", "productName", "repo", "status", "priority", "active", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator", "lat", "lng"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1052,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":7902,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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":35584,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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/index.ts":{"bytes":629,"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/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20976},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","createSpaceObjectGenerator","createTestObjectGenerator","range","testObjectGenerators","testSchemas"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":9993},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":1422},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":12021}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":10093,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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":37173,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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/index.ts":{"bytes":634,"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/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22908},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range","testObjectGenerators","testSchemas"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10590},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":1943},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13157}}}
@@ -24,6 +24,7 @@ __export(src_exports, {
24
24
  SpaceObjectGenerator: () => SpaceObjectGenerator,
25
25
  Status: () => Status,
26
26
  TestObjectGenerator: () => TestObjectGenerator,
27
+ TestSchemaType: () => TestSchemaType,
27
28
  createSpaceObjectGenerator: () => createSpaceObjectGenerator,
28
29
  createTestObjectGenerator: () => createTestObjectGenerator,
29
30
  range: () => range,
@@ -61,28 +62,34 @@ var TestObjectGenerator = class {
61
62
  }
62
63
  createObject({ types } = {}) {
63
64
  const type = import_faker.faker.helpers.arrayElement(types ?? Object.keys(this.schema));
64
- const factory = this._generators[type];
65
- const data = factory(this._provider);
65
+ const data = this._generators[type](this._provider);
66
66
  return new import_echo.Expando(data, {
67
67
  schema: this.schema[type]
68
68
  });
69
69
  }
70
70
  // TODO(burdon): Create batch.
71
- createObjects({ types, count }) {
72
- return range(() => this.createObject({
73
- types
74
- }), count);
71
+ // TODO(burdon): Based on dependencies (e.g., organization before contact).
72
+ createObjects(map) {
73
+ const objects = [];
74
+ Object.entries(map).forEach(([type, count]) => {
75
+ range(() => objects.push(this.createObject({
76
+ types: [
77
+ type
78
+ ]
79
+ })), count);
80
+ });
81
+ return objects;
75
82
  }
76
83
  };
77
84
  var SpaceObjectGenerator = class extends TestObjectGenerator {
78
- constructor(_space, schema, generators) {
79
- super(schema, generators, (type) => {
85
+ constructor(space, schemaMap, generators) {
86
+ super(mergeSchemaMap(space, schemaMap), generators, (type) => {
80
87
  const { objects } = this._space.db.query((object) => {
81
- return object.__schema === schema[type];
88
+ return object.__schema === schemaMap[type];
82
89
  });
83
90
  return objects;
84
91
  });
85
- this._space = _space;
92
+ this._space = space;
86
93
  }
87
94
  addSchemas() {
88
95
  this.schemas.forEach((schema) => this._space.db.add(schema));
@@ -94,6 +101,16 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
94
101
  }));
95
102
  }
96
103
  };
104
+ var mergeSchemaMap = (space, schemaMap) => {
105
+ const { objects } = space.db.query(import_echo.Schema.filter());
106
+ Object.keys(schemaMap).forEach((type) => {
107
+ const schema = objects.find((object) => object.typename === type);
108
+ if (schema) {
109
+ schemaMap[type] = schema;
110
+ }
111
+ });
112
+ return schemaMap;
113
+ };
97
114
 
98
115
  // packages/core/echo/echo-generator/src/data.ts
99
116
  var Status = [
@@ -108,8 +125,16 @@ var Priority = [
108
125
  4,
109
126
  5
110
127
  ];
128
+ var TestSchemaType;
129
+ (function(TestSchemaType2) {
130
+ TestSchemaType2["document"] = "example.com/schema/document";
131
+ TestSchemaType2["organization"] = "example.com/schema/organization";
132
+ TestSchemaType2["contact"] = "example.com/schema/contact";
133
+ TestSchemaType2["project"] = "example.com/schema/project";
134
+ })(TestSchemaType || (TestSchemaType = {}));
111
135
  var testSchemas = () => {
112
136
  const document = new import_echo2.Schema({
137
+ typename: TestSchemaType.document,
113
138
  props: [
114
139
  {
115
140
  id: "name",
@@ -122,7 +147,7 @@ var testSchemas = () => {
122
147
  ]
123
148
  });
124
149
  const organization = new import_echo2.Schema({
125
- typename: "example.com/schema/organization",
150
+ typename: TestSchemaType.organization,
126
151
  props: [
127
152
  {
128
153
  id: "name",
@@ -138,8 +163,8 @@ var testSchemas = () => {
138
163
  }
139
164
  ]
140
165
  });
141
- const person = new import_echo2.Schema({
142
- typename: "example.com/schema/person",
166
+ const contact = new import_echo2.Schema({
167
+ typename: TestSchemaType.contact,
143
168
  props: [
144
169
  {
145
170
  id: "name",
@@ -166,7 +191,7 @@ var testSchemas = () => {
166
191
  ]
167
192
  });
168
193
  const project = new import_echo2.Schema({
169
- typename: "example.com/schema/project",
194
+ typename: TestSchemaType.project,
170
195
  props: [
171
196
  {
172
197
  id: "title",
@@ -195,14 +220,14 @@ var testSchemas = () => {
195
220
  ]
196
221
  });
197
222
  return {
198
- document,
199
- organization,
200
- person,
201
- project
223
+ [TestSchemaType.document]: document,
224
+ [TestSchemaType.organization]: organization,
225
+ [TestSchemaType.contact]: contact,
226
+ [TestSchemaType.project]: project
202
227
  };
203
228
  };
204
229
  var testObjectGenerators = {
205
- document: () => ({
230
+ [TestSchemaType.document]: () => ({
206
231
  title: import_faker2.faker.lorem.sentence(3),
207
232
  content: import_faker2.faker.lorem.sentences({
208
233
  min: 1,
@@ -212,15 +237,15 @@ var testObjectGenerators = {
212
237
  })
213
238
  })
214
239
  }),
215
- organization: () => ({
240
+ [TestSchemaType.organization]: () => ({
216
241
  name: import_faker2.faker.company.name(),
217
242
  website: import_faker2.faker.datatype.boolean({
218
243
  probability: 0.3
219
244
  }) ? import_faker2.faker.internet.url() : void 0,
220
245
  description: new import_echo2.TextObject(import_faker2.faker.lorem.sentences())
221
246
  }),
222
- person: (provider) => {
223
- const organizations = provider?.("organization");
247
+ [TestSchemaType.contact]: (provider) => {
248
+ const organizations = provider?.(TestSchemaType.organization);
224
249
  const location = import_faker2.faker.datatype.boolean() ? import_faker2.faker.helpers.arrayElement(locations) : void 0;
225
250
  return {
226
251
  name: import_faker2.faker.person.fullName(),
@@ -233,7 +258,7 @@ var testObjectGenerators = {
233
258
  ...location
234
259
  };
235
260
  },
236
- project: () => ({
261
+ [TestSchemaType.project]: () => ({
237
262
  title: import_faker2.faker.commerce.productName(),
238
263
  repo: import_faker2.faker.datatype.boolean({
239
264
  probability: 0.3
@@ -638,13 +663,13 @@ var locations = [
638
663
  lat: 3.048606670909237,
639
664
  lng: 36.765010656628135
640
665
  },
641
- {
642
- lat: 12.481312562873995,
643
- lng: 41.89790148509894
644
- },
645
666
  {
646
667
  lat: 125.75274485499392,
647
668
  lng: 39.02138455800434
669
+ },
670
+ {
671
+ lat: 12.481312562873995,
672
+ lng: 41.89790148509894
648
673
  }
649
674
  ];
650
675
  // Annotate the CommonJS export names for ESM import in node:
@@ -653,6 +678,7 @@ var locations = [
653
678
  SpaceObjectGenerator,
654
679
  Status,
655
680
  TestObjectGenerator,
681
+ TestSchemaType,
656
682
  createSpaceObjectGenerator,
657
683
  createTestObjectGenerator,
658
684
  range,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts", "../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from './data';\nexport * from './generator';\nexport * from './util';\n", "//\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 { faker } from '@faker-js/faker';\n\nimport { Schema, type Space, TextObject } from '@dxos/client/echo';\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 type TestSchemaType = 'document' | 'organization' | 'person' | 'project';\n\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n // TODO(burdon): primary: true,\n },\n {\n id: 'content',\n type: Schema.PropType.STRING, // TODO(burdon): Rich text.\n },\n ],\n });\n\n const organization = new Schema({\n typename: 'example.com/schema/organization',\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING,\n },\n ],\n });\n\n const person = new Schema({\n typename: 'example.com/schema/person',\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'email',\n type: Schema.PropType.STRING,\n },\n {\n id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\n },\n // TODO(burdon): Convert to object with nested props.\n {\n id: 'lat',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'lng',\n type: Schema.PropType.NUMBER,\n },\n ],\n });\n\n const project = new Schema({\n typename: 'example.com/schema/project',\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING, // TODO(burdon): Text.\n },\n {\n id: 'repo',\n type: Schema.PropType.STRING,\n },\n {\n id: 'status',\n type: Schema.PropType.STRING,\n },\n {\n id: 'priority',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'active',\n type: Schema.PropType.BOOLEAN,\n },\n ],\n });\n\n return { document, organization, person, project };\n};\n\nexport const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n 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 organization: () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: new TextObject(faker.lorem.sentences()),\n }),\n\n person: (provider) => {\n const organizations = provider?.('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 project: () => ({\n title: 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\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: 12.481312562873995, lng: 41.89790148509894 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n];\n", "//\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 { faker } from '@faker-js/faker';\n\nimport { Expando, type Schema, type Space } from '@dxos/client/echo';\n\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> {\n // prettier-ignore\n constructor(\n public readonly schema: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this.schema);\n }\n\n getSchema(typename: string) {\n return this.schemas.find((schema) => schema.typename === typename);\n }\n\n createObject({ types }: { types?: T[] } = {}): Expando {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));\n const factory = this._generators[type];\n const data = factory(this._provider);\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n return new Expando(data, { schema: this.schema[type] });\n }\n\n // TODO(burdon): Create batch.\n createObjects({ types, count }: { types?: T[]; count: number }): Expando[] {\n return range(() => this.createObject({ types }), count);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(private readonly _space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {\n super(schema, generators, (type: T) => {\n // TODO(burdon): Query by schema.\n const { objects } = this._space.db.query((object) => {\n return object.__schema === schema[type];\n });\n\n return objects;\n });\n }\n\n addSchemas() {\n this.schemas.forEach((schema) => this._space.db.add(schema));\n return this.schemas;\n }\n\n override createObject({ types }: { types?: T[] } = {}): Expando {\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": ";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;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B;EACnD;IAAED,KAAK;IAAqBC,KAAK;EAAmB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAqBC,KAAK;EAAiB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAqBC,KAAK;EAAkB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;;",
6
- "names": ["import_faker", "import_echo", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "schema", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "typename", "find", "createObject", "types", "type", "faker", "helpers", "arrayElement", "keys", "factory", "data", "Expando", "createObjects", "count", "range", "SpaceObjectGenerator", "_space", "generators", "objects", "db", "query", "object", "__schema", "addSchemas", "forEach", "add", "Status", "Priority", "testSchemas", "document", "Schema", "props", "id", "type", "PropType", "STRING", "organization", "typename", "person", "REF", "ref", "NUMBER", "project", "BOOLEAN", "testObjectGenerators", "title", "faker", "lorem", "sentence", "content", "sentences", "min", "max", "number", "int", "name", "company", "website", "datatype", "boolean", "probability", "internet", "url", "undefined", "description", "TextObject", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "fullName", "email", "org", "length", "commerce", "productName", "repo", "status", "priority", "active", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator", "lat", "lng"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from './data';\nexport * from './generator';\nexport * from './util';\n", "//\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 { faker } from '@faker-js/faker';\n\nimport { Schema, type Space, TextObject } from '@dxos/client/echo';\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\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n typename: TestSchemaType.document,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'content',\n type: Schema.PropType.STRING, // TODO(burdon): Rich text.\n },\n ],\n });\n\n const organization = new Schema({\n typename: TestSchemaType.organization,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING,\n },\n ],\n });\n\n const contact = new Schema({\n typename: TestSchemaType.contact,\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'email',\n type: Schema.PropType.STRING,\n },\n {\n id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\n },\n // TODO(burdon): Convert to object with nested props.\n {\n id: 'lat',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'lng',\n type: Schema.PropType.NUMBER,\n },\n ],\n });\n\n const project = new Schema({\n typename: TestSchemaType.project,\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n },\n {\n id: 'description',\n type: Schema.PropType.STRING, // TODO(burdon): Text.\n },\n {\n id: 'repo',\n type: Schema.PropType.STRING,\n },\n {\n id: 'status',\n type: Schema.PropType.STRING,\n },\n {\n id: 'priority',\n type: Schema.PropType.NUMBER,\n },\n {\n id: 'active',\n type: Schema.PropType.BOOLEAN,\n },\n ],\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nexport const 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: new TextObject(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 title: 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\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\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 { faker } from '@faker-js/faker';\n\nimport { Expando, type TypedObject, Schema, type Space } from '@dxos/client/echo';\n\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> {\n // prettier-ignore\n constructor(\n public readonly schema: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this.schema);\n }\n\n getSchema(typename: string) {\n return this.schemas.find((schema) => schema.typename === typename);\n }\n\n createObject({ types }: { types?: T[] } = {}): TypedObject {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));\n const data = this._generators[type](this._provider);\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n return new Expando(data, { schema: this.schema[type] });\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>>): Expando[] {\n const objects: Expando[] = [];\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 private readonly _space: Space;\n\n constructor(space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {\n super(mergeSchemaMap(space, schemaMap), generators, (type: T) => {\n const { objects } = this._space.db.query((object) => {\n return object.__schema === schemaMap[type];\n });\n\n return objects;\n });\n\n this._space = space;\n }\n\n addSchemas() {\n this.schemas.forEach((schema) => this._space.db.add(schema));\n return this.schemas;\n }\n\n override createObject({ types }: { types?: T[] } = {}): Expando {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n\n/**\n * Merge existing schema in space with defaults.\n */\nconst mergeSchemaMap = <T extends string>(space: Space, schemaMap: TestSchemaMap<T>) => {\n const { objects } = space.db.query(Schema.filter());\n Object.keys(schemaMap).forEach((type) => {\n const schema = objects.find((object) => object.typename === type);\n if (schema) {\n (schemaMap as any)[type] = schema;\n }\n });\n\n return schemaMap;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>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oBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAqBC,KAAK;EAAiB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAoB;EACpD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAqBC,KAAK;EAAkB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAoBC,KAAK;EAAmB;EACnD;IAAED,KAAK;IAAmBC,KAAK;EAAmB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;EAClD;IAAED,KAAK;IAAoBC,KAAK;EAAkB;;",
6
+ "names": ["import_faker", "import_echo", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "schema", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "typename", "find", "createObject", "types", "type", "faker", "helpers", "arrayElement", "keys", "data", "Expando", "createObjects", "map", "objects", "entries", "forEach", "count", "range", "push", "SpaceObjectGenerator", "space", "schemaMap", "generators", "mergeSchemaMap", "_space", "db", "query", "object", "__schema", "addSchemas", "add", "Schema", "filter", "Status", "Priority", "TestSchemaType", "document", "organization", "contact", "project", "testSchemas", "Schema", "typename", "props", "id", "type", "PropType", "STRING", "REF", "ref", "NUMBER", "BOOLEAN", "testObjectGenerators", "title", "faker", "lorem", "sentence", "content", "sentences", "min", "max", "number", "int", "name", "company", "website", "datatype", "boolean", "probability", "internet", "url", "undefined", "description", "TextObject", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "email", "org", "length", "commerce", "productName", "repo", "status", "priority", "active", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator", "lat", "lng"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1052,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":7902,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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":35584,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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/index.ts":{"bytes":629,"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/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":21159},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true},{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":481},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10516},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":1456},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91}},"bytes":13955}}}
1
+ {"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":10093,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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":37173,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","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/index.ts":{"bytes":634,"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/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":23070},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true},{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":521},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":11082},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":1981},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91}},"bytes":15104}}}
@@ -3,7 +3,12 @@ import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
3
3
  import { type TestGeneratorMap, type TestSchemaMap } from './types';
4
4
  export declare const Status: string[];
5
5
  export declare const Priority: number[];
6
- export type TestSchemaType = 'document' | 'organization' | 'person' | 'project';
6
+ export declare enum TestSchemaType {
7
+ document = "example.com/schema/document",
8
+ organization = "example.com/schema/organization",
9
+ contact = "example.com/schema/contact",
10
+ project = "example.com/schema/project"
11
+ }
7
12
  export declare const testSchemas: () => TestSchemaMap<TestSchemaType>;
8
13
  export declare const testObjectGenerators: TestGeneratorMap<TestSchemaType>;
9
14
  export declare const createTestObjectGenerator: () => TestObjectGenerator<TestSchemaType>;
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AASA,OAAO,EAAU,KAAK,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAGpE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhF,eAAO,MAAM,WAAW,QAAO,cAAc,cAAc,CA4F1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,cAAc,CAiCjE,CAAC;AAEF,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":"AASA,OAAO,EAAU,KAAK,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAGpE,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;AAED,eAAO,MAAM,WAAW,QAAO,cAAc,cAAc,CAiG1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,cAAc,CAiCjE,CAAC;AAEF,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACe,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Expando, type Schema, type Space } from '@dxos/client/echo';
1
+ import { Expando, type TypedObject, Schema, type Space } from '@dxos/client/echo';
2
2
  import { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';
3
3
  /**
4
4
  * Typed object generator.
@@ -12,18 +12,15 @@ export declare class TestObjectGenerator<T extends string> {
12
12
  getSchema(typename: string): Schema | undefined;
13
13
  createObject({ types }?: {
14
14
  types?: T[];
15
- }): Expando;
16
- createObjects({ types, count }: {
17
- types?: T[];
18
- count: number;
19
- }): Expando[];
15
+ }): TypedObject;
16
+ createObjects(map: Partial<Record<T, number>>): Expando[];
20
17
  }
21
18
  /**
22
19
  * Typed object generator for a space.
23
20
  */
24
21
  export declare class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {
25
22
  private readonly _space;
26
- constructor(_space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>);
23
+ constructor(space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>);
27
24
  addSchemas(): Schema[];
28
25
  createObject({ types }?: {
29
26
  types?: T[];
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,E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,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7F;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM;aAG7B,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAFX,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAChC,SAAS,CAAC,mCAAuB;IAGpD,IAAI,OAAO,IAAI,MAAM,EAAE,CAEtB;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM;IAI1B,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,WAAW;IAS1D,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE;CAQ1D;AAED;;GAEG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAYtF,UAAU;IAKD,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;KAAO,GAAG,OAAO;CAGhE"}
@@ -3,6 +3,6 @@ export type TestObject = {
3
3
  id: string;
4
4
  } & Record<string, any>;
5
5
  export type TestSchemaMap<T extends string> = Record<T, Schema>;
6
- export type TestObjectProvider<T extends string> = (type: T) => Expando[];
7
6
  export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
7
+ export type TestObjectProvider<T extends string> = (type: T) => Expando[];
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,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;AAE1E,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,GAAG,CAAC,CAAC;AAEjH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-generator",
3
- "version": "0.3.6",
3
+ "version": "0.3.7-main.0ee8374",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -17,8 +17,8 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "@faker-js/faker": "^8.0.2",
20
- "@dxos/node-std": "0.3.6",
21
- "@dxos/client": "0.3.6"
20
+ "@dxos/node-std": "0.3.7-main.0ee8374",
21
+ "@dxos/client": "0.3.7-main.0ee8374"
22
22
  },
23
23
  "devDependencies": {},
24
24
  "publishConfig": {
package/src/data.ts CHANGED
@@ -16,15 +16,20 @@ import { type TestGeneratorMap, type TestSchemaMap } from './types';
16
16
  export const Status = ['pending', 'active', 'done'];
17
17
  export const Priority = [1, 2, 3, 4, 5];
18
18
 
19
- export type TestSchemaType = 'document' | 'organization' | 'person' | 'project';
19
+ export enum TestSchemaType {
20
+ document = 'example.com/schema/document',
21
+ organization = 'example.com/schema/organization',
22
+ contact = 'example.com/schema/contact',
23
+ project = 'example.com/schema/project',
24
+ }
20
25
 
21
26
  export const testSchemas = (): TestSchemaMap<TestSchemaType> => {
22
27
  const document = new Schema({
28
+ typename: TestSchemaType.document,
23
29
  props: [
24
30
  {
25
31
  id: 'name',
26
32
  type: Schema.PropType.STRING,
27
- // TODO(burdon): primary: true,
28
33
  },
29
34
  {
30
35
  id: 'content',
@@ -34,7 +39,7 @@ export const testSchemas = (): TestSchemaMap<TestSchemaType> => {
34
39
  });
35
40
 
36
41
  const organization = new Schema({
37
- typename: 'example.com/schema/organization',
42
+ typename: TestSchemaType.organization,
38
43
  props: [
39
44
  {
40
45
  id: 'name',
@@ -51,8 +56,8 @@ export const testSchemas = (): TestSchemaMap<TestSchemaType> => {
51
56
  ],
52
57
  });
53
58
 
54
- const person = new Schema({
55
- typename: 'example.com/schema/person',
59
+ const contact = new Schema({
60
+ typename: TestSchemaType.contact,
56
61
  props: [
57
62
  {
58
63
  id: 'name',
@@ -80,7 +85,7 @@ export const testSchemas = (): TestSchemaMap<TestSchemaType> => {
80
85
  });
81
86
 
82
87
  const project = new Schema({
83
- typename: 'example.com/schema/project',
88
+ typename: TestSchemaType.project,
84
89
  props: [
85
90
  {
86
91
  id: 'title',
@@ -109,23 +114,28 @@ export const testSchemas = (): TestSchemaMap<TestSchemaType> => {
109
114
  ],
110
115
  });
111
116
 
112
- return { document, organization, person, project };
117
+ return {
118
+ [TestSchemaType.document]: document,
119
+ [TestSchemaType.organization]: organization,
120
+ [TestSchemaType.contact]: contact,
121
+ [TestSchemaType.project]: project,
122
+ };
113
123
  };
114
124
 
115
125
  export const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
116
- document: () => ({
126
+ [TestSchemaType.document]: () => ({
117
127
  title: faker.lorem.sentence(3),
118
128
  content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),
119
129
  }),
120
130
 
121
- organization: () => ({
131
+ [TestSchemaType.organization]: () => ({
122
132
  name: faker.company.name(),
123
133
  website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
124
134
  description: new TextObject(faker.lorem.sentences()),
125
135
  }),
126
136
 
127
- person: (provider) => {
128
- const organizations = provider?.('organization');
137
+ [TestSchemaType.contact]: (provider) => {
138
+ const organizations = provider?.(TestSchemaType.organization);
129
139
  const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;
130
140
  return {
131
141
  name: faker.person.fullName(),
@@ -138,7 +148,7 @@ export const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {
138
148
  };
139
149
  },
140
150
 
141
- project: () => ({
151
+ [TestSchemaType.project]: () => ({
142
152
  title: faker.commerce.productName(),
143
153
  repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
144
154
  status: faker.helpers.arrayElement(Status),
@@ -251,6 +261,6 @@ const locations = [
251
261
  { lat: 28.028063865019476, lng: -26.16809888138414 },
252
262
  { lat: 13.399602764700546, lng: 52.523764522251156 },
253
263
  { lat: 3.048606670909237, lng: 36.765010656628135 },
254
- { lat: 12.481312562873995, lng: 41.89790148509894 },
255
264
  { lat: 125.75274485499392, lng: 39.02138455800434 },
265
+ { lat: 12.481312562873995, lng: 41.89790148509894 },
256
266
  ];
@@ -8,7 +8,7 @@ import { expect } from 'chai';
8
8
  import { Client } from '@dxos/client';
9
9
  import { describe, test } from '@dxos/test';
10
10
 
11
- import { createSpaceObjectGenerator, createTestObjectGenerator } from './data';
11
+ import { createSpaceObjectGenerator, createTestObjectGenerator, TestSchemaType } from './data';
12
12
 
13
13
  faker.seed(3);
14
14
 
@@ -17,7 +17,7 @@ describe('TestObjectGenerator', () => {
17
17
  const generator = createTestObjectGenerator();
18
18
 
19
19
  // Create raw object.
20
- const object = generator.createObject({ types: ['person'] });
20
+ const object = generator.createObject({ types: [TestSchemaType.contact] });
21
21
  expect(object).to.exist;
22
22
  });
23
23
 
@@ -32,11 +32,11 @@ describe('TestObjectGenerator', () => {
32
32
  generator.addSchemas();
33
33
 
34
34
  // Create org object.
35
- const organization = generator.createObject({ types: ['organization'] });
35
+ const organization = generator.createObject({ types: [TestSchemaType.organization] });
36
36
  expect(organization.__schema).to.exist;
37
37
 
38
38
  // Expect at least one person object with a linked org reference.
39
- const objects = generator.createObjects({ types: ['person'], count: 10 });
39
+ const objects = generator.createObjects({ [TestSchemaType.contact]: 10 });
40
40
  expect(objects.some((object) => object.org === organization)).to.be.true;
41
41
 
42
42
  await client.destroy();
package/src/generator.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { faker } from '@faker-js/faker';
9
9
 
10
- import { Expando, type Schema, type Space } from '@dxos/client/echo';
10
+ import { Expando, type TypedObject, Schema, type Space } from '@dxos/client/echo';
11
11
 
12
12
  import { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';
13
13
  import { range } from './util';
@@ -31,17 +31,22 @@ export class TestObjectGenerator<T extends string> {
31
31
  return this.schemas.find((schema) => schema.typename === typename);
32
32
  }
33
33
 
34
- createObject({ types }: { types?: T[] } = {}): Expando {
34
+ createObject({ types }: { types?: T[] } = {}): TypedObject {
35
35
  const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));
36
- const factory = this._generators[type];
37
- const data = factory(this._provider);
36
+ const data = this._generators[type](this._provider);
38
37
  // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).
39
38
  return new Expando(data, { schema: this.schema[type] });
40
39
  }
41
40
 
42
41
  // TODO(burdon): Create batch.
43
- createObjects({ types, count }: { types?: T[]; count: number }): Expando[] {
44
- return range(() => this.createObject({ types }), count);
42
+ // TODO(burdon): Based on dependencies (e.g., organization before contact).
43
+ createObjects(map: Partial<Record<T, number>>): Expando[] {
44
+ const objects: Expando[] = [];
45
+ Object.entries<number>(map as any).forEach(([type, count]) => {
46
+ range(() => objects.push(this.createObject({ types: [type as T] })), count);
47
+ });
48
+
49
+ return objects;
45
50
  }
46
51
  }
47
52
 
@@ -49,15 +54,18 @@ export class TestObjectGenerator<T extends string> {
49
54
  * Typed object generator for a space.
50
55
  */
51
56
  export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {
52
- constructor(private readonly _space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {
53
- super(schema, generators, (type: T) => {
54
- // TODO(burdon): Query by schema.
57
+ private readonly _space: Space;
58
+
59
+ constructor(space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {
60
+ super(mergeSchemaMap(space, schemaMap), generators, (type: T) => {
55
61
  const { objects } = this._space.db.query((object) => {
56
- return object.__schema === schema[type];
62
+ return object.__schema === schemaMap[type];
57
63
  });
58
64
 
59
65
  return objects;
60
66
  });
67
+
68
+ this._space = space;
61
69
  }
62
70
 
63
71
  addSchemas() {
@@ -69,3 +77,18 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
69
77
  return this._space.db.add(super.createObject({ types }));
70
78
  }
71
79
  }
80
+
81
+ /**
82
+ * Merge existing schema in space with defaults.
83
+ */
84
+ const mergeSchemaMap = <T extends string>(space: Space, schemaMap: TestSchemaMap<T>) => {
85
+ const { objects } = space.db.query(Schema.filter());
86
+ Object.keys(schemaMap).forEach((type) => {
87
+ const schema = objects.find((object) => object.typename === type);
88
+ if (schema) {
89
+ (schemaMap as any)[type] = schema;
90
+ }
91
+ });
92
+
93
+ return schemaMap;
94
+ };
package/src/types.ts CHANGED
@@ -8,6 +8,6 @@ export type TestObject = { id: string } & Record<string, any>;
8
8
 
9
9
  export type TestSchemaMap<T extends string> = Record<T, Schema>;
10
10
 
11
- export type TestObjectProvider<T extends string> = (type: T) => Expando[];
12
-
13
11
  export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
12
+
13
+ export type TestObjectProvider<T extends string> = (type: T) => Expando[];