@agentshouse/mdruntime-families 0.1.0-cb4e61ecbff59 → 0.1.0-cbbc2294ffb59
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 +27 -5
- 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
|
@@ -124,7 +124,29 @@ function byRoom(items) {
|
|
|
124
124
|
}
|
|
125
125
|
return rooms;
|
|
126
126
|
}
|
|
127
|
+
function complete(answer) {
|
|
128
|
+
return !('pending' in answer);
|
|
129
|
+
}
|
|
127
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
|
+
}
|
|
128
150
|
function resourceOf(name) {
|
|
129
151
|
const resource = Object.hasOwn(resources, name) ? resources[name] : undefined;
|
|
130
152
|
if (resource === undefined)
|
|
@@ -137,7 +159,7 @@ export function records(client, resources) {
|
|
|
137
159
|
const definitions = new Map();
|
|
138
160
|
for (const room of rooms) {
|
|
139
161
|
const schema = (await client.types(room)).collection;
|
|
140
|
-
if (schema.
|
|
162
|
+
if (schema.types === null)
|
|
141
163
|
continue;
|
|
142
164
|
const definition = schema.types.find((type) => type.name === resource.type);
|
|
143
165
|
if (definition === undefined)
|
|
@@ -147,7 +169,7 @@ export function records(client, resources) {
|
|
|
147
169
|
return { resource, rooms, definitions };
|
|
148
170
|
}
|
|
149
171
|
async function keys(shelf, query) {
|
|
150
|
-
const
|
|
172
|
+
const documents = await documentsOf({
|
|
151
173
|
...query,
|
|
152
174
|
types: [shelf.resource.type],
|
|
153
175
|
pathPrefix: shelf.resource.folder,
|
|
@@ -201,13 +223,13 @@ export function records(client, resources) {
|
|
|
201
223
|
const places = ids.map((id) => placeOf(shelf, id));
|
|
202
224
|
const documents = new Map();
|
|
203
225
|
for (const room of new Set(places.map((place) => place.room))) {
|
|
204
|
-
const
|
|
226
|
+
const held = await documentsOf({
|
|
205
227
|
rooms: [room],
|
|
206
228
|
types: [shelf.resource.type],
|
|
207
229
|
pathPrefix: shelf.resource.folder,
|
|
208
230
|
select,
|
|
209
231
|
});
|
|
210
|
-
for (const document of
|
|
232
|
+
for (const document of held)
|
|
211
233
|
documents.set(keyOf(shelf, document), document);
|
|
212
234
|
}
|
|
213
235
|
return places.map((place) => ({
|
|
@@ -247,7 +269,7 @@ export function records(client, resources) {
|
|
|
247
269
|
return {
|
|
248
270
|
async list(name, clause, order) {
|
|
249
271
|
const shelf = await shelfOf(name);
|
|
250
|
-
const
|
|
272
|
+
const documents = await documentsOf({
|
|
251
273
|
types: [shelf.resource.type],
|
|
252
274
|
pathPrefix: shelf.resource.folder,
|
|
253
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-cbbc2294ffb59",
|
|
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-ccf1367190878",
|
|
32
|
+
"@agentshouse/mdruntime": "0.1.0-c02c3f1090329"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@refinedev/core": ">=5",
|