@dxos/echo-generator 0.8.3 → 0.8.4-main.84f28bd

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-generator",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.84f28bd",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -24,24 +24,24 @@
24
24
  "src"
25
25
  ],
26
26
  "dependencies": {
27
- "@automerge/automerge": "3.0.0-beta.4",
28
- "effect": "3.14.21",
29
- "@dxos/client": "0.8.3",
30
- "@dxos/echo-db": "0.8.3",
31
- "@dxos/echo-schema": "0.8.3",
32
- "@dxos/live-object": "0.8.3",
33
- "@dxos/log": "0.8.3",
34
- "@dxos/node-std": "0.8.3",
35
- "@dxos/schema": "0.8.3",
36
- "@dxos/util": "0.8.3",
37
- "@dxos/invariant": "0.8.3"
27
+ "@automerge/automerge": "3.0.0",
28
+ "effect": "3.16.13",
29
+ "@dxos/client": "0.8.4-main.84f28bd",
30
+ "@dxos/echo-schema": "0.8.4-main.84f28bd",
31
+ "@dxos/echo-db": "0.8.4-main.84f28bd",
32
+ "@dxos/invariant": "0.8.4-main.84f28bd",
33
+ "@dxos/live-object": "0.8.4-main.84f28bd",
34
+ "@dxos/log": "0.8.4-main.84f28bd",
35
+ "@dxos/node-std": "0.8.4-main.84f28bd",
36
+ "@dxos/schema": "0.8.4-main.84f28bd",
37
+ "@dxos/util": "0.8.4-main.84f28bd"
38
38
  },
