@forge/storage 1.3.2-next.8 → 1.4.0-next.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isIn = exports.isNotEqualTo = void 0;
3
+ exports.FilterConditions = exports.WhereConditions = exports.isIn = exports.isNotEqualTo = void 0;
4
4
  function isNotEqualTo(value) {
5
5
  return {
6
6
  condition: 'NOT_EQUAL_TO',
@@ -15,3 +15,98 @@ function isIn(values) {
15
15
  };
16
16
  }
17
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
+ };
@@ -0,0 +1,2 @@
1
+ export { EntityStorageBuilder, EntityStorageBuilderType } from './storage-builder';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
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; } });
@@ -0,0 +1,48 @@
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
@@ -0,0 +1 @@
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;IAMpB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAMxC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAmBxC;AAED,cAAM,iCAAiC,CAAC,CAAC,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;IAE1E,SAAS,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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"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomEntityBuilder = exports.CustomEntityIndexBuilder = void 0;
4
+ class CustomEntityQueryBuilder {
5
+ constructor(globalStorage, queryOptions = {}) {
6
+ this.globalStorage = globalStorage;
7
+ this.queryOptions = queryOptions;
8
+ this.queryOptions = Object.assign({}, queryOptions);
9
+ }
10
+ clone(overrides) {
11
+ return new (Object.getPrototypeOf(this).constructor)(this.globalStorage, Object.assign(Object.assign({}, this.queryOptions), overrides));
12
+ }
13
+ where(condition) {
14
+ return this.clone({
15
+ range: Object.assign({}, condition)
16
+ });
17
+ }
18
+ sort(sort) {
19
+ return this.clone({
20
+ sort
21
+ });
22
+ }
23
+ cursor(cursor) {
24
+ return this.clone({
25
+ cursor
26
+ });
27
+ }
28
+ limit(limit) {
29
+ return this.clone({
30
+ limit
31
+ });
32
+ }
33
+ async getOne() {
34
+ const { results } = await this.limit(1).getMany();
35
+ return results === null || results === void 0 ? void 0 : results[0];
36
+ }
37
+ async getMany() {
38
+ if (!this.queryOptions.entityName) {
39
+ throw new Error('entityName is mandatory');
40
+ }
41
+ if (!this.queryOptions.indexName) {
42
+ throw new Error('indexName is mandatory');
43
+ }
44
+ const queryOptions = Object.assign({}, this.queryOptions);
45
+ if (!queryOptions.filterOperator && queryOptions.filters) {
46
+ queryOptions.filterOperator = 'and';
47
+ }
48
+ return this.globalStorage.listCustomEntities(this.queryOptions);
49
+ }
50
+ }
51
+ class CustomEntityAndFilterQueryBuilder extends CustomEntityQueryBuilder {
52
+ constructor(globalStorage, queryOptions = {}) {
53
+ super(globalStorage, queryOptions);
54
+ this.globalStorage = globalStorage;
55
+ this.queryOptions = queryOptions;
56
+ this.queryOptions = Object.assign({}, queryOptions);
57
+ }
58
+ andFilter(field, condition) {
59
+ var _a;
60
+ const newQueryOptions = Object.assign({}, this.queryOptions);
61
+ newQueryOptions.filters = [...((_a = this.queryOptions.filters) !== null && _a !== void 0 ? _a : []), Object.assign({ property: field }, condition)];
62
+ newQueryOptions.filterOperator = 'and';
63
+ return new CustomEntityAndFilterQueryBuilder(this.globalStorage, newQueryOptions);
64
+ }
65
+ }
66
+ class CustomEntityOrFilterQueryBuilder extends CustomEntityQueryBuilder {
67
+ constructor(globalStorage, queryOptions = {}) {
68
+ super(globalStorage, queryOptions);
69
+ this.globalStorage = globalStorage;
70
+ this.queryOptions = queryOptions;
71
+ this.queryOptions = Object.assign({}, queryOptions);
72
+ }
73
+ orFilter(field, condition) {
74
+ var _a;
75
+ const newQueryOptions = Object.assign({}, this.queryOptions);
76
+ newQueryOptions.filters = [...((_a = this.queryOptions.filters) !== null && _a !== void 0 ? _a : []), Object.assign({ property: field }, condition)];
77
+ newQueryOptions.filterOperator = 'or';
78
+ return new CustomEntityOrFilterQueryBuilder(this.globalStorage, newQueryOptions);
79
+ }
80
+ }
81
+ class CustomEntityFilterQueryBuilder extends CustomEntityQueryBuilder {
82
+ constructor(globalStorage, queryOptions = {}) {
83
+ super(globalStorage, queryOptions);
84
+ this.globalStorage = globalStorage;
85
+ this.queryOptions = queryOptions;
86
+ this.queryOptions = Object.assign({}, queryOptions);
87
+ }
88
+ andFilter(field, condition) {
89
+ return new CustomEntityAndFilterQueryBuilder(this.globalStorage, this.queryOptions).andFilter(field, condition);
90
+ }
91
+ orFilter(field, condition) {
92
+ return new CustomEntityOrFilterQueryBuilder(this.globalStorage, this.queryOptions).orFilter(field, condition);
93
+ }
94
+ }
95
+ class CustomEntityIndexBuilder {
96
+ constructor(globalStorage, queryOptions = {}) {
97
+ this.globalStorage = globalStorage;
98
+ this.queryOptions = queryOptions;
99
+ this.queryOptions = Object.assign({}, queryOptions);
100
+ }
101
+ index(name, indexOptions) {
102
+ const indexProperties = indexOptions ? Object.assign({ indexName: name }, indexOptions) : { indexName: name };
103
+ return new CustomEntityFilterQueryBuilder(this.globalStorage, Object.assign(Object.assign({}, this.queryOptions), indexProperties));
104
+ }
105
+ }
106
+ exports.CustomEntityIndexBuilder = CustomEntityIndexBuilder;
107
+ class CustomEntityBuilder {
108
+ constructor(globalStorage, queryOptions = {}) {
109
+ this.globalStorage = globalStorage;
110
+ this.queryOptions = queryOptions;
111
+ this.queryOptions = Object.assign({}, queryOptions);
112
+ }
113
+ entity(name) {
114
+ return new CustomEntityIndexBuilder(this.globalStorage, Object.assign(Object.assign({}, this.queryOptions), { entityName: name }));
115
+ }
116
+ }
117
+ exports.CustomEntityBuilder = CustomEntityBuilder;
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
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;IAC7D,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,aAAa;gBAAzC,UAAU,EAAE,MAAM,EAAU,aAAa,EAAE,mBAAmB;IAElF,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"}
@@ -0,0 +1,23 @@
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
+ constructor(entityName, globalStorage) {
7
+ this.entityName = entityName;
8
+ this.globalStorage = globalStorage;
9
+ }
10
+ query() {
11
+ return new query_api_1.CustomEntityBuilder(this.globalStorage).entity(this.entityName);
12
+ }
13
+ get(entityKey) {
14
+ return this.globalStorage.getEntity(this.entityName, entityKey);
15
+ }
16
+ set(entityKey, value) {
17
+ return this.globalStorage.setEntity(this.entityName, entityKey, value);
18
+ }
19
+ delete(entityKey) {
20
+ return this.globalStorage.deleteEntity(this.entityName, entityKey);
21
+ }
22
+ }
23
+ exports.EntityStorageBuilder = EntityStorageBuilder;
@@ -1,6 +1,6 @@
1
1
  import { FetchMethod } from './index';
