@xyo-network/archivist-indexeddb 3.9.17 → 3.9.19

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.
@@ -0,0 +1,74 @@
1
+ import { Hash, Hex } from '@xylabs/hex';
2
+ import { ObjectStore } from '@xylabs/indexed-db';
3
+ import { AbstractArchivist } from '@xyo-network/archivist-abstract';
4
+ import { ArchivistModuleEventData, ArchivistNextOptions } from '@xyo-network/archivist-model';
5
+ import { Payload, Schema, WithStorageMeta } from '@xyo-network/payload-model';
6
+ import { IDBPDatabase } from 'idb';
7
+ import { IndexedDbArchivistParams } from './Params.ts';
8
+ export interface PayloadStore {
9
+ [s: string]: WithStorageMeta;
10
+ }
11
+ export declare class IndexedDbArchivist<TParams extends IndexedDbArchivistParams = IndexedDbArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData> extends AbstractArchivist<TParams, TEventData> {
12
+ static readonly configSchemas: Schema[];
13
+ static readonly defaultConfigSchema: Schema;
14
+ static readonly defaultDbName = "archivist";
15
+ static readonly defaultDbVersion = 1;
16
+ static readonly defaultStoreName = "payloads";
17
+ private static readonly dataHashIndex;
18
+ private static readonly hashIndex;
19
+ private static readonly schemaIndex;
20
+ private static readonly sequenceIndex;
21
+ static readonly hashIndexName: string;
22
+ static readonly dataHashIndexName: string;
23
+ static readonly schemaIndexName: string;
24
+ static readonly sequenceIndexName: string;
25
+ private _dbName?;
26
+ private _dbVersion?;
27
+ private _storeName?;
28
+ /**
29
+ * The database name. If not supplied via config, it defaults
30
+ * to the module name (not guaranteed to be unique) and if module
31
+ * name is not supplied, it defaults to `archivist`. This behavior
32
+ * biases towards a single, isolated DB per archivist which seems to
33
+ * make the most sense for 99% of use cases.
34
+ */
35
+ get dbName(): string;
36
+ /**
37
+ * The database version. If not supplied via config, it defaults to 1.
38
+ */
39
+ get dbVersion(): number;
40
+ get queries(): string[];
41
+ /**
42
+ * The name of the object store. If not supplied via config, it defaults
43
+ * to `payloads`.
44
+ */
45
+ get storeName(): string;
46
+ /**
47
+ * The indexes to create on the store
48
+ */
49
+ private get indexes();
50
+ protected allHandler(): Promise<WithStorageMeta<Payload>[]>;
51
+ protected clearHandler(): Promise<void>;
52
+ protected deleteHandler(hashes: Hash[]): Promise<Hash[]>;
53
+ protected getFromCursor(db: IDBPDatabase<ObjectStore>, storeName: string, order?: 'asc' | 'desc', limit?: number, cursor?: Hex, open?: boolean): Promise<WithStorageMeta[]>;
54
+ /**
55
+ * Uses an index to get a payload by the index value, but returns the value with the primary key (from the root store)
56
+ * @param db The db instance to use
57
+ * @param storeName The name of the store to use
58
+ * @param indexName The index to use
59
+ * @param key The key to get from the index
60
+ * @returns The primary key and the payload, or undefined if not found
61
+ */
62
+ protected getFromIndexWithPrimaryKey(db: IDBPDatabase<ObjectStore>, storeName: string, indexName: string, key: IDBValidKey): Promise<[number, WithStorageMeta] | undefined>;
63
+ protected getHandler(hashes: string[]): Promise<WithStorageMeta[]>;
64
+ protected insertHandler(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<Payload>[]>;
65
+ protected nextHandler(options?: ArchivistNextOptions): Promise<WithStorageMeta<Payload>[]>;
66
+ protected startHandler(): Promise<boolean>;
67
+ /**
68
+ * Executes a callback with the initialized DB and then closes the db
69
+ * @param callback The method to execute with the initialized DB
70
+ * @returns
71
+ */
72
+ private useDb;
73
+ }
74
+ //# sourceMappingURL=Archivist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Archivist.d.ts","sourceRoot":"","sources":["../../src/Archivist.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EACL,WAAW,EAGZ,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAKL,wBAAwB,EACxB,oBAAoB,EAIrB,MAAM,8BAA8B,CAAA;AAGrC,OAAO,EACL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OAAO,aASnB;IAED;;;OAGG;IACH,IAAI,SAAS,WAUZ;IAED;;OAEG;IACH,OAAO,KAAK,OAAO,GAQlB;cAEwB,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;cAOjD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAI7B,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;cA+BvD,aAAa,CAC3B,EAAE,EAAE,YAAY,CAAC,WAAW,CAAC,EAC7B,SAAS,EAAE,MAAM,EACf,KAAK,GAAE,KAAK,GAAG,MAAc,EAC7B,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,GAAG,EACZ,IAAI,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,eAAe,EAAE,CAAC;IAsC7B;;;;;;;OAOG;cACa,0BAA0B,CACxC,EAAE,EAAE,YAAY,CAAC,WAAW,CAAC,EAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;cAkBxB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;cAmCxD,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;cA6BxF,WAAW,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;cAShF,YAAY;IAQrC;;;;OAIG;YACW,KAAK;CAKpB"}
@@ -0,0 +1,20 @@
1
+ import type { ArchivistConfig } from '@xyo-network/archivist-model';
2
+ import { IndexedDbArchivistSchema } from './Schema.ts';
3
+ export type IndexedDbArchivistConfigSchema = `${IndexedDbArchivistSchema}.config`;
4
+ export declare const IndexedDbArchivistConfigSchema: IndexedDbArchivistConfigSchema;
5
+ export type IndexedDbArchivistConfig<TStoreName extends string = string> = ArchivistConfig<{
6
+ /**
7
+ * The database name
8
+ */
9
+ dbName?: string;
10
+ /**
11
+ * The version of the DB, defaults to 1
12
+ */
13
+ dbVersion?: number;
14
+ schema: IndexedDbArchivistConfigSchema;
15
+ /**
16
+ * The name of the object store
17
+ */
18
+ storeName?: TStoreName;
19
+ }>;
20
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,8BAA8B,GAAG,GAAG,wBAAwB,SAAS,CAAA;AACjF,eAAO,MAAM,8BAA8B,EAAE,8BAAqE,CAAA;AAElH,MAAM,MAAM,wBAAwB,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,IAAI,eAAe,CAAC;IACzF;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,8BAA8B,CAAA;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;CACvB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { ArchivistParams } from '@xyo-network/archivist-model';
2
+ import type { AnyConfigSchema } from '@xyo-network/module-model';
3
+ import type { IndexedDbArchivistConfig } from './Config.ts';
4
+ export type IndexedDbArchivistParams = ArchivistParams<AnyConfigSchema<IndexedDbArchivistConfig>>;
5
+ //# sourceMappingURL=Params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Params.d.ts","sourceRoot":"","sources":["../../src/Params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAE3D,MAAM,MAAM,wBAAwB,GAAG,eAAe,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const IndexedDbArchivistSchema: "network.xyo.archivist.indexeddb";
2
+ export type IndexedDbArchivistSchema = typeof IndexedDbArchivistSchema;
3
+ //# sourceMappingURL=Schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,EAAG,iCAA0C,CAAA;AAClF,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAA"}
@@ -1,60 +1,5 @@
1
- import { Hash, Hex } from '@xylabs/hex';
2
- import { ObjectStore } from '@xylabs/indexed-db';
3
- import { AbstractArchivist } from '@xyo-network/archivist-abstract';
4
- import { ArchivistConfig, ArchivistParams, ArchivistModuleEventData, ArchivistNextOptions } from '@xyo-network/archivist-model';
5
- import { WithStorageMeta, Schema, Payload } from '@xyo-network/payload-model';
6
- import { IDBPDatabase } from 'idb';
7
- import { AnyConfigSchema } from '@xyo-network/module-model';
8
-
9
- declare const IndexedDbArchivistSchema: "network.xyo.archivist.indexeddb";
10
- type IndexedDbArchivistSchema = typeof IndexedDbArchivistSchema;
11
-
12
- type IndexedDbArchivistConfigSchema = `${IndexedDbArchivistSchema}.config`;
13
- declare const IndexedDbArchivistConfigSchema: IndexedDbArchivistConfigSchema;
14
- type IndexedDbArchivistConfig<TStoreName extends string = string> = ArchivistConfig<{
15
- dbName?: string;
16
- dbVersion?: number;
17
- schema: IndexedDbArchivistConfigSchema;
18
- storeName?: TStoreName;
19
- }>;
20
-
21
- type IndexedDbArchivistParams = ArchivistParams<AnyConfigSchema<IndexedDbArchivistConfig>>;
22
-
23
- interface PayloadStore {
24
- [s: string]: WithStorageMeta;
25
- }
26
- declare class IndexedDbArchivist<TParams extends IndexedDbArchivistParams = IndexedDbArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData> extends AbstractArchivist<TParams, TEventData> {
27
- static readonly configSchemas: Schema[];
28
- static readonly defaultConfigSchema: Schema;
29
- static readonly defaultDbName = "archivist";
30
- static readonly defaultDbVersion = 1;
31
- static readonly defaultStoreName = "payloads";
32
- private static readonly dataHashIndex;
33
- private static readonly hashIndex;
34
- private static readonly schemaIndex;
35
- private static readonly sequenceIndex;
36
- static readonly hashIndexName: string;
37
- static readonly dataHashIndexName: string;
38
- static readonly schemaIndexName: string;
39
- static readonly sequenceIndexName: string;
40
- private _dbName?;
41
- private _dbVersion?;
42
- private _storeName?;
43
- get dbName(): string;
44
- get dbVersion(): number;
45
- get queries(): string[];
46
- get storeName(): string;
47
- private get indexes();
48
- protected allHandler(): Promise<WithStorageMeta<Payload>[]>;
49
- protected clearHandler(): Promise<void>;
50
- protected deleteHandler(hashes: Hash[]): Promise<Hash[]>;
51
- protected getFromCursor(db: IDBPDatabase<ObjectStore>, storeName: string, order?: 'asc' | 'desc', limit?: number, cursor?: Hex, open?: boolean): Promise<WithStorageMeta[]>;
52
- protected getFromIndexWithPrimaryKey(db: IDBPDatabase<ObjectStore>, storeName: string, indexName: string, key: IDBValidKey): Promise<[number, WithStorageMeta] | undefined>;
53
- protected getHandler(hashes: string[]): Promise<WithStorageMeta[]>;
54
- protected insertHandler(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<Payload>[]>;
55
- protected nextHandler(options?: ArchivistNextOptions): Promise<WithStorageMeta<Payload>[]>;
56
- protected startHandler(): Promise<boolean>;
57
- private useDb;
58
- }
59
-
60
- export { IndexedDbArchivist, type IndexedDbArchivistConfig, IndexedDbArchivistConfigSchema, type IndexedDbArchivistParams, IndexedDbArchivistSchema, type PayloadStore };
1
+ export * from './Archivist.ts';
2
+ export * from './Config.ts';
3
+ export * from './Params.ts';
4
+ export * from './Schema.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/archivist-indexeddb",
3
- "version": "3.9.17",
3
+ "version": "3.9.19",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -34,26 +34,26 @@
34
34
  "@xylabs/exists": "^4.5.1",
35
35
  "@xylabs/hex": "^4.5.1",
36
36
  "@xylabs/indexed-db": "^4.5.1",
37
- "@xyo-network/archivist-abstract": "^3.9.17",
38
- "@xyo-network/archivist-model": "^3.9.17",
39
- "@xyo-network/module-model": "^3.9.17",
40
- "@xyo-network/payload-builder": "^3.9.17",
41
- "@xyo-network/payload-model": "^3.9.17",
37
+ "@xyo-network/archivist-abstract": "^3.9.19",
38
+ "@xyo-network/archivist-model": "^3.9.19",
39
+ "@xyo-network/module-model": "^3.9.19",
40
+ "@xyo-network/payload-builder": "^3.9.19",
41
+ "@xyo-network/payload-model": "^3.9.19",
42
42
  "idb": "^8.0.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@xylabs/delay": "^4.5.1",
46
46
  "@xylabs/object": "^4.5.1",
47
- "@xylabs/ts-scripts-yarn3": "^5.0.24",
48
- "@xylabs/tsconfig": "^5.0.24",
49
- "@xyo-network/account": "^3.9.17",
50
- "@xyo-network/archivist-acceptance-tests": "^3.9.17",
51
- "@xyo-network/id-payload-plugin": "^3.9.17",
52
- "@xyo-network/payload-wrapper": "^3.9.17",
47
+ "@xylabs/ts-scripts-yarn3": "^5.0.39",
48
+ "@xylabs/tsconfig": "^5.0.39",
49
+ "@xyo-network/account": "^3.9.19",
50
+ "@xyo-network/archivist-acceptance-tests": "^3.9.19",
51
+ "@xyo-network/id-payload-plugin": "^3.9.19",
52
+ "@xyo-network/payload-wrapper": "^3.9.19",
53
53
  "fake-indexeddb": "^6.0.0",
54
- "typescript": "^5.7.3",
54
+ "typescript": "^5.8.2",
55
55
  "uuid": "^11.1.0",
56
- "vitest": "^3.0.6"
56
+ "vitest": "^3.0.7"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"