@tsed/formio 6.103.2 → 6.105.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/.nycrc CHANGED
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "check-coverage": true,
23
23
  "statements": 100,
24
- "branches": 81.16,
24
+ "branches": 80.43,
25
25
  "functions": 100,
26
26
  "lines": 100
27
27
  }
@@ -2,8 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlterActions = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
5
  const di_1 = require("@tsed/di");
6
+ const schema_1 = require("@tsed/schema");
7
+ const platform_params_1 = require("@tsed/platform-params");
8
+ const platform_response_filter_1 = require("@tsed/platform-response-filter");
9
+ const core_1 = require("@tsed/core");
10
+ const common_1 = require("@tsed/common");
7
11
  const alter_1 = require("../decorators/alter");
8
12
  const FormioService_1 = require("../services/FormioService");
9
13
  let AlterActions = class AlterActions {
@@ -13,7 +17,7 @@ let AlterActions = class AlterActions {
13
17
  var _a;
14
18
  const instance = this.injector.invoke(provider.token);
15
19
  const options = provider.store.get("formio:action");
16
- const resolveHandler = this.createResolveHandler(provider);
20
+ const resolveHandler = this.createHandler(provider, "resolve");
17
21
  return {
18
22
  ...actions,
19
23
  [options.name]: (_a = class extends Action {
@@ -39,17 +43,50 @@ let AlterActions = class AlterActions {
39
43
  getActions() {
40
44
  return this.injector.getProviders("formio:action");
41
45
  }
42
- createResolveHandler(provider) {
43
- const platformHandler = this.injector.get(common_1.PlatformHandler);
44
- const middleware = platformHandler.createCustomHandler(provider, "resolve");
45
- return (action, handler, method, req, res, next, setActionItemMessage) => {
46
- req.$ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
47
- req.$ctx.endpoint = common_1.EndpointMetadata.get(provider.useClass, "resolve");
48
- middleware(req.$ctx)
49
- .then(() => (req.$ctx.data ? platformHandler.flush(req.$ctx.data, req.$ctx) : next()))
50
- .catch(next);
46
+ createHandler(provider, propertyKey) {
47
+ const promisedHandler = this.params.compileHandler({
48
+ token: provider.token,
49
+ propertyKey
50
+ });
51
+ return async (action, handler, method, req, res, next, setActionItemMessage) => {
52
+ const $ctx = req.$ctx;
53
+ $ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
54
+ $ctx.endpoint = schema_1.EndpointMetadata.get(provider.useClass, "resolve");
55
+ await this.injector.runInContext($ctx, async () => {
56
+ try {
57
+ const resolver = new core_1.AnyToPromise();
58
+ const handler = await promisedHandler;
59
+ const { state, data, status, headers } = await resolver.call(() => handler({ $ctx }));
60
+ if (state === core_1.AnyToPromiseStatus.RESOLVED) {
61
+ if (status) {
62
+ $ctx.response.status(status);
63
+ }
64
+ if (headers) {
65
+ $ctx.response.setHeaders(headers);
66
+ }
67
+ if (data !== undefined) {
68
+ $ctx.data = data;
69
+ return await this.flush($ctx.data, $ctx);
70
+ }
71
+ next();
72
+ }
73
+ }
74
+ catch (er) {
75
+ next(er);
76
+ }
77
+ });
51
78
  };
52
79
  }
80
+ async flush(data, $ctx) {
81
+ const { response } = $ctx;
82
+ if (!response.isDone()) {
83
+ (0, common_1.setResponseHeaders)($ctx);
84
+ data = await this.responseFilter.serialize(data, $ctx);
85
+ data = await this.responseFilter.transform(data, $ctx);
86
+ response.body(data);
87
+ }
88
+ return response;
89
+ }
53
90
  };
54
91
  (0, tslib_1.__decorate)([
55
92
  (0, di_1.Inject)(),
@@ -59,6 +96,14 @@ let AlterActions = class AlterActions {
59
96
  (0, di_1.Inject)(),
60
97
  (0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
61
98
  ], AlterActions.prototype, "formio", void 0);
99
+ (0, tslib_1.__decorate)([
100
+ (0, di_1.Inject)(),
101
+ (0, tslib_1.__metadata)("design:type", platform_params_1.PlatformParams)
102
+ ], AlterActions.prototype, "params", void 0);
103
+ (0, tslib_1.__decorate)([
104
+ (0, di_1.Inject)(),
105
+ (0, tslib_1.__metadata)("design:type", platform_response_filter_1.PlatformResponseFilter)
106
+ ], AlterActions.prototype, "responseFilter", void 0);
62
107
  AlterActions = (0, tslib_1.__decorate)([
63
108
  (0, alter_1.Alter)("actions")
64
109
  ], AlterActions);
@@ -1 +1 @@
1
- {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,yCAAgF;AAChF,iCAA2D;AAE3D,+CAA0C;AAI1C,6DAAwD;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAOvB,SAAS,CAAC,OAAsB;QAC9B,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAmB,eAAe,CAAC,CAAC;YACtE,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAE3D,OAAO;gBACL,GAAG,OAAO;gBACV,CAAC,OAAO,CAAC,IAAI,CAAC,QAAE,KAAM,SAAQ,MAAM;wBAElC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAc;4BAClD,IAAI,IAAI,GAAG,EAAC,GAAG,OAAO,EAAC,CAAC;4BAExB,IAAI,QAAQ,CAAC,IAAI,EAAE;gCACjB,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;6BAC5C;4BAED,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBACnB,CAAC;wBAED,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GA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,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;iBACrF,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhEC;IADC,IAAA,WAAM,GAAE;2CACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;4CAAC;AALrB,YAAY;IADxB,IAAA,aAAK,EAAC,SAAS,CAAC;GACJ,YAAY,CAkExB;AAlEY,oCAAY","sourcesContent":["import {EndpointMetadata, PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createResolveHandler(provider);\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createResolveHandler(provider: Provider<any>) {\n const platformHandler = this.injector.get<PlatformHandler>(PlatformHandler)!;\n const middleware = platformHandler.createCustomHandler(provider, \"resolve\");\n\n return (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: Response,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n req.$ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n req.$ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n middleware(req.$ctx)\n .then(() => (req.$ctx.data ? platformHandler.flush(req.$ctx.data, req.$ctx) : next()))\n .catch(next);\n };\n }\n}\n"]}
1
+ {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,iCAA2D;AAC3D,yCAA8C;AAE9C,2DAAqD;AACrD,6EAAsE;AACtE,qCAA4D;AAC5D,yCAAiE;AACjE,+CAA0C;AAI1C,6DAAwD;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAavB,SAAS,CAAC,OAAsB;QAC9B,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAmB,eAAe,CAAC,CAAC;YACtE,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAE/D,OAAO;gBACL,GAAG,OAAO;gBACV,CAAC,OAAO,CAAC,IAAI,CAAC,QAAE,KAAM,SAAQ,MAAM;wBAGlC,MAAM,CAAC,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AC,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE;YACtB,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;YAEzB,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEvD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAhHC;IADC,IAAA,WAAM,GAAE;2CACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,WAAM,GAAE;2CACS,gCAAc;4CAAC;AAGjC;IADC,IAAA,WAAM,GAAE;2CACiB,iDAAsB;oDAAC;AAXtC,YAAY;IADxB,IAAA,aAAK,EAAC,SAAS,CAAC;GACJ,YAAY,CAkHxB;AAlHY,oCAAY","sourcesContent":["import {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected params: PlatformParams;\n\n @Inject()\n protected responseFilter: PlatformResponseFilter;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createHandler(provider, \"resolve\");\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createHandler(provider: Provider, propertyKey: string | symbol) {\n const promisedHandler = this.params.compileHandler({\n token: provider.token,\n propertyKey\n });\n\n return async (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = req.$ctx;\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n await this.injector.runInContext($ctx, async () => {\n try {\n const resolver = new AnyToPromise();\n const handler = await promisedHandler;\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n if (state === AnyToPromiseStatus.RESOLVED) {\n if (status) {\n $ctx.response.status(status);\n }\n\n if (headers) {\n $ctx.response.setHeaders(headers);\n }\n\n if (data !== undefined) {\n $ctx.data = data;\n\n return await this.flush($ctx.data, $ctx);\n }\n\n next();\n }\n } catch (er) {\n next(er);\n }\n });\n };\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!response.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx);\n data = await this.responseFilter.transform(data, $ctx);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,GAAoB;QACxD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AALY,UAAU;IADtB,IAAA,aAAK,EAAC,OAAO,CAAC;GACF,UAAU,CAKtB;AALY,gCAAU","sourcesContent":["import {PlatformContext} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"audit\")\nexport class AlterAudit implements AlterHook {\n transform(info: any[], event: string, ctx: PlatformContext): boolean {\n ctx.logger.info({event, info});\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,GAAc;QAClD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AALY,UAAU;IADtB,IAAA,aAAK,EAAC,OAAO,CAAC;GACF,UAAU,CAKtB;AALY,gCAAU","sourcesContent":["import {DIContext} from \"@tsed/di\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"audit\")\nexport class AlterAudit implements AlterHook {\n transform(info: any[], event: string, ctx: DIContext): boolean {\n ctx.logger.info({event, info});\n return false;\n }\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -44,6 +44,7 @@ const tslib_1 = require("tslib");
44
44
  (0, tslib_1.__exportStar)(require("./services/FormioDatabase"), exports);
45
45
  (0, tslib_1.__exportStar)(require("./services/FormioHooksService"), exports);
46
46
  (0, tslib_1.__exportStar)(require("./services/FormioInstaller"), exports);
47
+ (0, tslib_1.__exportStar)(require("./services/FormioRepository"), exports);
47
48
  (0, tslib_1.__exportStar)(require("./services/FormioService"), exports);
48
49
  (0, tslib_1.__exportStar)(require("./utils/isMongoId"), exports);
49
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8DAA+B;AAC/B,sEAAuC;AACvC,yEAA0C;AAC1C,uEAAwC;AACxC,sEAAuC;AACvC,qEAAsC;AACtC,sEAAuC;AACvC,qFAAsD;AACtD,qFAAsD;AACtD,mEAAoC;AACpC,sEAAuC;AACvC,kEAAmC;AACnC,+DAAgC;AAChC,0EAA2C;AAC3C,kEAAmC;AACnC,+DAAgC;AAChC,qEAAsC;AACtC,2EAA4C;AAC5C,mEAAoC;AACpC,wEAAyC;AACzC,qEAAsC;AACtC,wEAAyC;AACzC,2EAA4C;AAC5C,qEAAsC;AACtC,oEAAqC;AACrC,iEAAkC;AAClC,qEAAsC;AACtC,qEAAsC;AACtC,uEAAwC;AACxC,uEAAwC;AACxC,2EAA4C;AAC5C,qEAAsC;AACtC,oEAAqC;AACrC,+DAAgC;AAChC,iEAAkC;AAClC,kFAAmD;AACnD,4EAA6C;AAC7C,yEAA0C;AAC1C,6EAA8C;AAC9C,0EAA2C;AAC3C,wEAAyC;AACzC,iEAAkC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterSkip\";\nexport * from \"./components/AlterTemplateExportSteps\";\nexport * from \"./components/AlterTemplateImportSteps\";\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/OnHook\";\nexport * from \"./domain/Resource\";\nexport * from \"./middlewares/FormioAuthMiddleware\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./services/FormioInstaller\";\nexport * from \"./services/FormioService\";\nexport * from \"./utils/isMongoId\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8DAA+B;AAC/B,sEAAuC;AACvC,yEAA0C;AAC1C,uEAAwC;AACxC,sEAAuC;AACvC,qEAAsC;AACtC,sEAAuC;AACvC,qFAAsD;AACtD,qFAAsD;AACtD,mEAAoC;AACpC,sEAAuC;AACvC,kEAAmC;AACnC,+DAAgC;AAChC,0EAA2C;AAC3C,kEAAmC;AACnC,+DAAgC;AAChC,qEAAsC;AACtC,2EAA4C;AAC5C,mEAAoC;AACpC,wEAAyC;AACzC,qEAAsC;AACtC,wEAAyC;AACzC,2EAA4C;AAC5C,qEAAsC;AACtC,oEAAqC;AACrC,iEAAkC;AAClC,qEAAsC;AACtC,qEAAsC;AACtC,uEAAwC;AACxC,uEAAwC;AACxC,2EAA4C;AAC5C,qEAAsC;AACtC,oEAAqC;AACrC,+DAAgC;AAChC,iEAAkC;AAClC,kFAAmD;AACnD,4EAA6C;AAC7C,yEAA0C;AAC1C,6EAA8C;AAC9C,0EAA2C;AAC3C,2EAA4C;AAC5C,wEAAyC;AACzC,iEAAkC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterSkip\";\nexport * from \"./components/AlterTemplateExportSteps\";\nexport * from \"./components/AlterTemplateImportSteps\";\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/OnHook\";\nexport * from \"./domain/Resource\";\nexport * from \"./middlewares/FormioAuthMiddleware\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./services/FormioInstaller\";\nexport * from \"./services/FormioRepository\";\nexport * from \"./services/FormioService\";\nexport * from \"./utils/isMongoId\";\n"]}
@@ -4,6 +4,7 @@ exports.FormioDatabase = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@tsed/core");
6
6
  const di_1 = require("@tsed/di");
7
+ const omit_1 = (0, tslib_1.__importDefault)(require("lodash/omit"));
7
8
  const FormioMapper_1 = require("../builder/FormioMapper");
8
9
  const isMongoId_1 = require("../utils/isMongoId");
9
10
  const FormioService_1 = require("./FormioService");
@@ -69,18 +70,52 @@ let FormioDatabase = class FormioDatabase {
69
70
  .lean()
70
71
  .exec();
71
72
  }
72
- async createFormIfNotExists(form, onCreate) {
73
+ /**
74
+ * Import form previously exported by export tool.
75
+ * This method transform alias to a real mongoose _id
76
+ * @param form
77
+ * @param onCreate
78
+ */
79
+ async importFormIfNotExists(form, onCreate) {
73
80
  if (!(await this.hasForm(form.name))) {
74
- const createForm = await this.saveFormDefinition(form);
81
+ const createForm = await this.importForm(form);
75
82
  onCreate && (await onCreate(createForm));
76
83
  }
77
84
  return this.getForm(form.name);
78
85
  }
79
- async saveFormDefinition(form) {
86
+ /**
87
+ * Import form previously exported by export tool.
88
+ * This method transform alias to a real mongoose _id
89
+ * @param form
90
+ */
91
+ async importForm(form) {
80
92
  const mapper = await this.getFormioMapper();
81
- const instance = new this.formModel(mapper.mapToImport(form));
82
- await this.formModel.updateOne({ _id: instance._id }, { $set: instance }, { upsert: true });
83
- return instance;
93
+ return this.saveForm(mapper.mapToImport(form));
94
+ }
95
+ async saveForm(form) {
96
+ form = (0, omit_1.default)(form, ["__v"]);
97
+ return this.formModel.findOneAndUpdate({ _id: form._id }, form, { upsert: true, new: true });
98
+ }
99
+ async getSubmissions(query = {}) {
100
+ return this.submissionModel.find({
101
+ ...query,
102
+ deleted: { $eq: null }
103
+ });
104
+ }
105
+ /**
106
+ * Import submission previously exported by export tool.
107
+ * This method transform alias to a real mongoose _id
108
+ * @param submission
109
+ */
110
+ async importSubmission(submission) {
111
+ const mapper = await this.getFormioMapper();
112
+ return this.saveSubmission(mapper.mapToImport(submission));
113
+ }
114
+ async saveSubmission(submission) {
115
+ submission = (0, omit_1.default)(submission, ["__v"]);
116
+ return this.submissionModel.findOneAndUpdate({
117
+ _id: submission._id
118
+ }, submission, { new: true, upsert: true });
84
119
  }
85
120
  idToBson(form) {
86
121
  if ((0, core_1.isArray)(form)) {
@@ -1 +1 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAG5C,0DAAqD;AACrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAA,YAAI,EAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5H,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC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,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;SACnD;aAAM,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AApGC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;8CAAC;AAFrB,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAsG1B;AAtGY,wCAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n async createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.saveFormDefinition(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n async saveFormDefinition(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n const instance = new this.formModel(mapper.mapToImport(form));\n\n await this.formModel.updateOne({_id: instance._id}, {$set: instance}, {upsert: true});\n\n return instance;\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAG5C,oEAA+B;AAE/B,0DAAqD;AACrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAA,YAAI,EAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,E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I,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;YACjB,OAAO,EAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;SACnD;aAAM,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAlJC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;8CAAC;AAFrB,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAoJ1B;AApJY,wCAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport type {FilterQuery} from \"mongoose\";\nimport omit from \"lodash/omit\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n * @param onCreate\n */\n async importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.importForm(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n */\n async importForm(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return this.saveForm(mapper.mapToImport(form));\n }\n\n async saveForm(form: FormioForm) {\n form = omit(form, [\"__v\"]) as any;\n\n return this.formModel.findOneAndUpdate({_id: form._id}, form, {upsert: true, new: true});\n }\n\n async getSubmissions<Data>(\n query: FilterQuery<MongooseModel<FormioSubmission<Data>>> = {}\n ): Promise<MongooseDocument<FormioSubmission<Data>>[]> {\n return this.submissionModel.find({\n ...query,\n deleted: {$eq: null}\n }) as any;\n }\n\n /**\n * Import submission previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param submission\n */\n async importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, \"form\"> & {form?: any}) {\n const mapper = await this.getFormioMapper();\n\n return this.saveSubmission(mapper.mapToImport(submission));\n }\n\n async saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>) {\n submission = omit(submission, [\"__v\"]);\n\n return this.submissionModel.findOneAndUpdate(\n {\n _id: submission._id\n },\n submission,\n {new: true, upsert: true}\n );\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormioRepository = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const FormioDatabase_1 = require("./FormioDatabase");
7
+ class FormioRepository {
8
+ async getFormId() {
9
+ if (!this.formId) {
10
+ const form = await this.formioDatabase.formModel.findOne({ name: { $eq: this.formName } });
11
+ if (form) {
12
+ this.formId = form._id;
13
+ }
14
+ }
15
+ return this.formId;
16
+ }
17
+ async saveSubmission(submission) {
18
+ return this.formioDatabase.saveSubmission({
19
+ ...submission,
20
+ form: submission.form || (await this.getFormId())
21
+ });
22
+ }
23
+ async getSubmissions(query = {}) {
24
+ return this.formioDatabase.getSubmissions({
25
+ ...query,
26
+ form: await this.getFormId()
27
+ });
28
+ }
29
+ async findOneSubmission(query) {
30
+ return this.formioDatabase.submissionModel.findOne({
31
+ form: await this.getFormId(),
32
+ deleted: null,
33
+ ...query
34
+ });
35
+ }
36
+ }
37
+ (0, tslib_1.__decorate)([
38
+ (0, di_1.Inject)(),
39
+ (0, tslib_1.__metadata)("design:type", FormioDatabase_1.FormioDatabase)
40
+ ], FormioRepository.prototype, "formioDatabase", void 0);
41
+ exports.FormioRepository = FormioRepository;
42
+ //# sourceMappingURL=FormioRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/FormioRepository.ts"],"names":[],"mappings":";;;;AACA,iCAAgC;AAGhC,qDAAgD;AAEhD,MAAsB,gBAAgB;IAQpC,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;YAEvF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;aACxB;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkF;QACrG,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAAsE,EAAE;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,KAAK;YACR,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAU;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO,EAAE,IAAI;YACb,GAAG,KAAK;SACT,CAAQ,CAAC;IACZ,CAAC;CACF;AAvCC;IADC,IAAA,WAAM,GAAE;2CACiB,+BAAc;wDAAC;AAF3C,4CAyCC","sourcesContent":["import type {FilterQuery} from \"mongoose\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\n\nexport abstract class FormioRepository<SubmissionData = any> {\n @Inject()\n protected formioDatabase: FormioDatabase;\n\n protected abstract formName: string;\n\n private formId: string;\n\n async getFormId() {\n if (!this.formId) {\n const form = await this.formioDatabase.formModel.findOne({name: {$eq: this.formName}});\n\n if (form) {\n this.formId = form._id;\n }\n }\n\n return this.formId;\n }\n\n async saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, \"form\"> & {form?: any}) {\n return this.formioDatabase.saveSubmission<SubmissionData>({\n ...submission,\n form: submission.form || (await this.getFormId())\n });\n }\n\n async getSubmissions(query: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>> = {}) {\n return this.formioDatabase.getSubmissions<SubmissionData>({\n ...query,\n form: await this.getFormId()\n });\n }\n\n async findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined> {\n return this.formioDatabase.submissionModel.findOne({\n form: await this.getFormId(),\n deleted: null,\n ...query\n }) as any;\n }\n}\n"]}
@@ -1,6 +1,10 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { EndpointMetadata, PlatformHandler } from "@tsed/common";
3
2
  import { Inject, InjectorService } from "@tsed/di";
3
+ import { EndpointMetadata } from "@tsed/schema";
4
+ import { PlatformParams } from "@tsed/platform-params";
5
+ import { PlatformResponseFilter } from "@tsed/platform-response-filter";
6
+ import { AnyToPromise, AnyToPromiseStatus } from "@tsed/core";
7
+ import { setResponseHeaders } from "@tsed/common";
4
8
  import { Alter } from "../decorators/alter.js";
5
9
  import { FormioService } from "../services/FormioService.js";
6
10
  let AlterActions = class AlterActions {
@@ -10,7 +14,7 @@ let AlterActions = class AlterActions {
10
14
  var _a;
11
15
  const instance = this.injector.invoke(provider.token);
12
16
  const options = provider.store.get("formio:action");
13
- const resolveHandler = this.createResolveHandler(provider);
17
+ const resolveHandler = this.createHandler(provider, "resolve");
14
18
  return {
15
19
  ...actions,
16
20
  [options.name]: (_a = class extends Action {
@@ -36,17 +40,50 @@ let AlterActions = class AlterActions {
36
40
  getActions() {
37
41
  return this.injector.getProviders("formio:action");
38
42
  }
39
- createResolveHandler(provider) {
40
- const platformHandler = this.injector.get(PlatformHandler);
41
- const middleware = platformHandler.createCustomHandler(provider, "resolve");
42
- return (action, handler, method, req, res, next, setActionItemMessage) => {
43
- req.$ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
44
- req.$ctx.endpoint = EndpointMetadata.get(provider.useClass, "resolve");
45
- middleware(req.$ctx)
46
- .then(() => (req.$ctx.data ? platformHandler.flush(req.$ctx.data, req.$ctx) : next()))
47
- .catch(next);
43
+ createHandler(provider, propertyKey) {
44
+ const promisedHandler = this.params.compileHandler({
45
+ token: provider.token,
46
+ propertyKey
47
+ });
48
+ return async (action, handler, method, req, res, next, setActionItemMessage) => {
49
+ const $ctx = req.$ctx;
50
+ $ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
51
+ $ctx.endpoint = EndpointMetadata.get(provider.useClass, "resolve");
52
+ await this.injector.runInContext($ctx, async () => {
53
+ try {
54
+ const resolver = new AnyToPromise();
55
+ const handler = await promisedHandler;
56
+ const { state, data, status, headers } = await resolver.call(() => handler({ $ctx }));
57
+ if (state === AnyToPromiseStatus.RESOLVED) {
58
+ if (status) {
59
+ $ctx.response.status(status);
60
+ }
61
+ if (headers) {
62
+ $ctx.response.setHeaders(headers);
63
+ }
64
+ if (data !== undefined) {
65
+ $ctx.data = data;
66
+ return await this.flush($ctx.data, $ctx);
67
+ }
68
+ next();
69
+ }
70
+ }
71
+ catch (er) {
72
+ next(er);
73
+ }
74
+ });
48
75
  };
49
76
  }
77
+ async flush(data, $ctx) {
78
+ const { response } = $ctx;
79
+ if (!response.isDone()) {
80
+ setResponseHeaders($ctx);
81
+ data = await this.responseFilter.serialize(data, $ctx);
82
+ data = await this.responseFilter.transform(data, $ctx);
83
+ response.body(data);
84
+ }
85
+ return response;
86
+ }
50
87
  };
51
88
  __decorate([
52
89
  Inject(),
@@ -56,6 +93,14 @@ __decorate([
56
93
  Inject(),
57
94
  __metadata("design:type", FormioService)
58
95
  ], AlterActions.prototype, "formio", void 0);
96
+ __decorate([
97
+ Inject(),
98
+ __metadata("design:type", PlatformParams)
99
+ ], AlterActions.prototype, "params", void 0);
100
+ __decorate([
101
+ Inject(),
102
+ __metadata("design:type", PlatformResponseFilter)
103
+ ], AlterActions.prototype, "responseFilter", void 0);
59
104
  AlterActions = __decorate([
60
105
  Alter("actions")
61
106
  ], AlterActions);
@@ -1 +1 @@
1
- {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,gBAAgB,EAAmB,eAAe,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,MAAM,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAOvB,SAAS,CAAC,OAAsB;QAC9B,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAmB,eAAe,CAAC,CAAC;YACtE,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,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE5E,OAAO,CACL,MAAW,EACX,OAAe,EACf,MAAc,EACd,GAA4B,EAC5B,GAAa,EACb,IAAS,EACT,oBAA0C,EAC1C,EAAE;YACF,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAC,CAAC,CAAC;YAC5E,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAEvE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;iBACjB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;iBACrF,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhEC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AALrB,YAAY;IADxB,KAAK,CAAC,SAAS,CAAC;GACJ,YAAY,CAkExB;SAlEY,YAAY","sourcesContent":["import {EndpointMetadata, PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createResolveHandler(provider);\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createResolveHandler(provider: Provider<any>) {\n const platformHandler = this.injector.get<PlatformHandler>(PlatformHandler)!;\n const middleware = platformHandler.createCustomHandler(provider, \"resolve\");\n\n return (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: Response,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n req.$ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n req.$ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n middleware(req.$ctx)\n .then(() => (req.$ctx.data ? platformHandler.flush(req.$ctx.data, req.$ctx) : next()))\n .catch(next);\n };\n }\n}\n"]}
1
+ {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,sBAAsB,EAAC,MAAM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EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AAGhC;IADC,MAAM,EAAE;8BACS,cAAc;4CAAC;AAGjC;IADC,MAAM,EAAE;8BACiB,sBAAsB;oDAAC;AAXtC,YAAY;IADxB,KAAK,CAAC,SAAS,CAAC;GACJ,YAAY,CAkHxB;SAlHY,YAAY","sourcesContent":["import {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected params: PlatformParams;\n\n @Inject()\n protected responseFilter: PlatformResponseFilter;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createHandler(provider, \"resolve\");\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createHandler(provider: Provider, propertyKey: string | symbol) {\n const promisedHandler = this.params.compileHandler({\n token: provider.token,\n propertyKey\n });\n\n return async (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = req.$ctx;\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n await this.injector.runInContext($ctx, async () => {\n try {\n const resolver = new AnyToPromise();\n const handler = await promisedHandler;\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n if (state === AnyToPromiseStatus.RESOLVED) {\n if (status) {\n $ctx.response.status(status);\n }\n\n if (headers) {\n $ctx.response.setHeaders(headers);\n }\n\n if (data !== undefined) {\n $ctx.data = data;\n\n return await this.flush($ctx.data, $ctx);\n }\n\n next();\n }\n } catch (er) {\n next(er);\n }\n });\n };\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!response.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx);\n data = await this.responseFilter.transform(data, $ctx);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,GAAoB;QACxD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AALY,UAAU;IADtB,KAAK,CAAC,OAAO,CAAC;GACF,UAAU,CAKtB;SALY,UAAU","sourcesContent":["import {PlatformContext} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"audit\")\nexport class AlterAudit implements AlterHook {\n transform(info: any[], event: string, ctx: PlatformContext): boolean {\n ctx.logger.info({event, info});\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,GAAc;QAClD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AALY,UAAU;IADtB,KAAK,CAAC,OAAO,CAAC;GACF,UAAU,CAKtB;SALY,UAAU","sourcesContent":["import {DIContext} from \"@tsed/di\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"audit\")\nexport class AlterAudit implements AlterHook {\n transform(info: any[], event: string, ctx: DIContext): boolean {\n ctx.logger.info({event, info});\n return false;\n }\n}\n"]}
package/lib/esm/index.js CHANGED
@@ -41,6 +41,7 @@ export * from "./services/FormioAuthService.js";
41
41
  export * from "./services/FormioDatabase.js";
42
42
  export * from "./services/FormioHooksService.js";
43
43
  export * from "./services/FormioInstaller.js";
44
+ export * from "./services/FormioRepository.js";
44
45
  export * from "./services/FormioService.js";
45
46
  export * from "./utils/isMongoId.js";
46
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterSkip\";\nexport * from \"./components/AlterTemplateExportSteps\";\nexport * from \"./components/AlterTemplateImportSteps\";\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/OnHook\";\nexport * from \"./domain/Resource\";\nexport * from \"./middlewares/FormioAuthMiddleware\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./services/FormioInstaller\";\nexport * from \"./services/FormioService\";\nexport * from \"./utils/isMongoId\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterSkip\";\nexport * from \"./components/AlterTemplateExportSteps\";\nexport * from \"./components/AlterTemplateImportSteps\";\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/OnHook\";\nexport * from \"./domain/Resource\";\nexport * from \"./middlewares/FormioAuthMiddleware\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./services/FormioInstaller\";\nexport * from \"./services/FormioRepository\";\nexport * from \"./services/FormioService\";\nexport * from \"./utils/isMongoId\";\n"]}
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { isArray, isObject, isString, toMap as tMap } from "@tsed/core";
3
3
  import { Inject, Injectable } from "@tsed/di";
4
+ import omit from "lodash/omit";
4
5
  import { FormioMapper } from "../builder/FormioMapper.js";
5
6
  import { isMongoId } from "../utils/isMongoId.js";
6
7
  import { FormioService } from "./FormioService.js";
@@ -66,18 +67,52 @@ let FormioDatabase = class FormioDatabase {
66
67
  .lean()
67
68
  .exec();
68
69
  }
69
- async createFormIfNotExists(form, onCreate) {
70
+ /**
71
+ * Import form previously exported by export tool.
72
+ * This method transform alias to a real mongoose _id
73
+ * @param form
74
+ * @param onCreate
75
+ */
76
+ async importFormIfNotExists(form, onCreate) {
70
77
  if (!(await this.hasForm(form.name))) {
71
- const createForm = await this.saveFormDefinition(form);
78
+ const createForm = await this.importForm(form);
72
79
  onCreate && (await onCreate(createForm));
73
80
  }
74
81
  return this.getForm(form.name);
75
82
  }
76
- async saveFormDefinition(form) {
83
+ /**
84
+ * Import form previously exported by export tool.
85
+ * This method transform alias to a real mongoose _id
86
+ * @param form
87
+ */
88
+ async importForm(form) {
77
89
  const mapper = await this.getFormioMapper();
78
- const instance = new this.formModel(mapper.mapToImport(form));
79
- await this.formModel.updateOne({ _id: instance._id }, { $set: instance }, { upsert: true });
80
- return instance;
90
+ return this.saveForm(mapper.mapToImport(form));
91
+ }
92
+ async saveForm(form) {
93
+ form = omit(form, ["__v"]);
94
+ return this.formModel.findOneAndUpdate({ _id: form._id }, form, { upsert: true, new: true });
95
+ }
96
+ async getSubmissions(query = {}) {
97
+ return this.submissionModel.find({
98
+ ...query,
99
+ deleted: { $eq: null }
100
+ });
101
+ }
102
+ /**
103
+ * Import submission previously exported by export tool.
104
+ * This method transform alias to a real mongoose _id
105
+ * @param submission
106
+ */
107
+ async importSubmission(submission) {
108
+ const mapper = await this.getFormioMapper();
109
+ return this.saveSubmission(mapper.mapToImport(submission));
110
+ }
111
+ async saveSubmission(submission) {
112
+ submission = omit(submission, ["__v"]);
113
+ return this.submissionModel.findOneAndUpdate({
114
+ _id: submission._id
115
+ }, submission, { new: true, upsert: true });
81
116
  }
82
117
  idToBson(form) {
83
118
  if (isArray(form)) {
@@ -1 +1 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,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MongooseModel} from \"@tsed/mongoose\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n async createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.saveFormDefinition(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n async saveFormDefinition(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n const instance = new this.formModel(mapper.mapToImport(form));\n\n await this.formModel.updateOne({_id: instance._id}, {$set: instance}, {upsert: true});\n\n return instance;\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5H,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CA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AAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAlJC;IADC,MAAM,EAAE;8BACS,aAAa;8CAAC;AAFrB,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAoJ1B;SApJY,cAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport type {FilterQuery} from \"mongoose\";\nimport omit from \"lodash/omit\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n * @param onCreate\n */\n async importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.importForm(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n */\n async importForm(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return this.saveForm(mapper.mapToImport(form));\n }\n\n async saveForm(form: FormioForm) {\n form = omit(form, [\"__v\"]) as any;\n\n return this.formModel.findOneAndUpdate({_id: form._id}, form, {upsert: true, new: true});\n }\n\n async getSubmissions<Data>(\n query: FilterQuery<MongooseModel<FormioSubmission<Data>>> = {}\n ): Promise<MongooseDocument<FormioSubmission<Data>>[]> {\n return this.submissionModel.find({\n ...query,\n deleted: {$eq: null}\n }) as any;\n }\n\n /**\n * Import submission previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param submission\n */\n async importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, \"form\"> & {form?: any}) {\n const mapper = await this.getFormioMapper();\n\n return this.saveSubmission(mapper.mapToImport(submission));\n }\n\n async saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>) {\n submission = omit(submission, [\"__v\"]);\n\n return this.submissionModel.findOneAndUpdate(\n {\n _id: submission._id\n },\n submission,\n {new: true, upsert: true}\n );\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject } from "@tsed/di";
3
+ import { FormioDatabase } from "./FormioDatabase.js";
4
+ export class FormioRepository {
5
+ async getFormId() {
6
+ if (!this.formId) {
7
+ const form = await this.formioDatabase.formModel.findOne({ name: { $eq: this.formName } });
8
+ if (form) {
9
+ this.formId = form._id;
10
+ }
11
+ }
12
+ return this.formId;
13
+ }
14
+ async saveSubmission(submission) {
15
+ return this.formioDatabase.saveSubmission({
16
+ ...submission,
17
+ form: submission.form || (await this.getFormId())
18
+ });
19
+ }
20
+ async getSubmissions(query = {}) {
21
+ return this.formioDatabase.getSubmissions({
22
+ ...query,
23
+ form: await this.getFormId()
24
+ });
25
+ }
26
+ async findOneSubmission(query) {
27
+ return this.formioDatabase.submissionModel.findOne({
28
+ form: await this.getFormId(),
29
+ deleted: null,
30
+ ...query
31
+ });
32
+ }
33
+ }
34
+ __decorate([
35
+ Inject(),
36
+ __metadata("design:type", FormioDatabase)
37
+ ], FormioRepository.prototype, "formioDatabase", void 0);
38
+ //# sourceMappingURL=FormioRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/FormioRepository.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,OAAgB,gBAAgB;IAQpC,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;YAEvF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;aACxB;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkF;QACrG,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAAsE,EAAE;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,KAAK;YACR,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAU;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO,EAAE,IAAI;YACb,GAAG,KAAK;SACT,CAAQ,CAAC;IACZ,CAAC;CACF;AAvCC;IADC,MAAM,EAAE;8BACiB,cAAc;wDAAC","sourcesContent":["import type {FilterQuery} from \"mongoose\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\n\nexport abstract class FormioRepository<SubmissionData = any> {\n @Inject()\n protected formioDatabase: FormioDatabase;\n\n protected abstract formName: string;\n\n private formId: string;\n\n async getFormId() {\n if (!this.formId) {\n const form = await this.formioDatabase.formModel.findOne({name: {$eq: this.formName}});\n\n if (form) {\n this.formId = form._id;\n }\n }\n\n return this.formId;\n }\n\n async saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, \"form\"> & {form?: any}) {\n return this.formioDatabase.saveSubmission<SubmissionData>({\n ...submission,\n form: submission.form || (await this.getFormId())\n });\n }\n\n async getSubmissions(query: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>> = {}) {\n return this.formioDatabase.getSubmissions<SubmissionData>({\n ...query,\n form: await this.getFormId()\n });\n }\n\n async findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined> {\n return this.formioDatabase.submissionModel.findOne({\n form: await this.getFormId(),\n deleted: null,\n ...query\n }) as any;\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
- import { PlatformContext } from "@tsed/common";
2
1
  import { InjectorService, Provider } from "@tsed/di";
2
+ import { PlatformParams } from "@tsed/platform-params";
3
+ import { PlatformResponseFilter } from "@tsed/platform-response-filter";
4
+ import { PlatformContext } from "@tsed/common";
3
5
  import { AlterHook } from "../domain/AlterHook";
4
6
  import { SetActionItemMessage } from "../domain/FormioAction";
5
7
  import { FormioActions } from "../domain/FormioActionsIndex";
@@ -7,9 +9,12 @@ import { FormioService } from "../services/FormioService";
7
9
  export declare class AlterActions implements AlterHook {
8
10
  protected injector: InjectorService;
9
11
  protected formio: FormioService;
12
+ protected params: PlatformParams;
13
+ protected responseFilter: PlatformResponseFilter;
10
14
  transform(actions: FormioActions): FormioActions;
11
15
  protected getActions(): Provider<any>[];
12
- protected createResolveHandler(provider: Provider<any>): (action: any, handler: string, method: string, req: {
16
+ protected createHandler(provider: Provider, propertyKey: string | symbol): (action: any, handler: string, method: string, req: {
13
17
  $ctx: PlatformContext;
14
- }, res: Response, next: any, setActionItemMessage: SetActionItemMessage) => void;
18
+ }, res: any, next: any, setActionItemMessage: SetActionItemMessage) => Promise<void>;
19
+ private flush;
15
20
  }
@@ -1,5 +1,5 @@
1
- import { PlatformContext } from "@tsed/common";
1
+ import { DIContext } from "@tsed/di";
2
2
  import { AlterHook } from "../domain/AlterHook";
3
3
  export declare class AlterAudit implements AlterHook {
4
- transform(info: any[], event: string, ctx: PlatformContext): boolean;
4
+ transform(info: any[], event: string, ctx: DIContext): boolean;
5
5
  }
@@ -41,5 +41,6 @@ export * from "./services/FormioAuthService";
41
41
  export * from "./services/FormioDatabase";
42
42
  export * from "./services/FormioHooksService";
43
43
  export * from "./services/FormioInstaller";
44
+ export * from "./services/FormioRepository";
44
45
  export * from "./services/FormioService";
45
46
  export * from "./utils/isMongoId";
@@ -1,5 +1,5 @@
1
- /// <reference types="mongoose" />
2
- import { MongooseModel } from "@tsed/mongoose";
1
+ import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
2
+ import type { FilterQuery } from "mongoose";
3
3
  import { FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "@tsed/formio-types";
4
4
  import { FormioMapper } from "../builder/FormioMapper";
5
5
  import { FormioService } from "./FormioService";
@@ -18,7 +18,29 @@ export declare class FormioDatabase {
18
18
  hasForms(): Promise<boolean>;
19
19
  hasForm(name: string): Promise<boolean>;
20
20
  getForm(nameOrId: string): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>> | null>;
21
- createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>> | null>;
22
- saveFormDefinition(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>>;
21
+ /**
22
+ * Import form previously exported by export tool.
23
+ * This method transform alias to a real mongoose _id
24
+ * @param form
25
+ * @param onCreate
26
+ */
27
+ importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>> | null>;
28
+ /**
29
+ * Import form previously exported by export tool.
30
+ * This method transform alias to a real mongoose _id
31
+ * @param form
32
+ */
33
+ importForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>>;
34
+ saveForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>>>;
35
+ getSubmissions<Data>(query?: FilterQuery<MongooseModel<FormioSubmission<Data>>>): Promise<MongooseDocument<FormioSubmission<Data>>[]>;
36
+ /**
37
+ * Import submission previously exported by export tool.
38
+ * This method transform alias to a real mongoose _id
39
+ * @param submission
40
+ */
41
+ importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, "form"> & {
42
+ form?: any;
43
+ }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
44
+ saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
23
45
  idToBson(form?: any): any;
24
46
  }
@@ -0,0 +1,15 @@
1
+ import type { FilterQuery } from "mongoose";
2
+ import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
3
+ import { FormioSubmission } from "../domain/FormioModels";
4
+ import { FormioDatabase } from "./FormioDatabase";
5
+ export declare abstract class FormioRepository<SubmissionData = any> {
6
+ protected formioDatabase: FormioDatabase;
7
+ protected abstract formName: string;
8
+ private formId;
9
+ getFormId(): Promise<string>;
10
+ saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, "form"> & {
11
+ form?: any;
12
+ }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
13
+ getSubmissions(query?: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>>): Promise<MongooseDocument<FormioSubmission<SubmissionData>>[]>;
14
+ findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined>;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/formio",
3
- "version": "6.103.2",
3
+ "version": "6.105.0",
4
4
  "description": "Formio package for Ts.ED framework",
5
5
  "private": false,
6
6
  "keywords": [
@@ -30,14 +30,14 @@
30
30
  "test": "cross-env NODE_ENV=test nyc mocha"
31
31
  },
32
32
  "dependencies": {
33
- "@tsed/formio-types": "6.103.2",
33
+ "@tsed/formio-types": "6.105.0",
34
34
  "tslib": "2.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@tsed/common": "6.103.2",
38
- "@tsed/core": "6.103.2",
39
- "@tsed/di": "6.103.2",
40
- "@tsed/mongoose": "6.103.2",
37
+ "@tsed/common": "6.105.0",
38
+ "@tsed/core": "6.105.0",
39
+ "@tsed/di": "6.105.0",
40
+ "@tsed/mongoose": "6.105.0",
41
41
  "@types/async": "3.2.12",
42
42
  "express": "^4.17.1",
43
43
  "formio": "^2.0.0",
@@ -45,12 +45,13 @@
45
45
  "mongoose": "^5.12.2"
46
46
  },
47
47
  "peerDependencies": {
48
- "@tsed/common": "^6.103.2",
49
- "@tsed/core": "^6.103.2",
50
- "@tsed/di": "^6.103.2",
51
- "@tsed/mongoose": "^6.103.2",
48
+ "@tsed/common": "^6.105.0",
49
+ "@tsed/core": "^6.105.0",
50
+ "@tsed/di": "^6.105.0",
51
+ "@tsed/mongoose": "^6.105.0",
52
52
  "express": "^4.17.1",
53
53
  "formio": "^2.0.0",
54
+ "lodash": "^4.17.21",
54
55
  "mongodb": "*",
55
56
  "mongoose": "^5.12.2"
56
57
  },