@golemio/core 1.6.6-dev.837591395 → 1.6.6-rc.839233788

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 (84) hide show
  1. package/README.md +1 -0
  2. package/bin/import-test-data.js +72 -0
  3. package/dist/helpers/HealthCheck.d.ts +1 -0
  4. package/dist/helpers/HealthCheck.js +1 -0
  5. package/dist/helpers/HealthCheck.js.map +1 -1
  6. package/dist/integration-engine/config/IntegrationEngineConfiguration.d.ts +1 -0
  7. package/dist/integration-engine/config/IntegrationEngineConfiguration.js +1 -0
  8. package/dist/integration-engine/config/IntegrationEngineConfiguration.js.map +1 -1
  9. package/dist/integration-engine/config/abstract.d.ts +1 -0
  10. package/dist/integration-engine/connectors/MongoConnector.d.ts +15 -0
  11. package/dist/integration-engine/connectors/MongoConnector.js +89 -0
  12. package/dist/integration-engine/connectors/MongoConnector.js.map +1 -0
  13. package/dist/integration-engine/connectors/index.d.ts +6 -0
  14. package/dist/integration-engine/connectors/index.js +6 -1
  15. package/dist/integration-engine/connectors/index.js.map +1 -1
  16. package/dist/integration-engine/connectors/interfaces/IMongoConnector.d.ts +7 -0
  17. package/dist/integration-engine/connectors/interfaces/IMongoConnector.js +3 -0
  18. package/dist/integration-engine/connectors/interfaces/IMongoConnector.js.map +1 -0
  19. package/dist/integration-engine/datasources/IDataSource.d.ts +2 -2
  20. package/dist/integration-engine/ioc/ContainerToken.d.ts +1 -0
  21. package/dist/integration-engine/ioc/ContainerToken.js +1 -0
  22. package/dist/integration-engine/ioc/ContainerToken.js.map +1 -1
  23. package/dist/integration-engine/ioc/Di.js +2 -0
  24. package/dist/integration-engine/ioc/Di.js.map +1 -1
  25. package/dist/integration-engine/models/IModel.d.ts +12 -0
  26. package/dist/integration-engine/models/MongoModel.d.ts +42 -0
  27. package/dist/integration-engine/models/MongoModel.js +245 -0
  28. package/dist/integration-engine/models/MongoModel.js.map +1 -0
  29. package/dist/integration-engine/models/PostgresModel.js +1 -1
  30. package/dist/integration-engine/models/PostgresModel.js.map +1 -1
  31. package/dist/integration-engine/models/index.d.ts +1 -0
  32. package/dist/integration-engine/models/index.js +1 -0
  33. package/dist/integration-engine/models/index.js.map +1 -1
  34. package/dist/monitoring/opentelemetry/instrumentation/configs/index.d.ts +1 -0
  35. package/dist/monitoring/opentelemetry/instrumentation/configs/index.js +3 -1
  36. package/dist/monitoring/opentelemetry/instrumentation/configs/index.js.map +1 -1
  37. package/dist/monitoring/opentelemetry/instrumentation/configs/mongoose.d.ts +2 -0
  38. package/dist/monitoring/opentelemetry/instrumentation/configs/mongoose.js +20 -0
  39. package/dist/monitoring/opentelemetry/instrumentation/configs/mongoose.js.map +1 -0
  40. package/dist/monitoring/opentelemetry/instrumentation/index.d.ts +2 -1
  41. package/dist/monitoring/opentelemetry/instrumentation/index.js +2 -0
  42. package/dist/monitoring/opentelemetry/instrumentation/index.js.map +1 -1
  43. package/dist/monitoring/sentry/sentry-provider.js +1 -0
  44. package/dist/monitoring/sentry/sentry-provider.js.map +1 -1
  45. package/dist/output-gateway/Geo.d.ts +1 -1
  46. package/dist/output-gateway/config/OutputGatewayConfiguration.d.ts +3 -0
  47. package/dist/output-gateway/config/OutputGatewayConfiguration.js +11 -0
  48. package/dist/output-gateway/config/OutputGatewayConfiguration.js.map +1 -1
  49. package/dist/output-gateway/database/MongoDatabase.d.ts +19 -0
  50. package/dist/output-gateway/database/MongoDatabase.js +89 -0
  51. package/dist/output-gateway/database/MongoDatabase.js.map +1 -0
  52. package/dist/output-gateway/database/index.d.ts +30 -1
  53. package/dist/output-gateway/database/index.js +6 -1
  54. package/dist/output-gateway/database/index.js.map +1 -1
  55. package/dist/output-gateway/ioc/ContainerToken.d.ts +1 -0
  56. package/dist/output-gateway/ioc/ContainerToken.js +1 -0
  57. package/dist/output-gateway/ioc/ContainerToken.js.map +1 -1
  58. package/dist/output-gateway/ioc/Di.js +2 -0
  59. package/dist/output-gateway/ioc/Di.js.map +1 -1
  60. package/dist/output-gateway/models/GeoJsonModel.d.ts +56 -0
  61. package/dist/output-gateway/models/GeoJsonModel.js +188 -0
  62. package/dist/output-gateway/models/GeoJsonModel.js.map +1 -0
  63. package/dist/output-gateway/models/HistoryModel.d.ts +30 -0
  64. package/dist/output-gateway/models/HistoryModel.js +96 -0
  65. package/dist/output-gateway/models/HistoryModel.js.map +1 -0
  66. package/dist/output-gateway/models/MongoModel.d.ts +74 -0
  67. package/dist/output-gateway/models/MongoModel.js +87 -0
  68. package/dist/output-gateway/models/MongoModel.js.map +1 -0
  69. package/dist/output-gateway/models/index.d.ts +3 -0
  70. package/dist/output-gateway/models/index.js +3 -0
  71. package/dist/output-gateway/models/index.js.map +1 -1
  72. package/dist/output-gateway/routes/HistoryRouter.d.ts +7 -0
  73. package/dist/output-gateway/routes/HistoryRouter.js +46 -0
  74. package/dist/output-gateway/routes/HistoryRouter.js.map +1 -0
  75. package/dist/output-gateway/routes/RouterBuilder.d.ts +70 -0
  76. package/dist/output-gateway/routes/RouterBuilder.js +92 -0
  77. package/dist/output-gateway/routes/RouterBuilder.js.map +1 -0
  78. package/dist/output-gateway/routes/index.d.ts +2 -0
  79. package/dist/output-gateway/routes/index.js +2 -0
  80. package/dist/output-gateway/routes/index.js.map +1 -1
  81. package/dist/shared/mongoose.d.ts +2 -0
  82. package/dist/shared/mongoose.js +7 -0
  83. package/dist/shared/mongoose.js.map +1 -0
  84. package/package.json +5 -2
