@dxos/echo-generator 0.3.3-main.1817c8a → 0.3.3-main.22971a3
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 +170 -102
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +175 -103
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/data.d.ts +11 -0
- package/dist/types/src/data.d.ts.map +1 -0
- package/dist/types/src/generator.d.ts +25 -36
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +8 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +2 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/data.ts +130 -0
- package/src/generator.test.ts +31 -4
- package/src/generator.ts +42 -123
- package/src/index.ts +2 -0
- package/src/types.ts +13 -0
- package/src/util.ts +9 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -21,28 +21,77 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Priority: () => Priority,
|
|
24
|
+
SpaceObjectGenerator: () => SpaceObjectGenerator,
|
|
24
25
|
Status: () => Status,
|
|
25
26
|
TestObjectGenerator: () => TestObjectGenerator,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
createSpaceObjectGenerator: () => createSpaceObjectGenerator,
|
|
28
|
+
createTestObjectGenerator: () => createTestObjectGenerator,
|
|
29
|
+
range: () => range,
|
|
30
|
+
testObjectGenerators: () => testObjectGenerators,
|
|
31
|
+
testSchemas: () => testSchemas
|
|
28
32
|
});
|
|
29
33
|
module.exports = __toCommonJS(src_exports);
|
|
30
34
|
|
|
35
|
+
// packages/core/echo/echo-generator/src/data.ts
|
|
36
|
+
var import_faker2 = require("@faker-js/faker");
|
|
37
|
+
var import_echo2 = require("@dxos/client/echo");
|
|
38
|
+
|
|
31
39
|
// packages/core/echo/echo-generator/src/generator.ts
|
|
32
40
|
var import_faker = require("@faker-js/faker");
|
|
33
41
|
var import_echo = require("@dxos/client/echo");
|
|
42
|
+
|
|
43
|
+
// packages/core/echo/echo-generator/src/util.ts
|
|
34
44
|
var range = (fn, length) => Array.from({
|
|
35
45
|
length
|
|
36
46
|
}).map((_, i) => fn(i)).filter(Boolean);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
// packages/core/echo/echo-generator/src/generator.ts
|
|
49
|
+
var TestObjectGenerator = class {
|
|
50
|
+
// prettier-ignore
|
|
51
|
+
constructor(schema, _generators, _provider) {
|
|
52
|
+
this.schema = schema;
|
|
53
|
+
this._generators = _generators;
|
|
54
|
+
this._provider = _provider;
|
|
55
|
+
}
|
|
56
|
+
get schemas() {
|
|
57
|
+
return Object.values(this.schema);
|
|
58
|
+
}
|
|
59
|
+
createObject({ types } = {}) {
|
|
60
|
+
const type = import_faker.faker.helpers.arrayElement(types ?? Object.keys(this.schema));
|
|
61
|
+
const factory = this._generators[type];
|
|
62
|
+
const data = factory(this._provider);
|
|
63
|
+
return new import_echo.Expando(data, {
|
|
64
|
+
schema: this.schema[type]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// TODO(burdon): Create batch.
|
|
68
|
+
createObjects({ types, count }) {
|
|
69
|
+
return range(() => this.createObject({
|
|
70
|
+
types
|
|
71
|
+
}), count);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
75
|
+
constructor(_space, schema, generators) {
|
|
76
|
+
super(schema, generators, (type) => {
|
|
77
|
+
const { objects } = this._space.db.query((object) => {
|
|
78
|
+
return object.__schema === schema[type];
|
|
79
|
+
});
|
|
80
|
+
return objects;
|
|
81
|
+
});
|
|
82
|
+
this._space = _space;
|
|
83
|
+
}
|
|
84
|
+
addSchemas() {
|
|
85
|
+
this.schemas.forEach((schema) => this._space.db.add(schema));
|
|
86
|
+
}
|
|
87
|
+
createObject({ types } = {}) {
|
|
88
|
+
return this._space.db.add(super.createObject({
|
|
89
|
+
types
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
45
92
|
};
|
|
93
|
+
|
|
94
|
+
// packages/core/echo/echo-generator/src/data.ts
|
|
46
95
|
var Status = [
|
|
47
96
|
"pending",
|
|
48
97
|
"active",
|
|
@@ -55,108 +104,131 @@ var Priority = [
|
|
|
55
104
|
4,
|
|
56
105
|
5
|
|
57
106
|
];
|
|
58
|
-
var
|
|
59
|
-
document
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
107
|
+
var testSchemas = () => {
|
|
108
|
+
const document = new import_echo2.Schema({
|
|
109
|
+
props: [
|
|
110
|
+
{
|
|
111
|
+
id: "name",
|
|
112
|
+
type: import_echo2.Schema.PropType.STRING
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "content",
|
|
116
|
+
type: import_echo2.Schema.PropType.STRING
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
const organization = new import_echo2.Schema({
|
|
121
|
+
props: [
|
|
122
|
+
// TODO(burdon): Add metadata for default label.
|
|
123
|
+
{
|
|
124
|
+
id: "name",
|
|
125
|
+
type: import_echo2.Schema.PropType.STRING
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "website",
|
|
129
|
+
type: import_echo2.Schema.PropType.STRING
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "active",
|
|
133
|
+
type: import_echo2.Schema.PropType.BOOLEAN
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
const person = new import_echo2.Schema({
|
|
138
|
+
props: [
|
|
139
|
+
{
|
|
140
|
+
id: "name",
|
|
141
|
+
type: import_echo2.Schema.PropType.STRING
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "email",
|
|
145
|
+
type: import_echo2.Schema.PropType.STRING
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "org",
|
|
149
|
+
type: import_echo2.Schema.PropType.REF,
|
|
150
|
+
ref: organization
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
const project = new import_echo2.Schema({
|
|
155
|
+
props: [
|
|
156
|
+
{
|
|
157
|
+
id: "title",
|
|
158
|
+
type: import_echo2.Schema.PropType.STRING
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "repo",
|
|
162
|
+
type: import_echo2.Schema.PropType.STRING
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: "status",
|
|
166
|
+
type: import_echo2.Schema.PropType.STRING
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: "priority",
|
|
170
|
+
type: import_echo2.Schema.PropType.NUMBER
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
document,
|
|
176
|
+
organization,
|
|
177
|
+
person,
|
|
178
|
+
project
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
var testObjectGenerators = {
|
|
182
|
+
document: () => ({
|
|
183
|
+
title: import_faker2.faker.lorem.sentence(3),
|
|
184
|
+
content: import_faker2.faker.lorem.sentences({
|
|
185
|
+
min: 1,
|
|
186
|
+
max: import_faker2.faker.number.int({
|
|
75
187
|
min: 1,
|
|
76
|
-
max:
|
|
77
|
-
min: 1,
|
|
78
|
-
max: 3
|
|
79
|
-
})
|
|
188
|
+
max: 3
|
|
80
189
|
})
|
|
81
190
|
})
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
title: import_faker.faker.lorem.sentence(3),
|
|
99
|
-
body: import_faker.faker.datatype.boolean() ? import_faker.faker.lorem.sentences() : void 0
|
|
100
|
-
})
|
|
101
|
-
},
|
|
102
|
-
project: {
|
|
103
|
-
createSchema: () => new import_echo.Schema({
|
|
104
|
-
props: [
|
|
105
|
-
{
|
|
106
|
-
id: "title",
|
|
107
|
-
type: import_echo.Schema.PropType.STRING
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "repo",
|
|
111
|
-
type: import_echo.Schema.PropType.STRING
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "status",
|
|
115
|
-
type: import_echo.Schema.PropType.STRING
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: "priority",
|
|
119
|
-
type: import_echo.Schema.PropType.NUMBER
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
}),
|
|
123
|
-
createData: () => ({
|
|
124
|
-
title: import_faker.faker.commerce.productName(),
|
|
125
|
-
repo: import_faker.faker.datatype.boolean({
|
|
191
|
+
}),
|
|
192
|
+
organization: () => ({
|
|
193
|
+
name: import_faker2.faker.company.name(),
|
|
194
|
+
website: import_faker2.faker.datatype.boolean({
|
|
195
|
+
probability: 0.3
|
|
196
|
+
}) ? import_faker2.faker.internet.url() : void 0,
|
|
197
|
+
description: new import_echo2.Text(import_faker2.faker.lorem.sentences())
|
|
198
|
+
}),
|
|
199
|
+
person: (provider) => {
|
|
200
|
+
const organizations = provider?.("organization");
|
|
201
|
+
return {
|
|
202
|
+
name: import_faker2.faker.person.fullName(),
|
|
203
|
+
email: import_faker2.faker.datatype.boolean({
|
|
204
|
+
probability: 0.5
|
|
205
|
+
}) ? import_faker2.faker.internet.email() : void 0,
|
|
206
|
+
org: organizations?.length && import_faker2.faker.datatype.boolean({
|
|
126
207
|
probability: 0.3
|
|
127
|
-
}) ?
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, {});
|
|
139
|
-
}
|
|
140
|
-
get schema() {
|
|
141
|
-
return Object.values(this.factories).map((f) => f.schema);
|
|
142
|
-
}
|
|
143
|
-
createObject({ types } = {}) {
|
|
144
|
-
const type = import_faker.faker.helpers.arrayElement(types ?? Object.keys(this.factories));
|
|
145
|
-
const factory = this.factories[type];
|
|
146
|
-
return factory?.createObject();
|
|
147
|
-
}
|
|
148
|
-
createObjects({ types, length }) {
|
|
149
|
-
return range(() => this.createObject({
|
|
150
|
-
types
|
|
151
|
-
}), length);
|
|
152
|
-
}
|
|
208
|
+
}) ? import_faker2.faker.helpers.arrayElement(organizations) : void 0
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
project: () => ({
|
|
212
|
+
title: import_faker2.faker.commerce.productName(),
|
|
213
|
+
repo: import_faker2.faker.datatype.boolean({
|
|
214
|
+
probability: 0.3
|
|
215
|
+
}) ? import_faker2.faker.internet.url() : void 0,
|
|
216
|
+
status: import_faker2.faker.helpers.arrayElement(Status),
|
|
217
|
+
priority: import_faker2.faker.helpers.arrayElement(Priority)
|
|
218
|
+
})
|
|
153
219
|
};
|
|
220
|
+
var createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);
|
|
221
|
+
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);
|
|
154
222
|
// Annotate the CommonJS export names for ESM import in node:
|
|
155
223
|
0 && (module.exports = {
|
|
156
224
|
Priority,
|
|
225
|
+
SpaceObjectGenerator,
|
|
157
226
|
Status,
|
|
158
227
|
TestObjectGenerator,
|
|
159
|
-
|
|
160
|
-
|
|
228
|
+
createSpaceObjectGenerator,
|
|
229
|
+
createTestObjectGenerator,
|
|
230
|
+
range,
|
|
231
|
+
testObjectGenerators,
|
|
232
|
+
testSchemas
|
|
161
233
|
});
|
|
162
234
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/generator.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from './generator';\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { faker } from '@faker-js/faker';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA
|
|
6
|
-
"names": ["range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/data.ts", "../../../src/generator.ts", "../../../src/util.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from './data';\nexport * from './generator';\nexport * from './util';\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { faker } from '@faker-js/faker';\n\nimport { Schema, type Space, Text } from '@dxos/client/echo';\n\nimport { SpaceObjectGenerator, TestObjectGenerator } from './generator';\nimport { type TestGeneratorMap, type TestSchemaMap } from './types';\n\n// TODO(burdon): Handle restricted values.\nexport const Status = ['pending', 'active', 'done'];\nexport const Priority = [1, 2, 3, 4, 5];\n\nexport type TestSchemaType = 'document' | 'organization' | 'person' | 'project';\n\nexport const testSchemas = (): TestSchemaMap<TestSchemaType> => {\n const document = new Schema({\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'content',\n type: Schema.PropType.STRING, // TODO(burdon): Rich text.\n },\n ],\n });\n\n const organization = new Schema({\n props: [\n // TODO(burdon): Add metadata for default label.\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'website',\n type: Schema.PropType.STRING,\n },\n {\n id: 'active',\n type: Schema.PropType.BOOLEAN,\n },\n ],\n });\n\n const person = new Schema({\n props: [\n {\n id: 'name',\n type: Schema.PropType.STRING,\n },\n {\n id: 'email',\n type: Schema.PropType.STRING,\n },\n {\n id: 'org',\n type: Schema.PropType.REF,\n ref: organization,\n },\n ],\n });\n\n const project = new Schema({\n props: [\n {\n id: 'title',\n type: Schema.PropType.STRING,\n },\n {\n id: 'repo',\n type: Schema.PropType.STRING,\n },\n {\n id: 'status',\n type: Schema.PropType.STRING,\n },\n {\n id: 'priority',\n type: Schema.PropType.NUMBER,\n },\n ],\n });\n\n return { document, organization, person, project };\n};\n\nexport const testObjectGenerators: TestGeneratorMap<TestSchemaType> = {\n document: () => ({\n title: faker.lorem.sentence(3),\n content: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),\n }),\n\n organization: () => ({\n name: faker.company.name(),\n website: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n description: new Text(faker.lorem.sentences()),\n }),\n\n person: (provider) => {\n const organizations = provider?.('organization');\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 };\n },\n\n project: () => ({\n title: faker.commerce.productName(),\n repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,\n status: faker.helpers.arrayElement(Status),\n priority: faker.helpers.arrayElement(Priority),\n }),\n};\n\nexport const createTestObjectGenerator = () => new TestObjectGenerator(testSchemas(), testObjectGenerators);\n\nexport const createSpaceObjectGenerator = (space: Space) =>\n new SpaceObjectGenerator(space, testSchemas(), testObjectGenerators);\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/aurora/testing.\n// TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).\n\nimport { faker } from '@faker-js/faker';\n\nimport { Expando, type Schema, type Space } from '@dxos/client/echo';\n\nimport { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';\nimport { range } from './util';\n\n/**\n * Typed object generator.\n */\nexport class TestObjectGenerator<T extends string> {\n // prettier-ignore\n constructor(\n public readonly schema: TestSchemaMap<T>,\n private readonly _generators: TestGeneratorMap<T>,\n private readonly _provider?: TestObjectProvider<T>\n ) {}\n\n get schemas(): Schema[] {\n return Object.values(this.schema);\n }\n\n createObject({ types }: { types?: T[] } = {}): Expando {\n const type = faker.helpers.arrayElement(types ?? (Object.keys(this.schema) as T[]));\n const factory = this._generators[type];\n const data = factory(this._provider);\n return new Expando(data, { schema: this.schema[type] });\n }\n\n // TODO(burdon): Create batch.\n createObjects({ types, count }: { types?: T[]; count: number }): Expando[] {\n return range(() => this.createObject({ types }), count);\n }\n}\n\n/**\n * Typed object generator for a space.\n */\nexport class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {\n constructor(private readonly _space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>) {\n super(schema, generators, (type: T) => {\n // TODO(burdon): Query by schema.\n const { objects } = this._space.db.query((object) => {\n return object.__schema === schema[type];\n });\n\n return objects;\n });\n }\n\n addSchemas() {\n this.schemas.forEach((schema) => this._space.db.add(schema));\n }\n\n override createObject({ types }: { types?: T[] } = {}): Expando {\n return this._space.db.add(super.createObject({ types }));\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(burdon): Util.\nexport const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>\n Array.from({ length })\n .map((_, i) => fn(i))\n .filter(Boolean) as T[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;ACOA,IAAAA,gBAAsB;AAEtB,IAAAC,eAAyC;;;ACFzC,mBAAsB;AAEtB,kBAAiD;;;ACJ1C,IAAMC,QAAQ,CAAIC,IAAkCC,WACzDC,MAAMC,KAAK;EAAEF;AAAO,CAAA,EACjBG,IAAI,CAACC,GAAGC,MAAMN,GAAGM,CAAAA,CAAAA,EACjBC,OAAOC,OAAAA;;;ADSL,IAAMC,sBAAN,MAAMA;;EAEXC,YACkBC,QACCC,aACAC,WACjB;kBAHgBF;uBACCC;qBACAC;EAChB;EAEH,IAAIC,UAAoB;AACtB,WAAOC,OAAOC,OAAO,KAAKL,MAAM;EAClC;EAEAM,aAAa,EAAEC,MAAK,IAAsB,CAAC,GAAY;AACrD,UAAMC,OAAOC,mBAAMC,QAAQC,aAAaJ,SAAUH,OAAOQ,KAAK,KAAKZ,MAAM,CAAA;AACzE,UAAMa,UAAU,KAAKZ,YAAYO,IAAAA;AACjC,UAAMM,OAAOD,QAAQ,KAAKX,SAAS;AACnC,WAAO,IAAIa,oBAAQD,MAAM;MAAEd,QAAQ,KAAKA,OAAOQ,IAAAA;IAAM,CAAA;EACvD;;EAGAQ,cAAc,EAAET,OAAOU,MAAK,GAA+C;AACzE,WAAOC,MAAM,MAAM,KAAKZ,aAAa;MAAEC;IAAM,CAAA,GAAIU,KAAAA;EACnD;AACF;AAKO,IAAME,uBAAN,cAAqDrB,oBAAAA;EAC1DC,YAA6BqB,QAAepB,QAA0BqB,YAAiC;AACrG,UAAMrB,QAAQqB,YAAY,CAACb,SAAAA;AAEzB,YAAM,EAAEc,QAAO,IAAK,KAAKF,OAAOG,GAAGC,MAAM,CAACC,WAAAA;AACxC,eAAOA,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,oBAAoBnD,YAAAA,GAAee,oBAAAA;AAE/E,IAAMqC,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAOrD,YAAAA,GAAee,oBAAAA;",
|
|
6
|
+
"names": ["import_faker", "import_echo", "range", "fn", "length", "Array", "from", "map", "_", "i", "filter", "Boolean", "TestObjectGenerator", "constructor", "schema", "_generators", "_provider", "schemas", "Object", "values", "createObject", "types", "type", "faker", "helpers", "arrayElement", "keys", "factory", "data", "Expando", "createObjects", "count", "range", "SpaceObjectGenerator", "_space", "generators", "objects", "db", "query", "object", "__schema", "addSchemas", "forEach", "add", "Status", "Priority", "testSchemas", "document", "Schema", "props", "id", "type", "PropType", "STRING", "organization", "BOOLEAN", "person", "REF", "ref", "project", "NUMBER", "testObjectGenerators", "title", "faker", "lorem", "sentence", "content", "sentences", "min", "max", "number", "int", "name", "company", "website", "datatype", "boolean", "probability", "internet", "url", "undefined", "description", "Text", "provider", "organizations", "fullName", "email", "org", "length", "helpers", "arrayElement", "commerce", "productName", "repo", "status", "priority", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-generator/src/generator.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":7133,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/core/echo/echo-generator/src/data.ts":{"bytes":12963,"imports":[{"path":"@faker-js/faker","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"}],"format":"esm"},"packages/core/echo/echo-generator/src/index.ts":{"bytes":634,"imports":[{"path":"packages/core/echo/echo-generator/src/data.ts","kind":"import-statement","original":"./data"},{"path":"packages/core/echo/echo-generator/src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"packages/core/echo/echo-generator/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-generator/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10508},"packages/core/echo/echo-generator/dist/lib/node/index.cjs":{"imports":[{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true},{"path":"@faker-js/faker","kind":"require-call","external":true},{"path":"@dxos/client/echo","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/core/echo/echo-generator/src/index.ts","inputs":{"packages/core/echo/echo-generator/src/index.ts":{"bytesInOutput":481},"packages/core/echo/echo-generator/src/data.ts":{"bytesInOutput":3273},"packages/core/echo/echo-generator/src/generator.ts":{"bytesInOutput":1331},"packages/core/echo/echo-generator/src/util.ts":{"bytesInOutput":91}},"bytes":6587}}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Space } from '@dxos/client/echo';
|
|
2
|
+
import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
|
|
3
|
+
import { type TestGeneratorMap, type TestSchemaMap } from './types';
|
|
4
|
+
export declare const Status: string[];
|
|
5
|
+
export declare const Priority: number[];
|
|
6
|
+
export type TestSchemaType = 'document' | 'organization' | 'person' | 'project';
|
|
7
|
+
export declare const testSchemas: () => TestSchemaMap<TestSchemaType>;
|
|
8
|
+
export declare const testObjectGenerators: TestGeneratorMap<TestSchemaType>;
|
|
9
|
+
export declare const createTestObjectGenerator: () => TestObjectGenerator<TestSchemaType>;
|
|
10
|
+
export declare const createSpaceObjectGenerator: (space: Space) => SpaceObjectGenerator<TestSchemaType>;
|
|
11
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AASA,OAAO,EAAU,KAAK,KAAK,EAAQ,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAGpE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhF,eAAO,MAAM,WAAW,QAAO,cAAc,cAAc,CAwE1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,cAAc,CA8BjE,CAAC;AAEF,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACe,CAAC"}
|
|
@@ -1,42 +1,31 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export type TestItem = {
|
|
4
|
-
id: string;
|
|
5
|
-
type: string;
|
|
6
|
-
} & Record<string, any>;
|
|
7
|
-
type ObjectDataGenerator = {
|
|
8
|
-
createSchema?: () => SchemaType;
|
|
9
|
-
createData: () => any;
|
|
10
|
-
};
|
|
11
|
-
type ObjectFactory<T extends TypedObject> = {
|
|
12
|
-
schema?: SchemaType;
|
|
13
|
-
createObject: () => T;
|
|
14
|
-
};
|
|
15
|
-
type ObjectFactoryMap = {
|
|
16
|
-
[type: string]: ObjectFactory<any>;
|
|
17
|
-
};
|
|
18
|
-
export declare const Status: string[];
|
|
19
|
-
export declare const Priority: number[];
|
|
20
|
-
export declare const defaultGenerators: {
|
|
21
|
-
[type: string]: ObjectDataGenerator;
|
|
22
|
-
};
|
|
1
|
+
import { Expando, type Schema, type Space } from '@dxos/client/echo';
|
|
2
|
+
import { type TestGeneratorMap, type TestObjectProvider, type TestSchemaMap } from './types';
|
|
23
3
|
/**
|
|
24
4
|
* Typed object generator.
|
|
25
5
|
*/
|
|
26
|
-
export declare class TestObjectGenerator {
|
|
27
|
-
readonly
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
get schema(): SchemaType[];
|
|
6
|
+
export declare class TestObjectGenerator<T extends string> {
|
|
7
|
+
readonly schema: TestSchemaMap<T>;
|
|
8
|
+
private readonly _generators;
|
|
9
|
+
private readonly _provider?;
|
|
10
|
+
constructor(schema: TestSchemaMap<T>, _generators: TestGeneratorMap<T>, _provider?: TestObjectProvider<T> | undefined);
|
|
11
|
+
get schemas(): Schema[];
|
|
33
12
|
createObject({ types }?: {
|
|
34
|
-
types?:
|
|
35
|
-
}):
|
|
36
|
-
createObjects({ types,
|
|
37
|
-
types?:
|
|
38
|
-
|
|
39
|
-
}):
|
|
13
|
+
types?: T[];
|
|
14
|
+
}): Expando;
|
|
15
|
+
createObjects({ types, count }: {
|
|
16
|
+
types?: T[];
|
|
17
|
+
count: number;
|
|
18
|
+
}): Expando[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Typed object generator for a space.
|
|
22
|
+
*/
|
|
23
|
+
export declare class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<T> {
|
|
24
|
+
private readonly _space;
|
|
25
|
+
constructor(_space: Space, schema: TestSchemaMap<T>, generators: TestGeneratorMap<T>);
|
|
26
|
+
addSchemas(): void;
|
|
27
|
+
createObject({ types }?: {
|
|
28
|
+
types?: T[];
|
|
29
|
+
}): Expando;
|
|
40
30
|
}
|
|
41
|
-
export {};
|
|
42
31
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file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|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Schema, type Expando } from '@dxos/client/echo';
|
|
2
|
+
export type TestObject = {
|
|
3
|
+
id: string;
|
|
4
|
+
} & Record<string, any>;
|
|
5
|
+
export type TestSchemaMap<T extends string> = Record<T, Schema>;
|
|
6
|
+
export type TestObjectProvider<T extends string> = (type: T) => Expando[];
|
|
7
|
+
export type TestGeneratorMap<T extends string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;AAE1E,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,cAAe,MAAM,4BAA4B,MAAM,QAG9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-generator",
|
|
3
|
-
"version": "0.3.3-main.
|
|
3
|
+
"version": "0.3.3-main.22971a3",
|
|
4
4
|
"description": "ECHO data generator for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@faker-js/faker": "^8.0.2",
|
|
20
|
-
"@dxos/client": "0.3.3-main.
|
|
21
|
-
"@dxos/node-std": "0.3.3-main.
|
|
20
|
+
"@dxos/client": "0.3.3-main.22971a3",
|
|
21
|
+
"@dxos/node-std": "0.3.3-main.22971a3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {},
|
|
24
24
|
"publishConfig": {
|