ag-common 0.0.766 → 0.0.769
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/cosmos/delete.js +1 -1
- package/dist/api/helpers/cosmos/get.d.ts +2 -2
- package/dist/api/helpers/cosmos/get.js +13 -4
- package/dist/api/helpers/cosmos/index.d.ts +2 -2
- package/dist/api/helpers/cosmos/index.js +1 -1
- package/dist/api/helpers/cosmos/write.js +1 -1
- package/dist/api/helpers/index.d.ts +1 -1
- package/dist/api/helpers/index.js +1 -1
- package/package.json +1 -1
|
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.deleteItemCosmos = deleteItemCosmos;
|
|
13
13
|
exports.deleteItemsByField = deleteItemsByField;
|
|
14
|
-
const utils_1 = require("./utils");
|
|
15
14
|
const log_1 = require("../../../common/helpers/log");
|
|
16
15
|
const withRetry_1 = require("../withRetry");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
17
|
function deleteItemCosmos(container, pk) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
try {
|
|
@@ -2,9 +2,9 @@ import type { Container } from '@azure/cosmos';
|
|
|
2
2
|
export declare function getItemCosmos<T>(container: Container, partitionValue: string): Promise<T | null>;
|
|
3
3
|
export declare function getItemsByCosmos<T>(container: Container, partitionValues: string[]): Promise<T[]>;
|
|
4
4
|
export declare function queryItemsByText<T>(container: Container, searchFields: {
|
|
5
|
-
fieldName: string;
|
|
5
|
+
fieldName: keyof T & string;
|
|
6
6
|
fieldValue: string;
|
|
7
|
-
type: 'contains' | 'equals';
|
|
7
|
+
type: 'contains' | 'equals' | 'not_equals';
|
|
8
8
|
}[], operator?: 'AND' | 'OR'): Promise<T[] | {
|
|
9
9
|
error: string;
|
|
10
10
|
}>;
|
|
@@ -19,8 +19,8 @@ exports.scanCosmos = scanCosmos;
|
|
|
19
19
|
exports.queryItemsByNumber = queryItemsByNumber;
|
|
20
20
|
exports.queryItemsByType = queryItemsByType;
|
|
21
21
|
exports.queryItemsByRelevancy = queryItemsByRelevancy;
|
|
22
|
-
const log_1 = require("../../../common/helpers/log");
|
|
23
22
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
23
|
+
const log_1 = require("../../../common/helpers/log");
|
|
24
24
|
// Create a NodeCache instance with 5 second TTL
|
|
25
25
|
const cache = new node_cache_1.default({ stdTTL: 5 });
|
|
26
26
|
function getItemCosmos(container, partitionValue) {
|
|
@@ -114,9 +114,18 @@ function queryItemsCosmos(container, query, parameters) {
|
|
|
114
114
|
function queryItemsByText(container_1, searchFields_1) {
|
|
115
115
|
return __awaiter(this, arguments, void 0, function* (container, searchFields, operator = 'AND') {
|
|
116
116
|
try {
|
|
117
|
-
const conditions = searchFields.map((field, index) =>
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const conditions = searchFields.map((field, index) => {
|
|
118
|
+
switch (field.type) {
|
|
119
|
+
case 'contains':
|
|
120
|
+
return `CONTAINS(c.${field.fieldName}, @value${index}, true)`; //true to ignore case
|
|
121
|
+
case 'equals':
|
|
122
|
+
return `c.${field.fieldName} = @value${index}`;
|
|
123
|
+
case 'not_equals':
|
|
124
|
+
return `c.${field.fieldName} != @value${index}`;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unsupported field type: ${field.type}`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
120
129
|
const query = `SELECT * FROM c WHERE ${conditions.join(` ${operator} `)}`;
|
|
121
130
|
const parameters = searchFields.reduce((acc, field, index) => {
|
|
122
131
|
acc[`value${index}`] = escapeSqlString(field.fieldValue);
|
|
@@ -5,9 +5,9 @@ export declare class Cosmos {
|
|
|
5
5
|
getItem<T>(partitionValue: string): Promise<T | null>;
|
|
6
6
|
getItemsBy<T>(partitionValues: string[]): Promise<T[]>;
|
|
7
7
|
queryItemsByText<T>(searchFields: {
|
|
8
|
-
fieldName: string;
|
|
8
|
+
fieldName: keyof T & string;
|
|
9
9
|
fieldValue: string;
|
|
10
|
-
type: 'contains' | 'equals';
|
|
10
|
+
type: 'contains' | 'equals' | 'not_equals';
|
|
11
11
|
}[], operator?: 'AND' | 'OR'): Promise<T[] | {
|
|
12
12
|
error: string;
|
|
13
13
|
}>;
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Cosmos = void 0;
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
13
|
const delete_1 = require("./delete");
|
|
15
14
|
const get_1 = require("./get");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
16
|
const write_1 = require("./write");
|
|
17
17
|
class Cosmos {
|
|
18
18
|
constructor(settings) {
|
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.putItemCosmos = putItemCosmos;
|
|
13
13
|
exports.putItemsCosmos = putItemsCosmos;
|
|
14
|
-
const withRetry_1 = require("../withRetry");
|
|
15
14
|
const log_1 = require("../../../common/helpers/log");
|
|
15
|
+
const withRetry_1 = require("../withRetry");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
17
|
function putItemCosmos(container, item) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './api';
|
|
2
2
|
export * from './apigw';
|
|
3
3
|
export * from './aws';
|
|
4
|
+
export * from './cosmos';
|
|
4
5
|
export * from './dynamo';
|
|
5
6
|
export * from './enforceDynamoProvisionCap';
|
|
6
7
|
export * from './s3';
|
|
@@ -10,4 +11,3 @@ export * from './ssm';
|
|
|
10
11
|
export * from './ssmInfra';
|
|
11
12
|
export * from './sts';
|
|
12
13
|
export * from './validations';
|
|
13
|
-
export * from './cosmos';
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
18
|
__exportStar(require("./apigw"), exports);
|
|
19
19
|
__exportStar(require("./aws"), exports);
|
|
20
|
+
__exportStar(require("./cosmos"), exports);
|
|
20
21
|
__exportStar(require("./dynamo"), exports);
|
|
21
22
|
__exportStar(require("./enforceDynamoProvisionCap"), exports);
|
|
22
23
|
__exportStar(require("./s3"), exports);
|
|
@@ -26,4 +27,3 @@ __exportStar(require("./ssm"), exports);
|
|
|
26
27
|
__exportStar(require("./ssmInfra"), exports);
|
|
27
28
|
__exportStar(require("./sts"), exports);
|
|
28
29
|
__exportStar(require("./validations"), exports);
|
|
29
|
-
__exportStar(require("./cosmos"), exports);
|
package/package.json
CHANGED