package/README.md CHANGED
@@ -33,6 +33,7 @@ This module is intended for use with Golemio services.
33
33
 
34
34
  - node.js (https://nodejs.org)
35
35
  - RabbitMQ (https://www.rabbitmq.com/)
36
+ - Mongo (https://www.mongodb.com)
36
37
  - Postgres (https://www.postgresql.org/)
37
38
  - Redis (https://redis.io/)
38
39
  - TypeScript (https://www.typescriptlang.org/)
@@ -4,6 +4,8 @@ require("../dist/shared/_global");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
  const glob = require("fast-glob");
7
+ const restore = require("mongodb-restore-dump");
8
+ const mongoose = require("mongoose");
7
9
 
8
10
  const APP_ROOT_PATH = fs.realpathSync(process.cwd());
9
11
  require("dotenv").config({ path: path.resolve(APP_ROOT_PATH, ".env") });
@@ -18,6 +20,7 @@ const log = {
18
20
 
19
21
  const variables = {
20
22
  sqlDumpFiles: process.env.SQL_DUMP_FILES || " ",
23
+ mongoDataPaths: process.env.MONGO_DATA_PATHS || " ",
21
24
  };
22
25
 
23
26
  /**
@@ -43,6 +46,74 @@ const importPostgresTestData = async () => {
43
46
  }
44
47
  };
45
48
 
49
+ /**
50
+ * @deprecated No longer maintained
51
+ */
52
+ const importMongoTestData = async () => {
53
+ const paths = glob.sync(variables.mongoDataPaths, {
54
+ cwd: APP_ROOT_PATH,
55
+ onlyFiles: false,
56
+ absolute: true,
57
+ });
58
+
59
+ if (paths.length < 1) {
60
+ log.info(`Skipping Mongo data import`);
61
+ return;
62
+ }
63
+
64
+ const { mongooseConnection } = require("../dist/output-gateway/database");
65
+ await mongooseConnection;
66
+
67
+ const client = mongoose.connection.getClient();
68
+
69
+ for (const restorePath of paths) {
70
+ log.info(`Restoring Mongo data from '${restorePath}'`);
71
+
72
+ // Restore BSON dumps
73
+ await restore.dump({
74
+ con: client,
75
+ from: restorePath,
76
+ });
77
+
78
+ // Manually restore collection indexes from mongodump-generated metadata files
79
+ const restorePathDir = fs.opendirSync(restorePath);
80
+ let restorePathEntry;
81
+
82
+ // Iterate over $restorePath/$dbName
83
+ while (!!(restorePathEntry = restorePathDir.readSync())) {
84
+ if (restorePathEntry.isFile()) {
85
+ continue;
86
+ }
87
+
88
+ const dbName = restorePathEntry.name;
89
+ const db = client.db(dbName);
90
+ const metadataPaths = glob.sync("*.metadata.json", {
91
+ cwd: path.join(restorePath, dbName),
92
+ absolute: true,
93
+ });
94
+
95
+ // Iterate over $restorePath/$dbName/*.metadata.json
96
+ for (const metadataPath of metadataPaths) {
97
+ const collectionName = path.basename(metadataPath, ".metadata.json");
98
+
99
+ try {
100
+ const { indexes } = JSON.parse(fs.readFileSync(metadataPath).toString("utf8"));
101
+
102
+ if (Array.isArray(indexes)) {
103
+ // Collection should already exist by this point, so just import the indexes
104
+ await db.collection(collectionName).createIndexes(indexes);
105
+ }
106
+ } catch (e) {
107
+ log.warn(`Failed to create indexes for '${dbName}.${collectionName}'`);
108
+ log.warn(e);
109
+ }
110
+ }
111
+ }
112
+
113
+ restorePathDir.closeSync();
114
+ }
115
+ };
116
+
46
117
  (async () => {
47
118
  console.log(
48
119
  "\x1b[33m%s\x1b[0m",
@@ -50,6 +121,7 @@ const importPostgresTestData = async () => {
50
121
  );
51
122
 
52
123
  await importPostgresTestData();
124
+ await importMongoTestData();
53
125
 
54
126
  // Exit with zero code
55
127
  process.exit(0);
@@ -1,5 +1,6 @@
1
1
  export declare enum Service {
2
2
  POSTGRES = "PostgreSQL",
3
+ MONGO = "MongoDB",
3
4
  REDIS = "RedisDB",
4
5
  RABBITMQ = "RabbitMQ"
5
6
  }
@@ -13,6 +13,7 @@ exports.getServiceHealth = exports.Service = void 0;
13
13
  var Service;
14
14
  (function (Service) {
15
15
  Service["POSTGRES"] = "PostgreSQL";
16
+ Service["MONGO"] = "MongoDB";
16
17
  Service["REDIS"] = "RedisDB";
17
18
  Service["RABBITMQ"] = "RabbitMQ";
18
19
  })(Service = exports.Service || (exports.Service = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"HealthCheck.js","sourceRoot":"","sources":["../../src/helpers/HealthCheck.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAY,OAIX;AAJD,WAAY,OAAO;IACf,kCAAuB,CAAA;IACvB,4BAAiB,CAAA;IACjB,gCAAqB,CAAA;AACzB,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAED,IAAK,MAGJ;AAHD,WAAK,MAAM;IACP,mBAAS,CAAA;IACT,uBAAa,CAAA;AACjB,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAiBM,MAAM,gBAAgB,GAAG,CAAO,QAAyB,EAA0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AQ,CAAC,GAAG,CAAC,CAAO,OAAO,EAAE,EAAE;YAC3B,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7F,CAAC,CAAA,CAAC,CACL,CAAC;QACF,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC;QACpE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;KACpD;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;KAC1C;AACL,CAAC,CAAA,CAAC;AAZW,QAAA,gBAAgB,oBAY3B"}
@@ -6,6 +6,7 @@ export declare class IntegrationEngineConfiguration implements IConfiguration {
6
6
  HOPPYGO_BASE_URL: string | undefined;
7
7
  LOG_LEVEL: string | undefined;
8
8
  MOJEPRAHA_ENDPOINT_BASEURL: string | undefined;
9
+ MONGO_CONN: string | undefined;
9
10
  NODE_ENV: string;
10
11
  OPEN_STREET_MAP_API_URL_REVERSE: string | undefined;
11
12
  OPEN_STREET_MAP_API_URL_SEARCH: string | undefined;
@@ -20,6 +20,7 @@ let IntegrationEngineConfiguration = class IntegrationEngineConfiguration {
20
20
  this.HOPPYGO_BASE_URL = process.env.HOPPYGO_BASE_URL;
21
21
  this.LOG_LEVEL = process.env.LOG_LEVEL;
22
22
  this.MOJEPRAHA_ENDPOINT_BASEURL = process.env.MOJEPRAHA_ENDPOINT_BASEURL;
23
+ this.MONGO_CONN = process.env.MONGO_CONN;
23
24
  this.NODE_ENV = process.env.NODE_ENV || "development";
24
25
  this.OPEN_STREET_MAP_API_URL_REVERSE = process.env.OPEN_STREET_MAP_API_URL_REVERSE;
25
26
  this.OPEN_STREET_MAP_API_URL_SEARCH = process.env.OPEN_STREET_MAP_API_URL_SEARCH;
@@ -1 +1 @@
1
- {"version":3,"file":"IntegrationEngineConfiguration.js","sourceRoot":"","sources":["../../../src/integration-engine/config/IntegrationEngineConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwC;AAExC,kDAAkD;AAClD,uCAAsC;AAItC,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAmHvC;;QAlHO,oBAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC;QACtD,qBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAChD,cAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QAClC,+BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;QACpE,aAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;QACjD,oCAA+B,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC;QAC9E,mCAA8B,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;QAC5E,+BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;QACpE,yBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACxD,8BAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;QAClE,kBAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1C,kCAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;QAC1E,kCAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;QAC1E,+BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;QACpE,gBAAW,GAAG,OAAO,C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ChG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC;gBACnF,CAAC,CAAC,CAAC,CAAC;SACX,CAAC;QAGE,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAY,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,IAAI,uBAAY,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;QAChE,IAAI,CAAC,oBAAoB,GAAG,IAAI,uBAAY,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC;IAC9E,CAAC;CACJ,CAAA;AAxHY,8BAA8B;IAD1C,IAAA,qBAAU,GAAE;;GACA,8BAA8B,CAwH1C;AAxHY,wEAA8B"}
1
+ {"version":3,"file":"IntegrationEngineConfiguration.js","sourceRoot":"","sources":["../../../src/integration-engine/config/IntegrationEngineConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwC;AAExC,kDAAkD;AAClD,uCAAsC;AAItC,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAoHvC;;QAnHO,oBAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC;QACtD,qBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAChD,cAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QAClC,+BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;QACpE,eAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QACpC,aAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;QACjD,oCAA+B,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC;QAC9E,mCAA8B,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;QAC5E,+BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;QACpE,yBAAoB,G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ACxB,uBAAuB,EAAE,OAAO,CAAC,GAAG,CAAC,uCAAuC;gBACxE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,EAAE,CAAC;gBACnE,CAAC,CAAC,EAAE;YACR,yBAAyB,EAAE,OAAO,CAAC,GAAG,CAAC,yDAAyD;gBAC5F,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC;gBACjF,CAAC,CAAC,EAAE;YACR,2BAA2B,EAAE,OAAO,CAAC,GAAG,CAAC,2DAA2D;gBAChG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC;gBACnF,CAAC,CAAC,CAAC,CAAC;SACX,CAAC;QAGE,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAY,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,IAAI,uBAAY,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;QAChE,IAAI,CAAC,oBAAoB,GAAG,IAAI,uBAAY,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC;IAC9E,CAAC;CACJ,CAAA;AAzHY,8BAA8B;IAD1C,IAAA,qBAAU,GAAE;;GACA,8BAA8B,CAyH1C;AAzHY,wEAA8B"}
@@ -6,6 +6,7 @@ export interface IConfiguration {
6
6
  HOPPYGO_BASE_URL: string | undefined;
7
7
  LOG_LEVEL: string | undefined;
8
8
  MOJEPRAHA_ENDPOINT_BASEURL: string | undefined;
9
+ MONGO_CONN: string | undefined;
9
10
  NODE_ENV: string;
10
11
  OPEN_STREET_MAP_API_URL_REVERSE: string | undefined;
11
12
  OPEN_STREET_MAP_API_URL_SEARCH: string | undefined;
@@ -0,0 +1,15 @@
1
+ import { ILogger } from "../../helpers";
2
+ import { IConfiguration } from "../config";
3
+ import mongoose from "mongoose";
4
+ import { Disposable } from "tsyringe";
5
+ import { IMongoConnector } from "./interfaces/IMongoConnector";
6
+ export declare class MongoConnector implements IMongoConnector, Disposable {
7
+ private readonly log;
8
+ private mongoConn;
9
+ constructor(config: IConfiguration, log: ILogger);
10
+ connect: () => Promise<mongoose.Connection>;
11
+ getConnection: () => mongoose.Connection;
12
+ isConnected: () => Promise<boolean>;
13
+ disconnect: () => Promise<void>;
14
+ dispose: () => Promise<void>;
15
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __importDefault = (this && this.__importDefault) || function (mod) {
24
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.MongoConnector = void 0;
28
+ const ioc_1 = require("../ioc");
29
+ const errors_1 = require("@golemio/errors");
30
+ const mongoose_1 = __importDefault(require("mongoose"));
31
+ const tsyringe_1 = require("tsyringe");
32
+ let MongoConnector = class MongoConnector {
33
+ constructor(config, log) {
34
+ this.log = log;
35
+ this.connect = () => __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ if (!this.mongoConn) {
38
+ throw new errors_1.CustomError("The ENV variable MONGO_CONN cannot be undefined.", true, this.constructor.name, 6003);
39
+ }
40
+ const connectOptions = {
41
+ bufferCommands: false,
42
+ connectTimeoutMS: 90000,
43
+ socketTimeoutMS: 90000,
44
+ };
45
+ yield mongoose_1.default.connect(this.mongoConn, connectOptions);
46
+ mongoose_1.default.connection.on("disconnected", () => {
47
+ this.log.error("MongoDB disconnected!");
48
+ });
49
+ mongoose_1.default.connection.on("reconnected", () => {
50
+ this.log.warn("MongoDB reconnected after connection lost.");
51
+ });
52
+ mongoose_1.default.connection.on("error", (err) => {
53
+ this.log.error(err);
54
+ });
55
+ this.log.info("Connected to MongoDB!");
56
+ return mongoose_1.default.connection;
57
+ }
58
+ catch (err) {
59
+ this.log.error("Could not connect to " + this.mongoConn);
60
+ throw new errors_1.CustomError("Error while connecting to MongoDB.", false, this.constructor.name, 1001, err);
61
+ }
62
+ });
63
+ this.getConnection = () => {
64
+ if (mongoose_1.default.connection.readyState !== 1) {
65
+ throw new errors_1.CustomError("Mongoose connection does not exist. First call connect() method.", false, this.constructor.name, 1002);
66
+ }
67
+ return mongoose_1.default.connection;
68
+ };
69
+ this.isConnected = () => __awaiter(this, void 0, void 0, function* () {
70
+ return mongoose_1.default.connection.readyState === 1;
71
+ });
72
+ this.disconnect = () => __awaiter(this, void 0, void 0, function* () {
73
+ this.log.info("MongoDB disconnect called");
74
+ return mongoose_1.default.connection.close();
75
+ });
76
+ this.dispose = () => __awaiter(this, void 0, void 0, function* () {
77
+ yield this.disconnect();
78
+ });
79
+ this.mongoConn = config.MONGO_CONN;
80
+ }
81
+ };
82
+ MongoConnector = __decorate([
83
+ (0, tsyringe_1.injectable)(),
84
+ __param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.Config)),
85
+ __param(1, (0, tsyringe_1.inject)(ioc_1.ContainerToken.Logger)),
86
+ __metadata("design:paramtypes", [Object, Object])
87
+ ], MongoConnector);
88
+ exports.MongoConnector = MongoConnector;
89
+ //# sourceMappingURL=MongoConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MongoConnector.js","sourceRoot":"","sources":["../../../src/integration-engine/connectors/MongoConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gCAAyC;AACzC,4CAA8C;AAC9C,wDAAoD;AACpD,uCAA0D;AAI1D,IAAa,cAAc,GAA3B,MAAa,cAAc;IAGvB,YACmC,MAAsB,EACL,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;QAKzD,YAAO,GAAG,GAAuC,EAAE;YACtD,IAAI;gBACA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;oBACjB,MAAM,IAAI,oBAAW,CAAC,kDAAkD,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChH;gBACD,MAAM,cAAc,GAAmB;oBACnC,cAAc,EAAE,KAAK;oBACrB,gBAAgB,EAAE,KAAK;oBACvB,eAAe,EAAE,KAAK;iBACzB,CAAC;gBAEF,MAAM,kBAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;gBAEvD,kBAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;oBACxC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBAC5C,CAAC,CAAC,CAAC;gBAEH,kBAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;oBACvC,IAAI,CAAC,GAAG,CAA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AAE,CAAC;QAC5B,CAAC,CAAA,CAAC;QA3DE,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;IACvC,CAAC;CA2DJ,CAAA;AAnEY,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAKJ,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,MAAM,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,MAAM,CAAC,CAAA;;GALzB,cAAc,CAmE1B;AAnEY,wCAAc"}
@@ -1,10 +1,15 @@
1
1
  import { AMQPConnector } from "./AMQPConnector";
2
+ import { IMongoConnector } from "./interfaces/IMongoConnector";
2
3
  import IPostgresConnector from "./interfaces/IPostgresConnector";
3
4
  import IRedisConnector from "./interfaces/IRedisConnector";
4
5
  /**
5
6
  * @deprecated For backwards compatibility. Use ioc container instead.
6
7
  */
7
8
  declare const queueConnector: AMQPConnector;
9
+ /**
10
+ * @deprecated For backwards compatibility. Use ioc container instead.
11
+ */
12
+ declare const mongoConnector: IMongoConnector;
8
13
  /**
9
14
  * @deprecated For backwards compatibility. Use ioc container instead.
10
15
  */
@@ -15,4 +20,5 @@ declare const postgresConnector: IPostgresConnector;
15
20
  declare const redisConnector: IRedisConnector;
16
21
  export { redisConnector as RedisConnector };
17
22
  export { queueConnector as AMQPConnector };
23
+ export { mongoConnector as MongoConnector };
18
24
  export { postgresConnector as PostgresConnector };
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgresConnector = exports.AMQPConnector = exports.RedisConnector = void 0;
3
+ exports.PostgresConnector = exports.MongoConnector = exports.AMQPConnector = exports.RedisConnector = void 0;
4
4
  const ioc_1 = require("../ioc");
5
5
  /**
6
6
  * @deprecated For backwards compatibility. Use ioc container instead.
7
7
  */
8
8
  const queueConnector = ioc_1.IntegrationEngineContainer.resolve(ioc_1.ContainerToken.AmqpConnector);
9
9
  exports.AMQPConnector = queueConnector;
10
+ /**
11
+ * @deprecated For backwards compatibility. Use ioc container instead.
12
+ */
13
+ const mongoConnector = ioc_1.IntegrationEngineContainer.resolve(ioc_1.ContainerToken.MongoConnector);
14
+ exports.MongoConnector = mongoConnector;
10
15
  /**
11
16
  * @deprecated For backwards compatibility. Use ioc container instead.
12
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration-engine/connectors/index.ts"],"names":[],"mappings":";;;AAAA,gCAAqE;AAKrE;;GAEG;AACH,MAAM,cAAc,GAAG,gCAA0B,CAAC,OAAO,CAAgB,oBAAc,CAAC,aAAa,CAAC,CAAC;AAY5E,uCAAa;AAXxC;;GAEG;AACH,MAAM,iBAAiB,GAAG,gCAA0B,CAAC,OAAO,CAAqB,oBAAc,CAAC,iBAAiB,CAAC,CAAC;AASrF,8CAAiB;AAR/C;;GAEG;AACH,MAAM,cAAc,GAAG,gCAA0B,CAAC,OAAO,CAAkB,oBAAc,CAAC,cAAc,CAAC,CAAC;AAG/E,wCAAc"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration-engine/connectors/index.ts"],"names":[],"mappings":";;;AAAA,gCAAqE;AAMrE;;GAEG;AACH,MAAM,cAAc,GAAG,gCAA0B,CAAC,OAAO,CAAgB,oBAAc,CAAC,aAAa,CAAC,CAAC;AAgB5E,uCAAa;AAfxC;;GAEG;AACH,MAAM,cAAc,GAAG,gCAA0B,CAAC,OAAO,CAAkB,oBAAc,CAAC,cAAc,CAAC,CAAC;AAa/E,wCAAc;AAZzC;;GAEG;AACH,MAAM,iBAAiB,GAAG,gCAA0B,CAAC,OAAO,CAAqB,oBAAc,CAAC,iBAAiB,CAAC,CAAC;AAUrF,8CAAiB;AAT/C;;GAEG;AACH,MAAM,cAAc,GAAG,gCAA0B,CAAC,OAAO,CAAkB,oBAAc,CAAC,cAAc,CAAC,CAAC;AAG/E,wCAAc"}
@@ -0,0 +1,7 @@
1
+ import mongoose from "mongoose";
2
+ export interface IMongoConnector {
3
+ connect(): Promise<mongoose.Connection>;
4
+ getConnection(): mongoose.Connection;
5
+ isConnected(): Promise<boolean>;
6
+ disconnect(): Promise<void>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IMongoConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMongoConnector.js","sourceRoot":"","sources":["../../../../src/integration-engine/connectors/interfaces/IMongoConnector.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { IValidator } from "@golemio/validator";
1
+ import { Validator } from "@golemio/validator";
2
2
  import { IDataTypeStrategy, IProtocolStrategy, DataSourceStream } from "./";
3
3
  export interface IDataSource<T = any> {
4
4
  /** The name of the data source. */
@@ -6,7 +6,7 @@ export interface IDataSource<T = any> {
6
6
  dataStream: DataSourceStream;
7
7
  setProtocolStrategy(strategy: IProtocolStrategy): void;
8
8
  setDataTypeStrategy(strategy: IDataTypeStrategy): void;
9
- setValidator(validator: IValidator): void;
9
+ setValidator(validator: Validator): void;
10
10
  /**
11
11
  * Gets raw data, validates them and sends as a response.
12
12
  *
@@ -4,6 +4,7 @@ declare const ContainerToken: {
4
4
  LoggerEvents: symbol;
5
5
  RequestLogger: symbol;
6
6
  AmqpConnector: symbol;
7
+ MongoConnector: symbol;
7
8
  PostgresConnector: symbol;
8
9
  RedisConnector: symbol;
9
10
  StorageService: symbol;
@@ -7,6 +7,7 @@ const ContainerToken = {
7
7
  LoggerEvents: Symbol(),
8
8
  RequestLogger: Symbol(),
9
9
  AmqpConnector: Symbol(),
10
+ MongoConnector: Symbol(),
10
11
  PostgresConnector: Symbol(),
11
12
  RedisConnector: Symbol(),
12
13
  StorageService: Symbol(),
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerToken.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/ContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,cAAc,GAAG;IACnB,MAAM,EAAE,MAAM,EAAE;IAChB,MAAM,EAAE,MAAM,EAAE;IAChB,YAAY,EAAE,MAAM,EAAE;IACtB,aAAa,EAAE,MAAM,EAAE;IACvB,aAAa,EAAE,MAAM,EAAE;IACvB,iBAAiB,EAAE,MAAM,EAAE;IAC3B,cAAc,EAAE,MAAM,EAAE;IACxB,cAAc,EAAE,MAAM,EAAE;IACxB,sBAAsB,EAAE,MAAM,EAAE;IAChC,UAAU,EAAE,MAAM,EAAE;IACpB,cAAc,EAAE,MAAM,EAAE;IACxB,kBAAkB,EAAE,MAAM,EAAE;IAC5B,yBAAyB,EAAE,MAAM,EAAE;CACtC,CAAC;AAEO,wCAAc"}
1
+ {"version":3,"file":"ContainerToken.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/ContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,cAAc,GAAG;IACnB,MAAM,EAAE,MAAM,EAAE;IAChB,MAAM,EAAE,MAAM,EAAE;IAChB,YAAY,EAAE,MAAM,EAAE;IACtB,aAAa,EAAE,MAAM,EAAE;IACvB,aAAa,EAAE,MAAM,EAAE;IACvB,cAAc,EAAE,MAAM,EAAE;IACxB,iBAAiB,EAAE,MAAM,EAAE;IAC3B,cAAc,EAAE,MAAM,EAAE;IACxB,cAAc,EAAE,MAAM,EAAE;IACxB,sBAAsB,EAAE,MAAM,EAAE;IAChC,UAAU,EAAE,MAAM,EAAE;IACpB,cAAc,EAAE,MAAM,EAAE;IACxB,kBAAkB,EAAE,MAAM,EAAE;IAC5B,yBAAyB,EAAE,MAAM,EAAE;CACtC,CAAC;AAEO,wCAAc"}
@@ -8,6 +8,7 @@ const _helpers_1 = require("../../helpers");
8
8
  const Di_1 = require("../../helpers/ioc/Di");
9
9
  const IntegrationEngineConfiguration_1 = require("../config/IntegrationEngineConfiguration");
10
10
  const AMQPConnector_1 = require("../connectors/AMQPConnector");
11
+ const MongoConnector_1 = require("../connectors/MongoConnector");
11
12
  const PostgresConnector_1 = require("../connectors/PostgresConnector");
12
13
  const RedisConnector_1 = require("../connectors/RedisConnector");
13
14
  const FeatureFlagServiceWrapper_1 = require("../data-access/FeatureFlagServiceWrapper");
@@ -37,6 +38,7 @@ IntegrationEngineContainer.register(ContainerToken_1.ContainerToken.Logger, {
37
38
  //#endregion
38
39
  //#region Data Access
39
40
  IntegrationEngineContainer.register(ContainerToken_1.ContainerToken.AmqpConnector, { useClass: AMQPConnector_1.AMQPConnector }, singletonOptions)
41
+ .register(ContainerToken_1.ContainerToken.MongoConnector, { useClass: MongoConnector_1.MongoConnector }, singletonOptions)
40
42
  .register(ContainerToken_1.ContainerToken.PostgresConnector, { useClass: PostgresConnector_1.PostgresConnector }, singletonOptions)
41
43
  .register(ContainerToken_1.ContainerToken.RedisConnector, { useClass: RedisConnector_1.RedisConnector }, singletonOptions)
42
44
  .register(ContainerToken_1.ContainerToken.StorageServiceProvider, StorageServiceProvider_1.StorageServiceProvider, singletonOptions)
@@ -1 +1 @@
1
- {"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/Di.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAsE;AAEtE,6CAAkD;AAElD,6FAA2F;AAC3F,+DAA6D;AAC7D,uEAAqE;AACrE,iEAA+D;AAG/D,wFAAsF;AACtF,mFAA4D;AAC5D,kFAAgF;AAChF,sDAAoD;AACpD,2EAAoD;AACpD,uCAA6D;AAC7D,qDAAkD;AAElD,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,EAAE,SAAS,EAAE,oBAAS,CAAC,SAAS,EAAE,CAAC;AAC5D,MAAM,0BAA0B,GAAG,oBAAe,CAAC,oBAAoB,EAAE,CAAC;AA+CjE,gEAA0B;AA9CnC,YAAY;AAEZ,iBAAiB;AACjB,0BAA0B,CAAC,QAAQ,CAC/B,+BAAc,CAAC,MAAM,EACrB,EAAE,QAAQ,EAAE,+DAA8B,EAAE,EAC5C,gBAAgB,CACnB,CAAC;AAEF,MAAM,MAAM,GAAG,0BAA0B,CAAC,OA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AE,wBAAc,CAAC;KAChE,QAAQ,CAAC,+BAAc,CAAC,yBAAyB,EAAE,qDAAyB,EAAE,gBAAgB,CAAC;KAC/F,QAAQ,CAAC,+BAAc,CAAC,kBAAkB,EAAE;IACzC,UAAU,EAAE,IAAA,iCAAsB,EAC9B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAA4B,+BAAc,CAAC,yBAAyB,CAAC,CAAC,OAAO,CAChG;CACJ,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { SchemaDefinition } from "mongoose";
1
2
  import { ModelAttributes } from "sequelize";
2
3
  export interface ISequelizeSettings {
3
4
  attributesToRemove?: string[];
@@ -9,6 +10,17 @@ export interface ISequelizeSettings {
9
10
  hasTmpTable?: boolean;
10
11
  addAuditAttributes?: boolean;
11
12
  }
13
+ export interface IMongooseSettings {
14
+ identifierPath: string;
15
+ mongoCollectionName: string;
16
+ outputMongooseSchemaObject: SchemaDefinition;
17
+ resultsPath?: string;
18
+ savingType: "readOnly" | "insertOnly" | "insertOrUpdate";
19
+ updateValues?: (dbData: any, newData: any) => any;
20
+ searchPath?: (id: any, multiple: boolean) => any;
21
+ select?: string;
22
+ tmpMongoCollectionName?: string;
23
+ }
12
24
  export interface IRedisSettings {
13
25
  isKeyConstructedFromData: boolean;
14
26
  prefix: string;
@@ -0,0 +1,42 @@
1
+ import { IModel, IMongooseSettings } from "./";
2
+ import { Validator } from "@golemio/validator";
3
+ import mongoose from "mongoose";
4
+ export declare class MongoModel implements IModel {
5
+ /** Model name */
6
+ name: string;
7
+ /** The schema which contains schemaObject for creating the Mongoose Schema */
8
+ protected schema: mongoose.Schema;
9
+ /** The Mongoose Model */
10
+ protected mongooseModel: mongoose.Model<any>;
11
+ /** The Mongoose Model for temporary collection */
12
+ protected tmpMongooseModel?: mongoose.Model<any>;
13
+ /** Validation helper */
14
+ protected validator: Validator;
15
+ /** Path where to look for ID - identifier to search by */
16
+ protected searchPath: Function;
17
+ /** Path to the sub-property which contains the identifier (separated by dot), e.g. "properties.id" */
18
+ protected identifierPath: string;
19
+ /** Path to the sub-property which contains the results (separated by dot), e.g. "properties" */
20
+ protected resultsPath: string;
21
+ /** String to specify selection of DB query. */
22
+ protected select: string;
23
+ /** Type/Strategy of saving the data */
24
+ protected savingType: "readOnly" | "insertOnly" | "insertOrUpdate";
25
+ /** Function to specify which values can be updated */
26
+ protected updateValues: ((dbData: any, newData: any) => any) | null;
27
+ constructor(name: string, settings: IMongooseSettings, validator: Validator);
28
+ save: (data: any, useTmpTable?: boolean) => Promise<any>;
29
+ updateOne: (opts: any, data: any, useTmpTable?: boolean) => Promise<any>;
30
+ updateOneById: (id: any, data: any, useTmpTable?: boolean) => Promise<any>;
31
+ truncate: (useTmpTable?: boolean) => Promise<any>;
32
+ delete: (opts: object, useTmpTable?: boolean) => Promise<any>;
33
+ find: (opts: object, useTmpTable?: boolean) => Promise<any>;
34
+ findOne: (opts: object, useTmpTable?: boolean) => Promise<any>;
35
+ findOneById: (id: string | number, useTmpTable?: boolean) => Promise<any>;
36
+ aggregate: (aggregation: any[], useTmpTable?: boolean) => Promise<any>;
37
+ replaceOrigCollectionByTempCollection: () => Promise<void>;
38
+ private insertOnly;
39
+ private insertOrUpdate;
40
+ private insertOrUpdateOne;
41
+ private getMongooseModelSafely;
42
+ }