@omnistreamai/data-core 0.1.4 → 0.3.0
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/store.test.ts +131 -2
- package/src/store.ts +17 -1
- package/src/sync-manager.ts +2 -0
- package/src/types.ts +2 -0
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @omnistreamai/data-core
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4825f5d: Support nested paths (e.g., /test1/test2) when initializing WebDAV stores. Store's adapter setters now return a Promise and automatically reinitialize when changing adapters.
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add sorting support to getList method with sortBy and sortOrder options.
|
|
14
|
+
|
|
3
15
|
## 0.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -49,6 +49,8 @@ interface QueryOptions<T = Record<string, unknown>> {
|
|
|
49
49
|
page?: number;
|
|
50
50
|
limit?: number;
|
|
51
51
|
where?: Partial<T>;
|
|
52
|
+
sortBy?: keyof T;
|
|
53
|
+
sortOrder?: 'asc' | 'desc';
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Paginated result
|
|
@@ -198,6 +200,7 @@ declare class Store<T extends Record<string, unknown>> {
|
|
|
198
200
|
private maxLocalEntries?;
|
|
199
201
|
private sortByKey?;
|
|
200
202
|
private onChange?;
|
|
203
|
+
private notThrowLocalErrorProps;
|
|
201
204
|
private notThrowLocalError;
|
|
202
205
|
private initialized;
|
|
203
206
|
constructor(storeName: string, options: StoreOptions<T>);
|
|
@@ -248,6 +251,8 @@ declare class Store<T extends Record<string, unknown>> {
|
|
|
248
251
|
* Clear store
|
|
249
252
|
*/
|
|
250
253
|
clear(): Promise<void>;
|
|
254
|
+
setLocalAdapter(adapter: LocalAdapter | null): Promise<void>;
|
|
255
|
+
setRemoteAdapter(adapter: RemoteAdapter | null): Promise<void>;
|
|
251
256
|
}
|
|
252
257
|
//#endregion
|
|
253
258
|
//#region src/sync-manager.d.ts
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AASiB,aAjBL,WAAA;EA4BK,KAAA,GAAA,OAAA;EAWA,MAAA,GAAA,QAAa;AAQ9B;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AASiB,aAjBL,WAAA;EA4BK,KAAA,GAAA,OAAA;EAWA,MAAA,GAAA,QAAa;AAQ9B;;;;AAKiB,aA5CL,QAAA;EA4CM,KAAA,GAAA,OAAA;EAOD,KAAA,GAAA,OAAA;EAUA,MAAA,GAAA,QAAW;;;;;AAGG,UAvDd,SAAA,CAuDc;EAMd,YAAA,EAAW,MAAA;EAUX,UAAA,EAAA,MAAW;EAQX,UAAA,CAAA,EAAA,MAAa;EACb,aAAY,CAAA,EAAA,MAAA;EAKb,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;AAYE,UAtFD,cAAA,CAsFC;EAAR,QAAA,EArFE,QAqFF;EAEG,KAAA,CAAA,EAtFH,SAsFG;EAAR,QAAA,CAAA,EAAA,MAAA;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EAMd;AAUjB;AAQA;EACiB,eAAY,CAAA,OAAA,EElEF,YFkEE,CAAA,EAAA,IAAA;EAKb;;;EAIX,gBAAA,CAAA,OAAA,EEnEuB,aFmEvB,CAAA,EAAA,IAAA;EAKc;;;EAKN,WAAA,CAAA,UErEW,MFqEX,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EEnED,WFmEC,CAAA,EElER,KFkEQ,CElEF,CFkEE,CAAA;EAAR,SAAA,CAAA,CAAA,EE7CM,OF6CN,CAAA,IAAA,EAAA,CAAA;;;;;AAmBe,iBEpDJ,iBAAA,CFoDI,OAAA,CAAA,EEnDT,kBFmDS,CAAA,EElDjB,WFkDiB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ interface QueryOptions<T = Record<string, unknown>> {
|
|
|
49
49
|
page?: number;
|
|
50
50
|
limit?: number;
|
|
51
51
|
where?: Partial<T>;
|
|
52
|
+
sortBy?: keyof T;
|
|
53
|
+
sortOrder?: 'asc' | 'desc';
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Paginated result
|
|
@@ -198,6 +200,7 @@ declare class Store<T extends Record<string, unknown>> {
|
|
|
198
200
|
private maxLocalEntries?;
|
|
199
201
|
private sortByKey?;
|
|
200
202
|
private onChange?;
|
|
203
|
+
private notThrowLocalErrorProps;
|
|
201
204
|
private notThrowLocalError;
|
|
202
205
|
private initialized;
|
|
203
206
|
constructor(storeName: string, options: StoreOptions<T>);
|
|
@@ -248,6 +251,8 @@ declare class Store<T extends Record<string, unknown>> {
|
|
|
248
251
|
* Clear store
|
|
249
252
|
*/
|
|
250
253
|
clear(): Promise<void>;
|
|
254
|
+
setLocalAdapter(adapter: LocalAdapter | null): Promise<void>;
|
|
255
|
+
setRemoteAdapter(adapter: RemoteAdapter | null): Promise<void>;
|
|
251
256
|
}
|
|
252
257
|
//#endregion
|
|
253
258
|
//#region src/sync-manager.d.ts
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AASiB,aAjBL,WAAA;EA4BK,KAAA,GAAA,OAAA;EAWA,MAAA,GAAA,QAAa;AAQ9B;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AASiB,aAjBL,WAAA;EA4BK,KAAA,GAAA,OAAA;EAWA,MAAA,GAAA,QAAa;AAQ9B;;;;AAKiB,aA5CL,QAAA;EA4CM,KAAA,GAAA,OAAA;EAOD,KAAA,GAAA,OAAA;EAUA,MAAA,GAAA,QAAW;;;;;AAGG,UAvDd,SAAA,CAuDc;EAMd,YAAA,EAAW,MAAA;EAUX,UAAA,EAAA,MAAW;EAQX,UAAA,CAAA,EAAA,MAAa;EACb,aAAY,CAAA,EAAA,MAAA;EAKb,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;AAYE,UAtFD,cAAA,CAsFC;EAAR,QAAA,EArFE,QAqFF;EAEG,KAAA,CAAA,EAtFH,SAsFG;EAAR,QAAA,CAAA,EAAA,MAAA;EAKoD,QAAA,CAAA,EAAA,MAAA;EAKrC,MAAA,CAAA,EAAA,MAAA;;;;;AAWN,UAlGG,aAAA,CAkGH;EAED,QAAA,EAAA,MAAA;EAAR,cAAA,CAAA,EAlGc,cAkGd;;;;;AAoBY,UAhHA,YAgHc,CAAA,IAhHG,MAgHH,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,CAAA;EACd,MAAA,CAAA,EAAY,OAAA,GAAA,QAAA;EAKb,IAAA,CAAA,EAAA,MAAA;EAEN,KAAA,CAAA,EAAA,MAAA;EAEG,KAAA,CAAA,EAtHH,OAsHG,CAtHK,CAsHL,CAAA;EAAR,MAAA,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CFoDI,OAAA,CAAA,EEnDT,kBFmDS,CAAA,EElDjB,WFkDiB"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var Store = class {
|
|
|
32
32
|
maxLocalEntries;
|
|
33
33
|
sortByKey;
|
|
34
34
|
onChange;
|
|
35
|
+
notThrowLocalErrorProps;
|
|
35
36
|
notThrowLocalError;
|
|
36
37
|
initialized = false;
|
|
37
38
|
constructor(storeName, options) {
|
|
@@ -43,7 +44,8 @@ var Store = class {
|
|
|
43
44
|
this.maxLocalEntries = options.maxLocalEntries;
|
|
44
45
|
this.sortByKey = options.sortByKey;
|
|
45
46
|
this.onChange = options.onChange;
|
|
46
|
-
this.
|
|
47
|
+
this.notThrowLocalErrorProps = options.notThrowLocalError;
|
|
48
|
+
this.notThrowLocalError = options.notThrowLocalError && !!this.remoteAdapter;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Initialize Store
|
|
@@ -243,6 +245,17 @@ var Store = class {
|
|
|
243
245
|
await Promise.all(promises);
|
|
244
246
|
this.triggerChange();
|
|
245
247
|
}
|
|
248
|
+
setLocalAdapter(adapter) {
|
|
249
|
+
this.localAdapter = adapter;
|
|
250
|
+
this.initialized = false;
|
|
251
|
+
return this.init();
|
|
252
|
+
}
|
|
253
|
+
setRemoteAdapter(adapter) {
|
|
254
|
+
this.remoteAdapter = adapter;
|
|
255
|
+
this.notThrowLocalError = this.notThrowLocalErrorProps && !!adapter;
|
|
256
|
+
this.initialized = false;
|
|
257
|
+
return this.init();
|
|
258
|
+
}
|
|
246
259
|
};
|
|
247
260
|
|
|
248
261
|
//#endregion
|
|
@@ -265,12 +278,14 @@ var SyncManager = class {
|
|
|
265
278
|
*/
|
|
266
279
|
setLocalAdapter(adapter) {
|
|
267
280
|
this.localAdapter = adapter;
|
|
281
|
+
this.stores.forEach((store) => store.setLocalAdapter(adapter));
|
|
268
282
|
}
|
|
269
283
|
/**
|
|
270
284
|
* Set remote adapter
|
|
271
285
|
*/
|
|
272
286
|
setRemoteAdapter(adapter) {
|
|
273
287
|
this.remoteAdapter = adapter;
|
|
288
|
+
this.stores.forEach((store) => store.setRemoteAdapter(adapter));
|
|
274
289
|
}
|
|
275
290
|
/**
|
|
276
291
|
* Create Store
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["promises: Promise<void | null>[]","promises: Promise<T>[]","promises: Promise<void>[]","promiseList: Promise<void>[]"],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":["/**\n * Adapter type: local or remote\n */\nexport enum AdapterType {\n Local = 'local',\n Remote = 'remote',\n}\n\n/**\n * Authentication type\n */\nexport enum AuthType {\n Token = 'token',\n Basic = 'basic',\n Bearer = 'bearer',\n}\n\n/**\n * Token authentication configuration\n */\nexport interface TokenAuth {\n access_token: string;\n token_type: string;\n expires_in?: number;\n refresh_token?: string;\n [key: string]: unknown;\n}\n\n/**\n * Authentication configuration\n */\nexport interface Authentication {\n authType: AuthType;\n token?: TokenAuth;\n username?: string;\n password?: string;\n bearer?: string;\n}\n\n/**\n * Service configuration (for remote adapters)\n */\nexport interface ServiceConfig {\n endpoint: string;\n authentication?: Authentication;\n}\n\n/**\n * Query options\n */\nexport interface QueryOptions<T = Record<string, unknown>> {\n source?: 'local' | 'remote';\n page?: number;\n limit?: number;\n where?: Partial<T>;\n}\n\n/**\n * Paginated result\n */\nexport interface PaginatedResult<T> {\n data: T[];\n totalCount: number;\n page: number;\n limit: number;\n}\n\n/**\n * Query function and initial data (for React Query, etc.)\n */\nexport interface QueryResult<T> {\n queryKey: unknown[];\n queryFn: () => Promise<T>;\n getInitialData: () => Promise<T>;\n}\n\n/**\n * Store configuration\n */\nexport interface StoreConfig {\n indexes?: string[];\n idKey?: string;\n maxLocalEntries?: number;\n onChange?: () => void;\n}\n\n/**\n * Base adapter interface\n */\nexport interface BaseAdapter {\n readonly type: AdapterType;\n readonly name: string;\n}\n\n/**\n * Local adapter interface\n */\nexport interface LocalAdapter extends BaseAdapter {\n readonly type: AdapterType.Local;\n \n /**\n * Add data\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<T[]>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n}\n\n/**\n * Remote adapter interface\n */\nexport interface RemoteAdapter extends BaseAdapter {\n readonly type: AdapterType.Remote;\n \n /**\n * 添加数据\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<PaginatedResult<T>>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store (create if not exists)\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n \n /**\n * Set service configuration\n */\n setService(service: ServiceConfig): void;\n}\n\n/**\n * Adapter union type\n */\nexport type Adapter = LocalAdapter | RemoteAdapter;\n\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type QueryOptions,\n type QueryResult,\n} from \"./types.js\";\n\n/**\n * Store configuration\n */\nexport interface StoreOptions<_T extends Record<string, unknown>> {\n localAdapter: LocalAdapter | null;\n remoteAdapter: RemoteAdapter | null;\n idKey: keyof _T;\n indexes?: Array<keyof _T>;\n /**\n * Maximum number of local storage entries\n * When local storage entries exceed this limit, oldest entries will be automatically deleted\n * Can be used with sortByKey parameter to specify sorting field for deletion order\n * If not set, no limit on local storage entries\n */\n maxLocalEntries?: number;\n /**\n * Field name for sorting when maxLocalEntries is in effect\n * If this field is specified, entries will be sorted by this field's value before deleting oldest entries\n * If not specified, entries will be deleted in default array order (usually insertion order)\n * Supports number and string type field values\n */\n sortByKey?: keyof _T;\n onChange?: () => void;\n notThrowLocalError: boolean;\n}\n\n/**\n * Store class\n */\nexport class Store<T extends Record<string, unknown>> {\n private storeName: string;\n private localAdapter: LocalAdapter | null;\n private remoteAdapter: RemoteAdapter | null;\n private idKey: string;\n private indexes?: string[];\n private maxLocalEntries?: number;\n private sortByKey?: string;\n private onChange?: () => void;\n private notThrowLocalError: boolean;\n private initialized = false;\n\n constructor(storeName: string, options: StoreOptions<T>) {\n this.storeName = storeName;\n this.localAdapter = options.localAdapter;\n this.remoteAdapter = options.remoteAdapter;\n this.idKey = options.idKey as string;\n this.indexes = options.indexes as string[];\n this.maxLocalEntries = options.maxLocalEntries;\n this.sortByKey = options.sortByKey as string;\n this.onChange = options.onChange;\n this.notThrowLocalError = options.notThrowLocalError;\n }\n\n /**\n * Initialize Store\n */\n async init(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.executeRemote(() =>\n this.remoteAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n await Promise.all(promises);\n this.initialized = true;\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.init();\n }\n }\n\n private triggerChange(): void {\n if (this.onChange) {\n this.onChange();\n }\n }\n\n private async executeLocal<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult | null> {\n if (!this.localAdapter) {\n return null;\n }\n\n try {\n return await operation();\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Local adapter error:\", error);\n return null;\n }\n throw error;\n }\n }\n\n private async executeRemote<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult> {\n return await operation();\n }\n\n /**\n * Enforce maximum local storage entries limit\n */\n private async enforceMaxLocalEntries(): Promise<void> {\n if (!this.localAdapter || !this.maxLocalEntries) {\n return;\n }\n\n try {\n let currentEntries = await this.localAdapter.getList<T>(\n this.storeName,\n {},\n this.idKey,\n );\n\n if (currentEntries.length > this.maxLocalEntries) {\n // If sorting field is specified, sort by that field\n if (this.sortByKey) {\n currentEntries = this.sortEntries(currentEntries, this.sortByKey);\n }\n\n // Calculate number of entries to delete\n const entriesToDelete = currentEntries.length - this.maxLocalEntries;\n\n // Delete oldest entries (first element after sorting is the oldest)\n for (let i = 0; i < entriesToDelete; i++) {\n const entryToDelete = currentEntries[i];\n if (entryToDelete) {\n const id = String(entryToDelete[this.idKey]);\n await this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n );\n }\n }\n }\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Failed to enforce max local entries:\", error);\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Sort entries by specified field\n * @param entries Array of entries to sort\n * @param key Sorting field name\n * @returns Sorted array of entries\n */\n private sortEntries(entries: T[], key: string): T[] {\n return [...entries].sort((a, b) => {\n const aValue = a[key];\n const bValue = b[key];\n\n // Handle undefined or null values\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1; // null/undefined at the end\n if (bValue == null) return -1; // null/undefined at the end\n\n // Number type sorting\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return aValue - bValue;\n }\n\n // String type sorting\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return aValue.localeCompare(bValue);\n }\n\n // Date type sorting (if string format date)\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n const aDate = new Date(aValue);\n const bDate = new Date(bValue);\n if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) {\n return aDate.getTime() - bDate.getTime();\n }\n }\n\n // Convert other types to string for comparison\n return String(aValue).localeCompare(String(bValue));\n });\n }\n\n /**\n * Add data\n */\n async add(data: T): Promise<T> {\n await this.ensureInitialized();\n\n // Write to both local and remote simultaneously\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.add(this.storeName, data, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n return data;\n }\n\n /**\n * Update data\n */\n async update(id: string, data: Partial<T>): Promise<T> {\n await this.ensureInitialized();\n\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.update<T>(this.storeName, id, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.remoteAdapter.update<T>(this.storeName, id, data, this.idKey),\n );\n }\n\n const results = await Promise.all(promises);\n this.triggerChange();\n // Return first non-null result\n const firstResult = results.find(\n (result) => result !== null && result !== undefined,\n );\n return firstResult as T;\n }\n\n /**\n * Delete data\n */\n async delete(id: string): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.delete(this.storeName, id, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n /**\n * Get data by ID\n */\n async getData(id: string): Promise<T | null> {\n await this.ensureInitialized();\n\n // Prioritize getting from local\n if (this.localAdapter) {\n try {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.getData(this.storeName, id, this.idKey),\n );\n if (localResult) {\n return localResult as T;\n }\n } catch (error) {\n if (!this.notThrowLocalError) {\n throw error;\n }\n }\n }\n\n // Get from remote\n if (this.remoteAdapter) {\n return await this.remoteAdapter.getData(this.storeName, id, this.idKey);\n }\n\n return null;\n }\n\n /**\n * Get list data\n */\n async getList(options: QueryOptions<T> = {}): Promise<T[]> {\n await this.ensureInitialized();\n\n const source = options.source;\n\n // If source is specified\n if (source === \"local\" && this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n if (source === \"remote\" && this.remoteAdapter) {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n return result.data;\n }\n\n // Default to getting from remote\n if (this.remoteAdapter) {\n try {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n\n // Cache to local\n if (this.localAdapter && result.data.length > 0) {\n await Promise.all(\n result.data.map((item) =>\n this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, item, this.idKey),\n ),\n ),\n );\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n\n return result.data;\n } catch (error) {\n // If remote fails, try to get from local\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n throw error;\n }\n }\n\n // Only local adapter\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n return [];\n }\n\n /**\n * Get query object for list data\n */\n getListQuery(options: QueryOptions<T> = {}): QueryResult<T[]> {\n const source = options.source;\n\n // Build query key\n const queryKey = [\"store\", this.storeName, source || \"default\", options];\n\n // Build query function\n const queryFn = async (): Promise<T[]> => {\n return this.getList(options);\n };\n\n // Build initial data fetch function\n const getInitialData = async (): Promise<T[]> => {\n await this.ensureInitialized();\n if (this.localAdapter) {\n try {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n } catch (error) {\n // If local fetch fails, return empty array\n return [];\n }\n }\n return [];\n };\n\n return {\n queryKey,\n queryFn,\n getInitialData,\n };\n }\n\n /**\n * Clear store\n */\n async clear(): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void>[] = [];\n\n if (this.localAdapter) {\n await this.executeLocal(() => this.localAdapter!.clear(this.storeName));\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.clear(this.storeName));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n}\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type StoreConfig,\n} from \"./types.js\";\nimport { Store } from \"./store.js\";\n\n/**\n * SyncManager configuration options\n */\nexport interface SyncManagerOptions {\n localAdapter?: LocalAdapter;\n remoteAdapter?: RemoteAdapter;\n notThrowLocalError?: boolean;\n}\n\n/**\n * Sync manager\n */\nexport class SyncManager {\n private localAdapter: LocalAdapter | null = null;\n private remoteAdapter: RemoteAdapter | null = null;\n private notThrowLocalError: boolean;\n private stores: Map<string, Store<Record<string, unknown>>> = new Map();\n\n constructor(options: SyncManagerOptions = {}) {\n this.localAdapter = options.localAdapter ?? null;\n this.remoteAdapter = options.remoteAdapter ?? null;\n this.notThrowLocalError = options.notThrowLocalError ?? false;\n }\n\n /**\n * Set local adapter\n */\n setLocalAdapter(adapter: LocalAdapter): void {\n this.localAdapter = adapter;\n }\n\n /**\n * Set remote adapter\n */\n setRemoteAdapter(adapter: RemoteAdapter): void {\n this.remoteAdapter = adapter;\n }\n\n /**\n * Create Store\n */\n createStore<T extends Record<string, unknown>>(\n storeName: string,\n config: StoreConfig = {},\n ): Store<T> {\n // If already exists, return existing store\n const existingStore = this.stores.get(storeName);\n if (existingStore) {\n return existingStore as Store<T>;\n }\n\n const store = new Store<T>(storeName, {\n localAdapter: this.localAdapter,\n remoteAdapter: this.remoteAdapter,\n idKey: config.idKey ?? \"id\",\n indexes: config.indexes,\n maxLocalEntries: config.maxLocalEntries,\n onChange: config.onChange,\n notThrowLocalError: this.notThrowLocalError,\n });\n\n this.stores.set(storeName, store as Store<Record<string, unknown>>);\n return store;\n }\n\n initStore() {\n const promiseList: Promise<void>[] = [];\n this.stores.forEach((store) => {\n promiseList.push(store.init());\n });\n return Promise.all(promiseList);\n }\n}\n\n/**\n * Create sync manager\n */\nexport function createSyncManager(\n options: SyncManagerOptions = {},\n): SyncManager {\n return new SyncManager(options);\n}\n"],"mappings":";;;;;AAGA,IAAY,sDAAL;AACL;AACA;;;;;;AAMF,IAAY,gDAAL;AACL;AACA;AACA;;;;;;;;;ACsBF,IAAa,QAAb,MAAsD;CACpD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAc;CAEtB,YAAY,WAAmB,SAA0B;AACvD,OAAK,YAAY;AACjB,OAAK,eAAe,QAAQ;AAC5B,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,QAAQ,QAAQ;AACrB,OAAK,UAAU,QAAQ;AACvB,OAAK,kBAAkB,QAAQ;AAC/B,OAAK,YAAY,QAAQ;AACzB,OAAK,WAAW,QAAQ;AACxB,OAAK,qBAAqB,QAAQ;;;;;CAMpC,MAAM,OAAsB;AAC1B,MAAI,KAAK,YACP;EAGF,MAAMA,WAAmC,EAAE;AAE3C,MAAI,KAAK,aACP,UAAS,KACP,KAAK,mBACH,K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P,UAAS,KAAK,KAAK,cAAc,MAAM,KAAK,UAAU,CAAC;AAGzD,QAAM,QAAQ,IAAI,SAAS;AAC3B,OAAK,eAAe;;;;;;;;;AC9bxB,IAAa,cAAb,MAAyB;CACvB,AAAQ,eAAoC;CAC5C,AAAQ,gBAAsC;CAC9C,AAAQ;CACR,AAAQ,yBAAsD,IAAI,KAAK;CAEvE,YAAY,UAA8B,EAAE,EAAE;AAC5C,OAAK,eAAe,QAAQ,gBAAgB;AAC5C,OAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,OAAK,qBAAqB,QAAQ,sBAAsB;;;;;CAM1D,gBAAgB,SAA6B;AAC3C,OAAK,eAAe;;;;;CAMtB,iBAAiB,SAA8B;AAC7C,OAAK,gBAAgB;;;;;CAMvB,YACE,WACA,SAAsB,EAAE,EACd;EAEV,MAAM,gBAAgB,KAAK,OAAO,IAAI,UAAU;AAChD,MAAI,cACF,QAAO;EAGT,MAAM,QAAQ,IAAI,MAAS,WAAW;GACpC,cAAc,KAAK;GACnB,eAAe,KAAK;GACpB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO;GAChB,iBAAiB,OAAO;GACxB,UAAU,OAAO;GACjB,oBAAoB,KAAK;GAC1B,CAAC;AAEF,OAAK,OAAO,IAAI,WAAW,MAAwC;AACnE,SAAO;;CAGT,YAAY;EACV,MAAMC,cAA+B,EAAE;AACvC,OAAK,OAAO,SAAS,UAAU;AAC7B,eAAY,KAAK,MAAM,MAAM,CAAC;IAC9B;AACF,SAAO,QAAQ,IAAI,YAAY;;;;;;AAOnC,SAAgB,kBACd,UAA8B,EAAE,EACnB;AACb,QAAO,IAAI,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["promises: Promise<void | null>[]","promises: Promise<T>[]","promises: Promise<void>[]","promiseList: Promise<void>[]"],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":["/**\n * Adapter type: local or remote\n */\nexport enum AdapterType {\n Local = 'local',\n Remote = 'remote',\n}\n\n/**\n * Authentication type\n */\nexport enum AuthType {\n Token = 'token',\n Basic = 'basic',\n Bearer = 'bearer',\n}\n\n/**\n * Token authentication configuration\n */\nexport interface TokenAuth {\n access_token: string;\n token_type: string;\n expires_in?: number;\n refresh_token?: string;\n [key: string]: unknown;\n}\n\n/**\n * Authentication configuration\n */\nexport interface Authentication {\n authType: AuthType;\n token?: TokenAuth;\n username?: string;\n password?: string;\n bearer?: string;\n}\n\n/**\n * Service configuration (for remote adapters)\n */\nexport interface ServiceConfig {\n endpoint: string;\n authentication?: Authentication;\n}\n\n/**\n * Query options\n */\nexport interface QueryOptions<T = Record<string, unknown>> {\n source?: 'local' | 'remote';\n page?: number;\n limit?: number;\n where?: Partial<T>;\n sortBy?: keyof T;\n sortOrder?: 'asc' | 'desc';\n}\n\n/**\n * Paginated result\n */\nexport interface PaginatedResult<T> {\n data: T[];\n totalCount: number;\n page: number;\n limit: number;\n}\n\n/**\n * Query function and initial data (for React Query, etc.)\n */\nexport interface QueryResult<T> {\n queryKey: unknown[];\n queryFn: () => Promise<T>;\n getInitialData: () => Promise<T>;\n}\n\n/**\n * Store configuration\n */\nexport interface StoreConfig {\n indexes?: string[];\n idKey?: string;\n maxLocalEntries?: number;\n onChange?: () => void;\n}\n\n/**\n * Base adapter interface\n */\nexport interface BaseAdapter {\n readonly type: AdapterType;\n readonly name: string;\n}\n\n/**\n * Local adapter interface\n */\nexport interface LocalAdapter extends BaseAdapter {\n readonly type: AdapterType.Local;\n \n /**\n * Add data\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<T[]>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n}\n\n/**\n * Remote adapter interface\n */\nexport interface RemoteAdapter extends BaseAdapter {\n readonly type: AdapterType.Remote;\n \n /**\n * 添加数据\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<PaginatedResult<T>>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store (create if not exists)\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n \n /**\n * Set service configuration\n */\n setService(service: ServiceConfig): void;\n}\n\n/**\n * Adapter union type\n */\nexport type Adapter = LocalAdapter | RemoteAdapter;\n\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type QueryOptions,\n type QueryResult,\n} from \"./types.js\";\n\n/**\n * Store configuration\n */\nexport interface StoreOptions<_T extends Record<string, unknown>> {\n localAdapter: LocalAdapter | null;\n remoteAdapter: RemoteAdapter | null;\n idKey: keyof _T;\n indexes?: Array<keyof _T>;\n /**\n * Maximum number of local storage entries\n * When local storage entries exceed this limit, oldest entries will be automatically deleted\n * Can be used with sortByKey parameter to specify sorting field for deletion order\n * If not set, no limit on local storage entries\n */\n maxLocalEntries?: number;\n /**\n * Field name for sorting when maxLocalEntries is in effect\n * If this field is specified, entries will be sorted by this field's value before deleting oldest entries\n * If not specified, entries will be deleted in default array order (usually insertion order)\n * Supports number and string type field values\n */\n sortByKey?: keyof _T;\n onChange?: () => void;\n notThrowLocalError: boolean;\n}\n\n/**\n * Store class\n */\nexport class Store<T extends Record<string, unknown>> {\n private storeName: string;\n private localAdapter: LocalAdapter | null;\n private remoteAdapter: RemoteAdapter | null;\n private idKey: string;\n private indexes?: string[];\n private maxLocalEntries?: number;\n private sortByKey?: string;\n private onChange?: () => void;\n private notThrowLocalErrorProps: boolean;\n private notThrowLocalError: boolean;\n private initialized = false;\n\n constructor(storeName: string, options: StoreOptions<T>) {\n this.storeName = storeName;\n this.localAdapter = options.localAdapter;\n this.remoteAdapter = options.remoteAdapter;\n this.idKey = options.idKey as string;\n this.indexes = options.indexes as string[];\n this.maxLocalEntries = options.maxLocalEntries;\n this.sortByKey = options.sortByKey as string;\n this.onChange = options.onChange;\n this.notThrowLocalErrorProps = options.notThrowLocalError;\n this.notThrowLocalError =\n options.notThrowLocalError && !!this.remoteAdapter;\n }\n\n /**\n * Initialize Store\n */\n async init(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.executeRemote(() =>\n this.remoteAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n await Promise.all(promises);\n this.initialized = true;\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.init();\n }\n }\n\n private triggerChange(): void {\n if (this.onChange) {\n this.onChange();\n }\n }\n\n private async executeLocal<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult | null> {\n if (!this.localAdapter) {\n return null;\n }\n\n try {\n return await operation();\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Local adapter error:\", error);\n return null;\n }\n throw error;\n }\n }\n\n private async executeRemote<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult> {\n return await operation();\n }\n\n /**\n * Enforce maximum local storage entries limit\n */\n private async enforceMaxLocalEntries(): Promise<void> {\n if (!this.localAdapter || !this.maxLocalEntries) {\n return;\n }\n\n try {\n let currentEntries = await this.localAdapter.getList<T>(\n this.storeName,\n {},\n this.idKey,\n );\n\n if (currentEntries.length > this.maxLocalEntries) {\n // If sorting field is specified, sort by that field\n if (this.sortByKey) {\n currentEntries = this.sortEntries(currentEntries, this.sortByKey);\n }\n\n // Calculate number of entries to delete\n const entriesToDelete = currentEntries.length - this.maxLocalEntries;\n\n // Delete oldest entries (first element after sorting is the oldest)\n for (let i = 0; i < entriesToDelete; i++) {\n const entryToDelete = currentEntries[i];\n if (entryToDelete) {\n const id = String(entryToDelete[this.idKey]);\n await this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n );\n }\n }\n }\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Failed to enforce max local entries:\", error);\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Sort entries by specified field\n * @param entries Array of entries to sort\n * @param key Sorting field name\n * @returns Sorted array of entries\n */\n private sortEntries(entries: T[], key: string): T[] {\n return [...entries].sort((a, b) => {\n const aValue = a[key];\n const bValue = b[key];\n\n // Handle undefined or null values\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1; // null/undefined at the end\n if (bValue == null) return -1; // null/undefined at the end\n\n // Number type sorting\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return aValue - bValue;\n }\n\n // String type sorting\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return aValue.localeCompare(bValue);\n }\n\n // Date type sorting (if string format date)\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n const aDate = new Date(aValue);\n const bDate = new Date(bValue);\n if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) {\n return aDate.getTime() - bDate.getTime();\n }\n }\n\n // Convert other types to string for comparison\n return String(aValue).localeCompare(String(bValue));\n });\n }\n\n /**\n * Add data\n */\n async add(data: T): Promise<T> {\n await this.ensureInitialized();\n\n // Write to both local and remote simultaneously\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.add(this.storeName, data, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n return data;\n }\n\n /**\n * Update data\n */\n async update(id: string, data: Partial<T>): Promise<T> {\n await this.ensureInitialized();\n\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.update<T>(this.storeName, id, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.remoteAdapter.update<T>(this.storeName, id, data, this.idKey),\n );\n }\n\n const results = await Promise.all(promises);\n this.triggerChange();\n // Return first non-null result\n const firstResult = results.find(\n (result) => result !== null && result !== undefined,\n );\n return firstResult as T;\n }\n\n /**\n * Delete data\n */\n async delete(id: string): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.delete(this.storeName, id, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n /**\n * Get data by ID\n */\n async getData(id: string): Promise<T | null> {\n await this.ensureInitialized();\n\n // Prioritize getting from local\n if (this.localAdapter) {\n try {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.getData(this.storeName, id, this.idKey),\n );\n if (localResult) {\n return localResult as T;\n }\n } catch (error) {\n if (!this.notThrowLocalError) {\n throw error;\n }\n }\n }\n\n // Get from remote\n if (this.remoteAdapter) {\n return await this.remoteAdapter.getData(this.storeName, id, this.idKey);\n }\n\n return null;\n }\n\n /**\n * Get list data\n */\n async getList(options: QueryOptions<T> = {}): Promise<T[]> {\n await this.ensureInitialized();\n\n const source = options.source;\n\n // If source is specified\n if (source === \"local\" && this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n if (source === \"remote\" && this.remoteAdapter) {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n return result.data;\n }\n\n // Default to getting from remote\n if (this.remoteAdapter) {\n try {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n\n // Cache to local\n if (this.localAdapter && result.data.length > 0) {\n await Promise.all(\n result.data.map((item) =>\n this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, item, this.idKey),\n ),\n ),\n );\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n\n return result.data;\n } catch (error) {\n // If remote fails, try to get from local\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n throw error;\n }\n }\n\n // Only local adapter\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n return [];\n }\n\n /**\n * Get query object for list data\n */\n getListQuery(options: QueryOptions<T> = {}): QueryResult<T[]> {\n const source = options.source;\n\n // Build query key\n const queryKey = [\"store\", this.storeName, source || \"default\", options];\n\n // Build query function\n const queryFn = async (): Promise<T[]> => {\n return this.getList(options);\n };\n\n // Build initial data fetch function\n const getInitialData = async (): Promise<T[]> => {\n await this.ensureInitialized();\n if (this.localAdapter) {\n try {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n } catch (error) {\n // If local fetch fails, return empty array\n return [];\n }\n }\n return [];\n };\n\n return {\n queryKey,\n queryFn,\n getInitialData,\n };\n }\n\n /**\n * Clear store\n */\n async clear(): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void>[] = [];\n\n if (this.localAdapter) {\n await this.executeLocal(() => this.localAdapter!.clear(this.storeName));\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.clear(this.storeName));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n setLocalAdapter(adapter: LocalAdapter | null) {\n this.localAdapter = adapter;\n this.initialized = false;\n return this.init();\n }\n\n setRemoteAdapter(adapter: RemoteAdapter | null) {\n this.remoteAdapter = adapter;\n this.notThrowLocalError = this.notThrowLocalErrorProps && !!adapter;\n this.initialized = false;\n return this.init();\n }\n}\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type StoreConfig,\n} from \"./types.js\";\nimport { Store } from \"./store.js\";\n\n/**\n * SyncManager configuration options\n */\nexport interface SyncManagerOptions {\n localAdapter?: LocalAdapter;\n remoteAdapter?: RemoteAdapter;\n notThrowLocalError?: boolean;\n}\n\n/**\n * Sync manager\n */\nexport class SyncManager {\n private localAdapter: LocalAdapter | null = null;\n private remoteAdapter: RemoteAdapter | null = null;\n private notThrowLocalError: boolean;\n private stores: Map<string, Store<Record<string, unknown>>> = new Map();\n\n constructor(options: SyncManagerOptions = {}) {\n this.localAdapter = options.localAdapter ?? null;\n this.remoteAdapter = options.remoteAdapter ?? null;\n this.notThrowLocalError = options.notThrowLocalError ?? false;\n }\n\n /**\n * Set local adapter\n */\n setLocalAdapter(adapter: LocalAdapter): void {\n this.localAdapter = adapter;\n this.stores.forEach((store) => store.setLocalAdapter(adapter));\n }\n\n /**\n * Set remote adapter\n */\n setRemoteAdapter(adapter: RemoteAdapter): void {\n this.remoteAdapter = adapter;\n this.stores.forEach((store) => store.setRemoteAdapter(adapter));\n }\n\n /**\n * Create Store\n */\n createStore<T extends Record<string, unknown>>(\n storeName: string,\n config: StoreConfig = {},\n ): Store<T> {\n // If already exists, return existing store\n const existingStore = this.stores.get(storeName);\n if (existingStore) {\n return existingStore as Store<T>;\n }\n\n const store = new Store<T>(storeName, {\n localAdapter: this.localAdapter,\n remoteAdapter: this.remoteAdapter,\n idKey: config.idKey ?? \"id\",\n indexes: config.indexes,\n maxLocalEntries: config.maxLocalEntries,\n onChange: config.onChange,\n notThrowLocalError: this.notThrowLocalError,\n });\n\n this.stores.set(storeName, store as Store<Record<string, unknown>>);\n return store;\n }\n\n initStore() {\n const promiseList: Promise<void>[] = [];\n this.stores.forEach((store) => {\n promiseList.push(store.init());\n });\n return Promise.all(promiseList);\n }\n}\n\n/**\n * Create sync manager\n */\nexport function createSyncManager(\n options: SyncManagerOptions = {},\n): SyncManager {\n return new SyncManager(options);\n}\n"],"mappings":";;;;;AAGA,IAAY,sDAAL;AACL;AACA;;;;;;AAMF,IAAY,gDAAL;AACL;AACA;AACA;;;;;;;;;ACsBF,IAAa,QAAb,MAAsD;CACpD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAc;CAEtB,YAAY,WAAmB,SAA0B;AACvD,OAAK,YAAY;AACjB,OAAK,eAAe,QAAQ;AAC5B,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,QAAQ,QAAQ;AACrB,OAAK,UAAU,QAAQ;AACvB,OAAK,kBAAkB,QAAQ;AAC/B,OAAK,YAAY,QAAQ;AACzB,OAAK,WAAW,QAAQ;AACxB,OAAK,0BAA0B,QAAQ;AACvC,OAAK,qBACH,QAAQ,sBAAsB,CAAC,CAAC,KAAK;;;;;CAMzC,MAAM,OAAsB;AAC1B,MAAI,KAAK,YACP;EAGF,MAAMA,WAAmC,EAAE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AAE;AACvC,OAAK,OAAO,SAAS,UAAU;AAC7B,eAAY,KAAK,MAAM,MAAM,CAAC;IAC9B;AACF,SAAO,QAAQ,IAAI,YAAY;;;;;;AAOnC,SAAgB,kBACd,UAA8B,EAAE,EACnB;AACb,QAAO,IAAI,YAAY,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ var Store = class {
|
|
|
31
31
|
maxLocalEntries;
|
|
32
32
|
sortByKey;
|
|
33
33
|
onChange;
|
|
34
|
+
notThrowLocalErrorProps;
|
|
34
35
|
notThrowLocalError;
|
|
35
36
|
initialized = false;
|
|
36
37
|
constructor(storeName, options) {
|
|
@@ -42,7 +43,8 @@ var Store = class {
|
|
|
42
43
|
this.maxLocalEntries = options.maxLocalEntries;
|
|
43
44
|
this.sortByKey = options.sortByKey;
|
|
44
45
|
this.onChange = options.onChange;
|
|
45
|
-
this.
|
|
46
|
+
this.notThrowLocalErrorProps = options.notThrowLocalError;
|
|
47
|
+
this.notThrowLocalError = options.notThrowLocalError && !!this.remoteAdapter;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
50
|
* Initialize Store
|
|
@@ -242,6 +244,17 @@ var Store = class {
|
|
|
242
244
|
await Promise.all(promises);
|
|
243
245
|
this.triggerChange();
|
|
244
246
|
}
|
|
247
|
+
setLocalAdapter(adapter) {
|
|
248
|
+
this.localAdapter = adapter;
|
|
249
|
+
this.initialized = false;
|
|
250
|
+
return this.init();
|
|
251
|
+
}
|
|
252
|
+
setRemoteAdapter(adapter) {
|
|
253
|
+
this.remoteAdapter = adapter;
|
|
254
|
+
this.notThrowLocalError = this.notThrowLocalErrorProps && !!adapter;
|
|
255
|
+
this.initialized = false;
|
|
256
|
+
return this.init();
|
|
257
|
+
}
|
|
245
258
|
};
|
|
246
259
|
|
|
247
260
|
//#endregion
|
|
@@ -264,12 +277,14 @@ var SyncManager = class {
|
|
|
264
277
|
*/
|
|
265
278
|
setLocalAdapter(adapter) {
|
|
266
279
|
this.localAdapter = adapter;
|
|
280
|
+
this.stores.forEach((store) => store.setLocalAdapter(adapter));
|
|
267
281
|
}
|
|
268
282
|
/**
|
|
269
283
|
* Set remote adapter
|
|
270
284
|
*/
|
|
271
285
|
setRemoteAdapter(adapter) {
|
|
272
286
|
this.remoteAdapter = adapter;
|
|
287
|
+
this.stores.forEach((store) => store.setRemoteAdapter(adapter));
|
|
273
288
|
}
|
|
274
289
|
/**
|
|
275
290
|
* Create Store
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["promises: Promise<void | null>[]","promises: Promise<T>[]","promises: Promise<void>[]","promiseList: Promise<void>[]"],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":["/**\n * Adapter type: local or remote\n */\nexport enum AdapterType {\n Local = 'local',\n Remote = 'remote',\n}\n\n/**\n * Authentication type\n */\nexport enum AuthType {\n Token = 'token',\n Basic = 'basic',\n Bearer = 'bearer',\n}\n\n/**\n * Token authentication configuration\n */\nexport interface TokenAuth {\n access_token: string;\n token_type: string;\n expires_in?: number;\n refresh_token?: string;\n [key: string]: unknown;\n}\n\n/**\n * Authentication configuration\n */\nexport interface Authentication {\n authType: AuthType;\n token?: TokenAuth;\n username?: string;\n password?: string;\n bearer?: string;\n}\n\n/**\n * Service configuration (for remote adapters)\n */\nexport interface ServiceConfig {\n endpoint: string;\n authentication?: Authentication;\n}\n\n/**\n * Query options\n */\nexport interface QueryOptions<T = Record<string, unknown>> {\n source?: 'local' | 'remote';\n page?: number;\n limit?: number;\n where?: Partial<T>;\n}\n\n/**\n * Paginated result\n */\nexport interface PaginatedResult<T> {\n data: T[];\n totalCount: number;\n page: number;\n limit: number;\n}\n\n/**\n * Query function and initial data (for React Query, etc.)\n */\nexport interface QueryResult<T> {\n queryKey: unknown[];\n queryFn: () => Promise<T>;\n getInitialData: () => Promise<T>;\n}\n\n/**\n * Store configuration\n */\nexport interface StoreConfig {\n indexes?: string[];\n idKey?: string;\n maxLocalEntries?: number;\n onChange?: () => void;\n}\n\n/**\n * Base adapter interface\n */\nexport interface BaseAdapter {\n readonly type: AdapterType;\n readonly name: string;\n}\n\n/**\n * Local adapter interface\n */\nexport interface LocalAdapter extends BaseAdapter {\n readonly type: AdapterType.Local;\n \n /**\n * Add data\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<T[]>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n}\n\n/**\n * Remote adapter interface\n */\nexport interface RemoteAdapter extends BaseAdapter {\n readonly type: AdapterType.Remote;\n \n /**\n * 添加数据\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<PaginatedResult<T>>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store (create if not exists)\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n \n /**\n * Set service configuration\n */\n setService(service: ServiceConfig): void;\n}\n\n/**\n * Adapter union type\n */\nexport type Adapter = LocalAdapter | RemoteAdapter;\n\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type QueryOptions,\n type QueryResult,\n} from \"./types.js\";\n\n/**\n * Store configuration\n */\nexport interface StoreOptions<_T extends Record<string, unknown>> {\n localAdapter: LocalAdapter | null;\n remoteAdapter: RemoteAdapter | null;\n idKey: keyof _T;\n indexes?: Array<keyof _T>;\n /**\n * Maximum number of local storage entries\n * When local storage entries exceed this limit, oldest entries will be automatically deleted\n * Can be used with sortByKey parameter to specify sorting field for deletion order\n * If not set, no limit on local storage entries\n */\n maxLocalEntries?: number;\n /**\n * Field name for sorting when maxLocalEntries is in effect\n * If this field is specified, entries will be sorted by this field's value before deleting oldest entries\n * If not specified, entries will be deleted in default array order (usually insertion order)\n * Supports number and string type field values\n */\n sortByKey?: keyof _T;\n onChange?: () => void;\n notThrowLocalError: boolean;\n}\n\n/**\n * Store class\n */\nexport class Store<T extends Record<string, unknown>> {\n private storeName: string;\n private localAdapter: LocalAdapter | null;\n private remoteAdapter: RemoteAdapter | null;\n private idKey: string;\n private indexes?: string[];\n private maxLocalEntries?: number;\n private sortByKey?: string;\n private onChange?: () => void;\n private notThrowLocalError: boolean;\n private initialized = false;\n\n constructor(storeName: string, options: StoreOptions<T>) {\n this.storeName = storeName;\n this.localAdapter = options.localAdapter;\n this.remoteAdapter = options.remoteAdapter;\n this.idKey = options.idKey as string;\n this.indexes = options.indexes as string[];\n this.maxLocalEntries = options.maxLocalEntries;\n this.sortByKey = options.sortByKey as string;\n this.onChange = options.onChange;\n this.notThrowLocalError = options.notThrowLocalError;\n }\n\n /**\n * Initialize Store\n */\n async init(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.executeRemote(() =>\n this.remoteAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n await Promise.all(promises);\n this.initialized = true;\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.init();\n }\n }\n\n private triggerChange(): void {\n if (this.onChange) {\n this.onChange();\n }\n }\n\n private async executeLocal<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult | null> {\n if (!this.localAdapter) {\n return null;\n }\n\n try {\n return await operation();\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Local adapter error:\", error);\n return null;\n }\n throw error;\n }\n }\n\n private async executeRemote<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult> {\n return await operation();\n }\n\n /**\n * Enforce maximum local storage entries limit\n */\n private async enforceMaxLocalEntries(): Promise<void> {\n if (!this.localAdapter || !this.maxLocalEntries) {\n return;\n }\n\n try {\n let currentEntries = await this.localAdapter.getList<T>(\n this.storeName,\n {},\n this.idKey,\n );\n\n if (currentEntries.length > this.maxLocalEntries) {\n // If sorting field is specified, sort by that field\n if (this.sortByKey) {\n currentEntries = this.sortEntries(currentEntries, this.sortByKey);\n }\n\n // Calculate number of entries to delete\n const entriesToDelete = currentEntries.length - this.maxLocalEntries;\n\n // Delete oldest entries (first element after sorting is the oldest)\n for (let i = 0; i < entriesToDelete; i++) {\n const entryToDelete = currentEntries[i];\n if (entryToDelete) {\n const id = String(entryToDelete[this.idKey]);\n await this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n );\n }\n }\n }\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Failed to enforce max local entries:\", error);\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Sort entries by specified field\n * @param entries Array of entries to sort\n * @param key Sorting field name\n * @returns Sorted array of entries\n */\n private sortEntries(entries: T[], key: string): T[] {\n return [...entries].sort((a, b) => {\n const aValue = a[key];\n const bValue = b[key];\n\n // Handle undefined or null values\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1; // null/undefined at the end\n if (bValue == null) return -1; // null/undefined at the end\n\n // Number type sorting\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return aValue - bValue;\n }\n\n // String type sorting\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return aValue.localeCompare(bValue);\n }\n\n // Date type sorting (if string format date)\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n const aDate = new Date(aValue);\n const bDate = new Date(bValue);\n if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) {\n return aDate.getTime() - bDate.getTime();\n }\n }\n\n // Convert other types to string for comparison\n return String(aValue).localeCompare(String(bValue));\n });\n }\n\n /**\n * Add data\n */\n async add(data: T): Promise<T> {\n await this.ensureInitialized();\n\n // Write to both local and remote simultaneously\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.add(this.storeName, data, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n return data;\n }\n\n /**\n * Update data\n */\n async update(id: string, data: Partial<T>): Promise<T> {\n await this.ensureInitialized();\n\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.update<T>(this.storeName, id, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.remoteAdapter.update<T>(this.storeName, id, data, this.idKey),\n );\n }\n\n const results = await Promise.all(promises);\n this.triggerChange();\n // Return first non-null result\n const firstResult = results.find(\n (result) => result !== null && result !== undefined,\n );\n return firstResult as T;\n }\n\n /**\n * Delete data\n */\n async delete(id: string): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.delete(this.storeName, id, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n /**\n * Get data by ID\n */\n async getData(id: string): Promise<T | null> {\n await this.ensureInitialized();\n\n // Prioritize getting from local\n if (this.localAdapter) {\n try {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.getData(this.storeName, id, this.idKey),\n );\n if (localResult) {\n return localResult as T;\n }\n } catch (error) {\n if (!this.notThrowLocalError) {\n throw error;\n }\n }\n }\n\n // Get from remote\n if (this.remoteAdapter) {\n return await this.remoteAdapter.getData(this.storeName, id, this.idKey);\n }\n\n return null;\n }\n\n /**\n * Get list data\n */\n async getList(options: QueryOptions<T> = {}): Promise<T[]> {\n await this.ensureInitialized();\n\n const source = options.source;\n\n // If source is specified\n if (source === \"local\" && this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n if (source === \"remote\" && this.remoteAdapter) {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n return result.data;\n }\n\n // Default to getting from remote\n if (this.remoteAdapter) {\n try {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n\n // Cache to local\n if (this.localAdapter && result.data.length > 0) {\n await Promise.all(\n result.data.map((item) =>\n this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, item, this.idKey),\n ),\n ),\n );\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n\n return result.data;\n } catch (error) {\n // If remote fails, try to get from local\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n throw error;\n }\n }\n\n // Only local adapter\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n return [];\n }\n\n /**\n * Get query object for list data\n */\n getListQuery(options: QueryOptions<T> = {}): QueryResult<T[]> {\n const source = options.source;\n\n // Build query key\n const queryKey = [\"store\", this.storeName, source || \"default\", options];\n\n // Build query function\n const queryFn = async (): Promise<T[]> => {\n return this.getList(options);\n };\n\n // Build initial data fetch function\n const getInitialData = async (): Promise<T[]> => {\n await this.ensureInitialized();\n if (this.localAdapter) {\n try {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n } catch (error) {\n // If local fetch fails, return empty array\n return [];\n }\n }\n return [];\n };\n\n return {\n queryKey,\n queryFn,\n getInitialData,\n };\n }\n\n /**\n * Clear store\n */\n async clear(): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void>[] = [];\n\n if (this.localAdapter) {\n await this.executeLocal(() => this.localAdapter!.clear(this.storeName));\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.clear(this.storeName));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n}\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type StoreConfig,\n} from \"./types.js\";\nimport { Store } from \"./store.js\";\n\n/**\n * SyncManager configuration options\n */\nexport interface SyncManagerOptions {\n localAdapter?: LocalAdapter;\n remoteAdapter?: RemoteAdapter;\n notThrowLocalError?: boolean;\n}\n\n/**\n * Sync manager\n */\nexport class SyncManager {\n private localAdapter: LocalAdapter | null = null;\n private remoteAdapter: RemoteAdapter | null = null;\n private notThrowLocalError: boolean;\n private stores: Map<string, Store<Record<string, unknown>>> = new Map();\n\n constructor(options: SyncManagerOptions = {}) {\n this.localAdapter = options.localAdapter ?? null;\n this.remoteAdapter = options.remoteAdapter ?? null;\n this.notThrowLocalError = options.notThrowLocalError ?? false;\n }\n\n /**\n * Set local adapter\n */\n setLocalAdapter(adapter: LocalAdapter): void {\n this.localAdapter = adapter;\n }\n\n /**\n * Set remote adapter\n */\n setRemoteAdapter(adapter: RemoteAdapter): void {\n this.remoteAdapter = adapter;\n }\n\n /**\n * Create Store\n */\n createStore<T extends Record<string, unknown>>(\n storeName: string,\n config: StoreConfig = {},\n ): Store<T> {\n // If already exists, return existing store\n const existingStore = this.stores.get(storeName);\n if (existingStore) {\n return existingStore as Store<T>;\n }\n\n const store = new Store<T>(storeName, {\n localAdapter: this.localAdapter,\n remoteAdapter: this.remoteAdapter,\n idKey: config.idKey ?? \"id\",\n indexes: config.indexes,\n maxLocalEntries: config.maxLocalEntries,\n onChange: config.onChange,\n notThrowLocalError: this.notThrowLocalError,\n });\n\n this.stores.set(storeName, store as Store<Record<string, unknown>>);\n return store;\n }\n\n initStore() {\n const promiseList: Promise<void>[] = [];\n this.stores.forEach((store) => {\n promiseList.push(store.init());\n });\n return Promise.all(promiseList);\n }\n}\n\n/**\n * Create sync manager\n */\nexport function createSyncManager(\n options: SyncManagerOptions = {},\n): SyncManager {\n return new SyncManager(options);\n}\n"],"mappings":";;;;AAGA,IAAY,sDAAL;AACL;AACA;;;;;;AAMF,IAAY,gDAAL;AACL;AACA;AACA;;;;;;;;;ACsBF,IAAa,QAAb,MAAsD;CACpD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAc;CAEtB,YAAY,WAAmB,SAA0B;AACvD,OAAK,YAAY;AACjB,OAAK,eAAe,QAAQ;AAC5B,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,QAAQ,QAAQ;AACrB,OAAK,UAAU,QAAQ;AACvB,OAAK,kBAAkB,QAAQ;AAC/B,OAAK,YAAY,QAAQ;AACzB,OAAK,WAAW,QAAQ;AACxB,OAAK,qBAA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]","promises: Promise<void>[]","promiseList: Promise<void>[]"],"sources":["../src/types.ts","../src/store.ts","../src/sync-manager.ts"],"sourcesContent":["/**\n * Adapter type: local or remote\n */\nexport enum AdapterType {\n Local = 'local',\n Remote = 'remote',\n}\n\n/**\n * Authentication type\n */\nexport enum AuthType {\n Token = 'token',\n Basic = 'basic',\n Bearer = 'bearer',\n}\n\n/**\n * Token authentication configuration\n */\nexport interface TokenAuth {\n access_token: string;\n token_type: string;\n expires_in?: number;\n refresh_token?: string;\n [key: string]: unknown;\n}\n\n/**\n * Authentication configuration\n */\nexport interface Authentication {\n authType: AuthType;\n token?: TokenAuth;\n username?: string;\n password?: string;\n bearer?: string;\n}\n\n/**\n * Service configuration (for remote adapters)\n */\nexport interface ServiceConfig {\n endpoint: string;\n authentication?: Authentication;\n}\n\n/**\n * Query options\n */\nexport interface QueryOptions<T = Record<string, unknown>> {\n source?: 'local' | 'remote';\n page?: number;\n limit?: number;\n where?: Partial<T>;\n sortBy?: keyof T;\n sortOrder?: 'asc' | 'desc';\n}\n\n/**\n * Paginated result\n */\nexport interface PaginatedResult<T> {\n data: T[];\n totalCount: number;\n page: number;\n limit: number;\n}\n\n/**\n * Query function and initial data (for React Query, etc.)\n */\nexport interface QueryResult<T> {\n queryKey: unknown[];\n queryFn: () => Promise<T>;\n getInitialData: () => Promise<T>;\n}\n\n/**\n * Store configuration\n */\nexport interface StoreConfig {\n indexes?: string[];\n idKey?: string;\n maxLocalEntries?: number;\n onChange?: () => void;\n}\n\n/**\n * Base adapter interface\n */\nexport interface BaseAdapter {\n readonly type: AdapterType;\n readonly name: string;\n}\n\n/**\n * Local adapter interface\n */\nexport interface LocalAdapter extends BaseAdapter {\n readonly type: AdapterType.Local;\n \n /**\n * Add data\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<T[]>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n}\n\n/**\n * Remote adapter interface\n */\nexport interface RemoteAdapter extends BaseAdapter {\n readonly type: AdapterType.Remote;\n \n /**\n * 添加数据\n */\n add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Update data\n */\n update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey?: string\n ): Promise<T>;\n \n /**\n * Delete data\n */\n delete(storeName: string, id: string, idKey?: string): Promise<void>;\n \n /**\n * Get data by ID\n */\n getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey?: string\n ): Promise<T | null>;\n \n /**\n * Get list data (with pagination support)\n */\n getList<T extends Record<string, unknown>>(\n storeName: string,\n options?: QueryOptions<T>,\n idKey?: string\n ): Promise<PaginatedResult<T>>;\n \n /**\n * Clear store\n */\n clear(storeName: string): Promise<void>;\n \n /**\n * Initialize store (create if not exists)\n */\n initStore(\n storeName: string,\n indexes?: string[],\n idKey?: string\n ): Promise<void>;\n \n /**\n * Set service configuration\n */\n setService(service: ServiceConfig): void;\n}\n\n/**\n * Adapter union type\n */\nexport type Adapter = LocalAdapter | RemoteAdapter;\n\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type QueryOptions,\n type QueryResult,\n} from \"./types.js\";\n\n/**\n * Store configuration\n */\nexport interface StoreOptions<_T extends Record<string, unknown>> {\n localAdapter: LocalAdapter | null;\n remoteAdapter: RemoteAdapter | null;\n idKey: keyof _T;\n indexes?: Array<keyof _T>;\n /**\n * Maximum number of local storage entries\n * When local storage entries exceed this limit, oldest entries will be automatically deleted\n * Can be used with sortByKey parameter to specify sorting field for deletion order\n * If not set, no limit on local storage entries\n */\n maxLocalEntries?: number;\n /**\n * Field name for sorting when maxLocalEntries is in effect\n * If this field is specified, entries will be sorted by this field's value before deleting oldest entries\n * If not specified, entries will be deleted in default array order (usually insertion order)\n * Supports number and string type field values\n */\n sortByKey?: keyof _T;\n onChange?: () => void;\n notThrowLocalError: boolean;\n}\n\n/**\n * Store class\n */\nexport class Store<T extends Record<string, unknown>> {\n private storeName: string;\n private localAdapter: LocalAdapter | null;\n private remoteAdapter: RemoteAdapter | null;\n private idKey: string;\n private indexes?: string[];\n private maxLocalEntries?: number;\n private sortByKey?: string;\n private onChange?: () => void;\n private notThrowLocalErrorProps: boolean;\n private notThrowLocalError: boolean;\n private initialized = false;\n\n constructor(storeName: string, options: StoreOptions<T>) {\n this.storeName = storeName;\n this.localAdapter = options.localAdapter;\n this.remoteAdapter = options.remoteAdapter;\n this.idKey = options.idKey as string;\n this.indexes = options.indexes as string[];\n this.maxLocalEntries = options.maxLocalEntries;\n this.sortByKey = options.sortByKey as string;\n this.onChange = options.onChange;\n this.notThrowLocalErrorProps = options.notThrowLocalError;\n this.notThrowLocalError =\n options.notThrowLocalError && !!this.remoteAdapter;\n }\n\n /**\n * Initialize Store\n */\n async init(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.executeRemote(() =>\n this.remoteAdapter!.initStore(\n this.storeName,\n this.indexes,\n this.idKey,\n ),\n ),\n );\n }\n\n await Promise.all(promises);\n this.initialized = true;\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.init();\n }\n }\n\n private triggerChange(): void {\n if (this.onChange) {\n this.onChange();\n }\n }\n\n private async executeLocal<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult | null> {\n if (!this.localAdapter) {\n return null;\n }\n\n try {\n return await operation();\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Local adapter error:\", error);\n return null;\n }\n throw error;\n }\n }\n\n private async executeRemote<TResult>(\n operation: () => Promise<TResult>,\n ): Promise<TResult> {\n return await operation();\n }\n\n /**\n * Enforce maximum local storage entries limit\n */\n private async enforceMaxLocalEntries(): Promise<void> {\n if (!this.localAdapter || !this.maxLocalEntries) {\n return;\n }\n\n try {\n let currentEntries = await this.localAdapter.getList<T>(\n this.storeName,\n {},\n this.idKey,\n );\n\n if (currentEntries.length > this.maxLocalEntries) {\n // If sorting field is specified, sort by that field\n if (this.sortByKey) {\n currentEntries = this.sortEntries(currentEntries, this.sortByKey);\n }\n\n // Calculate number of entries to delete\n const entriesToDelete = currentEntries.length - this.maxLocalEntries;\n\n // Delete oldest entries (first element after sorting is the oldest)\n for (let i = 0; i < entriesToDelete; i++) {\n const entryToDelete = currentEntries[i];\n if (entryToDelete) {\n const id = String(entryToDelete[this.idKey]);\n await this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n );\n }\n }\n }\n } catch (error) {\n if (this.notThrowLocalError) {\n console.warn(\"Failed to enforce max local entries:\", error);\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Sort entries by specified field\n * @param entries Array of entries to sort\n * @param key Sorting field name\n * @returns Sorted array of entries\n */\n private sortEntries(entries: T[], key: string): T[] {\n return [...entries].sort((a, b) => {\n const aValue = a[key];\n const bValue = b[key];\n\n // Handle undefined or null values\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1; // null/undefined at the end\n if (bValue == null) return -1; // null/undefined at the end\n\n // Number type sorting\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return aValue - bValue;\n }\n\n // String type sorting\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return aValue.localeCompare(bValue);\n }\n\n // Date type sorting (if string format date)\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n const aDate = new Date(aValue);\n const bDate = new Date(bValue);\n if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) {\n return aDate.getTime() - bDate.getTime();\n }\n }\n\n // Convert other types to string for comparison\n return String(aValue).localeCompare(String(bValue));\n });\n }\n\n /**\n * Add data\n */\n async add(data: T): Promise<T> {\n await this.ensureInitialized();\n\n // Write to both local and remote simultaneously\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.add(this.storeName, data, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n return data;\n }\n\n /**\n * Update data\n */\n async update(id: string, data: Partial<T>): Promise<T> {\n await this.ensureInitialized();\n\n const promises: Promise<T>[] = [];\n\n if (this.localAdapter) {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.update<T>(this.storeName, id, data, this.idKey),\n );\n if (localResult) {\n promises.push(Promise.resolve(localResult));\n }\n }\n\n if (this.remoteAdapter) {\n promises.push(\n this.remoteAdapter.update<T>(this.storeName, id, data, this.idKey),\n );\n }\n\n const results = await Promise.all(promises);\n this.triggerChange();\n // Return first non-null result\n const firstResult = results.find(\n (result) => result !== null && result !== undefined,\n );\n return firstResult as T;\n }\n\n /**\n * Delete data\n */\n async delete(id: string): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void | null>[] = [];\n\n if (this.localAdapter) {\n promises.push(\n this.executeLocal(() =>\n this.localAdapter!.delete(this.storeName, id, this.idKey),\n ),\n );\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.delete(this.storeName, id, this.idKey));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n /**\n * Get data by ID\n */\n async getData(id: string): Promise<T | null> {\n await this.ensureInitialized();\n\n // Prioritize getting from local\n if (this.localAdapter) {\n try {\n const localResult = await this.executeLocal(() =>\n this.localAdapter!.getData(this.storeName, id, this.idKey),\n );\n if (localResult) {\n return localResult as T;\n }\n } catch (error) {\n if (!this.notThrowLocalError) {\n throw error;\n }\n }\n }\n\n // Get from remote\n if (this.remoteAdapter) {\n return await this.remoteAdapter.getData(this.storeName, id, this.idKey);\n }\n\n return null;\n }\n\n /**\n * Get list data\n */\n async getList(options: QueryOptions<T> = {}): Promise<T[]> {\n await this.ensureInitialized();\n\n const source = options.source;\n\n // If source is specified\n if (source === \"local\" && this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n if (source === \"remote\" && this.remoteAdapter) {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n return result.data;\n }\n\n // Default to getting from remote\n if (this.remoteAdapter) {\n try {\n const result = await this.remoteAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n\n // Cache to local\n if (this.localAdapter && result.data.length > 0) {\n await Promise.all(\n result.data.map((item) =>\n this.executeLocal(() =>\n this.localAdapter!.add(this.storeName, item, this.idKey),\n ),\n ),\n );\n\n // Check local storage entries limit\n await this.enforceMaxLocalEntries();\n }\n\n return result.data;\n } catch (error) {\n // If remote fails, try to get from local\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n throw error;\n }\n }\n\n // Only local adapter\n if (this.localAdapter) {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n }\n\n return [];\n }\n\n /**\n * Get query object for list data\n */\n getListQuery(options: QueryOptions<T> = {}): QueryResult<T[]> {\n const source = options.source;\n\n // Build query key\n const queryKey = [\"store\", this.storeName, source || \"default\", options];\n\n // Build query function\n const queryFn = async (): Promise<T[]> => {\n return this.getList(options);\n };\n\n // Build initial data fetch function\n const getInitialData = async (): Promise<T[]> => {\n await this.ensureInitialized();\n if (this.localAdapter) {\n try {\n return await this.localAdapter.getList<T>(\n this.storeName,\n options,\n this.idKey,\n );\n } catch (error) {\n // If local fetch fails, return empty array\n return [];\n }\n }\n return [];\n };\n\n return {\n queryKey,\n queryFn,\n getInitialData,\n };\n }\n\n /**\n * Clear store\n */\n async clear(): Promise<void> {\n await this.ensureInitialized();\n\n const promises: Promise<void>[] = [];\n\n if (this.localAdapter) {\n await this.executeLocal(() => this.localAdapter!.clear(this.storeName));\n }\n\n if (this.remoteAdapter) {\n promises.push(this.remoteAdapter.clear(this.storeName));\n }\n\n await Promise.all(promises);\n this.triggerChange();\n }\n\n setLocalAdapter(adapter: LocalAdapter | null) {\n this.localAdapter = adapter;\n this.initialized = false;\n return this.init();\n }\n\n setRemoteAdapter(adapter: RemoteAdapter | null) {\n this.remoteAdapter = adapter;\n this.notThrowLocalError = this.notThrowLocalErrorProps && !!adapter;\n this.initialized = false;\n return this.init();\n }\n}\n","import {\n type LocalAdapter,\n type RemoteAdapter,\n type StoreConfig,\n} from \"./types.js\";\nimport { Store } from \"./store.js\";\n\n/**\n * SyncManager configuration options\n */\nexport interface SyncManagerOptions {\n localAdapter?: LocalAdapter;\n remoteAdapter?: RemoteAdapter;\n notThrowLocalError?: boolean;\n}\n\n/**\n * Sync manager\n */\nexport class SyncManager {\n private localAdapter: LocalAdapter | null = null;\n private remoteAdapter: RemoteAdapter | null = null;\n private notThrowLocalError: boolean;\n private stores: Map<string, Store<Record<string, unknown>>> = new Map();\n\n constructor(options: SyncManagerOptions = {}) {\n this.localAdapter = options.localAdapter ?? null;\n this.remoteAdapter = options.remoteAdapter ?? null;\n this.notThrowLocalError = options.notThrowLocalError ?? false;\n }\n\n /**\n * Set local adapter\n */\n setLocalAdapter(adapter: LocalAdapter): void {\n this.localAdapter = adapter;\n this.stores.forEach((store) => store.setLocalAdapter(adapter));\n }\n\n /**\n * Set remote adapter\n */\n setRemoteAdapter(adapter: RemoteAdapter): void {\n this.remoteAdapter = adapter;\n this.stores.forEach((store) => store.setRemoteAdapter(adapter));\n }\n\n /**\n * Create Store\n */\n createStore<T extends Record<string, unknown>>(\n storeName: string,\n config: StoreConfig = {},\n ): Store<T> {\n // If already exists, return existing store\n const existingStore = this.stores.get(storeName);\n if (existingStore) {\n return existingStore as Store<T>;\n }\n\n const store = new Store<T>(storeName, {\n localAdapter: this.localAdapter,\n remoteAdapter: this.remoteAdapter,\n idKey: config.idKey ?? \"id\",\n indexes: config.indexes,\n maxLocalEntries: config.maxLocalEntries,\n onChange: config.onChange,\n notThrowLocalError: this.notThrowLocalError,\n });\n\n this.stores.set(storeName, store as Store<Record<string, unknown>>);\n return store;\n }\n\n initStore() {\n const promiseList: Promise<void>[] = [];\n this.stores.forEach((store) => {\n promiseList.push(store.init());\n });\n return Promise.all(promiseList);\n }\n}\n\n/**\n * Create sync manager\n */\nexport function createSyncManager(\n options: SyncManagerOptions = {},\n): SyncManager {\n return new SyncManager(options);\n}\n"],"mappings":";;;;AAGA,IAAY,sDAAL;AACL;AACA;;;;;;AAMF,IAAY,gDAAL;AACL;AACA;AACA;;;;;;;;;ACsBF,IAAa,QAAb,MAAsD;CACpD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAc;CAEtB,YAAY,WAAmB,SAA0B;AACvD,OAAK,YAAY;AACjB,OAAK,eAAe,QAAQ;AAC5B,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,QAAQ,QAAQ;AACrB,OAAK,UAAU,QAAQ;AACvB,OAAK,kBAAkB,QAAQ;AAC/B,OAAK,YAAY,QAAQ;AACzB,OAAK,WAAW,QAAQ;AACxB,OAAK,0BAA0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;GACxB,UAAU,OAAO;GACjB,oBAAoB,KAAK;GAC1B,CAAC;AAEF,OAAK,OAAO,IAAI,WAAW,MAAwC;AACnE,SAAO;;CAGT,YAAY;EACV,MAAMC,cAA+B,EAAE;AACvC,OAAK,OAAO,SAAS,UAAU;AAC7B,eAAY,KAAK,MAAM,MAAM,CAAC;IAC9B;AACF,SAAO,QAAQ,IAAI,YAAY;;;;;;AAOnC,SAAgB,kBACd,UAA8B,EAAE,EACnB;AACb,QAAO,IAAI,YAAY,QAAQ"}
|
package/package.json
CHANGED
package/src/store.test.ts
CHANGED
|
@@ -48,10 +48,54 @@ class MockLocalAdapter implements LocalAdapter {
|
|
|
48
48
|
|
|
49
49
|
async getList<T extends Record<string, unknown>>(
|
|
50
50
|
storeName: string,
|
|
51
|
-
options?:
|
|
51
|
+
options?: QueryOptions<T>,
|
|
52
52
|
idKey?: string
|
|
53
53
|
): Promise<T[]> {
|
|
54
|
-
|
|
54
|
+
let allData = Array.from(this.data.values()) as T[];
|
|
55
|
+
|
|
56
|
+
// 应用条件筛选
|
|
57
|
+
if (options?.where) {
|
|
58
|
+
const whereKeys = Object.keys(options.where);
|
|
59
|
+
allData = allData.filter((item) => {
|
|
60
|
+
return whereKeys.every((key) => {
|
|
61
|
+
return item[key] === options.where?.[key];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 应用排序
|
|
67
|
+
if (options?.sortBy) {
|
|
68
|
+
allData = this.sortEntries(allData, String(options.sortBy), options.sortOrder);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return allData;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private sortEntries<T extends Record<string, unknown>>(
|
|
75
|
+
entries: T[],
|
|
76
|
+
key: string,
|
|
77
|
+
sortOrder: 'asc' | 'desc' = 'asc'
|
|
78
|
+
): T[] {
|
|
79
|
+
return [...entries].sort((a, b) => {
|
|
80
|
+
const aValue = a[key];
|
|
81
|
+
const bValue = b[key];
|
|
82
|
+
|
|
83
|
+
if (aValue == null && bValue == null) return 0;
|
|
84
|
+
if (aValue == null) return 1;
|
|
85
|
+
if (bValue == null) return -1;
|
|
86
|
+
|
|
87
|
+
let comparison = 0;
|
|
88
|
+
|
|
89
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
90
|
+
comparison = aValue - bValue;
|
|
91
|
+
} else if (typeof aValue === "string" && typeof bValue === "string") {
|
|
92
|
+
comparison = aValue.localeCompare(bValue);
|
|
93
|
+
} else {
|
|
94
|
+
comparison = String(aValue).localeCompare(String(bValue));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return sortOrder === 'desc' ? -comparison : comparison;
|
|
98
|
+
});
|
|
55
99
|
}
|
|
56
100
|
|
|
57
101
|
|
|
@@ -128,6 +172,11 @@ class MockRemoteAdapter implements RemoteAdapter {
|
|
|
128
172
|
});
|
|
129
173
|
}
|
|
130
174
|
|
|
175
|
+
// 应用排序
|
|
176
|
+
if (options?.sortBy) {
|
|
177
|
+
allData = this.sortEntries(allData, String(options.sortBy), options.sortOrder);
|
|
178
|
+
}
|
|
179
|
+
|
|
131
180
|
// 应用分页
|
|
132
181
|
let page = options?.page ?? 1;
|
|
133
182
|
let limit = options?.limit ?? (allData.length || 10);
|
|
@@ -143,6 +192,33 @@ class MockRemoteAdapter implements RemoteAdapter {
|
|
|
143
192
|
};
|
|
144
193
|
}
|
|
145
194
|
|
|
195
|
+
private sortEntries<T extends Record<string, unknown>>(
|
|
196
|
+
entries: T[],
|
|
197
|
+
key: string,
|
|
198
|
+
sortOrder: 'asc' | 'desc' = 'asc'
|
|
199
|
+
): T[] {
|
|
200
|
+
return [...entries].sort((a, b) => {
|
|
201
|
+
const aValue = a[key];
|
|
202
|
+
const bValue = b[key];
|
|
203
|
+
|
|
204
|
+
if (aValue == null && bValue == null) return 0;
|
|
205
|
+
if (aValue == null) return 1;
|
|
206
|
+
if (bValue == null) return -1;
|
|
207
|
+
|
|
208
|
+
let comparison = 0;
|
|
209
|
+
|
|
210
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
211
|
+
comparison = aValue - bValue;
|
|
212
|
+
} else if (typeof aValue === "string" && typeof bValue === "string") {
|
|
213
|
+
comparison = aValue.localeCompare(bValue);
|
|
214
|
+
} else {
|
|
215
|
+
comparison = String(aValue).localeCompare(String(bValue));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return sortOrder === 'desc' ? -comparison : comparison;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
146
222
|
getListQuery<T extends Record<string, unknown>>(
|
|
147
223
|
storeName: string,
|
|
148
224
|
options?: QueryOptions<T>,
|
|
@@ -302,6 +378,59 @@ describe("Store", () => {
|
|
|
302
378
|
const data = await result.queryFn();
|
|
303
379
|
expect(Array.isArray(data)).toBe(true);
|
|
304
380
|
});
|
|
381
|
+
|
|
382
|
+
it("应该支持按字段升序排序", async () => {
|
|
383
|
+
const data1 = { id: "1", username: "alice" };
|
|
384
|
+
const data2 = { id: "2", username: "bob" };
|
|
385
|
+
const data3 = { id: "3", username: "charlie" };
|
|
386
|
+
|
|
387
|
+
await store.add(data3);
|
|
388
|
+
await store.add(data1);
|
|
389
|
+
await store.add(data2);
|
|
390
|
+
|
|
391
|
+
const result = await store.getList({ sortBy: "username" as any });
|
|
392
|
+
expect(result).toHaveLength(3);
|
|
393
|
+
expect(result[0]?.username).toBe("alice");
|
|
394
|
+
expect(result[1]?.username).toBe("bob");
|
|
395
|
+
expect(result[2]?.username).toBe("charlie");
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("应该支持按字段降序排序", async () => {
|
|
399
|
+
const data1 = { id: "1", username: "alice" };
|
|
400
|
+
const data2 = { id: "2", username: "bob" };
|
|
401
|
+
const data3 = { id: "3", username: "charlie" };
|
|
402
|
+
|
|
403
|
+
await store.add(data1);
|
|
404
|
+
await store.add(data3);
|
|
405
|
+
await store.add(data2);
|
|
406
|
+
|
|
407
|
+
const result = await store.getList({
|
|
408
|
+
sortBy: "username" as any,
|
|
409
|
+
sortOrder: "desc",
|
|
410
|
+
});
|
|
411
|
+
expect(result).toHaveLength(3);
|
|
412
|
+
expect(result[0]?.username).toBe("charlie");
|
|
413
|
+
expect(result[1]?.username).toBe("bob");
|
|
414
|
+
expect(result[2]?.username).toBe("alice");
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("应该支持排序和分页的组合", async () => {
|
|
418
|
+
const data1 = { id: "1", username: "alice" };
|
|
419
|
+
const data2 = { id: "2", username: "bob" };
|
|
420
|
+
const data3 = { id: "3", username: "charlie" };
|
|
421
|
+
|
|
422
|
+
await store.add(data3);
|
|
423
|
+
await store.add(data1);
|
|
424
|
+
await store.add(data2);
|
|
425
|
+
|
|
426
|
+
const result = await store.getList({
|
|
427
|
+
sortBy: "username" as any,
|
|
428
|
+
page: 2,
|
|
429
|
+
limit: 1,
|
|
430
|
+
});
|
|
431
|
+
expect(result).toHaveLength(1);
|
|
432
|
+
expect(result[0]?.username).toBe("bob");
|
|
433
|
+
});
|
|
305
434
|
});
|
|
306
435
|
|
|
307
436
|
describe("update", () => {
|
package/src/store.ts
CHANGED
|
@@ -43,6 +43,7 @@ export class Store<T extends Record<string, unknown>> {
|
|
|
43
43
|
private maxLocalEntries?: number;
|
|
44
44
|
private sortByKey?: string;
|
|
45
45
|
private onChange?: () => void;
|
|
46
|
+
private notThrowLocalErrorProps: boolean;
|
|
46
47
|
private notThrowLocalError: boolean;
|
|
47
48
|
private initialized = false;
|
|
48
49
|
|
|
@@ -55,7 +56,9 @@ export class Store<T extends Record<string, unknown>> {
|
|
|
55
56
|
this.maxLocalEntries = options.maxLocalEntries;
|
|
56
57
|
this.sortByKey = options.sortByKey as string;
|
|
57
58
|
this.onChange = options.onChange;
|
|
58
|
-
this.
|
|
59
|
+
this.notThrowLocalErrorProps = options.notThrowLocalError;
|
|
60
|
+
this.notThrowLocalError =
|
|
61
|
+
options.notThrowLocalError && !!this.remoteAdapter;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/**
|
|
@@ -465,4 +468,17 @@ export class Store<T extends Record<string, unknown>> {
|
|
|
465
468
|
await Promise.all(promises);
|
|
466
469
|
this.triggerChange();
|
|
467
470
|
}
|
|
471
|
+
|
|
472
|
+
setLocalAdapter(adapter: LocalAdapter | null) {
|
|
473
|
+
this.localAdapter = adapter;
|
|
474
|
+
this.initialized = false;
|
|
475
|
+
return this.init();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
setRemoteAdapter(adapter: RemoteAdapter | null) {
|
|
479
|
+
this.remoteAdapter = adapter;
|
|
480
|
+
this.notThrowLocalError = this.notThrowLocalErrorProps && !!adapter;
|
|
481
|
+
this.initialized = false;
|
|
482
|
+
return this.init();
|
|
483
|
+
}
|
|
468
484
|
}
|
package/src/sync-manager.ts
CHANGED
|
@@ -34,6 +34,7 @@ export class SyncManager {
|
|
|
34
34
|
*/
|
|
35
35
|
setLocalAdapter(adapter: LocalAdapter): void {
|
|
36
36
|
this.localAdapter = adapter;
|
|
37
|
+
this.stores.forEach((store) => store.setLocalAdapter(adapter));
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -41,6 +42,7 @@ export class SyncManager {
|
|
|
41
42
|
*/
|
|
42
43
|
setRemoteAdapter(adapter: RemoteAdapter): void {
|
|
43
44
|
this.remoteAdapter = adapter;
|
|
45
|
+
this.stores.forEach((store) => store.setRemoteAdapter(adapter));
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
package/src/types.ts
CHANGED
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/types.ts","./src/store.ts","./src/sync-manager.ts","./src/index.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/disposable.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/indexable.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/iterators.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/index.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/globals.typedarray.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/buffer.buffer.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/globals.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/abortcontroller.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/domexception.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/events.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/header.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/readable.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/file.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/fetch.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/formdata.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/connector.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/client.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/errors.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/dispatcher.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/global-dispatcher.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/global-origin.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/pool-stats.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/pool.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/handlers.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/balanced-pool.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/agent.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-interceptor.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-agent.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-client.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-pool.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-errors.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/proxy-agent.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/env-http-proxy-agent.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/retry-handler.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/retry-agent.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/api.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/interceptors.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/util.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/cookies.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/patch.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/websocket.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/eventsource.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/filereader.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/diagnostics-channel.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/content-type.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/cache.d.ts","../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/index.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/fetch.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/navigator.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/storage.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/assert.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/assert/strict.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/async_hooks.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/buffer.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/child_process.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/cluster.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/console.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/constants.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/crypto.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dgram.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dns.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dns/promises.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/domain.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/events.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/fs.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/fs/promises.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/http.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/http2.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/https.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/inspector.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/inspector.generated.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/module.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/net.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/os.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/path.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/perf_hooks.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/process.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/punycode.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/querystring.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/readline.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/readline/promises.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/repl.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/sea.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/sqlite.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/promises.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/consumers.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/web.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/string_decoder.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/test.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/timers.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/timers/promises.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/tls.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/trace_events.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/tty.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/url.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/util.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/v8.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/vm.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/wasi.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/worker_threads.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/zlib.d.ts","../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/index.d.ts"],"fileIdsList":[[67,112,113,115,132,133],[67,114,115,132,133],[115,132,133],[67,115,120,132,133,150],[67,115,116,121,126,132,133,135,147,158],[67,115,116,117,126,132,133,135],[67,115,132,133],[62,63,64,67,115,132,133],[67,115,118,132,133,159],[67,115,119,120,127,132,133,136],[67,115,120,132,133,147,155],[67,115,121,123,126,132,133,135],[67,114,115,122,132,133],[67,115,123,124,132,133],[67,115,125,126,132,133],[67,114,115,126,132,133],[67,115,126,127,128,132,133,147,158],[67,115,126,127,128,132,133,142,147,150],[67,108,115,123,126,129,132,133,135,147,158],[67,115,126,127,129,130,132,133,135,147,155,158],[67,115,129,131,132,133,147,155,158],[65,66,67,68,69,70,71,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164],[67,115,126,132,133],[67,115,132,133,134,158],[67,115,123,126,132,133,135,147],[67,115,132,133,136],[67,115,132,133,137],[67,114,115,132,133,138],[67,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164],[67,115,132,133,140],[67,115,132,133,141],[67,115,126,132,133,142,143],[67,115,132,133,142,144,159,161],[67,115,127,132,133],[67,115,126,132,133,147,148,150],[67,115,132,133,149,150],[67,115,132,133,147,148],[67,115,132,133,150],[67,115,132,133,151],[67,112,115,132,133,147,152],[67,115,126,132,133,153,154],[67,115,132,133,153,154],[67,115,120,132,133,135,147,155],[67,115,132,133,156],[67,115,132,133,135,157],[67,115,129,132,133,141,158],[67,115,120,132,133,159],[67,115,132,133,147,160],[67,115,132,133,134,161],[67,115,132,133,162],[67,108,115,132,133],[67,108,115,126,128,132,133,138,147,150,158,160,161,163],[67,115,132,133,147,164],[67,80,84,115,132,133,158],[67,80,115,132,133,147,158],[67,75,115,132,133],[67,77,80,115,132,133,155,158],[67,115,132,133,135,155],[67,115,132,133,165],[67,75,115,132,133,165],[67,77,80,115,132,133,135,158],[67,72,73,76,79,115,126,132,133,147,158],[67,80,87,115,132,133],[67,72,78,115,132,133],[67,80,101,102,115,132,133],[67,76,80,115,132,133,150,158,165],[67,101,115,132,133,165],[67,74,75,115,132,133,165],[67,80,115,132,133],[67,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,102,103,104,105,106,107,115,132,133],[67,80,95,115,132,133],[67,80,87,88,115,132,133],[67,78,80,88,89,115,132,133],[67,79,115,132,133],[67,72,75,80,115,132,133],[67,80,84,88,89,115,132,133],[67,84,115,132,133],[67,78,80,83,115,132,133,158],[67,72,77,80,87,115,132,133],[67,115,132,133,147],[67,75,80,101,115,132,133,163,165],[58,59,60,67,115,132,133],[58,67,115,132,133],[58,59,67,115,132,133]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"6aeedbfc7c31cc28605f3c4497a9f88d6d80c328feb36436d29555d9d3677df3","signature":"f7d17367d6223f1f503104d81a359949eb6c851a6fbc4635a6fa0885a81ef452"},{"version":"09a58114c796ae888cb4e13b4085c90d687c1a2981eafc3ae2fd55ff72c6ad3f","signature":"777f93b909782561923664aaa29cd22f46e366fac7b4fadc5381163735f83835"},{"version":"073e318ab87d0f52e4a3baba25cf5d93b77fd3e0908561468a3037b664d18b85","signature":"d3ea7a8d5121ba8680328cc76ae163fa73572d5df70b7bc599251e7890f0b342"},{"version":"dade929da94d6eaaa0f23f7e4403cafe77ebf8aed52277e42d8a379f5f6867a6","signature":"a88ced198d2e468152da1c5d02ed45352897c2c583d24a965ffc7436eef42904"},{"version":"6c7176368037af28cb72f2392010fa1cef295d6d6744bca8cfb54985f3a18c3e","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab41ef1f2cdafb8df48be20cd969d875602483859dc194e9c97c8a576892c052","affectsGlobalScope":true,"impliedFormat":1},{"version":"437e20f2ba32abaeb7985e0afe0002de1917bc74e949ba585e49feba65da6ca1","affectsGlobalScope":true,"impliedFormat":1},{"version":"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a","impliedFormat":1},{"version":"98cffbf06d6bab333473c70a893770dbe990783904002c4f1a960447b4b53dca","affectsGlobalScope":true,"impliedFormat":1},{"version":"3af97acf03cc97de58a3a4bc91f8f616408099bc4233f6d0852e72a8ffb91ac9","affectsGlobalScope":true,"impliedFormat":1},{"version":"808069bba06b6768b62fd22429b53362e7af342da4a236ed2d2e1c89fcca3b4a","affectsGlobalScope":true,"impliedFormat":1},{"version":"1db0b7dca579049ca4193d034d835f6bfe73096c73663e5ef9a0b5779939f3d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"9798340ffb0d067d69b1ae5b32faa17ab31b82466a3fc00d8f2f2df0c8554aaa","affectsGlobalScope":true,"impliedFormat":1},{"version":"f26b11d8d8e4b8028f1c7d618b22274c892e4b0ef5b3678a8ccbad85419aef43","affectsGlobalScope":true,"impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"763fe0f42b3d79b440a9b6e51e9ba3f3f91352469c1e4b3b67bfa4ff6352f3f4","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"7f182617db458e98fc18dfb272d40aa2fff3a353c44a89b2c0ccb3937709bfb5","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"e61be3f894b41b7baa1fbd6a66893f2579bfad01d208b4ff61daef21493ef0a8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"615ba88d0128ed16bf83ef8ccbb6aff05c3ee2db1cc0f89ab50a4939bfc1943f","impliedFormat":1},{"version":"a4d551dbf8746780194d550c88f26cf937caf8d56f102969a110cfaed4b06656","impliedFormat":1},{"version":"8bd86b8e8f6a6aa6c49b71e14c4ffe1211a0e97c80f08d2c8cc98838006e4b88","impliedFormat":1},{"version":"317e63deeb21ac07f3992f5b50cdca8338f10acd4fbb7257ebf56735bf52ab00","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"2cbe0621042e2a68c7cbce5dfed3906a1862a16a7d496010636cdbdb91341c0f","affectsGlobalScope":true,"impliedFormat":1},{"version":"f9501cc13ce624c72b61f12b3963e84fad210fbdf0ffbc4590e08460a3f04eba","affectsGlobalScope":true,"impliedFormat":1},{"version":"e7721c4f69f93c91360c26a0a84ee885997d748237ef78ef665b153e622b36c1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0fa06ada475b910e2106c98c68b10483dc8811d0c14a8a8dd36efb2672485b29","impliedFormat":1},{"version":"33e5e9aba62c3193d10d1d33ae1fa75c46a1171cf76fef750777377d53b0303f","impliedFormat":1},{"version":"2b06b93fd01bcd49d1a6bd1f9b65ddcae6480b9a86e9061634d6f8e354c1468f","impliedFormat":1},{"version":"6a0cd27e5dc2cfbe039e731cf879d12b0e2dded06d1b1dedad07f7712de0d7f4","affectsGlobalScope":true,"impliedFormat":1},{"version":"13f5c844119c43e51ce777c509267f14d6aaf31eafb2c2b002ca35584cd13b29","impliedFormat":1},{"version":"e60477649d6ad21542bd2dc7e3d9ff6853d0797ba9f689ba2f6653818999c264","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"5524481e56c48ff486f42926778c0a3cce1cc85dc46683b92b1271865bcf015a","impliedFormat":1},{"version":"4c829ab315f57c5442c6667b53769975acbf92003a66aef19bce151987675bd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"b2ade7657e2db96d18315694789eff2ddd3d8aea7215b181f8a0b303277cc579","impliedFormat":1},{"version":"9855e02d837744303391e5623a531734443a5f8e6e8755e018c41d63ad797db2","impliedFormat":1},{"version":"4d631b81fa2f07a0e63a9a143d6a82c25c5f051298651a9b69176ba28930756d","impliedFormat":1},{"version":"836a356aae992ff3c28a0212e3eabcb76dd4b0cc06bcb9607aeef560661b860d","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"41670ee38943d9cbb4924e436f56fc19ee94232bc96108562de1a734af20dc2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"c906fb15bd2aabc9ed1e3f44eb6a8661199d6c320b3aa196b826121552cb3695","impliedFormat":1},{"version":"22295e8103f1d6d8ea4b5d6211e43421fe4564e34d0dd8e09e520e452d89e659","impliedFormat":1},{"version":"bb45cd435da536500f1d9692a9b49d0c570b763ccbf00473248b777f5c1f353b","impliedFormat":1},{"version":"6b4e081d55ac24fc8a4631d5dd77fe249fa25900abd7d046abb87d90e3b45645","impliedFormat":1},{"version":"a10f0e1854f3316d7ee437b79649e5a6ae3ae14ffe6322b02d4987071a95362e","impliedFormat":1},{"version":"e208f73ef6a980104304b0d2ca5f6bf1b85de6009d2c7e404028b875020fa8f2","impliedFormat":1},{"version":"d163b6bc2372b4f07260747cbc6c0a6405ab3fbcea3852305e98ac43ca59f5bc","impliedFormat":1},{"version":"e6fa9ad47c5f71ff733744a029d1dc472c618de53804eae08ffc243b936f87ff","affectsGlobalScope":true,"impliedFormat":1},{"version":"83e63d6ccf8ec004a3bb6d58b9bb0104f60e002754b1e968024b320730cc5311","impliedFormat":1},{"version":"24826ed94a78d5c64bd857570fdbd96229ad41b5cb654c08d75a9845e3ab7dde","impliedFormat":1},{"version":"8b479a130ccb62e98f11f136d3ac80f2984fdc07616516d29881f3061f2dd472","impliedFormat":1},{"version":"928af3d90454bf656a52a48679f199f64c1435247d6189d1caf4c68f2eaf921f","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac39df6dfb9e284bb0c205b15f4d9a2b260f5bab5c85bf2fb97d0cdd509c06ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"933921f0bb0ec12ef45d1062a1fc0f27635318f4d294e4d99de9a5493e618ca2","impliedFormat":1},{"version":"71a0f3ad612c123b57239a7749770017ecfe6b66411488000aba83e4546fde25","impliedFormat":1},{"version":"77fbe5eecb6fac4b6242bbf6eebfc43e98ce5ccba8fa44e0ef6a95c945ff4d98","impliedFormat":1},{"version":"4f9d8ca0c417b67b69eeb54c7ca1bedd7b56034bb9bfd27c5d4f3bc4692daca7","impliedFormat":1},{"version":"814118df420c4e38fe5ae1b9a3bafb6e9c2aa40838e528cde908381867be6466","impliedFormat":1},{"version":"a3fc63c0d7b031693f665f5494412ba4b551fe644ededccc0ab5922401079c95","impliedFormat":1},{"version":"f27524f4bef4b6519c604bdb23bf4465bddcccbf3f003abb901acbd0d7404d99","impliedFormat":1},{"version":"37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","impliedFormat":1},{"version":"45650f47bfb376c8a8ed39d4bcda5902ab899a3150029684ee4c10676d9fbaee","impliedFormat":1},{"version":"dba28a419aec76ed864ef43e5f577a5c99a010c32e5949fe4e17a4d57c58dd11","affectsGlobalScope":true,"impliedFormat":1},{"version":"18fd40412d102c5564136f29735e5d1c3b455b8a37f920da79561f1fde068208","impliedFormat":1},{"version":"c959a391a75be9789b43c8468f71e3fa06488b4d691d5729dde1416dcd38225b","impliedFormat":1},{"version":"f0be1b8078cd549d91f37c30c222c2a187ac1cf981d994fb476a1adc61387b14","affectsGlobalScope":true,"impliedFormat":1},{"version":"0aaed1d72199b01234152f7a60046bc947f1f37d78d182e9ae09c4289e06a592","impliedFormat":1},{"version":"5ebe6f4cc3b803cbfc962bae0d954f9c80e5078ca41eb3f1de41d92e7193ef37","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"5b7aa3c4c1a5d81b411e8cb302b45507fea9358d3569196b27eb1a27ae3a90ef","affectsGlobalScope":true,"impliedFormat":1},{"version":"5987a903da92c7462e0b35704ce7da94d7fdc4b89a984871c0e2b87a8aae9e69","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea08a0345023ade2b47fbff5a76d0d0ed8bff10bc9d22b83f40858a8e941501c","impliedFormat":1},{"version":"47613031a5a31510831304405af561b0ffaedb734437c595256bb61a90f9311b","impliedFormat":1},{"version":"ae062ce7d9510060c5d7e7952ae379224fb3f8f2dd74e88959878af2057c143b","impliedFormat":1},{"version":"8a1a0d0a4a06a8d278947fcb66bf684f117bf147f89b06e50662d79a53be3e9f","affectsGlobalScope":true,"impliedFormat":1},{"version":"9f663c2f91127ef7024e8ca4b3b4383ff2770e5f826696005de382282794b127","impliedFormat":1},{"version":"9f55299850d4f0921e79b6bf344b47c420ce0f507b9dcf593e532b09ea7eeea1","impliedFormat":1}],"root":[[58,61]],"options":{"composite":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[112,1],[113,1],[114,2],[67,3],[115,4],[116,5],[117,6],[62,7],[65,8],[63,7],[64,7],[118,9],[119,10],[120,11],[121,12],[122,13],[123,14],[124,14],[125,15],[126,16],[127,17],[128,18],[68,7],[66,7],[129,19],[130,20],[131,21],[165,22],[132,23],[133,7],[134,24],[135,25],[136,26],[137,27],[138,28],[139,29],[140,30],[141,31],[142,32],[143,32],[144,33],[145,7],[146,34],[147,35],[149,36],[148,37],[150,38],[151,39],[152,40],[153,41],[154,42],[155,43],[156,44],[157,45],[158,46],[159,47],[160,48],[161,49],[162,50],[69,7],[70,7],[71,7],[109,51],[110,7],[111,7],[163,52],[164,53],[56,7],[57,7],[11,7],[10,7],[2,7],[12,7],[13,7],[14,7],[15,7],[16,7],[17,7],[18,7],[19,7],[3,7],[20,7],[21,7],[4,7],[22,7],[26,7],[23,7],[24,7],[25,7],[27,7],[28,7],[29,7],[5,7],[30,7],[31,7],[32,7],[33,7],[6,7],[37,7],[34,7],[35,7],[36,7],[38,7],[7,7],[39,7],[44,7],[45,7],[40,7],[41,7],[42,7],[43,7],[8,7],[49,7],[46,7],[47,7],[48,7],[50,7],[9,7],[51,7],[52,7],[53,7],[55,7],[54,7],[1,7],[87,54],[97,55],[86,54],[107,56],[78,57],[77,58],[106,59],[100,60],[105,61],[80,62],[94,63],[79,64],[103,65],[75,66],[74,59],[104,67],[76,68],[81,69],[82,7],[85,69],[72,7],[108,70],[98,71],[89,72],[90,73],[92,74],[88,75],[91,76],[101,59],[83,77],[84,78],[93,79],[73,80],[96,71],[95,69],[99,7],[102,81],[61,82],[59,83],[60,84],[58,7]],"affectedFilesPendingEmit":[[61,51],[59,51],[60,51],[58,51]],"emitSignatures":[58,59,60,61],"version":"5.9.3"}
|