@punks/backend-entity-manager 0.0.74 → 0.0.75
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/cjs/index.js +117 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/app/organizations/organization.controller.d.ts +1 -5
- package/dist/cjs/types/platforms/nest/__test__/server/app/setup/setup.controller.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/setup/setup.module.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/setup/templates/index.d.ts +4 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/{organizations → setup}/templates/organization-register/index.d.ts +3 -3
- package/dist/{esm/types/platforms/nest/__test__/server/app/organizations → cjs/types/platforms/nest/__test__/server/app/setup}/templates/organization-register/models.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/tenants/tenant.controller.d.ts +1 -7
- package/dist/cjs/types/platforms/nest/pipelines/builder/builder.d.ts +7 -0
- package/dist/cjs/types/platforms/nest/pipelines/builder/index.d.ts +2 -7
- package/dist/cjs/types/platforms/nest/pipelines/index.d.ts +3 -2
- package/dist/cjs/types/platforms/nest/pipelines/runner/index.d.ts +1 -11
- package/dist/cjs/types/platforms/nest/pipelines/runner/runner.d.ts +11 -0
- package/dist/cjs/types/platforms/nest/pipelines/template/index.d.ts +1 -22
- package/dist/cjs/types/platforms/nest/pipelines/template/template.d.ts +22 -0
- package/dist/esm/index.js +117 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/app/organizations/organization.controller.d.ts +1 -5
- package/dist/esm/types/platforms/nest/__test__/server/app/setup/setup.controller.d.ts +13 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/setup/setup.module.d.ts +2 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/setup/templates/index.d.ts +4 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/{organizations → setup}/templates/organization-register/index.d.ts +3 -3
- package/dist/{cjs/types/platforms/nest/__test__/server/app/organizations → esm/types/platforms/nest/__test__/server/app/setup}/templates/organization-register/models.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/tenants/tenant.controller.d.ts +1 -7
- package/dist/esm/types/platforms/nest/pipelines/builder/builder.d.ts +7 -0
- package/dist/esm/types/platforms/nest/pipelines/builder/index.d.ts +2 -7
- package/dist/esm/types/platforms/nest/pipelines/index.d.ts +3 -2
- package/dist/esm/types/platforms/nest/pipelines/runner/index.d.ts +1 -11
- package/dist/esm/types/platforms/nest/pipelines/runner/runner.d.ts +11 -0
- package/dist/esm/types/platforms/nest/pipelines/template/index.d.ts +1 -22
- package/dist/esm/types/platforms/nest/pipelines/template/template.d.ts +22 -0
- package/dist/index.d.ts +26 -1
- package/package.json +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/app/organizations/templates/index.d.ts +0 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/tenants/templates/index.d.ts +0 -3
- package/dist/cjs/types/platforms/nest/__test__/tests/pipelines/crud_pipeline_api.test.d.ts +0 -1
- package/dist/cjs/types/platforms/nest/__test__/tests/pipelines/crud_pipeline_template.test.d.ts +0 -1
- package/dist/esm/types/platforms/nest/__test__/server/app/organizations/templates/index.d.ts +0 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/tenants/templates/index.d.ts +0 -3
- package/dist/esm/types/platforms/nest/__test__/tests/pipelines/crud_pipeline_api.test.d.ts +0 -1
- package/dist/esm/types/platforms/nest/__test__/tests/pipelines/crud_pipeline_template.test.d.ts +0 -1
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/instance-initialize/index.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/instance-initialize/models.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{organizations/templates/organization-register → setup/templates/instance-initialize}/pipeline.test.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants/templates/instance-initialize → setup/templates/organization-register}/pipeline.test.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/index.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/models.d.ts +0 -0
- /package/dist/cjs/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/pipeline.test.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/instance-initialize/index.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/instance-initialize/models.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{organizations/templates/organization-register → setup/templates/instance-initialize}/pipeline.test.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants/templates/instance-initialize → setup/templates/organization-register}/pipeline.test.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/index.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/models.d.ts +0 -0
- /package/dist/esm/types/platforms/nest/__test__/server/app/{tenants → setup}/templates/tenant-initialize/pipeline.test.d.ts +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -20646,7 +20646,15 @@ exports.PipelinesRunner = __decorate([
|
|
|
20646
20646
|
const PipelineProviders = [exports.PipelinesBuilder, exports.PipelinesRunner];
|
|
20647
20647
|
|
|
20648
20648
|
// export const iocStorage = new AsyncLocalStorage<IocContext>()
|
|
20649
|
+
let _context;
|
|
20649
20650
|
const initializeIoCContext = (context) => {
|
|
20651
|
+
_context = context;
|
|
20652
|
+
};
|
|
20653
|
+
const getIoCContext = () => {
|
|
20654
|
+
if (!_context) {
|
|
20655
|
+
throw new Error("IoC context not initialized");
|
|
20656
|
+
}
|
|
20657
|
+
return _context;
|
|
20650
20658
|
};
|
|
20651
20659
|
|
|
20652
20660
|
exports.EntityManagerModule = class EntityManagerModule {
|
|
@@ -21194,6 +21202,114 @@ class AppExceptionsFilterBase {
|
|
|
21194
21202
|
}
|
|
21195
21203
|
}
|
|
21196
21204
|
|
|
21205
|
+
const buildCompletedStepsSequence = (step) => {
|
|
21206
|
+
const steps = [];
|
|
21207
|
+
let currentStep = step;
|
|
21208
|
+
while (currentStep) {
|
|
21209
|
+
steps.push(currentStep);
|
|
21210
|
+
currentStep = currentStep.previousStep;
|
|
21211
|
+
}
|
|
21212
|
+
return steps.reverse();
|
|
21213
|
+
};
|
|
21214
|
+
class PipelineUtils {
|
|
21215
|
+
constructor() {
|
|
21216
|
+
this.getStep = (step, index) => {
|
|
21217
|
+
const sequence = buildCompletedStepsSequence(step);
|
|
21218
|
+
if (index >= sequence.length) {
|
|
21219
|
+
throw new Error(`Step index ${index} is out of range`);
|
|
21220
|
+
}
|
|
21221
|
+
return sequence[index];
|
|
21222
|
+
};
|
|
21223
|
+
this.getStepInput = (step, index) => {
|
|
21224
|
+
return this.getStep(step, index).stepInput;
|
|
21225
|
+
};
|
|
21226
|
+
this.getStepOutput = (step, index) => {
|
|
21227
|
+
return this.getStep(step, index).stepOutput;
|
|
21228
|
+
};
|
|
21229
|
+
}
|
|
21230
|
+
}
|
|
21231
|
+
|
|
21232
|
+
class NestPipelineTemplate {
|
|
21233
|
+
constructor() {
|
|
21234
|
+
this.logger = backendCore.Log.getLogger(NestPipelineTemplate.name);
|
|
21235
|
+
this.utils = new PipelineUtils();
|
|
21236
|
+
}
|
|
21237
|
+
isAuthorized(context) {
|
|
21238
|
+
return true;
|
|
21239
|
+
}
|
|
21240
|
+
async invoke(input) {
|
|
21241
|
+
const result = await this.execute({
|
|
21242
|
+
input,
|
|
21243
|
+
context: await this.getContext(),
|
|
21244
|
+
});
|
|
21245
|
+
if (result.type !== "success") {
|
|
21246
|
+
throw new PipelineInvocationError(result.errorType, result.exception);
|
|
21247
|
+
}
|
|
21248
|
+
return result.output;
|
|
21249
|
+
}
|
|
21250
|
+
async execute(data) {
|
|
21251
|
+
const instanceId = backendCore.newUuid();
|
|
21252
|
+
const logMetadata = {
|
|
21253
|
+
input: data.input,
|
|
21254
|
+
context: data.context,
|
|
21255
|
+
instanceId,
|
|
21256
|
+
};
|
|
21257
|
+
this.logger.debug(`[START] | ${this.metadata.name}`, logMetadata);
|
|
21258
|
+
if (!this.isAuthorized(data.context)) {
|
|
21259
|
+
this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, logMetadata);
|
|
21260
|
+
return {
|
|
21261
|
+
type: "error",
|
|
21262
|
+
errorType: exports.PipelineErrorType.Unauthorized,
|
|
21263
|
+
input: data.input,
|
|
21264
|
+
stepResults: [],
|
|
21265
|
+
};
|
|
21266
|
+
}
|
|
21267
|
+
const instance = await this.controller.createInstance(this.getDefinition(), data.input, data.context);
|
|
21268
|
+
const result = await instance.execute();
|
|
21269
|
+
if (result.type === "error") {
|
|
21270
|
+
this.logger.error(`[ERROR] | ${this.metadata.name} -> ${result.exception?.name}`, {
|
|
21271
|
+
...logMetadata,
|
|
21272
|
+
result,
|
|
21273
|
+
});
|
|
21274
|
+
}
|
|
21275
|
+
else {
|
|
21276
|
+
this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, {
|
|
21277
|
+
...logMetadata,
|
|
21278
|
+
result,
|
|
21279
|
+
});
|
|
21280
|
+
}
|
|
21281
|
+
return result;
|
|
21282
|
+
}
|
|
21283
|
+
getDefinition() {
|
|
21284
|
+
if (!this.cachedDefinition) {
|
|
21285
|
+
this.cachedDefinition = this.buildDefinition();
|
|
21286
|
+
}
|
|
21287
|
+
return this.cachedDefinition;
|
|
21288
|
+
}
|
|
21289
|
+
buildDefinition() {
|
|
21290
|
+
return this.buildTemplate(new PipelineTemplateBuilder());
|
|
21291
|
+
}
|
|
21292
|
+
async getContext() {
|
|
21293
|
+
const contextService = this.registry
|
|
21294
|
+
.getContainer()
|
|
21295
|
+
.getEntitiesServicesLocator()
|
|
21296
|
+
.resolveAuthenticationContextProvider();
|
|
21297
|
+
return (await contextService?.getContext());
|
|
21298
|
+
}
|
|
21299
|
+
get controller() {
|
|
21300
|
+
return this.registry
|
|
21301
|
+
.getContainer()
|
|
21302
|
+
.getEntitiesServicesLocator()
|
|
21303
|
+
.resolvePipelinesController();
|
|
21304
|
+
}
|
|
21305
|
+
get registry() {
|
|
21306
|
+
return getIoCContext().registry;
|
|
21307
|
+
}
|
|
21308
|
+
get metadata() {
|
|
21309
|
+
return getInstanceDecoratorData(EntityManagerSymbols.PipelineTemplate, this);
|
|
21310
|
+
}
|
|
21311
|
+
}
|
|
21312
|
+
|
|
21197
21313
|
const AwsSesModuleSymbols = {
|
|
21198
21314
|
EmailTemplate: Symbol.for("WP.PLG:AWS_SES.EMAIL_TEMPLATE"),
|
|
21199
21315
|
};
|
|
@@ -26432,6 +26548,7 @@ exports.MultipleEntitiesFoundException = MultipleEntitiesFoundException;
|
|
|
26432
26548
|
exports.NestEntityActions = NestEntityActions;
|
|
26433
26549
|
exports.NestEntityAuthorizationMiddleware = NestEntityAuthorizationMiddleware;
|
|
26434
26550
|
exports.NestEntityManager = NestEntityManager;
|
|
26551
|
+
exports.NestPipelineTemplate = NestPipelineTemplate;
|
|
26435
26552
|
exports.NestTypeOrmEntitySeeder = NestTypeOrmEntitySeeder;
|
|
26436
26553
|
exports.NestTypeOrmQueryBuilder = NestTypeOrmQueryBuilder;
|
|
26437
26554
|
exports.NestTypeOrmRepository = NestTypeOrmRepository;
|