mocody 0.2.14 → 0.2.17

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.
Files changed (66) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -4
  3. package/dist/core/base-schema.d.ts +13 -13
  4. package/dist/core/base-schema.js +11 -11
  5. package/dist/core/base-schema.js.map +1 -1
  6. package/dist/couch/couch-data-operation.d.ts +90 -90
  7. package/dist/couch/couch-data-operation.js +581 -581
  8. package/dist/couch/couch-data-operation.js.map +1 -1
  9. package/dist/couch/couch-filter-query-operation.d.ts +47 -47
  10. package/dist/couch/couch-filter-query-operation.js +438 -438
  11. package/dist/couch/couch-initializer.d.ts +45 -45
  12. package/dist/couch/couch-initializer.js +98 -98
  13. package/dist/couch/couch-initializer.js.map +1 -1
  14. package/dist/couch/couch-manage-table.d.ts +46 -46
  15. package/dist/couch/couch-manage-table.js +113 -113
  16. package/dist/dynamo/dynamo-data-operation.d.ts +97 -97
  17. package/dist/dynamo/dynamo-data-operation.js +788 -793
  18. package/dist/dynamo/dynamo-data-operation.js.map +1 -1
  19. package/dist/dynamo/dynamo-filter-query-operation.d.ts +29 -28
  20. package/dist/dynamo/dynamo-filter-query-operation.js +655 -627
  21. package/dist/dynamo/dynamo-filter-query-operation.js.map +1 -1
  22. package/dist/dynamo/dynamo-helper.d.ts +1 -1
  23. package/dist/dynamo/dynamo-helper.js +8 -15
  24. package/dist/dynamo/dynamo-helper.js.map +1 -1
  25. package/dist/dynamo/dynamo-initializer.d.ts +14 -8
  26. package/dist/dynamo/dynamo-initializer.js +58 -34
  27. package/dist/dynamo/dynamo-initializer.js.map +1 -1
  28. package/dist/dynamo/dynamo-manage-table.d.ts +33 -32
  29. package/dist/dynamo/dynamo-manage-table.js +419 -418
  30. package/dist/dynamo/dynamo-manage-table.js.map +1 -1
  31. package/dist/dynamo/dynamo-query-scan-processor.d.ts +25 -24
  32. package/dist/dynamo/dynamo-query-scan-processor.js +268 -266
  33. package/dist/dynamo/dynamo-query-scan-processor.js.map +1 -1
  34. package/dist/helpers/base-joi-helper.d.ts +2 -2
  35. package/dist/helpers/base-joi-helper.js +12 -12
  36. package/dist/helpers/constants.d.ts +3 -3
  37. package/dist/helpers/constants.js +6 -6
  38. package/dist/helpers/errors.d.ts +13 -13
  39. package/dist/helpers/errors.js +38 -38
  40. package/dist/helpers/logging-service.d.ts +8 -8
  41. package/dist/helpers/logging-service.js +44 -44
  42. package/dist/helpers/mocody-utils.d.ts +13 -15
  43. package/dist/helpers/mocody-utils.js +48 -48
  44. package/dist/helpers/query-validator.d.ts +20 -20
  45. package/dist/helpers/query-validator.js +96 -84
  46. package/dist/helpers/query-validator.js.map +1 -1
  47. package/dist/helpers/util-service.d.ts +29 -30
  48. package/dist/helpers/util-service.js +155 -167
  49. package/dist/helpers/util-service.js.map +1 -1
  50. package/dist/index.d.ts +10 -10
  51. package/dist/index.js +19 -19
  52. package/dist/model/index.d.ts +40 -40
  53. package/dist/model/index.js +6 -6
  54. package/dist/mongo/mongo-data-operation.d.ts +88 -88
  55. package/dist/mongo/mongo-data-operation.js +597 -597
  56. package/dist/mongo/mongo-data-operation.js.map +1 -1
  57. package/dist/mongo/mongo-filter-query-operation.d.ts +47 -47
  58. package/dist/mongo/mongo-filter-query-operation.js +433 -433
  59. package/dist/mongo/mongo-initializer.d.ts +16 -16
  60. package/dist/mongo/mongo-initializer.js +47 -47
  61. package/dist/mongo/mongo-initializer.js.map +1 -1
  62. package/dist/mongo/mongo-table-manager.d.ts +31 -31
  63. package/dist/mongo/mongo-table-manager.js +104 -104
  64. package/dist/type/index.d.ts +108 -108
  65. package/dist/type/index.js +2 -2
  66. package/package.json +70 -71
