mocody 0.6.8 → 0.6.9
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/index.cjs +391 -362
- package/package.json +2 -7
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
CouchDataOperation: () => CouchDataOperation,
|
|
34
|
+
DynamoDataOperation: () => DynamoDataOperation,
|
|
35
|
+
MocodyGenericError: () => MocodyGenericError,
|
|
36
|
+
MocodyInitializerCouch: () => MocodyInitializerCouch,
|
|
37
|
+
MocodyInitializerDynamo: () => MocodyInitializerDynamo,
|
|
38
|
+
MocodyInitializerMongo: () => MocodyInitializerMongo,
|
|
39
|
+
MocodyUtil: () => MocodyUtil,
|
|
40
|
+
MongoDataOperation: () => MongoDataOperation
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
|
+
|
|
44
|
+
// src/helpers/errors.ts
|
|
2
45
|
var MocodyGenericError = class extends Error {
|
|
3
46
|
constructor(message) {
|
|
4
47
|
super(message);
|
|
@@ -34,11 +77,11 @@ var MocodyErrorUtilsServiceBase = class {
|
|
|
34
77
|
var MocodyErrorUtilsService = new MocodyErrorUtilsServiceBase();
|
|
35
78
|
|
|
36
79
|
// src/helpers/mocody-utils.ts
|
|
37
|
-
var
|
|
80
|
+
var import_util_dynamodb = require("@aws-sdk/util-dynamodb");
|
|
38
81
|
|
|
39
82
|
// src/helpers/util-service.ts
|
|
40
|
-
var
|
|
41
|
-
var
|
|
83
|
+
var import_node_crypto = require("crypto");
|
|
84
|
+
var import_nanoid = require("nanoid");
|
|
42
85
|
var UtilServiceBase = class {
|
|
43
86
|
convertHexadecimalToNumber(hexString) {
|
|
44
87
|
return parseInt(hexString, 16);
|
|
@@ -60,7 +103,7 @@ var UtilServiceBase = class {
|
|
|
60
103
|
}
|
|
61
104
|
getRandomString(count) {
|
|
62
105
|
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
63
|
-
const nanoid01 =
|
|
106
|
+
const nanoid01 = (0, import_nanoid.customAlphabet)(alphabet, count);
|
|
64
107
|
return nanoid01();
|
|
65
108
|
}
|
|
66
109
|
camelCaseToSentenceCase(text) {
|
|
@@ -143,7 +186,7 @@ var UtilServiceBase = class {
|
|
|
143
186
|
`${_now.getMinutes()}`.padStart(2, "0"),
|
|
144
187
|
`${_now.getSeconds()}`.padStart(2, "0"),
|
|
145
188
|
"-",
|
|
146
|
-
|
|
189
|
+
(0, import_node_crypto.randomUUID)()
|
|
147
190
|
];
|
|
148
191
|
return key.join("");
|
|
149
192
|
}
|
|
@@ -190,7 +233,7 @@ var UtilServiceBase = class {
|
|
|
190
233
|
}
|
|
191
234
|
groupOneBy(dataList, fn) {
|
|
192
235
|
const aggr = {};
|
|
193
|
-
if (
|
|
236
|
+
if (dataList?.length) {
|
|
194
237
|
dataList.forEach((data) => {
|
|
195
238
|
const groupId = fn(data);
|
|
196
239
|
if (aggr[groupId] === void 0) {
|
|
@@ -202,13 +245,13 @@ var UtilServiceBase = class {
|
|
|
202
245
|
}
|
|
203
246
|
groupBy(dataList, fn) {
|
|
204
247
|
const aggr = {};
|
|
205
|
-
if (
|
|
248
|
+
if (dataList?.length) {
|
|
206
249
|
dataList.forEach((data) => {
|
|
207
250
|
const groupId = fn(data);
|
|
208
251
|
if (!aggr[groupId]) {
|
|
209
252
|
aggr[groupId] = [];
|
|
210
253
|
}
|
|
211
|
-
|
|
254
|
+
aggr[groupId]?.push(data);
|
|
212
255
|
});
|
|
213
256
|
}
|
|
214
257
|
return aggr;
|
|
@@ -274,7 +317,7 @@ var UtilService = new UtilServiceBase();
|
|
|
274
317
|
// src/helpers/mocody-utils.ts
|
|
275
318
|
var MocodyUtilBase = class {
|
|
276
319
|
marshallFromJson(jsonData) {
|
|
277
|
-
const marshalled =
|
|
320
|
+
const marshalled = (0, import_util_dynamodb.marshall)(jsonData, {
|
|
278
321
|
convertClassInstanceToMap: true,
|
|
279
322
|
convertEmptyValues: true,
|
|
280
323
|
removeUndefinedValues: true
|
|
@@ -282,18 +325,18 @@ var MocodyUtilBase = class {
|
|
|
282
325
|
return marshalled;
|
|
283
326
|
}
|
|
284
327
|
unmarshallToJson(dynamoData) {
|
|
285
|
-
return
|
|
328
|
+
return (0, import_util_dynamodb.unmarshall)(dynamoData);
|
|
286
329
|
}
|
|
287
330
|
getProjectionFields({
|
|
288
331
|
excludeFields,
|
|
289
332
|
fields,
|
|
290
333
|
entityFields
|
|
291
334
|
}) {
|
|
292
|
-
if (!
|
|
335
|
+
if (!fields?.length && !excludeFields?.length) {
|
|
293
336
|
return void 0;
|
|
294
337
|
}
|
|
295
|
-
const fields01 =
|
|
296
|
-
const excludeFields01 =
|
|
338
|
+
const fields01 = fields?.length ? Array.from(/* @__PURE__ */ new Set([...fields])) : [];
|
|
339
|
+
const excludeFields01 = excludeFields?.length ? Array.from(/* @__PURE__ */ new Set([...excludeFields])) : [];
|
|
297
340
|
if (!excludeFields01.length) {
|
|
298
341
|
if (fields01.length) {
|
|
299
342
|
return fields01;
|
|
@@ -322,7 +365,7 @@ var MocodyUtilBase = class {
|
|
|
322
365
|
fieldAliases,
|
|
323
366
|
featureEntity
|
|
324
367
|
}) {
|
|
325
|
-
if (
|
|
368
|
+
if (fieldAliases?.length && data && typeof data === "object" && Object.keys(data).length && featureEntity) {
|
|
326
369
|
const data01 = UtilService.convertObjectPlainObject(data);
|
|
327
370
|
fieldAliases.forEach(({ source, dest }) => {
|
|
328
371
|
if (data01[source] !== data01[dest]) {
|
|
@@ -338,7 +381,7 @@ var MocodyUtilBase = class {
|
|
|
338
381
|
fieldAliases,
|
|
339
382
|
featureEntity
|
|
340
383
|
}) {
|
|
341
|
-
if (
|
|
384
|
+
if (fieldAliases?.length && typeof data === "object" && Object.keys(data).length && featureEntity) {
|
|
342
385
|
const data01 = UtilService.convertObjectPlainObject(data);
|
|
343
386
|
fieldAliases.forEach(({ source, dest }) => {
|
|
344
387
|
if (data01[source] !== data01[dest]) {
|
|
@@ -353,21 +396,13 @@ var MocodyUtilBase = class {
|
|
|
353
396
|
var MocodyUtil = new MocodyUtilBase();
|
|
354
397
|
|
|
355
398
|
// src/dynamo/dynamo-initializer.ts
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var _clientdynamodb = require('@aws-sdk/client-dynamodb');
|
|
365
|
-
var _libdynamodb = require('@aws-sdk/lib-dynamodb');
|
|
366
|
-
var _throat = require('throat'); var _throat2 = _interopRequireDefault(_throat);
|
|
367
|
-
var concurrency = _throat2.default.call(void 0, 1);
|
|
399
|
+
var import_client_dynamodb = require("@aws-sdk/client-dynamodb");
|
|
400
|
+
var import_lib_dynamodb = require("@aws-sdk/lib-dynamodb");
|
|
401
|
+
var import_throat = __toESM(require("throat"), 1);
|
|
402
|
+
var concurrency = (0, import_throat.default)(1);
|
|
368
403
|
var MocodyInitializerDynamo = class {
|
|
369
|
-
|
|
370
|
-
|
|
404
|
+
client;
|
|
405
|
+
_config;
|
|
371
406
|
constructor(inits) {
|
|
372
407
|
this._config = inits;
|
|
373
408
|
}
|
|
@@ -376,38 +411,38 @@ var MocodyInitializerDynamo = class {
|
|
|
376
411
|
}
|
|
377
412
|
async executeStatement(param) {
|
|
378
413
|
const client = await this.getInstance();
|
|
379
|
-
const docClient =
|
|
380
|
-
const command = new
|
|
414
|
+
const docClient = import_lib_dynamodb.DynamoDBDocumentClient.from(client);
|
|
415
|
+
const command = new import_lib_dynamodb.ExecuteStatementCommand(param);
|
|
381
416
|
const response = await docClient.send(command);
|
|
382
417
|
return response;
|
|
383
418
|
}
|
|
384
419
|
async putItem(params) {
|
|
385
420
|
const client = await this.getInstance();
|
|
386
|
-
return await client.send(new
|
|
421
|
+
return await client.send(new import_client_dynamodb.PutItemCommand(params));
|
|
387
422
|
}
|
|
388
423
|
async getItem(params) {
|
|
389
424
|
const client = await this.getInstance();
|
|
390
|
-
return await client.send(new
|
|
425
|
+
return await client.send(new import_client_dynamodb.GetItemCommand(params));
|
|
391
426
|
}
|
|
392
427
|
async transactWriteItems(params) {
|
|
393
428
|
const client = await this.getInstance();
|
|
394
|
-
return await client.send(new
|
|
429
|
+
return await client.send(new import_client_dynamodb.TransactWriteItemsCommand(params));
|
|
395
430
|
}
|
|
396
431
|
async batchWriteItem(params) {
|
|
397
432
|
const client = await this.getInstance();
|
|
398
|
-
return await client.send(new
|
|
433
|
+
return await client.send(new import_client_dynamodb.BatchWriteItemCommand(params));
|
|
399
434
|
}
|
|
400
435
|
async batchGetItem(params) {
|
|
401
436
|
const client = await this.getInstance();
|
|
402
|
-
return await client.send(new
|
|
437
|
+
return await client.send(new import_client_dynamodb.BatchGetItemCommand(params));
|
|
403
438
|
}
|
|
404
439
|
async deleteItem(params) {
|
|
405
440
|
const client = await this.getInstance();
|
|
406
|
-
return await client.send(new
|
|
441
|
+
return await client.send(new import_client_dynamodb.DeleteItemCommand(params));
|
|
407
442
|
}
|
|
408
443
|
async getInstanceBase() {
|
|
409
444
|
if (!this.client) {
|
|
410
|
-
this.client = new
|
|
445
|
+
this.client = new import_client_dynamodb.DynamoDBClient(this._config);
|
|
411
446
|
}
|
|
412
447
|
return await Promise.resolve(this.client);
|
|
413
448
|
}
|
|
@@ -418,11 +453,11 @@ var RepoModel = class {
|
|
|
418
453
|
};
|
|
419
454
|
|
|
420
455
|
// src/dynamo/dynamo-data-operation.ts
|
|
421
|
-
var
|
|
456
|
+
var import_joi2 = __toESM(require("joi"), 1);
|
|
422
457
|
|
|
423
458
|
// src/helpers/base-joi-helper.ts
|
|
424
459
|
function getJoiValidationErrors(err) {
|
|
425
|
-
if (
|
|
460
|
+
if (err?.details?.length) {
|
|
426
461
|
const details = JSON.parse(JSON.stringify(err.details));
|
|
427
462
|
const joiData = details.map((x) => x.message.replace(new RegExp('"', "g"), ""));
|
|
428
463
|
return joiData.join("; ");
|
|
@@ -431,17 +466,17 @@ function getJoiValidationErrors(err) {
|
|
|
431
466
|
}
|
|
432
467
|
|
|
433
468
|
// src/core/base-schema.ts
|
|
434
|
-
|
|
469
|
+
var import_joi = __toESM(require("joi"), 1);
|
|
435
470
|
var coreSchemaDefinition = {
|
|
436
|
-
id:
|
|
437
|
-
featureEntity:
|
|
438
|
-
dangerouslyExpireAt: [
|
|
439
|
-
dangerouslyExpireAtTTL:
|
|
471
|
+
id: import_joi.default.string().required().min(5).max(512),
|
|
472
|
+
featureEntity: import_joi.default.string().required().min(2).max(256),
|
|
473
|
+
dangerouslyExpireAt: [import_joi.default.string().isoDate().strict(false), import_joi.default.any().strip()],
|
|
474
|
+
dangerouslyExpireAtTTL: import_joi.default.any().strip()
|
|
440
475
|
};
|
|
441
476
|
|
|
442
477
|
// src/helpers/logging-service.ts
|
|
443
478
|
var LoggingServiceBase = class {
|
|
444
|
-
|
|
479
|
+
mode;
|
|
445
480
|
constructor() {
|
|
446
481
|
const mode = process.env.MOCODY_DEBUG_MODE || "";
|
|
447
482
|
if (String(mode) === "true") {
|
|
@@ -461,7 +496,7 @@ var LoggingServiceBase = class {
|
|
|
461
496
|
log(message, ...optionalParams) {
|
|
462
497
|
try {
|
|
463
498
|
if (this.mode) {
|
|
464
|
-
if (
|
|
499
|
+
if (optionalParams?.length) {
|
|
465
500
|
console.log(message, optionalParams);
|
|
466
501
|
} else {
|
|
467
502
|
console.log(message);
|
|
@@ -482,20 +517,13 @@ var LoggingServiceBase = class {
|
|
|
482
517
|
var LoggingService = new LoggingServiceBase();
|
|
483
518
|
|
|
484
519
|
// src/dynamo/dynamo-manage-table.ts
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
520
|
+
var import_client_dynamodb2 = require("@aws-sdk/client-dynamodb");
|
|
493
521
|
var DynamoManageTable = class {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
522
|
+
partitionKeyFieldName;
|
|
523
|
+
sortKeyFieldName;
|
|
524
|
+
dynamoDb;
|
|
525
|
+
tableFullName;
|
|
526
|
+
secondaryIndexOptions;
|
|
499
527
|
constructor({ dynamoDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName }) {
|
|
500
528
|
this.dynamoDb = dynamoDb;
|
|
501
529
|
this.tableFullName = tableFullName;
|
|
@@ -520,8 +548,8 @@ var DynamoManageTable = class {
|
|
|
520
548
|
Limit: 99
|
|
521
549
|
};
|
|
522
550
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
523
|
-
const listOfTables = await dynamo.send(new
|
|
524
|
-
return
|
|
551
|
+
const listOfTables = await dynamo.send(new import_client_dynamodb2.ListTablesCommand(params));
|
|
552
|
+
return listOfTables?.TableNames;
|
|
525
553
|
}
|
|
526
554
|
async mocody_updateTTL({ isEnabled }) {
|
|
527
555
|
const { tableFullName } = this._tbl_getLocalVariables();
|
|
@@ -534,8 +562,8 @@ var DynamoManageTable = class {
|
|
|
534
562
|
}
|
|
535
563
|
};
|
|
536
564
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
537
|
-
const result = await dynamo.send(new
|
|
538
|
-
if (
|
|
565
|
+
const result = await dynamo.send(new import_client_dynamodb2.UpdateTimeToLiveCommand(params));
|
|
566
|
+
if (result?.TimeToLiveSpecification) {
|
|
539
567
|
return result.TimeToLiveSpecification;
|
|
540
568
|
}
|
|
541
569
|
return null;
|
|
@@ -547,13 +575,13 @@ var DynamoManageTable = class {
|
|
|
547
575
|
TableName: tableFullName
|
|
548
576
|
};
|
|
549
577
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
550
|
-
const result = await dynamo.send(new
|
|
551
|
-
if (
|
|
578
|
+
const result = await dynamo.send(new import_client_dynamodb2.DescribeTableCommand(params));
|
|
579
|
+
if (result?.Table?.TableName === tableFullName) {
|
|
552
580
|
return result.Table;
|
|
553
581
|
}
|
|
554
582
|
return null;
|
|
555
583
|
} catch (error) {
|
|
556
|
-
LoggingService.log({ "@allGetTableInfoBase": "", error:
|
|
584
|
+
LoggingService.log({ "@allGetTableInfoBase": "", error: error?.message });
|
|
557
585
|
return null;
|
|
558
586
|
}
|
|
559
587
|
}
|
|
@@ -562,7 +590,7 @@ var DynamoManageTable = class {
|
|
|
562
590
|
if (!result) {
|
|
563
591
|
return false;
|
|
564
592
|
}
|
|
565
|
-
if (
|
|
593
|
+
if (result?.GlobalSecondaryIndexes) {
|
|
566
594
|
}
|
|
567
595
|
return true;
|
|
568
596
|
}
|
|
@@ -576,20 +604,20 @@ var DynamoManageTable = class {
|
|
|
576
604
|
const allIndexNames = [];
|
|
577
605
|
const newSecondaryIndexOptions = [];
|
|
578
606
|
const updateResults = [];
|
|
579
|
-
if (
|
|
580
|
-
|
|
607
|
+
if (existingTableInfo?.GlobalSecondaryIndexes?.length) {
|
|
608
|
+
existingTableInfo?.GlobalSecondaryIndexes.forEach((indexInfo) => {
|
|
581
609
|
if (indexInfo.IndexName) {
|
|
582
610
|
existingIndexNames.push(indexInfo.IndexName);
|
|
583
611
|
}
|
|
584
|
-
})
|
|
612
|
+
});
|
|
585
613
|
}
|
|
586
|
-
|
|
614
|
+
secondaryIndexOptions?.forEach((newIndexInfo) => {
|
|
587
615
|
allIndexNames.push(newIndexInfo.indexName);
|
|
588
616
|
const indexExists = existingIndexNames.includes(newIndexInfo.indexName);
|
|
589
617
|
if (!indexExists) {
|
|
590
618
|
newSecondaryIndexOptions.push(newIndexInfo);
|
|
591
619
|
}
|
|
592
|
-
})
|
|
620
|
+
});
|
|
593
621
|
existingIndexNames.forEach((indexName) => {
|
|
594
622
|
const existsInList = allIndexNames.includes(indexName);
|
|
595
623
|
if (!existsInList) {
|
|
@@ -622,16 +650,16 @@ var DynamoManageTable = class {
|
|
|
622
650
|
const indexName = creationParams.xGlobalSecondaryIndex[0].IndexName;
|
|
623
651
|
params.AttributeDefinitions = [...creationParams.xAttributeDefinitions];
|
|
624
652
|
creationParams.xGlobalSecondaryIndex.forEach((gsi) => {
|
|
625
|
-
|
|
653
|
+
params.GlobalSecondaryIndexUpdates?.push({
|
|
626
654
|
Create: {
|
|
627
655
|
...gsi
|
|
628
656
|
}
|
|
629
|
-
})
|
|
657
|
+
});
|
|
630
658
|
});
|
|
631
659
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
632
|
-
const result = await dynamo.send(new
|
|
633
|
-
if (
|
|
634
|
-
updateResults.push(
|
|
660
|
+
const result = await dynamo.send(new import_client_dynamodb2.UpdateTableCommand(params));
|
|
661
|
+
if (result?.TableDescription) {
|
|
662
|
+
updateResults.push(result?.TableDescription);
|
|
635
663
|
}
|
|
636
664
|
LoggingService.log(
|
|
637
665
|
[
|
|
@@ -658,15 +686,15 @@ var DynamoManageTable = class {
|
|
|
658
686
|
GlobalSecondaryIndexUpdates: []
|
|
659
687
|
};
|
|
660
688
|
indexCount++;
|
|
661
|
-
|
|
689
|
+
params.GlobalSecondaryIndexUpdates?.push({
|
|
662
690
|
Delete: {
|
|
663
691
|
IndexName: indexName
|
|
664
692
|
}
|
|
665
|
-
})
|
|
693
|
+
});
|
|
666
694
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
667
|
-
const result = await dynamo.send(new
|
|
668
|
-
if (
|
|
669
|
-
updateResults.push(
|
|
695
|
+
const result = await dynamo.send(new import_client_dynamodb2.UpdateTableCommand(params));
|
|
696
|
+
if (result?.TableDescription) {
|
|
697
|
+
updateResults.push(result?.TableDescription);
|
|
670
698
|
}
|
|
671
699
|
LoggingService.log(
|
|
672
700
|
[
|
|
@@ -695,7 +723,7 @@ var DynamoManageTable = class {
|
|
|
695
723
|
} catch (error) {
|
|
696
724
|
LoggingService.log({
|
|
697
725
|
"@allCreateGlobalSecondaryIndexBase": "",
|
|
698
|
-
error:
|
|
726
|
+
error: error?.message
|
|
699
727
|
});
|
|
700
728
|
return null;
|
|
701
729
|
}
|
|
@@ -704,7 +732,7 @@ var DynamoManageTable = class {
|
|
|
704
732
|
const { secondaryIndexOptions } = this._tbl_getLocalVariables();
|
|
705
733
|
const existingTableInfo = await this.mocody_tbl_getTableInfo();
|
|
706
734
|
if (existingTableInfo) {
|
|
707
|
-
if (
|
|
735
|
+
if (secondaryIndexOptions?.length) {
|
|
708
736
|
const result01 = await this._allUpdateGlobalSecondaryIndexBase({
|
|
709
737
|
secondaryIndexOptions,
|
|
710
738
|
existingTableInfo
|
|
@@ -720,12 +748,12 @@ var DynamoManageTable = class {
|
|
|
720
748
|
const { secondaryIndexOptions } = this._tbl_getLocalVariables();
|
|
721
749
|
const existingTableInfo = await this.mocody_tbl_getTableInfo();
|
|
722
750
|
if (existingTableInfo) {
|
|
723
|
-
if (
|
|
751
|
+
if (secondaryIndexOptions?.length) {
|
|
724
752
|
await this._allUpdateGlobalSecondaryIndexBase({
|
|
725
753
|
secondaryIndexOptions,
|
|
726
754
|
existingTableInfo
|
|
727
755
|
});
|
|
728
|
-
} else if (
|
|
756
|
+
} else if (existingTableInfo.GlobalSecondaryIndexes?.length) {
|
|
729
757
|
await this._allUpdateGlobalSecondaryIndexBase({
|
|
730
758
|
secondaryIndexOptions: [],
|
|
731
759
|
existingTableInfo
|
|
@@ -753,35 +781,35 @@ var DynamoManageTable = class {
|
|
|
753
781
|
const sortKeyFieldName01 = sortKeyFieldName;
|
|
754
782
|
if (!attributeDefinitionsNameList.includes(partitionKeyFieldName01)) {
|
|
755
783
|
attributeDefinitionsNameList.push(partitionKeyFieldName01);
|
|
756
|
-
|
|
784
|
+
params?.AttributeDefinitions?.push({
|
|
757
785
|
AttributeName: partitionKeyFieldName01,
|
|
758
786
|
AttributeType: dataTypes.partitionKeyDataType
|
|
759
|
-
})
|
|
787
|
+
});
|
|
760
788
|
}
|
|
761
789
|
if (!attributeDefinitionsNameList.includes(sortKeyFieldName01)) {
|
|
762
790
|
attributeDefinitionsNameList.push(sortKeyFieldName01);
|
|
763
|
-
|
|
791
|
+
params?.AttributeDefinitions?.push({
|
|
764
792
|
AttributeName: sortKeyFieldName01,
|
|
765
793
|
AttributeType: dataTypes.sortKeyDataType
|
|
766
|
-
})
|
|
794
|
+
});
|
|
767
795
|
}
|
|
768
796
|
let projectionFields = projectionFieldsInclude || [];
|
|
769
|
-
let projectionType =
|
|
770
|
-
if (
|
|
797
|
+
let projectionType = import_client_dynamodb2.ProjectionType.ALL;
|
|
798
|
+
if (projectionFields?.length) {
|
|
771
799
|
projectionFields = projectionFields.filter((field) => {
|
|
772
800
|
return field !== partitionKeyFieldName01 && field !== sortKeyFieldName01;
|
|
773
801
|
});
|
|
774
802
|
if (projectionFields.length === 0) {
|
|
775
|
-
projectionType =
|
|
803
|
+
projectionType = import_client_dynamodb2.ProjectionType.KEYS_ONLY;
|
|
776
804
|
} else {
|
|
777
|
-
projectionType =
|
|
805
|
+
projectionType = import_client_dynamodb2.ProjectionType.INCLUDE;
|
|
778
806
|
}
|
|
779
807
|
}
|
|
780
|
-
|
|
808
|
+
params.GlobalSecondaryIndexes?.push({
|
|
781
809
|
IndexName: indexName,
|
|
782
810
|
Projection: {
|
|
783
811
|
ProjectionType: projectionType,
|
|
784
|
-
NonKeyAttributes: projectionType ===
|
|
812
|
+
NonKeyAttributes: projectionType === import_client_dynamodb2.ProjectionType.INCLUDE ? projectionFields : void 0
|
|
785
813
|
},
|
|
786
814
|
KeySchema: [
|
|
787
815
|
{
|
|
@@ -793,7 +821,7 @@ var DynamoManageTable = class {
|
|
|
793
821
|
KeyType: "RANGE"
|
|
794
822
|
}
|
|
795
823
|
]
|
|
796
|
-
})
|
|
824
|
+
});
|
|
797
825
|
});
|
|
798
826
|
return {
|
|
799
827
|
xAttributeDefinitions: params.AttributeDefinitions || [],
|
|
@@ -836,16 +864,16 @@ var DynamoManageTable = class {
|
|
|
836
864
|
Value: tableFullName
|
|
837
865
|
}
|
|
838
866
|
];
|
|
839
|
-
if (
|
|
867
|
+
if (secondaryIndexOptions?.length) {
|
|
840
868
|
const creationParams = this._getGlobalSecondaryIndexCreationParams({
|
|
841
869
|
secondaryIndexOptions
|
|
842
870
|
});
|
|
843
|
-
if (
|
|
844
|
-
const existAttrDefNames =
|
|
871
|
+
if (creationParams.xAttributeDefinitions?.length) {
|
|
872
|
+
const existAttrDefNames = params.AttributeDefinitions?.map((def) => def.AttributeName);
|
|
845
873
|
creationParams.xAttributeDefinitions.forEach((def) => {
|
|
846
|
-
const alreadyDefined =
|
|
874
|
+
const alreadyDefined = existAttrDefNames?.includes(def.AttributeName);
|
|
847
875
|
if (!alreadyDefined) {
|
|
848
|
-
|
|
876
|
+
params.AttributeDefinitions?.push(def);
|
|
849
877
|
}
|
|
850
878
|
});
|
|
851
879
|
}
|
|
@@ -855,12 +883,12 @@ var DynamoManageTable = class {
|
|
|
855
883
|
"@allCreateTableBase, table: ": tableFullName
|
|
856
884
|
});
|
|
857
885
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
858
|
-
const result = await dynamo.send(new
|
|
859
|
-
if (
|
|
886
|
+
const result = await dynamo.send(new import_client_dynamodb2.CreateTableCommand(params));
|
|
887
|
+
if (result?.TableDescription) {
|
|
860
888
|
LoggingService.log(
|
|
861
|
-
[`@allCreateTableBase,`, `Created table: '${
|
|
889
|
+
[`@allCreateTableBase,`, `Created table: '${result?.TableDescription.TableName}'`, (/* @__PURE__ */ new Date()).toTimeString()].join(" ")
|
|
862
890
|
);
|
|
863
|
-
return
|
|
891
|
+
return result.TableDescription?.TableName;
|
|
864
892
|
}
|
|
865
893
|
return null;
|
|
866
894
|
}
|
|
@@ -877,9 +905,9 @@ var DynamoManageTable = class {
|
|
|
877
905
|
]
|
|
878
906
|
};
|
|
879
907
|
const dynamo = await this._tbl_dynamoDb().getInstance();
|
|
880
|
-
const result = await dynamo.send(new
|
|
881
|
-
if (
|
|
882
|
-
return
|
|
908
|
+
const result = await dynamo.send(new import_client_dynamodb2.UpdateTableCommand(params));
|
|
909
|
+
if (result?.TableDescription) {
|
|
910
|
+
return result.TableDescription?.TableName;
|
|
883
911
|
}
|
|
884
912
|
return null;
|
|
885
913
|
}
|
|
@@ -936,7 +964,7 @@ var QueryValidatorCheckBase = class {
|
|
|
936
964
|
if (!(conditionValue && typeof conditionValue === "object")) {
|
|
937
965
|
this.queryErrorThrowChecks({ conditionValue, queryType: "$elemMatch" });
|
|
938
966
|
}
|
|
939
|
-
if (!(
|
|
967
|
+
if (!(conditionValue?.$in?.length && Array.isArray(conditionValue.$in))) {
|
|
940
968
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(
|
|
941
969
|
"$elemMatch must have a valid $in query and must be an array of non-zero length"
|
|
942
970
|
);
|
|
@@ -994,10 +1022,10 @@ function getDynamoRandomKeyOrHash(prefix) {
|
|
|
994
1022
|
return [prefix, UtilService.getRandomString(6)].join("").toLowerCase();
|
|
995
1023
|
}
|
|
996
1024
|
var QueryConditionBuilder = class {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1025
|
+
expressAttrVal;
|
|
1026
|
+
expressAttrName;
|
|
1027
|
+
expressAttrNameInverse;
|
|
1028
|
+
filterExpressionValue01;
|
|
1001
1029
|
constructor() {
|
|
1002
1030
|
this.expressAttrVal = {};
|
|
1003
1031
|
this.expressAttrName = {};
|
|
@@ -1411,7 +1439,7 @@ var DynamoFilterQueryOperation = class {
|
|
|
1411
1439
|
fieldName,
|
|
1412
1440
|
attrValues: conditionValue
|
|
1413
1441
|
});
|
|
1414
|
-
if (
|
|
1442
|
+
if (elemMatchConditions?.length) {
|
|
1415
1443
|
elemMatchConditions.forEach((cond) => {
|
|
1416
1444
|
orConditions.push(cond);
|
|
1417
1445
|
});
|
|
@@ -1492,7 +1520,7 @@ var DynamoFilterQueryOperation = class {
|
|
|
1492
1520
|
queryObject: orQueryObjectOrValue
|
|
1493
1521
|
});
|
|
1494
1522
|
LoggingService.logAsString({ hasMultiField, orQueryCond01 });
|
|
1495
|
-
if (
|
|
1523
|
+
if (orQueryCond01?.queryConditions?.length) {
|
|
1496
1524
|
if (hasMultiField) {
|
|
1497
1525
|
OR_queryMultiConditionsPrivate.push(...orQueryCond01.queryConditions);
|
|
1498
1526
|
} else {
|
|
@@ -1606,25 +1634,25 @@ var DynamoFilterQueryOperation = class {
|
|
|
1606
1634
|
});
|
|
1607
1635
|
let _andfilterExpression = "";
|
|
1608
1636
|
let _orfilterExpression = "";
|
|
1609
|
-
if (
|
|
1637
|
+
if (AND_FilterExpressionArray?.length) {
|
|
1610
1638
|
_andfilterExpression = AND_FilterExpressionArray.join(" AND ").trim();
|
|
1611
1639
|
}
|
|
1612
|
-
if (
|
|
1640
|
+
if (OR_FilterExpressionMultiFieldsArray?.length) {
|
|
1613
1641
|
const subQuery = [];
|
|
1614
1642
|
OR_FilterExpressionMultiFieldsArray.forEach((item01) => {
|
|
1615
1643
|
const val = item01.join(" AND ").trim();
|
|
1616
1644
|
subQuery.push(`(${val})`);
|
|
1617
1645
|
});
|
|
1618
1646
|
_orfilterExpression = [...OR_FilterExpressionArray, ...subQuery].join(" OR ").trim();
|
|
1619
|
-
} else if (
|
|
1647
|
+
} else if (OR_FilterExpressionArray?.length) {
|
|
1620
1648
|
_orfilterExpression = OR_FilterExpressionArray.join(" OR ").trim();
|
|
1621
1649
|
}
|
|
1622
1650
|
let allFilters = [_andfilterExpression, _orfilterExpression].filter((f) => f);
|
|
1623
|
-
if (
|
|
1651
|
+
if (allFilters?.length && allFilters.length > 1) {
|
|
1624
1652
|
allFilters = allFilters.map((f) => `(${f})`);
|
|
1625
1653
|
}
|
|
1626
1654
|
const _filterExpression = allFilters.join(" AND ");
|
|
1627
|
-
if (
|
|
1655
|
+
if (projectionFields?.length && Array.isArray(projectionFields)) {
|
|
1628
1656
|
const _projection_expressionAttributeNames = {};
|
|
1629
1657
|
projectionFields.forEach((field) => {
|
|
1630
1658
|
if (field && typeof field === "string") {
|
|
@@ -1652,8 +1680,8 @@ var DynamoFilterQueryOperation = class {
|
|
|
1652
1680
|
};
|
|
1653
1681
|
|
|
1654
1682
|
// src/dynamo/dynamo-query-scan-processor.ts
|
|
1655
|
-
|
|
1656
|
-
|
|
1683
|
+
var import_client_dynamodb3 = require("@aws-sdk/client-dynamodb");
|
|
1684
|
+
var import_util_dynamodb2 = require("@aws-sdk/util-dynamodb");
|
|
1657
1685
|
var DynamoQueryScanProcessor = class {
|
|
1658
1686
|
//
|
|
1659
1687
|
async mocody__helperDynamoQueryProcessor({
|
|
@@ -1669,8 +1697,8 @@ var DynamoQueryScanProcessor = class {
|
|
|
1669
1697
|
featureEntityValue,
|
|
1670
1698
|
tableFullName
|
|
1671
1699
|
}) {
|
|
1672
|
-
if (
|
|
1673
|
-
const marshalled =
|
|
1700
|
+
if (params?.ExpressionAttributeValues) {
|
|
1701
|
+
const marshalled = (0, import_util_dynamodb2.marshall)(params.ExpressionAttributeValues, {
|
|
1674
1702
|
convertEmptyValues: false,
|
|
1675
1703
|
removeUndefinedValues: true
|
|
1676
1704
|
});
|
|
@@ -1767,10 +1795,10 @@ var DynamoQueryScanProcessor = class {
|
|
|
1767
1795
|
LoggingService.logAsString({ query_start: params01 });
|
|
1768
1796
|
while (hasNext) {
|
|
1769
1797
|
try {
|
|
1770
|
-
const { Items, LastEvaluatedKey } = await dynamoClient.send(new
|
|
1798
|
+
const { Items, LastEvaluatedKey } = await dynamoClient.send(new import_client_dynamodb3.QueryCommand(params01));
|
|
1771
1799
|
params01.ExclusiveStartKey = void 0;
|
|
1772
|
-
itemsLoopedOrderedLength.push(
|
|
1773
|
-
if (
|
|
1800
|
+
itemsLoopedOrderedLength.push(Items?.length || 0);
|
|
1801
|
+
if (Items?.length) {
|
|
1774
1802
|
returnedItems = [...returnedItems, ...Items];
|
|
1775
1803
|
}
|
|
1776
1804
|
LoggingService.log({
|
|
@@ -1825,7 +1853,7 @@ var DynamoQueryScanProcessor = class {
|
|
|
1825
1853
|
break;
|
|
1826
1854
|
}
|
|
1827
1855
|
} catch (error) {
|
|
1828
|
-
if (
|
|
1856
|
+
if (returnedItems?.length) {
|
|
1829
1857
|
outResult.paginationResults = [...returnedItems];
|
|
1830
1858
|
outResult.nextPageHash = void 0;
|
|
1831
1859
|
} else {
|
|
@@ -1849,7 +1877,7 @@ var DynamoQueryScanProcessor = class {
|
|
|
1849
1877
|
return { ...outResult };
|
|
1850
1878
|
}
|
|
1851
1879
|
__unmarshallToJson(items) {
|
|
1852
|
-
if (
|
|
1880
|
+
if (items?.length) {
|
|
1853
1881
|
return items.map((item) => MocodyUtil.unmarshallToJson(item));
|
|
1854
1882
|
}
|
|
1855
1883
|
return items;
|
|
@@ -1885,7 +1913,7 @@ var DynamoQueryScanProcessor = class {
|
|
|
1885
1913
|
return obj;
|
|
1886
1914
|
}
|
|
1887
1915
|
const itemJson = MocodyUtil.unmarshallToJson(lastKeyRawObject);
|
|
1888
|
-
const dataId =
|
|
1916
|
+
const dataId = itemJson?.[partitionKeyFieldName];
|
|
1889
1917
|
if (!dataId) {
|
|
1890
1918
|
return null;
|
|
1891
1919
|
}
|
|
@@ -1994,7 +2022,7 @@ var DynamoQueryPartiqlProcessor = class {
|
|
|
1994
2022
|
}
|
|
1995
2023
|
}
|
|
1996
2024
|
const projectionField01 = (() => {
|
|
1997
|
-
if (
|
|
2025
|
+
if (projectionFields?.length) {
|
|
1998
2026
|
return projectionFields.map((f) => JSON.stringify(f)).join(",").trim();
|
|
1999
2027
|
}
|
|
2000
2028
|
return "*";
|
|
@@ -2004,7 +2032,7 @@ var DynamoQueryPartiqlProcessor = class {
|
|
|
2004
2032
|
if (current_PartitionKeyFieldName) {
|
|
2005
2033
|
}
|
|
2006
2034
|
const statementText = [`SELECT ${projectionField01} FROM ${tableName} WHERE ${current_PartitionKeyFieldName}=?`];
|
|
2007
|
-
if (
|
|
2035
|
+
if (params.subStatement?.length) {
|
|
2008
2036
|
if (!params.subStatement[0].trim().startsWith("AND")) {
|
|
2009
2037
|
statementText.push("AND");
|
|
2010
2038
|
}
|
|
@@ -2041,8 +2069,8 @@ var DynamoQueryPartiqlProcessor = class {
|
|
|
2041
2069
|
try {
|
|
2042
2070
|
const { Items, LastEvaluatedKey, NextToken } = await dynamo.executeStatement(params01);
|
|
2043
2071
|
params01.NextToken = void 0;
|
|
2044
|
-
itemsLoopedOrderedLength.push(
|
|
2045
|
-
if (
|
|
2072
|
+
itemsLoopedOrderedLength.push(Items?.length || 0);
|
|
2073
|
+
if (Items?.length) {
|
|
2046
2074
|
returnedItems = [...returnedItems, ...Items];
|
|
2047
2075
|
}
|
|
2048
2076
|
LoggingService.log({
|
|
@@ -2082,7 +2110,7 @@ var DynamoQueryPartiqlProcessor = class {
|
|
|
2082
2110
|
break;
|
|
2083
2111
|
}
|
|
2084
2112
|
} catch (error) {
|
|
2085
|
-
if (
|
|
2113
|
+
if (returnedItems?.length) {
|
|
2086
2114
|
outResult.paginationResults = [...returnedItems];
|
|
2087
2115
|
outResult.nextPageHash = void 0;
|
|
2088
2116
|
} else {
|
|
@@ -2136,7 +2164,7 @@ var DynamoQueryPartiqlProcessor = class {
|
|
|
2136
2164
|
if (Object.keys(obj).length === fields.length) {
|
|
2137
2165
|
return obj;
|
|
2138
2166
|
}
|
|
2139
|
-
const dataId =
|
|
2167
|
+
const dataId = lastKeyRawObject?.[partitionKeyFieldName];
|
|
2140
2168
|
if (!dataId) {
|
|
2141
2169
|
return null;
|
|
2142
2170
|
}
|
|
@@ -2386,7 +2414,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2386
2414
|
fieldName,
|
|
2387
2415
|
attrParams
|
|
2388
2416
|
}) {
|
|
2389
|
-
if (!(typeof
|
|
2417
|
+
if (!(typeof attrParams?.query === "object" && typeof attrParams?.index === "number" && attrParams?.index >= 0 && attrParams?.path?.length && Array.isArray(attrParams.path))) {
|
|
2390
2418
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Invalid attrParams @ filterNestedMatch`);
|
|
2391
2419
|
}
|
|
2392
2420
|
const queryList = [];
|
|
@@ -2513,7 +2541,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2513
2541
|
fieldName,
|
|
2514
2542
|
attrValues: conditionValue
|
|
2515
2543
|
});
|
|
2516
|
-
if (
|
|
2544
|
+
if (elemMatchConditions?.length) {
|
|
2517
2545
|
elemMatchConditions.forEach((cond) => {
|
|
2518
2546
|
orConditions.push(cond);
|
|
2519
2547
|
});
|
|
@@ -2524,7 +2552,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2524
2552
|
fieldName,
|
|
2525
2553
|
attrValues: conditionValue
|
|
2526
2554
|
});
|
|
2527
|
-
if (
|
|
2555
|
+
if (nestedMatchConditions?.length) {
|
|
2528
2556
|
queryConditions.push(...nestedMatchConditions);
|
|
2529
2557
|
}
|
|
2530
2558
|
} else if (conditionKey === "$nestedArrayMatch") {
|
|
@@ -2533,7 +2561,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2533
2561
|
fieldName,
|
|
2534
2562
|
attrParams: conditionValue
|
|
2535
2563
|
});
|
|
2536
|
-
if (
|
|
2564
|
+
if (nestedMatchConditions?.length) {
|
|
2537
2565
|
queryConditions.push(...nestedMatchConditions);
|
|
2538
2566
|
}
|
|
2539
2567
|
} else if (conditionKey === "$notContains") {
|
|
@@ -2607,7 +2635,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2607
2635
|
fieldName,
|
|
2608
2636
|
queryObject: orQueryObjectOrValue
|
|
2609
2637
|
});
|
|
2610
|
-
if (
|
|
2638
|
+
if (orQueryCond01?.queryConditions?.length) {
|
|
2611
2639
|
if (hasMultiField) {
|
|
2612
2640
|
OR_queryMultiConditionsPrivate.push(...orQueryCond01.queryConditions);
|
|
2613
2641
|
} else {
|
|
@@ -2679,7 +2707,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2679
2707
|
LoggingService.logAsString({ out01 });
|
|
2680
2708
|
const subStatement = [];
|
|
2681
2709
|
const subParameter = [];
|
|
2682
|
-
if (
|
|
2710
|
+
if (AND_queryConditions?.length) {
|
|
2683
2711
|
AND_queryConditions.forEach((f, i) => {
|
|
2684
2712
|
if (i !== 0) {
|
|
2685
2713
|
subStatement.push(" AND ");
|
|
@@ -2688,7 +2716,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2688
2716
|
subParameter.push(...f.subParameters);
|
|
2689
2717
|
});
|
|
2690
2718
|
}
|
|
2691
|
-
if (
|
|
2719
|
+
if (OR_queryConditions?.length) {
|
|
2692
2720
|
if (subStatement.length) {
|
|
2693
2721
|
subStatement.push(" AND ");
|
|
2694
2722
|
}
|
|
@@ -2707,7 +2735,7 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2707
2735
|
subStatement.push(")");
|
|
2708
2736
|
}
|
|
2709
2737
|
}
|
|
2710
|
-
if (
|
|
2738
|
+
if (OR_queryConditions_multiFields?.length) {
|
|
2711
2739
|
subStatement.push("(");
|
|
2712
2740
|
OR_queryConditions_multiFields.forEach((qItem, i) => {
|
|
2713
2741
|
if (i !== 0) {
|
|
@@ -2731,28 +2759,28 @@ var DynamoFilterQueryPartiQlOperation = class {
|
|
|
2731
2759
|
};
|
|
2732
2760
|
|
|
2733
2761
|
// src/dynamo/dynamo-data-operation.ts
|
|
2734
|
-
var DynamoDataOperation =
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2762
|
+
var DynamoDataOperation = class extends RepoModel {
|
|
2763
|
+
_mocody_partitionKeyFieldName = "id";
|
|
2764
|
+
_mocody_sortKeyFieldName = "featureEntity";
|
|
2765
|
+
_mocody_featureEntity_Key_Value;
|
|
2738
2766
|
//
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2767
|
+
_mocody_dynamoDb;
|
|
2768
|
+
_mocody_dataKeyGenerator;
|
|
2769
|
+
_mocody_schema;
|
|
2770
|
+
_mocody_tableFullName;
|
|
2771
|
+
_mocody_strictRequiredFields;
|
|
2772
|
+
_mocody_featureEntityValue;
|
|
2773
|
+
_mocody_secondaryIndexOptions;
|
|
2774
|
+
_mocody_queryFilter;
|
|
2775
|
+
_mocody_queryPartiQlFilter;
|
|
2748
2776
|
//
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2777
|
+
_mocody_queryScanProcessor;
|
|
2778
|
+
_mocody_queryPartiQlProcessor;
|
|
2779
|
+
_mocody_entityFieldsKeySet;
|
|
2752
2780
|
//
|
|
2753
|
-
|
|
2781
|
+
_mocody_fieldAliases;
|
|
2754
2782
|
//
|
|
2755
|
-
|
|
2783
|
+
_mocody_tableManager;
|
|
2756
2784
|
constructor({
|
|
2757
2785
|
schemaDef,
|
|
2758
2786
|
dynamoDbInitializer,
|
|
@@ -2763,7 +2791,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2763
2791
|
dataKeyGenerator,
|
|
2764
2792
|
fieldAliases
|
|
2765
2793
|
}) {
|
|
2766
|
-
super();
|
|
2794
|
+
super();
|
|
2767
2795
|
this._mocody_dynamoDb = dynamoDbInitializer;
|
|
2768
2796
|
this._mocody_dataKeyGenerator = dataKeyGenerator;
|
|
2769
2797
|
this._mocody_tableFullName = baseTableName;
|
|
@@ -2784,7 +2812,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2784
2812
|
Object.keys(fullSchemaMapDef).forEach((key) => {
|
|
2785
2813
|
this._mocody_entityFieldsKeySet.add(key);
|
|
2786
2814
|
});
|
|
2787
|
-
this._mocody_schema =
|
|
2815
|
+
this._mocody_schema = import_joi2.default.object().keys(fullSchemaMapDef);
|
|
2788
2816
|
}
|
|
2789
2817
|
mocody_tableManager() {
|
|
2790
2818
|
if (!this._mocody_tableManager) {
|
|
@@ -2832,7 +2860,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2832
2860
|
_mocody_checkValidateStrictRequiredFields(onDataObj) {
|
|
2833
2861
|
this._mocody_checkValidateMustBeAnObjectDataType(onDataObj);
|
|
2834
2862
|
const { strictRequiredFields } = this._mocody_getLocalVariables();
|
|
2835
|
-
if (
|
|
2863
|
+
if (strictRequiredFields?.length) {
|
|
2836
2864
|
strictRequiredFields.forEach((field) => {
|
|
2837
2865
|
if (onDataObj[field] === null || onDataObj[field] === void 0) {
|
|
2838
2866
|
throw this._mocody_createGenericError(`Strict required field: '${field}', NOT defined`);
|
|
@@ -2847,7 +2875,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2847
2875
|
item,
|
|
2848
2876
|
withCondition
|
|
2849
2877
|
}) {
|
|
2850
|
-
if (item && typeof item === "object" &&
|
|
2878
|
+
if (item && typeof item === "object" && withCondition?.length) {
|
|
2851
2879
|
const isPassed = withCondition.every(({ field, equals }) => {
|
|
2852
2880
|
return item[field] !== void 0 && item[field] === equals;
|
|
2853
2881
|
});
|
|
@@ -2863,7 +2891,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2863
2891
|
stripUnknown: true
|
|
2864
2892
|
});
|
|
2865
2893
|
if (error) {
|
|
2866
|
-
const msg =
|
|
2894
|
+
const msg = getJoiValidationErrors(error) ?? "Validation error occured";
|
|
2867
2895
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(msg);
|
|
2868
2896
|
}
|
|
2869
2897
|
const validatedData = MocodyUtil.alignFormatFieldAlias({
|
|
@@ -2879,7 +2907,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2879
2907
|
return await Promise.resolve({ validatedData });
|
|
2880
2908
|
}
|
|
2881
2909
|
_mocody_formatTTL(fullData) {
|
|
2882
|
-
if (
|
|
2910
|
+
if (fullData?.dangerouslyExpireAt) {
|
|
2883
2911
|
fullData.dangerouslyExpireAtTTL = UtilService.getEpochTime(fullData.dangerouslyExpireAt);
|
|
2884
2912
|
} else {
|
|
2885
2913
|
delete fullData.dangerouslyExpireAtTTL;
|
|
@@ -2913,7 +2941,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
2913
2941
|
const result = { ...validatedData };
|
|
2914
2942
|
return result;
|
|
2915
2943
|
} catch (error) {
|
|
2916
|
-
if (
|
|
2944
|
+
if (error?.name === "ConditionalCheckFailedException") {
|
|
2917
2945
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Field, ${partitionKeyFieldName} already exists`);
|
|
2918
2946
|
}
|
|
2919
2947
|
throw error;
|
|
@@ -3002,10 +3030,10 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3002
3030
|
} = this._mocody_getLocalVariables();
|
|
3003
3031
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ Update1DataId: dataId });
|
|
3004
3032
|
const dataInDb = await this.mocody_getOneById({ dataId });
|
|
3005
|
-
if (!
|
|
3033
|
+
if (!dataInDb?.[partitionKeyFieldName]) {
|
|
3006
3034
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError("Data does NOT exists");
|
|
3007
3035
|
}
|
|
3008
|
-
if (
|
|
3036
|
+
if (dataInDb?.[sortKeyFieldName] !== featureEntityValue) {
|
|
3009
3037
|
throw this._mocody_createGenericError("Record does not exists");
|
|
3010
3038
|
}
|
|
3011
3039
|
const isPassed = this._mocody_withConditionPassed({
|
|
@@ -3118,7 +3146,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3118
3146
|
queryDefs: query01,
|
|
3119
3147
|
projectionFields: void 0
|
|
3120
3148
|
});
|
|
3121
|
-
|
|
3149
|
+
transactData.TransactItems?.push({
|
|
3122
3150
|
Put: {
|
|
3123
3151
|
TableName: item.tableName,
|
|
3124
3152
|
Item: item.data,
|
|
@@ -3126,7 +3154,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3126
3154
|
ExpressionAttributeNames: expressionAttributeNames,
|
|
3127
3155
|
ExpressionAttributeValues: expressionAttributeValues
|
|
3128
3156
|
}
|
|
3129
|
-
})
|
|
3157
|
+
});
|
|
3130
3158
|
} else if (item.kind === "update") {
|
|
3131
3159
|
const query01 = {
|
|
3132
3160
|
[item.partitionKeyFieldName]: { $exists: true }
|
|
@@ -3140,7 +3168,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3140
3168
|
queryDefs: query01,
|
|
3141
3169
|
projectionFields: void 0
|
|
3142
3170
|
});
|
|
3143
|
-
|
|
3171
|
+
transactData.TransactItems?.push({
|
|
3144
3172
|
Put: {
|
|
3145
3173
|
TableName: item.tableName,
|
|
3146
3174
|
Item: item.data,
|
|
@@ -3148,7 +3176,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3148
3176
|
ExpressionAttributeNames: expressionAttributeNames,
|
|
3149
3177
|
ExpressionAttributeValues: expressionAttributeValues
|
|
3150
3178
|
}
|
|
3151
|
-
})
|
|
3179
|
+
});
|
|
3152
3180
|
} else if (item.kind === "delete") {
|
|
3153
3181
|
const query01 = {
|
|
3154
3182
|
[item.partitionKeyFieldName]: { $exists: true }
|
|
@@ -3162,7 +3190,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3162
3190
|
queryDefs: query01,
|
|
3163
3191
|
projectionFields: void 0
|
|
3164
3192
|
});
|
|
3165
|
-
|
|
3193
|
+
transactData.TransactItems?.push({
|
|
3166
3194
|
Delete: {
|
|
3167
3195
|
TableName: item.tableName,
|
|
3168
3196
|
Key: item.keyQuery,
|
|
@@ -3170,7 +3198,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3170
3198
|
ExpressionAttributeNames: expressionAttributeNames,
|
|
3171
3199
|
ExpressionAttributeValues: expressionAttributeValues
|
|
3172
3200
|
}
|
|
3173
|
-
})
|
|
3201
|
+
});
|
|
3174
3202
|
}
|
|
3175
3203
|
}
|
|
3176
3204
|
await this._mocody_dynamoInit().transactWriteItems(transactData);
|
|
@@ -3192,20 +3220,20 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3192
3220
|
withCondition
|
|
3193
3221
|
}) {
|
|
3194
3222
|
const dataList = [];
|
|
3195
|
-
if (!
|
|
3223
|
+
if (!dataIds?.length) {
|
|
3196
3224
|
return dataList;
|
|
3197
3225
|
}
|
|
3198
3226
|
dataIds.forEach((dataId) => {
|
|
3199
3227
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ BatchGetDataId: dataId });
|
|
3200
3228
|
});
|
|
3201
3229
|
const originalIds = this._mocody_removeDuplicateString(dataIds);
|
|
3202
|
-
if (
|
|
3230
|
+
if (originalIds?.length === 1) {
|
|
3203
3231
|
const result = await this.mocody_getOneById({
|
|
3204
3232
|
dataId: originalIds[0],
|
|
3205
3233
|
withCondition
|
|
3206
3234
|
});
|
|
3207
3235
|
if (result) {
|
|
3208
|
-
if (
|
|
3236
|
+
if (fields?.length) {
|
|
3209
3237
|
const result01 = UtilService.pickFromObject({ dataObject: result, pickKeys: fields });
|
|
3210
3238
|
dataList.push(result01);
|
|
3211
3239
|
} else {
|
|
@@ -3249,9 +3277,9 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3249
3277
|
let projectionExpression;
|
|
3250
3278
|
let expressionAttributeNames;
|
|
3251
3279
|
const fields01 = this._mocody_getProjectionFields({ fields, excludeFields });
|
|
3252
|
-
if (
|
|
3280
|
+
if (fields01?.length) {
|
|
3253
3281
|
const fieldKeys = new Set(fields01);
|
|
3254
|
-
if (
|
|
3282
|
+
if (withCondition?.length) {
|
|
3255
3283
|
withCondition.forEach((condition) => {
|
|
3256
3284
|
fieldKeys.add(condition.field);
|
|
3257
3285
|
});
|
|
@@ -3265,7 +3293,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3265
3293
|
}
|
|
3266
3294
|
}
|
|
3267
3295
|
});
|
|
3268
|
-
if (
|
|
3296
|
+
if (Object.keys(expressionAttributeNames)?.length) {
|
|
3269
3297
|
projectionExpression = Object.keys(expressionAttributeNames).join(",");
|
|
3270
3298
|
} else {
|
|
3271
3299
|
projectionExpression = void 0;
|
|
@@ -3299,7 +3327,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3299
3327
|
const { Responses, UnprocessedKeys } = await dynamo.batchGetItem(params01);
|
|
3300
3328
|
if (Responses) {
|
|
3301
3329
|
const itemListRaw = Responses[tableFullName];
|
|
3302
|
-
if (
|
|
3330
|
+
if (itemListRaw?.length) {
|
|
3303
3331
|
const itemList = itemListRaw.map((item) => MocodyUtil.unmarshallToJson(item));
|
|
3304
3332
|
returnedItems = [...returnedItems, ...itemList];
|
|
3305
3333
|
}
|
|
@@ -3316,14 +3344,14 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3316
3344
|
} catch (error) {
|
|
3317
3345
|
hasNext = false;
|
|
3318
3346
|
LoggingService.error(error);
|
|
3319
|
-
if (!
|
|
3347
|
+
if (!returnedItems?.length) {
|
|
3320
3348
|
throw error;
|
|
3321
3349
|
} else {
|
|
3322
3350
|
break;
|
|
3323
3351
|
}
|
|
3324
3352
|
}
|
|
3325
3353
|
}
|
|
3326
|
-
if (
|
|
3354
|
+
if (returnedItems?.length && withCondition?.length) {
|
|
3327
3355
|
const returnedItems01 = [];
|
|
3328
3356
|
returnedItems.forEach((item) => {
|
|
3329
3357
|
const canInclude = withCondition.every((condition) => item[condition.field] === condition.equals);
|
|
@@ -3341,7 +3369,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3341
3369
|
canPaginate: false,
|
|
3342
3370
|
enableRelationFetch: false
|
|
3343
3371
|
});
|
|
3344
|
-
if (
|
|
3372
|
+
if (result?.paginationResults) {
|
|
3345
3373
|
return result.paginationResults;
|
|
3346
3374
|
}
|
|
3347
3375
|
return [];
|
|
@@ -3359,7 +3387,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3359
3387
|
canPaginate: false,
|
|
3360
3388
|
enableRelationFetch: true
|
|
3361
3389
|
});
|
|
3362
|
-
if (
|
|
3390
|
+
if (result?.paginationResults) {
|
|
3363
3391
|
return result.paginationResults;
|
|
3364
3392
|
}
|
|
3365
3393
|
return [];
|
|
@@ -3394,11 +3422,11 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3394
3422
|
sortKeyFieldName,
|
|
3395
3423
|
featureEntityValue
|
|
3396
3424
|
} = this._mocody_getLocalVariables();
|
|
3397
|
-
if (!
|
|
3425
|
+
if (!secondaryIndexOptions?.length) {
|
|
3398
3426
|
throw this._mocody_createGenericError("Invalid secondary index definitions");
|
|
3399
3427
|
}
|
|
3400
3428
|
const paramOption01 = { ...paramOption };
|
|
3401
|
-
if (!
|
|
3429
|
+
if (!paramOption01?.indexName) {
|
|
3402
3430
|
throw this._mocody_createGenericError("Invalid index name input");
|
|
3403
3431
|
}
|
|
3404
3432
|
const secondaryIndex = secondaryIndexOptions.find((item) => {
|
|
@@ -3414,7 +3442,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3414
3442
|
fields: paramOption01.fields,
|
|
3415
3443
|
excludeFields: paramOption01.excludeFields
|
|
3416
3444
|
});
|
|
3417
|
-
if (canPaginate &&
|
|
3445
|
+
if (canPaginate && fields01?.length) {
|
|
3418
3446
|
const fieldSet01 = new Set(fields01);
|
|
3419
3447
|
fieldSet01.add(partitionKeyFieldName);
|
|
3420
3448
|
projectionFields = Array.from(fieldSet01);
|
|
@@ -3426,8 +3454,8 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3426
3454
|
if (paramOption01.limit && UtilService.isNumericInteger(paramOption01.limit)) {
|
|
3427
3455
|
resultLimit01 = Number(paramOption01.limit);
|
|
3428
3456
|
}
|
|
3429
|
-
if (
|
|
3430
|
-
evaluationLimit01 =
|
|
3457
|
+
if (paramOption01?.pagingParams?.evaluationLimit) {
|
|
3458
|
+
evaluationLimit01 = paramOption01?.pagingParams?.evaluationLimit;
|
|
3431
3459
|
} else if (!paramOption01.query && resultLimit01) {
|
|
3432
3460
|
evaluationLimit01 = resultLimit01;
|
|
3433
3461
|
}
|
|
@@ -3472,7 +3500,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3472
3500
|
});
|
|
3473
3501
|
otherExpressionAttributeValues = otherFilter.expressionAttributeValues;
|
|
3474
3502
|
otherExpressionAttributeNames = otherFilter.expressionAttributeNames;
|
|
3475
|
-
if (
|
|
3503
|
+
if (otherFilter?.filterExpression?.length && otherFilter?.filterExpression.length > 1) {
|
|
3476
3504
|
otherFilterExpression = otherFilter.filterExpression;
|
|
3477
3505
|
}
|
|
3478
3506
|
}
|
|
@@ -3480,7 +3508,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3480
3508
|
TableName: tableFullName,
|
|
3481
3509
|
IndexName: paramOption01.indexName,
|
|
3482
3510
|
KeyConditionExpression: mainFilter.filterExpression,
|
|
3483
|
-
FilterExpression:
|
|
3511
|
+
FilterExpression: otherFilterExpression ?? void 0,
|
|
3484
3512
|
ExpressionAttributeValues: {
|
|
3485
3513
|
...otherExpressionAttributeValues,
|
|
3486
3514
|
...mainFilter.expressionAttributeValues
|
|
@@ -3490,7 +3518,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3490
3518
|
...mainFilter.expressionAttributeNames
|
|
3491
3519
|
}
|
|
3492
3520
|
};
|
|
3493
|
-
const orderDesc =
|
|
3521
|
+
const orderDesc = paramOption01?.sort === "desc";
|
|
3494
3522
|
if (orderDesc) {
|
|
3495
3523
|
params.ScanIndexForward = false;
|
|
3496
3524
|
} else {
|
|
@@ -3499,7 +3527,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3499
3527
|
if (mainFilter.projectionExpressionAttr) {
|
|
3500
3528
|
params.ProjectionExpression = mainFilter.projectionExpressionAttr;
|
|
3501
3529
|
}
|
|
3502
|
-
let nextPageHash01 =
|
|
3530
|
+
let nextPageHash01 = paramOption01?.pagingParams?.nextPageHash;
|
|
3503
3531
|
if (nextPageHash01 === "undefined") {
|
|
3504
3532
|
nextPageHash01 = void 0;
|
|
3505
3533
|
}
|
|
@@ -3534,11 +3562,11 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3534
3562
|
sortKeyFieldName,
|
|
3535
3563
|
featureEntityValue
|
|
3536
3564
|
} = this._mocody_getLocalVariables();
|
|
3537
|
-
if (!
|
|
3565
|
+
if (!secondaryIndexOptions?.length) {
|
|
3538
3566
|
throw this._mocody_createGenericError("Invalid secondary index definitions");
|
|
3539
3567
|
}
|
|
3540
3568
|
const paramOption01 = { ...paramOption };
|
|
3541
|
-
if (!
|
|
3569
|
+
if (!paramOption01?.indexName) {
|
|
3542
3570
|
throw this._mocody_createGenericError("Invalid index name input");
|
|
3543
3571
|
}
|
|
3544
3572
|
const secondaryIndex = secondaryIndexOptions.find((item) => {
|
|
@@ -3554,7 +3582,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3554
3582
|
fields: paramOption01.fields,
|
|
3555
3583
|
excludeFields: paramOption01.excludeFields
|
|
3556
3584
|
});
|
|
3557
|
-
if (canPaginate &&
|
|
3585
|
+
if (canPaginate && fields01?.length) {
|
|
3558
3586
|
const fieldSet01 = new Set(fields01);
|
|
3559
3587
|
fieldSet01.add(partitionKeyFieldName);
|
|
3560
3588
|
projectionFields = Array.from(fieldSet01);
|
|
@@ -3566,8 +3594,8 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3566
3594
|
if (paramOption01.limit && UtilService.isNumericInteger(paramOption01.limit)) {
|
|
3567
3595
|
resultLimit01 = Number(paramOption01.limit);
|
|
3568
3596
|
}
|
|
3569
|
-
if (
|
|
3570
|
-
evaluationLimit01 =
|
|
3597
|
+
if (paramOption01?.pagingParams?.evaluationLimit) {
|
|
3598
|
+
evaluationLimit01 = paramOption01?.pagingParams?.evaluationLimit;
|
|
3571
3599
|
} else if (!paramOption01.query && resultLimit01) {
|
|
3572
3600
|
evaluationLimit01 = resultLimit01;
|
|
3573
3601
|
}
|
|
@@ -3601,7 +3629,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3601
3629
|
queryDefs: partitionSortKeyQuery
|
|
3602
3630
|
});
|
|
3603
3631
|
LoggingService.logAsString({ sortFilter });
|
|
3604
|
-
if (
|
|
3632
|
+
if (sortFilter?.subStatement) {
|
|
3605
3633
|
subStatement.push(sortFilter.subStatement);
|
|
3606
3634
|
subParameter.push(...sortFilter.subParameter);
|
|
3607
3635
|
}
|
|
@@ -3616,7 +3644,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3616
3644
|
subParameter.push(...otherFilter.subParameter);
|
|
3617
3645
|
}
|
|
3618
3646
|
}
|
|
3619
|
-
let nextPageHash01 =
|
|
3647
|
+
let nextPageHash01 = paramOption01?.pagingParams?.nextPageHash;
|
|
3620
3648
|
if (nextPageHash01 === "undefined") {
|
|
3621
3649
|
nextPageHash01 = void 0;
|
|
3622
3650
|
}
|
|
@@ -3626,7 +3654,7 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3626
3654
|
LoggingService.logAsString({ subStatement, subParameter });
|
|
3627
3655
|
const result = await this._mocody_queryPartiQlProcessor.mocody__helperDynamoQueryProcessor({
|
|
3628
3656
|
dynamoDb: () => this._mocody_dynamoInit(),
|
|
3629
|
-
sortOrder:
|
|
3657
|
+
sortOrder: paramOption01?.sort,
|
|
3630
3658
|
indexName: paramOption01.indexName,
|
|
3631
3659
|
current_partitionValue: paramOption01.partitionKeyValue,
|
|
3632
3660
|
params: { subStatement, subParameter },
|
|
@@ -3675,16 +3703,16 @@ var DynamoDataOperation = (_class = class extends RepoModel {
|
|
|
3675
3703
|
}
|
|
3676
3704
|
return dataExist;
|
|
3677
3705
|
}
|
|
3678
|
-
}
|
|
3706
|
+
};
|
|
3679
3707
|
|
|
3680
3708
|
// src/couch/couch-initializer.ts
|
|
3681
|
-
var
|
|
3682
|
-
|
|
3683
|
-
var concurrency2 =
|
|
3709
|
+
var import_nano = __toESM(require("nano"), 1);
|
|
3710
|
+
var import_throat2 = __toESM(require("throat"), 1);
|
|
3711
|
+
var concurrency2 = (0, import_throat2.default)(1);
|
|
3684
3712
|
var MocodyInitializerCouch = class {
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3713
|
+
_databaseInstance;
|
|
3714
|
+
_documentScope;
|
|
3715
|
+
baseConfig;
|
|
3688
3716
|
constructor(baseConfig) {
|
|
3689
3717
|
this.baseConfig = baseConfig;
|
|
3690
3718
|
}
|
|
@@ -3716,7 +3744,7 @@ var MocodyInitializerCouch = class {
|
|
|
3716
3744
|
selector: { ...selector },
|
|
3717
3745
|
fields,
|
|
3718
3746
|
use_index,
|
|
3719
|
-
sort:
|
|
3747
|
+
sort: sort?.length ? sort : void 0,
|
|
3720
3748
|
limit,
|
|
3721
3749
|
skip
|
|
3722
3750
|
// bookmark: paramOption?.pagingParams?.nextPageHash,
|
|
@@ -3728,7 +3756,7 @@ var MocodyInitializerCouch = class {
|
|
|
3728
3756
|
return await db01.get(nativeId);
|
|
3729
3757
|
} catch (error) {
|
|
3730
3758
|
const error01 = error;
|
|
3731
|
-
if (
|
|
3759
|
+
if (error01?.error === "not_found" || error01?.statusCode === 404) {
|
|
3732
3760
|
return null;
|
|
3733
3761
|
}
|
|
3734
3762
|
LoggingService.error(error);
|
|
@@ -3758,8 +3786,8 @@ var MocodyInitializerCouch = class {
|
|
|
3758
3786
|
startkey: featureEntity,
|
|
3759
3787
|
endkey: `${featureEntity}\uFFF0`,
|
|
3760
3788
|
inclusive_end: true,
|
|
3761
|
-
limit:
|
|
3762
|
-
skip:
|
|
3789
|
+
limit: size ?? void 0,
|
|
3790
|
+
skip: skip ?? void 0
|
|
3763
3791
|
});
|
|
3764
3792
|
return data;
|
|
3765
3793
|
}
|
|
@@ -3772,7 +3800,7 @@ var MocodyInitializerCouch = class {
|
|
|
3772
3800
|
const serverScope = await this.getInstance();
|
|
3773
3801
|
const db = serverScope.db.use(this.baseConfig.couchConfig.databaseName);
|
|
3774
3802
|
try {
|
|
3775
|
-
if (
|
|
3803
|
+
if (this.baseConfig?.indexes?.length) {
|
|
3776
3804
|
for (const indexItem of this.baseConfig.indexes) {
|
|
3777
3805
|
await this.createIndex({ ...indexItem, dbx: db });
|
|
3778
3806
|
}
|
|
@@ -3830,18 +3858,18 @@ var MocodyInitializerCouch = class {
|
|
|
3830
3858
|
const pw = encodeURIComponent(password);
|
|
3831
3859
|
const uname = encodeURIComponent(username);
|
|
3832
3860
|
const url = `${protocol}://${uname}:${pw}@${host}:${port}`;
|
|
3833
|
-
this._databaseInstance =
|
|
3861
|
+
this._databaseInstance = (0, import_nano.default)({ url });
|
|
3834
3862
|
} else if (this.baseConfig.authType === "proxy") {
|
|
3835
3863
|
const proxyHeaders = this.baseConfig.couchConfig.proxyHeaders;
|
|
3836
3864
|
const url = `${protocol}://${host}:${port}`;
|
|
3837
|
-
this._databaseInstance =
|
|
3865
|
+
this._databaseInstance = (0, import_nano.default)({
|
|
3838
3866
|
url,
|
|
3839
3867
|
// requestDefaults: { headers: proxyHeaders },
|
|
3840
3868
|
headers: proxyHeaders
|
|
3841
3869
|
});
|
|
3842
3870
|
} else if (this.baseConfig.authType === "cookie") {
|
|
3843
3871
|
const url = `${protocol}://${host}:${port}`;
|
|
3844
|
-
this._databaseInstance =
|
|
3872
|
+
this._databaseInstance = (0, import_nano.default)({ url, cookie: this.baseConfig.couchConfig.cookie });
|
|
3845
3873
|
} else {
|
|
3846
3874
|
throw new MocodyGenericError("Invalid auth type definition");
|
|
3847
3875
|
}
|
|
@@ -3856,7 +3884,7 @@ var SettingDefaults = {
|
|
|
3856
3884
|
};
|
|
3857
3885
|
|
|
3858
3886
|
// src/couch/couch-data-operation.ts
|
|
3859
|
-
|
|
3887
|
+
var import_joi3 = __toESM(require("joi"), 1);
|
|
3860
3888
|
|
|
3861
3889
|
// src/couch/couch-filter-query-operation.ts
|
|
3862
3890
|
var KEY_CONDITION_MAP3 = {
|
|
@@ -4082,7 +4110,7 @@ var CouchFilterQueryOperation = class {
|
|
|
4082
4110
|
fieldName,
|
|
4083
4111
|
attrValues: conditionValue
|
|
4084
4112
|
});
|
|
4085
|
-
if (
|
|
4113
|
+
if (nestedMatchConditions?.length) {
|
|
4086
4114
|
nestedMatchConditions.forEach((_queryCondition) => {
|
|
4087
4115
|
queryConditions.push(_queryCondition);
|
|
4088
4116
|
});
|
|
@@ -4205,17 +4233,17 @@ var CouchFilterQueryOperation = class {
|
|
|
4205
4233
|
}
|
|
4206
4234
|
});
|
|
4207
4235
|
let queryAllConditions = {};
|
|
4208
|
-
if (
|
|
4236
|
+
if (queryMainConditions?.length) {
|
|
4209
4237
|
queryMainConditions.forEach((item1) => {
|
|
4210
4238
|
if (item1) {
|
|
4211
4239
|
queryAllConditions = { ...queryAllConditions, ...item1 };
|
|
4212
4240
|
}
|
|
4213
4241
|
});
|
|
4214
4242
|
}
|
|
4215
|
-
if (
|
|
4243
|
+
if (queryAndConditions?.length) {
|
|
4216
4244
|
queryAllConditions.$and = queryAndConditions;
|
|
4217
4245
|
}
|
|
4218
|
-
if (
|
|
4246
|
+
if (queryOrConditions?.length) {
|
|
4219
4247
|
queryAllConditions.$or = queryOrConditions;
|
|
4220
4248
|
}
|
|
4221
4249
|
return queryAllConditions;
|
|
@@ -4224,11 +4252,11 @@ var CouchFilterQueryOperation = class {
|
|
|
4224
4252
|
|
|
4225
4253
|
// src/couch/couch-manage-table.ts
|
|
4226
4254
|
var CouchManageTable = class {
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4255
|
+
partitionKeyFieldName;
|
|
4256
|
+
sortKeyFieldName;
|
|
4257
|
+
couchDb;
|
|
4258
|
+
tableFullName;
|
|
4259
|
+
secondaryIndexOptions;
|
|
4232
4260
|
constructor({ couchDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName }) {
|
|
4233
4261
|
this.couchDb = couchDb;
|
|
4234
4262
|
this.tableFullName = tableFullName;
|
|
@@ -4254,10 +4282,10 @@ var CouchManageTable = class {
|
|
|
4254
4282
|
async mocody_clearAllIndexes() {
|
|
4255
4283
|
const indexes = await this._mocody_getInstance().getIndexes();
|
|
4256
4284
|
LoggingService.log({ indexes });
|
|
4257
|
-
if (
|
|
4285
|
+
if (indexes?.indexes?.length) {
|
|
4258
4286
|
const deletedIndexes = [];
|
|
4259
4287
|
for (const index of indexes.indexes) {
|
|
4260
|
-
if (
|
|
4288
|
+
if (index?.type !== "special") {
|
|
4261
4289
|
deletedIndexes.push(index);
|
|
4262
4290
|
await this._mocody_getInstance().deleteIndex({
|
|
4263
4291
|
ddoc: index.ddoc,
|
|
@@ -4281,9 +4309,9 @@ var CouchManageTable = class {
|
|
|
4281
4309
|
}
|
|
4282
4310
|
async mocody_createDefinedIndexes() {
|
|
4283
4311
|
const results = [];
|
|
4284
|
-
if (
|
|
4312
|
+
if (this.secondaryIndexOptions?.length) {
|
|
4285
4313
|
for (const indexOption of this.secondaryIndexOptions) {
|
|
4286
|
-
if (
|
|
4314
|
+
if (indexOption?.indexName) {
|
|
4287
4315
|
const resultData = await this.mocody_createIndex({
|
|
4288
4316
|
fields: [indexOption.partitionKeyFieldName, indexOption.sortKeyFieldName],
|
|
4289
4317
|
indexName: indexOption.indexName
|
|
@@ -4298,24 +4326,24 @@ var CouchManageTable = class {
|
|
|
4298
4326
|
};
|
|
4299
4327
|
|
|
4300
4328
|
// src/couch/couch-data-operation.ts
|
|
4301
|
-
var CouchDataOperation =
|
|
4302
|
-
|
|
4303
|
-
|
|
4329
|
+
var CouchDataOperation = class extends RepoModel {
|
|
4330
|
+
_mocody_partitionKeyFieldName = "id";
|
|
4331
|
+
_mocody_sortKeyFieldName = "featureEntity";
|
|
4304
4332
|
//
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4333
|
+
_mocody_operationNotSuccessful = "Operation Not Successful";
|
|
4334
|
+
_mocody_entityFieldsKeySet;
|
|
4335
|
+
_mocody_couchDb;
|
|
4336
|
+
_mocody_dataKeyGenerator;
|
|
4337
|
+
_mocody_schema;
|
|
4338
|
+
_mocody_tableFullName;
|
|
4339
|
+
_mocody_strictRequiredFields;
|
|
4340
|
+
_mocody_featureEntityValue;
|
|
4341
|
+
_mocody_secondaryIndexOptions;
|
|
4342
|
+
_mocody_filterQueryOperation = new CouchFilterQueryOperation();
|
|
4315
4343
|
//
|
|
4316
|
-
|
|
4344
|
+
_mocody_fieldAliases;
|
|
4317
4345
|
//
|
|
4318
|
-
|
|
4346
|
+
_mocody_tableManager;
|
|
4319
4347
|
constructor({
|
|
4320
4348
|
schemaDef,
|
|
4321
4349
|
couchDbInitializer,
|
|
@@ -4326,7 +4354,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4326
4354
|
dataKeyGenerator,
|
|
4327
4355
|
fieldAliases
|
|
4328
4356
|
}) {
|
|
4329
|
-
super();
|
|
4357
|
+
super();
|
|
4330
4358
|
this._mocody_couchDb = couchDbInitializer;
|
|
4331
4359
|
this._mocody_dataKeyGenerator = dataKeyGenerator;
|
|
4332
4360
|
this._mocody_tableFullName = baseTableName;
|
|
@@ -4342,9 +4370,9 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4342
4370
|
Object.keys(fullSchemaMapDef).forEach((key) => {
|
|
4343
4371
|
this._mocody_entityFieldsKeySet.add(key);
|
|
4344
4372
|
});
|
|
4345
|
-
this._mocody_schema =
|
|
4373
|
+
this._mocody_schema = import_joi3.default.object().keys({
|
|
4346
4374
|
...fullSchemaMapDef,
|
|
4347
|
-
_id:
|
|
4375
|
+
_id: import_joi3.default.string().required().min(5).max(512)
|
|
4348
4376
|
});
|
|
4349
4377
|
}
|
|
4350
4378
|
mocody_tableManager() {
|
|
@@ -4394,7 +4422,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4394
4422
|
if (dataObj && typeof dataObj === "object" && this._mocody_entityFieldsKeySet.size > 0) {
|
|
4395
4423
|
Object.entries({ ...dataObj }).forEach(([key, value]) => {
|
|
4396
4424
|
if (this._mocody_entityFieldsKeySet.has(key)) {
|
|
4397
|
-
if (
|
|
4425
|
+
if (excludeFields?.length) {
|
|
4398
4426
|
if (!excludeFields.includes(key)) {
|
|
4399
4427
|
returnData[key] = value;
|
|
4400
4428
|
}
|
|
@@ -4422,7 +4450,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4422
4450
|
item,
|
|
4423
4451
|
withCondition
|
|
4424
4452
|
}) {
|
|
4425
|
-
if (item && typeof item === "object" &&
|
|
4453
|
+
if (item && typeof item === "object" && withCondition?.length) {
|
|
4426
4454
|
const isPassed = withCondition.every(({ field, equals }) => {
|
|
4427
4455
|
return item[field] !== void 0 && item[field] === equals;
|
|
4428
4456
|
});
|
|
@@ -4438,7 +4466,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4438
4466
|
_mocody_checkValidateStrictRequiredFields(onDataObj) {
|
|
4439
4467
|
this._mocody_checkValidateMustBeAnObjectDataType(onDataObj);
|
|
4440
4468
|
const { strictRequiredFields } = this._mocody_getLocalVariables();
|
|
4441
|
-
if (
|
|
4469
|
+
if (strictRequiredFields?.length) {
|
|
4442
4470
|
strictRequiredFields.forEach((field) => {
|
|
4443
4471
|
if (onDataObj[field] === null || onDataObj[field] === void 0) {
|
|
4444
4472
|
throw this._mocody_createGenericError(`Strict required field: '${field}', NOT defined`);
|
|
@@ -4454,7 +4482,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4454
4482
|
stripUnknown: true
|
|
4455
4483
|
});
|
|
4456
4484
|
if (error) {
|
|
4457
|
-
const msg =
|
|
4485
|
+
const msg = getJoiValidationErrors(error) ?? "Validation error occured";
|
|
4458
4486
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(msg);
|
|
4459
4487
|
}
|
|
4460
4488
|
const validatedData = MocodyUtil.alignFormatFieldAlias({
|
|
@@ -4523,12 +4551,12 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4523
4551
|
skip
|
|
4524
4552
|
});
|
|
4525
4553
|
const dataList = [];
|
|
4526
|
-
|
|
4527
|
-
if (
|
|
4554
|
+
data?.rows?.forEach((item) => {
|
|
4555
|
+
if (item?.doc?.featureEntity === this._mocody_featureEntityValue) {
|
|
4528
4556
|
const doc = this._mocody_stripNonRequiredOutputData({ dataObj: item.doc });
|
|
4529
4557
|
dataList.push(doc);
|
|
4530
4558
|
}
|
|
4531
|
-
})
|
|
4559
|
+
});
|
|
4532
4560
|
return dataList;
|
|
4533
4561
|
}
|
|
4534
4562
|
async mocody_getOneById({
|
|
@@ -4538,7 +4566,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4538
4566
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ dataId });
|
|
4539
4567
|
const nativeId = this._mocody_getNativePouchId(dataId);
|
|
4540
4568
|
const dataInDb = await this._mocody_couchDbInstance().getById({ nativeId });
|
|
4541
|
-
if (!(
|
|
4569
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue)) {
|
|
4542
4570
|
return null;
|
|
4543
4571
|
}
|
|
4544
4572
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -4555,7 +4583,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4555
4583
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ dataId });
|
|
4556
4584
|
const nativeId = this._mocody_getNativePouchId(dataId);
|
|
4557
4585
|
const dataInDb = await this._mocody_couchDbInstance().getById({ nativeId });
|
|
4558
|
-
if (!(
|
|
4586
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue && dataInDb._rev)) {
|
|
4559
4587
|
throw this._mocody_createGenericError("Record does not exists");
|
|
4560
4588
|
}
|
|
4561
4589
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -4603,20 +4631,20 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4603
4631
|
withCondition
|
|
4604
4632
|
}) {
|
|
4605
4633
|
const dataList = [];
|
|
4606
|
-
if (!
|
|
4634
|
+
if (!dataIds?.length) {
|
|
4607
4635
|
return dataList;
|
|
4608
4636
|
}
|
|
4609
4637
|
dataIds.forEach((dataId) => {
|
|
4610
4638
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ BatchGetDataId: dataId });
|
|
4611
4639
|
});
|
|
4612
4640
|
const uniqueIds = this._mocody_removeDuplicateString(dataIds);
|
|
4613
|
-
if (
|
|
4641
|
+
if (uniqueIds?.length === 1) {
|
|
4614
4642
|
const result = await this.mocody_getOneById({
|
|
4615
4643
|
dataId: uniqueIds[0],
|
|
4616
4644
|
withCondition
|
|
4617
4645
|
});
|
|
4618
4646
|
if (result) {
|
|
4619
|
-
if (
|
|
4647
|
+
if (fields?.length) {
|
|
4620
4648
|
const result01 = UtilService.pickFromObject({ dataObject: result, pickKeys: fields });
|
|
4621
4649
|
dataList.push(result01);
|
|
4622
4650
|
} else {
|
|
@@ -4628,9 +4656,9 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4628
4656
|
const nativeIds = uniqueIds.map((id) => this._mocody_getNativePouchId(id));
|
|
4629
4657
|
const data = await this._mocody_couchDbInstance().getManyByIds({ nativeIds });
|
|
4630
4658
|
const fieldKeys = this._mocody_getProjectionFields({ fields, excludeFields });
|
|
4631
|
-
if (
|
|
4632
|
-
|
|
4633
|
-
if (
|
|
4659
|
+
if (withCondition?.length) {
|
|
4660
|
+
data?.rows?.forEach((item) => {
|
|
4661
|
+
if (item?.doc?.featureEntity === this._mocody_featureEntityValue) {
|
|
4634
4662
|
const passed = this._mocody_withConditionPassed({ item: item.doc, withCondition });
|
|
4635
4663
|
if (passed) {
|
|
4636
4664
|
const k = this._mocody_stripNonRequiredOutputData({
|
|
@@ -4640,17 +4668,17 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4640
4668
|
dataList.push(k);
|
|
4641
4669
|
}
|
|
4642
4670
|
}
|
|
4643
|
-
})
|
|
4671
|
+
});
|
|
4644
4672
|
} else {
|
|
4645
|
-
|
|
4646
|
-
if (
|
|
4673
|
+
data?.rows?.forEach((item) => {
|
|
4674
|
+
if (item?.doc?.featureEntity === this._mocody_featureEntityValue) {
|
|
4647
4675
|
const k = this._mocody_stripNonRequiredOutputData({
|
|
4648
4676
|
dataObj: item.doc,
|
|
4649
4677
|
excludeFields: fieldKeys
|
|
4650
4678
|
});
|
|
4651
4679
|
dataList.push(k);
|
|
4652
4680
|
}
|
|
4653
|
-
})
|
|
4681
|
+
});
|
|
4654
4682
|
}
|
|
4655
4683
|
return dataList;
|
|
4656
4684
|
}
|
|
@@ -4660,7 +4688,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4660
4688
|
canPaginate: false,
|
|
4661
4689
|
enableRelationFetch: false
|
|
4662
4690
|
});
|
|
4663
|
-
if (
|
|
4691
|
+
if (result?.paginationResults?.length) {
|
|
4664
4692
|
return result.paginationResults;
|
|
4665
4693
|
}
|
|
4666
4694
|
return [];
|
|
@@ -4678,7 +4706,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4678
4706
|
canPaginate: false,
|
|
4679
4707
|
enableRelationFetch: true
|
|
4680
4708
|
});
|
|
4681
|
-
if (
|
|
4709
|
+
if (result?.paginationResults) {
|
|
4682
4710
|
return result.paginationResults;
|
|
4683
4711
|
}
|
|
4684
4712
|
return [];
|
|
@@ -4696,10 +4724,10 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4696
4724
|
enableRelationFetch
|
|
4697
4725
|
}) {
|
|
4698
4726
|
const { secondaryIndexOptions } = this._mocody_getLocalVariables();
|
|
4699
|
-
if (!
|
|
4727
|
+
if (!secondaryIndexOptions?.length) {
|
|
4700
4728
|
throw this._mocody_createGenericError("Invalid secondary index definitions");
|
|
4701
4729
|
}
|
|
4702
|
-
if (!
|
|
4730
|
+
if (!paramOption?.indexName) {
|
|
4703
4731
|
throw this._mocody_createGenericError("Invalid index name input");
|
|
4704
4732
|
}
|
|
4705
4733
|
const secondaryIndex = secondaryIndexOptions.find((item) => {
|
|
@@ -4769,7 +4797,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4769
4797
|
fields: paramOption.fields,
|
|
4770
4798
|
excludeFields: paramOption.excludeFields
|
|
4771
4799
|
});
|
|
4772
|
-
if (
|
|
4800
|
+
if (fieldKeys?.length) {
|
|
4773
4801
|
projection = this._mocody_removeDuplicateString(fieldKeys);
|
|
4774
4802
|
}
|
|
4775
4803
|
let nextPageHash;
|
|
@@ -4786,7 +4814,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4786
4814
|
pagingOptions.limit = Number(paramOption.limit);
|
|
4787
4815
|
}
|
|
4788
4816
|
try {
|
|
4789
|
-
const nextPageHash01 =
|
|
4817
|
+
const nextPageHash01 = paramOption?.pagingParams?.nextPageHash;
|
|
4790
4818
|
if (nextPageHash01) {
|
|
4791
4819
|
const param01 = JSON.parse(UtilService.decodeStringFromBase64(nextPageHash01));
|
|
4792
4820
|
if (param01.limit) {
|
|
@@ -4797,7 +4825,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4797
4825
|
}
|
|
4798
4826
|
}
|
|
4799
4827
|
} catch (error) {
|
|
4800
|
-
LoggingService.log(
|
|
4828
|
+
LoggingService.log(error?.message);
|
|
4801
4829
|
}
|
|
4802
4830
|
moreFindOption.limit = pagingOptions.limit;
|
|
4803
4831
|
const skipValue = pagingOptions.limit * (pagingOptions.pageNo || 0);
|
|
@@ -4814,13 +4842,13 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4814
4842
|
selector: { ...queryDefDataOrdered },
|
|
4815
4843
|
fields: projection,
|
|
4816
4844
|
use_index: paramOption.indexName,
|
|
4817
|
-
sort:
|
|
4845
|
+
sort: sort01?.length ? sort01 : void 0,
|
|
4818
4846
|
limit: moreFindOption.limit,
|
|
4819
4847
|
skip: moreFindOption.skip
|
|
4820
4848
|
});
|
|
4821
|
-
const results =
|
|
4849
|
+
const results = data?.docs?.map((item) => {
|
|
4822
4850
|
return this._mocody_stripNonRequiredOutputData({ dataObj: item });
|
|
4823
|
-
})
|
|
4851
|
+
});
|
|
4824
4852
|
if (canPaginate && results.length && moreFindOption.limit && results.length >= moreFindOption.limit) {
|
|
4825
4853
|
pagingOptions.pageNo = pagingOptions.pageNo + 1;
|
|
4826
4854
|
nextPageHash = UtilService.encodeStringToBase64(JSON.stringify(pagingOptions));
|
|
@@ -4836,7 +4864,7 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4836
4864
|
}) {
|
|
4837
4865
|
const nativeId = this._mocody_getNativePouchId(dataId);
|
|
4838
4866
|
const dataInDb = await this._mocody_couchDbInstance().getById({ nativeId });
|
|
4839
|
-
if (!(
|
|
4867
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue)) {
|
|
4840
4868
|
throw this._mocody_createGenericError("Record does not exists");
|
|
4841
4869
|
}
|
|
4842
4870
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -4849,21 +4877,21 @@ var CouchDataOperation = (_class2 = class extends RepoModel {
|
|
|
4849
4877
|
}
|
|
4850
4878
|
return this._mocody_stripNonRequiredOutputData({ dataObj: dataInDb });
|
|
4851
4879
|
}
|
|
4852
|
-
}
|
|
4880
|
+
};
|
|
4853
4881
|
|
|
4854
4882
|
// src/mongo/mongo-initializer.ts
|
|
4855
|
-
var
|
|
4856
|
-
|
|
4857
|
-
var concurrency3 =
|
|
4883
|
+
var import_mongodb = require("mongodb");
|
|
4884
|
+
var import_throat3 = __toESM(require("throat"), 1);
|
|
4885
|
+
var concurrency3 = (0, import_throat3.default)(1);
|
|
4858
4886
|
var MocodyInitializerMongo = class {
|
|
4859
|
-
|
|
4860
|
-
|
|
4887
|
+
_mongoClient;
|
|
4888
|
+
_inits;
|
|
4861
4889
|
constructor(inits) {
|
|
4862
4890
|
this._inits = inits;
|
|
4863
4891
|
}
|
|
4864
4892
|
async getInstance() {
|
|
4865
4893
|
if (!this._mongoClient) {
|
|
4866
|
-
this._mongoClient = new
|
|
4894
|
+
this._mongoClient = new import_mongodb.MongoClient(this._inits.uri, this._inits.options);
|
|
4867
4895
|
await this._mongoClient.connect();
|
|
4868
4896
|
}
|
|
4869
4897
|
return this._mongoClient;
|
|
@@ -4886,7 +4914,7 @@ var MocodyInitializerMongo = class {
|
|
|
4886
4914
|
};
|
|
4887
4915
|
|
|
4888
4916
|
// src/mongo/mongo-data-operation.ts
|
|
4889
|
-
|
|
4917
|
+
var import_joi4 = __toESM(require("joi"), 1);
|
|
4890
4918
|
|
|
4891
4919
|
// src/mongo/mongo-filter-query-operation.ts
|
|
4892
4920
|
var KEY_CONDITION_MAP4 = {
|
|
@@ -5106,7 +5134,7 @@ var MongoFilterQueryOperation = class {
|
|
|
5106
5134
|
fieldName,
|
|
5107
5135
|
attrValues: conditionValue
|
|
5108
5136
|
});
|
|
5109
|
-
if (
|
|
5137
|
+
if (nestedMatchConditions?.length) {
|
|
5110
5138
|
queryConditionsAdvanced.push(...nestedMatchConditions);
|
|
5111
5139
|
}
|
|
5112
5140
|
} else if (conditionKey === "$exists") {
|
|
@@ -5165,7 +5193,7 @@ var MongoFilterQueryOperation = class {
|
|
|
5165
5193
|
fieldName,
|
|
5166
5194
|
queryObject: orQueryObjectOrValue
|
|
5167
5195
|
});
|
|
5168
|
-
if (
|
|
5196
|
+
if (orQueryCond01?.length) {
|
|
5169
5197
|
if (orQueryCond01.length > 1) {
|
|
5170
5198
|
queryAndCondition_Inside_Or.push(orQueryCond01);
|
|
5171
5199
|
} else {
|
|
@@ -5223,21 +5251,21 @@ var MongoFilterQueryOperation = class {
|
|
|
5223
5251
|
}
|
|
5224
5252
|
});
|
|
5225
5253
|
let queryAllConditions = {};
|
|
5226
|
-
if (
|
|
5254
|
+
if (queryMainConditions?.length) {
|
|
5227
5255
|
queryMainConditions.forEach((item1) => {
|
|
5228
5256
|
if (item1) {
|
|
5229
5257
|
queryAllConditions = { ...queryAllConditions, ...item1 };
|
|
5230
5258
|
}
|
|
5231
5259
|
});
|
|
5232
5260
|
}
|
|
5233
|
-
if (
|
|
5261
|
+
if (queryAndConditions?.length) {
|
|
5234
5262
|
queryAllConditions.$and = queryAndConditions;
|
|
5235
5263
|
}
|
|
5236
|
-
if (
|
|
5264
|
+
if (queryOrConditions?.length) {
|
|
5237
5265
|
queryAllConditions.$or = queryOrConditions;
|
|
5238
5266
|
}
|
|
5239
|
-
if (
|
|
5240
|
-
if (!
|
|
5267
|
+
if (queryAndCondition_Inside_Or?.length) {
|
|
5268
|
+
if (!queryAllConditions?.$or?.length) {
|
|
5241
5269
|
queryAllConditions.$or = [];
|
|
5242
5270
|
}
|
|
5243
5271
|
queryAndCondition_Inside_Or.forEach((query01) => {
|
|
@@ -5251,11 +5279,11 @@ var MongoFilterQueryOperation = class {
|
|
|
5251
5279
|
|
|
5252
5280
|
// src/mongo/mongo-table-manager.ts
|
|
5253
5281
|
var MongoManageTable = class {
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5282
|
+
partitionKeyFieldName;
|
|
5283
|
+
sortKeyFieldName;
|
|
5284
|
+
mongoDb;
|
|
5285
|
+
tableFullName;
|
|
5286
|
+
secondaryIndexOptions;
|
|
5259
5287
|
constructor({ mongoDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName }) {
|
|
5260
5288
|
this.mongoDb = mongoDb;
|
|
5261
5289
|
this.tableFullName = tableFullName;
|
|
@@ -5309,7 +5337,7 @@ var MongoManageTable = class {
|
|
|
5309
5337
|
}
|
|
5310
5338
|
async mocody_createDefinedIndexes() {
|
|
5311
5339
|
const results = [];
|
|
5312
|
-
if (
|
|
5340
|
+
if (this.secondaryIndexOptions?.length) {
|
|
5313
5341
|
for (const indexOption of this.secondaryIndexOptions) {
|
|
5314
5342
|
if (indexOption.indexName) {
|
|
5315
5343
|
const resultData = await this.mocody_createIndex({
|
|
@@ -5326,25 +5354,25 @@ var MongoManageTable = class {
|
|
|
5326
5354
|
};
|
|
5327
5355
|
|
|
5328
5356
|
// src/mongo/mongo-data-operation.ts
|
|
5329
|
-
|
|
5330
|
-
var MongoDataOperation =
|
|
5331
|
-
|
|
5332
|
-
|
|
5357
|
+
var import_mongodb2 = require("mongodb");
|
|
5358
|
+
var MongoDataOperation = class extends RepoModel {
|
|
5359
|
+
_mocody_partitionKeyFieldName = "id";
|
|
5360
|
+
_mocody_sortKeyFieldName = "featureEntity";
|
|
5333
5361
|
//
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5362
|
+
_mocody_operationNotSuccessful = "Operation Not Successful";
|
|
5363
|
+
_mocody_entityFieldsKeySet;
|
|
5364
|
+
_mocody_mongoDb;
|
|
5365
|
+
_mocody_dataKeyGenerator;
|
|
5366
|
+
_mocody_schema;
|
|
5367
|
+
_mocody_tableFullName;
|
|
5368
|
+
_mocody_strictRequiredFields;
|
|
5369
|
+
_mocody_featureEntityValue;
|
|
5370
|
+
_mocody_secondaryIndexOptions;
|
|
5371
|
+
_mocody_filterQueryOperation = new MongoFilterQueryOperation();
|
|
5344
5372
|
//
|
|
5345
|
-
|
|
5373
|
+
_mocody_fieldAliases;
|
|
5346
5374
|
//
|
|
5347
|
-
|
|
5375
|
+
_mocody_tableManager;
|
|
5348
5376
|
constructor({
|
|
5349
5377
|
schemaDef,
|
|
5350
5378
|
mongoDbInitializer,
|
|
@@ -5355,7 +5383,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5355
5383
|
dataKeyGenerator,
|
|
5356
5384
|
fieldAliases
|
|
5357
5385
|
}) {
|
|
5358
|
-
super();
|
|
5386
|
+
super();
|
|
5359
5387
|
this._mocody_mongoDb = mongoDbInitializer;
|
|
5360
5388
|
this._mocody_dataKeyGenerator = dataKeyGenerator;
|
|
5361
5389
|
this._mocody_tableFullName = baseTableName;
|
|
@@ -5371,9 +5399,9 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5371
5399
|
Object.keys(fullSchemaMapDef).forEach((key) => {
|
|
5372
5400
|
this._mocody_entityFieldsKeySet.add(key);
|
|
5373
5401
|
});
|
|
5374
|
-
this._mocody_schema =
|
|
5402
|
+
this._mocody_schema = import_joi4.default.object().keys({
|
|
5375
5403
|
...fullSchemaMapDef,
|
|
5376
|
-
_id:
|
|
5404
|
+
_id: import_joi4.default.string().required().min(5).max(512)
|
|
5377
5405
|
});
|
|
5378
5406
|
}
|
|
5379
5407
|
mocody_tableManager() {
|
|
@@ -5424,7 +5452,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5424
5452
|
item,
|
|
5425
5453
|
withCondition
|
|
5426
5454
|
}) {
|
|
5427
|
-
if (item && typeof item === "object" &&
|
|
5455
|
+
if (item && typeof item === "object" && withCondition?.length) {
|
|
5428
5456
|
const isPassed = withCondition.every(({ field, equals }) => {
|
|
5429
5457
|
return item[field] !== void 0 && item[field] === equals;
|
|
5430
5458
|
});
|
|
@@ -5440,7 +5468,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5440
5468
|
_mocody_checkValidateStrictRequiredFields(onDataObj) {
|
|
5441
5469
|
this._mocody_checkValidateMustBeAnObjectDataType(onDataObj);
|
|
5442
5470
|
const { strictRequiredFields } = this._mocody_getLocalVariables();
|
|
5443
|
-
if (
|
|
5471
|
+
if (strictRequiredFields?.length) {
|
|
5444
5472
|
strictRequiredFields.forEach((field) => {
|
|
5445
5473
|
if (onDataObj[field] === null || onDataObj[field] === void 0) {
|
|
5446
5474
|
throw this._mocody_createGenericError(`Strict required field: '${field}', NOT defined`);
|
|
@@ -5462,7 +5490,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5462
5490
|
});
|
|
5463
5491
|
}
|
|
5464
5492
|
_mocody_toMongoProjection(fields) {
|
|
5465
|
-
if (
|
|
5493
|
+
if (fields?.length) {
|
|
5466
5494
|
const projection = {};
|
|
5467
5495
|
const uniqueFields = this._mocody_removeDuplicateString(fields);
|
|
5468
5496
|
uniqueFields.forEach((field) => {
|
|
@@ -5477,7 +5505,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5477
5505
|
stripUnknown: true
|
|
5478
5506
|
});
|
|
5479
5507
|
if (error) {
|
|
5480
|
-
const msg =
|
|
5508
|
+
const msg = getJoiValidationErrors(error) ?? "Validation error occured";
|
|
5481
5509
|
throw MocodyErrorUtilsService.mocody_helper_createFriendlyError(msg);
|
|
5482
5510
|
}
|
|
5483
5511
|
const validatedData = MocodyUtil.alignFormatFieldAlias({
|
|
@@ -5504,7 +5532,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5504
5532
|
const nativeId = this._mocody_getNativeMongoId(dataId);
|
|
5505
5533
|
const query = { _id: nativeId };
|
|
5506
5534
|
const dataInDb = await mongo.findOne(query, { projection: { _id: 0 } });
|
|
5507
|
-
if (!(
|
|
5535
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue)) {
|
|
5508
5536
|
return null;
|
|
5509
5537
|
}
|
|
5510
5538
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -5520,20 +5548,20 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5520
5548
|
withCondition
|
|
5521
5549
|
}) {
|
|
5522
5550
|
const dataList = [];
|
|
5523
|
-
if (!
|
|
5551
|
+
if (!dataIds?.length) {
|
|
5524
5552
|
return dataList;
|
|
5525
5553
|
}
|
|
5526
5554
|
dataIds.forEach((dataId) => {
|
|
5527
5555
|
MocodyErrorUtilsService.mocody_helper_validateRequiredString({ BatchGetDataId: dataId });
|
|
5528
5556
|
});
|
|
5529
5557
|
const uniqueIds = this._mocody_removeDuplicateString(dataIds);
|
|
5530
|
-
if (
|
|
5558
|
+
if (uniqueIds?.length === 1) {
|
|
5531
5559
|
const result = await this.mocody_getOneById({
|
|
5532
5560
|
dataId: uniqueIds[0],
|
|
5533
5561
|
withCondition
|
|
5534
5562
|
});
|
|
5535
5563
|
if (result) {
|
|
5536
|
-
if (
|
|
5564
|
+
if (fields?.length) {
|
|
5537
5565
|
const result01 = UtilService.pickFromObject({ dataObject: result, pickKeys: fields });
|
|
5538
5566
|
dataList.push(result01);
|
|
5539
5567
|
} else {
|
|
@@ -5545,7 +5573,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5545
5573
|
const fullUniqueIds = uniqueIds.map((id) => this._mocody_getNativeMongoId(id));
|
|
5546
5574
|
const mongo = await this._mocody_getDbInstance();
|
|
5547
5575
|
const fieldKeys = this._mocody_getProjectionFields({ fields, excludeFields });
|
|
5548
|
-
if (
|
|
5576
|
+
if (withCondition?.length && fieldKeys?.length) {
|
|
5549
5577
|
withCondition.forEach((item) => {
|
|
5550
5578
|
fieldKeys.push(item.field);
|
|
5551
5579
|
});
|
|
@@ -5553,13 +5581,13 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5553
5581
|
const projection = this._mocody_toMongoProjection(fieldKeys);
|
|
5554
5582
|
const query = { _id: { $in: fullUniqueIds } };
|
|
5555
5583
|
const dataListInDb = await mongo.find(query, { projection }).toArray();
|
|
5556
|
-
if (!
|
|
5584
|
+
if (!dataListInDb?.length) {
|
|
5557
5585
|
return [];
|
|
5558
5586
|
}
|
|
5559
5587
|
const dataListInDb01 = dataListInDb.map((f) => {
|
|
5560
5588
|
return UtilService.deleteKeysFromObject({ dataObject: f, delKeys: ["_id"] });
|
|
5561
5589
|
});
|
|
5562
|
-
if (
|
|
5590
|
+
if (withCondition?.length) {
|
|
5563
5591
|
const dataFiltered = dataListInDb01.filter((item) => {
|
|
5564
5592
|
const passed = this._mocody_withConditionPassed({ item, withCondition });
|
|
5565
5593
|
return passed;
|
|
@@ -5584,7 +5612,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5584
5612
|
const { validatedData, validatedDataWithTTL } = await this._mocody_validateReady({ data });
|
|
5585
5613
|
const mongo = await this._mocody_getDbInstance();
|
|
5586
5614
|
const result = await mongo.insertOne(validatedDataWithTTL);
|
|
5587
|
-
if (!
|
|
5615
|
+
if (!result?.acknowledged) {
|
|
5588
5616
|
throw this._mocody_createGenericError(this._mocody_operationNotSuccessful);
|
|
5589
5617
|
}
|
|
5590
5618
|
const final = { ...validatedData };
|
|
@@ -5615,7 +5643,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5615
5643
|
return { validatedData, validatedDataWithTTL };
|
|
5616
5644
|
}
|
|
5617
5645
|
_mocody_formatTTL(fullData) {
|
|
5618
|
-
if (
|
|
5646
|
+
if (fullData?.dangerouslyExpireAt) {
|
|
5619
5647
|
fullData.dangerouslyExpireAtTTL = new Date(fullData.dangerouslyExpireAt);
|
|
5620
5648
|
} else {
|
|
5621
5649
|
delete fullData.dangerouslyExpireAtTTL;
|
|
@@ -5632,7 +5660,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5632
5660
|
const query = { _id: nativeId };
|
|
5633
5661
|
const mongo = await this._mocody_getDbInstance();
|
|
5634
5662
|
const dataInDb = await mongo.findOne(query);
|
|
5635
|
-
if (!(
|
|
5663
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue)) {
|
|
5636
5664
|
throw this._mocody_createGenericError("Record does not exists");
|
|
5637
5665
|
}
|
|
5638
5666
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -5694,9 +5722,9 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5694
5722
|
const session = await this._mocody_mongoDb().getNewSession();
|
|
5695
5723
|
try {
|
|
5696
5724
|
const transactionOptions = {
|
|
5697
|
-
readPreference: new
|
|
5698
|
-
readConcern: new
|
|
5699
|
-
writeConcern: new
|
|
5725
|
+
readPreference: new import_mongodb2.ReadPreference("primary"),
|
|
5726
|
+
readConcern: new import_mongodb2.ReadConcern("local"),
|
|
5727
|
+
writeConcern: new import_mongodb2.WriteConcern("majority")
|
|
5700
5728
|
};
|
|
5701
5729
|
await session.withTransaction(async () => {
|
|
5702
5730
|
for (const item of transactInfo) {
|
|
@@ -5727,7 +5755,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5727
5755
|
canPaginate: false,
|
|
5728
5756
|
enableRelationFetch: false
|
|
5729
5757
|
});
|
|
5730
|
-
if (
|
|
5758
|
+
if (result?.paginationResults) {
|
|
5731
5759
|
return result.paginationResults;
|
|
5732
5760
|
}
|
|
5733
5761
|
return [];
|
|
@@ -5745,7 +5773,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5745
5773
|
canPaginate: false,
|
|
5746
5774
|
enableRelationFetch: true
|
|
5747
5775
|
});
|
|
5748
|
-
if (
|
|
5776
|
+
if (result?.paginationResults) {
|
|
5749
5777
|
return result.paginationResults;
|
|
5750
5778
|
}
|
|
5751
5779
|
return [];
|
|
@@ -5763,10 +5791,10 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5763
5791
|
enableRelationFetch
|
|
5764
5792
|
}) {
|
|
5765
5793
|
const { secondaryIndexOptions } = this._mocody_getLocalVariables();
|
|
5766
|
-
if (!
|
|
5794
|
+
if (!secondaryIndexOptions?.length) {
|
|
5767
5795
|
throw this._mocody_createGenericError("Invalid secondary index definitions");
|
|
5768
5796
|
}
|
|
5769
|
-
if (!
|
|
5797
|
+
if (!paramOption?.indexName) {
|
|
5770
5798
|
throw this._mocody_createGenericError("Invalid index name input");
|
|
5771
5799
|
}
|
|
5772
5800
|
const secondaryIndex = secondaryIndexOptions.find((item) => {
|
|
@@ -5809,7 +5837,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5809
5837
|
fields: paramOption.fields,
|
|
5810
5838
|
excludeFields: paramOption.excludeFields
|
|
5811
5839
|
});
|
|
5812
|
-
const projection =
|
|
5840
|
+
const projection = this._mocody_toMongoProjection(fieldKeys) ?? { _id: 0 };
|
|
5813
5841
|
const sort01 = [];
|
|
5814
5842
|
if (paramOption.sort === "desc") {
|
|
5815
5843
|
sort01.push([index_PartitionKeyFieldName, -1]);
|
|
@@ -5832,7 +5860,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5832
5860
|
pagingOptions.limit = Number(paramOption.limit);
|
|
5833
5861
|
}
|
|
5834
5862
|
try {
|
|
5835
|
-
const nextPageHash01 =
|
|
5863
|
+
const nextPageHash01 = paramOption?.pagingParams?.nextPageHash;
|
|
5836
5864
|
if (nextPageHash01) {
|
|
5837
5865
|
const param01 = JSON.parse(UtilService.decodeStringFromBase64(nextPageHash01));
|
|
5838
5866
|
if (UtilService.isNumericInteger(param01.limit)) {
|
|
@@ -5843,7 +5871,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5843
5871
|
}
|
|
5844
5872
|
}
|
|
5845
5873
|
} catch (error) {
|
|
5846
|
-
LoggingService.log(
|
|
5874
|
+
LoggingService.log(error?.message);
|
|
5847
5875
|
}
|
|
5848
5876
|
const skipValue = pagingOptions.limit * (pagingOptions.pageNo || 0);
|
|
5849
5877
|
if (skipValue) {
|
|
@@ -5881,7 +5909,7 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5881
5909
|
const nativeId = this._mocody_getNativeMongoId(dataId);
|
|
5882
5910
|
const query = { _id: nativeId };
|
|
5883
5911
|
const dataInDb = await db.findOne(query);
|
|
5884
|
-
if (!(
|
|
5912
|
+
if (!(dataInDb?.id === dataId && dataInDb.featureEntity === this._mocody_featureEntityValue)) {
|
|
5885
5913
|
throw this._mocody_createGenericError("Record does not exists");
|
|
5886
5914
|
}
|
|
5887
5915
|
const passed = this._mocody_withConditionPassed({ item: dataInDb, withCondition });
|
|
@@ -5889,19 +5917,20 @@ var MongoDataOperation = (_class3 = class extends RepoModel {
|
|
|
5889
5917
|
throw this._mocody_createGenericError("Record with conditions does not exists for deletion");
|
|
5890
5918
|
}
|
|
5891
5919
|
const result = await db.deleteOne(query);
|
|
5892
|
-
if (!
|
|
5920
|
+
if (!result?.deletedCount) {
|
|
5893
5921
|
throw this._mocody_createGenericError(this._mocody_operationNotSuccessful);
|
|
5894
5922
|
}
|
|
5895
5923
|
return dataInDb;
|
|
5896
5924
|
}
|
|
5897
|
-
}
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5925
|
+
};
|
|
5926
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
5927
|
+
0 && (module.exports = {
|
|
5928
|
+
CouchDataOperation,
|
|
5929
|
+
DynamoDataOperation,
|
|
5930
|
+
MocodyGenericError,
|
|
5931
|
+
MocodyInitializerCouch,
|
|
5932
|
+
MocodyInitializerDynamo,
|
|
5933
|
+
MocodyInitializerMongo,
|
|
5934
|
+
MocodyUtil,
|
|
5935
|
+
MongoDataOperation
|
|
5936
|
+
});
|