@etohq/link-modules-sdk 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.
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/initialize/index.d.ts +16 -0
- package/dist/initialize/index.d.ts.map +1 -0
- package/dist/initialize/index.js +127 -0
- package/dist/initialize/index.js.map +1 -0
- package/dist/initialize/module-definition.d.ts +3 -0
- package/dist/initialize/module-definition.d.ts.map +1 -0
- package/dist/initialize/module-definition.js +18 -0
- package/dist/initialize/module-definition.js.map +1 -0
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.d.ts.map +1 -0
- package/dist/loaders/connection.js +19 -0
- package/dist/loaders/connection.js.map +1 -0
- package/dist/loaders/container.d.ts +3 -0
- package/dist/loaders/container.d.ts.map +1 -0
- package/dist/loaders/container.js +32 -0
- package/dist/loaders/container.js.map +1 -0
- package/dist/loaders/index.d.ts +9 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +16 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/migration/index.d.ts +103 -0
- package/dist/migration/index.d.ts.map +1 -0
- package/dist/migration/index.js +353 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/repositories/index.d.ts +3 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +8 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/link.d.ts +38 -0
- package/dist/repositories/link.d.ts.map +1 -0
- package/dist/repositories/link.js +34 -0
- package/dist/repositories/link.js.map +1 -0
- package/dist/services/dynamic-service-class.d.ts +8 -0
- package/dist/services/dynamic-service-class.d.ts.map +1 -0
- package/dist/services/dynamic-service-class.js +29 -0
- package/dist/services/dynamic-service-class.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +26 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/link-module-service.d.ts +41 -0
- package/dist/services/link-module-service.d.ts.map +1 -0
- package/dist/services/link-module-service.js +271 -0
- package/dist/services/link-module-service.js.map +1 -0
- package/dist/services/link.d.ts +17 -0
- package/dist/services/link.d.ts.map +1 -0
- package/dist/services/link.js +139 -0
- package/dist/services/link.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/compress-name.d.ts +2 -0
- package/dist/utils/compress-name.d.ts.map +1 -0
- package/dist/utils/compress-name.js +33 -0
- package/dist/utils/compress-name.js.map +1 -0
- package/dist/utils/generate-entity.d.ts +4 -0
- package/dist/utils/generate-entity.d.ts.map +1 -0
- package/dist/utils/generate-entity.js +93 -0
- package/dist/utils/generate-entity.js.map +1 -0
- package/dist/utils/generate-schema.d.ts +5 -0
- package/dist/utils/generate-schema.d.ts.map +1 -0
- package/dist/utils/generate-schema.js +156 -0
- package/dist/utils/generate-schema.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./initialize"), exports);
|
|
18
|
+
__exportStar(require("./loaders"), exports);
|
|
19
|
+
__exportStar(require("./migration"), exports);
|
|
20
|
+
__exportStar(require("./services"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4CAAyB;AACzB,8CAA2B;AAC3B,6CAA0B;AAC1B,0CAAuB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration, ILinkModule, InternalModuleDeclaration, ModuleJoinerConfig, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@etohq/framework/types";
|
|
2
|
+
import { MigrationsExecutionPlanner } from "../migration";
|
|
3
|
+
import { InitializeModuleInjectableDependencies } from "../types";
|
|
4
|
+
export declare const buildInitialize: (linkDefinitions: ModuleJoinerConfig[]) => (options?: ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, pluginLinksDefinitions?: ModuleJoinerConfig[], injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<{
|
|
5
|
+
[link: string]: ILinkModule;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Prepare an execution plan and run the migrations accordingly.
|
|
9
|
+
* It includes creating, updating, deleting the tables according to the execution plan.
|
|
10
|
+
* If any unsafe sql is identified then we will notify the user to act manually.
|
|
11
|
+
*
|
|
12
|
+
* @param options
|
|
13
|
+
* @param pluginLinksDefinition
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildMigrationPlanner(linkDefinitions: ModuleJoinerConfig[]): (options: ModuleServiceInitializeOptions, pluginLinksDefinition?: ModuleJoinerConfig[]) => MigrationsExecutionPlanner;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,yBAAyB,EAGzB,kBAAkB,EAClB,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,wBAAwB,CAAA;AAW/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAA;AAIjE,eAAO,MAAM,eAAe,oBAAqB,kBAAkB,EAAE,gBAE/D,8BAA8B,GAC9B,6CAA6C,GAC7C,yBAAyB,GACzB,yBAAyB,2BACJ,kBAAkB,EAAE,yBACtB,sCAAsC,KAC5D,OAAO,CAAC;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAuIzC,CAAA;AAED;;;;;;;GAOG;AAEH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,kBAAkB,EAAE,aAE9D,8BAA8B,0BACf,kBAAkB,EAAE,gCAgD/C"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildInitialize = void 0;
|
|
4
|
+
exports.buildMigrationPlanner = buildMigrationPlanner;
|
|
5
|
+
const modules_sdk_1 = require("@etohq/framework/modules-sdk");
|
|
6
|
+
const utils_1 = require("@etohq/utils");
|
|
7
|
+
const migration_1 = require("../migration");
|
|
8
|
+
const utils_2 = require("../utils");
|
|
9
|
+
const module_definition_1 = require("./module-definition");
|
|
10
|
+
const buildInitialize = (linkDefinitions) => async (options, pluginLinksDefinitions, injectedDependencies) => {
|
|
11
|
+
const allLinks = {};
|
|
12
|
+
const modulesLoadedKeys = modules_sdk_1.EtoModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
|
|
13
|
+
const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinitions ?? []);
|
|
14
|
+
for (const linkDefinition of allLinksToLoad) {
|
|
15
|
+
const definition = JSON.parse(JSON.stringify(linkDefinition));
|
|
16
|
+
const [primary, foreign] = definition.relationships ?? [];
|
|
17
|
+
if (definition.relationships?.length !== 2 && !definition.isReadOnlyLink) {
|
|
18
|
+
throw new Error(`Link module ${definition.serviceName} can only link 2 modules.`);
|
|
19
|
+
}
|
|
20
|
+
else if (foreign?.foreignKey?.split(",").length > 1 &&
|
|
21
|
+
!definition.isReadOnlyLink) {
|
|
22
|
+
throw new Error(`Foreign key cannot be a composed key.`);
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(definition.extraDataFields)) {
|
|
25
|
+
const extraDataFields = definition.extraDataFields;
|
|
26
|
+
const definedDbFields = Object.keys(definition.databaseConfig?.extraFields || {});
|
|
27
|
+
const difference = (0, utils_1.arrayDifference)(extraDataFields, definedDbFields);
|
|
28
|
+
if (difference.length) {
|
|
29
|
+
throw new Error(`extraDataFields (fieldNames: ${difference.join(",")}) need to be configured under databaseConfig (serviceName: ${definition.serviceName}).`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const serviceKey = !definition.isReadOnlyLink
|
|
33
|
+
? definition.serviceName ??
|
|
34
|
+
(0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)
|
|
35
|
+
: (0, utils_1.simpleHash)(JSON.stringify(definition.extends));
|
|
36
|
+
if (modulesLoadedKeys.includes(serviceKey)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
else if (serviceKey in allLinks) {
|
|
40
|
+
throw new Error(`Link module ${serviceKey} already defined.`);
|
|
41
|
+
}
|
|
42
|
+
if (definition.isReadOnlyLink) {
|
|
43
|
+
const extended = [];
|
|
44
|
+
for (const extension of definition.extends ?? []) {
|
|
45
|
+
if (modulesLoadedKeys.includes(extension.serviceName) &&
|
|
46
|
+
modulesLoadedKeys.includes(extension.relationship.serviceName)) {
|
|
47
|
+
extended.push(extension);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
definition.extends = extended;
|
|
51
|
+
if (extended.length === 0) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (!modulesLoadedKeys.includes(primary.serviceName) ||
|
|
56
|
+
!modulesLoadedKeys.includes(foreign.serviceName)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const logger = injectedDependencies?.[utils_1.ContainerRegistrationKeys.LOGGER] ?? console;
|
|
60
|
+
definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
|
|
61
|
+
logger,
|
|
62
|
+
});
|
|
63
|
+
if (!Array.isArray(definition.alias)) {
|
|
64
|
+
definition.alias = definition.alias ? [definition.alias] : [];
|
|
65
|
+
}
|
|
66
|
+
for (const alias of definition.alias) {
|
|
67
|
+
alias.args ??= {};
|
|
68
|
+
alias.entity = (0, utils_1.toPascalCase)("Link_" +
|
|
69
|
+
(definition.databaseConfig?.tableName ??
|
|
70
|
+
(0, utils_1.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
|
|
71
|
+
}
|
|
72
|
+
const moduleDefinition = (0, module_definition_1.getLinkModuleDefinition)(definition, primary, foreign);
|
|
73
|
+
const linkModuleDefinition = {
|
|
74
|
+
key: serviceKey,
|
|
75
|
+
label: serviceKey,
|
|
76
|
+
dependencies: [utils_1.Modules.EVENT_BUS],
|
|
77
|
+
defaultModuleDeclaration: {
|
|
78
|
+
scope: modules_sdk_1.MODULE_SCOPE.INTERNAL,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const loaded = await modules_sdk_1.EtoModule.bootstrapLink({
|
|
82
|
+
definition: linkModuleDefinition,
|
|
83
|
+
declaration: options,
|
|
84
|
+
moduleExports: moduleDefinition,
|
|
85
|
+
injectedDependencies,
|
|
86
|
+
});
|
|
87
|
+
allLinks[serviceKey] = Object.values(loaded)[0];
|
|
88
|
+
}
|
|
89
|
+
return allLinks;
|
|
90
|
+
};
|
|
91
|
+
exports.buildInitialize = buildInitialize;
|
|
92
|
+
/**
|
|
93
|
+
* Prepare an execution plan and run the migrations accordingly.
|
|
94
|
+
* It includes creating, updating, deleting the tables according to the execution plan.
|
|
95
|
+
* If any unsafe sql is identified then we will notify the user to act manually.
|
|
96
|
+
*
|
|
97
|
+
* @param options
|
|
98
|
+
* @param pluginLinksDefinition
|
|
99
|
+
*/
|
|
100
|
+
function buildMigrationPlanner(linkDefinitions) {
|
|
101
|
+
return function (options, pluginLinksDefinition) {
|
|
102
|
+
const modulesLoadedKeys = modules_sdk_1.EtoModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
|
|
103
|
+
const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinition ?? []);
|
|
104
|
+
const allLinks = new Set();
|
|
105
|
+
for (const definition of allLinksToLoad) {
|
|
106
|
+
if (definition.isReadOnlyLink) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (definition.relationships?.length !== 2) {
|
|
110
|
+
throw new Error(`Link module ${definition.serviceName} must have 2 relationships.`);
|
|
111
|
+
}
|
|
112
|
+
const [primary, foreign] = definition.relationships ?? [];
|
|
113
|
+
const serviceKey = definition.serviceName ??
|
|
114
|
+
(0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey);
|
|
115
|
+
if (allLinks.has(serviceKey)) {
|
|
116
|
+
throw new Error(`Link module ${serviceKey} already exists.`);
|
|
117
|
+
}
|
|
118
|
+
allLinks.add(serviceKey);
|
|
119
|
+
if (!modulesLoadedKeys.includes(primary.serviceName) ||
|
|
120
|
+
!modulesLoadedKeys.includes(foreign.serviceName)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return new migration_1.MigrationsExecutionPlanner(allLinksToLoad, options);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":";;;AAqLA,sDAmDC;AAxOD,8DAAuE;AAavE,wCAQqB;AACrB,4CAAyD;AAEzD,oCAAgD;AAChD,2DAA6D;AAEtD,MAAM,eAAe,GAAG,CAAC,eAAqC,EAAE,EAAE,CAAC,KAAK,EAC7E,OAI6B,EAC7B,sBAA6C,EAC7C,oBAA6D,EACnB,EAAE;IAC5C,MAAM,QAAQ,GAAG,EAAE,CAAA;IACnB,MAAM,iBAAiB,GAAG,uBAAS,CAAC,gBAAgB,EAAE,CAAC,GAAG,CACxD,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAA;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAC1D,sBAAsB,IAAI,EAAE,CAC7B,CAAA;IAED,KAAK,MAAM,cAAc,IAAI,cAAc,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAuB,IAAI,CAAC,KAAK,CAC/C,IAAI,CAAC,S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AAC,CAAA;IAChE,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { JoinerRelationship, ModuleExports, ModuleJoinerConfig } from "@etohq/types";
|
|
2
|
+
export declare function getLinkModuleDefinition(joinerConfig: ModuleJoinerConfig, primary: JoinerRelationship, foreign: JoinerRelationship): ModuleExports;
|
|
3
|
+
//# sourceMappingURL=module-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../../src/initialize/module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EACnB,MAAM,cAAc,CAAA;AAIrB,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAWf"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLinkModuleDefinition = getLinkModuleDefinition;
|
|
4
|
+
const services_1 = require("../services");
|
|
5
|
+
const loaders_1 = require("../loaders");
|
|
6
|
+
function getLinkModuleDefinition(joinerConfig, primary, foreign) {
|
|
7
|
+
return {
|
|
8
|
+
service: joinerConfig.isReadOnlyLink
|
|
9
|
+
? (0, services_1.getReadOnlyModuleService)(joinerConfig)
|
|
10
|
+
: (0, services_1.getModuleService)(joinerConfig),
|
|
11
|
+
loaders: (0, loaders_1.getLoaders)({
|
|
12
|
+
joinerConfig,
|
|
13
|
+
primary,
|
|
14
|
+
foreign,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=module-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-definition.js","sourceRoot":"","sources":["../../src/initialize/module-definition.ts"],"names":[],"mappings":";;AAQA,0DAeC;AAlBD,0CAAwE;AACxE,wCAAuC;AAEvC,SAAgB,uBAAuB,CACrC,YAAgC,EAChC,OAA2B,EAC3B,OAA2B;IAE3B,OAAO;QACL,OAAO,EAAE,YAAY,CAAC,cAAc;YAClC,CAAC,CAAC,IAAA,mCAAwB,EAAC,YAAY,CAAC;YACxC,CAAC,CAAC,IAAA,2BAAgB,EAAC,YAAY,CAAC;QAClC,OAAO,EAAE,IAAA,oBAAU,EAAC;YAClB,YAAY;YACZ,OAAO;YACP,OAAO;SACR,CAAC;KACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@etohq/framework/types";
|
|
2
|
+
import { EntitySchema } from "@mikro-orm/core";
|
|
3
|
+
export declare function connectionLoader(entity: EntitySchema): ({ options, container, logger, }: LoaderOptions<ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
|
4
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,qCAM9C,aAAa,CACZ,8BAA8B,GAC9B,6CAA6C,CAChD,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CAajB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionLoader = connectionLoader;
|
|
4
|
+
const utils_1 = require("@etohq/utils");
|
|
5
|
+
function connectionLoader(entity) {
|
|
6
|
+
return async ({ options, container, logger, }, moduleDeclaration) => {
|
|
7
|
+
const pathToMigrations = __dirname + "/../migrations";
|
|
8
|
+
await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
|
|
9
|
+
moduleName: "link_module",
|
|
10
|
+
entities: [entity],
|
|
11
|
+
container,
|
|
12
|
+
options,
|
|
13
|
+
moduleDeclaration,
|
|
14
|
+
logger,
|
|
15
|
+
pathToMigrations,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":";;AAUA,4CAwBC;AA5BD,wCAA8C;AAI9C,SAAgB,gBAAgB,CAAC,MAAoB;IACnD,OAAO,KAAK,EACV,EACE,OAAO,EACP,SAAS,EACT,MAAM,GAIP,EACD,iBAA6C,EAC9B,EAAE;QACjB,MAAM,gBAAgB,GAAG,SAAS,GAAG,gBAAgB,CAAA;QAErD,MAAM,uBAAe,CAAC,wBAAwB,CAAC;YAC7C,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,CAAC,MAAM,CAAC;YAClB,SAAS;YACT,OAAO;YACP,iBAAiB;YACjB,MAAM;YACN,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions, ModuleJoinerConfig, ModulesSdkTypes } from "@etohq/framework/types";
|
|
2
|
+
export declare function containerLoader(entity: any, joinerConfig: ModuleJoinerConfig): ({ options, container, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
|
3
|
+
//# sourceMappingURL=container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,eAAe,EAChB,MAAM,wBAAwB,CAAA;AAS/B,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,YAAY,EAAE,kBAAkB,6BAKjE,aAAa,CACZ,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CAyCjB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containerLoader = containerLoader;
|
|
4
|
+
const repositories_1 = require("../repositories");
|
|
5
|
+
const services_1 = require("../services");
|
|
6
|
+
const utils_1 = require("@etohq/utils");
|
|
7
|
+
const awilix_1 = require("awilix");
|
|
8
|
+
function containerLoader(entity, joinerConfig) {
|
|
9
|
+
return async ({ options, container, }, moduleDeclaration) => {
|
|
10
|
+
const [primary, foreign] = joinerConfig.relationships;
|
|
11
|
+
const serviceName = !joinerConfig.isReadOnlyLink
|
|
12
|
+
? joinerConfig.serviceName ??
|
|
13
|
+
(0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)
|
|
14
|
+
: (0, utils_1.simpleHash)(JSON.stringify(joinerConfig.extends));
|
|
15
|
+
const entityName = (0, utils_1.toPascalCase)("Link_" +
|
|
16
|
+
(joinerConfig.databaseConfig?.tableName ??
|
|
17
|
+
(0, utils_1.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
|
|
18
|
+
container.register({
|
|
19
|
+
joinerConfig: (0, awilix_1.asValue)(joinerConfig),
|
|
20
|
+
primaryKey: (0, awilix_1.asValue)(primary.foreignKey.split(",")),
|
|
21
|
+
foreignKey: (0, awilix_1.asValue)(foreign.foreignKey),
|
|
22
|
+
extraFields: (0, awilix_1.asValue)(Object.keys(joinerConfig.databaseConfig?.extraFields || {})),
|
|
23
|
+
linkModuleService: (0, awilix_1.asClass)((0, services_1.getModuleService)(joinerConfig)).singleton(),
|
|
24
|
+
linkService: (0, awilix_1.asClass)(services_1.LinkService).singleton(),
|
|
25
|
+
baseRepository: (0, awilix_1.asClass)(repositories_1.BaseRepository).singleton(),
|
|
26
|
+
linkRepository: (0, awilix_1.asClass)((0, repositories_1.getLinkRepository)(entity)).singleton(),
|
|
27
|
+
entityName: (0, awilix_1.asValue)(entityName),
|
|
28
|
+
serviceName: (0, awilix_1.asValue)(serviceName),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":";;AAiBA,0CAmDC;AApED,kDAAmE;AACnE,0CAA2D;AAQ3D,wCAKqB;AACrB,mCAAyC;AAEzC,SAAgB,eAAe,CAAC,MAAM,EAAE,YAAgC;IACtE,OAAO,KAAK,EACV,EACE,OAAO,EACP,SAAS,GAIV,EACD,iBAA6C,EAC9B,EAAE;QACjB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,aAAc,CAAA;QAEtD,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,cAAc;YAC9C,CAAC,CAAC,YAAY,CAAC,WAAW;gBACxB,IAAA,uBAAe,EACb,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,CACnB;YACH,CAAC,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;QAEpD,MAAM,UAAU,GAAG,IAAA,oBAAY,EAC7B,OAAO;YACL,CAAC,YAAY,CAAC,cAAc,EAAE,SAAS;gBACrC,IAAA,wBAAgB,EACd,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,CACnB,CAAC,CACP,CAAA;QAED,SAAS,CAAC,QAAQ,CAAC;YACjB,YAAY,EAAE,IAAA,gBAAO,EAAC,YAAY,CAAC;YACnC,UAAU,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClD,UAAU,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,UAAU,CAAC;YACvC,WAAW,EAAE,IAAA,gBAAO,EAClB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,IAAI,EAAE,CAAC,CAC5D;YAED,iBAAiB,EAAE,IAAA,gBAAO,EAAC,IAAA,2BAAgB,EAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAAE;YACtE,WAAW,EAAE,IAAA,gBAAO,EAAC,sBAAW,CAAC,CAAC,SAAS,EAAE;YAE7C,cAAc,EAAE,IAAA,gBAAO,EAAC,6BAAc,CAAC,CAAC,SAAS,EAAE;YACnD,cAAc,EAAE,IAAA,gBAAO,EAAC,IAAA,gCAAiB,EAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE;YAC9D,UAAU,EAAE,IAAA,gBAAO,EAAC,UAAU,CAAC;YAC/B,WAAW,EAAE,IAAA,gBAAO,EAAC,WAAW,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JoinerRelationship, ModuleJoinerConfig, ModuleLoaderFunction } from "@etohq/framework/types";
|
|
2
|
+
import { connectionLoader } from "./connection";
|
|
3
|
+
declare function getLoaders({ joinerConfig, primary, foreign, }: {
|
|
4
|
+
joinerConfig: ModuleJoinerConfig;
|
|
5
|
+
primary: JoinerRelationship;
|
|
6
|
+
foreign: JoinerRelationship;
|
|
7
|
+
}): ModuleLoaderFunction[];
|
|
8
|
+
export { connectionLoader, getLoaders };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,iBAAS,UAAU,CAAC,EAClB,YAAY,EACZ,OAAO,EACP,OAAO,GACR,EAAE;IACD,YAAY,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE,kBAAkB,CAAA;IAC3B,OAAO,EAAE,kBAAkB,CAAA;CAC5B,GAAG,oBAAoB,EAAE,CAOzB;AAGD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionLoader = void 0;
|
|
4
|
+
exports.getLoaders = getLoaders;
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const connection_1 = require("./connection");
|
|
7
|
+
Object.defineProperty(exports, "connectionLoader", { enumerable: true, get: function () { return connection_1.connectionLoader; } });
|
|
8
|
+
const container_1 = require("./container");
|
|
9
|
+
function getLoaders({ joinerConfig, primary, foreign, }) {
|
|
10
|
+
if (joinerConfig.isReadOnlyLink) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
|
|
14
|
+
return [(0, connection_1.connectionLoader)(entity), (0, container_1.containerLoader)(entity, joinerConfig)];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":";;;AA4B2B,gCAAU;AAtBrC,oCAAyC;AACzC,6CAA+C;AAqBtC,iGArBA,6BAAgB,OAqBA;AApBzB,2CAA6C;AAE7C,SAAS,UAAU,CAAC,EAClB,YAAY,EACZ,OAAO,EACP,OAAO,GAKR;IACC,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;QAChC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7D,OAAO,CAAC,IAAA,6BAAgB,EAAC,MAAM,CAAC,EAAE,IAAA,2BAAe,EAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ILinkMigrationsPlanner, LinkMigrationsPlannerAction, ModuleJoinerConfig, ModuleServiceInitializeOptions, PlannerActionLinkDescriptor } from "@etohq/framework/types";
|
|
2
|
+
import { EntitySchema, MikroORM } from "@mikro-orm/core";
|
|
3
|
+
import { PostgreSqlDriver } from "@mikro-orm/postgresql";
|
|
4
|
+
/**
|
|
5
|
+
* The migrations execution planner creates a plan of SQL queries
|
|
6
|
+
* to be executed to keep link modules database state in sync
|
|
7
|
+
* with the links defined inside the user application.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MigrationsExecutionPlanner implements ILinkMigrationsPlanner {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* The table that keeps a track of tables generated by the link
|
|
13
|
+
* module.
|
|
14
|
+
*/
|
|
15
|
+
protected tableName: string;
|
|
16
|
+
constructor(joinerConfig: ModuleJoinerConfig[], options?: ModuleServiceInitializeOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Initializes the ORM using the normalized dbConfig and set
|
|
19
|
+
* of provided entities
|
|
20
|
+
*/
|
|
21
|
+
protected createORM(entities?: EntitySchema[]): Promise<MikroORM<PostgreSqlDriver>>;
|
|
22
|
+
/**
|
|
23
|
+
* Ensure the table to track link modules migrations
|
|
24
|
+
* exists.
|
|
25
|
+
*
|
|
26
|
+
* @param orm MikroORM
|
|
27
|
+
*/
|
|
28
|
+
protected ensureMigrationsTable(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Ensure the migrations table is in sync
|
|
31
|
+
*
|
|
32
|
+
* @param orm
|
|
33
|
+
* @protected
|
|
34
|
+
*/
|
|
35
|
+
protected ensureMigrationsTableUpToDate(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Insert tuple to the migrations table and create the link table
|
|
38
|
+
*
|
|
39
|
+
* @param orm
|
|
40
|
+
* @param action
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
protected createLinkTable(orm: MikroORM<PostgreSqlDriver>, action: LinkMigrationsPlannerAction & {
|
|
44
|
+
linkDescriptor: PlannerActionLinkDescriptor;
|
|
45
|
+
sql: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Drops the link table and untracks it from the "link_modules_migrations"
|
|
49
|
+
* table.
|
|
50
|
+
*/
|
|
51
|
+
protected dropLinkTable(orm: MikroORM<PostgreSqlDriver>, tableName: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns an array of table names that have been tracked during
|
|
54
|
+
* the last run. In short, these tables were created by the
|
|
55
|
+
* link modules migrations runner.
|
|
56
|
+
*
|
|
57
|
+
* @param orm MikroORM
|
|
58
|
+
*/
|
|
59
|
+
protected getTrackedLinksTables(orm: MikroORM<PostgreSqlDriver>): Promise<{
|
|
60
|
+
table_name: string;
|
|
61
|
+
link_descriptor: PlannerActionLinkDescriptor;
|
|
62
|
+
}[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the migration plan for a specific link entity.
|
|
65
|
+
*/
|
|
66
|
+
protected getEntityMigrationPlan(linkDescriptor: PlannerActionLinkDescriptor, entity: EntitySchema, trackedLinksTables: string[]): Promise<LinkMigrationsPlannerAction>;
|
|
67
|
+
/**
|
|
68
|
+
* This method loops over the tables we have fetched from the
|
|
69
|
+
* "link_module_migrations" tables and checks if their new
|
|
70
|
+
* name is different from the tracked name and in that
|
|
71
|
+
* case it will rename the actual table and also the
|
|
72
|
+
* tracked entry.
|
|
73
|
+
*/
|
|
74
|
+
protected migrateOldTables(orm: MikroORM<PostgreSqlDriver>, trackedTables: {
|
|
75
|
+
table_name: string;
|
|
76
|
+
link_descriptor: PlannerActionLinkDescriptor;
|
|
77
|
+
}[]): Promise<{
|
|
78
|
+
table_name: string;
|
|
79
|
+
link_descriptor: PlannerActionLinkDescriptor;
|
|
80
|
+
}[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Renames existing table and also its tracked entry
|
|
83
|
+
*/
|
|
84
|
+
protected renameOldTable(orm: MikroORM<PostgreSqlDriver>, oldName: string, newName: string, descriptor: PlannerActionLinkDescriptor): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a plan to executed in order to keep the database state in
|
|
87
|
+
* sync with the user-defined links.
|
|
88
|
+
*
|
|
89
|
+
* This method only creates a plan and does not change the database
|
|
90
|
+
* state. You must call the "executePlan" method for that.
|
|
91
|
+
*/
|
|
92
|
+
createPlan(): Promise<LinkMigrationsPlannerAction[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Executes the actionsPlan actions where the action is one of 'create' | 'update' | 'delete'.
|
|
95
|
+
* 'noop' and 'notify' actions are implicitly ignored. If a notify action needs to be
|
|
96
|
+
* executed, you can mutate its action to 'update', in that scenario it means that an unsafe
|
|
97
|
+
* update sql (from our point of view) will be executed and some data could be lost.
|
|
98
|
+
*
|
|
99
|
+
* @param actionPlan
|
|
100
|
+
*/
|
|
101
|
+
executePlan(actionPlan: LinkMigrationsPlannerAction[]): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAS/B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAkB,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAGxE;;;;GAIG;AAGH,qBAAa,0BAA2B,YAAW,sBAAsB;;IAoBvE;;;OAGG;IACH,SAAS,CAAC,SAAS,SAA2B;gBAG5C,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,CAAC,EAAE,8BAA8B;IAyB1C;;;OAGG;cACa,SAAS,CAAC,QAAQ,GAAE,YAAY,EAAO;IAIvD;;;;;OAKG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;OAKG;cACa,6BAA6B,CAC3C,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAoDjC;;;;;;OAMG;cACa,eAAe,CAC7B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,MAAM,EAAE,2BAA2B,GAAG;QACpC,cAAc,EAAE,2BAA2B,CAAA;QAC3C,GAAG,EAAE,MAAM,CAAA;KACZ;IAgBH;;;OAGG;cACa,aAAa,CAC3B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,SAAS,EAAE,MAAM;IAQnB;;;;;;OAMG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CACR;QACE,UAAU,EAAE,MAAM,CAAA;QAClB,eAAe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