@@ -1,45 +1,45 @@
1
- import type { IMocodyCoreEntityModel } from "../core/base-schema";
2
- import Nano from "nano";
3
- declare type IBaseDef<T> = Omit<T & IMocodyCoreEntityModel, "">;
4
- interface IOptions {
5
- couchConfig: {
6
- host: string;
7
- password?: string;
8
- username?: string;
9
- databaseName: string;
10
- port?: number;
11
- protocol?: "http" | "https";
12
- };
13
- }
14
- export declare class MocodyInitializerCouch {
15
- private _databaseInstance;
16
- private _documentScope;
17
- private readonly couchConfig;
18
- constructor({ couchConfig }: IOptions);
19
- private getFullDbUrl;
20
- deleteIndex({ ddoc, name }: {
21
- ddoc: string;
22
- name: string;
23
- }): Promise<{
24
- ok: boolean;
25
- }>;
26
- getIndexes(): Promise<{
27
- indexes: {
28
- ddoc: string;
29
- name: string;
30
- type: string;
31
- def: {
32
- fields: {
33
- [field: string]: "asc" | "desc";
34
- }[];
35
- };
36
- }[];
37
- total_rows: number;
38
- }>;
39
- getDocInstance<T>(): Promise<Nano.DocumentScope<IBaseDef<T>>>;
40
- checkDatabaseExists(databaseName?: string): Promise<any>;
41
- createDatabase(): Promise<Nano.DatabaseCreateResponse>;
42
- getInstance(): Promise<Nano.ServerScope>;
43
- private getInstanceBase;
44
- }
45
- export {};
1
+ import type { IMocodyCoreEntityModel } from "../core/base-schema";
2
+ import Nano from "nano";
3
+ declare type IBaseDef<T> = Omit<T & IMocodyCoreEntityModel, "">;
4
+ interface IOptions {
5
+ couchConfig: {
6
+ host: string;
7
+ password?: string;
8
+ username?: string;
9
+ databaseName: string;
10
+ port?: number;
11
+ protocol?: "http" | "https";
12
+ };
13
+ }
14
+ export declare class MocodyInitializerCouch {
15
+ private _databaseInstance;
16
+ private _documentScope;
17
+ private readonly couchConfig;
18
+ constructor({ couchConfig }: IOptions);
19
+ private getFullDbUrl;
20
+ deleteIndex({ ddoc, name }: {
21
+ ddoc: string;
22
+ name: string;
23
+ }): Promise<{
24
+ ok: boolean;
25
+ }>;
26
+ getIndexes(): Promise<{
27
+ indexes: {
28
+ ddoc: string;
29
+ name: string;
30
+ type: string;
31
+ def: {
32
+ fields: {
33
+ [field: string]: "asc" | "desc";
34
+ }[];
35
+ };
36
+ }[];
37
+ total_rows: number;
38
+ }>;
39
+ getDocInstance<T>(): Promise<Nano.DocumentScope<IBaseDef<T>>>;
40
+ checkDatabaseExists(databaseName?: string): Promise<any>;
41
+ createDatabase(): Promise<Nano.DatabaseCreateResponse>;
42
+ getInstance(): Promise<Nano.ServerScope>;
43
+ private getInstanceBase;
44
+ }
45
+ export {};
@@ -1,99 +1,99 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MocodyInitializerCouch = void 0;
4
- const tslib_1 = require("tslib");
5
- const logging_service_1 = require("../helpers/logging-service");
6
- const nano_1 = (0, tslib_1.__importDefault)(require("nano"));
7
- const throat_1 = (0, tslib_1.__importDefault)(require("throat"));
8
- const concurrency = (0, throat_1.default)(1);
9
- class MocodyInitializerCouch {
10
- constructor({ couchConfig }) {
11
- Object.defineProperty(this, "_databaseInstance", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "_documentScope", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- Object.defineProperty(this, "couchConfig", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- this.couchConfig = couchConfig;
30
- }
31
- getFullDbUrl(config) {
32
- const protocol = config?.protocol || "http";
33
- const dbUrlPart = [`${protocol}://`];
34
- if (config?.username && config.password) {
35
- dbUrlPart.push(config.username);
36
- dbUrlPart.push(`:${config.password}@`);
37
- }
38
- dbUrlPart.push(config.host);
39
- if (config?.port) {
40
- dbUrlPart.push(`:${config.port}`);
41
- }
42
- return dbUrlPart.join("");
43
- }
44
- async deleteIndex({ ddoc, name }) {
45
- const path = ["_index", ddoc, "json", name].join("/");
46
- const instance = await this.getInstance();
47
- const result = await instance.relax({
48
- db: this.couchConfig.databaseName,
49
- method: "DELETE",
50
- path,
51
- content_type: "application/json",
52
- });
53
- return result;
54
- }
55
- async getIndexes() {
56
- const instance = await this.getInstance();
57
- const result = await instance.request({
58
- db: this.couchConfig.databaseName,
59
- method: "GET",
60
- path: "_index",
61
- content_type: "application/json",
62
- });
63
- logging_service_1.LoggingService.log({ indexes: result });
64
- return result;
65
- }
66
- async getDocInstance() {
67
- if (!this._documentScope) {
68
- const n = await this.getInstance();
69
- const db = n.db.use(this.couchConfig.databaseName);
70
- this._documentScope = db;
71
- }
72
- return this._documentScope;
73
- }
74
- async checkDatabaseExists(databaseName) {
75
- const instance = await this.getInstance();
76
- const checkDbExistResult = await instance.request({
77
- db: databaseName || this.couchConfig.databaseName,
78
- method: "HEAD",
79
- content_type: "application/json",
80
- });
81
- logging_service_1.LoggingService.log(JSON.stringify({ checkDbExistResult }, null, 2));
82
- return checkDbExistResult;
83
- }
84
- async createDatabase() {
85
- const instance = await this.getInstance();
86
- return instance.db.create(this.couchConfig.databaseName, { partitioned: true });
87
- }
88
- async getInstance() {
89
- return await concurrency(() => this.getInstanceBase());
90
- }
91
- async getInstanceBase() {
92
- if (!this._databaseInstance) {
93
- this._databaseInstance = (0, nano_1.default)(this.getFullDbUrl(this.couchConfig));
94
- }
95
- return await Promise.resolve(this._databaseInstance);
96
- }
97
- }
98
- exports.MocodyInitializerCouch = MocodyInitializerCouch;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MocodyInitializerCouch = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const logging_service_1 = require("../helpers/logging-service");
6
+ const nano_1 = tslib_1.__importDefault(require("nano"));
7
+ const throat_1 = tslib_1.__importDefault(require("throat"));
8
+ const concurrency = (0, throat_1.default)(1);
9
+ class MocodyInitializerCouch {
10
+ constructor({ couchConfig }) {
11
+ Object.defineProperty(this, "_databaseInstance", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "_documentScope", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "couchConfig", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ this.couchConfig = couchConfig;
30
+ }
31
+ getFullDbUrl(config) {
32
+ const protocol = config?.protocol || "http";
33
+ const dbUrlPart = [`${protocol}://`];
34
+ if (config?.username && config.password) {
35
+ dbUrlPart.push(config.username);
36
+ dbUrlPart.push(`:${config.password}@`);
37
+ }
38
+ dbUrlPart.push(config.host);
39
+ if (config?.port) {
40
+ dbUrlPart.push(`:${config.port}`);
41
+ }
42
+ return dbUrlPart.join("");
43
+ }
44
+ async deleteIndex({ ddoc, name }) {
45
+ const path = ["_index", ddoc, "json", name].join("/");
46
+ const instance = await this.getInstance();
47
+ const result = await instance.relax({
48
+ db: this.couchConfig.databaseName,
49
+ method: "DELETE",
50
+ path,
51
+ content_type: "application/json",
52
+ });
53
+ return result;
54
+ }
55
+ async getIndexes() {
56
+ const instance = await this.getInstance();
57
+ const result = await instance.request({
58
+ db: this.couchConfig.databaseName,
59
+ method: "GET",
60
+ path: "_index",
61
+ content_type: "application/json",
62
+ });
63
+ logging_service_1.LoggingService.log({ indexes: result });
64
+ return result;
65
+ }
66
+ async getDocInstance() {
67
+ if (!this._documentScope) {
68
+ const n = await this.getInstance();
69
+ const db = n.db.use(this.couchConfig.databaseName);
70
+ this._documentScope = db;
71
+ }
72
+ return this._documentScope;
73
+ }
74
+ async checkDatabaseExists(databaseName) {
75
+ const instance = await this.getInstance();
76
+ const checkDbExistResult = await instance.request({
77
+ db: databaseName || this.couchConfig.databaseName,
78
+ method: "HEAD",
79
+ content_type: "application/json",
80
+ });
81
+ logging_service_1.LoggingService.log(JSON.stringify({ checkDbExistResult }, null, 2));
82
+ return checkDbExistResult;
83
+ }
84
+ async createDatabase() {
85
+ const instance = await this.getInstance();
86
+ return instance.db.create(this.couchConfig.databaseName, { partitioned: true });
87
+ }
88
+ async getInstance() {
89
+ return await concurrency(() => this.getInstanceBase());
90
+ }
91
+ async getInstanceBase() {
92
+ if (!this._databaseInstance) {
93
+ this._databaseInstance = (0, nano_1.default)(this.getFullDbUrl(this.couchConfig));
94
+ }
95
+ return await Promise.resolve(this._databaseInstance);
96
+ }
97
+ }
98
+ exports.MocodyInitializerCouch = MocodyInitializerCouch;
99
99
  //# sourceMappingURL=couch-initializer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"couch-initializer.js","sourceRoot":"","sources":["../../src/couch/couch-initializer.ts"],"names":[],"mappings":";;;;AAAA,gEAA4D;AAE5D,6DAAwB;AAExB,iEAA4B;AAC5B,MAAM,WAAW,GAAG,IAAA,gBAAM,EAAC,CAAC,CAAC,CAAC;AAsB9B,MAAa,sBAAsB;IAQjC,YAAY,EAAE,WAAW,EAAY;QAPrC;;;;;WAAoD;QACpD;;;;;WAAwD;QAExD;;;;;WAAsD;QAKpD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEO,YAAY,CAAC,MAA+B;QAElD,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,MAAM,CAAC;QAC5C,MAAM,SAAS,GAAa,CAAC,GAAG,QAAQ,KAAK,CAAC,CAAC;QAE/C,IAAI,MAAM,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE;YACvC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;SACxC;QAED,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5B,IAAI,MAAM,EAAE,IAAI,EAAE;YAChB,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;SACnC;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,EAAkC;QAC9D,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC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O,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IACzD,CAAC;IAEO,KAAK,CAAC,eAAe;QAC3B,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,IAAI,CAAC,iBAAiB,GAAG,IAAA,cAAI,EAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;SACpE;QACD,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC;CACF;AAxGD,wDAwGC"}
@@ -1,46 +1,46 @@
1
- import type { IMocodyIndexDefinition } from "../type";
2
- import type { MocodyInitializerCouch } from "./couch-initializer";
3
- interface ITableOptions<T> {
4
- couchDb: () => MocodyInitializerCouch;
5
- secondaryIndexOptions: IMocodyIndexDefinition<T>[];
6
- tableFullName: string;
7
- partitionKeyFieldName: string;
8
- sortKeyFieldName: string;
9
- }
10
- export declare class CouchManageTable<T> {
11
- private readonly partitionKeyFieldName;
12
- private readonly sortKeyFieldName;
13
- private readonly couchDb;
14
- private readonly tableFullName;
15
- private readonly secondaryIndexOptions;
16
- constructor({ couchDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName, }: ITableOptions<T>);
17
- private _trickLinter;
18
- private _mocody_getInstance;
19
- mocody_createIndex({ indexName, fields }: {
20
- indexName: string;
21
- fields: string[];
22
- }): Promise<{
23
- id: string;
24
- name: string;
25
- result: string;
26
- }>;
27
- mocody_clearAllIndexes(): Promise<{
28
- deletedIndexes: any[];
29
- }>;
30
- mocody_getIndexes(): Promise<{
31
- indexes: {
32
- ddoc: string;
33
- name: string;
34
- type: string;
35
- def: {
36
- fields: {
37
- [field: string]: "asc" | "desc";
38
- }[];
39
- };
40
- }[];
41
- total_rows: number;
42
- }>;
43
- mocody_createDatabase(): Promise<import("nano").DatabaseCreateResponse>;
44
- mocody_createDefinedIndexes(): Promise<string[]>;
45
- }
46
- export {};
1
+ import type { IMocodyIndexDefinition } from "../type";
2
+ import type { MocodyInitializerCouch } from "./couch-initializer";
3
+ interface ITableOptions<T> {
4
+ couchDb: () => MocodyInitializerCouch;
5
+ secondaryIndexOptions: IMocodyIndexDefinition<T>[];
6
+ tableFullName: string;
7
+ partitionKeyFieldName: string;
8
+ sortKeyFieldName: string;
9
+ }
10
+ export declare class CouchManageTable<T> {
11
+ private readonly partitionKeyFieldName;
12
+ private readonly sortKeyFieldName;
13
+ private readonly couchDb;
14
+ private readonly tableFullName;
15
+ private readonly secondaryIndexOptions;
16
+ constructor({ couchDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName, }: ITableOptions<T>);
17
+ private _trickLinter;
18
+ private _mocody_getInstance;
19
+ mocody_createIndex({ indexName, fields }: {
20
+ indexName: string;
21
+ fields: string[];
22
+ }): Promise<{
23
+ id: string;
24
+ name: string;
25
+ result: string;
26
+ }>;
27
+ mocody_clearAllIndexes(): Promise<{
28
+ deletedIndexes: any[];
29
+ }>;
30
+ mocody_getIndexes(): Promise<{
31
+ indexes: {
32
+ ddoc: string;
33
+ name: string;
34
+ type: string;
35
+ def: {
36
+ fields: {
37
+ [field: string]: "asc" | "desc";
38
+ }[];
39
+ };
40
+ }[];
41
+ total_rows: number;
42
+ }>;
43
+ mocody_createDatabase(): Promise<import("nano").DatabaseCreateResponse>;
44
+ mocody_createDefinedIndexes(): Promise<string[]>;
45
+ }
46
+ export {};
@@ -1,114 +1,114 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CouchManageTable = void 0;
4
- const logging_service_1 = require("./../helpers/logging-service");
5
- class CouchManageTable {
6
- constructor({ couchDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName, }) {
7
- Object.defineProperty(this, "partitionKeyFieldName", {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value: void 0
12
- });
13
- Object.defineProperty(this, "sortKeyFieldName", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "couchDb", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- Object.defineProperty(this, "tableFullName", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- Object.defineProperty(this, "secondaryIndexOptions", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- this.couchDb = couchDb;
38
- this.tableFullName = tableFullName;
39
- this.partitionKeyFieldName = partitionKeyFieldName;
40
- this.sortKeyFieldName = sortKeyFieldName;
41
- this.secondaryIndexOptions = secondaryIndexOptions;
42
- this._trickLinter();
43
- }
44
- _trickLinter() {
45
- if (this.partitionKeyFieldName && this.sortKeyFieldName && this.tableFullName) {
46
- }
47
- }
48
- _mocody_getInstance() {
49
- return this.couchDb();
50
- }
51
- async mocody_createIndex({ indexName, fields }) {
52
- const instance = await this._mocody_getInstance().getDocInstance();
53
- const result = await instance.createIndex({
54
- index: {
55
- fields: fields,
56
- },
57
- name: indexName,
58
- ddoc: indexName,
59
- type: "json",
60
- partitioned: true,
61
- });
62
- logging_service_1.LoggingService.log(result);
63
- return {
64
- id: result.id,
65
- name: result.name,
66
- result: result.result,
67
- };
68
- }
69
- async mocody_clearAllIndexes() {
70
- const indexes = await this._mocody_getInstance().getIndexes();
71
- if (indexes?.indexes?.length) {
72
- const deletedIndexes = [];
73
- for (const index of indexes.indexes) {
74
- if (index?.type !== "special") {
75
- deletedIndexes.push(index);
76
- await this._mocody_getInstance().deleteIndex({
77
- ddoc: index.ddoc,
78
- name: index.name,
79
- });
80
- }
81
- }
82
- return {
83
- deletedIndexes,
84
- };
85
- }
86
- return {
87
- deletedIndexes: [],
88
- };
89
- }
90
- async mocody_getIndexes() {
91
- return await this._mocody_getInstance().getIndexes();
92
- }
93
- async mocody_createDatabase() {
94
- return await this._mocody_getInstance().createDatabase();
95
- }
96
- async mocody_createDefinedIndexes() {
97
- const results = [];
98
- if (this.secondaryIndexOptions?.length) {
99
- for (const indexOption of this.secondaryIndexOptions) {
100
- if (indexOption?.indexName) {
101
- const resultData = await this.mocody_createIndex({
102
- fields: [indexOption.partitionKeyFieldName, indexOption.sortKeyFieldName],
103
- indexName: indexOption.indexName,
104
- });
105
- logging_service_1.LoggingService.log(resultData);
106
- results.push(resultData.result);
107
- }
108
- }
109
- }
110
- return results;
111
- }
112
- }
113
- exports.CouchManageTable = CouchManageTable;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CouchManageTable = void 0;
4
+ const logging_service_1 = require("./../helpers/logging-service");
5
+ class CouchManageTable {
6
+ constructor({ couchDb, secondaryIndexOptions, tableFullName, partitionKeyFieldName, sortKeyFieldName, }) {
7
+ Object.defineProperty(this, "partitionKeyFieldName", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: void 0
12
+ });
13
+ Object.defineProperty(this, "sortKeyFieldName", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ Object.defineProperty(this, "couchDb", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+ Object.defineProperty(this, "tableFullName", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: void 0
30
+ });
31
+ Object.defineProperty(this, "secondaryIndexOptions", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: void 0
36
+ });
37
+ this.couchDb = couchDb;
38
+ this.tableFullName = tableFullName;
39
+ this.partitionKeyFieldName = partitionKeyFieldName;
40
+ this.sortKeyFieldName = sortKeyFieldName;
41
+ this.secondaryIndexOptions = secondaryIndexOptions;
42
+ this._trickLinter();
43
+ }
44
+ _trickLinter() {
45
+ if (this.partitionKeyFieldName && this.sortKeyFieldName && this.tableFullName) {
46
+ }
47
+ }
48
+ _mocody_getInstance() {
49
+ return this.couchDb();
50
+ }
51
+ async mocody_createIndex({ indexName, fields }) {
52
+ const instance = await this._mocody_getInstance().getDocInstance();
53
+ const result = await instance.createIndex({
54
+ index: {
55
+ fields: fields,
56
+ },
57
+ name: indexName,
58
+ ddoc: indexName,
59
+ type: "json",
60
+ partitioned: true,
61
+ });
62
+ logging_service_1.LoggingService.log(result);
63
+ return {
64
+ id: result.id,
65
+ name: result.name,
66
+ result: result.result,
67
+ };
68
+ }
69
+ async mocody_clearAllIndexes() {
70
+ const indexes = await this._mocody_getInstance().getIndexes();
71
+ if (indexes?.indexes?.length) {
72
+ const deletedIndexes = [];
73
+ for (const index of indexes.indexes) {
74
+ if (index?.type !== "special") {
75
+ deletedIndexes.push(index);
76
+ await this._mocody_getInstance().deleteIndex({
77
+ ddoc: index.ddoc,
78
+ name: index.name,
79
+ });
80
+ }
81
+ }
82
+ return {
83
+ deletedIndexes,
84
+ };
85
+ }
86
+ return {
87
+ deletedIndexes: [],
88
+ };
89
+ }
90
+ async mocody_getIndexes() {
91
+ return await this._mocody_getInstance().getIndexes();
92
+ }
93
+ async mocody_createDatabase() {
94
+ return await this._mocody_getInstance().createDatabase();
95
+ }
96
+ async mocody_createDefinedIndexes() {
97
+ const results = [];
98
+ if (this.secondaryIndexOptions?.length) {
99
+ for (const indexOption of this.secondaryIndexOptions) {
100
+ if (indexOption?.indexName) {
101
+ const resultData = await this.mocody_createIndex({
102
+ fields: [indexOption.partitionKeyFieldName, indexOption.sortKeyFieldName],
103
+ indexName: indexOption.indexName,
104
+ });
105
+ logging_service_1.LoggingService.log(resultData);
106
+ results.push(resultData.result);
107
+ }
108
+ }
109
+ }
110
+ return results;
111
+ }
112
+ }
113
+ exports.CouchManageTable = CouchManageTable;
114
114
  //# sourceMappingURL=couch-manage-table.js.map