39
39
  "devDependencies": {
40
- "@dxos/random": "0.8.3"
40
+ "@dxos/random": "0.8.4-main.84f28bd"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "effect": "^3.13.3",
44
- "@dxos/random": "0.8.3"
44
+ "@dxos/random": "0.8.4-main.84f28bd"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
@@ -8,8 +8,7 @@ import { describe, expect, onTestFinished, test } from 'vitest';
8
8
 
9
9
  import { Client } from '@dxos/client';
10
10
  import { getObjectCore } from '@dxos/echo-db';
11
- import { TypedObject } from '@dxos/echo-schema';
12
- import { getType } from '@dxos/live-object';
11
+ import { TypedObject, getType } from '@dxos/echo-schema';
13
12
  import { faker } from '@dxos/random';
14
13
 
15
14
  import { createSpaceObjectGenerator, createTestObjectGenerator, TestSchemaType } from './data';
@@ -1,322 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var node_exports = {};
20
- __export(node_exports, {
21
- Priority: () => Priority,
22
- SpaceObjectGenerator: () => SpaceObjectGenerator,
23
- Status: () => Status,
24
- TestObjectGenerator: () => TestObjectGenerator,
25
- TestSchemaType: () => TestSchemaType,
26
- createSpaceObjectGenerator: () => createSpaceObjectGenerator,
27
- createTestObjectGenerator: () => createTestObjectGenerator,
28
- randomText: () => randomText
29
- });
30
- module.exports = __toCommonJS(node_exports);
31
- var import_automerge = require("@automerge/automerge");
32
- var import_effect = require("effect");
33
- var import_echo = require("@dxos/client/echo");
34
- var import_echo_schema = require("@dxos/echo-schema");
35
- var import_random = require("@dxos/random");
36
- var import_echo2 = require("@dxos/client/echo");
37
- var import_echo_schema2 = require("@dxos/echo-schema");
38
- var import_invariant = require("@dxos/invariant");
39
- var import_live_object = require("@dxos/live-object");
40
- var import_random2 = require("@dxos/random");
41
- var import_util = require("@dxos/util");
42
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
43
- var TestObjectGenerator = class {
44
- // prettier-ignore
45
- constructor(_schemas, _generators, _provider) {
46
- this._schemas = _schemas;
47
- this._generators = _generators;
48
- this._provider = _provider;
49
- }
50
- get schemas() {
51
- return Object.values(this._schemas);
52
- }
53
- getSchema(type) {
54
- return this.schemas.find((schema) => (0, import_echo_schema2.getTypeAnnotation)(schema).typename === type);
55
- }
56
- setSchema(type, schema) {
57
- this._schemas[type] = schema;
58
- }
59
- async createObject({ types } = {}) {
60
- const type = import_random2.faker.helpers.arrayElement(types ?? Object.keys(this._schemas));
61
- const data = await this._generators[type](this._provider);
62
- if ((0, import_live_object.isLiveObject)(data)) {
63
- return data;
64
- }
65
- const schema = this.getSchema(type);
66
- return schema ? (0, import_live_object.live)(schema, data) : (0, import_live_object.live)(data);
67
- }
68
- // TODO(burdon): Based on dependencies (e.g., organization before contact).
69
- async createObjects(map) {
70
- const results = [];
71
- for (const [type, count] of (0, import_util.entries)(map)) {
72
- results.push(...await Promise.all((0, import_util.range)(count ?? 0, () => this.createObject({
73
- types: [
74
- type
75
- ]
76
- }))));
77
- }
78
- const tasks = Object.entries(map).map(([type, count]) => {
79
- return (0, import_util.range)(count, () => this.createObject({
80
- types: [
81
- type
82
- ]
83
- }));
84
- }).flatMap((t) => t);
85
- return Promise.all(tasks);
86
- }
87
- };
88
- var SpaceObjectGenerator = class extends TestObjectGenerator {
89
- constructor(_space, schemaMap, generators, _mutations) {
90
- super(schemaMap, generators, async (type) => {
91
- const schema = this.getSchema(type);
92
- const { objects } = await this._space.db.query(schema ? import_echo2.Filter.type(schema) : import_echo2.Filter.nothing()).run();
93
- return objects;
94
- }), this._space = _space, this._mutations = _mutations;
95
- }
96
- async addSchemas() {
97
- const result = [];
98
- for (const [typename, schema] of Object.entries(this._schemas)) {
99
- const echoSchema = await this._maybeRegisterSchema(typename, schema);
100
- this.setSchema(typename, echoSchema);
101
- result.push(echoSchema);
102
- }
103
- return result;
104
- }
105
- async createObject({ types } = {}) {
106
- return this._space.db.add(await super.createObject({
107
- types
108
- }));
109
- }
110
- async _maybeRegisterSchema(typename, schema) {
111
- if (schema instanceof import_echo_schema2.EchoSchema) {
112
- const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
113
- if (existingSchema != null) {
114
- return existingSchema;
115
- }
116
- const [registeredSchema] = await this._space.db.schemaRegistry.register([
117
- schema
118
- ]);
119
- return registeredSchema;
120
- } else {
121
- const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
122
- if (existingSchema != null) {
123
- return existingSchema;
124
- }
125
- this._space.db.graph.schemaRegistry.addSchema([
126
- schema
127
- ]);
128
- return schema;
129
- }
130
- }
131
- async mutateObject(object, params) {
132
- (0, import_invariant.invariant)(this._mutations, "Mutations not defined.", {
133
- F: __dxlog_file,
134
- L: 130,
135
- S: this,
136
- A: [
137
- "this._mutations",
138
- "'Mutations not defined.'"
139
- ]
140
- });
141
- const type = (0, import_echo_schema2.getTypeAnnotation)((0, import_echo_schema2.getSchema)(object)).typename;
142
- (0, import_invariant.invariant)(type && this._mutations?.[type], "Invalid object type.", {
143
- F: __dxlog_file,
144
- L: 132,
145
- S: this,
146
- A: [
147
- "type && this._mutations?.[type]",
148
- "'Invalid object type.'"
149
- ]
150
- });
151
- await this._mutations[type](object, params);
152
- }
153
- async mutateObjects(objects, params) {
154
- for (const object of objects) {
155
- await this.mutateObject(object, params);
156
- }
157
- }
158
- };
159
- var randomText = (length) => {
160
- let result = "";
161
- const characters = "abcdefghijklmnopqrstuvwxyz";
162
- const charactersLength = characters.length;
163
- for (let index = 0; index < length; index++) {
164
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
165
- }
166
- return result;
167
- };
168
- var Status = [
169
- "pending",
170
- "active",
171
- "done"
172
- ];
173
- var Priority = [
174
- 1,
175
- 2,
176
- 3,
177
- 4,
178
- 5
179
- ];
180
- var TestSchemaType = /* @__PURE__ */ function(TestSchemaType2) {
181
- TestSchemaType2["document"] = "example.com/type/Document";
182
- TestSchemaType2["organization"] = "example.com/type/Organization";
183
- TestSchemaType2["contact"] = "example.com/type/Contact";
184
- TestSchemaType2["project"] = "example.com/type/Project";
185
- return TestSchemaType2;
186
- }({});
187
- var testSchemas = () => {
188
- const document = import_effect.Schema.Struct({
189
- title: import_effect.Schema.String.annotations({
190
- description: "title of the document"
191
- }),
192
- content: import_effect.Schema.String
193
- }).pipe((0, import_echo_schema.EchoObject)({
194
- typename: "example.com/type/Document",
195
- version: "0.1.0"
196
- }));
197
- const organization = import_effect.Schema.Struct({
198
- name: import_effect.Schema.String.annotations({
199
- description: "name of the company or organization"
200
- }),
201
- website: import_effect.Schema.optional(import_effect.Schema.String.annotations({
202
- description: "public website URL"
203
- })),
204
- description: import_effect.Schema.String.annotations({
205
- description: "short summary of the company"
206
- })
207
- }).pipe((0, import_echo_schema.EchoObject)({
208
- typename: "example.com/type/Organization",
209
- version: "0.1.0"
210
- }));
211
- const contact = import_effect.Schema.Struct({
212
- name: import_effect.Schema.String.annotations({
213
- description: "name of the person"
214
- }),
215
- email: import_effect.Schema.optional(import_effect.Schema.String),
216
- org: import_effect.Schema.optional((0, import_echo_schema.Ref)(organization)),
217
- lat: import_effect.Schema.optional(import_effect.Schema.Number),
218
- lng: import_effect.Schema.optional(import_effect.Schema.Number)
219
- }).pipe((0, import_echo_schema.EchoObject)({
220
- typename: "example.com/type/Contact",
221
- version: "0.1.0"
222
- }));
223
- const project = import_effect.Schema.Struct({
224
- name: import_effect.Schema.String.annotations({
225
- description: "name of the project"
226
- }),
227
- description: import_effect.Schema.String,
228
- website: import_effect.Schema.String,
229
- repo: import_effect.Schema.String,
230
- status: import_effect.Schema.String,
231
- priority: import_effect.Schema.Number,
232
- active: import_effect.Schema.Boolean,
233
- org: import_effect.Schema.optional((0, import_echo_schema.Ref)(organization))
234
- }).pipe((0, import_echo_schema.EchoObject)({
235
- typename: "example.com/type/Project",
236
- version: "0.1.0"
237
- }));
238
- return {
239
- ["example.com/type/Document"]: document,
240
- ["example.com/type/Organization"]: organization,
241
- ["example.com/type/Contact"]: contact,
242
- ["example.com/type/Project"]: project
243
- };
244
- };
245
- var testObjectGenerators = {
246
- ["example.com/type/Document"]: async () => ({
247
- title: import_random.faker.lorem.sentence(3),
248
- content: import_random.faker.lorem.sentences({
249
- min: 1,
250
- max: import_random.faker.number.int({
251
- min: 1,
252
- max: 3
253
- })
254
- })
255
- }),
256
- ["example.com/type/Organization"]: async () => ({
257
- name: import_random.faker.company.name(),
258
- website: import_random.faker.datatype.boolean({
259
- probability: 0.3
260
- }) ? import_random.faker.internet.url() : void 0,
261
- description: import_random.faker.lorem.sentences()
262
- }),
263
- ["example.com/type/Contact"]: async (provider) => {
264
- const organizations = await provider?.("example.com/type/Organization");
265
- const location = import_random.faker.datatype.boolean() ? import_random.faker.geo.airport() : {};
266
- return {
267
- name: import_random.faker.person.fullName(),
268
- email: import_random.faker.datatype.boolean({
269
- probability: 0.5
270
- }) ? import_random.faker.internet.email() : void 0,
271
- org: organizations?.length && import_random.faker.datatype.boolean({
272
- probability: 0.8
273
- }) ? import_echo_schema.Ref.make(import_random.faker.helpers.arrayElement(organizations)) : void 0,
274
- ...location
275
- };
276
- },
277
- ["example.com/type/Project"]: async () => ({
278
- name: import_random.faker.commerce.productName(),
279
- repo: import_random.faker.internet.url(),
280
- status: import_random.faker.helpers.arrayElement(Status),
281
- description: import_random.faker.lorem.sentences(),
282
- website: import_random.faker.internet.url(),
283
- priority: import_random.faker.helpers.arrayElement(Priority),
284
- active: import_random.faker.datatype.boolean()
285
- })
286
- };
287
- var testObjectMutators = {
288
- ["example.com/type/Document"]: async (object, params) => {
289
- const accessor = (0, import_echo.createDocAccessor)(object, [
290
- "content"
291
- ]);
292
- for (let i = 0; i < params.count; i++) {
293
- const length = object.content?.content?.length ?? 0;
294
- accessor.handle.change((doc) => {
295
- import_automerge.next.splice(doc, accessor.path.slice(), 0, params.maxContentLength >= length ? 0 : params.mutationSize, randomText(params.mutationSize));
296
- });
297
- }
298
- },
299
- ["example.com/type/Organization"]: async () => {
300
- throw new Error("Method not implemented.");
301
- },
302
- ["example.com/type/Contact"]: async () => {
303
- throw new Error("Method not implemented.");
304
- },
305
- ["example.com/type/Project"]: async () => {
306
- throw new Error("Method not implemented.");
307
- }
308
- };
309
- var createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
310
- var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);
311
- // Annotate the CommonJS export names for ESM import in node:
312
- 0 && (module.exports = {
313
- Priority,
314
- SpaceObjectGenerator,
315
- Status,
316
- TestObjectGenerator,
317
- TestSchemaType,
318
- createSpaceObjectGenerator,
319
- createTestObjectGenerator,
320
- randomText
321
- });
322
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { next as A } from '@automerge/automerge';\nimport { Schema } from 'effect';\n\nimport { createDocAccessor, type Space } from '@dxos/client/echo';\nimport { EchoObject, Ref } from '@dxos/echo-schema';\nimport { faker } from '@dxos/random';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestMutationsMap, type TestSchemaMap } from './types';\nimport { randomText } from './util';\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\n/**\n * @deprecated\n */\nexport enum TestSchemaType {\n document = 'example.com/type/Document',\n organization = 'example.com/type/Organization',\n contact = 'example.com/type/Contact',\n project = 'example.com/type/Project',\n}\n\n/**\n * @deprecated\n */\nconst testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = Schema.Struct({\n title: Schema.String.annotations({ description: 'title of the document' }),\n content: Schema.String,\n }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));\n\n const organization = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the company or organization' }),\n website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),\n description: Schema.String.annotations({ description: 'short summary of the company' }),\n }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));\n\n const contact = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the person' }),\n email: Schema.optional(Schema.String),\n org: Schema.optional(Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));\n\n const project = Schema.Struct({\n name: Schema.String.annotations({ description: 'name of the project' }),\n description: Schema.String,\n website: Schema.String,\n repo: Schema.String,\n status: Schema.String,\n priority: Schema.Number,\n active: Schema.Boolean,\n org: Schema.optional(Ref(organization)),\n }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));\n\n return {\n [TestSchemaType.document]: document,\n [TestSchemaType.organization]: organization,\n [TestSchemaType.contact]: contact,\n [TestSchemaType.project]: project,\n };\n};\n\nconst testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n [TestSchemaType.document]: async () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: faker.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = faker.datatype.boolean() ? faker.geo.airport() : {};\n\n return {\n name: faker.person.fullName(),\n email: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.email() : undefined,\n org:\n organizations?.length && faker.datatype.boolean({ probability: 0.8 })\n ? Ref.make(faker.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: faker.commerce.productName(),\n repo: faker.internet.url(),\n status: faker.helpers.arrayElement(Status),\n description: faker.lorem.sentences(),\n website: faker.internet.url(),\n priority: faker.helpers.arrayElement(Priority),\n active: faker.datatype.boolean(),\n }),\n};\n\nconst testObjectMutators: TestMutationsMap<TestSchemaType> = {\n [TestSchemaType.document]: async (object, params) => {\n const accessor = createDocAccessor(object, ['content']);\n for (let i = 0; i < params.count; i++) {\n const length = object.content?.content?.length ?? 0;\n accessor.handle.change((doc) => {\n A.splice(\n doc,\n accessor.path.slice(),\n 0,\n params.maxContentLength >= length ? 0 : params.mutationSize,\n randomText(params.mutationSize),\n );\n });\n }\n },\n [TestSchemaType.organization]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.contact]: async () => {\n throw new Error('Method not implemented.');\n },\n [TestSchemaType.project]: async () => {\n throw new Error('Method not implemented.');\n },\n};\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\n/**\n * @deprecated Use generators in schema package.\n */\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators, testObjectMutators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { type AnyLiveObject } from '@dxos/echo-db';\nimport { getTypeAnnotation, EchoSchema, getSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { live, isLiveObject, type Live } from '@dxos/live-object';\nimport { faker } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderParams,\n type TestGeneratorMap,\n type TestMutationsMap,\n type TestObjectProvider,\n type TestSchemaMap,\n} from './types';\n\n/**\n * Typed object generator.\n * @deprecated\n */\nexport class TestObjectGenerator<T extends string = TestSchemaType> {\n // prettier-ignore\n constructor(\n protected readonly _schemas: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>,\n ) {}\n\n get schemas(): (EchoSchema | Schema.Schema.AnyNoContext)[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): EchoSchema | Schema.Schema.AnyNoContext | undefined {\n return this.schemas.find((schema) => getTypeAnnotation(schema)!.typename === type);\n }\n\n protected setSchema(type: T, schema: EchoSchema | Schema.Schema.AnyNoContext): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<Live<any>> {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isLiveObject(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n return schema ? live(schema, data) : live(data);\n }\n\n // TODO(burdon): Based on dependencies (e.g., organization before contact).\n async createObjects(map: Partial<Record<T, number>>) {\n const results: Live<any>[] = [];\n for (const [type, count] of entries(map)) {\n results.push(...(await Promise.all(range(count ?? 0, () => this.createObject({ types: [type as T] })))));\n }\n\n const tasks = Object.entries<number>(map as any)\n .map(([type, count]) => {\n return range(count, () => this.createObject({ types: [type as T] }));\n })\n .flatMap((t) => t);\n\n return Promise.all(tasks);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(\n private readonly _space: Space,\n schemaMap: TestSchemaMap<T>,\n generators: TestGeneratorMap<T>,\n private readonly _mutations?: TestMutationsMap<T>,\n ) {\n super(schemaMap, generators, async (type: T) => {\n const schema = this.getSchema(type);\n const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();\n return objects;\n });\n }\n\n async addSchemas() {\n const result: (EchoSchema | Schema.Schema.AnyNoContext)[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as EchoSchema | Schema.Schema.AnyNoContext);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({ types }: { types?: T[] } = {}): Promise<AnyLiveObject<any>> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(\n typename: string,\n schema: EchoSchema | Schema.Schema.AnyNoContext,\n ): Promise<EchoSchema | Schema.Schema.AnyNoContext> {\n if (schema instanceof EchoSchema) {\n const existingSchema = this._space.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n this._space.db.graph.schemaRegistry.addSchema([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = getTypeAnnotation(getSchema(object)!)!.typename as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations![type](object, params);\n }\n\n async mutateObjects(objects: AnyLiveObject<any>[], params: MutationsProviderParams): Promise<void> {\n for (const object of objects) {\n await this.mutateObject(object, params);\n }\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const randomText = (length: number) => {\n let result = '';\n const characters = 'abcdefghijklmnopqrstuvwxyz';\n const charactersLength = characters.length;\n for (let index = 0; index < length; index++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n\n return result;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAA0B;AAC1B,oBAAuB;A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AA,MAAMoG,SAASC,IAAG;IACxBjB,QAAQpF,cAAAA,MAAMC,QAAQC,aAAasD,MAAAA;IACnCU,aAAalE,cAAAA,MAAMyF,MAAME,UAAS;IAClClB,SAASzE,cAAAA,MAAMoG,SAASC,IAAG;IAC3BhB,UAAUrF,cAAAA,MAAMC,QAAQC,aAAauD,QAAAA;IACrC6B,QAAQtF,cAAAA,MAAMiG,SAASC,QAAO;EAChC;AACF;AAEA,IAAMe,qBAAuD;EAC3D,CAAA,2BAAA,GAA2B,OAAOtE,QAAQC,WAAAA;AACxC,UAAMsE,eAAWC,+BAAkBxE,QAAQ;MAAC;KAAU;AACtD,aAASyE,IAAI,GAAGA,IAAIxE,OAAOlC,OAAO0G,KAAK;AACrC,YAAMpE,SAASL,OAAOwB,SAASA,SAASnB,UAAU;AAClDkE,eAASG,OAAOC,OAAO,CAACC,QAAAA;AACtBC,yBAAAA,KAAEC,OACAF,KACAL,SAASQ,KAAKC,MAAK,GACnB,GACA/E,OAAOgF,oBAAoB5E,SAAS,IAAIJ,OAAOiF,cAC/C9E,WAAWH,OAAOiF,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIC,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAI/I,oBAAoB2E,YAAAA,GAAe6B,oBAAAA;AAK/E,IAAMwC,6BAA6B,CAACC,UACzC,IAAI9G,qBAAqB8G,OAAOtE,YAAAA,GAAe6B,sBAAsByB,kBAAAA;",
6
- "names": ["import_echo", "import_echo_schema", "import_random", "TestObjectGenerator", "_schemas", "_generators", "_provider", "schemas", "Object", "values", "getSchema", "type", "find", "schema", "getTypeAnnotation", "typename", "setSchema", "createObject", "types", "faker", "helpers", "arrayElement", "keys", "data", "isLiveObject", "live", "createObjects", "map", "results", "count", "entries", "push", "Promise", "all", "range", "tasks", "flatMap", "t", "SpaceObjectGenerator", "_space", "schemaMap", "generators", "_mutations", "objects", "db", "query", "Filter", "nothing", "run", "addSchemas", "result", "echoSchema", "_maybeRegisterSchema", "add", "EchoSchema", "existingSchema", "schemaRegistry", "registeredSchema", "register", "graph", "addSchema", "mutateObject", "object", "params", "invariant", "mutateObjects", "randomText", "length", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Schema", "Struct", "title", "String", "annotations", "description", "content", "pipe", "EchoObject", "version", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "make", "commerce", "productName", "testObjectMutators", "accessor", "createDocAccessor", "i", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "Error", "createTestObjectGenerator", "createSpaceObjectGenerator", "space"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"packages/core/echo/echo-generator/src/generator.ts":{"bytes":16612,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-generator/src/util.ts":{"bytes":1580,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":19484,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/types.ts":{"bytes":1713,"imports":[],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":715,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18938},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Priority","SpaceObjectGenerator","Status","TestObjectGenerator","TestSchemaType","createSpaceObjectGenerator","createTestObjectGenerator","randomText"],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":4811},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":3960},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":299},"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":0}},"bytes":9480}}}