@dxos/echo-generator 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/{browser → neutral}/index.mjs +80 -120
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/types/src/data.d.ts +4 -4
- package/dist/types/src/data.d.ts.map +1 -1
- package/dist/types/src/generator.d.ts +10 -13
- package/dist/types/src/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -8
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/data.ts +31 -30
- package/src/generator.test.ts +18 -18
- package/src/generator.ts +36 -38
- package/src/types.ts +5 -9
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -317
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -18,4 +18,4 @@ pnpm i @dxos/echo-generator
|
|
|
18
18
|
|
|
19
19
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
20
20
|
|
|
21
|
-
License: [
|
|
21
|
+
License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
|
|
@@ -3,50 +3,45 @@ import "@dxos/node-std/globals";
|
|
|
3
3
|
// src/data.ts
|
|
4
4
|
import { next as A } from "@automerge/automerge";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { DXN, Ref, Type as Type2 } from "@dxos/echo";
|
|
7
|
+
import { createDocAccessor } from "@dxos/echo-db";
|
|
8
|
+
import { random as random2 } from "@dxos/random";
|
|
9
9
|
|
|
10
10
|
// src/generator.ts
|
|
11
|
-
import { Filter } from "@dxos/
|
|
12
|
-
import {
|
|
13
|
-
import { EchoSchema, getSchema, getTypeAnnotation } from "@dxos/echo/internal";
|
|
11
|
+
import { Filter, Obj, Type } from "@dxos/echo";
|
|
12
|
+
import { isProxy } from "@dxos/echo/internal";
|
|
14
13
|
import { invariant } from "@dxos/invariant";
|
|
15
|
-
import {
|
|
16
|
-
import { faker } from "@dxos/random";
|
|
14
|
+
import { random } from "@dxos/random";
|
|
17
15
|
import { entries, range } from "@dxos/util";
|
|
18
|
-
function _define_property(obj, key, value) {
|
|
19
|
-
if (key in obj) {
|
|
20
|
-
Object.defineProperty(obj, key, {
|
|
21
|
-
value,
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
obj[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return obj;
|
|
30
|
-
}
|
|
31
16
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-generator/src/generator.ts";
|
|
32
17
|
var TestObjectGenerator = class {
|
|
18
|
+
_schemas;
|
|
19
|
+
_generators;
|
|
20
|
+
_provider;
|
|
21
|
+
// prettier-ignore
|
|
22
|
+
constructor(_schemas, _generators, _provider) {
|
|
23
|
+
this._schemas = _schemas;
|
|
24
|
+
this._generators = _generators;
|
|
25
|
+
this._provider = _provider;
|
|
26
|
+
}
|
|
33
27
|
get schemas() {
|
|
34
28
|
return Object.values(this._schemas);
|
|
35
29
|
}
|
|
36
30
|
getSchema(type) {
|
|
37
|
-
return this.schemas.find((schema) =>
|
|
31
|
+
return this.schemas.find((schema) => Type.getTypename(schema) === type);
|
|
38
32
|
}
|
|
39
33
|
setSchema(type, schema) {
|
|
40
34
|
this._schemas[type] = schema;
|
|
41
35
|
}
|
|
42
36
|
async createObject({ types } = {}) {
|
|
43
|
-
const type =
|
|
37
|
+
const type = random.helpers.arrayElement(types ?? Object.keys(this._schemas));
|
|
44
38
|
const data = await this._generators[type](this._provider);
|
|
45
|
-
if (
|
|
39
|
+
if (isProxy(data)) {
|
|
46
40
|
return data;
|
|
47
41
|
}
|
|
48
42
|
const schema = this.getSchema(type);
|
|
49
|
-
|
|
43
|
+
invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 38, S: this, A: ["schema", "`Schema is required for type: ${type}. Register a schema for this type.`"] });
|
|
44
|
+
return Obj.make(schema, data);
|
|
50
45
|
}
|
|
51
46
|
// TODO(burdon): Based on dependencies (e.g., organization before contact).
|
|
52
47
|
async createObjects(map) {
|
|
@@ -67,17 +62,17 @@ var TestObjectGenerator = class {
|
|
|
67
62
|
}).flatMap((t) => t);
|
|
68
63
|
return Promise.all(tasks);
|
|
69
64
|
}
|
|
70
|
-
// prettier-ignore
|
|
71
|
-
constructor(_schemas, _generators, _provider) {
|
|
72
|
-
_define_property(this, "_schemas", void 0);
|
|
73
|
-
_define_property(this, "_generators", void 0);
|
|
74
|
-
_define_property(this, "_provider", void 0);
|
|
75
|
-
this._schemas = _schemas;
|
|
76
|
-
this._generators = _generators;
|
|
77
|
-
this._provider = _provider;
|
|
78
|
-
}
|
|
79
65
|
};
|
|
80
66
|
var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
67
|
+
_space;
|
|
68
|
+
_mutations;
|
|
69
|
+
constructor(_space, schemaMap, generators, _mutations) {
|
|
70
|
+
super(schemaMap, generators, async (type) => {
|
|
71
|
+
const schema = this.getSchema(type);
|
|
72
|
+
const objects = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
|
|
73
|
+
return objects;
|
|
74
|
+
}), this._space = _space, this._mutations = _mutations;
|
|
75
|
+
}
|
|
81
76
|
async addSchemas() {
|
|
82
77
|
const result = [];
|
|
83
78
|
for (const [typename, schema] of Object.entries(this._schemas)) {
|
|
@@ -93,46 +88,30 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
|
93
88
|
}));
|
|
94
89
|
}
|
|
95
90
|
async _maybeRegisterSchema(typename, schema) {
|
|
96
|
-
if (schema
|
|
97
|
-
const existingSchema = this._space.db.schemaRegistry.getSchema(typename);
|
|
91
|
+
if (Type.getDatabase(schema) != null) {
|
|
92
|
+
const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);
|
|
98
93
|
if (existingSchema != null) {
|
|
99
94
|
return existingSchema;
|
|
100
95
|
}
|
|
101
|
-
const [registeredSchema] = await this._space.db.schemaRegistry.register([
|
|
96
|
+
const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([
|
|
102
97
|
schema
|
|
103
98
|
]);
|
|
104
99
|
return registeredSchema;
|
|
105
100
|
} else {
|
|
106
|
-
const existingSchema = this._space.db.graph.schemaRegistry.getSchema(typename);
|
|
101
|
+
const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);
|
|
107
102
|
if (existingSchema != null) {
|
|
108
103
|
return existingSchema;
|
|
109
104
|
}
|
|
110
|
-
this._space.db.graph.schemaRegistry.
|
|
105
|
+
await this._space.internal.db.graph.schemaRegistry.register([
|
|
111
106
|
schema
|
|
112
107
|
]);
|
|
113
108
|
return schema;
|
|
114
109
|
}
|
|
115
110
|
}
|
|
116
111
|
async mutateObject(object, params) {
|
|
117
|
-
invariant(this._mutations, "Mutations not defined.", {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
S: this,
|
|
121
|
-
A: [
|
|
122
|
-
"this._mutations",
|
|
123
|
-
"'Mutations not defined.'"
|
|
124
|
-
]
|
|
125
|
-
});
|
|
126
|
-
const type = getTypeAnnotation(getSchema(object)).typename;
|
|
127
|
-
invariant(type && this._mutations?.[type], "Invalid object type.", {
|
|
128
|
-
F: __dxlog_file,
|
|
129
|
-
L: 133,
|
|
130
|
-
S: this,
|
|
131
|
-
A: [
|
|
132
|
-
"type && this._mutations?.[type]",
|
|
133
|
-
"'Invalid object type.'"
|
|
134
|
-
]
|
|
135
|
-
});
|
|
112
|
+
invariant(this._mutations, "Mutations not defined.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: this, A: ["this._mutations", "'Mutations not defined.'"] });
|
|
113
|
+
const type = Type.getTypename(Obj.getType(object));
|
|
114
|
+
invariant(type && this._mutations?.[type], "Invalid object type.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 111, S: this, A: ["type && this._mutations?.[type]", "'Invalid object type.'"] });
|
|
136
115
|
await this._mutations[type](object, params);
|
|
137
116
|
}
|
|
138
117
|
async mutateObjects(objects, params) {
|
|
@@ -140,13 +119,6 @@ var SpaceObjectGenerator = class extends TestObjectGenerator {
|
|
|
140
119
|
await this.mutateObject(object, params);
|
|
141
120
|
}
|
|
142
121
|
}
|
|
143
|
-
constructor(_space, schemaMap, generators, _mutations) {
|
|
144
|
-
super(schemaMap, generators, async (type) => {
|
|
145
|
-
const schema = this.getSchema(type);
|
|
146
|
-
const { objects } = await this._space.db.query(schema ? Filter.type(schema) : Filter.nothing()).run();
|
|
147
|
-
return objects;
|
|
148
|
-
}), _define_property(this, "_space", void 0), _define_property(this, "_mutations", void 0), this._space = _space, this._mutations = _mutations;
|
|
149
|
-
}
|
|
150
122
|
};
|
|
151
123
|
|
|
152
124
|
// src/util.ts
|
|
@@ -174,10 +146,10 @@ var Priority = [
|
|
|
174
146
|
5
|
|
175
147
|
];
|
|
176
148
|
var TestSchemaType = /* @__PURE__ */ (function(TestSchemaType2) {
|
|
177
|
-
TestSchemaType2["document"] = "example.
|
|
178
|
-
TestSchemaType2["organization"] = "example.
|
|
179
|
-
TestSchemaType2["contact"] = "example.
|
|
180
|
-
TestSchemaType2["project"] = "example.
|
|
149
|
+
TestSchemaType2["document"] = "com.example.type.document";
|
|
150
|
+
TestSchemaType2["organization"] = "com.example.type.organization";
|
|
151
|
+
TestSchemaType2["contact"] = "com.example.type.person";
|
|
152
|
+
TestSchemaType2["project"] = "com.example.type.project";
|
|
181
153
|
return TestSchemaType2;
|
|
182
154
|
})({});
|
|
183
155
|
var testSchemas = () => {
|
|
@@ -186,10 +158,7 @@ var testSchemas = () => {
|
|
|
186
158
|
description: "title of the document"
|
|
187
159
|
}),
|
|
188
160
|
content: Schema.String
|
|
189
|
-
}).pipe(
|
|
190
|
-
typename: "example.com/type/Document",
|
|
191
|
-
version: "0.1.0"
|
|
192
|
-
}));
|
|
161
|
+
}).pipe(Type2.makeObject(DXN.make("com.example.type.document", "0.1.0")));
|
|
193
162
|
const organization = Schema.Struct({
|
|
194
163
|
name: Schema.String.annotations({
|
|
195
164
|
description: "name of the company or organization"
|
|
@@ -200,22 +169,16 @@ var testSchemas = () => {
|
|
|
200
169
|
description: Schema.String.annotations({
|
|
201
170
|
description: "short summary of the company"
|
|
202
171
|
})
|
|
203
|
-
}).pipe(
|
|
204
|
-
typename: "example.com/type/Organization",
|
|
205
|
-
version: "0.1.0"
|
|
206
|
-
}));
|
|
172
|
+
}).pipe(Type2.makeObject(DXN.make("com.example.type.organization", "0.1.0")));
|
|
207
173
|
const contact = Schema.Struct({
|
|
208
174
|
name: Schema.String.annotations({
|
|
209
175
|
description: "name of the person"
|
|
210
176
|
}),
|
|
211
177
|
email: Schema.optional(Schema.String),
|
|
212
|
-
org: Schema.optional(Ref(organization)),
|
|
178
|
+
org: Schema.optional(Ref.Ref(organization)),
|
|
213
179
|
lat: Schema.optional(Schema.Number),
|
|
214
180
|
lng: Schema.optional(Schema.Number)
|
|
215
|
-
}).pipe(
|
|
216
|
-
typename: "example.com/type/Contact",
|
|
217
|
-
version: "0.1.0"
|
|
218
|
-
}));
|
|
181
|
+
}).pipe(Type2.makeObject(DXN.make("com.example.type.person", "0.1.0")));
|
|
219
182
|
const project = Schema.Struct({
|
|
220
183
|
name: Schema.String.annotations({
|
|
221
184
|
description: "name of the project"
|
|
@@ -226,62 +189,59 @@ var testSchemas = () => {
|
|
|
226
189
|
status: Schema.String,
|
|
227
190
|
priority: Schema.Number,
|
|
228
191
|
active: Schema.Boolean,
|
|
229
|
-
org: Schema.optional(Ref(organization))
|
|
230
|
-
}).pipe(
|
|
231
|
-
typename: "example.com/type/Project",
|
|
232
|
-
version: "0.1.0"
|
|
233
|
-
}));
|
|
192
|
+
org: Schema.optional(Ref.Ref(organization))
|
|
193
|
+
}).pipe(Type2.makeObject(DXN.make("com.example.type.project", "0.1.0")));
|
|
234
194
|
return {
|
|
235
|
-
["example.
|
|
236
|
-
["example.
|
|
237
|
-
["example.
|
|
238
|
-
["example.
|
|
195
|
+
["com.example.type.document"]: document,
|
|
196
|
+
["com.example.type.organization"]: organization,
|
|
197
|
+
["com.example.type.person"]: contact,
|
|
198
|
+
["com.example.type.project"]: project
|
|
239
199
|
};
|
|
240
200
|
};
|
|
241
201
|
var testObjectGenerators = {
|
|
242
|
-
["example.
|
|
243
|
-
title:
|
|
244
|
-
content:
|
|
202
|
+
["com.example.type.document"]: async () => ({
|
|
203
|
+
title: random2.lorem.sentence(3),
|
|
204
|
+
content: random2.lorem.sentences({
|
|
245
205
|
min: 1,
|
|
246
|
-
max:
|
|
206
|
+
max: random2.number.int({
|
|
247
207
|
min: 1,
|
|
248
208
|
max: 3
|
|
249
209
|
})
|
|
250
210
|
})
|
|
251
211
|
}),
|
|
252
|
-
["example.
|
|
253
|
-
name:
|
|
254
|
-
website:
|
|
212
|
+
["com.example.type.organization"]: async () => ({
|
|
213
|
+
name: random2.company.name(),
|
|
214
|
+
website: random2.datatype.boolean({
|
|
255
215
|
probability: 0.3
|
|
256
|
-
}) ?
|
|
257
|
-
description:
|
|
216
|
+
}) ? random2.internet.url() : void 0,
|
|
217
|
+
description: random2.lorem.sentences()
|
|
258
218
|
}),
|
|
259
|
-
["example.
|
|
260
|
-
const organizations = await provider?.("example.
|
|
261
|
-
const location =
|
|
219
|
+
["com.example.type.person"]: async (provider) => {
|
|
220
|
+
const organizations = await provider?.("com.example.type.organization");
|
|
221
|
+
const location = random2.datatype.boolean() ? random2.geo.airport() : {};
|
|
262
222
|
return {
|
|
263
|
-
name:
|
|
264
|
-
email:
|
|
223
|
+
name: random2.person.fullName(),
|
|
224
|
+
email: random2.datatype.boolean({
|
|
265
225
|
probability: 0.5
|
|
266
|
-
}) ?
|
|
267
|
-
org: organizations?.length &&
|
|
226
|
+
}) ? random2.internet.email() : void 0,
|
|
227
|
+
org: organizations?.length && random2.datatype.boolean({
|
|
268
228
|
probability: 0.8
|
|
269
|
-
}) ? Ref.make(
|
|
229
|
+
}) ? Ref.make(random2.helpers.arrayElement(organizations)) : void 0,
|
|
270
230
|
...location
|
|
271
231
|
};
|
|
272
232
|
},
|
|
273
|
-
["example.
|
|
274
|
-
name:
|
|
275
|
-
repo:
|
|
276
|
-
status:
|
|
277
|
-
description:
|
|
278
|
-
website:
|
|
279
|
-
priority:
|
|
280
|
-
active:
|
|
233
|
+
["com.example.type.project"]: async () => ({
|
|
234
|
+
name: random2.commerce.productName(),
|
|
235
|
+
repo: random2.internet.url(),
|
|
236
|
+
status: random2.helpers.arrayElement(Status),
|
|
237
|
+
description: random2.lorem.sentences(),
|
|
238
|
+
website: random2.internet.url(),
|
|
239
|
+
priority: random2.helpers.arrayElement(Priority),
|
|
240
|
+
active: random2.datatype.boolean()
|
|
281
241
|
})
|
|
282
242
|
};
|
|
283
243
|
var testObjectMutators = {
|
|
284
|
-
["example.
|
|
244
|
+
["com.example.type.document"]: async (object, params) => {
|
|
285
245
|
const accessor = createDocAccessor(object, [
|
|
286
246
|
"content"
|
|
287
247
|
]);
|
|
@@ -292,13 +252,13 @@ var testObjectMutators = {
|
|
|
292
252
|
});
|
|
293
253
|
}
|
|
294
254
|
},
|
|
295
|
-
["example.
|
|
255
|
+
["com.example.type.organization"]: async () => {
|
|
296
256
|
throw new Error("Method not implemented.");
|
|
297
257
|
},
|
|
298
|
-
["example.
|
|
258
|
+
["com.example.type.person"]: async () => {
|
|
299
259
|
throw new Error("Method not implemented.");
|
|
300
260
|
},
|
|
301
|
-
["example.
|
|
261
|
+
["com.example.type.project"]: async () => {
|
|
302
262
|
throw new Error("Method not implemented.");
|
|
303
263
|
}
|
|
304
264
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 * as Schema from 'effect/Schema';\n\nimport { type Space } from '@dxos/client/echo';\nimport { DXN, Ref, Type } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { random } 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 = 'com.example.type.document',\n organization = 'com.example.type.organization',\n contact = 'com.example.type.person',\n project = 'com.example.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(Type.makeObject(DXN.make(TestSchemaType.document, '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(Type.makeObject(DXN.make(TestSchemaType.organization, '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.Ref(organization)),\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }).pipe(Type.makeObject(DXN.make(TestSchemaType.contact, '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.Ref(organization)),\n }).pipe(Type.makeObject(DXN.make(TestSchemaType.project, '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: random.lorem.sentence(3),\n content: random.lorem.sentences({ min: 1, max: random.number.int({ min: 1, max: 3 }) }),\n }),\n\n [TestSchemaType.organization]: async () => ({\n name: random.company.name(),\n website: random.datatype.boolean({ probability: 0.3 }) ? random.internet.url() : undefined,\n description: random.lorem.sentences(),\n }),\n\n [TestSchemaType.contact]: async (provider) => {\n const organizations = await provider?.(TestSchemaType.organization);\n const location = random.datatype.boolean() ? random.geo.airport() : {};\n\n return {\n name: random.person.fullName(),\n email: random.datatype.boolean({ probability: 0.5 }) ? random.internet.email() : undefined,\n org:\n organizations?.length && random.datatype.boolean({ probability: 0.8 })\n ? Ref.make(random.helpers.arrayElement(organizations))\n : undefined,\n ...location,\n };\n },\n\n [TestSchemaType.project]: async () => ({\n name: random.commerce.productName(),\n repo: random.internet.url(),\n status: random.helpers.arrayElement(Status),\n description: random.lorem.sentences(),\n website: random.internet.url(),\n priority: random.helpers.arrayElement(Priority),\n active: random.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 Space } from '@dxos/client/echo';\nimport { Filter, Obj, Type } from '@dxos/echo';\nimport { isProxy } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { random } from '@dxos/random';\nimport { entries, range } from '@dxos/util';\n\nimport { type TestSchemaType } from './data';\nimport {\n type MutationsProviderProps,\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\t\tprotected readonly _schemas: TestSchemaMap<T>,\n\t\tprivate readonly _generators: TestGeneratorMap<T>,\n\t\tprivate readonly _provider?: TestObjectProvider<T>,\n\t) {}\n\n get schemas(): Type.AnyObj[] {\n return Object.values(this._schemas);\n }\n\n getSchema(type: T): Type.AnyObj | undefined {\n return this.schemas.find((schema) => Type.getTypename(schema) === type);\n }\n\n protected setSchema(type: T, schema: Type.AnyEntity): void {\n this._schemas[type] = schema;\n }\n\n async createObject({ types }: { types?: T[] } = {}): Promise<any> {\n const type = random.helpers.arrayElement(types ?? (Object.keys(this._schemas) as T[]));\n const data = await this._generators[type](this._provider);\n if (isProxy(data)) {\n return data;\n }\n\n const schema = this.getSchema(type);\n invariant(schema, `Schema is required for type: ${type}. Register a schema for this type.`);\n return Obj.make(schema, 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: 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: Type.AnyEntity[] = [];\n for (const [typename, schema] of Object.entries(this._schemas)) {\n const echoSchema = await this._maybeRegisterSchema(typename, schema as Type.AnyObj);\n this.setSchema(typename as T, echoSchema);\n result.push(echoSchema);\n }\n\n return result;\n }\n\n override async createObject({\n types,\n }: {\n types?: T[];\n } = {}): Promise<Obj.Any> {\n return this._space.db.add(await super.createObject({ types }));\n }\n\n private async _maybeRegisterSchema(typename: string, schema: Type.AnyEntity): Promise<Type.AnyEntity> {\n if (Type.getDatabase(schema) != null) {\n const existingSchema = this._space.internal.db.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n const [registeredSchema] = await this._space.internal.db.schemaRegistry.register([schema]);\n return registeredSchema;\n } else {\n const existingSchema = this._space.internal.db.graph.schemaRegistry.getSchema(typename);\n if (existingSchema != null) {\n return existingSchema;\n }\n await this._space.internal.db.graph.schemaRegistry.register([schema]);\n return schema;\n }\n }\n\n async mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void> {\n invariant(this._mutations, 'Mutations not defined.');\n const type = Type.getTypename(Obj.getType(object)!) as T;\n invariant(type && this._mutations?.[type], 'Invalid object type.');\n\n await this._mutations;\n }\n\n async mutateObjects(objects: Obj.Any[], params: MutationsProviderProps): 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,SAASA,QAAQC,SAAS;AAC1B,YAAYC,YAAY;AAGxB,SAASC,KAAKC,KAAKC,QAAAA,aAAY;AAC/B,SAASC,y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eAASI,OAAOC,OAAO,CAACC,QAAAA;AACtBC,UAAEC,OACAF,KACAN,SAASS,KAAKC,MAAK,GACnB,GACAX,OAAOY,oBAAoBnB,SAAS,IAAIO,OAAOa,cAC/CC,WAAWd,OAAOa,YAAY,CAAA;MAElC,CAAA;IACF;EACF;EACA,CAAA,+BAAA,GAA+B,YAAA;AAC7B,UAAM,IAAIE,MAAM,yBAAA;EAClB;EACA,CAAA,yBAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;EACA,CAAA,0BAAA,GAA0B,YAAA;AACxB,UAAM,IAAIA,MAAM,yBAAA;EAClB;AACF;AAKO,IAAMC,4BAA4B,MAAM,IAAIC,oBAAoB7E,YAAAA,GAAe8B,oBAAAA;AAK/E,IAAMgD,6BAA6B,CAACC,UACzC,IAAIC,qBAAqBD,OAAO/E,YAAAA,GAAe8B,sBAAsB4B,kBAAAA;",
|
|
6
|
+
"names": ["next", "A", "Schema", "DXN", "Ref", "Type", "createDocAccessor", "random", "Filter", "Obj", "Type", "isProxy", "invariant", "random", "entries", "range", "_generators", "_provider", "schemas", "getSchema", "type", "setSchema", "schema", "createObject", "types", "data", "count", "results", "tasks", "t", "Promise", "objects", "_space", "query", "_mutations", "addSchemas", "typename", "echoSchema", "result", "_maybeRegisterSchema", "existingSchema", "internal", "registeredSchema", "getTypename", "object", "params", "mutateObjects", "mutateObject", "randomText", "length", "result", "characters", "charactersLength", "index", "charAt", "Math", "floor", "random", "Status", "Priority", "TestSchemaType", "testSchemas", "document", "Struct", "title", "String", "annotations", "description", "content", "pipe", "Type", "makeObject", "DXN", "make", "organization", "name", "website", "optional", "contact", "email", "org", "Ref", "lat", "Number", "lng", "project", "repo", "status", "priority", "active", "Boolean", "testObjectGenerators", "random", "lorem", "sentence", "sentences", "min", "max", "number", "int", "company", "datatype", "boolean", "probability", "internet", "url", "undefined", "provider", "organizations", "location", "geo", "airport", "person", "fullName", "length", "helpers", "arrayElement", "commerce", "productName", "testObjectMutators", "object", "params", "accessor", "createDocAccessor", "i", "count", "handle", "change", "doc", "A", "splice", "path", "slice", "maxContentLength", "mutationSize", "randomText", "Error", "createTestObjectGenerator", "TestObjectGenerator", "createSpaceObjectGenerator", "space", "SpaceObjectGenerator"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/generator.ts":{"bytes":16267,"imports":[{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util.ts":{"bytes":1484,"imports":[],"format":"esm"},"src/data.ts":{"bytes":19397,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":577,"imports":[{"path":"src/data.ts","kind":"import-statement","original":"./data"},{"path":"src/generator.ts","kind":"import-statement","original":"./generator"},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18122},"dist/lib/neutral/index.mjs":{"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/invariant","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":"src/index.ts","inputs":{"src/data.ts":{"bytesInOutput":4776},"src/generator.ts":{"bytesInOutput":4123},"src/util.ts":{"bytesInOutput":299},"src/index.ts":{"bytesInOutput":0}},"bytes":9506}}}
|
package/dist/types/src/data.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export declare const Priority: number[];
|
|
|
6
6
|
* @deprecated
|
|
7
7
|
*/
|
|
8
8
|
export declare enum TestSchemaType {
|
|
9
|
-
document = "example.
|
|
10
|
-
organization = "example.
|
|
11
|
-
contact = "example.
|
|
12
|
-
project = "example.
|
|
9
|
+
document = "com.example.type.document",
|
|
10
|
+
organization = "com.example.type.organization",
|
|
11
|
+
contact = "com.example.type.person",
|
|
12
|
+
project = "com.example.type.project"
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* @deprecated Use generators in schema package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/data.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQxE,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC;;GAEG;AACH,oBAAY,cAAc;IACxB,QAAQ,8BAA8B;IACtC,YAAY,kCAAkC;IAC9C,OAAO,4BAA4B;IACnC,OAAO,6BAA6B;CACrC;AA6GD;;GAEG;AACH,eAAO,MAAM,yBAAyB,2CAAqE,CAAC;AAE5G;;GAEG;AACH,eAAO,MAAM,0BAA0B,UAAW,KAAK,yCACmC,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type * as Schema from 'effect/Schema';
|
|
2
1
|
import { type Space } from '@dxos/client/echo';
|
|
3
|
-
import {
|
|
4
|
-
import { type AnyLiveObject } from '@dxos/echo-db';
|
|
5
|
-
import { type Live } from '@dxos/live-object';
|
|
2
|
+
import { Obj, Type } from '@dxos/echo';
|
|
6
3
|
import { type TestSchemaType } from './data';
|
|
7
|
-
import { type
|
|
4
|
+
import { type MutationsProviderProps, type TestGeneratorMap, type TestMutationsMap, type TestObjectProvider, type TestSchemaMap } from './types';
|
|
8
5
|
/**
|
|
9
6
|
* Typed object generator.
|
|
10
7
|
* @deprecated
|
|
@@ -14,12 +11,12 @@ export declare class TestObjectGenerator<T extends string = TestSchemaType> {
|
|
|
14
11
|
private readonly _generators;
|
|
15
12
|
private readonly _provider?;
|
|
16
13
|
constructor(_schemas: TestSchemaMap<T>, _generators: TestGeneratorMap<T>, _provider?: TestObjectProvider<T> | undefined);
|
|
17
|
-
get schemas():
|
|
18
|
-
getSchema(type: T):
|
|
19
|
-
protected setSchema(type: T, schema:
|
|
14
|
+
get schemas(): Type.AnyObj[];
|
|
15
|
+
getSchema(type: T): Type.AnyObj | undefined;
|
|
16
|
+
protected setSchema(type: T, schema: Type.AnyEntity): void;
|
|
20
17
|
createObject({ types }?: {
|
|
21
18
|
types?: T[];
|
|
22
|
-
}): Promise<
|
|
19
|
+
}): Promise<any>;
|
|
23
20
|
createObjects(map: Partial<Record<T, number>>): Promise<any[]>;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
@@ -29,12 +26,12 @@ export declare class SpaceObjectGenerator<T extends string> extends TestObjectGe
|
|
|
29
26
|
private readonly _space;
|
|
30
27
|
private readonly _mutations?;
|
|
31
28
|
constructor(_space: Space, schemaMap: TestSchemaMap<T>, generators: TestGeneratorMap<T>, _mutations?: TestMutationsMap<T> | undefined);
|
|
32
|
-
addSchemas(): Promise<
|
|
29
|
+
addSchemas(): Promise<Type.AnyEntity[]>;
|
|
33
30
|
createObject({ types }?: {
|
|
34
31
|
types?: T[];
|
|
35
|
-
}): Promise<
|
|
32
|
+
}): Promise<Obj.Any>;
|
|
36
33
|
private _maybeRegisterSchema;
|
|
37
|
-
mutateObject(object:
|
|
38
|
-
mutateObjects(objects:
|
|
34
|
+
mutateObject(object: Obj.Any, params: MutationsProviderProps): Promise<void>;
|
|
35
|
+
mutateObjects(objects: Obj.Any[], params: MutationsProviderProps): Promise<void>;
|
|
39
36
|
}
|
|
40
37
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAU,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAM/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc;IAGhE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAH3B,YACmB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC5B,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAChC,SAAS,C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AsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrF;CACF"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type EchoSchema } from '@dxos/echo/internal';
|
|
3
|
-
import { type AnyLiveObject } from '@dxos/echo-db';
|
|
4
|
-
import { type Live } from '@dxos/live-object';
|
|
1
|
+
import { type Obj, type Type } from '@dxos/echo';
|
|
5
2
|
export type TestObject = {
|
|
6
3
|
id: string;
|
|
7
4
|
} & Record<string, any>;
|
|
8
|
-
export type TestSchemaMap<T extends string = string> = Record<T,
|
|
9
|
-
export type TestObjectProvider<T extends string = string> = (type: T) => Promise<
|
|
5
|
+
export type TestSchemaMap<T extends string = string> = Record<T, Type.AnyEntity>;
|
|
6
|
+
export type TestObjectProvider<T extends string = string> = (type: T) => Promise<any[]>;
|
|
10
7
|
export type TestGeneratorMap<T extends string = string> = Record<T, (provider: TestObjectProvider<T> | undefined) => any>;
|
|
11
8
|
export type TestMutationsMap<T extends string = string> = Record<T, TestObjectMutators>;
|
|
12
|
-
export type
|
|
9
|
+
export type MutationsProviderProps = {
|
|
13
10
|
count: number;
|
|
14
11
|
mutationSize: number;
|
|
15
12
|
maxContentLength: number;
|
|
16
13
|
};
|
|
17
|
-
export type TestObjectMutators = (object:
|
|
14
|
+
export type TestObjectMutators = (object: Obj.Any, params: MutationsProviderProps) => Promise<void>;
|
|
18
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAGjD,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,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAEjF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAExF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAC9D,CAAC,EACD,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,GAAG,CACrD,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAExF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,WAAY,MAAM,WASxC,CAAC"}
|