@forge/storage 2.0.2 → 2.0.3-experimental-04cc2b9

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.
Files changed (51) hide show
  1. package/LICENSE.txt +1 -1
  2. package/package.json +11 -2
  3. package/README.md +0 -50
  4. package/out/__test__/errors.test.d.ts +0 -2
  5. package/out/__test__/errors.test.d.ts.map +0 -1
  6. package/out/__test__/errors.test.js +0 -34
  7. package/out/__test__/global-storage.test.d.ts +0 -2
  8. package/out/__test__/global-storage.test.d.ts.map +0 -1
  9. package/out/__test__/global-storage.test.js +0 -833
  10. package/out/__test__/list-api.test.d.ts +0 -2
  11. package/out/__test__/list-api.test.d.ts.map +0 -1
  12. package/out/__test__/list-api.test.js +0 -650
  13. package/out/conditions.d.ts +0 -3
  14. package/out/conditions.d.ts.map +0 -1
  15. package/out/conditions.js +0 -10
  16. package/out/eap/conditions.d.ts +0 -40
  17. package/out/eap/conditions.d.ts.map +0 -1
  18. package/out/eap/conditions.js +0 -112
  19. package/out/eap/index.d.ts +0 -2
  20. package/out/eap/index.d.ts.map +0 -1
  21. package/out/eap/index.js +0 -4
  22. package/out/entity-storage/index.d.ts +0 -2
  23. package/out/entity-storage/index.d.ts.map +0 -1
  24. package/out/entity-storage/index.js +0 -5
  25. package/out/entity-storage/query-api.d.ts +0 -48
  26. package/out/entity-storage/query-api.d.ts.map +0 -1
  27. package/out/entity-storage/query-api.js +0 -154
  28. package/out/entity-storage/storage-builder.d.ts +0 -20
  29. package/out/entity-storage/storage-builder.d.ts.map +0 -1
  30. package/out/entity-storage/storage-builder.js +0 -25
  31. package/out/errors.d.ts +0 -9
  32. package/out/errors.d.ts.map +0 -1
  33. package/out/errors.js +0 -41
  34. package/out/global-storage.d.ts +0 -50
  35. package/out/global-storage.d.ts.map +0 -1
  36. package/out/global-storage.js +0 -156
  37. package/out/gql-queries.d.ts +0 -81
  38. package/out/gql-queries.d.ts.map +0 -1
  39. package/out/gql-queries.js +0 -200
  40. package/out/index.d.ts +0 -49
  41. package/out/index.d.ts.map +0 -1
  42. package/out/index.js +0 -33
  43. package/out/query-api.d.ts +0 -14
  44. package/out/query-api.d.ts.map +0 -1
  45. package/out/query-api.js +0 -44
  46. package/out/query-interfaces.d.ts +0 -113
  47. package/out/query-interfaces.d.ts.map +0 -1
  48. package/out/query-interfaces.js +0 -8
  49. package/out/storage-adapter.d.ts +0 -42
  50. package/out/storage-adapter.d.ts.map +0 -1
  51. package/out/storage-adapter.js +0 -2
