@ebarahona/loopback-connector-mongodb 1.0.0

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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +526 -0
  3. package/dist/connector/coercion.d.ts +30 -0
  4. package/dist/connector/coercion.js +75 -0
  5. package/dist/connector/coercion.js.map +1 -0
  6. package/dist/connector/errors.d.ts +13 -0
  7. package/dist/connector/errors.js +20 -0
  8. package/dist/connector/errors.js.map +1 -0
  9. package/dist/connector/index.d.ts +6 -0
  10. package/dist/connector/index.js +24 -0
  11. package/dist/connector/index.js.map +1 -0
  12. package/dist/connector/mongo.connector.d.ts +171 -0
  13. package/dist/connector/mongo.connector.js +567 -0
  14. package/dist/connector/mongo.connector.js.map +1 -0
  15. package/dist/connector/property-mapping.d.ts +64 -0
  16. package/dist/connector/property-mapping.js +105 -0
  17. package/dist/connector/property-mapping.js.map +1 -0
  18. package/dist/connector/query-builder.d.ts +42 -0
  19. package/dist/connector/query-builder.js +204 -0
  20. package/dist/connector/query-builder.js.map +1 -0
  21. package/dist/datasource/index.d.ts +3 -0
  22. package/dist/datasource/index.js +10 -0
  23. package/dist/datasource/index.js.map +1 -0
  24. package/dist/datasource/mongo.datasource.d.ts +17 -0
  25. package/dist/datasource/mongo.datasource.factory.d.ts +30 -0
  26. package/dist/datasource/mongo.datasource.factory.js +44 -0
  27. package/dist/datasource/mongo.datasource.factory.js.map +1 -0
  28. package/dist/datasource/mongo.datasource.js +40 -0
  29. package/dist/datasource/mongo.datasource.js.map +1 -0
  30. package/dist/datasource/mongo.datasource.provider.d.ts +17 -0
  31. package/dist/datasource/mongo.datasource.provider.js +42 -0
  32. package/dist/datasource/mongo.datasource.provider.js.map +1 -0
  33. package/dist/helpers/config-validator.d.ts +34 -0
  34. package/dist/helpers/config-validator.js +79 -0
  35. package/dist/helpers/config-validator.js.map +1 -0
  36. package/dist/helpers/connection-manager.d.ts +78 -0
  37. package/dist/helpers/connection-manager.js +212 -0
  38. package/dist/helpers/connection-manager.js.map +1 -0
  39. package/dist/helpers/index.d.ts +5 -0
  40. package/dist/helpers/index.js +15 -0
  41. package/dist/helpers/index.js.map +1 -0
  42. package/dist/helpers/topology.d.ts +23 -0
  43. package/dist/helpers/topology.js +27 -0
  44. package/dist/helpers/topology.js.map +1 -0
  45. package/dist/helpers/url-builder.d.ts +7 -0
  46. package/dist/helpers/url-builder.js +30 -0
  47. package/dist/helpers/url-builder.js.map +1 -0
  48. package/dist/index.d.ts +15 -0
  49. package/dist/index.js +37 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/keys.d.ts +38 -0
  52. package/dist/keys.js +38 -0
  53. package/dist/keys.js.map +1 -0
  54. package/dist/mongo.component.d.ts +59 -0
  55. package/dist/mongo.component.js +138 -0
  56. package/dist/mongo.component.js.map +1 -0
  57. package/dist/providers/index.d.ts +0 -0
  58. package/dist/providers/index.js +4 -0
  59. package/dist/providers/index.js.map +1 -0
  60. package/dist/services/index.d.ts +2 -0
  61. package/dist/services/index.js +7 -0
  62. package/dist/services/index.js.map +1 -0
  63. package/dist/services/mongo.service.d.ts +61 -0
  64. package/dist/services/mongo.service.impl.d.ts +58 -0
  65. package/dist/services/mongo.service.impl.js +211 -0
  66. package/dist/services/mongo.service.impl.js.map +1 -0
  67. package/dist/services/mongo.service.js +3 -0
  68. package/dist/services/mongo.service.js.map +1 -0
  69. package/dist/types.d.ts +85 -0
  70. package/dist/types.js +3 -0
  71. package/dist/types.js.map +1 -0
  72. package/package.json +109 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDatabase = toDatabase;
