@webiny/db 6.3.0 → 6.4.0-beta.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/DbRegistry.js CHANGED
@@ -1,38 +1,32 @@
1
- export class DbRegistry {
2
- items = {};
3
- register(input) {
4
- const key = `${input.app}-${input.tags.sort().join("-")}`;
5
- if (this.items[key]) {
6
- throw new Error(`Item with app "${input.app}" and tags "${input.tags.join(", ")}" is already registered.`);
1
+ class DbRegistry {
2
+ register(input) {
3
+ const key = `${input.app}-${input.tags.sort().join("-")}`;
4
+ if (this.items[key]) throw new Error(`Item with app "${input.app}" and tags "${input.tags.join(", ")}" is already registered.`);
5
+ this.items[key] = input;
7
6
  }
8
- this.items[key] = input;
9
- }
10
- getOneItem(cb) {
11
- const item = this.getItem(cb);
12
- if (!item) {
13
- throw new Error("Item not found.");
7
+ getOneItem(cb) {
8
+ const item = this.getItem(cb);
9
+ if (!item) throw new Error("Item not found.");
10
+ return item;
14
11
  }
15
- return item;
16
- }
17
- getItem(cb) {
18
- const items = this.getItems(cb);
19
- if (items.length === 0) {
20
- return null;
21
- } else if (items.length > 1) {
22
- throw new Error("More than one item found with the provided criteria.");
12
+ getItem(cb) {
13
+ const items = this.getItems(cb);
14
+ if (0 === items.length) return null;
15
+ if (items.length > 1) throw new Error("More than one item found with the provided criteria.");
16
+ return items[0];
23
17
  }
24
- return items[0];
25
- }
26
- getItems(cb) {
27
- const results = [];
28
- for (const key in this.items) {
29
- const item = this.items[key];
30
- if (cb(item)) {
31
- results.push(item);
32
- }
18
+ getItems(cb) {
19
+ const results = [];
20
+ for(const key in this.items){
21
+ const item = this.items[key];
22
+ if (cb(item)) results.push(item);
23
+ }
24
+ return results;
25
+ }
26
+ constructor(){
27
+ this.items = {};
33
28
  }
34
- return results;
35
- }
36
29
  }
30
+ export { DbRegistry };
37
31
 
38
32
  //# sourceMappingURL=DbRegistry.js.map
package/DbRegistry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["DbRegistry","items","register","input","key","app","tags","sort","join","Error","getOneItem","cb","item","getItem","getItems","length","results","push"],"sources":["DbRegistry.ts"],"sourcesContent":["import type { IRegistry, IRegistryItem, IRegistryRegisterParams } from \"./types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport class DbRegistry implements IRegistry {\n private readonly items: GenericRecord<string, IRegistryItem> = {};\n\n public register<T = unknown>(input: IRegistryRegisterParams<T>): void {\n const key = `${input.app}-${input.tags.sort().join(\"-\")}`;\n\n if (this.items[key]) {\n throw new Error(\n `Item with app \"${input.app}\" and tags \"${input.tags.join(\n \", \"\n )}\" is already registered.`\n );\n }\n this.items[key] = input;\n }\n\n public getOneItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T> {\n const item = this.getItem(cb);\n if (!item) {\n throw new Error(\"Item not found.\");\n }\n return item;\n }\n\n public getItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T> | null {\n const items = this.getItems(cb);\n if (items.length === 0) {\n return null;\n } else if (items.length > 1) {\n throw new Error(\"More than one item found with the provided criteria.\");\n }\n return items[0];\n }\n\n public getItems<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T>[] {\n const results: IRegistryItem<T>[] = [];\n for (const key in this.items) {\n const item = this.items[key] as IRegistryItem<T>;\n if (cb(item)) {\n results.push(item);\n }\n }\n\n return results;\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,UAAU,CAAsB;EACxBC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,QAAQA,CAAcC,KAAiC,EAAQ;IAClE,MAAMC,GAAG,GAAG,GAAGD,KAAK,CAACE,GAAG,IAAIF,KAAK,CAACG,IAAI,CAACC,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,EAAE;IAEzD,IAAI,IAAI,CAACP,KAAK,CAACG,GAAG,CAAC,EAAE;MACjB,MAAM,IAAIK,KAAK,CACX,kBAAkBN,KAAK,CAACE,GAAG,eAAeF,KAAK,CAACG,IAAI,CAACE,IAAI,CACrD,IACJ,CAAC,0BACL,CAAC;IACL;IACA,IAAI,CAACP,KAAK,CAACG,GAAG,CAAC,GAAGD,KAAK;EAC3B;EAEOO,UAAUA,CAAcC,EAAuC,EAAoB;IACtF,MAAMC,IAAI,GAAG,IAAI,CAACC,OAAO,CAACF,EAAE,CAAC;IAC7B,IAAI,CAACC,IAAI,EAAE;MACP,MAAM,IAAIH,KAAK,CAAC,iBAAiB,CAAC;IACtC;IACA,OAAOG,IAAI;EACf;EAEOC,OAAOA,CAAcF,EAAuC,EAA2B;IAC1F,MAAMV,KAAK,GAAG,IAAI,CAACa,QAAQ,CAACH,EAAE,CAAC;IAC/B,IAAIV,KAAK,CAACc,MAAM,KAAK,CAAC,EAAE;MACpB,OAAO,IAAI;IACf,CAAC,MAAM,IAAId,KAAK,CAACc,MAAM,GAAG,CAAC,EAAE;MACzB,MAAM,IAAIN,KAAK,CAAC,sDAAsD,CAAC;IAC3E;IACA,OAAOR,KAAK,CAAC,CAAC,CAAC;EACnB;EAEOa,QAAQA,CAAcH,EAAuC,EAAsB;IACtF,MAAMK,OAA2B,GAAG,EAAE;IACtC,KAAK,MAAMZ,GAAG,IAAI,IAAI,CAACH,KAAK,EAAE;MAC1B,MAAMW,IAAI,GAAG,IAAI,CAACX,KAAK,CAACG,GAAG,CAAqB;MAChD,IAAIO,EAAE,CAACC,IAAI,CAAC,EAAE;QACVI,OAAO,CAACC,IAAI,CAACL,IAAI,CAAC;MACtB;IACJ;IAEA,OAAOI,OAAO;EAClB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"DbRegistry.js","sources":["../src/DbRegistry.ts"],"sourcesContent":["import type { IRegistry, IRegistryItem, IRegistryRegisterParams } from \"./types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport class DbRegistry implements IRegistry {\n private readonly items: GenericRecord<string, IRegistryItem> = {};\n\n public register<T = unknown>(input: IRegistryRegisterParams<T>): void {\n const key = `${input.app}-${input.tags.sort().join(\"-\")}`;\n\n if (this.items[key]) {\n throw new Error(\n `Item with app \"${input.app}\" and tags \"${input.tags.join(\n \", \"\n )}\" is already registered.`\n );\n }\n this.items[key] = input;\n }\n\n public getOneItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T> {\n const item = this.getItem(cb);\n if (!item) {\n throw new Error(\"Item not found.\");\n }\n return item;\n }\n\n public getItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T> | null {\n const items = this.getItems(cb);\n if (items.length === 0) {\n return null;\n } else if (items.length > 1) {\n throw new Error(\"More than one item found with the provided criteria.\");\n }\n return items[0];\n }\n\n public getItems<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T>[] {\n const results: IRegistryItem<T>[] = [];\n for (const key in this.items) {\n const item = this.items[key] as IRegistryItem<T>;\n if (cb(item)) {\n results.push(item);\n }\n }\n\n return results;\n }\n}\n"],"names":["DbRegistry","input","key","Error","cb","item","items","results"],"mappings":"AAGO,MAAMA;IAGF,SAAsBC,KAAiC,EAAQ;QAClE,MAAMC,MAAM,GAAGD,MAAM,GAAG,CAAC,CAAC,EAAEA,MAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM;QAEzD,IAAI,IAAI,CAAC,KAAK,CAACC,IAAI,EACf,MAAM,IAAIC,MACN,CAAC,eAAe,EAAEF,MAAM,GAAG,CAAC,YAAY,EAAEA,MAAM,IAAI,CAAC,IAAI,CACrD,MACF,wBAAwB,CAAC;QAGnC,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGD;IACtB;IAEO,WAAwBG,EAAuC,EAAoB;QACtF,MAAMC,OAAO,IAAI,CAAC,OAAO,CAACD;QAC1B,IAAI,CAACC,MACD,MAAM,IAAIF,MAAM;QAEpB,OAAOE;IACX;IAEO,QAAqBD,EAAuC,EAA2B;QAC1F,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,IAAIE,AAAiB,MAAjBA,MAAM,MAAM,EACZ,OAAO;QACJ,IAAIA,MAAM,MAAM,GAAG,GACtB,MAAM,IAAIH,MAAM;QAEpB,OAAOG,KAAK,CAAC,EAAE;IACnB;IAEO,SAAsBF,EAAuC,EAAsB;QACtF,MAAMG,UAA8B,EAAE;QACtC,IAAK,MAAML,OAAO,IAAI,CAAC,KAAK,CAAE;YAC1B,MAAMG,OAAO,IAAI,CAAC,KAAK,CAACH,IAAI;YAC5B,IAAIE,GAAGC,OACHE,QAAQ,IAAI,CAACF;QAErB;QAEA,OAAOE;IACX;;aA3CiB,KAAK,GAAyC,CAAC;;AA4CpE"}
package/index.js CHANGED
@@ -2,17 +2,14 @@ import { DbRegistry } from "./DbRegistry.js";
2
2
  import { Store } from "./store/Store.js";
3
3
  export * from "./types.js";
4
4
  class Db {
5
- registry = new DbRegistry();
6
- constructor({
7
- driver,
8
- table
9
- }) {
10
- this.table = table;
11
- this.driver = driver;
12
- this.store = new Store({
13
- driver
14
- });
15
- }
5
+ constructor({ driver, table }){
6
+ this.registry = new DbRegistry();
7
+ this.table = table;
8
+ this.driver = driver;
9
+ this.store = new Store({
10
+ driver
11
+ });
12
+ }
16
13
  }
17
14
  export { Db };
18
15
 
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["DbRegistry","Store","Db","registry","constructor","driver","table","store"],"sources":["index.ts"],"sourcesContent":["import { DbRegistry } from \"~/DbRegistry.js\";\nimport type { IStore } from \"~/store/types.js\";\nimport { Store } from \"~/store/Store.js\";\n\nexport * from \"./types.js\";\n\nexport interface DbDriver<T> extends IStore {\n getClient(): T;\n}\n\nexport interface ConstructorArgs<T> {\n driver: DbDriver<T>;\n table?: string;\n}\n\nclass Db<T> {\n public driver: DbDriver<T>;\n public readonly table?: string;\n public readonly store: IStore;\n\n public readonly registry = new DbRegistry();\n\n constructor({ driver, table }: ConstructorArgs<T>) {\n this.table = table;\n this.driver = driver;\n this.store = new Store<T>({\n driver\n });\n }\n}\n\nexport { Db };\n"],"mappings":"AAAA,SAASA,UAAU;AAEnB,SAASC,KAAK;AAEd;AAWA,MAAMC,EAAE,CAAI;EAKQC,QAAQ,GAAG,IAAIH,UAAU,CAAC,CAAC;EAE3CI,WAAWA,CAAC;IAAEC,MAAM;IAAEC;EAA0B,CAAC,EAAE;IAC/C,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,KAAK,GAAG,IAAIN,KAAK,CAAI;MACtBI;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,SAASH,EAAE","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { DbRegistry } from \"~/DbRegistry.js\";\nimport type { IStore } from \"~/store/types.js\";\nimport { Store } from \"~/store/Store.js\";\n\nexport * from \"./types.js\";\n\nexport interface DbDriver<T> extends IStore {\n getClient(): T;\n}\n\nexport interface ConstructorArgs<T> {\n driver: DbDriver<T>;\n table?: string;\n}\n\nclass Db<T> {\n public driver: DbDriver<T>;\n public readonly table?: string;\n public readonly store: IStore;\n\n public readonly registry = new DbRegistry();\n\n constructor({ driver, table }: ConstructorArgs<T>) {\n this.table = table;\n this.driver = driver;\n this.store = new Store<T>({\n driver\n });\n }\n}\n\nexport { Db };\n"],"names":["Db","driver","table","DbRegistry","Store"],"mappings":";;;AAeA,MAAMA;IAOF,YAAY,EAAEC,MAAM,EAAEC,KAAK,EAAsB,CAAE;aAFnC,QAAQ,GAAG,IAAIC;QAG3B,IAAI,CAAC,KAAK,GAAGD;QACb,IAAI,CAAC,MAAM,GAAGD;QACd,IAAI,CAAC,KAAK,GAAG,IAAIG,MAAS;YACtBH;QACJ;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/db",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-beta.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,13 +17,13 @@
17
17
  "directory": "dist"
18
18
  },
19
19
  "dependencies": {
20
- "@webiny/api": "6.3.0",
20
+ "@webiny/api": "6.4.0-beta.0",
21
21
  "type-fest": "5.6.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/build-tools": "6.3.0",
24
+ "@webiny/build-tools": "6.4.0-beta.0",
25
25
  "rimraf": "6.1.3",
26
26
  "typescript": "6.0.3"
27
27
  },
28
- "gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693"
28
+ "gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
29
29
  }
package/store/Store.js CHANGED
@@ -1,28 +1,29 @@
1
- export class Store {
2
- constructor(params) {
3
- this.driver = params.driver;
4
- }
5
- async storeValue(key, value) {
6
- return this.driver.storeValue(key, value);
7
- }
8
- async storeValues(values) {
9
- return this.driver.storeValues(values);
10
- }
11
- async getValue(key) {
12
- return this.driver.getValue(key);
13
- }
14
- async getValues(keys) {
15
- return this.driver.getValues(keys);
16
- }
17
- async listValues(params) {
18
- return this.driver.listValues(params);
19
- }
20
- async removeValue(key) {
21
- return this.driver.removeValue(key);
22
- }
23
- async removeValues(keys) {
24
- return this.driver.removeValues(keys);
25
- }
1
+ class Store {
2
+ constructor(params){
3
+ this.driver = params.driver;
4
+ }
5
+ async storeValue(key, value) {
6
+ return this.driver.storeValue(key, value);
7
+ }
8
+ async storeValues(values) {
9
+ return this.driver.storeValues(values);
10
+ }
11
+ async getValue(key) {
12
+ return this.driver.getValue(key);
13
+ }
14
+ async getValues(keys) {
15
+ return this.driver.getValues(keys);
16
+ }
17
+ async listValues(params) {
18
+ return this.driver.listValues(params);
19
+ }
20
+ async removeValue(key) {
21
+ return this.driver.removeValue(key);
22
+ }
23
+ async removeValues(keys) {
24
+ return this.driver.removeValues(keys);
25
+ }
26
26
  }
27
+ export { Store };
27
28
 
28
29
  //# sourceMappingURL=Store.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Store","constructor","params","driver","storeValue","key","value","storeValues","values","getValue","getValues","keys","listValues","removeValue","removeValues"],"sources":["Store.ts"],"sourcesContent":["import type {\n GetValueResult,\n GetValuesResult,\n IListValuesParams,\n IStore,\n ListValuesResult,\n RemoveValueResult,\n RemoveValuesResult,\n StorageKey,\n StoreValueResult,\n StoreValuesResult\n} from \"./types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { DbDriver } from \"~/index.js\";\n\nexport interface IStoreParams<T> {\n driver: DbDriver<T>;\n}\n\nexport class Store<T> implements IStore {\n private driver: DbDriver<T>;\n\n public constructor(params: IStoreParams<T>) {\n this.driver = params.driver;\n }\n\n public async storeValue<V>(key: StorageKey, value: V): Promise<StoreValueResult<V>> {\n return this.driver.storeValue<V>(key, value);\n }\n\n public async storeValues<V extends GenericRecord<StorageKey>>(\n values: V\n ): Promise<StoreValuesResult<V>> {\n return this.driver.storeValues<V>(values);\n }\n\n public async getValue<V>(key: StorageKey): Promise<GetValueResult<V>> {\n return this.driver.getValue<V>(key);\n }\n\n public async getValues<V extends GenericRecord<StorageKey>>(\n keys: (keyof V)[]\n ): Promise<GetValuesResult<V>> {\n return this.driver.getValues<V>(keys);\n }\n\n public async listValues<V extends GenericRecord<StorageKey>>(\n params?: IListValuesParams\n ): Promise<ListValuesResult<V>> {\n return this.driver.listValues<V>(params);\n }\n\n public async removeValue<V>(key: StorageKey): Promise<RemoveValueResult<V>> {\n return this.driver.removeValue<V>(key);\n }\n\n public async removeValues<V extends GenericRecord<StorageKey>>(\n keys: (keyof V)[]\n ): Promise<RemoveValuesResult<V>> {\n return this.driver.removeValues<V>(keys);\n }\n}\n"],"mappings":"AAmBA,OAAO,MAAMA,KAAK,CAAsB;EAG7BC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,UAAUA,CAAIC,GAAe,EAAEC,KAAQ,EAAgC;IAChF,OAAO,IAAI,CAACH,MAAM,CAACC,UAAU,CAAIC,GAAG,EAAEC,KAAK,CAAC;EAChD;EAEA,MAAaC,WAAWA,CACpBC,MAAS,EACoB;IAC7B,OAAO,IAAI,CAACL,MAAM,CAACI,WAAW,CAAIC,MAAM,CAAC;EAC7C;EAEA,MAAaC,QAAQA,CAAIJ,GAAe,EAA8B;IAClE,OAAO,IAAI,CAACF,MAAM,CAACM,QAAQ,CAAIJ,GAAG,CAAC;EACvC;EAEA,MAAaK,SAASA,CAClBC,IAAiB,EACU;IAC3B,OAAO,IAAI,CAACR,MAAM,CAACO,SAAS,CAAIC,IAAI,CAAC;EACzC;EAEA,MAAaC,UAAUA,CACnBV,MAA0B,EACE;IAC5B,OAAO,IAAI,CAACC,MAAM,CAACS,UAAU,CAAIV,MAAM,CAAC;EAC5C;EAEA,MAAaW,WAAWA,CAAIR,GAAe,EAAiC;IACxE,OAAO,IAAI,CAACF,MAAM,CAACU,WAAW,CAAIR,GAAG,CAAC;EAC1C;EAEA,MAAaS,YAAYA,CACrBH,IAAiB,EACa;IAC9B,OAAO,IAAI,CAACR,MAAM,CAACW,YAAY,CAAIH,IAAI,CAAC;EAC5C;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"store/Store.js","sources":["../../src/store/Store.ts"],"sourcesContent":["import type {\n GetValueResult,\n GetValuesResult,\n IListValuesParams,\n IStore,\n ListValuesResult,\n RemoveValueResult,\n RemoveValuesResult,\n StorageKey,\n StoreValueResult,\n StoreValuesResult\n} from \"./types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { DbDriver } from \"~/index.js\";\n\nexport interface IStoreParams<T> {\n driver: DbDriver<T>;\n}\n\nexport class Store<T> implements IStore {\n private driver: DbDriver<T>;\n\n public constructor(params: IStoreParams<T>) {\n this.driver = params.driver;\n }\n\n public async storeValue<V>(key: StorageKey, value: V): Promise<StoreValueResult<V>> {\n return this.driver.storeValue<V>(key, value);\n }\n\n public async storeValues<V extends GenericRecord<StorageKey>>(\n values: V\n ): Promise<StoreValuesResult<V>> {\n return this.driver.storeValues<V>(values);\n }\n\n public async getValue<V>(key: StorageKey): Promise<GetValueResult<V>> {\n return this.driver.getValue<V>(key);\n }\n\n public async getValues<V extends GenericRecord<StorageKey>>(\n keys: (keyof V)[]\n ): Promise<GetValuesResult<V>> {\n return this.driver.getValues<V>(keys);\n }\n\n public async listValues<V extends GenericRecord<StorageKey>>(\n params?: IListValuesParams\n ): Promise<ListValuesResult<V>> {\n return this.driver.listValues<V>(params);\n }\n\n public async removeValue<V>(key: StorageKey): Promise<RemoveValueResult<V>> {\n return this.driver.removeValue<V>(key);\n }\n\n public async removeValues<V extends GenericRecord<StorageKey>>(\n keys: (keyof V)[]\n ): Promise<RemoveValuesResult<V>> {\n return this.driver.removeValues<V>(keys);\n }\n}\n"],"names":["Store","params","key","value","values","keys"],"mappings":"AAmBO,MAAMA;IAGT,YAAmBC,MAAuB,CAAE;QACxC,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;IAEA,MAAa,WAAcC,GAAe,EAAEC,KAAQ,EAAgC;QAChF,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAID,KAAKC;IAC1C;IAEA,MAAa,YACTC,MAAS,EACoB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAIA;IACtC;IAEA,MAAa,SAAYF,GAAe,EAA8B;QAClE,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAIA;IACnC;IAEA,MAAa,UACTG,IAAiB,EACU;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAIA;IACpC;IAEA,MAAa,WACTJ,MAA0B,EACE;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAIA;IACrC;IAEA,MAAa,YAAeC,GAAe,EAAiC;QACxE,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAIA;IACtC;IAEA,MAAa,aACTG,IAAiB,EACa;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAIA;IACvC;AACJ"}
package/store/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
package/types.js CHANGED
@@ -1,4 +1 @@
1
1
  export * from "./store/types.js";
2
- export {};
3
-
4
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CamelCase } from \"type-fest\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type StorageKey = `${CamelCase<string>}`;\n\nexport interface IStoreValueSuccessResult<V> {\n key: StorageKey;\n data: V | null | undefined;\n error?: undefined;\n}\n\nexport interface IStoreValueErrorResult {\n key: StorageKey;\n data?: never;\n error: Error;\n}\n\nexport type StoreValueResult<V> = IStoreValueSuccessResult<V> | IStoreValueErrorResult;\n\nexport interface IStoreValuesSuccessResult<V extends GenericRecord<StorageKey>> {\n keys: (keyof V)[];\n data: V;\n error?: undefined;\n}\n\nexport interface IStoreValuesErrorResult<V> {\n keys: (keyof V)[];\n data?: never;\n error: Error;\n}\n\nexport type StoreValuesResult<V extends GenericRecord<StorageKey>> =\n | IStoreValuesSuccessResult<V>\n | IStoreValuesErrorResult<V>;\n\nexport interface IGetValueSuccessResult<V> {\n key: StorageKey;\n data: V | null | undefined;\n error?: undefined;\n}\n\nexport interface IGetValueErrorResult {\n key: StorageKey;\n data?: never;\n error: Error;\n}\n\nexport type GetValueResult<V> = IGetValueSuccessResult<V> | IGetValueErrorResult;\n\nexport interface IGetValuesSuccessResult<V extends GenericRecord<StorageKey>> {\n keys: (keyof V)[];\n data: V;\n error?: undefined;\n}\n\nexport interface IGetValuesErrorResult<V> {\n keys: (keyof V)[];\n data?: never;\n error: Error;\n}\n\nexport type GetValuesResult<V extends GenericRecord<StorageKey>> =\n | IGetValuesSuccessResult<V>\n | IGetValuesErrorResult<V>;\n\nexport interface IListValuesSuccessResult<V extends GenericRecord<StorageKey>> {\n keys: (keyof V)[];\n data: V;\n error?: undefined;\n}\n\nexport interface IListValuesErrorResult {\n data?: never;\n error: Error;\n}\n\nexport type ListValuesResult<V extends GenericRecord<StorageKey>> =\n | IListValuesSuccessResult<V>\n | IListValuesErrorResult;\n\nexport type IListValuesParams =\n | {\n beginsWith: string;\n }\n | {\n eq: string;\n }\n | {\n gt: string;\n }\n | {\n gte: string;\n }\n | {\n lt: string;\n }\n | {\n lte: string;\n };\n\nexport type RemoveValueResult<V> = StoreValueResult<V>;\n\nexport interface RemoveValuesResult<V extends GenericRecord<StorageKey>> {\n keys: (keyof V)[];\n error?: Error;\n}\n\nexport interface IStore {\n storeValue<V>(key: StorageKey, value: V): Promise<StoreValueResult<V>>;\n storeValues<V extends GenericRecord<StorageKey>>(values: V): Promise<StoreValuesResult<V>>;\n getValue<V>(key: StorageKey): Promise<GetValueResult<V>>;\n getValues<V extends GenericRecord<StorageKey>>(keys: (keyof V)[]): Promise<GetValuesResult<V>>;\n listValues<V extends GenericRecord<StorageKey>>(\n params?: IListValuesParams\n ): Promise<ListValuesResult<V>>;\n removeValue<V>(key: StorageKey): Promise<RemoveValueResult<V>>;\n removeValues<V extends GenericRecord<StorageKey>>(\n keys: (keyof V)[]\n ): Promise<RemoveValuesResult<V>>;\n}\n"],"mappings":"","ignoreList":[]}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { NonEmptyArray } from \"@webiny/api/types.js\";\n\nexport interface IRegistryRegisterParams<T = unknown> {\n item: T;\n app: string;\n tags: NonEmptyArray<string>;\n}\n\nexport interface IRegistryItem<T = unknown> {\n item: T;\n app: string;\n tags: NonEmptyArray<string>;\n}\n\nexport interface IRegistry {\n register<T = unknown>(params: IRegistryRegisterParams<T>): void;\n /**\n * Throws an error if more than one item is found or there is no item found.\n */\n getOneItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T>;\n /**\n * Throws an error if more than one item is found.\n */\n getItem<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T> | null;\n getItems<T = unknown>(cb: (item: IRegistryItem<T>) => boolean): IRegistryItem<T>[];\n}\n\nexport * from \"./store/types.js\";\n"],"mappings":"AA2BA;AAAiC","ignoreList":[]}