@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.
- package/LICENSE.txt +1 -1
- package/package.json +11 -2
- package/README.md +0 -50
- package/out/__test__/errors.test.d.ts +0 -2
- package/out/__test__/errors.test.d.ts.map +0 -1
- package/out/__test__/errors.test.js +0 -34
- package/out/__test__/global-storage.test.d.ts +0 -2
- package/out/__test__/global-storage.test.d.ts.map +0 -1
- package/out/__test__/global-storage.test.js +0 -833
- package/out/__test__/list-api.test.d.ts +0 -2
- package/out/__test__/list-api.test.d.ts.map +0 -1
- package/out/__test__/list-api.test.js +0 -650
- package/out/conditions.d.ts +0 -3
- package/out/conditions.d.ts.map +0 -1
- package/out/conditions.js +0 -10
- package/out/eap/conditions.d.ts +0 -40
- package/out/eap/conditions.d.ts.map +0 -1
- package/out/eap/conditions.js +0 -112
- package/out/eap/index.d.ts +0 -2
- package/out/eap/index.d.ts.map +0 -1
- package/out/eap/index.js +0 -4
- package/out/entity-storage/index.d.ts +0 -2
- package/out/entity-storage/index.d.ts.map +0 -1
- package/out/entity-storage/index.js +0 -5
- package/out/entity-storage/query-api.d.ts +0 -48
- package/out/entity-storage/query-api.d.ts.map +0 -1
- package/out/entity-storage/query-api.js +0 -154
- package/out/entity-storage/storage-builder.d.ts +0 -20
- package/out/entity-storage/storage-builder.d.ts.map +0 -1
- package/out/entity-storage/storage-builder.js +0 -25
- package/out/errors.d.ts +0 -9
- package/out/errors.d.ts.map +0 -1
- package/out/errors.js +0 -41
- package/out/global-storage.d.ts +0 -50
- package/out/global-storage.d.ts.map +0 -1
- package/out/global-storage.js +0 -156
- package/out/gql-queries.d.ts +0 -81
- package/out/gql-queries.d.ts.map +0 -1
- package/out/gql-queries.js +0 -200
- package/out/index.d.ts +0 -49
- package/out/index.d.ts.map +0 -1
- package/out/index.js +0 -33
- package/out/query-api.d.ts +0 -14
- package/out/query-api.d.ts.map +0 -1
- package/out/query-api.js +0 -44
- package/out/query-interfaces.d.ts +0 -113
- package/out/query-interfaces.d.ts.map +0 -1
- package/out/query-interfaces.js +0 -8
- package/out/storage-adapter.d.ts +0 -42
- package/out/storage-adapter.d.ts.map +0 -1
- package/out/storage-adapter.js +0 -2
package/out/global-storage.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GlobalStorage = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
const gql_queries_1 = require("./gql-queries");
|
|
6
|
-
function assertNoErrors(errors) {
|
|
7
|
-
if (errors && errors.length > 0) {
|
|
8
|
-
const { message, extensions: { errorType } } = errors[0];
|
|
9
|
-
throw errors_1.APIError.forErrorCode(errorType, message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
async function getResponseBody(response) {
|
|
13
|
-
if (response.status !== 200) {
|
|
14
|
-
throw errors_1.APIError.forStatus(response.status);
|
|
15
|
-
}
|
|
16
|
-
const responseText = await response.text();
|
|
17
|
-
let responseBody;
|
|
18
|
-
try {
|
|
19
|
-
responseBody = JSON.parse(responseText);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
throw errors_1.APIError.forUnexpected(`Response text was not a valid JSON: ${responseText}`);
|
|
23
|
-
}
|
|
24
|
-
assertNoErrors(responseBody.errors);
|
|
25
|
-
return responseBody.data;
|
|
26
|
-
}
|
|
27
|
-
class GlobalStorage {
|
|
28
|
-
apiClient;
|
|
29
|
-
getMetrics;
|
|
30
|
-
endpoint = '/forge/entities/graphql';
|
|
31
|
-
constructor(apiClient, getMetrics) {
|
|
32
|
-
this.apiClient = apiClient;
|
|
33
|
-
this.getMetrics = getMetrics;
|
|
34
|
-
}
|
|
35
|
-
async get(key) {
|
|
36
|
-
return this.getInternal(key, false);
|
|
37
|
-
}
|
|
38
|
-
async getSecret(key) {
|
|
39
|
-
return this.getInternal(key, true);
|
|
40
|
-
}
|
|
41
|
-
async list(options) {
|
|
42
|
-
const requestBody = gql_queries_1.UntypedQueries.listQuery(options);
|
|
43
|
-
const response = await this.wrapInMetric('untyped', 'query', false, async () => await this.query(requestBody));
|
|
44
|
-
const edges = response.appStoredEntities.edges;
|
|
45
|
-
const nextCursor = edges.length > 0 ? edges[edges.length - 1].cursor : undefined;
|
|
46
|
-
const results = edges.map(({ node }) => node);
|
|
47
|
-
return {
|
|
48
|
-
results,
|
|
49
|
-
nextCursor
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async listCustomEntities(options) {
|
|
53
|
-
const requestBody = gql_queries_1.CustomEntityQueries.listQuery(options);
|
|
54
|
-
const response = await this.wrapInMetric('typed', 'query', false, async () => await this.query(requestBody));
|
|
55
|
-
const edges = response.appStoredCustomEntities.edges;
|
|
56
|
-
const results = edges.map(({ node }) => node);
|
|
57
|
-
return {
|
|
58
|
-
results,
|
|
59
|
-
nextCursor: response.appStoredCustomEntities.cursor || null
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
async set(key, value) {
|
|
63
|
-
const requestBody = gql_queries_1.UntypedQueries.set(key, value, false);
|
|
64
|
-
await this.wrapInMetric('untyped', 'set', false, async () => await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity'));
|
|
65
|
-
}
|
|
66
|
-
async setSecret(key, value) {
|
|
67
|
-
const requestBody = gql_queries_1.UntypedQueries.set(key, value, true);
|
|
68
|
-
await this.wrapInMetric('untyped', 'set', true, async () => await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity'));
|
|
69
|
-
}
|
|
70
|
-
async delete(key) {
|
|
71
|
-
const requestBody = gql_queries_1.UntypedQueries.delete(key, false);
|
|
72
|
-
await this.wrapInMetric('untyped', 'delete', false, async () => this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity'));
|
|
73
|
-
}
|
|
74
|
-
async deleteSecret(key) {
|
|
75
|
-
const requestBody = gql_queries_1.UntypedQueries.delete(key, true);
|
|
76
|
-
await this.wrapInMetric('untyped', 'delete', true, async () => this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity'));
|
|
77
|
-
}
|
|
78
|
-
async getEntity(entityName, entityKey) {
|
|
79
|
-
return this.getEntityInternal(entityName, entityKey);
|
|
80
|
-
}
|
|
81
|
-
async setEntity(entityName, entityKey, value) {
|
|
82
|
-
const requestBody = gql_queries_1.CustomEntityQueries.set(entityName, entityKey, value);
|
|
83
|
-
await this.wrapInMetric('typed', 'set', false, async () => this.mutation(requestBody, 'appStorageCustomEntity', 'setAppStoredCustomEntity'));
|
|
84
|
-
}
|
|
85
|
-
async deleteEntity(entityName, entityKey) {
|
|
86
|
-
const requestBody = gql_queries_1.CustomEntityQueries.delete(entityName, entityKey);
|
|
87
|
-
await this.wrapInMetric('typed', 'delete', false, async () => await this.mutation(requestBody, 'appStorageCustomEntity', 'deleteAppStoredCustomEntity'));
|
|
88
|
-
}
|
|
89
|
-
async getInternal(key, encrypted) {
|
|
90
|
-
const requestBody = gql_queries_1.UntypedQueries.get(key, encrypted);
|
|
91
|
-
const { appStoredEntity: { value } } = await this.wrapInMetric('untyped', 'get', encrypted, async () => await this.query(requestBody));
|
|
92
|
-
return value ?? undefined;
|
|
93
|
-
}
|
|
94
|
-
async getEntityInternal(entityName, entityKey) {
|
|
95
|
-
const requestBody = gql_queries_1.CustomEntityQueries.get(entityName, entityKey);
|
|
96
|
-
const { appStoredCustomEntity: { value } } = await this.wrapInMetric('typed', 'get', false, async () => await this.query(requestBody));
|
|
97
|
-
return value ?? undefined;
|
|
98
|
-
}
|
|
99
|
-
buildRequest(requestBody) {
|
|
100
|
-
return {
|
|
101
|
-
method: 'POST',
|
|
102
|
-
body: JSON.stringify(requestBody),
|
|
103
|
-
headers: {
|
|
104
|
-
'content-type': 'application/json'
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
async query(body) {
|
|
109
|
-
const response = await this.apiClient(this.endpoint, this.buildRequest(body));
|
|
110
|
-
return await getResponseBody(response);
|
|
111
|
-
}
|
|
112
|
-
async mutation(body, namespace, mutationMethod) {
|
|
113
|
-
const response = await this.apiClient(this.endpoint, this.buildRequest(body));
|
|
114
|
-
const { [namespace]: { [mutationMethod]: { success, errors } } } = await getResponseBody(response);
|
|
115
|
-
assertNoErrors(errors);
|
|
116
|
-
if (!success) {
|
|
117
|
-
throw errors_1.APIError.forStatus(500);
|
|
118
|
-
}
|
|
119
|
-
return response;
|
|
120
|
-
}
|
|
121
|
-
async wrapInMetric(store, operation, encrypted, fn) {
|
|
122
|
-
const metrics = this.getMetrics();
|
|
123
|
-
if (!metrics) {
|
|
124
|
-
return await fn();
|
|
125
|
-
}
|
|
126
|
-
const timer = metrics
|
|
127
|
-
.timing('forge.runtime.storage.operation.latency', { store, operation, encrypted: String(encrypted) })
|
|
128
|
-
.measure();
|
|
129
|
-
try {
|
|
130
|
-
const result = await fn();
|
|
131
|
-
timer.stop({ success: 'true' });
|
|
132
|
-
metrics
|
|
133
|
-
.counter('forge.runtime.storage.operation', {
|
|
134
|
-
store,
|
|
135
|
-
operation,
|
|
136
|
-
encrypted: String(encrypted),
|
|
137
|
-
success: 'true'
|
|
138
|
-
})
|
|
139
|
-
.incr();
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
timer.stop({ success: 'false' });
|
|
144
|
-
metrics
|
|
145
|
-
.counter('forge.runtime.storage.operation', {
|
|
146
|
-
store,
|
|
147
|
-
operation,
|
|
148
|
-
encrypted: String(encrypted),
|
|
149
|
-
success: 'false'
|
|
150
|
-
})
|
|
151
|
-
.incr();
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.GlobalStorage = GlobalStorage;
|
package/out/gql-queries.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { CustomEntityListOptions, ListOptions } from './query-interfaces';
|
|
2
|
-
export declare class UntypedQueries {
|
|
3
|
-
static get: (key: string, encrypted: boolean) => {
|
|
4
|
-
query: string;
|
|
5
|
-
variables: {
|
|
6
|
-
key: string;
|
|
7
|
-
encrypted: boolean;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
static set: (key: string, value: any, encrypted: boolean) => {
|
|
11
|
-
query: string;
|
|
12
|
-
variables: {
|
|
13
|
-
input: {
|
|
14
|
-
key: string;
|
|
15
|
-
value: any;
|
|
16
|
-
encrypted: boolean;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
static delete: (key: string, encrypted: boolean) => {
|
|
21
|
-
query: string;
|
|
22
|
-
variables: {
|
|
23
|
-
input: {
|
|
24
|
-
key: string;
|
|
25
|
-
encrypted: boolean;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
static listQuery: (options: ListOptions) => {
|
|
30
|
-
query: string;
|
|
31
|
-
variables: {
|
|
32
|
-
where: import("./query-interfaces").WhereClause[] | null;
|
|
33
|
-
cursor: string | null;
|
|
34
|
-
limit: number | null;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export declare class CustomEntityQueries {
|
|
39
|
-
static get: (entityName: string, key: string) => {
|
|
40
|
-
query: string;
|
|
41
|
-
variables: {
|
|
42
|
-
entityName: string;
|
|
43
|
-
key: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
static set: (entityName: string, key: string, value: any) => {
|
|
47
|
-
query: string;
|
|
48
|
-
variables: {
|
|
49
|
-
input: {
|
|
50
|
-
entityName: string;
|
|
51
|
-
key: string;
|
|
52
|
-
value: any;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
static delete: (entityName: string, key: string) => {
|
|
57
|
-
query: string;
|
|
58
|
-
variables: {
|
|
59
|
-
input: {
|
|
60
|
-
entityName: string;
|
|
61
|
-
key: string;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
static listQuery: (options: CustomEntityListOptions) => {
|
|
66
|
-
query: string;
|
|
67
|
-
variables: {
|
|
68
|
-
limit?: number | undefined;
|
|
69
|
-
cursor?: string | undefined;
|
|
70
|
-
sort?: import("./query-interfaces").SortOrder | undefined;
|
|
71
|
-
partition?: import("./query-interfaces").CustomEntityPartitionValue[] | undefined;
|
|
72
|
-
filters?: {
|
|
73
|
-
[x: string]: import("./query-interfaces").FilterClause[];
|
|
74
|
-
} | undefined;
|
|
75
|
-
entityName: string | undefined;
|
|
76
|
-
indexName: string | undefined;
|
|
77
|
-
range: import("./query-interfaces").RangeClause | undefined;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=gql-queries.d.ts.map
|
package/out/gql-queries.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,QAAS,MAAM,aAAa,OAAO;;;;;;MAajD;IAEH,OAAc,GAAG,QAAS,MAAM,SAAS,GAAG,aAAa,OAAO;;;;;;;;;MAyB7D;IAEH,OAAc,MAAM,QAAS,MAAM,aAAa,OAAO;;;;;;;;MAwBpD;IAEH,OAAc,SAAS,YAAa,WAAW;;;;;;;MAqB5C;CACJ;AAED,qBAAa,mBAAmB;IAC9B,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM;;;;;;MAcjD;IAEH,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,SAAS,GAAG;;;;;;;;;MAyB7D;IAEH,OAAc,MAAM,eAAgB,MAAM,OAAO,MAAM;;;;;;;;MAwBpD;IAEH,OAAc,SAAS,YAAa,uBAAuB;;;;;;;;;;;;;;MAsCzD;CACH"}
|
package/out/gql-queries.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomEntityQueries = exports.UntypedQueries = void 0;
|
|
4
|
-
class UntypedQueries {
|
|
5
|
-
static get = (key, encrypted) => ({
|
|
6
|
-
query: `
|
|
7
|
-
query forge_app_getApplicationStorageEntity($key: ID!, $encrypted: Boolean!) {
|
|
8
|
-
appStoredEntity(key: $key, encrypted: $encrypted) {
|
|
9
|
-
key
|
|
10
|
-
value
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`,
|
|
14
|
-
variables: {
|
|
15
|
-
key,
|
|
16
|
-
encrypted
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
static set = (key, value, encrypted) => ({
|
|
20
|
-
query: `
|
|
21
|
-
mutation forge_app_setApplicationStorageEntity($input: SetAppStoredEntityMutationInput!) {
|
|
22
|
-
appStorage{
|
|
23
|
-
setAppStoredEntity(input: $input) {
|
|
24
|
-
success
|
|
25
|
-
|
|
26
|
-
errors {
|
|
27
|
-
message
|
|
28
|
-
extensions {
|
|
29
|
-
errorType
|
|
30
|
-
statusCode
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`,
|
|
37
|
-
variables: {
|
|
38
|
-
input: {
|
|
39
|
-
key,
|
|
40
|
-
value,
|
|
41
|
-
encrypted
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
static delete = (key, encrypted) => ({
|
|
46
|
-
query: `
|
|
47
|
-
mutation forge_app_deleteApplicationStorageEntity($input: DeleteAppStoredEntityMutationInput!) {
|
|
48
|
-
appStorage {
|
|
49
|
-
deleteAppStoredEntity(input: $input) {
|
|
50
|
-
success
|
|
51
|
-
|
|
52
|
-
errors {
|
|
53
|
-
message
|
|
54
|
-
extensions {
|
|
55
|
-
errorType
|
|
56
|
-
statusCode
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`,
|
|
63
|
-
variables: {
|
|
64
|
-
input: {
|
|
65
|
-
key,
|
|
66
|
-
encrypted
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
static listQuery = (options) => ({
|
|
71
|
-
query: `
|
|
72
|
-
query forge_app_getApplicationStorageEntities($where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
|
|
73
|
-
appStoredEntities(where: $where, after: $cursor, first: $limit) {
|
|
74
|
-
edges {
|
|
75
|
-
node {
|
|
76
|
-
value
|
|
77
|
-
key
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
cursor
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
`,
|
|
85
|
-
variables: {
|
|
86
|
-
where: options.where ?? null,
|
|
87
|
-
cursor: options.cursor ?? null,
|
|
88
|
-
limit: options.limit ?? null
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
exports.UntypedQueries = UntypedQueries;
|
|
93
|
-
class CustomEntityQueries {
|
|
94
|
-
static get = (entityName, key) => ({
|
|
95
|
-
query: `
|
|
96
|
-
query forge_app_getApplicationStorageCustomEntity ($key: ID!, $entityName: String!) {
|
|
97
|
-
appStoredCustomEntity(key: $key, entityName: $entityName) {
|
|
98
|
-
value
|
|
99
|
-
entityName
|
|
100
|
-
key
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`,
|
|
104
|
-
variables: {
|
|
105
|
-
entityName,
|
|
106
|
-
key
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
static set = (entityName, key, value) => ({
|
|
110
|
-
query: `
|
|
111
|
-
mutation forge_app_setApplicationStorageCustomEntity($input: SetAppStoredCustomEntityMutationInput!) {
|
|
112
|
-
appStorageCustomEntity{
|
|
113
|
-
setAppStoredCustomEntity(input: $input) {
|
|
114
|
-
success
|
|
115
|
-
|
|
116
|
-
errors {
|
|
117
|
-
message
|
|
118
|
-
extensions {
|
|
119
|
-
errorType
|
|
120
|
-
statusCode
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
`,
|
|
127
|
-
variables: {
|
|
128
|
-
input: {
|
|
129
|
-
entityName,
|
|
130
|
-
key,
|
|
131
|
-
value
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
static delete = (entityName, key) => ({
|
|
136
|
-
query: `
|
|
137
|
-
mutation forge_app_deleteApplicationStorageCustomEntity($input: DeleteAppStoredCustomEntityMutationInput!) {
|
|
138
|
-
appStorageCustomEntity {
|
|
139
|
-
deleteAppStoredCustomEntity(input: $input) {
|
|
140
|
-
success
|
|
141
|
-
|
|
142
|
-
errors {
|
|
143
|
-
message
|
|
144
|
-
extensions {
|
|
145
|
-
errorType
|
|
146
|
-
statusCode
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
`,
|
|
153
|
-
variables: {
|
|
154
|
-
input: {
|
|
155
|
-
entityName,
|
|
156
|
-
key
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
static listQuery = (options) => {
|
|
161
|
-
return {
|
|
162
|
-
query: `
|
|
163
|
-
query AppStorageCustomEntityQueries ($entityName: String!, $indexName: String!, $range: AppStoredCustomEntityRange, $filters: AppStoredCustomEntityFilters, $sort:SortOrder, $limit: Int, $cursor: String, $partition: [AppStoredCustomEntityFieldValue!]) {
|
|
164
|
-
appStoredCustomEntities(entityName: $entityName, indexName: $indexName, range: $range, filters: $filters, sort:$sort, limit: $limit, cursor: $cursor, partition: $partition) {
|
|
165
|
-
edges {
|
|
166
|
-
node {
|
|
167
|
-
key
|
|
168
|
-
value
|
|
169
|
-
}
|
|
170
|
-
cursor
|
|
171
|
-
}
|
|
172
|
-
pageInfo {
|
|
173
|
-
hasNextPage
|
|
174
|
-
hasPreviousPage
|
|
175
|
-
}
|
|
176
|
-
totalCount
|
|
177
|
-
cursor
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
`,
|
|
181
|
-
variables: {
|
|
182
|
-
entityName: options.entityName,
|
|
183
|
-
indexName: options.indexName,
|
|
184
|
-
range: options.range,
|
|
185
|
-
...(options.filters && options.filters.length
|
|
186
|
-
? {
|
|
187
|
-
filters: {
|
|
188
|
-
[options.filterOperator || 'and']: options.filters
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
: {}),
|
|
192
|
-
...(options.partition ? { partition: options.partition } : {}),
|
|
193
|
-
...(options.sort ? { sort: options.sort } : {}),
|
|
194
|
-
...(options.cursor ? { cursor: options.cursor } : {}),
|
|
195
|
-
...(options.limit ? { limit: options.limit } : {})
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
exports.CustomEntityQueries = CustomEntityQueries;
|
package/out/index.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { EntityStorageBuilder } from './entity-storage';
|
|
2
|
-
import { GlobalStorage } from './global-storage';
|
|
3
|
-
import { DefaultQueryBuilder } from './query-api';
|
|
4
|
-
export interface Headers {
|
|
5
|
-
append: (name: string, value: string) => void;
|
|
6
|
-
delete: (name: string) => void;
|
|
7
|
-
get: (name: string) => string | null;
|
|
8
|
-
has: (name: string) => boolean;
|
|
9
|
-
set: (name: string, value: string) => void;
|
|
10
|
-
forEach: (callbackfn: (value: string, key: string) => void) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare type RequestRedirect = 'error' | 'follow' | 'manual';
|
|
13
|
-
export interface RequestInit {
|
|
14
|
-
body?: ArrayBuffer | string | URLSearchParams;
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
method?: string;
|
|
17
|
-
redirect?: RequestRedirect;
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
}
|
|
20
|
-
interface Response {
|
|
21
|
-
json: () => Promise<any>;
|
|
22
|
-
text: () => Promise<string>;
|
|
23
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
24
|
-
ok: boolean;
|
|
25
|
-
status: number;
|
|
26
|
-
statusText: string;
|
|
27
|
-
headers: Headers;
|
|
28
|
-
}
|
|
29
|
-
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText'>;
|
|
30
|
-
export declare type FetchMethod = (url: string, init: RequestInit) => Promise<APIResponse>;
|
|
31
|
-
export declare const getStorageInstanceWithQuery: (adapter: GlobalStorage) => {
|
|
32
|
-
get: (key: string) => Promise<any>;
|
|
33
|
-
set: (key: string, value: any) => Promise<void>;
|
|
34
|
-
delete: (key: string) => Promise<void>;
|
|
35
|
-
getSecret: (key: string) => Promise<any>;
|
|
36
|
-
setSecret: (key: string, value: any) => Promise<void>;
|
|
37
|
-
deleteSecret: (key: string) => Promise<void>;
|
|
38
|
-
query: () => DefaultQueryBuilder;
|
|
39
|
-
entity: <T>(entityName: string) => EntityStorageBuilder<T>;
|
|
40
|
-
};
|
|
41
|
-
export { GlobalStorage } from './global-storage';
|
|
42
|
-
export { startsWith } from './conditions';
|
|
43
|
-
export { WhereConditions, FilterConditions } from './eap/conditions';
|
|
44
|
-
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, EntityStorageApi, WherePredicate, FilterPredicate } from './storage-adapter';
|
|
45
|
-
export { EntityStorageBuilder, EntityStorageBuilderType } from './entity-storage';
|
|
46
|
-
export { Value, SortOrder } from './query-interfaces';
|
|
47
|
-
export { APIError } from './errors';
|
|
48
|
-
export { CustomEntityIndexBuilder } from './entity-storage/query-api';
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACrC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE3C,OAAO,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CACrE;AAED,oBAAY,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,eAAe,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAExC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,oBAAY,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC;AAC3G,oBAAY,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAEnF,eAAO,MAAM,2BAA2B,YAAa,aAAa;;;;;;;iBAQnD,mBAAmB;4BACN,MAAM;CAEjC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,EACV,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,cAAc,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,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/out/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomEntityIndexBuilder = exports.APIError = exports.SortOrder = exports.EntityStorageBuilder = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.GlobalStorage = exports.getStorageInstanceWithQuery = void 0;
|
|
4
|
-
const entity_storage_1 = require("./entity-storage");
|
|
5
|
-
const query_api_1 = require("./query-api");
|
|
6
|
-
const getStorageInstanceWithQuery = (adapter) => {
|
|
7
|
-
return {
|
|
8
|
-
get: adapter.get.bind(adapter),
|
|
9
|
-
set: adapter.set.bind(adapter),
|
|
10
|
-
delete: adapter.delete.bind(adapter),
|
|
11
|
-
getSecret: adapter.getSecret.bind(adapter),
|
|
12
|
-
setSecret: adapter.setSecret.bind(adapter),
|
|
13
|
-
deleteSecret: adapter.deleteSecret.bind(adapter),
|
|
14
|
-
query: () => new query_api_1.DefaultQueryBuilder(adapter),
|
|
15
|
-
entity: (entityName) => new entity_storage_1.EntityStorageBuilder(entityName, adapter)
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.getStorageInstanceWithQuery = getStorageInstanceWithQuery;
|
|
19
|
-
var global_storage_1 = require("./global-storage");
|
|
20
|
-
Object.defineProperty(exports, "GlobalStorage", { enumerable: true, get: function () { return global_storage_1.GlobalStorage; } });
|
|
21
|
-
var conditions_1 = require("./conditions");
|
|
22
|
-
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return conditions_1.startsWith; } });
|
|
23
|
-
var conditions_2 = require("./eap/conditions");
|
|
24
|
-
Object.defineProperty(exports, "WhereConditions", { enumerable: true, get: function () { return conditions_2.WhereConditions; } });
|
|
25
|
-
Object.defineProperty(exports, "FilterConditions", { enumerable: true, get: function () { return conditions_2.FilterConditions; } });
|
|
26
|
-
var entity_storage_2 = require("./entity-storage");
|
|
27
|
-
Object.defineProperty(exports, "EntityStorageBuilder", { enumerable: true, get: function () { return entity_storage_2.EntityStorageBuilder; } });
|
|
28
|
-
var query_interfaces_1 = require("./query-interfaces");
|
|
29
|
-
Object.defineProperty(exports, "SortOrder", { enumerable: true, get: function () { return query_interfaces_1.SortOrder; } });
|
|
30
|
-
var errors_1 = require("./errors");
|
|
31
|
-
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return errors_1.APIError; } });
|
|
32
|
-
var query_api_2 = require("./entity-storage/query-api");
|
|
33
|
-
Object.defineProperty(exports, "CustomEntityIndexBuilder", { enumerable: true, get: function () { return query_api_2.CustomEntityIndexBuilder; } });
|
package/out/query-api.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { GlobalStorage } from './global-storage';
|
|
2
|
-
import { ListOptions } from './query-interfaces';
|
|
3
|
-
import { QueryBuilder, Condition, Result, ListResult } from './storage-adapter';
|
|
4
|
-
export declare class DefaultQueryBuilder implements QueryBuilder {
|
|
5
|
-
private globalStorage;
|
|
6
|
-
private queryOptions;
|
|
7
|
-
constructor(globalStorage: Pick<GlobalStorage, 'list'>, queryOptions?: ListOptions);
|
|
8
|
-
where(field: 'key', where: Condition): QueryBuilder;
|
|
9
|
-
cursor(cursor: string): QueryBuilder;
|
|
10
|
-
limit(limit: number): QueryBuilder;
|
|
11
|
-
getOne(): Promise<Result | undefined>;
|
|
12
|
-
getMany(): Promise<ListResult>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=query-api.d.ts.map
|
package/out/query-api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-api.d.ts","sourceRoot":"","sources":["../src/query-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEhF,qBAAa,mBAAoB,YAAW,YAAY;IAEpD,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,YAAY;gBADZ,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAC1C,YAAY,GAAE,WAAgB;IAGxC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,GAAG,YAAY;IAYnD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAOpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY;IAO5B,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAQrC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;CAGrC"}
|
package/out/query-api.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultQueryBuilder = void 0;
|
|
4
|
-
class DefaultQueryBuilder {
|
|
5
|
-
globalStorage;
|
|
6
|
-
queryOptions;
|
|
7
|
-
constructor(globalStorage, queryOptions = {}) {
|
|
8
|
-
this.globalStorage = globalStorage;
|
|
9
|
-
this.queryOptions = queryOptions;
|
|
10
|
-
}
|
|
11
|
-
where(field, where) {
|
|
12
|
-
return new DefaultQueryBuilder(this.globalStorage, {
|
|
13
|
-
...this.queryOptions,
|
|
14
|
-
where: [
|
|
15
|
-
{
|
|
16
|
-
field,
|
|
17
|
-
...where
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
cursor(cursor) {
|
|
23
|
-
return new DefaultQueryBuilder(this.globalStorage, {
|
|
24
|
-
...this.queryOptions,
|
|
25
|
-
cursor
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
limit(limit) {
|
|
29
|
-
return new DefaultQueryBuilder(this.globalStorage, {
|
|
30
|
-
...this.queryOptions,
|
|
31
|
-
limit
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async getOne() {
|
|
35
|
-
const { results } = await this.limit(1).getMany();
|
|
36
|
-
if (results && results.length > 0) {
|
|
37
|
-
return results[0];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async getMany() {
|
|
41
|
-
return this.globalStorage.list(this.queryOptions);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.DefaultQueryBuilder = DefaultQueryBuilder;
|