@mgarlik/datastore 0.1.0 → 0.1.1
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/README.md +28 -1
- package/dist/chunk-7XDRKNJQ.js +14 -0
- package/dist/chunk-7XDRKNJQ.js.map +1 -0
- package/dist/expo-sqlite.cjs +210 -0
- package/dist/expo-sqlite.cjs.map +1 -0
- package/dist/expo-sqlite.d.cts +31 -0
- package/dist/expo-sqlite.d.ts +31 -0
- package/dist/expo-sqlite.js +166 -0
- package/dist/expo-sqlite.js.map +1 -0
- package/dist/index.cjs +142 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -74
- package/dist/index.d.ts +89 -74
- package/dist/index.js +146 -255
- package/dist/index.js.map +1 -1
- package/dist/storage-D_xv8gFb.d.cts +18 -0
- package/dist/storage-D_xv8gFb.d.ts +18 -0
- package/package.json +16 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
declare class SQLite$1 {
|
|
6
|
-
dbName: string;
|
|
7
|
-
private db;
|
|
8
|
-
constructor(name?: string);
|
|
9
|
-
private initDB;
|
|
10
|
-
private getDb;
|
|
11
|
-
private createTable;
|
|
12
|
-
private createTables;
|
|
13
|
-
/**
|
|
14
|
-
* Smazani starych logu
|
|
15
|
-
*/
|
|
16
|
-
private deleteLogs;
|
|
17
|
-
read<T>(query: string, args?: SQL.SQLiteBindParams): Promise<T[]>;
|
|
18
|
-
query<T>(query: string, args?: SQL.SQLiteBindParams): Promise<T[]>;
|
|
19
|
-
dropTable(table: string): Promise<SQL.SQLiteRunResult>;
|
|
20
|
-
emptyTable(table: string): Promise<SQL.SQLiteRunResult>;
|
|
21
|
-
getTables(): Promise<unknown[]>;
|
|
22
|
-
resetDatabase(): Promise<void>;
|
|
23
|
-
}
|
|
3
|
+
import { D as DataStoreStorage } from './storage-D_xv8gFb.cjs';
|
|
24
4
|
|
|
5
|
+
/**
|
|
6
|
+
* String identifikátor providera (např. "brands" nebo "categories").
|
|
7
|
+
*/
|
|
25
8
|
type ProviderTypes = string;
|
|
9
|
+
/**
|
|
10
|
+
* Definice zdroje popisující, odkud se mají data providera načítat.
|
|
11
|
+
*/
|
|
26
12
|
type ProviderDataSource = {
|
|
27
13
|
uri?: string;
|
|
28
14
|
crud?: {
|
|
@@ -43,6 +29,9 @@ type ProviderDataSource = {
|
|
|
43
29
|
select?: any;
|
|
44
30
|
file?: string;
|
|
45
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Definice providera používaná při runtime registraci v DataStoreProvideru.
|
|
34
|
+
*/
|
|
46
35
|
type DataProvider = {
|
|
47
36
|
id: ProviderTypes;
|
|
48
37
|
dataSource?: ProviderDataSource;
|
|
@@ -54,21 +43,30 @@ type DataProvider = {
|
|
|
54
43
|
editor?: Record<string, any>;
|
|
55
44
|
actions?: string[];
|
|
56
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Kolekce definic providerů indexovaná podle provider id.
|
|
48
|
+
*/
|
|
57
49
|
type DataProviders = Record<string, DataProvider>;
|
|
58
50
|
|
|
51
|
+
/** Kanonický UUID řetězec používaný pro dokumenty a providery. */
|
|
59
52
|
type Uuid = string;
|
|
53
|
+
/** JSON-kompatibilní hodnota používaná v payloadu, filtrech a update operacích. */
|
|
60
54
|
type JSONType = string | number | boolean | {
|
|
61
55
|
[x: string]: JSONType;
|
|
62
56
|
} | Array<JSONType>;
|
|
57
|
+
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
63
58
|
type SocketServerType = {
|
|
64
59
|
url: string;
|
|
65
60
|
params: Record<string, any>;
|
|
66
61
|
};
|
|
62
|
+
/** In-memory metadata aktivní socket místnosti. */
|
|
67
63
|
type SocketItem = {
|
|
68
64
|
listeners: number;
|
|
69
65
|
data: any[];
|
|
70
66
|
};
|
|
67
|
+
/** Podporované akce zpracovávané interní frontou dispatcheru. */
|
|
71
68
|
type DispatcherActionType = "registerProvider" | "unregisterProvider" | "updateDataStore" | "createDocument" | "updateDocument" | "updateDocuments" | "removeItem" | "deleteDocument" | "createProviderItem" | "deleteProviderItem";
|
|
69
|
+
/** Interní struktura async fronty pro serializované datastore akce. */
|
|
72
70
|
type DispatcherType = {
|
|
73
71
|
isBussy: Boolean;
|
|
74
72
|
actions: {
|
|
@@ -148,14 +146,22 @@ type ProductFiltersType = {
|
|
|
148
146
|
};
|
|
149
147
|
};
|
|
150
148
|
interface DataStoreProps {
|
|
149
|
+
/** Předdefinovaní provideři dostupní pro registraci a hooky. */
|
|
151
150
|
providers: DataProviders;
|
|
152
151
|
/** Adresa REST/CRUD serveru */
|
|
153
152
|
restServer: string;
|
|
153
|
+
/** Socket.IO server používaný pro live aktualizace. */
|
|
154
154
|
socketServer: SocketServerType;
|
|
155
|
+
/** Volitelná lokalizace pro hlavičku Accept-Language. Pokud chybí, použije se runtime locale. */
|
|
156
|
+
locale?: string;
|
|
157
|
+
/** Volitelný persistence adapter. Pokud není předán, balíček běží bez lokální persistence. */
|
|
158
|
+
storage?: DataStoreStorage | null;
|
|
155
159
|
/** false - provider nebude cist/ukladat data do persistentniho uloziste */
|
|
156
160
|
usePersistentStorage?: boolean;
|
|
161
|
+
/** React subtree obalená DataStoreProviderem. */
|
|
157
162
|
children: ReactNode;
|
|
158
163
|
}
|
|
164
|
+
/** Veřejné runtime API vystavené přes useDataStore a související hooky. */
|
|
159
165
|
interface DataStore {
|
|
160
166
|
providers: Record<string, any>;
|
|
161
167
|
documents: Record<string, any>;
|
|
@@ -184,7 +190,6 @@ interface DataStore {
|
|
|
184
190
|
unregisterProviderSockets: (sockets: string | string[]) => void;
|
|
185
191
|
}
|
|
186
192
|
|
|
187
|
-
declare const SQLite: SQLite$1;
|
|
188
193
|
type DataStoreMetaType = Pick<DataStore, "isLive" | "isSynchronizing" | "sockets" | "counterProviders" | "counterDocuments">;
|
|
189
194
|
type DataStoreActionsType = Pick<DataStore, "dispatch" | "initProvider" | "resetProvider" | "registerProvider" | "unregisterProvider" | "updateProviderListeners" | "resetDataStore" | "startSockets" | "stopSockets" | "registerProviderSockets" | "unregisterProviderSockets" | "updateDocuments" | "presetProviders">;
|
|
190
195
|
type DataStoreStableType = {
|
|
@@ -196,17 +201,17 @@ type DataStoreStableType = {
|
|
|
196
201
|
getExternalDocuments: () => Record<string, any>;
|
|
197
202
|
getExternalProviders: () => Record<string, any>;
|
|
198
203
|
};
|
|
199
|
-
/** Meta (isLive, isSynchronizing, sockets,
|
|
204
|
+
/** Meta informace (isLive, isSynchronizing, sockets, čítače). */
|
|
200
205
|
declare const DataStoreContext: React.Context<DataStoreMetaType>;
|
|
201
|
-
/**
|
|
206
|
+
/** Surová mapa dokumentů */
|
|
202
207
|
declare const DataStoreDocumentsContext: React.Context<Record<string, any>>;
|
|
203
|
-
/**
|
|
208
|
+
/** Surová mapa providerů */
|
|
204
209
|
declare const DataStoreProvidersContext: React.Context<Record<string, any>>;
|
|
205
|
-
/**
|
|
210
|
+
/** Stabilní action callbacky */
|
|
206
211
|
declare const DataStoreActionsContext: React.Context<DataStoreActionsType>;
|
|
207
|
-
/**
|
|
212
|
+
/** Stabilní datastore API pro provider-scoped subscriptions */
|
|
208
213
|
declare const DataStoreStableContext: React.Context<DataStoreStableType>;
|
|
209
|
-
/**
|
|
214
|
+
/** Vrací všechny stabilní action callbacky. Komponenty s tímto hookem se nepřerenderují při změnách dokumentů. */
|
|
210
215
|
declare const useDataStoreActions: () => DataStoreActionsType;
|
|
211
216
|
/**
|
|
212
217
|
*
|
|
@@ -214,6 +219,9 @@ declare const useDataStoreActions: () => DataStoreActionsType;
|
|
|
214
219
|
* @param resultType - "object"(default) | "array"
|
|
215
220
|
* @returns {documents, filter}
|
|
216
221
|
*/
|
|
222
|
+
/**
|
|
223
|
+
* Vyfiltruje všechny datastore dokumenty podle matcher objektu a vrátí reaktivní výsledek.
|
|
224
|
+
*/
|
|
217
225
|
declare const useFilteredDocuments: (filter: Record<string, any>) => {
|
|
218
226
|
documents: any[] | Record<string, any>;
|
|
219
227
|
setFilter: React.Dispatch<React.SetStateAction<Record<string, any>>>;
|
|
@@ -230,7 +238,6 @@ declare const useDocuments: () => {
|
|
|
230
238
|
* Vrati object of documents daneho providera. Dokumenty lze vyfiltrovat
|
|
231
239
|
*
|
|
232
240
|
* @param {*} provider
|
|
233
|
-
* @param {*} filter
|
|
234
241
|
* @returns
|
|
235
242
|
*/
|
|
236
243
|
declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
@@ -240,18 +247,44 @@ declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
|
240
247
|
}) => {
|
|
241
248
|
[key: string]: any;
|
|
242
249
|
};
|
|
250
|
+
/** Vrací surový stav providera podle provider id. */
|
|
243
251
|
declare const useProvider: (val: ProviderTypes) => any;
|
|
244
|
-
/**
|
|
252
|
+
/** Kompletní DataStore - spojuje všechny sub-contexty. Komponenty s tímto hookem se přerenderují při jakékoliv změně stavu. */
|
|
245
253
|
declare const useDataStore: () => DataStore;
|
|
246
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Kořenový provider, který propojuje DataStore contexty, REST načítání, sockety a volitelnou persistenci.
|
|
256
|
+
*/
|
|
257
|
+
declare const DataStoreProvider: ({ socketServer, restServer, usePersistentStorage, locale, storage, ...props }: DataStoreProps) => react_jsx_runtime.JSX.Element;
|
|
247
258
|
|
|
259
|
+
interface UseDataProviderResult {
|
|
260
|
+
/** Materializované dokumenty providera po vyhodnocení šablon a filtraci. */
|
|
261
|
+
documents: Array<Record<string, any>>;
|
|
262
|
+
/** Schéma providera, pokud je dostupné. */
|
|
263
|
+
schema?: Record<string, any>;
|
|
264
|
+
/** Aktualizuje data providera pomocí výchozí update varianty. */
|
|
265
|
+
update: (val: JSONType) => void;
|
|
266
|
+
/** Aktualizuje položku/položky providera s volitelnou variantou a route parametry. */
|
|
267
|
+
updateItem: (args: {
|
|
268
|
+
params?: JSONType;
|
|
269
|
+
data?: JSONType;
|
|
270
|
+
variant?: string;
|
|
271
|
+
documentId?: string;
|
|
272
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
273
|
+
/** Smaže položku/položky providera. */
|
|
274
|
+
deleteItem: (args: {
|
|
275
|
+
params?: JSONType;
|
|
276
|
+
data?: JSONType;
|
|
277
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
278
|
+
/** Vytvoří novou položku providera. */
|
|
279
|
+
createItem: (data: JSONType, callback?: () => void) => void;
|
|
280
|
+
}
|
|
248
281
|
/**
|
|
282
|
+
* Zaregistruje/zpřístupní providera a vrátí normalizované dokumenty spolu s CRUD helpery.
|
|
249
283
|
*
|
|
250
|
-
* @param id
|
|
251
|
-
* @param params
|
|
252
|
-
* @param dataFilter
|
|
253
|
-
* @param settings
|
|
254
|
-
* @returns void
|
|
284
|
+
* @param id Provider id nebo inline definice providera.
|
|
285
|
+
* @param params Parametry šablony používané při renderu URI/definice.
|
|
286
|
+
* @param dataFilter Volitelný client-side filtr dokumentů providera.
|
|
287
|
+
* @param settings Volitelný závislý dokument použitý pro přepočet dat.
|
|
255
288
|
*/
|
|
256
289
|
declare const useDataProvider: (
|
|
257
290
|
/**
|
|
@@ -276,26 +309,9 @@ dataFilter?: JSONType | null,
|
|
|
276
309
|
settings?: {
|
|
277
310
|
documentId?: string;
|
|
278
311
|
document?: JSONType;
|
|
279
|
-
}) =>
|
|
280
|
-
documents: any;
|
|
281
|
-
schema: any;
|
|
282
|
-
update: (val: JSONType) => void;
|
|
283
|
-
updateItem: ({ params, data, variant, documentId }: {
|
|
284
|
-
params?: JSONType;
|
|
285
|
-
data?: JSONType;
|
|
286
|
-
variant?: string;
|
|
287
|
-
documentId?: string;
|
|
288
|
-
}, callback?: (resp: JSONType) => void) => void;
|
|
289
|
-
deleteItem: ({ params, data }: {
|
|
290
|
-
params?: JSONType;
|
|
291
|
-
data?: JSONType;
|
|
292
|
-
}, callback?: (resp: JSONType) => void) => void;
|
|
293
|
-
createItem: (data: JSONType, callback?: () => void) => void;
|
|
294
|
-
};
|
|
312
|
+
}) => UseDataProviderResult;
|
|
295
313
|
|
|
296
|
-
/**
|
|
297
|
-
* blabla
|
|
298
|
-
*/
|
|
314
|
+
/** Vstupní parametry hooku useDocument. */
|
|
299
315
|
interface UseDocumentParams {
|
|
300
316
|
/**
|
|
301
317
|
* UUID dokumentu
|
|
@@ -316,41 +332,40 @@ interface UseDocumentParams {
|
|
|
316
332
|
allFields?: boolean;
|
|
317
333
|
}
|
|
318
334
|
interface UseDocumentResult {
|
|
319
|
-
/**
|
|
320
|
-
* Vraci neco
|
|
321
|
-
*/
|
|
335
|
+
/** Materializovaný payload dokumentu z DataStore. */
|
|
322
336
|
document: Record<string, any>;
|
|
323
337
|
}
|
|
324
338
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* Example: useDocument({documentId: "123-123123-123123-12", model: "products", fields: ["name", "image"]})
|
|
339
|
+
* Vrátí jeden dokument a volitelně spustí lazy načtení chybějících polí.
|
|
328
340
|
*
|
|
329
|
-
*
|
|
330
|
-
* @param model - nazev modelu
|
|
331
|
-
* @param provider - nazev providera
|
|
332
|
-
* @param fields - seznam polozek dokumentu ktere chceme ziskat
|
|
333
|
-
* @param allFields - kompletni dokument
|
|
334
|
-
*
|
|
335
|
-
* @returns - vraci dokument
|
|
341
|
+
* Example: useDocument({ documentId: "...", model: "products", fields: ["name", "image"] })
|
|
336
342
|
*/
|
|
337
343
|
declare const useDocument: ({ documentId, model, provider, fields, allFields }: UseDocumentParams) => UseDocumentResult;
|
|
338
344
|
|
|
339
|
-
|
|
340
|
-
|
|
345
|
+
interface UseProviderActionsResult {
|
|
346
|
+
/** Schéma providera, pokud je dostupné. */
|
|
347
|
+
schema?: Record<string, any>;
|
|
348
|
+
/** Aktualizuje data providera pomocí výchozí update varianty. */
|
|
341
349
|
update: (val: JSONType) => void;
|
|
342
|
-
|
|
350
|
+
/** Aktualizuje položku/položky providera s volitelnou route variantou a parametry. */
|
|
351
|
+
updateItem: (args: {
|
|
343
352
|
params?: JSONType;
|
|
344
353
|
data?: any;
|
|
345
354
|
variant?: string;
|
|
346
355
|
documentId?: Uuid;
|
|
347
356
|
}, callback?: (value: JSONType) => void) => void;
|
|
348
|
-
|
|
357
|
+
/** Smaže položku/položky providera. */
|
|
358
|
+
deleteItem: (args: {
|
|
349
359
|
params: JSONType;
|
|
350
360
|
data?: JSONType;
|
|
351
361
|
}, callback?: () => void) => void;
|
|
362
|
+
/** Vytvoří novou položku providera. */
|
|
352
363
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => void;
|
|
353
|
-
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Vrací action helpery pro známé provider id.
|
|
367
|
+
*/
|
|
368
|
+
declare const useProviderActions: (providerId: Uuid, data?: JSONType) => UseProviderActionsResult;
|
|
354
369
|
|
|
355
370
|
declare function recalculateObjectWithDocument(obj: any, document: any): any;
|
|
356
371
|
declare function getValueByRules(data: any, document: any, { mode, ruleId }: {
|
|
@@ -410,4 +425,4 @@ declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
|
410
425
|
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
411
426
|
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
412
427
|
|
|
413
|
-
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, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes,
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
declare class SQLite$1 {
|
|
6
|
-
dbName: string;
|
|
7
|
-
private db;
|
|
8
|
-
constructor(name?: string);
|
|
9
|
-
private initDB;
|
|
10
|
-
private getDb;
|
|
11
|
-
private createTable;
|
|
12
|
-
private createTables;
|
|
13
|
-
/**
|
|
14
|
-
* Smazani starych logu
|
|
15
|
-
*/
|
|
16
|
-
private deleteLogs;
|
|
17
|
-
read<T>(query: string, args?: SQL.SQLiteBindParams): Promise<T[]>;
|
|
18
|
-
query<T>(query: string, args?: SQL.SQLiteBindParams): Promise<T[]>;
|
|
19
|
-
dropTable(table: string): Promise<SQL.SQLiteRunResult>;
|
|
20
|
-
emptyTable(table: string): Promise<SQL.SQLiteRunResult>;
|
|
21
|
-
getTables(): Promise<unknown[]>;
|
|
22
|
-
resetDatabase(): Promise<void>;
|
|
23
|
-
}
|
|
3
|
+
import { D as DataStoreStorage } from './storage-D_xv8gFb.js';
|
|
24
4
|
|
|
5
|
+
/**
|
|
6
|
+
* String identifikátor providera (např. "brands" nebo "categories").
|
|
7
|
+
*/
|
|
25
8
|
type ProviderTypes = string;
|
|
9
|
+
/**
|
|
10
|
+
* Definice zdroje popisující, odkud se mají data providera načítat.
|
|
11
|
+
*/
|
|
26
12
|
type ProviderDataSource = {
|
|
27
13
|
uri?: string;
|
|
28
14
|
crud?: {
|
|
@@ -43,6 +29,9 @@ type ProviderDataSource = {
|
|
|
43
29
|
select?: any;
|
|
44
30
|
file?: string;
|
|
45
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Definice providera používaná při runtime registraci v DataStoreProvideru.
|
|
34
|
+
*/
|
|
46
35
|
type DataProvider = {
|
|
47
36
|
id: ProviderTypes;
|
|
48
37
|
dataSource?: ProviderDataSource;
|
|
@@ -54,21 +43,30 @@ type DataProvider = {
|
|
|
54
43
|
editor?: Record<string, any>;
|
|
55
44
|
actions?: string[];
|
|
56
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Kolekce definic providerů indexovaná podle provider id.
|
|
48
|
+
*/
|
|
57
49
|
type DataProviders = Record<string, DataProvider>;
|
|
58
50
|
|
|
51
|
+
/** Kanonický UUID řetězec používaný pro dokumenty a providery. */
|
|
59
52
|
type Uuid = string;
|
|
53
|
+
/** JSON-kompatibilní hodnota používaná v payloadu, filtrech a update operacích. */
|
|
60
54
|
type JSONType = string | number | boolean | {
|
|
61
55
|
[x: string]: JSONType;
|
|
62
56
|
} | Array<JSONType>;
|
|
57
|
+
/** Konfigurace Socket.IO serveru používaná DataStoreProviderem. */
|
|
63
58
|
type SocketServerType = {
|
|
64
59
|
url: string;
|
|
65
60
|
params: Record<string, any>;
|
|
66
61
|
};
|
|
62
|
+
/** In-memory metadata aktivní socket místnosti. */
|
|
67
63
|
type SocketItem = {
|
|
68
64
|
listeners: number;
|
|
69
65
|
data: any[];
|
|
70
66
|
};
|
|
67
|
+
/** Podporované akce zpracovávané interní frontou dispatcheru. */
|
|
71
68
|
type DispatcherActionType = "registerProvider" | "unregisterProvider" | "updateDataStore" | "createDocument" | "updateDocument" | "updateDocuments" | "removeItem" | "deleteDocument" | "createProviderItem" | "deleteProviderItem";
|
|
69
|
+
/** Interní struktura async fronty pro serializované datastore akce. */
|
|
72
70
|
type DispatcherType = {
|
|
73
71
|
isBussy: Boolean;
|
|
74
72
|
actions: {
|
|
@@ -148,14 +146,22 @@ type ProductFiltersType = {
|
|
|
148
146
|
};
|
|
149
147
|
};
|
|
150
148
|
interface DataStoreProps {
|
|
149
|
+
/** Předdefinovaní provideři dostupní pro registraci a hooky. */
|
|
151
150
|
providers: DataProviders;
|
|
152
151
|
/** Adresa REST/CRUD serveru */
|
|
153
152
|
restServer: string;
|
|
153
|
+
/** Socket.IO server používaný pro live aktualizace. */
|
|
154
154
|
socketServer: SocketServerType;
|
|
155
|
+
/** Volitelná lokalizace pro hlavičku Accept-Language. Pokud chybí, použije se runtime locale. */
|
|
156
|
+
locale?: string;
|
|
157
|
+
/** Volitelný persistence adapter. Pokud není předán, balíček běží bez lokální persistence. */
|
|
158
|
+
storage?: DataStoreStorage | null;
|
|
155
159
|
/** false - provider nebude cist/ukladat data do persistentniho uloziste */
|
|
156
160
|
usePersistentStorage?: boolean;
|
|
161
|
+
/** React subtree obalená DataStoreProviderem. */
|
|
157
162
|
children: ReactNode;
|
|
158
163
|
}
|
|
164
|
+
/** Veřejné runtime API vystavené přes useDataStore a související hooky. */
|
|
159
165
|
interface DataStore {
|
|
160
166
|
providers: Record<string, any>;
|
|
161
167
|
documents: Record<string, any>;
|
|
@@ -184,7 +190,6 @@ interface DataStore {
|
|
|
184
190
|
unregisterProviderSockets: (sockets: string | string[]) => void;
|
|
185
191
|
}
|
|
186
192
|
|
|
187
|
-
declare const SQLite: SQLite$1;
|
|
188
193
|
type DataStoreMetaType = Pick<DataStore, "isLive" | "isSynchronizing" | "sockets" | "counterProviders" | "counterDocuments">;
|
|
189
194
|
type DataStoreActionsType = Pick<DataStore, "dispatch" | "initProvider" | "resetProvider" | "registerProvider" | "unregisterProvider" | "updateProviderListeners" | "resetDataStore" | "startSockets" | "stopSockets" | "registerProviderSockets" | "unregisterProviderSockets" | "updateDocuments" | "presetProviders">;
|
|
190
195
|
type DataStoreStableType = {
|
|
@@ -196,17 +201,17 @@ type DataStoreStableType = {
|
|
|
196
201
|
getExternalDocuments: () => Record<string, any>;
|
|
197
202
|
getExternalProviders: () => Record<string, any>;
|
|
198
203
|
};
|
|
199
|
-
/** Meta (isLive, isSynchronizing, sockets,
|
|
204
|
+
/** Meta informace (isLive, isSynchronizing, sockets, čítače). */
|
|
200
205
|
declare const DataStoreContext: React.Context<DataStoreMetaType>;
|
|
201
|
-
/**
|
|
206
|
+
/** Surová mapa dokumentů */
|
|
202
207
|
declare const DataStoreDocumentsContext: React.Context<Record<string, any>>;
|
|
203
|
-
/**
|
|
208
|
+
/** Surová mapa providerů */
|
|
204
209
|
declare const DataStoreProvidersContext: React.Context<Record<string, any>>;
|
|
205
|
-
/**
|
|
210
|
+
/** Stabilní action callbacky */
|
|
206
211
|
declare const DataStoreActionsContext: React.Context<DataStoreActionsType>;
|
|
207
|
-
/**
|
|
212
|
+
/** Stabilní datastore API pro provider-scoped subscriptions */
|
|
208
213
|
declare const DataStoreStableContext: React.Context<DataStoreStableType>;
|
|
209
|
-
/**
|
|
214
|
+
/** Vrací všechny stabilní action callbacky. Komponenty s tímto hookem se nepřerenderují při změnách dokumentů. */
|
|
210
215
|
declare const useDataStoreActions: () => DataStoreActionsType;
|
|
211
216
|
/**
|
|
212
217
|
*
|
|
@@ -214,6 +219,9 @@ declare const useDataStoreActions: () => DataStoreActionsType;
|
|
|
214
219
|
* @param resultType - "object"(default) | "array"
|
|
215
220
|
* @returns {documents, filter}
|
|
216
221
|
*/
|
|
222
|
+
/**
|
|
223
|
+
* Vyfiltruje všechny datastore dokumenty podle matcher objektu a vrátí reaktivní výsledek.
|
|
224
|
+
*/
|
|
217
225
|
declare const useFilteredDocuments: (filter: Record<string, any>) => {
|
|
218
226
|
documents: any[] | Record<string, any>;
|
|
219
227
|
setFilter: React.Dispatch<React.SetStateAction<Record<string, any>>>;
|
|
@@ -230,7 +238,6 @@ declare const useDocuments: () => {
|
|
|
230
238
|
* Vrati object of documents daneho providera. Dokumenty lze vyfiltrovat
|
|
231
239
|
*
|
|
232
240
|
* @param {*} provider
|
|
233
|
-
* @param {*} filter
|
|
234
241
|
* @returns
|
|
235
242
|
*/
|
|
236
243
|
declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
@@ -240,18 +247,44 @@ declare const useProviderDocuments: (provider: ProviderTypes, settings?: {
|
|
|
240
247
|
}) => {
|
|
241
248
|
[key: string]: any;
|
|
242
249
|
};
|
|
250
|
+
/** Vrací surový stav providera podle provider id. */
|
|
243
251
|
declare const useProvider: (val: ProviderTypes) => any;
|
|
244
|
-
/**
|
|
252
|
+
/** Kompletní DataStore - spojuje všechny sub-contexty. Komponenty s tímto hookem se přerenderují při jakékoliv změně stavu. */
|
|
245
253
|
declare const useDataStore: () => DataStore;
|
|
246
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Kořenový provider, který propojuje DataStore contexty, REST načítání, sockety a volitelnou persistenci.
|
|
256
|
+
*/
|
|
257
|
+
declare const DataStoreProvider: ({ socketServer, restServer, usePersistentStorage, locale, storage, ...props }: DataStoreProps) => react_jsx_runtime.JSX.Element;
|
|
247
258
|
|
|
259
|
+
interface UseDataProviderResult {
|
|
260
|
+
/** Materializované dokumenty providera po vyhodnocení šablon a filtraci. */
|
|
261
|
+
documents: Array<Record<string, any>>;
|
|
262
|
+
/** Schéma providera, pokud je dostupné. */
|
|
263
|
+
schema?: Record<string, any>;
|
|
264
|
+
/** Aktualizuje data providera pomocí výchozí update varianty. */
|
|
265
|
+
update: (val: JSONType) => void;
|
|
266
|
+
/** Aktualizuje položku/položky providera s volitelnou variantou a route parametry. */
|
|
267
|
+
updateItem: (args: {
|
|
268
|
+
params?: JSONType;
|
|
269
|
+
data?: JSONType;
|
|
270
|
+
variant?: string;
|
|
271
|
+
documentId?: string;
|
|
272
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
273
|
+
/** Smaže položku/položky providera. */
|
|
274
|
+
deleteItem: (args: {
|
|
275
|
+
params?: JSONType;
|
|
276
|
+
data?: JSONType;
|
|
277
|
+
}, callback?: (resp: JSONType) => void) => void;
|
|
278
|
+
/** Vytvoří novou položku providera. */
|
|
279
|
+
createItem: (data: JSONType, callback?: () => void) => void;
|
|
280
|
+
}
|
|
248
281
|
/**
|
|
282
|
+
* Zaregistruje/zpřístupní providera a vrátí normalizované dokumenty spolu s CRUD helpery.
|
|
249
283
|
*
|
|
250
|
-
* @param id
|
|
251
|
-
* @param params
|
|
252
|
-
* @param dataFilter
|
|
253
|
-
* @param settings
|
|
254
|
-
* @returns void
|
|
284
|
+
* @param id Provider id nebo inline definice providera.
|
|
285
|
+
* @param params Parametry šablony používané při renderu URI/definice.
|
|
286
|
+
* @param dataFilter Volitelný client-side filtr dokumentů providera.
|
|
287
|
+
* @param settings Volitelný závislý dokument použitý pro přepočet dat.
|
|
255
288
|
*/
|
|
256
289
|
declare const useDataProvider: (
|
|
257
290
|
/**
|
|
@@ -276,26 +309,9 @@ dataFilter?: JSONType | null,
|
|
|
276
309
|
settings?: {
|
|
277
310
|
documentId?: string;
|
|
278
311
|
document?: JSONType;
|
|
279
|
-
}) =>
|
|
280
|
-
documents: any;
|
|
281
|
-
schema: any;
|
|
282
|
-
update: (val: JSONType) => void;
|
|
283
|
-
updateItem: ({ params, data, variant, documentId }: {
|
|
284
|
-
params?: JSONType;
|
|
285
|
-
data?: JSONType;
|
|
286
|
-
variant?: string;
|
|
287
|
-
documentId?: string;
|
|
288
|
-
}, callback?: (resp: JSONType) => void) => void;
|
|
289
|
-
deleteItem: ({ params, data }: {
|
|
290
|
-
params?: JSONType;
|
|
291
|
-
data?: JSONType;
|
|
292
|
-
}, callback?: (resp: JSONType) => void) => void;
|
|
293
|
-
createItem: (data: JSONType, callback?: () => void) => void;
|
|
294
|
-
};
|
|
312
|
+
}) => UseDataProviderResult;
|
|
295
313
|
|
|
296
|
-
/**
|
|
297
|
-
* blabla
|
|
298
|
-
*/
|
|
314
|
+
/** Vstupní parametry hooku useDocument. */
|
|
299
315
|
interface UseDocumentParams {
|
|
300
316
|
/**
|
|
301
317
|
* UUID dokumentu
|
|
@@ -316,41 +332,40 @@ interface UseDocumentParams {
|
|
|
316
332
|
allFields?: boolean;
|
|
317
333
|
}
|
|
318
334
|
interface UseDocumentResult {
|
|
319
|
-
/**
|
|
320
|
-
* Vraci neco
|
|
321
|
-
*/
|
|
335
|
+
/** Materializovaný payload dokumentu z DataStore. */
|
|
322
336
|
document: Record<string, any>;
|
|
323
337
|
}
|
|
324
338
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* Example: useDocument({documentId: "123-123123-123123-12", model: "products", fields: ["name", "image"]})
|
|
339
|
+
* Vrátí jeden dokument a volitelně spustí lazy načtení chybějících polí.
|
|
328
340
|
*
|
|
329
|
-
*
|
|
330
|
-
* @param model - nazev modelu
|
|
331
|
-
* @param provider - nazev providera
|
|
332
|
-
* @param fields - seznam polozek dokumentu ktere chceme ziskat
|
|
333
|
-
* @param allFields - kompletni dokument
|
|
334
|
-
*
|
|
335
|
-
* @returns - vraci dokument
|
|
341
|
+
* Example: useDocument({ documentId: "...", model: "products", fields: ["name", "image"] })
|
|
336
342
|
*/
|
|
337
343
|
declare const useDocument: ({ documentId, model, provider, fields, allFields }: UseDocumentParams) => UseDocumentResult;
|
|
338
344
|
|
|
339
|
-
|
|
340
|
-
|
|
345
|
+
interface UseProviderActionsResult {
|
|
346
|
+
/** Schéma providera, pokud je dostupné. */
|
|
347
|
+
schema?: Record<string, any>;
|
|
348
|
+
/** Aktualizuje data providera pomocí výchozí update varianty. */
|
|
341
349
|
update: (val: JSONType) => void;
|
|
342
|
-
|
|
350
|
+
/** Aktualizuje položku/položky providera s volitelnou route variantou a parametry. */
|
|
351
|
+
updateItem: (args: {
|
|
343
352
|
params?: JSONType;
|
|
344
353
|
data?: any;
|
|
345
354
|
variant?: string;
|
|
346
355
|
documentId?: Uuid;
|
|
347
356
|
}, callback?: (value: JSONType) => void) => void;
|
|
348
|
-
|
|
357
|
+
/** Smaže položku/položky providera. */
|
|
358
|
+
deleteItem: (args: {
|
|
349
359
|
params: JSONType;
|
|
350
360
|
data?: JSONType;
|
|
351
361
|
}, callback?: () => void) => void;
|
|
362
|
+
/** Vytvoří novou položku providera. */
|
|
352
363
|
createItem: (data: JSONType, callback?: (value: JSONType) => void) => void;
|
|
353
|
-
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Vrací action helpery pro známé provider id.
|
|
367
|
+
*/
|
|
368
|
+
declare const useProviderActions: (providerId: Uuid, data?: JSONType) => UseProviderActionsResult;
|
|
354
369
|
|
|
355
370
|
declare function recalculateObjectWithDocument(obj: any, document: any): any;
|
|
356
371
|
declare function getValueByRules(data: any, document: any, { mode, ruleId }: {
|
|
@@ -410,4 +425,4 @@ declare const COLOR_AXIOS = "\u001B[33m%s\u001B[0m";
|
|
|
410
425
|
declare const COLOR_APP = "\u001B[34m%s\u001B[0m";
|
|
411
426
|
declare const COLOR_DS = "\u001B[35m%s\u001B[0m";
|
|
412
427
|
|
|
413
|
-
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, type DispatcherActionType, type DispatcherType, type FilterType, type JSONType, type ProductFiltersType, type ProviderDataSource, type ProviderTypes,
|
|
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 };
|