@mgarlik/datastore 0.1.1 → 0.1.3
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 +971 -909
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -5
- package/dist/index.d.ts +47 -5
- package/dist/index.js +982 -910
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import React, { ReactNode } from 'react';
|
|
3
2
|
import { D as DataStoreStorage } from './storage-D_xv8gFb.cjs';
|
|
4
3
|
|
|
@@ -57,11 +56,23 @@ type JSONType = string | number | boolean | {
|
|
|
57
56
|
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
58
57
|
type SocketServerType = {
|
|
59
58
|
url: string;
|
|
60
|
-
params:
|
|
59
|
+
params: {
|
|
60
|
+
autoConnect: boolean;
|
|
61
|
+
transports: string[];
|
|
62
|
+
auth: Record<string, any>;
|
|
63
|
+
/**
|
|
64
|
+
* Jakym socket eventům naslouchat pro aktualizace dat. Pokud není uvedeno, naslouchá se na ["create", "update", "delete"].
|
|
65
|
+
*/
|
|
66
|
+
socketEvents?: string[];
|
|
67
|
+
};
|
|
61
68
|
};
|
|
62
69
|
/** In-memory metadata aktivní socket místnosti. */
|
|
63
|
-
type
|
|
70
|
+
type SocketFilterItem = {
|
|
71
|
+
filter: Record<string, any>;
|
|
64
72
|
listeners: number;
|
|
73
|
+
};
|
|
74
|
+
type SocketItem = {
|
|
75
|
+
filters: SocketFilterItem[];
|
|
65
76
|
data: any[];
|
|
66
77
|
};
|
|
67
78
|
/** Podporované akce zpracovávané interní frontou dispatcheru. */
|
|
@@ -251,10 +262,41 @@ declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
|
251
262
|
declare const useProvider: (val: ProviderTypes) => any;
|
|
252
263
|
/** Kompletní DataStore - spojuje všechny sub-contexty. Komponenty s tímto hookem se přerenderují při jakékoliv změně stavu. */
|
|
253
264
|
declare const useDataStore: () => DataStore;
|
|
265
|
+
/**
|
|
266
|
+
* Imperativní API `DataStoreProvider` vystavené přes `ref`.
|
|
267
|
+
*
|
|
268
|
+
* Umožňuje volat akce DataStore přímo z rodiče (např. `App.tsx`)
|
|
269
|
+
* bez nutnosti použití `useDataStoreActions` hooku uvnitř stromové hierarchie.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```tsx
|
|
273
|
+
* const dsRef = useRef<DataStoreRef>(null);
|
|
274
|
+
*
|
|
275
|
+
* <DataStoreProvider ref={dsRef} ...>
|
|
276
|
+
* <AppProvider
|
|
277
|
+
* auth={{
|
|
278
|
+
* requireLogin: true,
|
|
279
|
+
* onLogin: ({ userId }) => {
|
|
280
|
+
* dsRef.current?.startSockets();
|
|
281
|
+
* dsRef.current?.registerProviderSockets(userId);
|
|
282
|
+
* },
|
|
283
|
+
* onLogout: ({ userId }) => {
|
|
284
|
+
* dsRef.current?.unregisterProviderSockets(userId);
|
|
285
|
+
* dsRef.current?.stopSockets();
|
|
286
|
+
* },
|
|
287
|
+
* }}
|
|
288
|
+
* />
|
|
289
|
+
* </DataStoreProvider>
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
type DataStoreRef = DataStoreActionsType;
|
|
254
293
|
/**
|
|
255
294
|
* Kořenový provider, který propojuje DataStore contexty, REST načítání, sockety a volitelnou persistenci.
|
|
295
|
+
*
|
|
296
|
+
* Podporuje volitelný `ref` (`DataStoreRef`) pro imperativní přístup k akcím
|
|
297
|
+
* přímo z rodičovské komponenty bez použití kontextového hooku.
|
|
256
298
|
*/
|
|
257
|
-
declare const DataStoreProvider:
|
|
299
|
+
declare const DataStoreProvider: React.ForwardRefExoticComponent<DataStoreProps & React.RefAttributes<DataStoreActionsType>>;
|
|
258
300
|
|
|
259
301
|
interface UseDataProviderResult {
|
|
260
302
|
/** Materializované dokumenty providera po vyhodnocení šablon a filtraci. */
|
|
@@ -425,4 +467,4 @@ declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
|
425
467
|
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
426
468
|
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
427
469
|
|
|
428
|
-
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 DataProvider, type DataProviders, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes, type SchemaType, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
|
470
|
+
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 DataProvider, type DataProviders, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes, type SchemaType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import React, { ReactNode } from 'react';
|
|
3
2
|
import { D as DataStoreStorage } from './storage-D_xv8gFb.js';
|
|
4
3
|
|
|
@@ -57,11 +56,23 @@ type JSONType = string | number | boolean | {
|
|
|
57
56
|
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
58
57
|
type SocketServerType = {
|
|
59
58
|
url: string;
|
|
60
|
-
params:
|
|
59
|
+
params: {
|
|
60
|
+
autoConnect: boolean;
|
|
61
|
+
transports: string[];
|
|
62
|
+
auth: Record<string, any>;
|
|
63
|
+
/**
|
|
64
|
+
* Jakym socket eventům naslouchat pro aktualizace dat. Pokud není uvedeno, naslouchá se na ["create", "update", "delete"].
|
|
65
|
+
*/
|
|
66
|
+
socketEvents?: string[];
|
|
67
|
+
};
|
|
61
68
|
};
|
|
62
69
|
/** In-memory metadata aktivní socket místnosti. */
|
|
63
|
-
type
|
|
70
|
+
type SocketFilterItem = {
|
|
71
|
+
filter: Record<string, any>;
|
|
64
72
|
listeners: number;
|
|
73
|
+
};
|
|
74
|
+
type SocketItem = {
|
|
75
|
+
filters: SocketFilterItem[];
|
|
65
76
|
data: any[];
|
|
66
77
|
};
|
|
67
78
|
/** Podporované akce zpracovávané interní frontou dispatcheru. */
|
|
@@ -251,10 +262,41 @@ declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
|
251
262
|
declare const useProvider: (val: ProviderTypes) => any;
|
|
252
263
|
/** Kompletní DataStore - spojuje všechny sub-contexty. Komponenty s tímto hookem se přerenderují při jakékoliv změně stavu. */
|
|
253
264
|
declare const useDataStore: () => DataStore;
|
|
265
|
+
/**
|
|
266
|
+
* Imperativní API `DataStoreProvider` vystavené přes `ref`.
|
|
267
|
+
*
|
|
268
|
+
* Umožňuje volat akce DataStore přímo z rodiče (např. `App.tsx`)
|
|
269
|
+
* bez nutnosti použití `useDataStoreActions` hooku uvnitř stromové hierarchie.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```tsx
|
|
273
|
+
* const dsRef = useRef<DataStoreRef>(null);
|
|
274
|
+
*
|
|
275
|
+
* <DataStoreProvider ref={dsRef} ...>
|
|
276
|
+
* <AppProvider
|
|
277
|
+
* auth={{
|
|
278
|
+
* requireLogin: true,
|
|
279
|
+
* onLogin: ({ userId }) => {
|
|
280
|
+
* dsRef.current?.startSockets();
|
|
281
|
+
* dsRef.current?.registerProviderSockets(userId);
|
|
282
|
+
* },
|
|
283
|
+
* onLogout: ({ userId }) => {
|
|
284
|
+
* dsRef.current?.unregisterProviderSockets(userId);
|
|
285
|
+
* dsRef.current?.stopSockets();
|
|
286
|
+
* },
|
|
287
|
+
* }}
|
|
288
|
+
* />
|
|
289
|
+
* </DataStoreProvider>
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
type DataStoreRef = DataStoreActionsType;
|
|
254
293
|
/**
|
|
255
294
|
* Kořenový provider, který propojuje DataStore contexty, REST načítání, sockety a volitelnou persistenci.
|
|
295
|
+
*
|
|
296
|
+
* Podporuje volitelný `ref` (`DataStoreRef`) pro imperativní přístup k akcím
|
|
297
|
+
* přímo z rodičovské komponenty bez použití kontextového hooku.
|
|
256
298
|
*/
|
|
257
|
-
declare const DataStoreProvider:
|
|
299
|
+
declare const DataStoreProvider: React.ForwardRefExoticComponent<DataStoreProps & React.RefAttributes<DataStoreActionsType>>;
|
|
258
300
|
|
|
259
301
|
interface UseDataProviderResult {
|
|
260
302
|
/** Materializované dokumenty providera po vyhodnocení šablon a filtraci. */
|
|
@@ -425,4 +467,4 @@ declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
|
425
467
|
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
426
468
|
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
427
469
|
|
|
428
|
-
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 DataProvider, type DataProviders, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes, type SchemaType, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|
|
470
|
+
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 DataProvider, type DataProviders, type DataStore, DataStoreActionsContext, DataStoreContext, DataStoreDocumentsContext, type DataStoreProps, DataStoreProvider, DataStoreProvidersContext, type DataStoreRef, DataStoreStableContext, DataStoreStorage, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes, type SchemaType, type SocketFilterItem, type SocketItem, type SocketServerType, type UseDataProviderResult, type UseProviderActionsResult, type Uuid, dataStoreFilterObject, doesObjectMatchFilter, doesValueMatchFilter, filterDocuments, filterDocumentsAsync, type filterItemType, getValueByRules, isUuid, recalculateObjectWithDocument, useDataProvider, useDataStore, useDataStoreActions, useDocument, useDocuments, useFilteredDocuments, useProvider, useProviderActions, useProviderDocuments, uuid };
|