@arcote.tech/arc-react 0.0.27 → 0.0.28
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/index.js +31 -6
- package/dist/reactModel.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,8 +67,31 @@ class IDBReadTransaction {
|
|
|
67
67
|
async findByIndex(store, index, data) {
|
|
68
68
|
return new Promise((resolve) => {
|
|
69
69
|
const idbIndex = this.transaction.objectStore(store).index(index);
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const keyPath = idbIndex.keyPath;
|
|
71
|
+
let keyRange;
|
|
72
|
+
const getKey = (obj) => {
|
|
73
|
+
const key = keyPath.map((key2) => obj[key2]);
|
|
74
|
+
if (key.some((value) => value === undefined))
|
|
75
|
+
return;
|
|
76
|
+
return key;
|
|
77
|
+
};
|
|
78
|
+
const simpleKey = getKey(data);
|
|
79
|
+
if (!simpleKey) {
|
|
80
|
+
const lower = "$gt" in data ? getKey(data.$gt) : getKey(data.$gte);
|
|
81
|
+
const upper = "$lt" in data ? getKey(data.$lt) : getKey(data.$lte);
|
|
82
|
+
const lowerOpen = "$gt" in data;
|
|
83
|
+
const upperOpen = "$lt" in data;
|
|
84
|
+
if (lower !== undefined && upper !== undefined) {
|
|
85
|
+
keyRange = IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen);
|
|
86
|
+
} else if (lower !== undefined) {
|
|
87
|
+
keyRange = IDBKeyRange.lowerBound(lower, lowerOpen);
|
|
88
|
+
} else {
|
|
89
|
+
keyRange = IDBKeyRange.upperBound(upper, upperOpen);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
keyRange = IDBKeyRange.only(simpleKey);
|
|
93
|
+
}
|
|
94
|
+
console.log(keyRange);
|
|
72
95
|
const result = idbIndex.getAll(keyRange);
|
|
73
96
|
result.onsuccess = (e) => {
|
|
74
97
|
resolve(e.target.result);
|
|
@@ -244,12 +267,14 @@ var reactModel = (arcContext, databaseName) => {
|
|
|
244
267
|
}
|
|
245
268
|
return arcContext.commandsClient(context.client, context.dataStorage, context.catchErrorCallback);
|
|
246
269
|
},
|
|
247
|
-
async function query(queryBuilderFn) {
|
|
270
|
+
async function query(queryBuilderFn, datastorage) {
|
|
271
|
+
if (!datastorage)
|
|
272
|
+
datastorage = modelMasterDataStorage;
|
|
248
273
|
const queryBuilder = arcContext.queryBuilder();
|
|
249
274
|
const query = queryBuilderFn(queryBuilder).toQuery();
|
|
250
|
-
if (!
|
|
275
|
+
if (!datastorage)
|
|
251
276
|
throw new Error("dataStorage not found");
|
|
252
|
-
const result = await query.run(
|
|
277
|
+
const result = await query.run(datastorage);
|
|
253
278
|
return result;
|
|
254
279
|
},
|
|
255
280
|
function useLocalDataStorage() {
|
|
@@ -267,4 +292,4 @@ export {
|
|
|
267
292
|
formResolver
|
|
268
293
|
};
|
|
269
294
|
|
|
270
|
-
//# debugId=
|
|
295
|
+
//# debugId=EB0E8168D4E98EF264756E2164756E21
|
package/dist/reactModel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ForkedDataStorage, type ArcContextAny, type CommandsClient, type QueryBuilderFunctionResult, type QueryFactoryFunction } from "@arcote.tech/arc";
|
|
1
|
+
import { ForkedDataStorage, type ArcContextAny, type CommandsClient, type DataStorage, type QueryBuilderFunctionResult, type QueryFactoryFunction } from "@arcote.tech/arc";
|
|
2
2
|
export declare const reactModel: <C extends ArcContextAny>(arcContext: C, databaseName: string) => readonly [(props: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
client: string;
|
|
@@ -12,5 +12,5 @@ export declare const reactModel: <C extends ArcContextAny>(arcContext: C, databa
|
|
|
12
12
|
catchErrorCallback: (error: any) => void;
|
|
13
13
|
}) => import("react/jsx-dev-runtime").JSX.Element, ({ children }: {
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
-
}) => import("react/jsx-dev-runtime").JSX.Element, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, dependencies?: any[]) => [QueryBuilderFunctionResult<QueryBuilderFn>, boolean], () => CommandsClient<C["commands"]>, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn) => Promise<QueryBuilderFunctionResult<QueryBuilderFn>>, () => ForkedDataStorage | null];
|
|
15
|
+
}) => import("react/jsx-dev-runtime").JSX.Element, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, dependencies?: any[]) => [QueryBuilderFunctionResult<QueryBuilderFn>, boolean], () => CommandsClient<C["commands"]>, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, datastorage?: DataStorage | null) => Promise<QueryBuilderFunctionResult<QueryBuilderFn>>, () => ForkedDataStorage | null];
|
|
16
16
|
//# sourceMappingURL=reactModel.d.ts.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.28",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
|