@forge/storage 1.5.15-experimental-7fc11d3 → 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/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.js +5 -3
- package/out/gql-queries.js +95 -91
- package/out/query-api.js +19 -5
- package/package.json +1 -1
|
@@ -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.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;
|
|
@@ -105,12 +107,12 @@ class GlobalStorage {
|
|
|
105
107
|
async getInternal(key, encrypted) {
|
|
106
108
|
const requestBody = gql_queries_1.UntypedQueries.get(this.doGetAppContextAri(), key, encrypted);
|
|
107
109
|
const { appStoredEntity: { value } } = await this.query(requestBody);
|
|
108
|
-
return value
|
|
110
|
+
return value ?? undefined;
|
|
109
111
|
}
|
|
110
112
|
async getEntityInternal(entityName, entityKey) {
|
|
111
113
|
const requestBody = gql_queries_1.CustomEntityQueries.get(this.doGetAppContextAri(), entityName, entityKey);
|
|
112
114
|
const { appStoredCustomEntity: { value } } = await this.query(requestBody);
|
|
113
|
-
return value
|
|
115
|
+
return value ?? undefined;
|
|
114
116
|
}
|
|
115
117
|
buildRequest(requestBody) {
|
|
116
118
|
return {
|
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,14 +109,13 @@ 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
|
|
122
115
|
}
|
|
123
116
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
query: `
|
|
117
|
+
static bulkSet = (contextAri, values, encrypted) => ({
|
|
118
|
+
query: `
|
|
127
119
|
mutation forge_app_setApplicationStorageEntities($input: SetAppStoredEntitiesMutationInput!) {
|
|
128
120
|
appStorage{
|
|
129
121
|
setAppStoredEntities(input: $input) {
|
|
@@ -141,19 +133,19 @@ UntypedQueries.bulkSet = (contextAri, values, encrypted) => ({
|
|
|
141
133
|
}
|
|
142
134
|
}
|
|
143
135
|
`,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
variables: {
|
|
137
|
+
input: {
|
|
138
|
+
contextAri,
|
|
139
|
+
entities: values,
|
|
140
|
+
encrypted
|
|
141
|
+
}
|
|
149
142
|
}
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
class CustomEntityQueries {
|
|
143
|
+
});
|
|
153
144
|
}
|
|
154
|
-
exports.
|
|
155
|
-
CustomEntityQueries
|
|
156
|
-
|
|
145
|
+
exports.UntypedQueries = UntypedQueries;
|
|
146
|
+
class CustomEntityQueries {
|
|
147
|
+
static get = (contextAri, entityName, key) => ({
|
|
148
|
+
query: `
|
|
157
149
|
query forge_app_getApplicationStorageCustomEntity ($contextAri: ID!, $key: ID!, $entityName: String!) {
|
|
158
150
|
appStoredCustomEntity(contextAri: $contextAri, key: $key, entityName: $entityName) {
|
|
159
151
|
value
|
|
@@ -162,14 +154,14 @@ CustomEntityQueries.get = (contextAri, entityName, key) => ({
|
|
|
162
154
|
}
|
|
163
155
|
}
|
|
164
156
|
`,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
|
|
157
|
+
variables: {
|
|
158
|
+
contextAri,
|
|
159
|
+
entityName,
|
|
160
|
+
key
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
static set = (contextAri, entityName, key, value) => ({
|
|
164
|
+
query: `
|
|
173
165
|
mutation forge_app_setApplicationStorageCustomEntity($input: SetAppStoredCustomEntityMutationInput!) {
|
|
174
166
|
appStorageCustomEntity{
|
|
175
167
|
setAppStoredCustomEntity(input: $input) {
|
|
@@ -186,17 +178,17 @@ CustomEntityQueries.set = (contextAri, entityName, key, value) => ({
|
|
|
186
178
|
}
|
|
187
179
|
}
|
|
188
180
|
`,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
variables: {
|
|
182
|
+
input: {
|
|
183
|
+
contextAri,
|
|
184
|
+
entityName,
|
|
185
|
+
key,
|
|
186
|
+
value
|
|
187
|
+
}
|
|
195
188
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
query: `
|
|
189
|
+
});
|
|
190
|
+
static delete = (contextAri, entityName, key) => ({
|
|
191
|
+
query: `
|
|
200
192
|
mutation forge_app_deleteApplicationStorageCustomEntity($input: DeleteAppStoredCustomEntityMutationInput!) {
|
|
201
193
|
appStorageCustomEntity {
|
|
202
194
|
deleteAppStoredCustomEntity(input: $input) {
|
|
@@ -213,17 +205,17 @@ CustomEntityQueries.delete = (contextAri, entityName, key) => ({
|
|
|
213
205
|
}
|
|
214
206
|
}
|
|
215
207
|
`,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
208
|
+
variables: {
|
|
209
|
+
input: {
|
|
210
|
+
contextAri,
|
|
211
|
+
entityName,
|
|
212
|
+
key
|
|
213
|
+
}
|
|
221
214
|
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
query: `
|
|
215
|
+
});
|
|
216
|
+
static listQuery = (contextAri, options) => {
|
|
217
|
+
return {
|
|
218
|
+
query: `
|
|
227
219
|
query AppStorageCustomEntityQueries ($contextAri: ID!, $entityName: String!, $indexName: String!, $range: AppStoredCustomEntityRange, $filters: AppStoredCustomEntityFilters, $sort:SortOrder, $limit: Int, $cursor: String, $partition: [AppStoredCustomEntityFieldValue!]) {
|
|
228
220
|
appStoredCustomEntities(contextAri: $contextAri, entityName: $entityName, indexName: $indexName, range: $range, filters: $filters, sort:$sort, limit: $limit, cursor: $cursor, partition: $partition) {
|
|
229
221
|
edges {
|
|
@@ -242,12 +234,24 @@ CustomEntityQueries.listQuery = (contextAri, options) => {
|
|
|
242
234
|
}
|
|
243
235
|
}
|
|
244
236
|
`,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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 } : {})
|
|
250
253
|
}
|
|
251
|
-
|
|
254
|
+
};
|
|
252
255
|
};
|
|
253
|
-
}
|
|
256
|
+
}
|
|
257
|
+
exports.CustomEntityQueries = CustomEntityQueries;
|
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();
|