@agentshouse/mdruntime-families 0.1.0-c3651724d1b2b → 0.1.0-c3c78c33dbfb2
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/records.d.ts.map +1 -1
- package/dist/records.js +34 -21
- package/package.json +5 -5
package/dist/records.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE3D,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,CAAC;AAEnF,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAExF,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACpC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAkKrF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS;IAmK3D,IAAI,OAAO,MAAM,UAAU,MAAM,GAAG,IAAI,SAAS,SAAS,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAcpF,IAAI,OAAO,MAAM,OAAO,SAAS,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAOzD,GAAG,OAAO,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC;IAM1C,MAAM,OAAO,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAiBlD,MAAM,OACJ,MAAM,OACP,SAAS,GAAG,EAAE,QACb,MAAM,SACL,MAAM,GAAG,IAAI,GACnB,OAAO,CAAC,KAAK,EAAE,CAAC;IAab,MAAM,OAAO,MAAM,OAAO,SAAS,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAiB3D,KAAK,OAAO,MAAM,SAAS,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;EAWpE"}
|
package/dist/records.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ARRAY_INDEX, escapePointer, itemFacts, memberFacts, pointerSegments, references, relative, target, } from '@agentshouse/mdmodel';
|
|
1
|
+
import { ARRAY_INDEX, equalValue, escapePointer, itemFacts, memberFacts, pointerSegments, references, relative, target, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { saveRoomDrafts } from '@agentshouse/mdruntime/react';
|
|
3
3
|
const FIELDS = { fields: 'all' };
|
|
4
4
|
const REMOVABLE = { fields: 'all', markdown: true };
|
|
@@ -19,18 +19,6 @@ function pointer(field) {
|
|
|
19
19
|
function listed(value) {
|
|
20
20
|
return Array.isArray(value) ? value : [value];
|
|
21
21
|
}
|
|
22
|
-
function same(left, right) {
|
|
23
|
-
if (Object.is(left, right))
|
|
24
|
-
return true;
|
|
25
|
-
if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(left) !== Array.isArray(right))
|
|
29
|
-
return false;
|
|
30
|
-
const named = Object.keys(left);
|
|
31
|
-
return (named.length === Object.keys(right).length &&
|
|
32
|
-
named.every((name) => same(left[name], right[name])));
|
|
33
|
-
}
|
|
34
22
|
function factsAt(facts, field) {
|
|
35
23
|
let reached = facts;
|
|
36
24
|
for (const segment of field.split('.')) {
|
|
@@ -116,9 +104,9 @@ function changed(shelf, { place, document }, data, shown) {
|
|
|
116
104
|
const stored = document.fields ?? {};
|
|
117
105
|
const fields = {};
|
|
118
106
|
for (const [field, value] of Object.entries(data)) {
|
|
119
|
-
if (RESERVED.has(field) || value === undefined ||
|
|
107
|
+
if (RESERVED.has(field) || value === undefined || equalValue(value, prior[field]))
|
|
120
108
|
continue;
|
|
121
|
-
const base =
|
|
109
|
+
const base = equalValue(prior[field], current[field])
|
|
122
110
|
? Object.hasOwn(stored, field)
|
|
123
111
|
? { value: stored[field] }
|
|
124
112
|
: null
|
|
@@ -136,7 +124,29 @@ function byRoom(items) {
|
|
|
136
124
|
}
|
|
137
125
|
return rooms;
|
|
138
126
|
}
|
|
127
|
+
function complete(answer) {
|
|
128
|
+
return !('pending' in answer);
|
|
129
|
+
}
|
|
139
130
|
export function records(client, resources) {
|
|
131
|
+
async function documentsOf(query) {
|
|
132
|
+
const answer = await client.query(query);
|
|
133
|
+
if (complete(answer))
|
|
134
|
+
return answer.documents;
|
|
135
|
+
const observation = await client.observe('query', query);
|
|
136
|
+
try {
|
|
137
|
+
return await new Promise((resolve) => {
|
|
138
|
+
const settle = (value) => {
|
|
139
|
+
if (complete(value))
|
|
140
|
+
resolve(value.documents);
|
|
141
|
+
};
|
|
142
|
+
observation.subscribe(settle);
|
|
143
|
+
settle(observation.current());
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
observation.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
140
150
|
function resourceOf(name) {
|
|
141
151
|
const resource = Object.hasOwn(resources, name) ? resources[name] : undefined;
|
|
142
152
|
if (resource === undefined)
|
|
@@ -149,7 +159,7 @@ export function records(client, resources) {
|
|
|
149
159
|
const definitions = new Map();
|
|
150
160
|
for (const room of rooms) {
|
|
151
161
|
const schema = (await client.types(room)).collection;
|
|
152
|
-
if (schema.
|
|
162
|
+
if (schema.types === null)
|
|
153
163
|
continue;
|
|
154
164
|
const definition = schema.types.find((type) => type.name === resource.type);
|
|
155
165
|
if (definition === undefined)
|
|
@@ -159,7 +169,7 @@ export function records(client, resources) {
|
|
|
159
169
|
return { resource, rooms, definitions };
|
|
160
170
|
}
|
|
161
171
|
async function keys(shelf, query) {
|
|
162
|
-
const
|
|
172
|
+
const documents = await documentsOf({
|
|
163
173
|
...query,
|
|
164
174
|
types: [shelf.resource.type],
|
|
165
175
|
pathPrefix: shelf.resource.folder,
|
|
@@ -213,13 +223,13 @@ export function records(client, resources) {
|
|
|
213
223
|
const places = ids.map((id) => placeOf(shelf, id));
|
|
214
224
|
const documents = new Map();
|
|
215
225
|
for (const room of new Set(places.map((place) => place.room))) {
|
|
216
|
-
const
|
|
226
|
+
const held = await documentsOf({
|
|
217
227
|
rooms: [room],
|
|
218
228
|
types: [shelf.resource.type],
|
|
219
229
|
pathPrefix: shelf.resource.folder,
|
|
220
230
|
select,
|
|
221
231
|
});
|
|
222
|
-
for (const document of
|
|
232
|
+
for (const document of held)
|
|
223
233
|
documents.set(keyOf(shelf, document), document);
|
|
224
234
|
}
|
|
225
235
|
return places.map((place) => ({
|
|
@@ -250,13 +260,16 @@ export function records(client, resources) {
|
|
|
250
260
|
});
|
|
251
261
|
if (result.outcome === 'refused') {
|
|
252
262
|
await dropped(room, parts.keys());
|
|
253
|
-
throw new Error(`the Save was refused as ${result.
|
|
263
|
+
throw Object.assign(new Error(`the Save was refused as ${result.code}`, { cause: result }), {
|
|
264
|
+
code: result.code,
|
|
265
|
+
retryable: result.retryable,
|
|
266
|
+
});
|
|
254
267
|
}
|
|
255
268
|
}
|
|
256
269
|
return {
|
|
257
270
|
async list(name, clause, order) {
|
|
258
271
|
const shelf = await shelfOf(name);
|
|
259
|
-
const
|
|
272
|
+
const documents = await documentsOf({
|
|
260
273
|
types: [shelf.resource.type],
|
|
261
274
|
pathPrefix: shelf.resource.folder,
|
|
262
275
|
orderBy: (order.length === 0 ? BY_ID : order).flatMap((one) => sorting(shelf, one)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-families",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c3c78c33dbfb2",
|
|
4
4
|
"description": "react-admin and Refine data providers over the MD Runtime client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
"./react-admin": {
|
|
16
16
|
"types": "./dist/react-admin.d.ts",
|
|
17
|
-
"
|
|
17
|
+
"default": "./dist/react-admin.js"
|
|
18
18
|
},
|
|
19
19
|
"./refine": {
|
|
20
20
|
"types": "./dist/refine.d.ts",
|
|
21
|
-
"
|
|
21
|
+
"default": "./dist/refine.js"
|
|
22
22
|
},
|
|
23
23
|
"./package.json": "./package.json"
|
|
24
24
|
},
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agentshouse/mdmodel": "0.1.0-
|
|
32
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
31
|
+
"@agentshouse/mdmodel": "0.1.0-cad192ab63d5f",
|
|
32
|
+
"@agentshouse/mdruntime": "0.1.0-c454894e67f74"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@refinedev/core": ">=5",
|