ag-common 0.0.892 → 0.0.894
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/dist/api/helpers/acm.js +7 -17
- package/dist/api/helpers/api.js +28 -23
- package/dist/api/helpers/apigw.js +54 -71
- package/dist/api/helpers/cosmos/delete.js +81 -94
- package/dist/api/helpers/cosmos/get.js +170 -195
- package/dist/api/helpers/cosmos/index.js +23 -53
- package/dist/api/helpers/cosmos/write.js +88 -92
- package/dist/api/helpers/dynamo/delete.js +22 -52
- package/dist/api/helpers/dynamo/get.js +145 -135
- package/dist/api/helpers/dynamo/set.js +22 -29
- package/dist/api/helpers/enforceDynamoProvisionCap.js +5 -5
- package/dist/api/helpers/google/apikey.js +1 -2
- package/dist/api/helpers/google/gemini.js +26 -37
- package/dist/api/helpers/retryOnError.js +15 -26
- package/dist/api/helpers/s3.js +102 -121
- package/dist/api/helpers/ses.js +19 -26
- package/dist/api/helpers/sqs.js +5 -15
- package/dist/api/helpers/ssmInfra/dynamo.js +9 -5
- package/dist/api/helpers/sts.js +26 -37
- package/dist/api/helpers/validations.js +7 -17
- package/dist/api/helpers/zod.js +1 -2
- package/dist/common/helpers/async.js +27 -42
- package/dist/common/helpers/csv.js +1 -4
- package/dist/common/helpers/date.js +2 -2
- package/dist/common/helpers/fetch.js +42 -55
- package/dist/common/helpers/generator.js +11 -22
- package/dist/common/helpers/i18n.js +3 -5
- package/dist/common/helpers/log.js +4 -4
- package/dist/common/helpers/math.js +1 -2
- package/dist/common/helpers/node-cache.js +10 -2
- package/dist/common/helpers/random.js +2 -2
- package/dist/common/helpers/secondsInNearest.js +1 -2
- package/dist/common/helpers/stream.js +24 -35
- package/dist/common/helpers/string/redact.js +1 -2
- package/dist/common/helpers/withRetry.js +5 -14
- package/dist/common/helpers/xml.js +9 -22
- package/dist/node/helpers/fetch.js +22 -33
- package/dist/ui/components/DarkMode/Base.js +10 -5
- package/dist/ui/components/Markdown/index.js +4 -5
- package/dist/ui/components/shadcn/accordion.js +13 -36
- package/dist/ui/components/shadcn/alert.d.ts +1 -1
- package/dist/ui/components/shadcn/alert.js +3 -23
- package/dist/ui/components/shadcn/avatar.js +4 -24
- package/dist/ui/components/shadcn/button.d.ts +1 -1
- package/dist/ui/components/shadcn/button.js +2 -14
- package/dist/ui/components/shadcn/card.js +6 -35
- package/dist/ui/components/shadcn/checkbox.js +4 -18
- package/dist/ui/components/shadcn/dialog.js +17 -46
- package/dist/ui/components/shadcn/dropdown-list.js +2 -2
- package/dist/ui/components/shadcn/dropdown-menu.js +22 -58
- package/dist/ui/components/shadcn/input-selector.js +4 -5
- package/dist/ui/components/shadcn/input.js +2 -14
- package/dist/ui/components/shadcn/label.d.ts +1 -1
- package/dist/ui/components/shadcn/label.js +2 -16
- package/dist/ui/components/shadcn/popover.js +3 -17
- package/dist/ui/components/shadcn/radio-group.js +4 -17
- package/dist/ui/components/shadcn/scroll-area.js +9 -26
- package/dist/ui/components/shadcn/select.js +23 -55
- package/dist/ui/components/shadcn/sheet.d.ts +1 -1
- package/dist/ui/components/shadcn/sheet.js +13 -42
- package/dist/ui/components/shadcn/switch.js +3 -17
- package/dist/ui/components/shadcn/textarea.js +2 -14
- package/dist/ui/components/shadcn/toast.js +6 -4
- package/dist/ui/helpers/cookie/get.js +5 -1
- package/dist/ui/helpers/cookie/raw.js +1 -2
- package/dist/ui/helpers/cookie/set.js +2 -2
- package/dist/ui/helpers/cookie/use.js +19 -9
- package/dist/ui/helpers/date.js +3 -4
- package/dist/ui/helpers/debounce.js +1 -1
- package/dist/ui/helpers/extractAttributes.js +1 -2
- package/dist/ui/helpers/openDialog.js +1 -2
- package/dist/ui/helpers/routes.js +6 -4
- package/dist/ui/helpers/serviceWorker.js +7 -18
- package/dist/ui/helpers/useContextMenu.js +2 -3
- package/dist/ui/helpers/useElementAttribute.js +1 -1
- package/dist/ui/helpers/useGranularHook.js +2 -2
- package/dist/ui/helpers/useInterval.js +5 -7
- package/dist/ui/helpers/useLocalStorage.js +1 -1
- package/dist/ui/helpers/useOnClickOutside.js +2 -3
- package/dist/ui/helpers/useOnScroll.js +6 -8
- package/dist/ui/helpers/useOverloadPageSearch.js +1 -1
- package/dist/ui/helpers/useQueryString.js +2 -2
- package/dist/ui/helpers/useResize.js +1 -1
- package/dist/ui/helpers/useTimeout.js +1 -1
- package/dist/ui/helpers/useTooltip.js +8 -5
- package/dist/ui/icons/Checkmark.js +2 -5
- package/dist/ui/icons/Circle.js +2 -5
- package/dist/ui/icons/Magnify.js +2 -5
- package/dist/ui/icons/Sun.js +8 -11
- package/dist/ui/icons/Warning.js +7 -10
- package/dist/ui/styles/common.js +8 -20
- package/package.json +66 -65
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -23,151 +14,140 @@ const node_cache_1 = __importDefault(require("node-cache"));
|
|
|
23
14
|
const log_1 = require("../../../common/helpers/log");
|
|
24
15
|
// Create a NodeCache instance with 5 second TTL
|
|
25
16
|
const cache = new node_cache_1.default({ stdTTL: 5 });
|
|
26
|
-
function getItemCosmos(container, partitionValue) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return resources[0];
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
17
|
+
async function getItemCosmos(container, partitionValue) {
|
|
18
|
+
try {
|
|
19
|
+
const querySpec = {
|
|
20
|
+
query: 'SELECT TOP 1 * FROM c WHERE c.PK = @val',
|
|
21
|
+
parameters: [
|
|
22
|
+
{
|
|
23
|
+
name: '@val',
|
|
24
|
+
value: partitionValue,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
const { resources, requestCharge } = await container.items
|
|
29
|
+
.query(querySpec)
|
|
30
|
+
.fetchAll();
|
|
31
|
+
(0, log_1.info)(`getItemCosmos:${partitionValue}. chg=${requestCharge}`);
|
|
32
|
+
if (resources.length > 0) {
|
|
33
|
+
return resources[0];
|
|
48
34
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const em = e.message;
|
|
54
|
-
(0, log_1.error)('Error deleting item:', em);
|
|
55
|
-
throw e;
|
|
35
|
+
else {
|
|
36
|
+
return null;
|
|
56
37
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
if (!partitionValues.length) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
const querySpec = {
|
|
66
|
-
query: 'SELECT * FROM c WHERE ARRAY_CONTAINS(@values, c.PK)',
|
|
67
|
-
parameters: [
|
|
68
|
-
{
|
|
69
|
-
name: '@values',
|
|
70
|
-
value: partitionValues,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
const { resources, requestCharge } = yield container.items
|
|
75
|
-
.query(querySpec)
|
|
76
|
-
.fetchAll();
|
|
77
|
-
(0, log_1.info)(`getItemsByCosmos: fetched ${resources.length} items. chg=${requestCharge}`);
|
|
78
|
-
return resources;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (e.message.includes('404')) {
|
|
41
|
+
return null;
|
|
79
42
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
43
|
+
const em = e.message;
|
|
44
|
+
(0, log_1.error)('Error deleting item:', em);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function getItemsByCosmos(container, partitionValues) {
|
|
49
|
+
try {
|
|
50
|
+
if (!partitionValues.length) {
|
|
51
|
+
return [];
|
|
84
52
|
}
|
|
85
|
-
|
|
53
|
+
const querySpec = {
|
|
54
|
+
query: 'SELECT * FROM c WHERE ARRAY_CONTAINS(@values, c.PK)',
|
|
55
|
+
parameters: [
|
|
56
|
+
{
|
|
57
|
+
name: '@values',
|
|
58
|
+
value: partitionValues,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
const { resources, requestCharge } = await container.items
|
|
63
|
+
.query(querySpec)
|
|
64
|
+
.fetchAll();
|
|
65
|
+
(0, log_1.info)(`getItemsByCosmos: fetched ${resources.length} items. chg=${requestCharge}`);
|
|
66
|
+
return resources;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
const em = e.message;
|
|
70
|
+
(0, log_1.error)('Error getting multiple items:', em);
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
86
73
|
}
|
|
87
74
|
function escapeSqlString(str) {
|
|
88
75
|
return str.replace(/'/g, "''");
|
|
89
76
|
}
|
|
90
|
-
function queryItemsCosmos(container, query, parameters) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
parameters
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
});
|
|
77
|
+
async function queryItemsCosmos(container, query, parameters) {
|
|
78
|
+
try {
|
|
79
|
+
const querySpec = {
|
|
80
|
+
query,
|
|
81
|
+
parameters: parameters
|
|
82
|
+
? Object.entries(parameters).map(([name, value]) => ({
|
|
83
|
+
name: `@${name}`,
|
|
84
|
+
value,
|
|
85
|
+
}))
|
|
86
|
+
: undefined,
|
|
87
|
+
};
|
|
88
|
+
const { resources, requestCharge } = await container.items
|
|
89
|
+
.query(querySpec)
|
|
90
|
+
.fetchAll();
|
|
91
|
+
return { resources, requestCharge };
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
const em = e.message;
|
|
95
|
+
(0, log_1.error)('Error queryItemsCosmos item:', em);
|
|
96
|
+
return { error: em };
|
|
97
|
+
}
|
|
113
98
|
}
|
|
114
|
-
function queryItemsByText(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
case
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
throw new Error(`Unsupported field type: ${field.type}`);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const query = `SELECT * FROM c WHERE ${conditions.join(` ${operator} `)}`;
|
|
130
|
-
const parameters = searchFields.reduce((acc, field, index) => {
|
|
131
|
-
acc[`value${index}`] = escapeSqlString(field.fieldValue);
|
|
132
|
-
return acc;
|
|
133
|
-
}, {});
|
|
134
|
-
const x = yield queryItemsCosmos(container, query, parameters);
|
|
135
|
-
(0, log_1.debug)(`queryItemsByText: ${JSON.stringify(searchFields)}, operator=${operator}. chg=${x.requestCharge}`);
|
|
136
|
-
if ('error' in x) {
|
|
137
|
-
throw x.error;
|
|
99
|
+
async function queryItemsByText(container, searchFields, operator = 'AND') {
|
|
100
|
+
try {
|
|
101
|
+
const conditions = searchFields.map((field, index) => {
|
|
102
|
+
switch (field.type) {
|
|
103
|
+
case 'contains':
|
|
104
|
+
return `CONTAINS(c.${field.fieldName}, @value${index}, true)`; //true to ignore case
|
|
105
|
+
case 'equals':
|
|
106
|
+
return `c.${field.fieldName} = @value${index}`;
|
|
107
|
+
case 'not_equals':
|
|
108
|
+
return `c.${field.fieldName} != @value${index}`;
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Unsupported field type: ${field.type}`);
|
|
138
111
|
}
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
112
|
+
});
|
|
113
|
+
const query = `SELECT * FROM c WHERE ${conditions.join(` ${operator} `)}`;
|
|
114
|
+
const parameters = searchFields.reduce((acc, field, index) => {
|
|
115
|
+
acc[`value${index}`] = escapeSqlString(field.fieldValue);
|
|
116
|
+
return acc;
|
|
117
|
+
}, {});
|
|
118
|
+
const x = await queryItemsCosmos(container, query, parameters);
|
|
119
|
+
(0, log_1.debug)(`queryItemsByText: ${JSON.stringify(searchFields)}, operator=${operator}. chg=${x.requestCharge}`);
|
|
120
|
+
if ('error' in x) {
|
|
121
|
+
throw x.error;
|
|
145
122
|
}
|
|
146
|
-
|
|
123
|
+
return x.resources;
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
const em = e.message;
|
|
127
|
+
(0, log_1.error)('Error queryItemsByText item:', em);
|
|
128
|
+
return { error: em };
|
|
129
|
+
}
|
|
147
130
|
}
|
|
148
|
-
function scanCosmos(container) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
throw x.error;
|
|
156
|
-
}
|
|
157
|
-
return x.resources;
|
|
158
|
-
}
|
|
159
|
-
catch (e) {
|
|
160
|
-
const em = e.message;
|
|
161
|
-
(0, log_1.error)('Error queryItemsByText item:', em);
|
|
162
|
-
return { error: em };
|
|
131
|
+
async function scanCosmos(container) {
|
|
132
|
+
try {
|
|
133
|
+
const query = `SELECT * FROM c`;
|
|
134
|
+
const x = await queryItemsCosmos(container, query, {});
|
|
135
|
+
(0, log_1.info)(`scan. chg=${x.requestCharge}`);
|
|
136
|
+
if ('error' in x) {
|
|
137
|
+
throw x.error;
|
|
163
138
|
}
|
|
164
|
-
|
|
139
|
+
return x.resources;
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
const em = e.message;
|
|
143
|
+
(0, log_1.error)('Error queryItemsByText item:', em);
|
|
144
|
+
return { error: em };
|
|
145
|
+
}
|
|
165
146
|
}
|
|
166
|
-
function queryItemsByNumber(container, options) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const query = `
|
|
147
|
+
async function queryItemsByNumber(container, options) {
|
|
148
|
+
try {
|
|
149
|
+
const { type, field, minValue = 0, limit, descending = true } = options;
|
|
150
|
+
const query = `
|
|
171
151
|
SELECT * FROM c
|
|
172
152
|
WHERE IS_NUMBER(c.${field})
|
|
173
153
|
AND c.${field} > @minValue
|
|
@@ -175,68 +155,63 @@ function queryItemsByNumber(container, options) {
|
|
|
175
155
|
ORDER BY c.${field} ${descending ? 'DESC' : 'ASC'}
|
|
176
156
|
${limit ? 'OFFSET 0 LIMIT @limit' : ''}
|
|
177
157
|
`;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
const x = yield queryItemsCosmos(container, query, parameters);
|
|
186
|
-
(0, log_1.debug)(`queryItemsByNumber: type=${type}, field=${field}, minValue=${minValue}, limit=${limit}. chg=${x.requestCharge}`);
|
|
187
|
-
if ('error' in x) {
|
|
188
|
-
throw x.error;
|
|
189
|
-
}
|
|
190
|
-
return x.resources;
|
|
158
|
+
const parameters = {
|
|
159
|
+
type,
|
|
160
|
+
minValue,
|
|
161
|
+
};
|
|
162
|
+
if (limit) {
|
|
163
|
+
parameters.limit = limit;
|
|
191
164
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
165
|
+
const x = await queryItemsCosmos(container, query, parameters);
|
|
166
|
+
(0, log_1.debug)(`queryItemsByNumber: type=${type}, field=${field}, minValue=${minValue}, limit=${limit}. chg=${x.requestCharge}`);
|
|
167
|
+
if ('error' in x) {
|
|
168
|
+
throw x.error;
|
|
196
169
|
}
|
|
197
|
-
|
|
170
|
+
return x.resources;
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
const em = e.message;
|
|
174
|
+
(0, log_1.error)('Error queryItemsByNumber:', em);
|
|
175
|
+
return { error: em };
|
|
176
|
+
}
|
|
198
177
|
}
|
|
199
|
-
function queryItemsByType(container, type) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const query = `
|
|
178
|
+
async function queryItemsByType(container, type) {
|
|
179
|
+
try {
|
|
180
|
+
// Check if data is in cache
|
|
181
|
+
const cacheKey = `queryItemsByType:${type}`;
|
|
182
|
+
const cachedData = cache.get(cacheKey);
|
|
183
|
+
if (cachedData) {
|
|
184
|
+
(0, log_1.info)(`queryItemsByType: type=${type}. [CACHE HIT]`);
|
|
185
|
+
return cachedData;
|
|
186
|
+
}
|
|
187
|
+
const query = `
|
|
210
188
|
SELECT * FROM c
|
|
211
189
|
WHERE c.type = @type
|
|
212
190
|
`;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
const result = x.resources;
|
|
222
|
-
// Store result in cache
|
|
223
|
-
cache.set(cacheKey, result);
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
catch (e) {
|
|
227
|
-
const em = e.message;
|
|
228
|
-
(0, log_1.error)('Error queryItemsByType:', em);
|
|
229
|
-
return { error: em };
|
|
191
|
+
const parameters = {
|
|
192
|
+
type,
|
|
193
|
+
};
|
|
194
|
+
const x = await queryItemsCosmos(container, query, parameters);
|
|
195
|
+
(0, log_1.info)(`queryItemsByType: type=${type}. chg=${x.requestCharge}`);
|
|
196
|
+
if ('error' in x) {
|
|
197
|
+
throw x.error;
|
|
230
198
|
}
|
|
231
|
-
|
|
199
|
+
const result = x.resources;
|
|
200
|
+
// Store result in cache
|
|
201
|
+
cache.set(cacheKey, result);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
const em = e.message;
|
|
206
|
+
(0, log_1.error)('Error queryItemsByType:', em);
|
|
207
|
+
return { error: em };
|
|
208
|
+
}
|
|
232
209
|
}
|
|
233
|
-
function queryItemsByRelevancy(container, type, limit) {
|
|
234
|
-
return
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
descending: true,
|
|
240
|
-
});
|
|
210
|
+
async function queryItemsByRelevancy(container, type, limit) {
|
|
211
|
+
return queryItemsByNumber(container, {
|
|
212
|
+
type,
|
|
213
|
+
field: 'relevancy',
|
|
214
|
+
limit,
|
|
215
|
+
descending: true,
|
|
241
216
|
});
|
|
242
217
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.Cosmos = void 0;
|
|
13
4
|
const delete_1 = require("./delete");
|
|
@@ -15,66 +6,45 @@ const get_1 = require("./get");
|
|
|
15
6
|
const utils_1 = require("./utils");
|
|
16
7
|
const write_1 = require("./write");
|
|
17
8
|
class Cosmos {
|
|
9
|
+
container;
|
|
18
10
|
constructor(settings) {
|
|
19
11
|
this.container = (0, utils_1.createContainer)(settings);
|
|
20
12
|
}
|
|
21
13
|
// Get operations
|
|
22
|
-
getItem(partitionValue) {
|
|
23
|
-
return
|
|
24
|
-
return (0, get_1.getItemCosmos)(this.container, partitionValue);
|
|
25
|
-
});
|
|
14
|
+
async getItem(partitionValue) {
|
|
15
|
+
return (0, get_1.getItemCosmos)(this.container, partitionValue);
|
|
26
16
|
}
|
|
27
|
-
getItemsBy(partitionValues) {
|
|
28
|
-
return
|
|
29
|
-
return (0, get_1.getItemsByCosmos)(this.container, partitionValues);
|
|
30
|
-
});
|
|
17
|
+
async getItemsBy(partitionValues) {
|
|
18
|
+
return (0, get_1.getItemsByCosmos)(this.container, partitionValues);
|
|
31
19
|
}
|
|
32
|
-
queryItemsByText(
|
|
33
|
-
return
|
|
34
|
-
return (0, get_1.queryItemsByText)(this.container, searchFields, operator);
|
|
35
|
-
});
|
|
20
|
+
async queryItemsByText(searchFields, operator = 'AND') {
|
|
21
|
+
return (0, get_1.queryItemsByText)(this.container, searchFields, operator);
|
|
36
22
|
}
|
|
37
|
-
scan() {
|
|
38
|
-
return
|
|
39
|
-
return (0, get_1.scanCosmos)(this.container);
|
|
40
|
-
});
|
|
23
|
+
async scan() {
|
|
24
|
+
return (0, get_1.scanCosmos)(this.container);
|
|
41
25
|
}
|
|
42
|
-
queryItemsByNumber(options) {
|
|
43
|
-
return
|
|
44
|
-
return (0, get_1.queryItemsByNumber)(this.container, options);
|
|
45
|
-
});
|
|
26
|
+
async queryItemsByNumber(options) {
|
|
27
|
+
return (0, get_1.queryItemsByNumber)(this.container, options);
|
|
46
28
|
}
|
|
47
|
-
queryItemsByType(type) {
|
|
48
|
-
return
|
|
49
|
-
return (0, get_1.queryItemsByType)(this.container, type);
|
|
50
|
-
});
|
|
29
|
+
async queryItemsByType(type) {
|
|
30
|
+
return (0, get_1.queryItemsByType)(this.container, type);
|
|
51
31
|
}
|
|
52
|
-
queryItemsByRelevancy(type, limit) {
|
|
53
|
-
return
|
|
54
|
-
return (0, get_1.queryItemsByRelevancy)(this.container, type, limit);
|
|
55
|
-
});
|
|
32
|
+
async queryItemsByRelevancy(type, limit) {
|
|
33
|
+
return (0, get_1.queryItemsByRelevancy)(this.container, type, limit);
|
|
56
34
|
}
|
|
57
35
|
// Write operations
|
|
58
|
-
putItem(item) {
|
|
59
|
-
return
|
|
60
|
-
return (0, write_1.putItemCosmos)(this.container, item);
|
|
61
|
-
});
|
|
36
|
+
async putItem(item) {
|
|
37
|
+
return (0, write_1.putItemCosmos)(this.container, item);
|
|
62
38
|
}
|
|
63
|
-
putItems(items) {
|
|
64
|
-
return
|
|
65
|
-
return (0, write_1.putItemsCosmos)(this.container, items);
|
|
66
|
-
});
|
|
39
|
+
async putItems(items) {
|
|
40
|
+
return (0, write_1.putItemsCosmos)(this.container, items);
|
|
67
41
|
}
|
|
68
42
|
// Delete operations
|
|
69
|
-
deleteItem(pk) {
|
|
70
|
-
return
|
|
71
|
-
return (0, delete_1.deleteItemCosmos)(this.container, pk);
|
|
72
|
-
});
|
|
43
|
+
async deleteItem(pk) {
|
|
44
|
+
return (0, delete_1.deleteItemCosmos)(this.container, pk);
|
|
73
45
|
}
|
|
74
|
-
deleteItemsByField(field, value) {
|
|
75
|
-
return
|
|
76
|
-
return (0, delete_1.deleteItemsByField)(this.container, field, value);
|
|
77
|
-
});
|
|
46
|
+
async deleteItemsByField(field, value) {
|
|
47
|
+
return (0, delete_1.deleteItemsByField)(this.container, field, value);
|
|
78
48
|
}
|
|
79
49
|
}
|
|
80
50
|
exports.Cosmos = Cosmos;
|