@forge/storage 1.5.14 → 1.5.15-experimental-03ab603
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/out/__test__/global-storage.test.js +600 -539
- package/out/entity-storage/query-api.js +56 -19
- package/out/entity-storage/storage-builder.js +2 -0
- package/out/errors.js +1 -1
- package/out/global-storage.d.ts +3 -2
- package/out/global-storage.d.ts.map +1 -1
- package/out/global-storage.js +16 -3
- package/out/gql-queries.d.ts +11 -0
- package/out/gql-queries.d.ts.map +1 -1
- package/out/gql-queries.js +113 -82
- package/out/index.d.ts +2 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/query-api.js +19 -5
- package/out/storage-adapter.d.ts +14 -0
- package/out/storage-adapter.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -2,17 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomEntityBuilder = exports.CustomEntityIndexBuilder = void 0;
|
|
4
4
|
class CustomEntityQueryBuilder {
|
|
5
|
+
globalStorage;
|
|
6
|
+
queryOptions;
|
|
5
7
|
constructor(globalStorage, queryOptions = {}) {
|
|
6
8
|
this.globalStorage = globalStorage;
|
|
7
9
|
this.queryOptions = queryOptions;
|
|
8
|
-
this.queryOptions =
|
|
10
|
+
this.queryOptions = {
|
|
11
|
+
...queryOptions
|
|
12
|
+
};
|
|
9
13
|
}
|
|
10
14
|
clone(overrides) {
|
|
11
|
-
return new (Object.getPrototypeOf(this).constructor)(this.globalStorage,
|
|
15
|
+
return new (Object.getPrototypeOf(this).constructor)(this.globalStorage, {
|
|
16
|
+
...this.queryOptions,
|
|
17
|
+
...overrides
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
where(condition) {
|
|
14
21
|
return this.clone({
|
|
15
|
-
range:
|
|
22
|
+
range: {
|
|
23
|
+
...condition
|
|
24
|
+
}
|
|
16
25
|
});
|
|
17
26
|
}
|
|
18
27
|
sort(sort) {
|
|
@@ -32,7 +41,7 @@ class CustomEntityQueryBuilder {
|
|
|
32
41
|
}
|
|
33
42
|
async getOne() {
|
|
34
43
|
const { results } = await this.limit(1).getMany();
|
|
35
|
-
return results
|
|
44
|
+
return results?.[0];
|
|
36
45
|
}
|
|
37
46
|
async getMany() {
|
|
38
47
|
if (!this.queryOptions.entityName) {
|
|
@@ -41,7 +50,7 @@ class CustomEntityQueryBuilder {
|
|
|
41
50
|
if (!this.queryOptions.indexName) {
|
|
42
51
|
throw new Error('indexName is mandatory');
|
|
43
52
|
}
|
|
44
|
-
const queryOptions =
|
|
53
|
+
const queryOptions = { ...this.queryOptions };
|
|
45
54
|
if (!queryOptions.filterOperator && queryOptions.filters) {
|
|
46
55
|
queryOptions.filterOperator = 'and';
|
|
47
56
|
}
|
|
@@ -49,41 +58,55 @@ class CustomEntityQueryBuilder {
|
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
class CustomEntityAndFilterQueryBuilder extends CustomEntityQueryBuilder {
|
|
61
|
+
globalStorage;
|
|
62
|
+
queryOptions;
|
|
52
63
|
constructor(globalStorage, queryOptions = {}) {
|
|
53
64
|
super(globalStorage, queryOptions);
|
|
54
65
|
this.globalStorage = globalStorage;
|
|
55
66
|
this.queryOptions = queryOptions;
|
|
56
|
-
this.queryOptions =
|
|
67
|
+
this.queryOptions = {
|
|
68
|
+
...queryOptions
|
|
69
|
+
};
|
|
57
70
|
}
|
|
58
71
|
andFilter(field, condition) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
const newQueryOptions = {
|
|
73
|
+
...this.queryOptions
|
|
74
|
+
};
|
|
75
|
+
newQueryOptions.filters = [...(this.queryOptions.filters ?? []), { property: field, ...condition }];
|
|
62
76
|
newQueryOptions.filterOperator = 'and';
|
|
63
77
|
return new CustomEntityAndFilterQueryBuilder(this.globalStorage, newQueryOptions);
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
80
|
class CustomEntityOrFilterQueryBuilder extends CustomEntityQueryBuilder {
|
|
81
|
+
globalStorage;
|
|
82
|
+
queryOptions;
|
|
67
83
|
constructor(globalStorage, queryOptions = {}) {
|
|
68
84
|
super(globalStorage, queryOptions);
|
|
69
85
|
this.globalStorage = globalStorage;
|
|
70
86
|
this.queryOptions = queryOptions;
|
|
71
|
-
this.queryOptions =
|
|
87
|
+
this.queryOptions = {
|
|
88
|
+
...queryOptions
|
|
89
|
+
};
|
|
72
90
|
}
|
|
73
91
|
orFilter(field, condition) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
const newQueryOptions = {
|
|
93
|
+
...this.queryOptions
|
|
94
|
+
};
|
|
95
|
+
newQueryOptions.filters = [...(this.queryOptions.filters ?? []), { property: field, ...condition }];
|
|
77
96
|
newQueryOptions.filterOperator = 'or';
|
|
78
97
|
return new CustomEntityOrFilterQueryBuilder(this.globalStorage, newQueryOptions);
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
100
|
class CustomEntityFilterQueryBuilder extends CustomEntityQueryBuilder {
|
|
101
|
+
globalStorage;
|
|
102
|
+
queryOptions;
|
|
82
103
|
constructor(globalStorage, queryOptions = {}) {
|
|
83
104
|
super(globalStorage, queryOptions);
|
|
84
105
|
this.globalStorage = globalStorage;
|
|
85
106
|
this.queryOptions = queryOptions;
|
|
86
|
-
this.queryOptions =
|
|
107
|
+
this.queryOptions = {
|
|
108
|
+
...queryOptions
|
|
109
|
+
};
|
|
87
110
|
}
|
|
88
111
|
andFilter(field, condition) {
|
|
89
112
|
return new CustomEntityAndFilterQueryBuilder(this.globalStorage, this.queryOptions).andFilter(field, condition);
|
|
@@ -93,25 +116,39 @@ class CustomEntityFilterQueryBuilder extends CustomEntityQueryBuilder {
|
|
|
93
116
|
}
|
|
94
117
|
}
|
|
95
118
|
class CustomEntityIndexBuilder {
|
|
119
|
+
globalStorage;
|
|
120
|
+
queryOptions;
|
|
96
121
|
constructor(globalStorage, queryOptions = {}) {
|
|
97
122
|
this.globalStorage = globalStorage;
|
|
98
123
|
this.queryOptions = queryOptions;
|
|
99
|
-
this.queryOptions =
|
|
124
|
+
this.queryOptions = {
|
|
125
|
+
...queryOptions
|
|
126
|
+
};
|
|
100
127
|
}
|
|
101
128
|
index(name, indexOptions) {
|
|
102
|
-
const indexProperties = indexOptions ?
|
|
103
|
-
return new CustomEntityFilterQueryBuilder(this.globalStorage,
|
|
129
|
+
const indexProperties = indexOptions ? { indexName: name, ...indexOptions } : { indexName: name };
|
|
130
|
+
return new CustomEntityFilterQueryBuilder(this.globalStorage, {
|
|
131
|
+
...this.queryOptions,
|
|
132
|
+
...indexProperties
|
|
133
|
+
});
|
|
104
134
|
}
|
|
105
135
|
}
|
|
106
136
|
exports.CustomEntityIndexBuilder = CustomEntityIndexBuilder;
|
|
107
137
|
class CustomEntityBuilder {
|
|
138
|
+
globalStorage;
|
|
139
|
+
queryOptions;
|
|
108
140
|
constructor(globalStorage, queryOptions = {}) {
|
|
109
141
|
this.globalStorage = globalStorage;
|
|
110
142
|
this.queryOptions = queryOptions;
|
|
111
|
-
this.queryOptions =
|
|
143
|
+
this.queryOptions = {
|
|
144
|
+
...queryOptions
|
|
145
|
+
};
|
|
112
146
|
}
|
|
113
147
|
entity(name) {
|
|
114
|
-
return new CustomEntityIndexBuilder(this.globalStorage,
|
|
148
|
+
return new CustomEntityIndexBuilder(this.globalStorage, {
|
|
149
|
+
...this.queryOptions,
|
|
150
|
+
entityName: name
|
|
151
|
+
});
|
|
115
152
|
}
|
|
116
153
|
}
|
|
117
154
|
exports.CustomEntityBuilder = CustomEntityBuilder;
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EntityStorageBuilder = void 0;
|
|
4
4
|
const query_api_1 = require("./query-api");
|
|
5
5
|
class EntityStorageBuilder {
|
|
6
|
+
entityName;
|
|
7
|
+
globalStorage;
|
|
6
8
|
constructor(entityName, globalStorage) {
|
|
7
9
|
this.entityName = entityName;
|
|
8
10
|
this.globalStorage = globalStorage;
|
package/out/errors.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.APIError = exports.getErrorMessage = exports.getErrorMessageFromCode = void 0;
|
|
4
4
|
const getErrorMessageFromCode = (code, message) => {
|
|
5
|
-
return message
|
|
5
|
+
return message ?? code;
|
|
6
6
|
};
|
|
7
7
|
exports.getErrorMessageFromCode = getErrorMessageFromCode;
|
|
8
8
|
const getErrorMessage = (statusCode) => {
|
package/out/global-storage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FetchMethod } from './index';
|
|
1
|
+
import { BulkResponse, FetchMethod } from './index';
|
|
2
2
|
import { CustomEntityListOptions, ListOptions } from './query-interfaces';
|
|
3
|
-
import { SharedStorageAdapter } from './storage-adapter';
|
|
3
|
+
import { BulkItem, SharedStorageAdapter } from './storage-adapter';
|
|
4
4
|
interface ListResults {
|
|
5
5
|
results: {
|
|
6
6
|
key: string;
|
|
@@ -20,6 +20,7 @@ export declare class GlobalStorage implements SharedStorageAdapter {
|
|
|
20
20
|
listCustomEntities(options: CustomEntityListOptions): Promise<ListResults>;
|
|
21
21
|
set(key: string, value: any): Promise<void>;
|
|
22
22
|
setSecret(key: string, value: any): Promise<void>;
|
|
23
|
+
bulkSet(items: BulkItem[]): Promise<BulkResponse>;
|
|
23
24
|
delete(key: string): Promise<void>;
|
|
24
25
|
deleteSecret(key: string): Promise<void>;
|
|
25
26
|
getEntity<T>(entityName: string, entityKey: string): Promise<T>;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO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,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;CAoBvB"}
|
package/out/global-storage.js
CHANGED
|
@@ -25,10 +25,12 @@ async function getResponseBody(response) {
|
|
|
25
25
|
return responseBody.data;
|
|
26
26
|
}
|
|
27
27
|
class GlobalStorage {
|
|
28
|
+
getAppContextAri;
|
|
29
|
+
apiClient;
|
|
30
|
+
endpoint = '/forge/entities/graphql';
|
|
28
31
|
constructor(getAppContextAri, apiClient) {
|
|
29
32
|
this.getAppContextAri = getAppContextAri;
|
|
30
33
|
this.apiClient = apiClient;
|
|
31
|
-
this.endpoint = '/forge/entities/graphql';
|
|
32
34
|
}
|
|
33
35
|
doGetAppContextAri() {
|
|
34
36
|
return typeof this.getAppContextAri === 'function' ? this.getAppContextAri() : this.getAppContextAri;
|
|
@@ -72,6 +74,17 @@ class GlobalStorage {
|
|
|
72
74
|
const requestBody = gql_queries_1.UntypedQueries.set(this.doGetAppContextAri(), key, value, true);
|
|
73
75
|
await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity');
|
|
74
76
|
}
|
|
77
|
+
async bulkSet(items) {
|
|
78
|
+
const requestBody = gql_queries_1.UntypedQueries.bulkSet(this.doGetAppContextAri(), items, false);
|
|
79
|
+
const response = await this.mutation(requestBody, 'appStorage', 'setAppStoredEntities');
|
|
80
|
+
const parsedResponse = await getResponseBody(response);
|
|
81
|
+
const failedKeys = parsedResponse.appStorage.setAppStoredEntities.failedKeys;
|
|
82
|
+
const savedKeys = parsedResponse.appStorage.setAppStoredEntities.savedKeys;
|
|
83
|
+
return {
|
|
84
|
+
savedKeys,
|
|
85
|
+
failedKeys
|
|
86
|
+
};
|
|
87
|
+
}
|
|
75
88
|
async delete(key) {
|
|
76
89
|
const requestBody = gql_queries_1.UntypedQueries.delete(this.doGetAppContextAri(), key, false);
|
|
77
90
|
await this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity');
|
|
@@ -94,12 +107,12 @@ class GlobalStorage {
|
|
|
94
107
|
async getInternal(key, encrypted) {
|
|
95
108
|
const requestBody = gql_queries_1.UntypedQueries.get(this.doGetAppContextAri(), key, encrypted);
|
|
96
109
|
const { appStoredEntity: { value } } = await this.query(requestBody);
|
|
97
|
-
return value
|
|
110
|
+
return value ?? undefined;
|
|
98
111
|
}
|
|
99
112
|
async getEntityInternal(entityName, entityKey) {
|
|
100
113
|
const requestBody = gql_queries_1.CustomEntityQueries.get(this.doGetAppContextAri(), entityName, entityKey);
|
|
101
114
|
const { appStoredCustomEntity: { value } } = await this.query(requestBody);
|
|
102
|
-
return value
|
|
115
|
+
return value ?? undefined;
|
|
103
116
|
}
|
|
104
117
|
buildRequest(requestBody) {
|
|
105
118
|
return {
|
package/out/gql-queries.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CustomEntityListOptions, ListOptions } from './query-interfaces';
|
|
2
|
+
import { BulkItem } from './storage-adapter';
|
|
2
3
|
export declare class UntypedQueries {
|
|
3
4
|
static get: (contextAri: string, key: string, encrypted: boolean) => {
|
|
4
5
|
query: string;
|
|
@@ -47,6 +48,16 @@ export declare class UntypedQueries {
|
|
|
47
48
|
limit: number | null;
|
|
48
49
|
};
|
|
49
50
|
};
|
|
51
|
+
static bulkSet: (contextAri: string, values: BulkItem[], encrypted: boolean) => {
|
|
52
|
+
query: string;
|
|
53
|
+
variables: {
|
|
54
|
+
input: {
|
|
55
|
+
contextAri: string;
|
|
56
|
+
entities: BulkItem[];
|
|
57
|
+
encrypted: boolean;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
50
61
|
}
|
|
51
62
|
export declare class CustomEntityQueries {
|
|
52
63
|
static get: (contextAri: string, entityName: string, key: string) => {
|
package/out/gql-queries.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,qBAAa,cAAc;IACzB,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,aAAa,OAAO;;;;;;;MAcrE;IAEH,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,SAAS,GAAG,aAAa,OAAO;;;;;;;;;;MA0BjF;IAEH,OAAc,MAAM,eAAgB,MAAM,OAAO,MAAM,aAAa,OAAO;;;;;;;;;MAyBxE;IAEH,OAAc,SAAS,eAAgB,MAAM,WAAW,WAAW;;;;;;;;MAuBhE;IAEH,OAAc,mBAAmB,eAAgB,MAAM,WAAW,WAAW;;;;;;;;MAuB1E;IAEH,OAAc,OAAO,eAAgB,MAAM,UAAU,QAAQ,EAAE,aAAa,OAAO;;;;;;;;;MA0BhF;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;;;;;;;;;;MA0BjF;IAEH,OAAc,MAAM,eAAgB,MAAM,cAAc,MAAM,OAAO,MAAM;;;;;;;;;MAyBxE;IAEH,OAAc,SAAS,eAAgB,MAAM,WAAW,uBAAuB;;;;;;;;;;;;;;;MAuC7E;CACH"}
|
package/out/gql-queries.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomEntityQueries = exports.UntypedQueries = void 0;
|
|
4
4
|
class UntypedQueries {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
UntypedQueries.get = (contextAri, key, encrypted) => ({
|
|
8
|
-
query: `
|
|
5
|
+
static get = (contextAri, key, encrypted) => ({
|
|
6
|
+
query: `
|
|
9
7
|
query forge_app_getApplicationStorageEntity($contextAri: ID!, $key: ID!, $encrypted: Boolean!) {
|
|
10
8
|
appStoredEntity(contextAri: $contextAri, key: $key, encrypted: $encrypted) {
|
|
11
9
|
key
|
|
@@ -13,14 +11,14 @@ UntypedQueries.get = (contextAri, key, encrypted) => ({
|
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
variables: {
|
|
15
|
+
contextAri,
|
|
16
|
+
key,
|
|
17
|
+
encrypted
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
static set = (contextAri, key, value, encrypted) => ({
|
|
21
|
+
query: `
|
|
24
22
|
mutation forge_app_setApplicationStorageEntity($input: SetAppStoredEntityMutationInput!) {
|
|
25
23
|
appStorage{
|
|
26
24
|
setAppStoredEntity(input: $input) {
|
|
@@ -37,17 +35,17 @@ UntypedQueries.set = (contextAri, key, value, encrypted) => ({
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
`,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
variables: {
|
|
39
|
+
input: {
|
|
40
|
+
contextAri,
|
|
41
|
+
key,
|
|
42
|
+
value,
|
|
43
|
+
encrypted
|
|
44
|
+
}
|
|
46
45
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
query: `
|
|
46
|
+
});
|
|
47
|
+
static delete = (contextAri, key, encrypted) => ({
|
|
48
|
+
query: `
|
|
51
49
|
mutation forge_app_deleteApplicationStorageEntity($input: DeleteAppStoredEntityMutationInput!) {
|
|
52
50
|
appStorage {
|
|
53
51
|
deleteAppStoredEntity(input: $input) {
|
|
@@ -64,17 +62,15 @@ UntypedQueries.delete = (contextAri, key, encrypted) => ({
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
`,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
variables: {
|
|
66
|
+
input: {
|
|
67
|
+
contextAri,
|
|
68
|
+
key,
|
|
69
|
+
encrypted
|
|
70
|
+
}
|
|
72
71
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
UntypedQueries.listQuery = (contextAri, options) => {
|
|
76
|
-
var _a, _b, _c;
|
|
77
|
-
return ({
|
|
72
|
+
});
|
|
73
|
+
static listQuery = (contextAri, options) => ({
|
|
78
74
|
query: `
|
|
79
75
|
query forge_app_getApplicationStorageEntities($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
|
|
80
76
|
appStoredEntities(contextAri: $contextAri, where: $where, after: $cursor, first: $limit) {
|
|
@@ -91,15 +87,12 @@ UntypedQueries.listQuery = (contextAri, options) => {
|
|
|
91
87
|
`,
|
|
92
88
|
variables: {
|
|
93
89
|
contextAri,
|
|
94
|
-
where:
|
|
95
|
-
cursor:
|
|
96
|
-
limit:
|
|
90
|
+
where: options.where ?? null,
|
|
91
|
+
cursor: options.cursor ?? null,
|
|
92
|
+
limit: options.limit ?? null
|
|
97
93
|
}
|
|
98
94
|
});
|
|
99
|
-
|
|
100
|
-
UntypedQueries.listQueryForCleanup = (contextAri, options) => {
|
|
101
|
-
var _a, _b, _c;
|
|
102
|
-
return ({
|
|
95
|
+
static listQueryForCleanup = (contextAri, options) => ({
|
|
103
96
|
query: `
|
|
104
97
|
query forge_app_getApplicationStorageEntitiesForCleanup($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
|
|
105
98
|
appStoredEntitiesForCleanup(contextAri: $contextAri, where: $where, after: $cursor, first: $limit) {
|
|
@@ -116,17 +109,43 @@ UntypedQueries.listQueryForCleanup = (contextAri, options) => {
|
|
|
116
109
|
`,
|
|
117
110
|
variables: {
|
|
118
111
|
contextAri,
|
|
119
|
-
where:
|
|
120
|
-
cursor:
|
|
121
|
-
limit:
|
|
112
|
+
where: options.where ?? null,
|
|
113
|
+
cursor: options.cursor ?? null,
|
|
114
|
+
limit: options.limit ?? null
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
static bulkSet = (contextAri, values, encrypted) => ({
|
|
118
|
+
query: `
|
|
119
|
+
mutation forge_app_setApplicationStorageEntities($input: SetAppStoredEntitiesMutationInput!) {
|
|
120
|
+
appStorage{
|
|
121
|
+
setAppStoredEntities(input: $input) {
|
|
122
|
+
success
|
|
123
|
+
savedKeys
|
|
124
|
+
failedKeys
|
|
125
|
+
errors {
|
|
126
|
+
message
|
|
127
|
+
extensions {
|
|
128
|
+
errorType
|
|
129
|
+
statusCode
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`,
|
|
136
|
+
variables: {
|
|
137
|
+
input: {
|
|
138
|
+
contextAri,
|
|
139
|
+
entities: values,
|
|
140
|
+
encrypted
|
|
141
|
+
}
|
|
122
142
|
}
|
|
123
143
|
});
|
|
124
|
-
};
|
|
125
|
-
class CustomEntityQueries {
|
|
126
144
|
}
|
|
127
|
-
exports.
|
|
128
|
-
CustomEntityQueries
|
|
129
|
-
|
|
145
|
+
exports.UntypedQueries = UntypedQueries;
|
|
146
|
+
class CustomEntityQueries {
|
|
147
|
+
static get = (contextAri, entityName, key) => ({
|
|
148
|
+
query: `
|
|
130
149
|
query forge_app_getApplicationStorageCustomEntity ($contextAri: ID!, $key: ID!, $entityName: String!) {
|
|
131
150
|
appStoredCustomEntity(contextAri: $contextAri, key: $key, entityName: $entityName) {
|
|
132
151
|
value
|
|
@@ -135,14 +154,14 @@ CustomEntityQueries.get = (contextAri, entityName, key) => ({
|
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
`,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
157
|
+
variables: {
|
|
158
|
+
contextAri,
|
|
159
|
+
entityName,
|
|
160
|
+
key
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
static set = (contextAri, entityName, key, value) => ({
|
|
164
|
+
query: `
|
|
146
165
|
mutation forge_app_setApplicationStorageCustomEntity($input: SetAppStoredCustomEntityMutationInput!) {
|
|
147
166
|
appStorageCustomEntity{
|
|
148
167
|
setAppStoredCustomEntity(input: $input) {
|
|
@@ -159,17 +178,17 @@ CustomEntityQueries.set = (contextAri, entityName, key, value) => ({
|
|
|
159
178
|
}
|
|
160
179
|
}
|
|
161
180
|
`,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
181
|
+
variables: {
|
|
182
|
+
input: {
|
|
183
|
+
contextAri,
|
|
184
|
+
entityName,
|
|
185
|
+
key,
|
|
186
|
+
value
|
|
187
|
+
}
|
|
168
188
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
query: `
|
|
189
|
+
});
|
|
190
|
+
static delete = (contextAri, entityName, key) => ({
|
|
191
|
+
query: `
|
|
173
192
|
mutation forge_app_deleteApplicationStorageCustomEntity($input: DeleteAppStoredCustomEntityMutationInput!) {
|
|
174
193
|
appStorageCustomEntity {
|
|
175
194
|
deleteAppStoredCustomEntity(input: $input) {
|
|
@@ -186,17 +205,17 @@ CustomEntityQueries.delete = (contextAri, entityName, key) => ({
|
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
207
|
`,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
208
|
+
variables: {
|
|
209
|
+
input: {
|
|
210
|
+
contextAri,
|
|
211
|
+
entityName,
|
|
212
|
+
key
|
|
213
|
+
}
|
|
194
214
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
query: `
|
|
215
|
+
});
|
|
216
|
+
static listQuery = (contextAri, options) => {
|
|
217
|
+
return {
|
|
218
|
+
query: `
|
|
200
219
|
query AppStorageCustomEntityQueries ($contextAri: ID!, $entityName: String!, $indexName: String!, $range: AppStoredCustomEntityRange, $filters: AppStoredCustomEntityFilters, $sort:SortOrder, $limit: Int, $cursor: String, $partition: [AppStoredCustomEntityFieldValue!]) {
|
|
201
220
|
appStoredCustomEntities(contextAri: $contextAri, entityName: $entityName, indexName: $indexName, range: $range, filters: $filters, sort:$sort, limit: $limit, cursor: $cursor, partition: $partition) {
|
|
202
221
|
edges {
|
|
@@ -215,12 +234,24 @@ CustomEntityQueries.listQuery = (contextAri, options) => {
|
|
|
215
234
|
}
|
|
216
235
|
}
|
|
217
236
|
`,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
237
|
+
variables: {
|
|
238
|
+
contextAri,
|
|
239
|
+
entityName: options.entityName,
|
|
240
|
+
indexName: options.indexName,
|
|
241
|
+
range: options.range,
|
|
242
|
+
...(options.filters && options.filters.length
|
|
243
|
+
? {
|
|
244
|
+
filters: {
|
|
245
|
+
[options.filterOperator || 'and']: options.filters
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
: {}),
|
|
249
|
+
...(options.partition ? { partition: options.partition } : {}),
|
|
250
|
+
...(options.sort ? { sort: options.sort } : {}),
|
|
251
|
+
...(options.cursor ? { cursor: options.cursor } : {}),
|
|
252
|
+
...(options.limit ? { limit: options.limit } : {})
|
|
223
253
|
}
|
|
224
|
-
|
|
254
|
+
};
|
|
225
255
|
};
|
|
226
|
-
}
|
|
256
|
+
}
|
|
257
|
+
exports.CustomEntityQueries = CustomEntityQueries;
|
package/out/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const getStorageInstanceWithQuery: (adapter: GlobalStorage) => {
|
|
|
11
11
|
getSecret: (key: string) => Promise<any>;
|
|
12
12
|
setSecret: (key: string, value: any) => Promise<void>;
|
|
13
13
|
deleteSecret: (key: string) => Promise<void>;
|
|
14
|
+
bulkSet: (items: import("./storage-adapter").BulkItem[]) => Promise<import("./storage-adapter").BulkResponse>;
|
|
14
15
|
query: () => DefaultQueryBuilder;
|
|
15
16
|
entity: <T>(entityName: string) => EntityStorageBuilder<T>;
|
|
16
17
|
};
|
|
@@ -21,5 +22,6 @@ export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Entit
|
|
|
21
22
|
export { EntityStorageBuilder, EntityStorageBuilderType } from './entity-storage';
|
|
22
23
|
export { Value, SortOrder } from './query-interfaces';
|
|
23
24
|
export { APIError } from './errors';
|
|
25
|
+
export { BulkItem, BulkResponse } from './storage-adapter';
|
|
24
26
|
export { CustomEntityIndexBuilder } from './entity-storage/query-api';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MA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AAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const getStorageInstanceWithQuery = (adapter) => {
|
|
|
11
11
|
getSecret: adapter.getSecret.bind(adapter),
|
|
12
12
|
setSecret: adapter.setSecret.bind(adapter),
|
|
13
13
|
deleteSecret: adapter.deleteSecret.bind(adapter),
|
|
14
|
+
bulkSet: adapter.bulkSet.bind(adapter),
|
|
14
15
|
query: () => new query_api_1.DefaultQueryBuilder(adapter),
|
|
15
16
|
entity: (entityName) => new entity_storage_1.EntityStorageBuilder(entityName, adapter)
|
|
16
17
|
};
|
package/out/query-api.js
CHANGED
|
@@ -2,20 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultQueryBuilder = void 0;
|
|
4
4
|
class DefaultQueryBuilder {
|
|
5
|
+
globalStorage;
|
|
6
|
+
queryOptions;
|
|
5
7
|
constructor(globalStorage, queryOptions = {}) {
|
|
6
8
|
this.globalStorage = globalStorage;
|
|
7
9
|
this.queryOptions = queryOptions;
|
|
8
10
|
}
|
|
9
11
|
where(field, where) {
|
|
10
|
-
return new DefaultQueryBuilder(this.globalStorage,
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
return new DefaultQueryBuilder(this.globalStorage, {
|
|
13
|
+
...this.queryOptions,
|
|
14
|
+
where: [
|
|
15
|
+
{
|
|
16
|
+
field,
|
|
17
|
+
...where
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
});
|
|
13
21
|
}
|
|
14
22
|
cursor(cursor) {
|
|
15
|
-
return new DefaultQueryBuilder(this.globalStorage,
|
|
23
|
+
return new DefaultQueryBuilder(this.globalStorage, {
|
|
24
|
+
...this.queryOptions,
|
|
25
|
+
cursor
|
|
26
|
+
});
|
|
16
27
|
}
|
|
17
28
|
limit(limit) {
|
|
18
|
-
return new DefaultQueryBuilder(this.globalStorage,
|
|
29
|
+
return new DefaultQueryBuilder(this.globalStorage, {
|
|
30
|
+
...this.queryOptions,
|
|
31
|
+
limit
|
|
32
|
+
});
|
|
19
33
|
}
|
|
20
34
|
async getOne() {
|
|
21
35
|
const { results } = await this.limit(1).getMany();
|
package/out/storage-adapter.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { EntityStorageBuilderType } from './entity-storage';
|
|
2
2
|
import { BeginsWithClause, BetweenClause, ExistsClause, DoesNotExistClause, GreaterThanClause, GreaterThanEqualToClause, StartsWith, NotEqualTo, In, LessThanClause, LessThanEqualToClause, ContainsClause, DoesNotContainClause, IsNotEqualToClause, EqualToClause } from './query-interfaces';
|
|
3
|
+
export interface BulkItem {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string | number | boolean | Record<string, any> | any[];
|
|
6
|
+
}
|
|
7
|
+
interface FailedKey {
|
|
8
|
+
key: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BulkResponse {
|
|
12
|
+
savedKeys: string[];
|
|
13
|
+
failedKeys: FailedKey[];
|
|
14
|
+
}
|
|
3
15
|
export interface StorageAdapter {
|
|
4
16
|
get(key: string): Promise<any>;
|
|
5
17
|
set(key: string, value: string | number | boolean | Record<string, any> | any[]): Promise<void>;
|
|
@@ -7,6 +19,7 @@ export interface StorageAdapter {
|
|
|
7
19
|
getSecret(key: string): Promise<any>;
|
|
8
20
|
setSecret(key: string, value: any): Promise<void>;
|
|
9
21
|
deleteSecret(key: string): Promise<void>;
|
|
22
|
+
bulkSet(items: BulkItem[]): Promise<BulkResponse>;
|
|
10
23
|
}
|
|
11
24
|
export interface EntityStorageAdapter {
|
|
12
25
|
getEntity<T>(entityName: string, entityKey: string): Promise<T>;
|
|
@@ -39,4 +52,5 @@ export interface ListResult<T = object> {
|
|
|
39
52
|
results: Result<T>[];
|
|
40
53
|
nextCursor?: string;
|
|
41
54
|
}
|
|
55
|
+
export {};
|
|
42
56
|
//# sourceMappingURL=storage-adapter.d.ts.map
|