@dxos/echo-generator 0.5.3-main.e76d664 → 0.5.3-main.eb56347
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 +18 -18
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +17 -17
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/data.d.ts +4 -4
- package/dist/types/src/data.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/data.ts +5 -5
|
@@ -8,7 +8,7 @@ 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 { create as create2, DynamicEchoSchema, echoObject, effectToJsonSchema, ref, S, StoredEchoSchema } 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
|
|
@@ -107,10 +107,10 @@ var Priority = [
|
|
|
107
107
|
];
|
|
108
108
|
var TestSchemaType;
|
|
109
109
|
(function(TestSchemaType2) {
|
|
110
|
-
TestSchemaType2["document"] = "example.com/
|
|
111
|
-
TestSchemaType2["organization"] = "example.com/
|
|
112
|
-
TestSchemaType2["contact"] = "example.com/
|
|
113
|
-
TestSchemaType2["project"] = "example.com/
|
|
110
|
+
TestSchemaType2["document"] = "example.com/type/document";
|
|
111
|
+
TestSchemaType2["organization"] = "example.com/type/organization";
|
|
112
|
+
TestSchemaType2["contact"] = "example.com/type/contact";
|
|
113
|
+
TestSchemaType2["project"] = "example.com/type/project";
|
|
114
114
|
})(TestSchemaType || (TestSchemaType = {}));
|
|
115
115
|
var createDynamicSchema = (typename, fields) => {
|
|
116
116
|
const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, "1.0.0"));
|
|
@@ -121,23 +121,23 @@ var createDynamicSchema = (typename, fields) => {
|
|
|
121
121
|
}));
|
|
122
122
|
};
|
|
123
123
|
var testSchemas = () => {
|
|
124
|
-
const document = createDynamicSchema("example.com/
|
|
124
|
+
const document = createDynamicSchema("example.com/type/document", {
|
|
125
125
|
title: S.string.pipe(S.description("title of the document")),
|
|
126
126
|
content: S.string
|
|
127
127
|
});
|
|
128
|
-
const organization = createDynamicSchema("example.com/
|
|
128
|
+
const organization = createDynamicSchema("example.com/type/organization", {
|
|
129
129
|
name: S.string.pipe(S.description("name of the company or organization")),
|
|
130
130
|
website: S.string.pipe(S.description("public website URL")),
|
|
131
131
|
description: S.string.pipe(S.description("short summary of the company"))
|
|
132
132
|
});
|
|
133
|
-
const contact = createDynamicSchema("example.com/
|
|
133
|
+
const contact = createDynamicSchema("example.com/type/contact", {
|
|
134
134
|
name: S.string.pipe(S.description("name of the person")),
|
|
135
135
|
email: S.string,
|
|
136
136
|
org: ref(organization),
|
|
137
137
|
lat: S.number,
|
|
138
138
|
lng: S.number
|
|
139
139
|
});
|
|
140
|
-
const project = createDynamicSchema("example.com/
|
|
140
|
+
const project = createDynamicSchema("example.com/type/project", {
|
|
141
141
|
name: S.string.pipe(S.description("name of the project")),
|
|
142
142
|
description: S.string,
|
|
143
143
|
website: S.string,
|
|
@@ -148,14 +148,14 @@ var testSchemas = () => {
|
|
|
148
148
|
org: ref(organization)
|
|
149
149
|
});
|
|
150
150
|
return {
|
|
151
|
-
["example.com/
|
|
152
|
-
["example.com/
|
|
153
|
-
["example.com/
|
|
154
|
-
["example.com/
|
|
151
|
+
["example.com/type/document"]: document,
|
|
152
|
+
["example.com/type/organization"]: organization,
|
|
153
|
+
["example.com/type/contact"]: contact,
|
|
154
|
+
["example.com/type/project"]: project
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
157
|
var testObjectGenerators = {
|
|
158
|
-
["example.com/
|
|
158
|
+
["example.com/type/document"]: async () => ({
|
|
159
159
|
title: faker2.lorem.sentence(3),
|
|
160
160
|
content: faker2.lorem.sentences({
|
|
161
161
|
min: 1,
|
|
@@ -165,15 +165,15 @@ var testObjectGenerators = {
|
|
|
165
165
|
})
|
|
166
166
|
})
|
|
167
167
|
}),
|
|
168
|
-
["example.com/
|
|
168
|
+
["example.com/type/organization"]: async () => ({
|
|
169
169
|
name: faker2.company.name(),
|
|
170
170
|
website: faker2.datatype.boolean({
|
|
171
171
|
probability: 0.3
|
|
172
172
|
}) ? faker2.internet.url() : void 0,
|
|
173
173
|
description: faker2.lorem.sentences()
|
|
174
174
|
}),
|
|
175
|
-
["example.com/
|
|
176
|
-
const organizations = await provider?.("example.com/
|
|
175
|
+
["example.com/type/contact"]: async (provider) => {
|
|
176
|
+
const organizations = await provider?.("example.com/type/organization");
|
|
177
177
|
const location = faker2.datatype.boolean() ? faker2.helpers.arrayElement(locations) : void 0;
|
|
178
178
|
return {
|
|
179
179
|
name: faker2.person.fullName(),
|
|
@@ -186,7 +186,7 @@ var testObjectGenerators = {
|
|
|
186
186
|
...location
|
|
187
187
|
};
|
|
188
188
|
},
|
|
189
|
-
["example.com/
|
|
189
|
+
["example.com/type/project"]: async () => ({
|
|
190
190
|
name: faker2.commerce.productName(),
|
|
191
191
|
repo: faker2.datatype.boolean({
|
|
192
192
|
probability: 0.3
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { type Space } from '@dxos/client/echo';\nimport { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.description('name of the project')),\n description: S.string,\n website: S.string,\n repo: S.string,\n status: S.string,\n priority: S.number,\n active: S.boolean,\n org: ref(organization),\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAQA,SAASA,
|
|
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 { create, DynamicEchoSchema, echoObject, effectToJsonSchema, ref, S, StoredEchoSchema } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/type/document',\n organization = 'example.com/type/organization',\n contact = 'example.com/type/contact',\n project = 'example.com/type/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.description('name of the project')),\n description: S.string,\n website: S.string,\n repo: S.string,\n status: S.string,\n priority: S.number,\n active: S.boolean,\n org: ref(organization),\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAQA,SAASA,UAAAA,SAAQC,mBAAmBC,YAAYC,oBAAoBC,KAAKC,GAAGC,wBAAwB;AACpG,SAASC,SAAAA,cAAa;;;ACLtB,SAAqBC,cAAc;AAEnC,SAASC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,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": ["create", "DynamicEchoSchema", "echoObject", "effectToJsonSchema", "ref", "S", "StoredEchoSchema", "faker", "Filter", "create", "faker", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "map", "tasks", "entries", "count", "range", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "schemaRegistry", "getRegisteredByTypename", "add", "addSchemas", "result", "existing", "push", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "typename", "fields", "typeSchema", "S", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "create", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "number", "lng", "project", "repo", "status", "priority", "active", "boolean", "testObjectGenerators", "faker", "lorem", "sentence", "sentences", "min", "max", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "helpers", "arrayElement", "locations", "person", "fullName", "length", "commerce", "productName", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":
|
|
1
|
+
{"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35579,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1005,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23468},"packages/core/echo/echo-generator/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10276},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2426},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13401}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -119,10 +119,10 @@ var Priority = [
|
|
|
119
119
|
];
|
|
120
120
|
var TestSchemaType;
|
|
121
121
|
(function(TestSchemaType2) {
|
|
122
|
-
TestSchemaType2["document"] = "example.com/
|
|
123
|
-
TestSchemaType2["organization"] = "example.com/
|
|
124
|
-
TestSchemaType2["contact"] = "example.com/
|
|
125
|
-
TestSchemaType2["project"] = "example.com/
|
|
122
|
+
TestSchemaType2["document"] = "example.com/type/document";
|
|
123
|
+
TestSchemaType2["organization"] = "example.com/type/organization";
|
|
124
|
+
TestSchemaType2["contact"] = "example.com/type/contact";
|
|
125
|
+
TestSchemaType2["project"] = "example.com/type/project";
|
|
126
126
|
})(TestSchemaType || (TestSchemaType = {}));
|
|
127
127
|
var createDynamicSchema = (typename, fields) => {
|
|
128
128
|
const typeSchema = import_echo_schema.S.partial(import_echo_schema.S.struct(fields)).pipe((0, import_echo_schema.echoObject)(typename, "1.0.0"));
|
|
@@ -133,23 +133,23 @@ var createDynamicSchema = (typename, fields) => {
|
|
|
133
133
|
}));
|
|
134
134
|
};
|
|
135
135
|
var testSchemas = () => {
|
|
136
|
-
const document = createDynamicSchema("example.com/
|
|
136
|
+
const document = createDynamicSchema("example.com/type/document", {
|
|
137
137
|
title: import_echo_schema.S.string.pipe(import_echo_schema.S.description("title of the document")),
|
|
138
138
|
content: import_echo_schema.S.string
|
|
139
139
|
});
|
|
140
|
-
const organization = createDynamicSchema("example.com/
|
|
140
|
+
const organization = createDynamicSchema("example.com/type/organization", {
|
|
141
141
|
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the company or organization")),
|
|
142
142
|
website: import_echo_schema.S.string.pipe(import_echo_schema.S.description("public website URL")),
|
|
143
143
|
description: import_echo_schema.S.string.pipe(import_echo_schema.S.description("short summary of the company"))
|
|
144
144
|
});
|
|
145
|
-
const contact = createDynamicSchema("example.com/
|
|
145
|
+
const contact = createDynamicSchema("example.com/type/contact", {
|
|
146
146
|
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the person")),
|
|
147
147
|
email: import_echo_schema.S.string,
|
|
148
148
|
org: (0, import_echo_schema.ref)(organization),
|
|
149
149
|
lat: import_echo_schema.S.number,
|
|
150
150
|
lng: import_echo_schema.S.number
|
|
151
151
|
});
|
|
152
|
-
const project = createDynamicSchema("example.com/
|
|
152
|
+
const project = createDynamicSchema("example.com/type/project", {
|
|
153
153
|
name: import_echo_schema.S.string.pipe(import_echo_schema.S.description("name of the project")),
|
|
154
154
|
description: import_echo_schema.S.string,
|
|
155
155
|
website: import_echo_schema.S.string,
|
|
@@ -160,14 +160,14 @@ var testSchemas = () => {
|
|
|
160
160
|
org: (0, import_echo_schema.ref)(organization)
|
|
161
161
|
});
|
|
162
162
|
return {
|
|
163
|
-
["example.com/
|
|
164
|
-
["example.com/
|
|
165
|
-
["example.com/
|
|
166
|
-
["example.com/
|
|
163
|
+
["example.com/type/document"]: document,
|
|
164
|
+
["example.com/type/organization"]: organization,
|
|
165
|
+
["example.com/type/contact"]: contact,
|
|
166
|
+
["example.com/type/project"]: project
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
169
|
var testObjectGenerators = {
|
|
170
|
-
["example.com/
|
|
170
|
+
["example.com/type/document"]: async () => ({
|
|
171
171
|
title: import_random.faker.lorem.sentence(3),
|
|
172
172
|
content: import_random.faker.lorem.sentences({
|
|
173
173
|
min: 1,
|
|
@@ -177,15 +177,15 @@ var testObjectGenerators = {
|
|
|
177
177
|
})
|
|
178
178
|
})
|
|
179
179
|
}),
|
|
180
|
-
["example.com/
|
|
180
|
+
["example.com/type/organization"]: async () => ({
|
|
181
181
|
name: import_random.faker.company.name(),
|
|
182
182
|
website: import_random.faker.datatype.boolean({
|
|
183
183
|
probability: 0.3
|
|
184
184
|
}) ? import_random.faker.internet.url() : void 0,
|
|
185
185
|
description: import_random.faker.lorem.sentences()
|
|
186
186
|
}),
|
|
187
|
-
["example.com/
|
|
188
|
-
const organizations = await provider?.("example.com/
|
|
187
|
+
["example.com/type/contact"]: async (provider) => {
|
|
188
|
+
const organizations = await provider?.("example.com/type/organization");
|
|
189
189
|
const location = import_random.faker.datatype.boolean() ? import_random.faker.helpers.arrayElement(locations) : void 0;
|
|
190
190
|
return {
|
|
191
191
|
name: import_random.faker.person.fullName(),
|
|
@@ -198,7 +198,7 @@ var testObjectGenerators = {
|
|
|
198
198
|
...location
|
|
199
199
|
};
|
|
200
200
|
},
|
|
201
|
-
["example.com/
|
|
201
|
+
["example.com/type/project"]: async () => ({
|
|
202
202
|
name: import_random.faker.commerce.productName(),
|
|
203
203
|
repo: import_random.faker.datatype.boolean({
|
|
204
204
|
probability: 0.3
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { type Space } from '@dxos/client/echo';\nimport { S, DynamicEchoSchema, effectToJsonSchema, StoredEchoSchema, create, ref, echoObject } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/schema/document',\n organization = 'example.com/schema/organization',\n contact = 'example.com/schema/contact',\n project = 'example.com/schema/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.description('name of the project')),\n description: S.string,\n website: S.string,\n repo: S.string,\n status: S.string,\n priority: S.number,\n active: S.boolean,\n org: ref(organization),\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,yBAAoG;AACpG,oBAAsB;ACLtB,kBAAmC;AAEnC,IAAAA,sBAAuB;AACvB,IAAAC,iBAAsB;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;ADQL,IAAMC,sBAAN,MAAMA;;EAEXC,YACmBC,UACAC,aACAC,WACjB;SAHiBF,WAAAA;SACAC,cAAAA;SACAC,YAAAA;EAChB;EAEH,IAAIC,UAA+B;AACjC,WAAOC,OAAOC,OAAO,KAAKL,QAAQ;EACpC;EAEAM,UAAUC,MAAwC;AAChD,WAAO,KAAKJ,QAAQK,KAAK,CAACC,WAAWA,OAAOC,aAAaH,IAAAA;EAC3D;EAEUI,UAAUJ,MAASE,QAA2B;AACtD,SAAKT,SAASO,IAAAA,IAAQE;EACxB;;EAGA,MAAMG,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiC;AAChF,UAAMN,OAAOO,qBAAMC,QAAQC,aAAaH,SAAUT,OAAOa,KAAK,KAA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OG,GAAGO,eAAeC,wBAAwB/B,OAAOC,QAAQ;AACtF,UAAIkC,YAAY,MAAM;AACpBD,eAAOE,KAAK,KAAKhB,OAAOG,GAAGO,eAAeE,IAAIhC,OAAOA,MAAM,CAAA;MAC7D,OAAO;AACLkC,eAAOE,KAAKD,QAAAA;MACd;IACF,CAAA;AAEA,WAAOD;EACT;EAEA,MAAe/B,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAiC;AACzF,WAAO,KAAKgB,OAAOG,GAAGS,IAAI,MAAM,MAAM7B,aAAa;MAAEC;IAAM,CAAA,CAAA;EAC7D;AACF;ADpFO,IAAMiC,SAAS;EAAC;EAAW;EAAU;;AACrC,IAAMC,WAAW;EAAC;EAAG;EAAG;EAAG;EAAG;;;UAEzBC,iBAAAA;;;;;GAAAA,mBAAAA,iBAAAA,CAAAA,EAAAA;AAOZ,IAAMC,sBAAsB,CAACvC,UAAkBwC,WAAAA;AAC7C,QAAMC,aAAaC,qBAAEC,QAAQD,qBAAEE,OAAOJ,MAAAA,CAAAA,EAASK,SAAKC,+BAAW9C,UAAU,OAAA,CAAA;AACzE,SAAO,IAAI+C,yCACTtC,mBAAAA,QAAOuC,qCAAkB;IACvBhD;IACAiD,SAAS;IACTC,gBAAYC,uCAAmBV,UAAAA;EACjC,CAAA,CAAA;AAEJ;AAEA,IAAMW,cAAc,MAAA;AAClB,QAAMC,WAAWd,oBAAAA
|
|
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 { create, DynamicEchoSchema, echoObject, effectToJsonSchema, ref, S, StoredEchoSchema } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport enum TestSchemaType {\n document = 'example.com/type/document',\n organization = 'example.com/type/organization',\n contact = 'example.com/type/contact',\n project = 'example.com/type/project',\n}\n\nconst createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {\n const typeSchema = S.partial(S.struct(fields)).pipe(echoObject(typename, '1.0.0'));\n return new DynamicEchoSchema(\n create(StoredEchoSchema, {\n typename,\n version: '1.0.0',\n jsonSchema: effectToJsonSchema(typeSchema),\n }),\n );\n};\n\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = createDynamicSchema(TestSchemaType.document, {\n title: S.string.pipe(S.description('title of the document')),\n content: S.string,\n });\n\n const organization = createDynamicSchema(TestSchemaType.organization, {\n name: S.string.pipe(S.description('name of the company or organization')),\n website: S.string.pipe(S.description('public website URL')),\n description: S.string.pipe(S.description('short summary of the company')),\n });\n\n const contact = createDynamicSchema(TestSchemaType.contact, {\n name: S.string.pipe(S.description('name of the person')),\n email: S.string,\n org: ref(organization),\n lat: S.number,\n lng: S.number,\n });\n\n const project = createDynamicSchema(TestSchemaType.project, {\n name: S.string.pipe(S.description('name of the project')),\n description: S.string,\n website: S.string,\n repo: S.string,\n status: S.string,\n priority: S.number,\n active: S.boolean,\n org: ref(organization),\n });\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.helpers.arrayElement(locations) : undefined;\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.3 })\n ? faker.helpers.arrayElement(organizations)\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n\n// TODO(burdon): Move to @dxos/random.\nconst locations = [\n { lat: 139.74946157054467, lng: 35.686962764371174 },\n { lat: -73.98196278740681, lng: 40.75192492259464 },\n { lat: -99.1329340602939, lng: 19.444388301415472 },\n { lat: 72.85504343876647, lng: 19.0189362343566 },\n { lat: -46.62696583905523, lng: -23.55673372837896 },\n { lat: 77.22805816860182, lng: 28.671938757181522 },\n { lat: 121.43455881982015, lng: 31.218398311228327 },\n { lat: 88.32272979950551, lng: 22.49691515689642 },\n { lat: 90.40663360810754, lng: 23.725005570312817 },\n { lat: -58.399477232331435, lng: -34.600555749907414 },\n { lat: -118.18192636994041, lng: 33.99192410876543 },\n { lat: 66.98806305137339, lng: 24.87193814681484 },\n { lat: 31.248022361126118, lng: 30.051906205103705 },\n { lat: -43.22696665284366, lng: -22.923077315615956 },\n { lat: 135.4581989565952, lng: 34.75198107491417 },\n { lat: 116.38633982565943, lng: 39.93083808990906 },\n { lat: 120.9802713035424, lng: 14.606104813440538 },\n { lat: 37.6135769672714, lng: 55.75410998124818 },\n { lat: 29.008055727002613, lng: 41.10694201243979 },\n { lat: 2.33138946713035, lng: 48.86863878981461 },\n { lat: 126.99778513820195, lng: 37.56829495838895 },\n { lat: 3.3895852125984334, lng: 6.445207512093191 },\n { lat: 106.82749176247012, lng: -6.172471846798885 },\n { lat: -87.75200083270931, lng: 41.83193651927843 },\n { lat: 113.32306427226172, lng: 23.14692716047989 },\n { lat: -0.11866770247593195, lng: 51.5019405883275 },\n { lat: -77.05200795343472, lng: -12.04606681752557 },\n { lat: 51.42239817500899, lng: 35.673888627001304 },\n { lat: 15.313026023171744, lng: -4.327778243275986 },\n { lat: -74.08528981377441, lng: 4.598369421147822 },\n { lat: 114.1201772298325, lng: 22.554316369677963 },\n { lat: 114.26807118958311, lng: 30.581977209337822 },\n { lat: 114.18306345846304, lng: 22.30692675357551 },\n { lat: 117.19807322410043, lng: 39.13197212310894 },\n { lat: 80.27805287890033, lng: 13.091933670856292 },\n { lat: 121.568333333333, lng: 25.0358333333333 },\n { lat: 77.55806386521755, lng: 12.97194099507442 },\n { lat: 100.51469879369489, lng: 13.751945064087977 },\n { lat: 74.34807892054346, lng: 31.56191739488844 },\n { lat: 106.59303578916195, lng: 29.566922888044644 },\n { lat: 78.47800771287751, lng: 17.401928991511454 },\n { lat: -70.66898671317483, lng: -33.448067956934096 },\n { lat: -80.22605193945003, lng: 25.789556555021534 },\n { lat: -43.916950376804834, lng: -19.91308016391116 },\n { lat: -3.6852975446125242, lng: 40.40197212311381 },\n { lat: -75.17194183200792, lng: 40.001919022526465 },\n { lat: 72.57805776168215, lng: 23.031998775062675 },\n { lat: 106.69308136207889, lng: 10.781971309193409 },\n { lat: -79.42196665298843, lng: 43.70192573640844 },\n { lat: 103.85387481909902, lng: 1.2949793251059418 },\n { lat: 13.23248118266855, lng: -8.836340255012658 },\n { lat: 44.391922914564134, lng: 33.34059435615865 },\n { lat: 2.181424460619155, lng: 41.385245438547486 },\n { lat: 88.32994665421205, lng: 22.580390440861947 },\n { lat: -96.84196278749818, lng: 32.82196968167733 },\n { lat: 123.44802765120869, lng: 41.80692512604918 },\n { lat: 32.532233380011576, lng: 15.590024084277673 },\n { lat: 73.84805776168719, lng: 18.531963374654026 },\n { lat: 151.1832339501475, lng: -33.91806510862875 },\n { lat: 30.314074200315076, lng: 59.94096036375191 },\n { lat: 91.79802154756635, lng: 22.33193814680459 },\n { lat: 113.74277634138707, lng: 23.050834758613007 },\n { lat: -84.40189524187565, lng: 33.83195971260585 },\n { lat: -71.07195953218684, lng: 42.33190600170229 },\n { lat: 46.770795798688255, lng: 24.642779007816443 },\n { lat: -95.341925149146, lng: 29.821920243188856 },\n { lat: 105.8480683412422, lng: 21.035273107737055 },\n { lat: -77.01136443943716, lng: 38.901495235087054 },\n { lat: -103.33198008081848, lng: 20.671961950508944 },\n { lat: 144.97307037590406, lng: -37.81808545369631 },\n { lat: 29.948050030391755, lng: 31.201965205759393 },\n { lat: 104.06807363094873, lng: 30.671945877957796 },\n { lat: -83.0820016464927, lng: 42.33190600170229 },\n { lat: 96.16473175266185, lng: 16.785299963188777 },\n { lat: 108.89305043760862, lng: 34.27697130928732 },\n { lat: -51.20195790450316, lng: -30.048068770722466 },\n { lat: 121.465, lng: 25.0127777777778 },\n { lat: 72.83809356897484, lng: 21.20192960187819 },\n { lat: 109.60911291406296, lng: 23.09653464659317 },\n { lat: -4.041994118507091, lng: 5.321942826098564 },\n { lat: -47.91799814700306, lng: -15.781394372878992 },\n { lat: 32.862445782356644, lng: 39.929184444075474 },\n { lat: -100.33193064232995, lng: 25.671940995125283 },\n { lat: 139.60202098994017, lng: 35.43065615270891 },\n { lat: 118.77802846499208, lng: 32.05196500231233 },\n { lat: -73.58524281670213, lng: 45.50194506421502 },\n { lat: 106.7180927553083, lng: 26.581988806001448 },\n { lat: -34.91755136960728, lng: -8.073699467249241 },\n { lat: 126.64803904445057, lng: 45.75192980542715 },\n { lat: -38.58192718342411, lng: -3.7480720258257634 },\n { lat: -112.07193755969467, lng: 33.5419257363676 },\n { lat: 117.67001623440774, lng: 24.520375385531167 },\n { lat: -38.48193328693924, lng: -12.968026046044827 },\n { lat: 129.00810170722048, lng: 35.09699877511093 },\n { lat: -122.41716877355225, lng: 37.76919562968743 },\n { lat: 28.028063865019476, lng: -26.16809888138414 },\n { lat: 13.399602764700546, lng: 52.523764522251156 },\n { lat: 3.048606670909237, lng: 36.765010656628135 },\n { lat: 125.75274485499392, lng: 39.02138455800434 },\n { lat: 12.481312562873995, lng: 41.89790148509894 },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Space, Filter } from '@dxos/client/echo';\nimport { type DynamicEchoSchema, type ReactiveObject } from '@dxos/echo-schema';\nimport { create } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { type TestSchemaType } from './data';\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n private readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): DynamicEchoSchema[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): DynamicEchoSchema | undefined {\n return this.schemas.find((schema) => schema.typename === type);\n }\n\n protected setSchema(type: T, schema: DynamicEchoSchema) {\n this._schemas[type] = schema;\n }\n\n // TODO(burdon): Runtime type check via: https://github.com/Effect-TS/schema (or zod).\n async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n const schema = this.getSchema(type);\n return schema ? create(schema, data) : create(data);\n }\n\n // TODO(burdon): Create batch.\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>): Promise<ReactiveObject<any>[]> {\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(() => this.createObject({ types: [type as T] }), count);\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n return (schema && (await this._space.db.query(Filter.schema(schema)).run()).objects) ?? [];\n });\n\n // TODO(burdon): Map initially are objects that have not been added to the space.\n // Merge existing schema in space with defaults.\n Object.entries<DynamicEchoSchema>(schemaMap).forEach(([type, dynamicSchema]) => {\n let schema = this._space.db.schemaRegistry.getRegisteredByTypename(type);\n if (schema == null) {\n schema = this._space.db.schemaRegistry.add(dynamicSchema.schema);\n }\n this.setSchema(type as T, schema);\n });\n }\n\n addSchemas() {\n const result: DynamicEchoSchema[] = [];\n this.schemas.forEach((schema) => {\n const existing = this._space.db.schemaRegistry.getRegisteredByTypename(schema.typename);\n if (existing == null) {\n result.push(this._space.db.schemaRegistry.add(schema.schema));\n } else {\n result.push(existing);\n }\n });\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<ReactiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,yBAAoG;AACpG,oBAAsB;ACLtB,kBAAmC;AAEnC,IAAAA,sBAAuB;AACvB,IAAAC,iBAAsB;ACFf,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;ADQL,IAAMC,sBAAN,MAAMA;;E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kB;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
6
|
"names": ["import_echo_schema", "import_random", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "create", "createObjects", "tasks", "entries", "count", "flatMap", "t", "Promise", "all", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "db", "query", "Filter", "run", "objects", "forEach", "dynamicSchema", "schemaRegistry", "getRegisteredByTypename", "add", "addSchemas", "result", "existing", "push", "Status", "Priority", "TestSchemaType", "createDynamicSchema", "fields", "typeSchema", "S", "partial", "struct", "pipe", "echoObject", "DynamicEchoSchema", "StoredEchoSchema", "version", "jsonSchema", "effectToJsonSchema", "testSchemas", "document", "title", "string", "description", "content", "organization", "name", "website", "contact", "email", "org", "ref", "lat", "number", "lng", "project", "repo", "status", "priority", "active", "boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "int", "company", "datatype", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "locations", "person", "fullName", "commerce", "productName", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-generator/src/util.ts":{"bytes":1057,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/generator.ts":{"bytes":11762,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":35579,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1005,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23459},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","range"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":10276},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":2426},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":13253}}}
|
package/dist/types/src/data.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
|
|
|
3
3
|
export declare const Status: string[];
|
|
4
4
|
export declare const Priority: number[];
|
|
5
5
|
export declare enum TestSchemaType {
|
|
6
|
-
document = "example.com/
|
|
7
|
-
organization = "example.com/
|
|
8
|
-
contact = "example.com/
|
|
9
|
-
project = "example.com/
|
|
6
|
+
document = "example.com/type/document",
|
|
7
|
+
organization = "example.com/type/organization",
|
|
8
|
+
contact = "example.com/type/contact",
|
|
9
|
+
project = "example.com/type/project"
|
|
10
10
|
}
|
|
11
11
|
export declare const createTestObjectGenerator: () => TestObjectGenerator<TestSchemaType>;
|
|
12
12
|
export declare const createSpaceObjectGenerator: (space: Space) => SpaceObjectGenerator<TestSchemaType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,6BAA6B;IACpC,OAAO,6BAA6B;CACrC;AAuFD,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-generator",
|
|
3
|
-
"version": "0.5.3-main.
|
|
3
|
+
"version": "0.5.3-main.eb56347",
|
|
4
4
|
"description": "ECHO data generator for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dxos/client": "0.5.3-main.
|
|
20
|
-
"@dxos/echo-schema": "0.5.3-main.
|
|
21
|
-
"@dxos/node-std": "0.5.3-main.
|
|
22
|
-
"@dxos/random": "0.5.3-main.
|
|
19
|
+
"@dxos/client": "0.5.3-main.eb56347",
|
|
20
|
+
"@dxos/echo-schema": "0.5.3-main.eb56347",
|
|
21
|
+
"@dxos/node-std": "0.5.3-main.eb56347",
|
|
22
|
+
"@dxos/random": "0.5.3-main.eb56347"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {},
|
|
25
25
|
"publishConfig": {
|
package/src/data.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).
|
|
7
7
|
|
|
8
8
|
import { type Space } from '@dxos/client/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { create, DynamicEchoSchema, echoObject, effectToJsonSchema, ref, S, StoredEchoSchema } from '@dxos/echo-schema';
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
11
11
|
|
|
12
12
|
import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
|
|
@@ -17,10 +17,10 @@ export const Status = ['pending', 'active', 'done'];
|
|
|
17
17
|
export const Priority = [1, 2, 3, 4, 5];
|
|
18
18
|
|
|
19
19
|
export enum TestSchemaType {
|
|
20
|
-
document = 'example.com/
|
|
21
|
-
organization = 'example.com/
|
|
22
|
-
contact = 'example.com/
|
|
23
|
-
project = 'example.com/
|
|
20
|
+
document = 'example.com/type/document',
|
|
21
|
+
organization = 'example.com/type/organization',
|
|
22
|
+
contact = 'example.com/type/contact',
|
|
23
|
+
project = 'example.com/type/project',
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const createDynamicSchema = (typename: string, fields: S.Struct.Fields): DynamicEchoSchema => {
|