2
- import { ListOptions } from './queries';
3
- import { StorageAdapter } from './storage-adapter';
2
+ import { CustomEntityListOptions, ListOptions } from './query-interfaces';
3
+ import { SharedStorageAdapter } from './storage-adapter';
4
4
  interface ListResults {
5
5
  results: {
6
6
  key: string;
@@ -8,7 +8,7 @@ interface ListResults {
8
8
  }[];
9
9
  nextCursor?: string;
10
10
  }
11
- export declare class GlobalStorage implements StorageAdapter {
11
+ export declare class GlobalStorage implements SharedStorageAdapter {
12
12
  private getAppContextAri;
13
13
  private apiClient;
14
14
  private readonly endpoint;
@@ -17,11 +17,16 @@ export declare class GlobalStorage implements StorageAdapter {
17
17
  get(key: string): Promise<any>;
18
18
  getSecret(key: string): Promise<any>;
19
19
  list(options: ListOptions): Promise<ListResults>;
20
+ listCustomEntities(options: CustomEntityListOptions): Promise<ListResults>;
20
21
  set(key: string, value: any): Promise<void>;
21
22
  setSecret(key: string, value: any): Promise<void>;
22
23
  delete(key: string): Promise<void>;
23
24
  deleteSecret(key: string): Promise<void>;
25
+ getEntity<T>(entityName: string, entityKey: string): Promise<T>;
26
+ setEntity<T>(entityName: string, entityKey: string, value: T): Promise<void>;
27
+ deleteEntity(entityName: string, entityKey: string): Promise<void>;
24
28
  private getInternal;
29
+ private getEntityInternal;
25
30
  private buildRequest;
26
31
  private query;
27
32
  private mutation;
@@ -1 +1 @@
1
- {"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EAA8C,WAAW,EAAuB,MAAM,WAAW,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,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;AA4CD,qBAAa,aAAc,YAAW,cAAc;IAEtC,OAAO,CAAC,gBAAgB;IAA2B,OAAO,CAAC,SAAS;IADhF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAClC,gBAAgB,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EAAU,SAAS,EAAE,WAAW;IAE7F,OAAO,CAAC,kBAAkB;IAIpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAqBhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjD,MAAM,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,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/D,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5E,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAK1D,WAAW;YAUX,iBAAiB;IAU/B,OAAO,CAAC,YAAY;YAUN,KAAK;YAML,QAAQ;CAqBvB"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GlobalStorage = void 0;
4
4
  const errors_1 = require("./errors");
5
- const queries_1 = require("./queries");
5
+ const gql_queries_1 = require("./gql-queries");
6
6
  function assertNoErrors(errors) {
7
7
  if (errors && errors.length > 0) {
8
8
  const { message, extensions: { errorType } } = errors[0];
@@ -41,8 +41,8 @@ class GlobalStorage {
41
41
  }
42
42
  async list(options) {
43
43
  const requestBody = process.env.IS_CLEANUP_FUNCTION === 'true'
44
- ? (0, queries_1.listQueryForCleanup)(this.doGetAppContextAri(), options)
45
- : (0, queries_1.listQuery)(this.doGetAppContextAri(), options);
44
+ ? gql_queries_1.UntypedQueries.listQueryForCleanup(this.doGetAppContextAri(), options)
45
+ : gql_queries_1.UntypedQueries.listQuery(this.doGetAppContextAri(), options);
46
46
  const response = await this.query(requestBody);
47
47
  const edges = process.env.IS_CLEANUP_FUNCTION === 'true'
48
48
  ? response.appStoredEntitiesForCleanup.edges
@@ -54,27 +54,55 @@ class GlobalStorage {
54
54
  nextCursor
55
55
  };
56
56
  }
57
+ async listCustomEntities(options) {
58
+ var _a;
59
+ const requestBody = gql_queries_1.CustomEntityQueries.listQuery(this.doGetAppContextAri(), options);
60
+ const response = await this.query(requestBody);
61
+ const edges = response.appStoredCustomEntities.edges;
62
+ const nextCursor = (_a = edges === null || edges === void 0 ? void 0 : edges[edges.length - 1]) === null || _a === void 0 ? void 0 : _a.cursor;
63
+ const results = edges.map(({ node }) => node);
64
+ return {
65
+ results,
66
+ nextCursor
67
+ };
68
+ }
57
69
  async set(key, value) {
58
- const requestBody = (0, queries_1.setQuery)(this.doGetAppContextAri(), key, value, false);
59
- await this.mutation(requestBody, 'setAppStoredEntity');
70
+ const requestBody = gql_queries_1.UntypedQueries.set(this.doGetAppContextAri(), key, value, false);
71
+ await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity');
60
72
  }
61
73
  async setSecret(key, value) {
62
- const requestBody = (0, queries_1.setQuery)(this.doGetAppContextAri(), key, value, true);
63
- await this.mutation(requestBody, 'setAppStoredEntity');
74
+ const requestBody = gql_queries_1.UntypedQueries.set(this.doGetAppContextAri(), key, value, true);
75
+ await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity');
64
76
  }
65
77
  async delete(key) {
66
- const requestBody = (0, queries_1.deleteQuery)(this.doGetAppContextAri(), key, false);
67
- await this.mutation(requestBody, 'deleteAppStoredEntity');
78
+ const requestBody = gql_queries_1.UntypedQueries.delete(this.doGetAppContextAri(), key, false);
79
+ await this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity');
68
80
  }
69
81
  async deleteSecret(key) {
70
- const requestBody = (0, queries_1.deleteQuery)(this.doGetAppContextAri(), key, true);
71
- await this.mutation(requestBody, 'deleteAppStoredEntity');
82
+ const requestBody = gql_queries_1.UntypedQueries.delete(this.doGetAppContextAri(), key, true);
83
+ await this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity');
84
+ }
85
+ async getEntity(entityName, entityKey) {
86
+ return this.getEntityInternal(entityName, entityKey);
87
+ }
88
+ async setEntity(entityName, entityKey, value) {
89
+ const requestBody = gql_queries_1.CustomEntityQueries.set(this.doGetAppContextAri(), entityName, entityKey, value);
90
+ await this.mutation(requestBody, 'appStorageCustomEntity', 'setAppStoredCustomEntity');
91
+ }
92
+ async deleteEntity(entityName, entityKey) {
93
+ const requestBody = gql_queries_1.CustomEntityQueries.delete(this.doGetAppContextAri(), entityName, entityKey);
94
+ await this.mutation(requestBody, 'appStorageCustomEntity', 'deleteAppStoredCustomEntity');
72
95
  }
73
96
  async getInternal(key, encrypted) {
74
- const requestBody = (0, queries_1.getQuery)(this.doGetAppContextAri(), key, encrypted);
97
+ const requestBody = gql_queries_1.UntypedQueries.get(this.doGetAppContextAri(), key, encrypted);
75
98
  const { appStoredEntity: { value } } = await this.query(requestBody);
76
99
  return value !== null && value !== void 0 ? value : undefined;
77
100
  }
101
+ async getEntityInternal(entityName, entityKey) {
102
+ const requestBody = gql_queries_1.CustomEntityQueries.get(this.doGetAppContextAri(), entityName, entityKey);
103
+ const { appStoredCustomEntity: { value } } = await this.query(requestBody);
104
+ return value !== null && value !== void 0 ? value : undefined;
105
+ }
78
106
  buildRequest(requestBody) {
79
107
  return {
80
108
  method: 'POST',
@@ -88,9 +116,9 @@ class GlobalStorage {
88
116
  const response = await this.apiClient(this.endpoint, this.buildRequest(body));
89
117
  return await getResponseBody(response);
90
118
  }
91
- async mutation(body, mutationMethod) {
119
+ async mutation(body, namespace, mutationMethod) {
92
120
  const response = await this.apiClient(this.endpoint, this.buildRequest(body));
93
- const { appStorage: { [mutationMethod]: { success, errors } } } = await getResponseBody(response);
121
+ const { [namespace]: { [mutationMethod]: { success, errors } } } = await getResponseBody(response);
94
122
  assertNoErrors(errors);
95
123
  if (!success) {
96
124
  throw errors_1.APIError.forStatus(500);
@@ -0,0 +1,98 @@
1
+ import { CustomEntityListOptions, ListOptions } from './query-interfaces';
2
+ export declare class UntypedQueries {
3
+ static get: (contextAri: string, key: string, encrypted: boolean) => {
4
+ query: string;
5
+ variables: {
6
+ contextAri: string;
7
+ key: string;
8
+ encrypted: boolean;
9
+ };
10
+ };
11
+ static set: (contextAri: string, key: string, value: any, encrypted: boolean) => {
12
+ query: string;
13
+ variables: {
14
+ input: {
15
+ contextAri: string;
16
+ key: string;
17
+ value: any;
18
+ encrypted: boolean;
19
+ };
20
+ };
21
+ };
22
+ static delete: (contextAri: string, key: string, encrypted: boolean) => {
23
+ query: string;
24
+ variables: {
25
+ input: {
26
+ contextAri: string;
27
+ key: string;
28
+ encrypted: boolean;
29
+ };
30
+ };
31
+ };
32
+ static listQuery: (contextAri: string, options: ListOptions) => {
33
+ query: string;
34
+ variables: {
35
+ contextAri: string;
36
+ where: import("./query-interfaces").WhereClause[] | null;
37
+ cursor: string | null;
38
+ limit: number | null;
39
+ };
40
+ };
41
+ static listQueryForCleanup: (contextAri: string, options: ListOptions) => {
42
+ query: string;
43
+ variables: {
44
+ contextAri: string;
45
+ where: import("./query-interfaces").WhereClause[] | null;
46
+ cursor: string | null;
47
+ limit: number | null;
48
+ };
49
+ };
50
+ }
51
+ export declare class CustomEntityQueries {
52
+ static get: (contextAri: string, entityName: string, key: string) => {
53
+ query: string;
54
+ variables: {
55
+ contextAri: string;
56
+ entityName: string;
57
+ key: string;
58
+ };
59
+ };
60
+ static set: (contextAri: string, entityName: string, key: string, value: any) => {
61
+ query: string;
62
+ variables: {
63
+ input: {
64
+ contextAri: string;
65
+ entityName: string;
66
+ key: string;
67
+ value: any;
68
+ };
69
+ };
70
+ };
71
+ static delete: (contextAri: string, entityName: string, key: string) => {
72
+ query: string;
73
+ variables: {
74
+ input: {
75
+ contextAri: string;
76
+ entityName: string;
77
+ key: string;
78
+ };
79
+ };
80
+ };
81
+ static listQuery: (contextAri: string, options: CustomEntityListOptions) => {
82
+ query: string;
83
+ variables: {
84
+ limit?: number | undefined;
85
+ cursor?: string | undefined;
86
+ sort?: import("./query-interfaces").SortOrder | undefined;
87
+ partition?: import("./query-interfaces").CustomEntityPartitionValue[] | undefined;
88
+ filters?: {
89
+ [x: string]: import("./query-interfaces").FilterClause[];
90
+ } | undefined;
91
+ contextAri: string;
92
+ entityName: string | undefined;
93
+ indexName: string | undefined;
94
+ range: import("./query-interfaces").RangeClause | undefined;
95
+ };
96
+ };
97
+ }
98
+ //# sourceMappingURL=gql-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gql-queries.d.ts","sourceRoot":"","sources":["../src/gql-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1E,qBAAa,cAAc;IACzB,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,aAAa,OAAO;;;;;;;MAcrE;IAEH,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,SAAS,GAAG,aAAa,OAAO;;;;;;;;;;MAyBjF;IAEH,OAAc,MAAM,eAAgB,MAAM,OAAO,MAAM,aAAa,OAAO;;;;;;;;;MAwBxE;IAEH,OAAc,SAAS,eAAgB,MAAM,WAAW,WAAW;;;;;;;;MAuBhE;IAEH,OAAc,mBAAmB,eAAgB,MAAM,WAAW,WAAW;;;;;;;;MAuB1E;CACJ;AAED,qBAAa,mBAAmB;IAC9B,OAAc,GAAG,eAAgB,MAAM,cAAc,MAAM,OAAO,MAAM;;;;;;;MAerE;IAEH,OAAc,GAAG,eAAgB,MAAM,cAAc,MAAM,OAAO,MAAM,SAAS,GAAG;;;;;;;;;;MAyBjF;IAEH,OAAc,MAAM,eAAgB,MAAM,cAAc,MAAM,OAAO,MAAM;;;;;;;;;MAwBxE;IAEH,OAAc,SAAS,eAAgB,MAAM,WAAW,uBAAuB;;;;;;;;;;;;;;;MAuC7E;CACH"}