@mgarlik/datastore 0.1.8 → 0.1.9

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.d.cts CHANGED
@@ -355,14 +355,14 @@ interface UseDataProviderResult {
355
355
  data?: JSONType;
356
356
  variant?: string;
357
357
  documentId?: string;
358
- }, callback?: (resp: JSONType) => void) => void;
358
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
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) => void;
363
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
364
364
  /** Vytvoří novou položku providera. */
365
- createItem: (data: JSONType, callback?: () => void) => void;
365
+ createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
366
366
  }
367
367
  /**
368
368
  * Zaregistruje/zpřístupní providera a vrátí normalizované dokumenty spolu s CRUD helpery.
@@ -439,14 +439,14 @@ interface UseProviderActionsResult {
439
439
  data?: any;
440
440
  variant?: string;
441
441
  documentId?: Uuid;
442
- }, callback?: (value: JSONType) => void) => void;
442
+ }, callback?: (value: JSONType) => void) => Promise<JSONType>;
443
443
  /** Smaže položku/položky providera. */
444
444
  deleteItem: (args: {
445
445
  params: JSONType;
446
446
  data?: JSONType;
447
- }, callback?: () => void) => void;
447
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
448
448
  /** Vytvoří novou položku providera. */
449
- createItem: (data: JSONType, callback?: (value: JSONType) => void) => void;
449
+ createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
450
450
  }
451
451
  /**
452
452
  * Vrací action helpery pro známé provider id.
@@ -480,41 +480,10 @@ 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
-
514
483
  /**
515
484
  * Zobrazí obsah celé databáze v console.log
516
485
  * Používá se pro debugging storage
517
486
  */
518
487
  declare function logStorageContent(storage: DataStoreStorage): Promise<void>;
519
488
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -355,14 +355,14 @@ interface UseDataProviderResult {
355
355
  data?: JSONType;
356
356
  variant?: string;
357
357
  documentId?: string;
358
- }, callback?: (resp: JSONType) => void) => void;
358
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
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) => void;
363
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
364
364
  /** Vytvoří novou položku providera. */
365
- createItem: (data: JSONType, callback?: () => void) => void;
365
+ createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
366
366
  }
367
367
  /**
368
368
  * Zaregistruje/zpřístupní providera a vrátí normalizované dokumenty spolu s CRUD helpery.
@@ -439,14 +439,14 @@ interface UseProviderActionsResult {
439
439
  data?: any;
440
440
  variant?: string;
441
441
  documentId?: Uuid;
442
- }, callback?: (value: JSONType) => void) => void;
442
+ }, callback?: (value: JSONType) => void) => Promise<JSONType>;
443
443
  /** Smaže položku/položky providera. */
444
444
  deleteItem: (args: {
445
445
  params: JSONType;
446
446
  data?: JSONType;
447
- }, callback?: () => void) => void;
447
+ }, callback?: (resp: JSONType) => void) => Promise<JSONType>;
448
448
  /** Vytvoří novou položku providera. */
449
- createItem: (data: JSONType, callback?: (value: JSONType) => void) => void;
449
+ createItem: (data: JSONType, callback?: (value: JSONType) => void) => Promise<JSONType>;
450
450
  }
451
451
  /**
452
452
  * Vrací action helpery pro známé provider id.
@@ -480,41 +480,10 @@ 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
-
514
483
  /**
515
484
  * Zobrazí obsah celé databáze v console.log
516
485
  * Používá se pro debugging storage
517
486
  */
518
487
  declare function logStorageContent(storage: DataStoreStorage): Promise<void>;
519
488
 
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 };
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 };
package/dist/index.js CHANGED
@@ -2038,14 +2038,32 @@ var useDataProvider = (id, params, dataFilter, settings) => {
2038
2038
  };
2039
2039
  const updateItem = ({ params: params2, data, variant, documentId = void 0 }, callback) => {
2040
2040
  systemLog("usedp", "UPDATUJI:", providerId, ", variant:", variant, ", documentId: ", documentId, ", params:", params2, ", data:", data);
2041
- dispatch("updateDataStore", { id: providerId, variant, params: params2, data, documentId }, callback);
2041
+ return new Promise((resolve, reject) => {
2042
+ const wrappedCallback = (result) => {
2043
+ callback?.(result);
2044
+ resolve(result);
2045
+ };
2046
+ dispatch("updateDataStore", { id: providerId, variant, params: params2, data, documentId }, wrappedCallback);
2047
+ });
2042
2048
  };
2043
2049
  const deleteItem = ({ params: params2, data }, callback) => {
2044
2050
  systemLog("usedp", "DELETE FROM:", providerId, ", params:", params2, "data:", data);
2045
- dispatch("deleteProviderItem", { providerId, data, params: params2 }, callback);
2051
+ return new Promise((resolve, reject) => {
2052
+ const wrappedCallback = (result) => {
2053
+ callback?.(result);
2054
+ resolve(result);
2055
+ };
2056
+ dispatch("deleteProviderItem", { providerId, data, params: params2 }, wrappedCallback);
2057
+ });
2046
2058
  };
