@tsed/formio 7.0.0-beta.15 → 7.0.0-beta.18

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.
@@ -51,7 +51,7 @@ let AlterActions = class AlterActions {
51
51
  propertyKey
52
52
  });
53
53
  return async (action, handler, method, req, res, next, setActionItemMessage) => {
54
- const $ctx = (0, di_1.getContext)();
54
+ const { $ctx } = req;
55
55
  if ($ctx) {
56
56
  $ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
57
57
  $ctx.endpoint = schema_1.EndpointMetadata.get(provider.useClass, "resolve");
@@ -85,7 +85,7 @@ let AlterActions = class AlterActions {
85
85
  }
86
86
  async flush(data, $ctx) {
87
87
  const { response } = $ctx;
88
- if (!response.isDone()) {
88
+ if (!$ctx.isDone()) {
89
89
  (0, common_1.setResponseHeaders)($ctx);
90
90
  data = await this.responseFilter.serialize(data, $ctx);
91
91
  data = await this.responseFilter.transform(data, $ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AACjE,qCAA4D;AAC5D,iCAAuE;AAEvE,2DAAqD;AACrD,6EAAsE;AACtE,yCAA8C;AAC9C,+CAA0C;AAI1C,6DAAwD;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAEb,QAAQ,CAAkB;IAG1B,MAAM,CAAgB;IAGtB,MAAM,CAAiB;IAGvB,cAAc,CAAyB;IAEjD,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,OAA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,CAAC;aACnC;YAED,IAAI,IAAI,KAAK,SAAS,EAAE;gBACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;gBAEjB,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAC1C;YAED,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,IAAS,EAAE,IAAqB;QAClD,MAAM,EAAC,QAAQ,EAAC,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,IAAW,CAAC,CAAC;YAC9D,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAvHC;IADC,IAAA,WAAM,GAAE;sCACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;sCACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,WAAM,GAAE;sCACS,gCAAc;4CAAC;AAGjC;IADC,IAAA,WAAM,GAAE;sCACiB,iDAAsB;oDAAC;AAXtC,YAAY;IADxB,IAAA,aAAK,EAAC,SAAS,CAAC;GACJ,YAAY,CAyHxB;AAzHY,oCAAY","sourcesContent":["import {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {getContext, Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {EndpointMetadata} from \"@tsed/schema\";\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 compiledHandler = 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: any,\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = getContext<PlatformContext>();\n\n if ($ctx) {\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n try {\n if (await this.onRequest(compiledHandler, $ctx)) {\n next();\n }\n } catch (er) {\n next(er);\n }\n }\n };\n }\n\n private async onRequest(handler: any, $ctx: PlatformContext) {\n const resolver = new AnyToPromise();\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n\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 return true;\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 as any);\n data = await this.responseFilter.transform(data, $ctx as any);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AACjE,qCAA4D;AAC5D,iCAA2D;AAE3D,2DAAqD;AACrD,6EAAsE;AACtE,yCAA8C;AAC9C,+CAA0C;AAI1C,6DAAwD;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAEb,QAAQ,CAAkB;IAG1B,MAAM,CAAgB;IAGtB,MAAM,CAAiB;IAGvB,cAAc,CAAyB;IAEjD,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,O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CAAC;aAC1C;YAED,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,IAAS,EAAE,IAAqB;QAClD,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YAClB,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;YAEzB,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAC9D,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAvHC;IADC,IAAA,WAAM,GAAE;sCACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;sCACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,WAAM,GAAE;sCACS,gCAAc;4CAAC;AAGjC;IADC,IAAA,WAAM,GAAE;sCACiB,iDAAsB;oDAAC;AAXtC,YAAY;IADxB,IAAA,aAAK,EAAC,SAAS,CAAC;GACJ,YAAY,CAyHxB;AAzHY,oCAAY","sourcesContent":["import {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {EndpointMetadata} from \"@tsed/schema\";\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 compiledHandler = 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: any,\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const {$ctx} = req;\n\n if ($ctx) {\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n try {\n if (await this.onRequest(compiledHandler, $ctx)) {\n next();\n }\n } catch (er) {\n next(er);\n }\n }\n };\n }\n\n private async onRequest(handler: any, $ctx: PlatformContext) {\n const resolver = new AnyToPromise();\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n\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 return true;\n }\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!$ctx.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx as any);\n data = await this.responseFilter.transform(data, $ctx as any);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { setResponseHeaders } from "@tsed/common";
3
3
  import { AnyToPromise, AnyToPromiseStatus } from "@tsed/core";
4
- import { getContext, Inject, InjectorService } from "@tsed/di";
4
+ import { Inject, InjectorService } from "@tsed/di";
5
5
  import { PlatformParams } from "@tsed/platform-params";
6
6
  import { PlatformResponseFilter } from "@tsed/platform-response-filter";
7
7
  import { EndpointMetadata } from "@tsed/schema";
@@ -48,7 +48,7 @@ let AlterActions = class AlterActions {
48
48
  propertyKey
49
49
  });
50
50
  return async (action, handler, method, req, res, next, setActionItemMessage) => {
51
- const $ctx = getContext();
51
+ const { $ctx } = req;
52
52
  if ($ctx) {
53
53
  $ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
54
54
  $ctx.endpoint = EndpointMetadata.get(provider.useClass, "resolve");
@@ -82,7 +82,7 @@ let AlterActions = class AlterActions {
82
82
  }
83
83
  async flush(data, $ctx) {
84
84
  const { response } = $ctx;
85
- if (!response.isDone()) {
85
+ if (!$ctx.isDone()) {
86
86
  setResponseHeaders($ctx);
87
87
  data = await this.responseFilter.serialize(data, $ctx);
88
88
  data = await this.responseFilter.transform(data, $ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,YAAY,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC5D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YAC9D,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAvHC;IADC,MAAM,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,CAyHxB;SAzHY,YAAY","sourcesContent":["import {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {getContext, Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {EndpointMetadata} from \"@tsed/schema\";\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 compiledHandler = 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: any,\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = getContext<PlatformContext>();\n\n if ($ctx) {\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n try {\n if (await this.onRequest(compiledHandler, $ctx)) {\n next();\n }\n } catch (er) {\n next(er);\n }\n }\n };\n }\n\n private async onRequest(handler: any, $ctx: PlatformContext) {\n const resolver = new AnyToPromise();\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n\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 return true;\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 as any);\n data = await this.responseFilter.transform(data, $ctx as any);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAk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AC;YAEzB,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAC9D,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAvHC;IADC,MAAM,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,CAyHxB;SAzHY,YAAY","sourcesContent":["import {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {EndpointMetadata} from \"@tsed/schema\";\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 compiledHandler = 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: any,\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const {$ctx} = req;\n\n if ($ctx) {\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n try {\n if (await this.onRequest(compiledHandler, $ctx)) {\n next();\n }\n } catch (er) {\n next(er);\n }\n }\n };\n }\n\n private async onRequest(handler: any, $ctx: PlatformContext) {\n const resolver = new AnyToPromise();\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n\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 return true;\n }\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!$ctx.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx as any);\n data = await this.responseFilter.transform(data, $ctx as any);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
@@ -1,11 +1,28 @@
1
- /// <reference types="mongoose/types/pipelinestage" />
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
2
4
  /// <reference types="mongoose/types/connection" />
3
5
  /// <reference types="mongoose/types/cursor" />
4
6
  /// <reference types="mongoose/types/document" />
5
7
  /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
6
13
  /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
7
17
  /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
8
24
  /// <reference types="mongoose" />
25
+ /// <reference types="mongoose/types/inferschematype" />
9
26
  import { PlatformContext, Req } from "@tsed/common";
10
27
  import { FormioPayloadToken } from "../domain/FormioDecodedToken";
11
28
  import { FormioSubmission, WithID } from "../domain/FormioModels";
@@ -41,7 +58,7 @@ export declare class FormioAuthService {
41
58
  * @param req
42
59
  */
43
60
  getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole>> & {
44
- _id: any;
61
+ _id: import("mongoose").Types.ObjectId;
45
62
  }>[]>;
46
63
  /**
47
64
  * Update the role of the current user submission
@@ -50,13 +67,15 @@ export declare class FormioAuthService {
50
67
  * @param req
51
68
  */
52
69
  updateUserRole(_id: string | any, role: string, req?: Req): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
53
- _id: any;
70
+ _id: import("mongoose").Types.ObjectId;
54
71
  }>;
55
72
  /**
56
73
  * Create a user submission in formio
57
74
  * @param user
58
75
  */
59
- createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
76
+ createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<any> & Required<{
77
+ _id: unknown;
78
+ }>>;
60
79
  /**
61
80
  * Update user submission in formio
62
81
  * @param user
@@ -1,10 +1,27 @@
1
- /// <reference types="mongoose/types/pipelinestage" />
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
2
4
  /// <reference types="mongoose/types/connection" />
3
5
  /// <reference types="mongoose/types/cursor" />
4
6
  /// <reference types="mongoose/types/document" />
5
7
  /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
6
13
  /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
7
17
  /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
8
25
  import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
9
26
  import type { FilterQuery } from "mongoose";
10
27
  import { FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "@tsed/formio-types";
@@ -23,7 +40,7 @@ export declare class FormioDatabase {
23
40
  hasForms(): Promise<boolean>;
24
41
  hasForm(name: string): Promise<boolean>;
25
42
  getForm(nameOrId: string): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
26
- _id: any;
43
+ _id: import("mongoose").Types.ObjectId;
27
44
  }> | null>;
28
45
  /**
29
46
  * Import form previously exported by export tool.
@@ -32,7 +49,7 @@ export declare class FormioDatabase {
32
49
  * @param onCreate
33
50
  */
34
51
  importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
35
- _id: any;
52
+ _id: import("mongoose").Types.ObjectId;
36
53
  }> | null>;
37
54
  /**
38
55
  * Import form previously exported by export tool.
@@ -40,10 +57,10 @@ export declare class FormioDatabase {
40
57
  * @param form
41
58
  */
42
59
  importForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
43
- _id: any;
60
+ _id: import("mongoose").Types.ObjectId;
44
61
  }>;
45
62
  saveForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
46
- _id: any;
63
+ _id: import("mongoose").Types.ObjectId;
47
64
  }>;
48
65
  getSubmissions<Data>(query?: FilterQuery<MongooseModel<FormioSubmission<Data>>>): Promise<MongooseDocument<FormioSubmission<Data>>[]>;
49
66
  /**
@@ -54,10 +71,10 @@ export declare class FormioDatabase {
54
71
  importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, "form"> & {
55
72
  form?: any;
56
73
  }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
57
- _id: any;
74
+ _id: import("mongoose").Types.ObjectId;
58
75
  }>;
59
76
  saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
60
- _id: any;
77
+ _id: import("mongoose").Types.ObjectId;
61
78
  }>;
62
79
  idToBson(form?: any): any;
63
80
  }
@@ -1,10 +1,27 @@
1
- /// <reference types="mongoose/types/pipelinestage" />
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
2
4
  /// <reference types="mongoose/types/connection" />
3
5
  /// <reference types="mongoose/types/cursor" />
4
6
  /// <reference types="mongoose/types/document" />
5
7
  /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
6
13
  /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
7
17
  /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
8
25
  import type { FilterQuery } from "mongoose";
9
26
  import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
10
27
  import { FormioSubmission } from "../domain/FormioModels";
@@ -17,7 +34,7 @@ export declare abstract class FormioRepository<SubmissionData = any> {
17
34
  saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, "form"> & {
18
35
  form?: any;
19
36
  }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
20
- _id: any;
37
+ _id: import("mongoose").Types.ObjectId;
21
38
  }>;
22
39
  getSubmissions(query?: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>>): Promise<MongooseDocument<FormioSubmission<SubmissionData>>[]>;
23
40
  findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/formio",
3
- "version": "7.0.0-beta.15",
3
+ "version": "7.0.0-beta.18",
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 yarn jest --max-workers=2"
31
31
  },
32
32
  "dependencies": {
33
- "@tsed/formio-types": "7.0.0-beta.15",
33
+ "@tsed/formio-types": "7.0.0-beta.18",
34
34
  "tslib": "2.4.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@tsed/common": "7.0.0-beta.15",
38
- "@tsed/core": "7.0.0-beta.15",
39
- "@tsed/di": "7.0.0-beta.15",
40
- "@tsed/mongoose": "7.0.0-beta.15",
37
+ "@tsed/common": "7.0.0-beta.18",
38
+ "@tsed/core": "7.0.0-beta.18",
39
+ "@tsed/di": "7.0.0-beta.18",
40
+ "@tsed/mongoose": "7.0.0-beta.18",
41
41
  "@types/async": "3.2.12",
42
42
  "express": "^4.17.1",
43
43
  "formio": "^2.0.0",
@@ -45,7 +45,7 @@
45
45
  "mongoose": "^6.1.7"
46
46
  },
47
47
  "peerDependencies": {
48
- "@tsed/common": "^7.0.0-beta.15",
48
+ "@tsed/common": "^7.0.0-beta.18",
49
49
  "express": "^4.17.1",
50
50
  "formio": "^2.0.0",
51
51
  "lodash": "^4.17.21",