@@ -1,40 +0,0 @@
1
- import { FilterPredicate, WherePredicate, Predicate } from '../storage-adapter';
2
- export declare function isNotEqualTo(value: string[]): Predicate;
3
- export declare function isIn(values: string[]): Predicate;
4
- declare function beginsWith(value: string | number): WherePredicate;
5
- declare function between(values: [string, string] | [number, number]): WherePredicate;
6
- declare function exists(): FilterPredicate;
7
- declare function doesNotExist(): FilterPredicate;
8
- declare function isGreaterThan(value: string | number): WherePredicate;
9
- declare function isGreaterThanEqualTo(value: string | number): WherePredicate;
10
- declare function isLessThan(value: string | number): WherePredicate;
11
- declare function isLessThanEqualTo(value: string | number): WherePredicate;
12
- declare function contains(value: string): FilterPredicate;
13
- declare function doesNotContain(value: string): FilterPredicate;
14
- declare function equalsTo(value: number | string | boolean): WherePredicate;
15
- declare function notEqualsTo(value: number | string | boolean): FilterPredicate;
16
- export declare const WhereConditions: {
17
- beginsWith: typeof beginsWith;
18
- between: typeof between;
19
- equalsTo: typeof equalsTo;
20
- isGreaterThan: typeof isGreaterThan;
21
- isGreaterThanEqualTo: typeof isGreaterThanEqualTo;
22
- isLessThan: typeof isLessThan;
23
- isLessThanEqualTo: typeof isLessThanEqualTo;
24
- };
25
- export declare const FilterConditions: {
26
- beginsWith: typeof beginsWith;
27
- between: typeof between;
28
- contains: typeof contains;
29
- doesNotContain: typeof doesNotContain;
30
- equalsTo: typeof equalsTo;
31
- notEqualsTo: typeof notEqualsTo;
32
- exists: typeof exists;
33
- doesNotExist: typeof doesNotExist;
34
- isGreaterThan: typeof isGreaterThan;
35
- isGreaterThanEqualTo: typeof isGreaterThanEqualTo;
36
- isLessThan: typeof isLessThan;
37
- isLessThanEqualTo: typeof isLessThanEqualTo;
38
- };
39
- export {};
40
- //# sourceMappingURL=conditions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/eap/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAKvD;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAKhD;AAKD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAK1D;AAED,iBAAS,OAAO,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,cAAc,CAK5E;AAED,iBAAS,MAAM,IAAI,eAAe,CAKjC;AAED,iBAAS,YAAY,IAAI,eAAe,CAKvC;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAK7D;AAED,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAKpE;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAK1D;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAKjE;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAKhD;AAED,iBAAS,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAKtD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAKlE;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAKtE;AAED,eAAO,MAAM,eAAe;;;;;;;;CAQ3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;CAa5B,CAAC"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterConditions = exports.WhereConditions = exports.isIn = exports.isNotEqualTo = void 0;
4
- function isNotEqualTo(value) {
5
- return {
6
- condition: 'NOT_EQUAL_TO',
7
- value
8
- };
9
- }
10
- exports.isNotEqualTo = isNotEqualTo;
11
- function isIn(values) {
12
- return {
13
- condition: 'IN',
14
- value: values
15
- };
16
- }
17
- exports.isIn = isIn;
18
- function beginsWith(value) {
19
- return {
20
- condition: 'BEGINS_WITH',
21
- values: [value]
22
- };
23
- }
24
- function between(values) {
25
- return {
26
- condition: 'BETWEEN',
27
- values
28
- };
29
- }
30
- function exists() {
31
- return {
32
- condition: 'EXISTS',
33
- values: [true]
34
- };
35
- }
36
- function doesNotExist() {
37
- return {
38
- condition: 'NOT_EXISTS',
39
- values: [true]
40
- };
41
- }
42
- function isGreaterThan(value) {
43
- return {
44
- condition: 'GREATER_THAN',
45
- values: [value]
46
- };
47
- }
48
- function isGreaterThanEqualTo(value) {
49
- return {
50
- condition: 'GREATER_THAN_EQUAL_TO',
51
- values: [value]
52
- };
53
- }
54
- function isLessThan(value) {
55
- return {
56
- condition: 'LESS_THAN',
57
- values: [value]
58
- };
59
- }
60
- function isLessThanEqualTo(value) {
61
- return {
62
- condition: 'LESS_THAN_EQUAL_TO',
63
- values: [value]
64
- };
65
- }
66
- function contains(value) {
67
- return {
68
- condition: 'CONTAINS',
69
- values: [value]
70
- };
71
- }
72
- function doesNotContain(value) {
73
- return {
74
- condition: 'NOT_CONTAINS',
75
- values: [value]
76
- };
77
- }
78
- function equalsTo(value) {
79
- return {
80
- condition: 'EQUAL_TO',
81
- values: [value]
82
- };
83
- }
84
- function notEqualsTo(value) {
85
- return {
86
- condition: 'NOT_EQUAL_TO',
87
- values: [value]
88
- };
89
- }
90
- exports.WhereConditions = {
91
- beginsWith,
92
- between,
93
- equalsTo,
94
- isGreaterThan,
95
- isGreaterThanEqualTo,
96
- isLessThan,
97
- isLessThanEqualTo
98
- };
99
- exports.FilterConditions = {
100
- beginsWith,
101
- between,
102
- contains,
103
- doesNotContain,
104
- equalsTo,
105
- notEqualsTo,
106
- exists,
107
- doesNotExist,
108
- isGreaterThan,
109
- isGreaterThanEqualTo,
110
- isLessThan,
111
- isLessThanEqualTo
112
- };
@@ -1,2 +0,0 @@
1
- export * from './conditions';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eap/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
package/out/eap/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./conditions"), exports);
@@ -1,2 +0,0 @@
1
- export { EntityStorageBuilder, EntityStorageBuilderType } from './storage-builder';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity-storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityStorageBuilder = void 0;
4
- var storage_builder_1 = require("./storage-builder");
5
- Object.defineProperty(exports, "EntityStorageBuilder", { enumerable: true, get: function () { return storage_builder_1.EntityStorageBuilder; } });
@@ -1,48 +0,0 @@
1
- import { GlobalStorage } from '../global-storage';
2
- import { CustomEntityQueryIndexOptions, CustomEntityListOptions, SortOrder } from '../query-interfaces';
3
- import { Result, ListResult, WherePredicate, FilterPredicate } from '../storage-adapter';
4
- declare class CustomEntityQueryBuilder<T> {
5
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
6
- protected queryOptions: CustomEntityListOptions;
7
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
8
- private clone;
9
- where(condition: WherePredicate): this;
10
- sort(sort: SortOrder): this;
11
- cursor(cursor: string): this;
12
- limit(limit: number): this;
13
- getOne(): Promise<Result<T> | undefined>;
14
- getMany(): Promise<ListResult<T>>;
15
- }
16
- declare class CustomEntityAndFilterQueryBuilder<T> extends CustomEntityQueryBuilder<T> {
17
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
18
- protected queryOptions: CustomEntityListOptions;
19
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
20
- andFilter(field: string, condition: FilterPredicate): CustomEntityAndFilterQueryBuilder<T>;
21
- }
22
- declare class CustomEntityOrFilterQueryBuilder<T> extends CustomEntityQueryBuilder<T> {
23
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
24
- protected queryOptions: CustomEntityListOptions;
25
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
26
- orFilter(field: string, condition: FilterPredicate): CustomEntityOrFilterQueryBuilder<T>;
27
- }
28
- declare class CustomEntityFilterQueryBuilder<T> extends CustomEntityQueryBuilder<T> {
29
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
30
- protected queryOptions: CustomEntityListOptions;
31
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
32
- andFilter(field: string, condition: FilterPredicate): CustomEntityAndFilterQueryBuilder<T>;
33
- orFilter(field: string, condition: FilterPredicate): CustomEntityOrFilterQueryBuilder<T>;
34
- }
35
- export declare class CustomEntityIndexBuilder<T> {
36
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
37
- protected queryOptions: CustomEntityListOptions;
38
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
39
- index(name: string, indexOptions?: CustomEntityQueryIndexOptions): CustomEntityFilterQueryBuilder<T>;
40
- }
41
- export declare class CustomEntityBuilder<T> {
42
- protected globalStorage: Pick<GlobalStorage, 'listCustomEntities'>;
43
- protected queryOptions: CustomEntityListOptions;
44
- constructor(globalStorage: Pick<GlobalStorage, 'listCustomEntities'>, queryOptions?: CustomEntityListOptions);
45
- entity(name: string): CustomEntityIndexBuilder<T>;
46
- }
47
- export {};
48
- //# sourceMappingURL=query-api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-api.d.ts","sourceRoot":"","sources":["../../src/entity-storage/query-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAuCzF,cAAM,wBAAwB,CAAC,CAAC;IAE5B,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,uBAAuB;gBADrC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,EACxD,YAAY,GAAE,uBAA4B;IAOtD,OAAO,CAAC,KAAK;IAOb,KAAK,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAQtC,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAM3B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM5B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;I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I1F,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,gCAAgC,CAAC,CAAC,CAAC;CAGzF;AAED,qBAAa,wBAAwB,CAAC,CAAC;IAEnC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,uBAAuB;gBADrC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,EACxD,YAAY,GAAE,uBAA4B;IAOtD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,6BAA6B,GAAG,8BAA8B,CAAC,CAAC,CAAC;CAQrG;AAED,qBAAa,mBAAmB,CAAC,CAAC;IAE9B,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,uBAAuB;gBADrC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,EACxD,YAAY,GAAE,uBAA4B;IAOtD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAAC,CAAC,CAAC;CAMlD"}
@@ -1,154 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomEntityBuilder = exports.CustomEntityIndexBuilder = void 0;
4
- class CustomEntityQueryBuilder {
5
- globalStorage;
6
- queryOptions;
7
- constructor(globalStorage, queryOptions = {}) {
8
- this.globalStorage = globalStorage;
9
- this.queryOptions = queryOptions;
10
- this.queryOptions = {
11
- ...queryOptions
12
- };
13
- }
14
- clone(overrides) {
15
- return new (Object.getPrototypeOf(this).constructor)(this.globalStorage, {
16
- ...this.queryOptions,
17
- ...overrides
18
- });
19
- }
20
- where(condition) {
21
- return this.clone({
22
- range: {
23
- ...condition
24
- }
25
- });
26
- }
27
- sort(sort) {
28
- return this.clone({
29
- sort
30
- });
31
- }
32
- cursor(cursor) {
33
- return this.clone({
34
- cursor
35
- });
36
- }
37
- limit(limit) {
38
- return this.clone({
39
- limit
40
- });
41
- }
42
- async getOne() {
43
- const { results } = await this.limit(1).getMany();
44
- return results?.[0];
45
- }
46
- async getMany() {
47
- if (!this.queryOptions.entityName) {
48
- throw new Error('entityName is mandatory');
49
- }
50
- if (!this.queryOptions.indexName) {
51
- throw new Error('indexName is mandatory');
52
- }
53
- const queryOptions = { ...this.queryOptions };
54
- if (!queryOptions.filterOperator && queryOptions.filters) {
55
- queryOptions.filterOperator = 'and';
56
- }
57
- return this.globalStorage.listCustomEntities(this.queryOptions);
58
- }
59
- }
60
- class CustomEntityAndFilterQueryBuilder extends CustomEntityQueryBuilder {
61
- globalStorage;
62
- queryOptions;
63
- constructor(globalStorage, queryOptions = {}) {
64
- super(globalStorage, queryOptions);
65
- this.globalStorage = globalStorage;
66
- this.queryOptions = queryOptions;
67
- this.queryOptions = {
68
- ...queryOptions
69
- };
70
- }
71
- andFilter(field, condition) {
72
- const newQueryOptions = {
73
- ...this.queryOptions
74
- };
75
- newQueryOptions.filters = [...(this.queryOptions.filters ?? []), { property: field, ...condition }];
76
- newQueryOptions.filterOperator = 'and';
77
- return new CustomEntityAndFilterQueryBuilder(this.globalStorage, newQueryOptions);
78
- }
79
- }
80
- class CustomEntityOrFilterQueryBuilder extends CustomEntityQueryBuilder {
81
- globalStorage;
82
- queryOptions;
83
- constructor(globalStorage, queryOptions = {}) {
84
- super(globalStorage, queryOptions);
85
- this.globalStorage = globalStorage;
86
- this.queryOptions = queryOptions;
87
- this.queryOptions = {
88
- ...queryOptions
89
- };
90
- }
91
- orFilter(field, condition) {
92
- const newQueryOptions = {
93
- ...this.queryOptions
94
- };
95
- newQueryOptions.filters = [...(this.queryOptions.filters ?? []), { property: field, ...condition }];
96
- newQueryOptions.filterOperator = 'or';
97
- return new CustomEntityOrFilterQueryBuilder(this.globalStorage, newQueryOptions);
98
- }
99
- }
100
- class CustomEntityFilterQueryBuilder extends CustomEntityQueryBuilder {
101
- globalStorage;
102
- queryOptions;
103
- constructor(globalStorage, queryOptions = {}) {
104
- super(globalStorage, queryOptions);
105
- this.globalStorage = globalStorage;
106
- this.queryOptions = queryOptions;
107
- this.queryOptions = {
108
- ...queryOptions
109
- };
110
- }
111
- andFilter(field, condition) {
112
- return new CustomEntityAndFilterQueryBuilder(this.globalStorage, this.queryOptions).andFilter(field, condition);
113
- }
114
- orFilter(field, condition) {
115
- return new CustomEntityOrFilterQueryBuilder(this.globalStorage, this.queryOptions).orFilter(field, condition);
116
- }
117
- }
118
- class CustomEntityIndexBuilder {
119
- globalStorage;
120
- queryOptions;
121
- constructor(globalStorage, queryOptions = {}) {
122
- this.globalStorage = globalStorage;
123
- this.queryOptions = queryOptions;
124
- this.queryOptions = {
125
- ...queryOptions
126
- };
127
- }
128
- index(name, indexOptions) {
129
- const indexProperties = indexOptions ? { indexName: name, ...indexOptions } : { indexName: name };
130
- return new CustomEntityFilterQueryBuilder(this.globalStorage, {
131
- ...this.queryOptions,
132
- ...indexProperties
133
- });
134
- }
135
- }
136
- exports.CustomEntityIndexBuilder = CustomEntityIndexBuilder;
137
- class CustomEntityBuilder {
138
- globalStorage;
139
- queryOptions;
140
- constructor(globalStorage, queryOptions = {}) {
141
- this.globalStorage = globalStorage;
142
- this.queryOptions = queryOptions;
143
- this.queryOptions = {
144
- ...queryOptions
145
- };
146
- }
147
- entity(name) {
148
- return new CustomEntityIndexBuilder(this.globalStorage, {
149
- ...this.queryOptions,
150
- entityName: name
151
- });
152
- }
153
- }
154
- exports.CustomEntityBuilder = CustomEntityBuilder;
@@ -1,20 +0,0 @@
1
- import { GlobalStorage } from '../global-storage';
2
- import { CustomEntityIndexBuilder } from './query-api';
3
- declare type EntityGlobalStorage = Pick<GlobalStorage, 'setEntity' | 'getEntity' | 'deleteEntity' | 'listCustomEntities'>;
4
- export interface EntityStorageBuilderType<T> {
5
- query(): CustomEntityIndexBuilder<T>;
6
- get(entityKey: string): Promise<T | undefined>;
7
- set(entityKey: string, value: T): Promise<void>;
8
- delete(entityKey: string): Promise<void>;
9
- }
10
- export declare class EntityStorageBuilder<T> implements EntityStorageBuilderType<T> {
11
- private entityName;
12
- private globalStorage;
13
- constructor(entityName: string, globalStorage: EntityGlobalStorage);
14
- query(): CustomEntityIndexBuilder<T>;
15
- get(entityKey: string): Promise<T | undefined>;
16
- set(entityKey: string, value: T): Promise<void>;
17
- delete(entityKey: string): Promise<void>;
18
- }
19
- export {};
20
- //# sourceMappingURL=storage-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-builder.d.ts","sourceRoot":"","sources":["../../src/entity-storage/storage-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAuB,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5E,aAAK,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,WAAW,GAAG,cAAc,GAAG,oBAAoB,CAAC,CAAC;AAClH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,KAAK,IAAI,wBAAwB,CAAC,CAAC,CAAC,CAAC;IACrC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC/C,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,wBAAwB,CAAC,CAAC,CAAC;IAEvE,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa;gBADb,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,mBAAmB;IAG5C,KAAK,IAAI,wBAAwB,CAAC,CAAC,CAAC;IAIpC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAI9C,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityStorageBuilder = void 0;
4
- const query_api_1 = require("./query-api");
5
- class EntityStorageBuilder {
6
- entityName;
7
- globalStorage;
8
- constructor(entityName, globalStorage) {
9
- this.entityName = entityName;
10
- this.globalStorage = globalStorage;
11
- }
12
- query() {
13
- return new query_api_1.CustomEntityBuilder(this.globalStorage).entity(this.entityName);
14
- }
15
- get(entityKey) {
16
- return this.globalStorage.getEntity(this.entityName, entityKey);
17
- }
18
- set(entityKey, value) {
19
- return this.globalStorage.setEntity(this.entityName, entityKey, value);
20
- }
21
- delete(entityKey) {
22
- return this.globalStorage.deleteEntity(this.entityName, entityKey);
23
- }
24
- }
25
- exports.EntityStorageBuilder = EntityStorageBuilder;
package/out/errors.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export declare const getErrorMessageFromCode: (code: string, message: string | null) => string;
2
- export declare const getErrorMessage: (statusCode: number) => string;
3
- export declare class APIError extends Error {
4
- private constructor();
5
- static forStatus(status: number): APIError;
6
- static forErrorCode(code: string, message: string | null): APIError;
7
- static forUnexpected(message: string): APIError;
8
- }
9
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,SAAU,MAAM,WAAW,MAAM,GAAG,IAAI,KAAG,MAE9E,CAAC;AAEF,eAAO,MAAM,eAAe,eAAgB,MAAM,KAAG,MAiBpD,CAAC;AAEF,qBAAa,QAAS,SAAQ,KAAK;IACjC,OAAO;WAIO,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;WAInC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ;WAI5D,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;CAGvD"}
package/out/errors.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APIError = exports.getErrorMessage = exports.getErrorMessageFromCode = void 0;
4
- const getErrorMessageFromCode = (code, message) => {
5
- return message ?? code;
6
- };
7
- exports.getErrorMessageFromCode = getErrorMessageFromCode;
8
- const getErrorMessage = (statusCode) => {
9
- switch (statusCode) {
10
- case 400:
11
- case 413:
12
- return 'Bad request';
13
- case 401:
14
- return 'Authentication error';
15
- case 403:
16
- case 404:
17
- return 'Permissions error or key does not exist';
18
- case 409:
19
- return 'Conflicting update occurred';
20
- case 500:
21
- return 'Internal server error';
22
- default:
23
- return `Unknown error. Received status code '${statusCode}'`;
24
- }
25
- };
26
- exports.getErrorMessage = getErrorMessage;
27
- class APIError extends Error {
28
- constructor(message) {
29
- super(message);
30
- }
31
- static forStatus(status) {
32
- return new APIError((0, exports.getErrorMessage)(status));
33
- }
34
- static forErrorCode(code, message) {
35
- return new APIError((0, exports.getErrorMessageFromCode)(code, message));
36
- }
37
- static forUnexpected(message) {
38
- return new APIError(message);
39
- }
40
- }
41
- exports.APIError = APIError;
@@ -1,50 +0,0 @@
1
- import { FetchMethod } from './index';
2
- import { CustomEntityListOptions, ListOptions } from './query-interfaces';
3
- import { SharedStorageAdapter } from './storage-adapter';
4
- interface ListResults {
5
- results: {
6
- key: string;
7
- value: any;
8
- }[];
9
- nextCursor?: string;
10
- }
11
- interface Timer {
12
- stop(tags?: Record<string, string>): void;
13
- }
14
- interface Counter {
15
- incr(): void;
16
- }
17
- interface Timing {
18
- measure(): Timer;
19
- }
20
- interface Metrics {
21
- timing(name: string, tags?: Record<string, string>): Timing;
22
- counter(name: string, tags?: Record<string, string>): Counter;
23
- }
24
- export declare type StoreType = 'typed' | 'untyped';
25
- export declare type OperationType = 'get' | 'set' | 'query' | 'delete';
26
- export declare class GlobalStorage implements SharedStorageAdapter {
27
- private apiClient;
28
- private readonly getMetrics;
29
- private readonly endpoint;
30
- constructor(apiClient: FetchMethod, getMetrics: () => Metrics | undefined);
31
- get(key: string): Promise<any>;
32
- getSecret(key: string): Promise<any>;
33
- list(options: ListOptions): Promise<ListResults>;
34
- listCustomEntities(options: CustomEntityListOptions): Promise<ListResults>;
35
- set(key: string, value: any): Promise<void>;
36
- setSecret(key: string, value: any): Promise<void>;
37
- delete(key: string): Promise<void>;
38
- deleteSecret(key: string): Promise<void>;
39
- getEntity<T>(entityName: string, entityKey: string): Promise<T>;
40
- setEntity<T>(entityName: string, entityKey: string, value: T): Promise<void>;
41
- deleteEntity(entityName: string, entityKey: string): Promise<void>;
42
- private getInternal;
43
- private getEntityInternal;
44
- private buildRequest;
45
- private query;
46
- private mutation;
47
- private wrapInMetric;
48
- }
49
- export {};
50
- //# sourceMappingURL=global-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAInD,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,UAAU,WAAW;IACnB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkBD,UAAU,KAAK;IACb,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,UAAU,OA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