@dxos/echo-generator 0.4.10-main.fa5a270 → 0.4.10-main.fe71b4c
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.
- package/dist/lib/browser/index.mjs +52 -120
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +53 -123
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/data.d.ts +0 -3
- package/dist/types/src/data.d.ts.map +1 -1
- package/dist/types/src/generator.d.ts +9 -8
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +3 -3
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/data.ts +38 -102
- package/src/generator.test.ts +18 -22
- package/src/generator.ts +27 -23
- package/src/types.ts +3 -3
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
} from "@dxos/node-std/inject-globals";
|
|
9
9
|
|
|
10
10
|
// packages/core/echo/echo-generator/src/data.ts
|
|
11
|
-
import {
|
|
11
|
+
import { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create as create2, ref, echoObject } from "@dxos/echo-schema";
|
|
12
12
|
import { faker as faker2 } from "@dxos/random";
|
|
13
13
|
|
|
14
14
|
// packages/core/echo/echo-generator/src/generator.ts
|
|
15
|
-
import {
|
|
15
|
+
import { Filter } from "@dxos/echo-schema";
|
|
16
|
+
import { create } from "@dxos/echo-schema";
|
|
16
17
|
import { faker } from "@dxos/random";
|
|
17
18
|
|
|
18
19
|
// packages/core/echo/echo-generator/src/util.ts
|
|
@@ -42,9 +43,7 @@ var TestObjectGenerator = class {
|
|
|
42
43
|
const type = faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
|
|
43
44
|
const data = this._generators[type](this._provider);
|
|
44
45
|
const schema = this.getSchema(type);
|
|
45
|
-
return
|
|
46
|
-
schema
|
|
47
|
-
});
|
|
46
|
+
return schema ? create(schema, data) : create(data);
|
|
48
47
|
}
|
|
49
48
|
// TODO(burdon): Create batch.
|
|
50
49
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
@@ -63,28 +62,31 @@ var TestObjectGenerator = class {
|
|
|
63
62
|
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
64
63
|
constructor(_space, schemaMap, generators) {
|
|
65
64
|
super(schemaMap, generators, (type) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
return objects2;
|
|
65
|
+
const schema = this.getSchema(type);
|
|
66
|
+
return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];
|
|
70
67
|
});
|
|
71
68
|
this._space = _space;
|
|
72
|
-
const
|
|
73
|
-
Object.
|
|
74
|
-
|
|
75
|
-
if (schema) {
|
|
76
|
-
this.
|
|
69
|
+
const schemas = this._space.db.schemaRegistry.getAll();
|
|
70
|
+
Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
|
|
71
|
+
let schema = schemas.find((object) => object.typename === type);
|
|
72
|
+
if (schema == null) {
|
|
73
|
+
schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);
|
|
77
74
|
}
|
|
75
|
+
this.setSchema(type, schema);
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
addSchemas() {
|
|
81
|
-
const
|
|
79
|
+
const result = [];
|
|
80
|
+
const dbSchemas = this._space.db.schemaRegistry.getAll();
|
|
82
81
|
this.schemas.forEach((schema) => {
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const existing = dbSchemas.find((object) => object.typename === schema.typename);
|
|
83
|
+
if (existing == null) {
|
|
84
|
+
result.push(this._space.db.schemaRegistry.add(schema.schema));
|
|
85
|
+
} else {
|
|
86
|
+
result.push(existing);
|
|
85
87
|
}
|
|
86
88
|
});
|
|
87
|
-
return
|
|
89
|
+
return result;
|
|
88
90
|
}
|
|
89
91
|
createObject({ types } = {}) {
|
|
90
92
|
return this._space.db.add(super.createObject({
|
|
@@ -113,108 +115,40 @@ var TestSchemaType;
|
|
|
113
115
|
TestSchemaType2["contact"] = "example.com/schema/contact";
|
|
114
116
|
TestSchemaType2["project"] = "example.com/schema/project";
|
|
115
117
|
})(TestSchemaType || (TestSchemaType = {}));
|
|
118
|
+
var createDynamicSchema = (typename, fields) => {
|
|
119
|
+
const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, "1.0.0"));
|
|
120
|
+
return new DynamicEchoSchema(create2(StoredEchoSchema, {
|
|
121
|
+
typename,
|
|
122
|
+
version: "1.0.0",
|
|
123
|
+
jsonSchema: effectToJsonSchema(typeSchema)
|
|
124
|
+
}));
|
|
125
|
+
};
|
|
116
126
|
var testSchemas = () => {
|
|
117
|
-
const document =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
id: "title",
|
|
122
|
-
type: Schema2.PropType.STRING,
|
|
123
|
-
description: "title of the document"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: "content",
|
|
127
|
-
type: Schema2.PropType.STRING
|
|
128
|
-
}
|
|
129
|
-
]
|
|
127
|
+
const document = createDynamicSchema("example.com/schema/document", {
|
|
128
|
+
title: S.string.pipe(S.description("title of the document")),
|
|
129
|
+
content: S.string
|
|
130
130
|
});
|
|
131
|
-
const organization =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
id: "name",
|
|
136
|
-
type: Schema2.PropType.STRING,
|
|
137
|
-
description: "name of the company or organization"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: "website",
|
|
141
|
-
type: Schema2.PropType.STRING,
|
|
142
|
-
description: "public website URL"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
id: "description",
|
|
146
|
-
type: Schema2.PropType.STRING,
|
|
147
|
-
description: "short summary of the company"
|
|
148
|
-
}
|
|
149
|
-
]
|
|
131
|
+
const organization = createDynamicSchema("example.com/schema/organization", {
|
|
132
|
+
name: S.string.pipe(S.description("name of the company or organization")),
|
|
133
|
+
website: S.string.pipe(S.description("public website URL")),
|
|
134
|
+
description: S.string.pipe(S.description("short summary of the company"))
|
|
150
135
|
});
|
|
151
|
-
const contact =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
description: "name of the person"
|
|
158
|
-
},
|
|
159
|
-
// TODO(burdon): Support multiple tagged properties.
|
|
160
|
-
{
|
|
161
|
-
id: "email",
|
|
162
|
-
type: Schema2.PropType.STRING
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: "org",
|
|
166
|
-
type: Schema2.PropType.REF,
|
|
167
|
-
ref: organization
|
|
168
|
-
},
|
|
169
|
-
// TODO(burdon): Convert to object with nested props.
|
|
170
|
-
{
|
|
171
|
-
id: "lat",
|
|
172
|
-
type: Schema2.PropType.NUMBER
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
id: "lng",
|
|
176
|
-
type: Schema2.PropType.NUMBER
|
|
177
|
-
}
|
|
178
|
-
]
|
|
136
|
+
const contact = createDynamicSchema("example.com/schema/contact", {
|
|
137
|
+
name: S.string.pipe(S.description("name of the person")),
|
|
138
|
+
email: S.string,
|
|
139
|
+
org: ref(organization),
|
|
140
|
+
lat: S.number,
|
|
141
|
+
lng: S.number
|
|
179
142
|
});
|
|
180
|
-
const project =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
id: "description",
|
|
190
|
-
type: Schema2.PropType.STRING
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: "website",
|
|
194
|
-
type: Schema2.PropType.STRING
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
id: "repo",
|
|
198
|
-
type: Schema2.PropType.STRING
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: "status",
|
|
202
|
-
type: Schema2.PropType.STRING
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
id: "priority",
|
|
206
|
-
type: Schema2.PropType.NUMBER
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
id: "active",
|
|
210
|
-
type: Schema2.PropType.BOOLEAN
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: "org",
|
|
214
|
-
type: Schema2.PropType.REF,
|
|
215
|
-
ref: organization
|
|
216
|
-
}
|
|
217
|
-
]
|
|
143
|
+
const project = createDynamicSchema("example.com/schema/project", {
|
|
144
|
+
name: S.string.pipe(S.description("name of the project")),
|
|
145
|
+
description: S.string,
|
|
146
|
+
website: S.string,
|
|
147
|
+
repo: S.string,
|
|
148
|
+
status: S.string,
|
|
149
|
+
priority: S.number,
|
|
150
|
+
active: S.boolean,
|
|
151
|
+
org: ref(organization)
|
|
218
152
|
});
|
|
219
153
|
return {
|
|
220
154
|
["example.com/schema/document"]: document,
|
|
@@ -239,7 +173,7 @@ var testObjectGenerators = {
|
|
|
239
173
|
website: faker2.datatype.boolean({
|
|
240
174
|
probability: 0.3
|
|
241
175
|
}) ? faker2.internet.url() : void 0,
|
|
242
|
-
description:
|
|
176
|
+
description: faker2.lorem.sentences()
|
|
243
177
|
}),
|
|
244
178
|
["example.com/schema/contact"]: (provider) => {
|
|
245
179
|
const organizations = provider?.("example.com/schema/organization");
|
|
@@ -677,8 +611,6 @@ export {
|
|
|
677
611
|
TestSchemaType,
|
|
678
612
|
createSpaceObjectGenerator,
|
|
679
613
|
createTestObjectGenerator,
|
|
680
|
-
range
|
|
681
|
-
testObjectGenerators,
|
|
682
|
-
testSchemas
|
|
614
|
+
range
|
|
683
615
|
};
|
|
684
616
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 { Schema, type Space, TextObject } from '@dxos/client/echo';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n typename: TestSchemaType.document,\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n description: 'title of the document',\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 description: 'name of the company or organization',\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n description: 'public website URL',\n },\n {\n id: 'description',\n type: Schema.PropType.STRING,\n description: 'short summary of the company',\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 description: 'name of the person',\n },\n // TODO(burdon): Support multiple tagged properties.\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: 'name',\n type: Schema.PropType.STRING,\n description: 'name of the project',\n },\n {\n id: 'description',\n type: Schema.PropType.STRING, // TODO(burdon): Text.\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\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 id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\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 name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Expando, type TypedObject, Schema, type Space } from '@dxos/client/echo';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T) {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: Schema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n createObject({ types }: { types?: T[] } = {}): TypedObject {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return new Expando(data, { schema });\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 constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, (type: T) => {\n const { objects } = this._space.db.query((object: TypedObject) => {\n return object.__schema?.id === this.getSchema(type)?.id;\n });\n\n return objects;\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n const { objects } = this._space.db.query(Schema.filter());\n Object.keys(schemaMap).forEach((type) => {\n const schema = objects.find((object) => object.typename === type);\n if (schema) {\n this.setSchema(type as T, schema);\n }\n });\n }\n\n addSchemas() {\n const { objects } = this._space.db.query(Schema.filter());\n this.schemas.forEach((schema) => {\n if (!objects.find((object) => object.typename === schema.typename)) {\n this._space.db.add(schema);\n }\n });\n\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": ";;;;;;;;;;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { type Space } from '@dxos/client/echo';\nimport { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.description('name of the project')),\n description: S.string,\n website: S.string,\n repo: S.string,\n status: S.string,\n priority: S.number,\n active: S.boolean,\n org: ref(organization),\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: (provider) => {\n const organizations = provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, Filter, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n createObjects(map: Partial<Record<T, number>>): ReactiveObject<any>[] {\n const objects: ReactiveObject<any>[] = [];\n Object.entries<number>(map as any).forEach(([type, count]) => {\n range(() => objects.push(this.createObject({ types: [type as T] })), count);\n });\n\n return objects;\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, (type: T) => {\n const schema = this.getSchema(type);\n return (schema && this._space.db.query(Filter.schema(schema)).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n const schemas = this._space.db.schemaRegistry.getAll();\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = schemas.find((object) => object.typename === type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n const dbSchemas = this._space.db.schemaRegistry.getAll();\n this.schemas.forEach((schema) => {\n const existing = dbSchemas.find((object) => object.typename === schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override createObject({ types }: { types?: T[] } = {}): ReactiveObject<any> {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAQA,SAASA,GAAGC,mBAAmBC,oBAAoBC,kBAAkBC,UAAAA,SAAQC,KAAKC,kBAAkB;AACpG,SAASC,SAAAA,cAAa;;;ACJtB,SAAiCC,cAAmC;AACpE,SAASC,cAAc;AACvB,SAASC,aAAa;;;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADQL,IAAMC,sBAAN,MAAMA;;EAEXC,YACmBC,UACAC,aACAC,WACjB;SAHiBF,WAAAA;SACAC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA+B;AACjC,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAwC;AAChD,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWA,OAAOC,aAAaH,IAAAA;EAC3D;EAEUI,UAAUJ,MAASE,QAA2B;AACtD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;;EAGAG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAwB;AACjE,UAAMN,OAAOO,MAAMC,QAAQC,aAAaH,SAAUT,OAAOa,KAAK,KAAKjB,QAAQ,CAAA;AAC3E,UAAMkB,OAAO,KAAKjB,YAAYM,IAAAA,EAAM,KAAKL,SAAS;AAClD,UAAMO,SAAS,KAAKH,UAAUC,IAAAA;AAC9B,WAAOE,SAASU,OAAOV,QAAQS,IAAAA,IAAQC,OAAOD,IAAAA;EAChD;;;EAIAE,cAAcC,KAAwD;AACpE,UAAMC,UAAiC,CAAA;AACv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ACtC;IAAEF,KAAK;IAAmBE,KAAK;EAAkB;EACjD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAqBE,KAAK;EAAmB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAqBE,KAAK;EAAiB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAoB;EACpD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAqBE,KAAK;EAAkB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAoBE,KAAK;EAAmB;EACnD;IAAEF,KAAK;IAAmBE,KAAK;EAAmB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;EAClD;IAAEF,KAAK;IAAoBE,KAAK;EAAkB;;",
|
|
6
|
+
"names": ["S", "DynamicEchoSchema", "effectToJsonSchema", "StoredEchoSchema", "create", "ref", "echoObject", "faker", "Filter", "create", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "map", "objects", "entries", "forEach", "count", "range", "push", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "schemaRegistry", "getAll", "dynamicSchema", "object", "add", "addSchemas", "result", "dbSchemas", "existing", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "typename", "fields", "typeSchema", "S", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "create", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "number", "lng", "project", "repo", "status", "priority", "active", "boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "length", "commerce", "productName", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":
|
|
1
|
+
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11848,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35559,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":993,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23463},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10280},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2474},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13453}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -25,14 +25,13 @@ __export(node_exports, {
|
|
|
25
25
|
TestSchemaType: () => TestSchemaType,
|
|
26
26
|
createSpaceObjectGenerator: () => createSpaceObjectGenerator,
|
|
27
27
|
createTestObjectGenerator: () => createTestObjectGenerator,
|
|
28
|
-
range: () => range
|
|
29
|
-
testObjectGenerators: () => testObjectGenerators,
|
|
30
|
-
testSchemas: () => testSchemas
|
|
28
|
+
range: () => range
|
|
31
29
|
});
|
|
32
30
|
module.exports = __toCommonJS(node_exports);
|
|
33
|
-
var
|
|
31
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
34
32
|
var import_random = require("@dxos/random");
|
|
35
|
-
var
|
|
33
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
34
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
36
35
|
var import_random2 = require("@dxos/random");
|
|
37
36
|
var range = (fn, length) => Array.from({
|
|
38
37
|
length
|
|
@@ -58,9 +57,7 @@ var TestObjectGenerator = class {
|
|
|
58
57
|
const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
|
|
59
58
|
const data = this._generators[type](this._provider);
|
|
60
59
|
const schema = this.getSchema(type);
|
|
61
|
-
return
|
|
62
|
-
schema
|
|
63
|
-
});
|
|
60
|
+
return schema ? (0, import_echo_schema3.create)(schema, data) : (0, import_echo_schema3.create)(data);
|
|
64
61
|
}
|
|
65
62
|
// TODO(burdon): Create batch.
|
|
66
63
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
@@ -79,28 +76,31 @@ var TestObjectGenerator = class {
|
|
|
79
76
|
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
80
77
|
constructor(_space, schemaMap, generators) {
|
|
81
78
|
super(schemaMap, generators, (type) => {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
return objects2;
|
|
79
|
+
const schema = this.getSchema(type);
|
|
80
|
+
return (schema && this._space.db.query(import_echo_schema2.Filter.schema(schema)).objects) ?? [];
|
|
86
81
|
});
|
|
87
82
|
this._space = _space;
|
|
88
|
-
const
|
|
89
|
-
Object.
|
|
90
|
-
|
|
91
|
-
if (schema) {
|
|
92
|
-
this.
|
|
83
|
+
const schemas = this._space.db.schemaRegistry.getAll();
|
|
84
|
+
Object.entries(schemaMap).forEach(([type, dynamicSchema]) => {
|
|
85
|
+
let schema = schemas.find((object) => object.typename === type);
|
|
86
|
+
if (schema == null) {
|
|
87
|
+
schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);
|
|
93
88
|
}
|
|
89
|
+
this.setSchema(type, schema);
|
|
94
90
|
});
|
|
95
91
|
}
|
|
96
92
|
addSchemas() {
|
|
97
|
-
const
|
|
93
|
+
const result = [];
|
|
94
|
+
const dbSchemas = this._space.db.schemaRegistry.getAll();
|
|
98
95
|
this.schemas.forEach((schema) => {
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
const existing = dbSchemas.find((object) => object.typename === schema.typename);
|
|
97
|
+
if (existing == null) {
|
|
98
|
+
result.push(this._space.db.schemaRegistry.add(schema.schema));
|
|
99
|
+
} else {
|
|
100
|
+
result.push(existing);
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
|
-
return
|
|
103
|
+
return result;
|
|
104
104
|
}
|
|
105
105
|
createObject({ types } = {}) {
|
|
106
106
|
return this._space.db.add(super.createObject({
|
|
@@ -127,108 +127,40 @@ var TestSchemaType;
|
|
|
127
127
|
TestSchemaType2["contact"] = "example.com/schema/contact";
|
|
128
128
|
TestSchemaType2["project"] = "example.com/schema/project";
|
|
129
129
|
})(TestSchemaType || (TestSchemaType = {}));
|
|
130
|
+
var createDynamicSchema = (typename, fields) => {
|
|
131
|
+
const typeSchema = import_echo_schema.S.partial(import_echo_schema.S.struct(fields)).pipe((0, import_echo_schema.echoObject)(typename, "1.0.0"));
|
|
132
|
+
return new import_echo_schema.DynamicEchoSchema((0, import_echo_schema.create)(import_echo_schema.StoredEchoSchema, {
|
|
133
|
+
typename,
|
|
134
|
+
version: "1.0.0",
|
|
135
|
+
jsonSchema: (0, import_echo_schema.effectToJsonSchema)(typeSchema)
|
|
136
|
+
}));
|
|
137
|
+
};
|
|
130
138
|
var testSchemas = () => {
|
|
131
|
-
const document =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
id: "title",
|
|
136
|
-
type: import_echo.Schema.PropType.STRING,
|
|
137
|
-
description: "title of the document"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: "content",
|
|
141
|
-
type: import_echo.Schema.PropType.STRING
|
|
142
|
-
}
|
|
143
|
-
]
|
|
139
|
+
const document = createDynamicSchema("example.com/schema/document", {
|
|
140
|
+
title: import_echo_schema.S.string.pipe(import_echo_schema.S.description("title of the document")),
|
|
141
|
+
content: import_echo_schema.S.string
|
|
144
142
|
});
|
|
145
|
-
const organization =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
id: "name",
|
|
150
|
-
type: import_echo.Schema.PropType.STRING,
|
|
151
|
-
description: "name of the company or organization"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: "website",
|
|
155
|
-
type: import_echo.Schema.PropType.STRING,
|
|
156
|
-
description: "public website URL"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: "description",
|
|
160
|
-
type: import_echo.Schema.PropType.STRING,
|
|
161
|
-
description: "short summary of the company"
|
|
162
|
-
}
|
|
163
|
-
]
|
|
143
|
+
const organization = createDynamicSchema("example.com/schema/organization", {
|
|
144
|
+
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the company or organization")),
|
|
145
|
+
website: import_echo_schema.S.string.pipe(import_echo_schema.S.description("public website URL")),
|
|
146
|
+
description: import_echo_schema.S.string.pipe(import_echo_schema.S.description("short summary of the company"))
|
|
164
147
|
});
|
|
165
|
-
const contact =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
description: "name of the person"
|
|
172
|
-
},
|
|
173
|
-
// TODO(burdon): Support multiple tagged properties.
|
|
174
|
-
{
|
|
175
|
-
id: "email",
|
|
176
|
-
type: import_echo.Schema.PropType.STRING
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
id: "org",
|
|
180
|
-
type: import_echo.Schema.PropType.REF,
|
|
181
|
-
ref: organization
|
|
182
|
-
},
|
|
183
|
-
// TODO(burdon): Convert to object with nested props.
|
|
184
|
-
{
|
|
185
|
-
id: "lat",
|
|
186
|
-
type: import_echo.Schema.PropType.NUMBER
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
id: "lng",
|
|
190
|
-
type: import_echo.Schema.PropType.NUMBER
|
|
191
|
-
}
|
|
192
|
-
]
|
|
148
|
+
const contact = createDynamicSchema("example.com/schema/contact", {
|
|
149
|
+
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the person")),
|
|
150
|
+
email: import_echo_schema.S.string,
|
|
151
|
+
org: (0, import_echo_schema.ref)(organization),
|
|
152
|
+
lat: import_echo_schema.S.number,
|
|
153
|
+
lng: import_echo_schema.S.number
|
|
193
154
|
});
|
|
194
|
-
const project =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
id: "description",
|
|
204
|
-
type: import_echo.Schema.PropType.STRING
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
id: "website",
|
|
208
|
-
type: import_echo.Schema.PropType.STRING
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
id: "repo",
|
|
212
|
-
type: import_echo.Schema.PropType.STRING
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
id: "status",
|
|
216
|
-
type: import_echo.Schema.PropType.STRING
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: "priority",
|
|
220
|
-
type: import_echo.Schema.PropType.NUMBER
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
id: "active",
|
|
224
|
-
type: import_echo.Schema.PropType.BOOLEAN
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
id: "org",
|
|
228
|
-
type: import_echo.Schema.PropType.REF,
|
|
229
|
-
ref: organization
|
|
230
|
-
}
|
|
231
|
-
]
|
|
155
|
+
const project = createDynamicSchema("example.com/schema/project", {
|
|
156
|
+
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the project")),
|
|
157
|
+
description: import_echo_schema.S.string,
|
|
158
|
+
website: import_echo_schema.S.string,
|
|
159
|
+
repo: import_echo_schema.S.string,
|
|
160
|
+
status: import_echo_schema.S.string,
|
|
161
|
+
priority: import_echo_schema.S.number,
|
|
162
|
+
active: import_echo_schema.S.boolean,
|
|
163
|
+
org: (0, import_echo_schema.ref)(organization)
|
|
232
164
|
});
|
|
233
165
|
return {
|
|
234
166
|
["example.com/schema/document"]: document,
|
|
@@ -253,7 +185,7 @@ var testObjectGenerators = {
|
|
|
253
185
|
website: import_random.faker.datatype.boolean({
|
|
254
186
|
probability: 0.3
|
|
255
187
|
}) ? import_random.faker.internet.url() : void 0,
|
|
256
|
-
description:
|
|
188
|
+
description: import_random.faker.lorem.sentences()
|
|
257
189
|
}),
|
|
258
190
|
["example.com/schema/contact"]: (provider) => {
|
|
259
191
|
const organizations = provider?.("example.com/schema/organization");
|
|
@@ -692,8 +624,6 @@ var locations = [
|
|
|
692
624
|
TestSchemaType,
|
|
693
625
|
createSpaceObjectGenerator,
|
|
694
626
|
createTestObjectGenerator,
|
|
695
|
-
range
|
|
696
|
-
testObjectGenerators,
|
|
697
|
-
testSchemas
|
|
627
|
+
range
|
|
698
628
|
});
|
|
699
629
|
//# sourceMappingURL=index.cjs.map
|