4
+ exports.fromDatabase = fromDatabase;
5
+ exports.getDatabaseColumnName = getDatabaseColumnName;
6
+ exports.getIdPropertyName = getIdPropertyName;
7
+ const mongodb_1 = require("mongodb");
8
+ const coercion_1 = require("./coercion");
9
+ /**
10
+ * Convert a model instance to its database representation.
11
+ * Handles:
12
+ * - Custom field name mappings (property.mongodb.fieldName)
13
+ * - GeoPoint to GeoJSON conversion
14
+ * - Decimal128 coercion
15
+ *
16
+ * @param modelDef - The model definition
17
+ * @param data - The data to convert
18
+ */
19
+ function toDatabase(modelDef, data) {
20
+ if (!modelDef)
21
+ return data;
22
+ const result = {};
23
+ const props = modelDef.properties;
24
+ for (const [key, value] of Object.entries(data)) {
25
+ const prop = props[key];
26
+ const dbName = prop?.mongodb?.fieldName ?? key;
27
+ if (prop?.mongodb?.dataType === 'Decimal128' && value != null) {
28
+ result[dbName] = (0, coercion_1.toDecimal128)(value);
29
+ }
30
+ else if (prop?.mongodb?.dataType === 'ObjectId' && value != null) {
31
+ result[dbName] = (0, coercion_1.toObjectId)(value);
32
+ }
33
+ else {
34
+ result[dbName] = value;
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ /**
40
+ * Convert a database document to a model instance.
41
+ * Handles:
42
+ * - Custom field name mappings (reverse)
43
+ * - Binary to Buffer conversion
44
+ * - Decimal128 to number conversion
45
+ * - ObjectId to string conversion for non-ObjectId properties
46
+ *
47
+ * @param modelDef - The model definition
48
+ * @param data - The database document
49
+ */
50
+ function fromDatabase(modelDef, data) {
51
+ if (!modelDef || !data)
52
+ return data;
53
+ const result = {};
54
+ const props = modelDef.properties;
55
+ // Build reverse field name mapping
56
+ const reverseMap = new Map();
57
+ for (const [propName, prop] of Object.entries(props)) {
58
+ const dbName = prop?.mongodb?.fieldName;
59
+ if (dbName) {
60
+ reverseMap.set(dbName, propName);
61
+ }
62
+ }
63
+ for (const [key, value] of Object.entries(data)) {
64
+ const propName = reverseMap.get(key) ?? key;
65
+ const prop = props[propName];
66
+ if (value instanceof mongodb_1.Binary) {
67
+ result[propName] = value.buffer;
68
+ }
69
+ else if (value instanceof mongodb_1.Decimal128) {
70
+ result[propName] = parseFloat(value.toString());
71
+ }
72
+ else if (value instanceof mongodb_1.ObjectId && prop && !isObjectIdProperty(prop)) {
73
+ result[propName] = value.toHexString();
74
+ }
75
+ else {
76
+ result[propName] = value;
77
+ }
78
+ }
79
+ return result;
80
+ }
81
+ /**
82
+ * Get the database column name for a model property.
83
+ */
84
+ function getDatabaseColumnName(modelDef, propertyName) {
85
+ if (!modelDef)
86
+ return propertyName;
87
+ const prop = modelDef.properties[propertyName];
88
+ return prop?.mongodb?.fieldName ?? propertyName;
89
+ }
90
+ /**
91
+ * Get the ID property name for a model.
92
+ */
93
+ function getIdPropertyName(modelDef) {
94
+ if (!modelDef)
95
+ return 'id';
96
+ for (const [name, prop] of Object.entries(modelDef.properties)) {
97
+ if (prop.id)
98
+ return name;
99
+ }
100
+ return 'id';
101
+ }
102
+ function isObjectIdProperty(prop) {
103
+ return prop?.mongodb?.dataType === 'ObjectId';
104
+ }
105
+ //# sourceMappingURL=property-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-mapping.js","sourceRoot":"","sources":["../../src/connector/property-mapping.ts"],"names":[],"mappings":";;AA8CA,gCAuBC;AAaD,oCAkCC;AAKD,sDAOC;AAKD,8CAQC;AArID,qCAAqD;AACrD,yCAAoD;AA2BpD;;;;;;;;;GASG;AACH,SAAgB,UAAU,CACxB,QAAqC,EACrC,IAA6B;IAE7B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC;IAElC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,IAAI,GAAG,CAAC;QAE/C,IAAI,IAAI,EAAE,OAAO,EAAE,QAAQ,KAAK,YAAY,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAC9D,MAAM,CAAC,MAAM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ack where filter to a MongoDB query document.
4
+ *
5
+ * Supports:
6
+ * - Simple equality: `{name: 'test'}`
7
+ * - Comparison operators: gt, gte, lt, lte, neq, between
8
+ * - Array operators: inq, nin
9
+ * - String operators: like, nlike, regexp
10
+ * - Logical operators: and, or, nor
11
+ * - Existence: exists
12
+ * - Null type matching
13
+ *
14
+ * Performance note: `like` and `regexp` build MongoDB `$regex`
15
+ * queries. Unanchored patterns (no leading `^`) cause a full
16
+ * collection scan unless backed by a text index. Use `inq` /
17
+ * exact-match where possible.
18
+ *
19
+ * @param where - LoopBack where filter
20
+ * @param idName - The model's ID property name (mapped to _id)
21
+ */
22
+ export declare function buildWhere(where: Record<string, unknown> | undefined, idName?: string): Filter<Document>;
23
+ /**
24
+ * Convert a LoopBack order specification to a MongoDB sort document.
25
+ *
26
+ * @param order - LoopBack order string or array
27
+ * - 'name ASC'
28
+ * - 'name DESC'
29
+ * - ['name ASC', 'date DESC']
30
+ * @param idName - The model's ID property name
31
+ */
32
+ export declare function buildSort(order: string | string[] | undefined, idName?: string): Sort | undefined;
33
+ /**
34
+ * Convert a LoopBack fields filter to a MongoDB projection.
35
+ *
36
+ * @param fields - LoopBack fields specification
37
+ * - `['name', 'email']` (include only)
38
+ * - `{name: true, email: true}` (include)
39
+ * - `{password: false}` (exclude)
40
+ * @param idName - The model's ID property name
41
+ */
42
+ export declare function buildFields(fields: string[] | Record<string, boolean> | undefined, idName?: string): Document | undefined;
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildWhere = buildWhere;
4
+ exports.buildSort = buildSort;
5
+ exports.buildFields = buildFields;
6
+ const coercion_1 = require("./coercion");
7
+ const errors_1 = require("./errors");
8
+ /**
9
+ * Convert a LoopBack where filter to a MongoDB query document.
10
+ *
11
+ * Supports:
12
+ * - Simple equality: `{name: 'test'}`
13
+ * - Comparison operators: gt, gte, lt, lte, neq, between
14
+ * - Array operators: inq, nin
15
+ * - String operators: like, nlike, regexp
16
+ * - Logical operators: and, or, nor
17
+ * - Existence: exists
18
+ * - Null type matching
19
+ *
20
+ * Performance note: `like` and `regexp` build MongoDB `$regex`
21
+ * queries. Unanchored patterns (no leading `^`) cause a full
22
+ * collection scan unless backed by a text index. Use `inq` /
23
+ * exact-match where possible.
24
+ *
25
+ * @param where - LoopBack where filter
26
+ * @param idName - The model's ID property name (mapped to _id)
27
+ */
28
+ function buildWhere(where, idName = 'id') {
29
+ if (!where)
30
+ return {};
31
+ const query = {};
32
+ for (const [key, value] of Object.entries(where)) {
33
+ // Logical operators
34
+ if (key === 'and' || key === 'or' || key === 'nor') {
35
+ if (!Array.isArray(value)) {
36
+ throw new errors_1.MongoConnectorError(`"${key}" operator requires an array`);
37
+ }
38
+ const conditions = value;
39
+ query[`$${key}`] = conditions.map(c => buildWhere(c, idName));
40
+ continue;
41
+ }
42
+ // Map id property to _id
43
+ const fieldName = key === idName ? '_id' : key;
44
+ if (value === null || value === undefined) {
45
+ query[fieldName] = null;
46
+ continue;
47
+ }
48
+ if (typeof value !== 'object' || value instanceof Date) {
49
+ // Simple equality
50
+ query[fieldName] = fieldName === '_id' ? (0, coercion_1.toObjectId)(value) : value;
51
+ continue;
52
+ }
53
+ // Operator expressions
54
+ const spec = value;
55
+ const mongoExpr = {};
56
+ let hasOperator = false;
57
+ let allKeysAreOperators = true;
58
+ for (const [op, operand] of Object.entries(spec)) {
59
+ let matched = true;
60
+ switch (op) {
61
+ case 'gt':
62
+ mongoExpr.$gt = fieldName === '_id' ? (0, coercion_1.toObjectId)(operand) : operand;
63
+ break;
64
+ case 'gte':
65
+ mongoExpr.$gte = fieldName === '_id' ? (0, coercion_1.toObjectId)(operand) : operand;
66
+ break;
67
+ case 'lt':
68
+ mongoExpr.$lt = fieldName === '_id' ? (0, coercion_1.toObjectId)(operand) : operand;
69
+ break;
70
+ case 'lte':
71
+ mongoExpr.$lte = fieldName === '_id' ? (0, coercion_1.toObjectId)(operand) : operand;
72
+ break;
73
+ case 'neq':
74
+ mongoExpr.$ne = fieldName === '_id' ? (0, coercion_1.toObjectId)(operand) : operand;
75
+ break;
76
+ case 'between':
77
+ if (!Array.isArray(operand) || operand.length !== 2) {
78
+ throw new errors_1.MongoConnectorError(`"between" operator requires a 2-element array, got: ${JSON.stringify(operand)}`);
79
+ }
80
+ mongoExpr.$gte = operand[0];
81
+ mongoExpr.$lte = operand[1];
82
+ break;
83
+ case 'inq':
84
+ mongoExpr.$in = Array.isArray(operand)
85
+ ? operand.map(v => (fieldName === '_id' ? (0, coercion_1.toObjectId)(v) : v))
86
+ : operand;
87
+ break;
88
+ case 'nin':
89
+ mongoExpr.$nin = Array.isArray(operand)
90
+ ? operand.map(v => (fieldName === '_id' ? (0, coercion_1.toObjectId)(v) : v))
91
+ : operand;
92
+ break;
93
+ case 'like':
94
+ mongoExpr.$regex = new RegExp(escapeRegex(String(operand)));
95
+ break;
96
+ case 'nlike':
97
+ mongoExpr.$not = new RegExp(escapeRegex(String(operand)));
98
+ break;
99
+ case 'regexp':
100
+ if (operand instanceof RegExp) {
101
+ mongoExpr.$regex = operand;
102
+ }
103
+ else if (typeof operand === 'string' && operand.length <= 256) {
104
+ // Hard cap on pattern length to bound RegExp compilation cost.
105
+ // Callers wanting arbitrary patterns should pass a real RegExp.
106
+ mongoExpr.$regex = new RegExp(operand);
107
+ }
108
+ else {
109
+ throw new errors_1.MongoConnectorError(`"regexp" operator requires a RegExp instance or a string ≤ 256 chars; got: ${typeof operand}`);
110
+ }
111
+ break;
112
+ case 'exists':
113
+ mongoExpr.$exists = Boolean(operand);
114
+ break;
115
+ default:
116
+ if (op.startsWith('$')) {
117
+ // Pass through native operators (e.g. $elemMatch, $size)
118
+ mongoExpr[op] = operand;
119
+ }
120
+ else {
121
+ matched = false;
122
+ }
123
+ break;
124
+ }
125
+ if (matched) {
126
+ hasOperator = true;
127
+ }
128
+ else {
129
+ allKeysAreOperators = false;
130
+ }
131
+ }
132
+ if (hasOperator && allKeysAreOperators) {
133
+ query[fieldName] = mongoExpr;
134
+ }
135
+ else {
136
+ // Plain object value (equality match). Includes the
137
+ // mixed case where some keys look like operators but
138
+ // others do not -- safer to treat as a literal match
139
+ // than to silently drop the non-operator keys.
140
+ query[fieldName] = fieldName === '_id' ? (0, coercion_1.toObjectId)(value) : value;
141
+ }
142
+ }
143
+ return query;
144
+ }
145
+ /**
146
+ * Convert a LoopBack order specification to a MongoDB sort document.
147
+ *
148
+ * @param order - LoopBack order string or array
149
+ * - 'name ASC'
150
+ * - 'name DESC'
151
+ * - ['name ASC', 'date DESC']
152
+ * @param idName - The model's ID property name
153
+ */
154
+ function buildSort(order, idName = 'id') {
155
+ if (!order)
156
+ return undefined;
157
+ const orders = Array.isArray(order) ? order : [order];
158
+ const sort = {};
159
+ for (const item of orders) {
160
+ const parts = item.trim().split(/\s+/);
161
+ let field = parts[0];
162
+ const direction = parts[1]?.toUpperCase() === 'DESC' ? -1 : 1;
163
+ if (field === idName)
164
+ field = '_id';
165
+ sort[field] = direction;
166
+ }
167
+ return sort;
168
+ }
169
+ /**
170
+ * Convert a LoopBack fields filter to a MongoDB projection.
171
+ *
172
+ * @param fields - LoopBack fields specification
173
+ * - `['name', 'email']` (include only)
174
+ * - `{name: true, email: true}` (include)
175
+ * - `{password: false}` (exclude)
176
+ * @param idName - The model's ID property name
177
+ */
178
+ function buildFields(fields, idName = 'id') {
179
+ if (!fields)
180
+ return undefined;
181
+ const projection = {};
182
+ if (Array.isArray(fields)) {
183
+ for (let field of fields) {
184
+ if (field === idName)
185
+ field = '_id';
186
+ projection[field] = 1;
187
+ }
188
+ }
189
+ else {
190
+ for (let [field, include] of Object.entries(fields)) {
191
+ if (field === idName)
192
+ field = '_id';
193
+ projection[field] = include ? 1 : 0;
194
+ }
195
+ }
196
+ return projection;
197
+ }
198
+ /**
199
+ * Escape special regex characters in a string.
200
+ */
201
+ function escapeRegex(str) {
202
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
203
+ }
204
+ //# sourceMappingURL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U,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACpD,IAAI,KAAK,KAAK,MAAM;gBAAE,KAAK,GAAG,KAAK,CAAC;YACpC,UAAU,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { MongoDataSource } from './mongo.datasource';
2
+ export { MongoDataSourceProvider } from './mongo.datasource.provider';
3
+ export { MongoDataSourceFactory, MongoDataSourceFactoryProvider, } from './mongo.datasource.factory';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MongoDataSourceFactoryProvider = exports.MongoDataSourceProvider = exports.MongoDataSource = void 0;
4
+ var mongo_datasource_1 = require("./mongo.datasource");
5
+ Object.defineProperty(exports, "MongoDataSource", { enumerable: true, get: function () { return mongo_datasource_1.MongoDataSource; } });
6
+ var mongo_datasource_provider_1 = require("./mongo.datasource.provider");
7
+ Object.defineProperty(exports, "MongoDataSourceProvider", { enumerable: true, get: function () { return mongo_datasource_provider_1.MongoDataSourceProvider; } });
8
+ var mongo_datasource_factory_1 = require("./mongo.datasource.factory");
9
+ Object.defineProperty(exports, "MongoDataSourceFactoryProvider", { enumerable: true, get: function () { return mongo_datasource_factory_1.MongoDataSourceFactoryProvider; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAA3C,mHAAA,eAAe,OAAA;AACvB,yEAAoE;AAA5D,oIAAA,uBAAuB,OAAA;AAC/B,uEAGoC;AADlC,0IAAA,8BAA8B,OAAA"}
@@ -0,0 +1,17 @@
1
+ import { juggler } from '@loopback/repository';
2
+ import type { MongoConnectionManager } from '../helpers/connection-manager';
3
+ import type { MongoConnectorConfig } from '../types';
4
+ /**
5
+ * A juggler DataSource whose underlying connector uses a shared
6
+ * MongoConnectionManager. Repositories built on this DataSource
7
+ * share one connection pool with MongoService.
8
+ *
9
+ * Lifecycle is owned by the shared manager (MongoComponent's
10
+ * lifecycle observer). Calling `disconnect()` on the underlying
11
+ * connector is a no-op.
12
+ *
13
+ * @public
14
+ */
15
+ export declare class MongoDataSource extends juggler.DataSource {
16
+ constructor(config: MongoConnectorConfig, connectionManager: MongoConnectionManager);
17
+ }
@@ -0,0 +1,30 @@
1
+ import { Provider } from '@loopback/core';
2
+ import { juggler } from '@loopback/repository';
3
+ import { MongoConnectionManager } from '../helpers/connection-manager';
4
+ import { MongoConnectorConfig } from '../types';
5
+ /**
6
+ * Factory for building per-tenant or per-database MongoDataSources
7
+ * that share the singleton MongoConnectionManager (one MongoClient,
8
+ * one pool).
9
+ *
10
+ * Pass `{database: 'tenant_42'}` (or any other override) to target
11
+ * a different database on the same cluster without opening a new
12
+ * connection. Useful for multi-tenant deployments where each tenant
13
+ * gets its own database.
14
+ *
15
+ * @public
16
+ */
17
+ export type MongoDataSourceFactory = (override?: Partial<MongoConnectorConfig>) => juggler.DataSource;
18
+ /**
19
+ * Provider that yields a MongoDataSourceFactory bound at
20
+ * `MongoBindings.DATASOURCE_FACTORY`. Each call constructs a new
21
+ * MongoDataSource wired to the shared MongoConnectionManager.
22
+ *
23
+ * @public
24
+ */
25
+ export declare class MongoDataSourceFactoryProvider implements Provider<MongoDataSourceFactory> {
26
+ private config;
27
+ private manager;
28
+ constructor(config: MongoConnectorConfig | undefined, manager: MongoConnectionManager);
29
+ value(): MongoDataSourceFactory;
30
+ }
@@ -0,0 +1,44 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MongoDataSourceFactoryProvider = void 0;
16
+ const core_1 = require("@loopback/core");
17
+ const keys_1 = require("../keys");
18
+ const connection_manager_1 = require("../helpers/connection-manager");
19
+ const mongo_datasource_1 = require("./mongo.datasource");
20
+ /**
21
+ * Provider that yields a MongoDataSourceFactory bound at
22
+ * `MongoBindings.DATASOURCE_FACTORY`. Each call constructs a new
23
+ * MongoDataSource wired to the shared MongoConnectionManager.
24
+ *
25
+ * @public
26
+ */
27
+ let MongoDataSourceFactoryProvider = class MongoDataSourceFactoryProvider {
28
+ constructor(config, manager) {
29
+ this.config = config;
30
+ this.manager = manager;
31
+ }
32
+ value() {
33
+ const base = this.config ?? {};
34
+ const manager = this.manager;
35
+ return (override) => new mongo_datasource_1.MongoDataSource({ ...base, ...(override ?? {}) }, manager);
36
+ }
37
+ };
38
+ exports.MongoDataSourceFactoryProvider = MongoDataSourceFactoryProvider;
39
+ exports.MongoDataSourceFactoryProvider = MongoDataSourceFactoryProvider = __decorate([
40
+ __param(0, (0, core_1.inject)(keys_1.MongoBindings.CONFIG, { optional: true })),
41
+ __param(1, (0, core_1.inject)(keys_1.MongoBindings.CONNECTION_MANAGER)),
42
+ __metadata("design:paramtypes", [Object, connection_manager_1.MongoConnectionManager])
43
+ ], MongoDataSourceFactoryProvider);
44
+ //# sourceMappingURL=mongo.datasource.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo.datasource.factory.js","sourceRoot":"","sources":["../../src/datasource/mongo.datasource.factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAgD;AAEhD,kCAAsC;AACtC,sEAAqE;AAErE,yDAAmD;AAkBnD;;;;;;GAMG;AACH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IACzC,YAEU,MAAwC,EAExC,OAA+B;QAF/B,WAAM,GAAN,MAAM,CAAkC;QAExC,YAAO,GAAP,OAAO,CAAwB;IACtC,CAAC;IAEJ,KAAK;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,OAAO,CAAC,QAAwC,EAAE,EAAE,CAClD,IAAI,kCAAe,CAAC,EAAC,GAAG,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AAdY,wEAA8B;yCAA9B,8BAA8B;IAEtC,WAAA,IAAA,aAAM,EAAC,oBAAa,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IAE9C,WAAA,IAAA,aAAM,EAAC,oBAAa,CAAC,kBAAkB,CAAC,CAAA;6CACxB,2CAAsB;GAL9B,8BAA8B,CAc1C"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MongoDataSource = void 0;
4
+ const repository_1 = require("@loopback/repository");
5
+ const mongodb_1 = require("mongodb");
6
+ const mongo_connector_1 = require("../connector/mongo.connector");
7
+ /**
8
+ * A juggler DataSource whose underlying connector uses a shared
9
+ * MongoConnectionManager. Repositories built on this DataSource
10
+ * share one connection pool with MongoService.
11
+ *
12
+ * Lifecycle is owned by the shared manager (MongoComponent's
13
+ * lifecycle observer). Calling `disconnect()` on the underlying
14
+ * connector is a no-op.
15
+ *
16
+ * @public
17
+ */
18
+ class MongoDataSource extends repository_1.juggler.DataSource {
19
+ constructor(config, connectionManager) {
20
+ const connector = new mongo_connector_1.MongoConnector(config, connectionManager);
21
+ super({
22
+ name: 'mongo',
23
+ ...config,
24
+ connector,
25
+ });
26
+ // juggler.DataSource only assigns `this.connector` when it
27
+ // resolves the connector via an initialize() module. We pass
28
+ // a fully constructed connector instance, so wire it directly.
29
+ this.connector = connector;
30
+ connector.dataSource = this;
31
+ this.ObjectID = mongodb_1.ObjectId;
32
+ // The shared MongoConnectionManager owns the real connection.
33
+ // Tell the juggler this DataSource is already connected so
34
+ // repository operations don't hang waiting for juggler's own
35
+ // connect flow.
36
+ this.connected = true;
37
+ }
38
+ }
39
+ exports.MongoDataSource = MongoDataSource;
40
+ //# sourceMappingURL=mongo.datasource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo.datasource.js","sourceRoot":"","sources":["../../src/datasource/mongo.datasource.ts"],"names":[],"mappings":";;;AAAA,qDAA6C;AAC7C,qCAAiC;AACjC,kEAA4D;AAI5D;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,oBAAO,CAAC,UAAU;IACrD,YACE,MAA4B,EAC5B,iBAAyC;QAEzC,MAAM,SAAS,GAAG,IAAI,gCAAc,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAChE,KAAK,CAAC;YACJ,IAAI,EAAE,OAAO;YACb,GAAG,MAAM;YACT,SAAS;SACV,CAAC,CAAC;QACH,2DAA2D;QAC3D,6DAA6D;QAC7D,+DAA+D;QAC9D,IAA+C,CAAC,SAAS,GAAG,SAAS,CAAC;QACvE,SAAS,CAAC,UAAU,GAAG,IAA0C,CAAC;QACjE,IAA2C,CAAC,QAAQ,GAAG,kBAAQ,CAAC;QAEjE,8DAA8D;QAC9D,2DAA2D;QAC3D,6DAA6D;QAC7D,gBAAgB;QACf,IAAwC,CAAC,SAAS,GAAG,IAAI,CAAC;IAC7D,CAAC;CACF;AAxBD,0CAwBC"}
@@ -0,0 +1,17 @@
1
+ import { Provider } from '@loopback/core';
2
+ import { juggler } from '@loopback/repository';
3
+ import { MongoConnectionManager } from '../helpers/connection-manager';
4
+ import { MongoConnectorConfig } from '../types';
5
+ /**
6
+ * Provider that yields a singleton MongoDataSource wired to the
7
+ * shared MongoConnectionManager. Bound by MongoComponent at
8
+ * MongoBindings.DATASOURCE.
9
+ *
10
+ * @public
11
+ */
12
+ export declare class MongoDataSourceProvider implements Provider<juggler.DataSource> {
13
+ private config;
14
+ private manager;
15
+ constructor(config: MongoConnectorConfig | undefined, manager: MongoConnectionManager);
16
+ value(): juggler.DataSource;
17
+ }
@@ -0,0 +1,42 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MongoDataSourceProvider = void 0;
16
+ const core_1 = require("@loopback/core");
17
+ const keys_1 = require("../keys");
18
+ const connection_manager_1 = require("../helpers/connection-manager");
19
+ const mongo_datasource_1 = require("./mongo.datasource");
20
+ /**
21
+ * Provider that yields a singleton MongoDataSource wired to the
22
+ * shared MongoConnectionManager. Bound by MongoComponent at
23
+ * MongoBindings.DATASOURCE.
24
+ *
25
+ * @public
26
+ */
27
+ let MongoDataSourceProvider = class MongoDataSourceProvider {
28
+ constructor(config, manager) {
29
+ this.config = config;
30
+ this.manager = manager;
31
+ }
32
+ value() {
33
+ return new mongo_datasource_1.MongoDataSource(this.config ?? {}, this.manager);
34
+ }
35
+ };
36
+ exports.MongoDataSourceProvider = MongoDataSourceProvider;
37
+ exports.MongoDataSourceProvider = MongoDataSourceProvider = __decorate([
38
+ __param(0, (0, core_1.inject)(keys_1.MongoBindings.CONFIG, { optional: true })),
39
+ __param(1, (0, core_1.inject)(keys_1.MongoBindings.CONNECTION_MANAGER)),
40
+ __metadata("design:paramtypes", [Object, connection_manager_1.MongoConnectionManager])
41
+ ], MongoDataSourceProvider);
42
+ //# sourceMappingURL=mongo.datasource.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo.datasource.provider.js","sourceRoot":"","sources":["../../src/datasource/mongo.datasource.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAgD;AAEhD,kCAAsC;AACtC,sEAAqE;AAErE,yDAAmD;AAEnD;;;;;;GAMG;AACH,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAClC,YAEU,MAAwC,EAExC,OAA+B;QAF/B,WAAM,GAAN,MAAM,CAAkC;QAExC,YAAO,GAAP,OAAO,CAAwB;IACtC,CAAC;IAEJ,KAAK;QACH,OAAO,IAAI,kCAAe,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AAXY,0DAAuB;kCAAvB,uBAAuB;IAE/B,WAAA,IAAA,aAAM,EAAC,oBAAa,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IAE9C,WAAA,IAAA,aAAM,EAAC,oBAAa,CAAC,kBAAkB,CAAC,CAAA;6CACxB,2CAAsB;GAL9B,uBAAuB,CAWnC"}
@@ -0,0 +1,34 @@
1
+ import type { MongoConnectorConfig } from '../types';
2
+ /**
3
+ * Error thrown when the connector config fails framework-level
4
+ * validation before any MongoDB driver call is made.
5
+ *
6
+ * Messages never contain credentials -- the offending URL or
7
+ * config object is redacted before formatting.
8
+ *
9
+ * @public
10
+ */
11
+ export declare class MongoConfigError extends Error {
12
+ readonly name = "MongoConfigError";
13
+ constructor(message: string);
14
+ }
15
+ /**
16
+ * Validate connector config. Throws MongoConfigError for cases the
17
+ * driver would otherwise surface as opaque runtime errors:
18
+ * - neither `url` nor `host` set
19
+ * - `url` is not a parseable mongodb:// or mongodb+srv:// URL
20
+ *
21
+ * Everything else (auth shape, TLS, pool sizing) is passed through
22
+ * to the driver, which has good error messages for those.
23
+ *
24
+ * @public
25
+ */
26
+ export declare function validateConfig(config: MongoConnectorConfig | undefined): void;
27
+ /**
28
+ * Replace `username:password@` with `<credentials>@` in a connection
29
+ * string. Safe to log. Handles credentials containing literal `@`
30
+ * characters by parsing the URL rather than relying on regex.
31
+ *
32
+ * @public
33
+ */
34
+ export declare function redactUrl(url: string): string;