@mgarlik/datastore 0.1.9 → 0.1.11
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.cjs +120 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -6
- package/dist/index.d.ts +37 -6
- package/dist/index.js +100 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -136,7 +136,7 @@ type DataProvidersType = Record<string, DataProviderType>;
|
|
|
136
136
|
/** Kanonický UUID řetězec používaný pro dokumenty a providery. */
|
|
137
137
|
type Uuid = string;
|
|
138
138
|
/** JSON-kompatibilní hodnota používaná v payloadu, filtrech a update operacích. */
|
|
139
|
-
type JSONType = string | number | boolean | {
|
|
139
|
+
type JSONType = string | number | boolean | null | {
|
|
140
140
|
[x: string]: JSONType;
|
|
141
141
|
} | Array<JSONType>;
|
|
142
142
|
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
@@ -355,12 +355,12 @@ interface UseDataProviderResult {
|
|
|
355
355
|
data?: JSONType;
|
|
356
356
|
variant?: string;
|
|
357
357
|
documentId?: string;
|
|
358
|
-
}, callback?: (resp: JSONType) => void) =>
|
|
358
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
359
359
|
/** Smaže položku/položky providera. */
|
|
360
360
|
deleteItem: (args: {
|
|
361
361
|
params?: JSONType;
|
|
362
362
|
data?: JSONType;
|
|
363
|
-
}, callback?: (resp: JSONType) => void) =>
|
|
363
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
364
364
|
/** Vytvoří novou položku providera. */
|
|
365
365
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
|
|
366
366
|
}
|
|
@@ -439,12 +439,12 @@ interface UseProviderActionsResult {
|
|
|
439
439
|
data?: any;
|
|
440
440
|
variant?: string;
|
|
441
441
|
documentId?: Uuid;
|
|
442
|
-
}, callback?: (value: JSONType) => void) =>
|
|
442
|
+
}, callback?: (value: JSONType) => void) => void;
|
|
443
443
|
/** Smaže položku/položky providera. */
|
|
444
444
|
deleteItem: (args: {
|
|
445
445
|
params: JSONType;
|
|
446
446
|
data?: JSONType;
|
|
447
|
-
}, callback?: (
|
|
447
|
+
}, callback?: () => void) => void;
|
|
448
448
|
/** Vytvoří novou položku providera. */
|
|
449
449
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
|
|
450
450
|
}
|
|
@@ -480,10 +480,41 @@ declare const dataStoreFilterObject: (obj: any, filter: any) => any;
|
|
|
480
480
|
declare function uuid(): string;
|
|
481
481
|
declare function isUuid(val: string): boolean;
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Black: \x1b[30m
|
|
485
|
+
* Red: \x1b[31m
|
|
486
|
+
* Green: \x1b[32m
|
|
487
|
+
*Yellow: \x1b[33m
|
|
488
|
+
* Blue: \x1b[34m
|
|
489
|
+
* Magenta: \x1b[35m
|
|
490
|
+
* Cyan: \x1b[36m
|
|
491
|
+
* White: \x1b[37m
|
|
492
|
+
*/
|
|
493
|
+
declare const COLOR_WHITE = "\u001B[37m%s\u001B[0m";
|
|
494
|
+
declare const COLOR_MAGENTA = "\u001B[35m%s\u001B[0m";
|
|
495
|
+
declare const COLOR_BLUE = "\u001B[34m%s\u001B[0m";
|
|
496
|
+
declare const COLOR_CYAN = "\u001B[36m%s\u001B[0m";
|
|
497
|
+
declare const COLOR_GREEN = "\u001B[32m%s\u001B[0m";
|
|
498
|
+
declare const COLOR_RED = "\u001B[31m%s\u001B[0m";
|
|
499
|
+
declare const COLOR_ERROR = "\u001B[31m%s\u001B[0m";
|
|
500
|
+
declare const COLOR_YELLOW = "\u001B[33m%s\u001B[0m";
|
|
501
|
+
declare const COLOR_ORANGE = "\u001B[38;5;208m%s\u001B[0m";
|
|
502
|
+
declare const COLOR_WARNING = "\u001B[33m%s\u001B[0m";
|
|
503
|
+
declare const COLOR_PROVIDER = "\u001B[35m%s\u001B[0m";
|
|
504
|
+
declare const COLOR_CONTEXT = "\u001B[35m%s\u001B[0m";
|
|
505
|
+
declare const COLOR_RENDER = "\u001B[34m%s\u001B[0m";
|
|
506
|
+
declare const COLOR_FUNCTION = "\u001B[36m%s\u001B[0m";
|
|
507
|
+
declare const COLOR_SCREEN = "\u001B[32m%s\u001B[0m";
|
|
508
|
+
declare const COLOR_SOCKET = "\u001B[36m%s\u001B[0m";
|
|
509
|
+
declare const COLOR_SOCKETS = "\u001B[33m%s\u001B[0m";
|
|
510
|
+
declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
511
|
+
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
512
|
+
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
513
|
+
|
|
483
514
|
/**
|
|
484
515
|
* Zobrazí obsah celé databáze v console.log
|
|
485
516
|
* Používá se pro debugging storage
|
|
486
517
|
*/
|
|
487
518
|
declare function logStorageContent(storage: DataStoreStorage): Promise<void>;
|
|
488
519
|
|
|
489
|
-
export { type DataProviderType, type DataProvidersType, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderSchemaItemType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, logStorageContent, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
|
520
|
+
export { COLOR_APP, COLOR_AXIOS, COLOR_BLUE, COLOR_CONTEXT, COLOR_CYAN, COLOR_DS, COLOR_ERROR, COLOR_FUNCTION, COLOR_GREEN, COLOR_MAGENTA, COLOR_ORANGE, COLOR_PROVIDER, COLOR_RED, COLOR_RENDER, COLOR_SCREEN, COLOR_SOCKET, COLOR_SOCKETS, COLOR_WARNING, COLOR_WHITE, COLOR_YELLOW, type DataProviderType, type DataProvidersType, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderSchemaItemType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, logStorageContent, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
package/dist/index.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ type DataProvidersType = Record<string, DataProviderType>;
|
|
|
136
136
|
/** Kanonický UUID řetězec používaný pro dokumenty a providery. */
|
|
137
137
|
type Uuid = string;
|
|
138
138
|
/** JSON-kompatibilní hodnota používaná v payloadu, filtrech a update operacích. */
|
|
139
|
-
type JSONType = string | number | boolean | {
|
|
139
|
+
type JSONType = string | number | boolean | null | {
|
|
140
140
|
[x: string]: JSONType;
|
|
141
141
|
} | Array<JSONType>;
|
|
142
142
|
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
@@ -355,12 +355,12 @@ interface UseDataProviderResult {
|
|
|
355
355
|
data?: JSONType;
|
|
356
356
|
variant?: string;
|
|
357
357
|
documentId?: string;
|
|
358
|
-
}, callback?: (resp: JSONType) => void) =>
|
|
358
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
359
359
|
/** Smaže položku/položky providera. */
|
|
360
360
|
deleteItem: (args: {
|
|
361
361
|
params?: JSONType;
|
|
362
362
|
data?: JSONType;
|
|
363
|
-
}, callback?: (resp: JSONType) => void) =>
|
|
363
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
364
364
|
/** Vytvoří novou položku providera. */
|
|
365
365
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
|
|
366
366
|
}
|
|
@@ -439,12 +439,12 @@ interface UseProviderActionsResult {
|
|
|
439
439
|
data?: any;
|
|
440
440
|
variant?: string;
|
|
441
441
|
documentId?: Uuid;
|
|
442
|
-
}, callback?: (value: JSONType) => void) =>
|
|
442
|
+
}, callback?: (value: JSONType) => void) => void;
|
|
443
443
|
/** Smaže položku/položky providera. */
|
|
444
444
|
deleteItem: (args: {
|
|
445
445
|
params: JSONType;
|
|
446
446
|
data?: JSONType;
|
|
447
|
-
}, callback?: (
|
|
447
|
+
}, callback?: () => void) => void;
|
|
448
448
|
/** Vytvoří novou položku providera. */
|
|
449
449
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
|
|
450
450
|
}
|
|
@@ -480,10 +480,41 @@ declare const dataStoreFilterObject: (obj: any, filter: any) => any;
|
|
|
480
480
|
declare function uuid(): string;
|
|
481
481
|
declare function isUuid(val: string): boolean;
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Black: \x1b[30m
|
|
485
|
+
* Red: \x1b[31m
|
|
486
|
+
* Green: \x1b[32m
|
|
487
|
+
*Yellow: \x1b[33m
|
|
488
|
+
* Blue: \x1b[34m
|
|
489
|
+
* Magenta: \x1b[35m
|
|
490
|
+
* Cyan: \x1b[36m
|
|
491
|
+
* White: \x1b[37m
|
|
492
|
+
*/
|
|
493
|
+
declare const COLOR_WHITE = "\u001B[37m%s\u001B[0m";
|
|
494
|
+
declare const COLOR_MAGENTA = "\u001B[35m%s\u001B[0m";
|
|
495
|
+
declare const COLOR_BLUE = "\u001B[34m%s\u001B[0m";
|
|
496
|
+
declare const COLOR_CYAN = "\u001B[36m%s\u001B[0m";
|
|
497
|
+
declare const COLOR_GREEN = "\u001B[32m%s\u001B[0m";
|
|
498
|
+
declare const COLOR_RED = "\u001B[31m%s\u001B[0m";
|
|
499
|
+
declare const COLOR_ERROR = "\u001B[31m%s\u001B[0m";
|
|
500
|
+
declare const COLOR_YELLOW = "\u001B[33m%s\u001B[0m";
|
|
501
|
+
declare const COLOR_ORANGE = "\u001B[38;5;208m%s\u001B[0m";
|
|
502
|
+
declare const COLOR_WARNING = "\u001B[33m%s\u001B[0m";
|
|
503
|
+
declare const COLOR_PROVIDER = "\u001B[35m%s\u001B[0m";
|
|
504
|
+
declare const COLOR_CONTEXT = "\u001B[35m%s\u001B[0m";
|
|
505
|
+
declare const COLOR_RENDER = "\u001B[34m%s\u001B[0m";
|
|
506
|
+
declare const COLOR_FUNCTION = "\u001B[36m%s\u001B[0m";
|
|
507
|
+
declare const COLOR_SCREEN = "\u001B[32m%s\u001B[0m";
|
|
508
|
+
declare const COLOR_SOCKET = "\u001B[36m%s\u001B[0m";
|
|
509
|
+
declare const COLOR_SOCKETS = "\u001B[33m%s\u001B[0m";
|
|
510
|
+
declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
511
|
+
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
512
|
+
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
513
|
+
|
|
483
514
|
/**
|
|
484
515
|
* Zobrazí obsah celé databáze v console.log
|
|
485
516
|
* Používá se pro debugging storage
|
|
486
517
|
*/
|
|
487
518
|
declare function logStorageContent(storage: DataStoreStorage): Promise<void>;
|
|
488
519
|
|
|
489
|
-
export { type DataProviderType, type DataProvidersType, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderSchemaItemType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, logStorageContent, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
|
520
|
+
export { COLOR_APP, COLOR_AXIOS, COLOR_BLUE, COLOR_CONTEXT, COLOR_CYAN, COLOR_DS, COLOR_ERROR, COLOR_FUNCTION, COLOR_GREEN, COLOR_MAGENTA, COLOR_ORANGE, COLOR_PROVIDER, COLOR_RED, COLOR_RENDER, COLOR_SCREEN, COLOR_SOCKET, COLOR_SOCKETS, COLOR_WARNING, COLOR_WHITE, COLOR_YELLOW, type DataProviderType, type DataProvidersType, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderSchemaItemType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, logStorageContent, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
package/dist/index.js
CHANGED
|
@@ -673,6 +673,17 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
673
673
|
console.log("Stahuji data z ", buildUri({ dataSource, method: "read" }), " s parametry ", params);
|
|
674
674
|
const axiosResponse = await axios.get(buildUri({ dataSource, method: "read" }), { params: serializeParams(params) });
|
|
675
675
|
if (schema && !dataSource.readAllFields) {
|
|
676
|
+
const mapBySchema = (element) => {
|
|
677
|
+
const mappedRow = {};
|
|
678
|
+
Object.keys(schema).forEach((key) => {
|
|
679
|
+
const sourceKey = schema[key].source || key;
|
|
680
|
+
const value = typeof element === "object" && element !== null ? element[sourceKey] : element;
|
|
681
|
+
if (value !== void 0) {
|
|
682
|
+
mappedRow[key] = value;
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
return mappedRow;
|
|
686
|
+
};
|
|
676
687
|
if (Array.isArray(axiosResponse.data.data)) {
|
|
677
688
|
newData = [];
|
|
678
689
|
axiosResponse.data.data.forEach((element) => {
|
|
@@ -680,14 +691,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
680
691
|
newData.push(element);
|
|
681
692
|
return;
|
|
682
693
|
}
|
|
683
|
-
|
|
684
|
-
Object.keys(schema).forEach((key) => {
|
|
685
|
-
if (typeof element === "object") {
|
|
686
|
-
newRow[key] = schema[key].source ? element[schema[key].source] : element[key];
|
|
687
|
-
} else {
|
|
688
|
-
newRow[key] = element;
|
|
689
|
-
}
|
|
690
|
-
});
|
|
694
|
+
const newRow = mapBySchema(element);
|
|
691
695
|
if (!newRow.id && ["payments", "deliveries"].includes(id)) {
|
|
692
696
|
if (element.id) {
|
|
693
697
|
newRow.id = id + "-" + element.id;
|
|
@@ -698,10 +702,7 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
698
702
|
newData.push(newRow);
|
|
699
703
|
});
|
|
700
704
|
} else {
|
|
701
|
-
newData =
|
|
702
|
-
Object.keys(schema).forEach((key) => {
|
|
703
|
-
newData[key] = schema[key].source ? axiosResponse.data.data[schema[key].source] : axiosResponse.data.data[key];
|
|
704
|
-
});
|
|
705
|
+
newData = mapBySchema(axiosResponse.data.data);
|
|
705
706
|
}
|
|
706
707
|
} else {
|
|
707
708
|
newData = axiosResponse.data.data;
|
|
@@ -731,6 +732,8 @@ var getData = async ({ id, dataSource, isPersisting, schema, SQLite, changeTime
|
|
|
731
732
|
`getData - Polozky ${id} persisted: ${persistedData.length}, newData: ${newData.length}, vysledek: ${updatedArray.length}`
|
|
732
733
|
);
|
|
733
734
|
console.timeEnd("Maping");
|
|
735
|
+
console.log("================== NEW DATA");
|
|
736
|
+
console.log(newData);
|
|
734
737
|
return updatedArray;
|
|
735
738
|
} else {
|
|
736
739
|
return newData || [];
|
|
@@ -1152,6 +1155,23 @@ var DataStoreProvider = forwardRef(
|
|
|
1152
1155
|
actions: [...prev.actions, { action, data, callback }]
|
|
1153
1156
|
}));
|
|
1154
1157
|
}, []);
|
|
1158
|
+
const mergeWithNullDeletion = useCallback((base, patch) => {
|
|
1159
|
+
const isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1160
|
+
if (!isObject(patch)) return patch;
|
|
1161
|
+
const result = isObject(base) ? { ...base } : {};
|
|
1162
|
+
Object.entries(patch).forEach(([key, value]) => {
|
|
1163
|
+
if (value === null) {
|
|
1164
|
+
delete result[key];
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if (isObject(value)) {
|
|
1168
|
+
result[key] = mergeWithNullDeletion(result[key], value);
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
result[key] = value;
|
|
1172
|
+
});
|
|
1173
|
+
return result;
|
|
1174
|
+
}, []);
|
|
1155
1175
|
useEffect(() => {
|
|
1156
1176
|
async function processDispatcher() {
|
|
1157
1177
|
if (dispatcher.actions.length > 0) {
|
|
@@ -1245,7 +1265,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1245
1265
|
if (!newDocs[id]) {
|
|
1246
1266
|
systemLog("dsp", "updateDocuments - vytvarim", id);
|
|
1247
1267
|
data.push(id);
|
|
1248
|
-
newDocs[id] = doc;
|
|
1268
|
+
newDocs[id] = mergeWithNullDeletion(void 0, doc);
|
|
1249
1269
|
documentsToPersist.push({ id, data: newDocs[id] });
|
|
1250
1270
|
} else if (doc._deleted) {
|
|
1251
1271
|
systemLog("dsp", "updateDocuments - mazu", id);
|
|
@@ -1254,7 +1274,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1254
1274
|
delete newDocs[id];
|
|
1255
1275
|
} else {
|
|
1256
1276
|
systemLog("dsp", "updateDocuments - updatuji", id);
|
|
1257
|
-
newDocs[id] =
|
|
1277
|
+
newDocs[id] = mergeWithNullDeletion(newDocs[id], doc);
|
|
1258
1278
|
documentsToPersist.push({ id, data: newDocs[id] });
|
|
1259
1279
|
}
|
|
1260
1280
|
break;
|
|
@@ -1282,7 +1302,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1282
1302
|
default:
|
|
1283
1303
|
if (!newDocs[key]) {
|
|
1284
1304
|
data.push(key);
|
|
1285
|
-
newDocs[key] = uDocuments[key];
|
|
1305
|
+
newDocs[key] = mergeWithNullDeletion(void 0, uDocuments[key]);
|
|
1286
1306
|
documentsToPersist.push({ id: key, data: newDocs[key] });
|
|
1287
1307
|
break;
|
|
1288
1308
|
}
|
|
@@ -1291,7 +1311,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1291
1311
|
documentIdsToDelete.push(key);
|
|
1292
1312
|
delete newDocs[key];
|
|
1293
1313
|
} else {
|
|
1294
|
-
newDocs[key] =
|
|
1314
|
+
newDocs[key] = mergeWithNullDeletion(newDocs[key], uDocuments[key]);
|
|
1295
1315
|
documentsToPersist.push({ id: key, data: newDocs[key] });
|
|
1296
1316
|
}
|
|
1297
1317
|
break;
|
|
@@ -1316,7 +1336,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1316
1336
|
await Promise.all(documentIdsToDelete.map((documentId) => removePersistedDocument(documentId)));
|
|
1317
1337
|
}
|
|
1318
1338
|
},
|
|
1319
|
-
[providers, setDocuments, setProviders, persistDocument, removePersistedDocument, persistenceStorage]
|
|
1339
|
+
[providers, setDocuments, setProviders, persistDocument, removePersistedDocument, persistenceStorage, mergeWithNullDeletion]
|
|
1320
1340
|
);
|
|
1321
1341
|
const updateDocument = useCallback(
|
|
1322
1342
|
async ({ documentId, model, fields, data: pData }) => {
|
|
@@ -1344,6 +1364,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1344
1364
|
}
|
|
1345
1365
|
if (data) {
|
|
1346
1366
|
console.log("[updateDocument]:", documentId, ", model:", model);
|
|
1367
|
+
const documentForFilter = mergeWithNullDeletion(documents[documentId], dataWithDocumentId);
|
|
1347
1368
|
var listeningProviders = 0;
|
|
1348
1369
|
var isProvidersUpdated = false;
|
|
1349
1370
|
const rand = uuid();
|
|
@@ -1360,7 +1381,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1360
1381
|
var socketListeners = providerNext.dataSource?.socketListeners || [];
|
|
1361
1382
|
if (socketListeners.length === 0) {
|
|
1362
1383
|
if (providerNext.data.includes(documentId)) {
|
|
1363
|
-
if (!providerNext.dataSource?.filter || filterDocuments(
|
|
1384
|
+
if (!providerNext.dataSource?.filter || filterDocuments(documentForFilter, providerNext.dataSource?.filter)) {
|
|
1364
1385
|
systemLog("dsp", "[updateDocument] - zustava v Provider bez Listeners:", key);
|
|
1365
1386
|
listeningProviders++;
|
|
1366
1387
|
providerNext.lastUpdate = {
|
|
@@ -1380,7 +1401,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1380
1401
|
}
|
|
1381
1402
|
} else if (socketListeners.includes(model) || // socketListeners.includes(documentId) ||
|
|
1382
1403
|
key === model) {
|
|
1383
|
-
if (!providerNext.dataSource.filter || filterDocuments(
|
|
1404
|
+
if (!providerNext.dataSource.filter || filterDocuments(documentForFilter, providerNext.dataSource.filter)) {
|
|
1384
1405
|
listeningProviders++;
|
|
1385
1406
|
providerNext.lastUpdate = {
|
|
1386
1407
|
id: uuid(),
|
|
@@ -1420,12 +1441,12 @@ var DataStoreProvider = forwardRef(
|
|
|
1420
1441
|
console.timeEnd("[DSP UPDATE DOCUMENTS INSIDE]");
|
|
1421
1442
|
return {
|
|
1422
1443
|
...prev2,
|
|
1423
|
-
[documentId]:
|
|
1444
|
+
[documentId]: mergeWithNullDeletion(prev2[documentId], dataWithDocumentId)
|
|
1424
1445
|
};
|
|
1425
1446
|
}
|
|
1426
1447
|
} else if (listeningProviders > 0) {
|
|
1427
1448
|
console.timeEnd("[DSP UPDATE DOCUMENTS INSIDE]");
|
|
1428
|
-
return { ...prev2, [documentId]: dataWithDocumentId };
|
|
1449
|
+
return { ...prev2, [documentId]: mergeWithNullDeletion(void 0, dataWithDocumentId) };
|
|
1429
1450
|
}
|
|
1430
1451
|
console.timeEnd("[DSP UPDATE DOCUMENTS INSIDE]");
|
|
1431
1452
|
return prev2;
|
|
@@ -1454,7 +1475,7 @@ var DataStoreProvider = forwardRef(
|
|
|
1454
1475
|
await persistDocument({
|
|
1455
1476
|
documentId,
|
|
1456
1477
|
model,
|
|
1457
|
-
data:
|
|
1478
|
+
data: documentForFilter
|
|
1458
1479
|
});
|
|
1459
1480
|
} else {
|
|
1460
1481
|
await removePersistedDocument(documentId);
|
|
@@ -1462,7 +1483,17 @@ var DataStoreProvider = forwardRef(
|
|
|
1462
1483
|
}
|
|
1463
1484
|
}
|
|
1464
1485
|
},
|
|
1465
|
-
[
|
|
1486
|
+
[
|
|
1487
|
+
documents,
|
|
1488
|
+
providers,
|
|
1489
|
+
setDocuments,
|
|
1490
|
+
setProviders,
|
|
1491
|
+
setCounterDocuments,
|
|
1492
|
+
persistDocument,
|
|
1493
|
+
removePersistedDocument,
|
|
1494
|
+
persistenceStorage,
|
|
1495
|
+
mergeWithNullDeletion
|
|
1496
|
+
]
|
|
1466
1497
|
);
|
|
1467
1498
|
const updateDataStore = useCallback(
|
|
1468
1499
|
async ({ id, documentId, params, variant, data }) => {
|
|
@@ -2038,23 +2069,11 @@ var useDataProvider = (id, params, dataFilter, settings) => {
|
|
|
2038
2069
|
};
|
|
2039
2070
|
const updateItem = ({ params: params2, data, variant, documentId = void 0 }, callback) => {
|
|
2040
2071
|
systemLog("usedp", "UPDATUJI:", providerId, ", variant:", variant, ", documentId: ", documentId, ", params:", params2, ", data:", data);
|
|
2041
|
-
|
|
2042
|
-
const wrappedCallback = (result) => {
|
|
2043
|
-
callback?.(result);
|
|
2044
|
-
resolve(result);
|
|
2045
|
-
};
|
|
2046
|
-
dispatch("updateDataStore", { id: providerId, variant, params: params2, data, documentId }, wrappedCallback);
|
|
2047
|
-
});
|
|
2072
|
+
dispatch("updateDataStore", { id: providerId, variant, params: params2, data, documentId }, callback);
|
|
2048
2073
|
};
|
|
2049
2074
|
const deleteItem = ({ params: params2, data }, callback) => {
|
|
2050
2075
|
systemLog("usedp", "DELETE FROM:", providerId, ", params:", params2, "data:", data);
|
|
2051
|
-
|
|
2052
|
-
const wrappedCallback = (result) => {
|
|
2053
|
-
callback?.(result);
|
|
2054
|
-
resolve(result);
|
|
2055
|
-
};
|
|
2056
|
-
dispatch("deleteProviderItem", { providerId, data, params: params2 }, wrappedCallback);
|
|
2057
|
-
});
|
|
2076
|
+
dispatch("deleteProviderItem", { providerId, data, params: params2 }, callback);
|
|
2058
2077
|
};
|
|
2059
2078
|
const createItem = (data, callback) => {
|
|
2060
2079
|
return new Promise((resolve, reject) => {
|
|
@@ -2185,22 +2204,10 @@ var useProviderActions = (providerId, data) => {
|
|
|
2185
2204
|
dispatch("updateDataStore", { id: providerId, data: val });
|
|
2186
2205
|
};
|
|
2187
2206
|
const updateItem = ({ params, data: data2, variant, documentId = void 0 }, callback) => {
|
|
2188
|
-
|
|
2189
|
-
const wrappedCallback = (result) => {
|
|
2190
|
-
callback?.(result);
|
|
2191
|
-
resolve(result);
|
|
2192
|
-
};
|
|
2193
|
-
dispatch("updateDataStore", { id: providerId, variant, params, data: data2, documentId }, wrappedCallback);
|
|
2194
|
-
});
|
|
2207
|
+
dispatch("updateDataStore", { id: providerId, variant, params, data: data2, documentId }, callback);
|
|
2195
2208
|
};
|
|
2196
2209
|
const deleteItem = ({ params, data: data2 }, callback) => {
|
|
2197
|
-
|
|
2198
|
-
const wrappedCallback = (result) => {
|
|
2199
|
-
callback?.(result);
|
|
2200
|
-
resolve(result);
|
|
2201
|
-
};
|
|
2202
|
-
dispatch("deleteProviderItem", { providerId, data: data2, params }, wrappedCallback);
|
|
2203
|
-
});
|
|
2210
|
+
dispatch("deleteProviderItem", { providerId, data: data2, params }, callback);
|
|
2204
2211
|
};
|
|
2205
2212
|
const createItem = (data2, callback) => {
|
|
2206
2213
|
systemLog("usedp", "createItem Prov. id:", providerId);
|
|
@@ -2221,6 +2228,28 @@ var useProviderActions = (providerId, data) => {
|
|
|
2221
2228
|
};
|
|
2222
2229
|
};
|
|
2223
2230
|
|
|
2231
|
+
// src/logColors.ts
|
|
2232
|
+
var COLOR_WHITE = `\x1B[37m%s\x1B[0m`;
|
|
2233
|
+
var COLOR_MAGENTA = `\x1B[35m%s\x1B[0m`;
|
|
2234
|
+
var COLOR_BLUE = `\x1B[34m%s\x1B[0m`;
|
|
2235
|
+
var COLOR_CYAN = `\x1B[36m%s\x1B[0m`;
|
|
2236
|
+
var COLOR_GREEN = `\x1B[32m%s\x1B[0m`;
|
|
2237
|
+
var COLOR_RED = `\x1B[31m%s\x1B[0m`;
|
|
2238
|
+
var COLOR_ERROR = `\x1B[31m%s\x1B[0m`;
|
|
2239
|
+
var COLOR_YELLOW = `\x1B[33m%s\x1B[0m`;
|
|
2240
|
+
var COLOR_ORANGE = `\x1B[38;5;208m%s\x1B[0m`;
|
|
2241
|
+
var COLOR_WARNING = `\x1B[33m%s\x1B[0m`;
|
|
2242
|
+
var COLOR_PROVIDER = COLOR_MAGENTA;
|
|
2243
|
+
var COLOR_CONTEXT = COLOR_MAGENTA;
|
|
2244
|
+
var COLOR_RENDER = COLOR_BLUE;
|
|
2245
|
+
var COLOR_FUNCTION = COLOR_CYAN;
|
|
2246
|
+
var COLOR_SCREEN = COLOR_GREEN;
|
|
2247
|
+
var COLOR_SOCKET = COLOR_CYAN;
|
|
2248
|
+
var COLOR_SOCKETS = COLOR_YELLOW;
|
|
2249
|
+
var COLOR_AXIOS = COLOR_YELLOW;
|
|
2250
|
+
var COLOR_APP = COLOR_BLUE;
|
|
2251
|
+
var COLOR_DS = COLOR_MAGENTA;
|
|
2252
|
+
|
|
2224
2253
|
// src/debugStorage.ts
|
|
2225
2254
|
async function logStorageContent(storage) {
|
|
2226
2255
|
try {
|
|
@@ -2249,6 +2278,26 @@ async function logStorageContent(storage) {
|
|
|
2249
2278
|
}
|
|
2250
2279
|
}
|
|
2251
2280
|
export {
|
|
2281
|
+
COLOR_APP,
|
|
2282
|
+
COLOR_AXIOS,
|
|
2283
|
+
COLOR_BLUE,
|
|
2284
|
+
COLOR_CONTEXT,
|
|
2285
|
+
COLOR_CYAN,
|
|
2286
|
+
COLOR_DS,
|
|
2287
|
+
COLOR_ERROR,
|
|
2288
|
+
COLOR_FUNCTION,
|
|
2289
|
+
COLOR_GREEN,
|
|
2290
|
+
COLOR_MAGENTA,
|
|
2291
|
+
COLOR_ORANGE,
|
|
2292
|
+
COLOR_PROVIDER,
|
|
2293
|
+
COLOR_RED,
|
|
2294
|
+
COLOR_RENDER,
|
|
2295
|
+
COLOR_SCREEN,
|
|
2296
|
+
COLOR_SOCKET,
|
|
2297
|
+
COLOR_SOCKETS,
|
|
2298
|
+
COLOR_WARNING,
|
|
2299
|
+
COLOR_WHITE,
|
|
2300
|
+
COLOR_YELLOW,
|
|
2252
2301
|
DataStoreActionsContext,
|
|
2253
2302
|
DataStoreContext,
|
|
2254
2303
|
DataStoreDocumentsContext,
|