2047
2059
  const createItem = (data, callback) => {
2048
- dispatch("createProviderItem", { id, data }, callback);
2060
+ return new Promise((resolve, reject) => {
2061
+ const wrappedCallback = (result) => {
2062
+ callback?.(result);
2063
+ resolve(result);
2064
+ };
2065
+ dispatch("createProviderItem", { id, data }, wrappedCallback);
2066
+ });
2049
2067
  };
2050
2068
  const provider = useMemo2(() => {
2051
2069
  systemLog("usedp", "Vytvoreni dat: ", filter);
@@ -2167,14 +2185,32 @@ var useProviderActions = (providerId, data) => {
2167
2185
  dispatch("updateDataStore", { id: providerId, data: val });
2168
2186
  };
2169
2187
  const updateItem = ({ params, data: data2, variant, documentId = void 0 }, callback) => {
2170
- dispatch("updateDataStore", { id: providerId, variant, params, data: data2, documentId }, callback);
2188
+ return new Promise((resolve, reject) => {
2189
+ const wrappedCallback = (result) => {
2190
+ callback?.(result);
2191
+ resolve(result);
2192
+ };
2193
+ dispatch("updateDataStore", { id: providerId, variant, params, data: data2, documentId }, wrappedCallback);
2194
+ });
2171
2195
  };
2172
2196
  const deleteItem = ({ params, data: data2 }, callback) => {
2173
- dispatch("deleteProviderItem", { providerId, data: data2, params }, callback);
2197
+ return new Promise((resolve, reject) => {
2198
+ const wrappedCallback = (result) => {
2199
+ callback?.(result);
2200
+ resolve(result);
2201
+ };
2202
+ dispatch("deleteProviderItem", { providerId, data: data2, params }, wrappedCallback);
2203
+ });
2174
2204
  };
2175
2205
  const createItem = (data2, callback) => {
2176
2206
  systemLog("usedp", "createItem Prov. id:", providerId);
2177
- dispatch("createProviderItem", { id: providerId, data: data2 }, callback);
2207
+ return new Promise((resolve, reject) => {
2208
+ const wrappedCallback = (result) => {
2209
+ callback?.(result);
2210
+ resolve(result);
2211
+ };
2212
+ dispatch("createProviderItem", { id: providerId, data: data2 }, wrappedCallback);
2213
+ });
2178
2214
  };
2179
2215
  return {
2180
2216
  schema: providers[providerId]?.schema,
@@ -2185,28 +2221,6 @@ var useProviderActions = (providerId, data) => {
2185
2221
  };
2186
2222
  };
2187
2223
 
2188
- // src/logColors.ts
2189
- var COLOR_WHITE = `\x1B[37m%s\x1B[0m`;
2190
- var COLOR_MAGENTA = `\x1B[35m%s\x1B[0m`;
2191
- var COLOR_BLUE = `\x1B[34m%s\x1B[0m`;
2192
- var COLOR_CYAN = `\x1B[36m%s\x1B[0m`;
2193
- var COLOR_GREEN = `\x1B[32m%s\x1B[0m`;
2194
- var COLOR_RED = `\x1B[31m%s\x1B[0m`;
2195
- var COLOR_ERROR = `\x1B[31m%s\x1B[0m`;
2196
- var COLOR_YELLOW = `\x1B[33m%s\x1B[0m`;
2197
- var COLOR_ORANGE = `\x1B[38;5;208m%s\x1B[0m`;
2198
- var COLOR_WARNING = `\x1B[33m%s\x1B[0m`;
2199
- var COLOR_PROVIDER = COLOR_MAGENTA;
2200
- var COLOR_CONTEXT = COLOR_MAGENTA;
2201
- var COLOR_RENDER = COLOR_BLUE;
2202
- var COLOR_FUNCTION = COLOR_CYAN;
2203
- var COLOR_SCREEN = COLOR_GREEN;
2204
- var COLOR_SOCKET = COLOR_CYAN;
2205
- var COLOR_SOCKETS = COLOR_YELLOW;
2206
- var COLOR_AXIOS = COLOR_YELLOW;
2207
- var COLOR_APP = COLOR_BLUE;
2208
- var COLOR_DS = COLOR_MAGENTA;
2209
-
2210
2224
  // src/debugStorage.ts
2211
2225
  async function logStorageContent(storage) {
2212
2226
  try {
@@ -2235,26 +2249,6 @@ async function logStorageContent(storage) {
2235
2249
  }
2236
2250
  }
2237
2251
  export {
2238
- COLOR_APP,
2239
- COLOR_AXIOS,
2240
- COLOR_BLUE,
2241
- COLOR_CONTEXT,
2242
- COLOR_CYAN,
2243
- COLOR_DS,
2244
- COLOR_ERROR,
2245
- COLOR_FUNCTION,
2246
- COLOR_GREEN,
2247
- COLOR_MAGENTA,
2248
- COLOR_ORANGE,
2249
- COLOR_PROVIDER,
2250
- COLOR_RED,
2251
- COLOR_RENDER,
2252
- COLOR_SCREEN,
2253
- COLOR_SOCKET,
2254
- COLOR_SOCKETS,
2255
- COLOR_WARNING,
2256
- COLOR_WHITE,
2257
- COLOR_YELLOW,
2258
2252
  DataStoreActionsContext,
2259
2253
  DataStoreContext,
2260
2254
  DataStoreDocumentsContext,