@tsed/formio 6.76.0 → 6.78.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,yCAAgF;AAChF,iCAA2D;AAC3D,+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,GAAQ,EAAE,GAAQ,EAAE,IAAc;4BAC1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,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,WAAM,EAAE;sCACW,oBAAe;8CAAC;AAGpC;IADC,WAAM,EAAE;sCACS,6BAAa;4CAAC;AALrB,YAAY;IADxB,aAAK,CAAC,SAAS,CAAC;GACJ,YAAY,CAkExB;AAlEY,oCAAY","sourcesContent":["import {EndpointMetadata, PlatformContext, PlatformHandler} from \"@tsed/common\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioActionInfo, 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,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,EAA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AAG,yBAAgB,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,WAAM,EAAE;sCACW,oBAAe;8CAAC;AAGpC;IADC,WAAM,EAAE;sCACS,6BAAa;4CAAC;AALrB,YAAY;IADxB,aAAK,CAAC,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,4 +1,4 @@
1
- import { FormioActionInfo } from "../domain/FormioAction";
1
+ import { FormioActionInfo } from "@tsed/formio-types";
2
2
  /**
3
3
  * Create a new FormIO Action.
4
4
  * @param options
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/decorators/action.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAA0C;AAG1C;;;;GAIG;AACH,SAAgB,MAAM,CAAC,OAAyB;IAC9C,OAAO,oBAAa,CAAC,CAAC,MAAW,EAAE,EAAE;QACnC,qBAAgB,CAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,eAAe;SACtB,CAAC,CAAC;IACL,CAAC,EAAE,eAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC;AAPD,wBAOC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"../domain/FormioAction\";\n\n/**\n * Create a new FormIO Action.\n * @param options\n * @decorator\n */\nexport function Action(options: FormioActionInfo): ClassDecorator {\n return useDecorators((target: any) => {\n registerProvider({\n provide: target,\n type: \"formio:action\"\n });\n }, StoreSet(\"formio:action\", options));\n}\n"]}
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/decorators/action.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAA0C;AAG1C;;;;GAIG;AACH,SAAgB,MAAM,CAAC,OAAyB;IAC9C,OAAO,oBAAa,CAAC,CAAC,MAAW,EAAE,EAAE;QACnC,qBAAgB,CAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,eAAe;SACtB,CAAC,CAAC;IACL,CAAC,EAAE,eAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC;AAPD,wBAOC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\n\n/**\n * Create a new FormIO Action.\n * @param options\n * @decorator\n */\nexport function Action(options: FormioActionInfo): ClassDecorator {\n return useDecorators((target: any) => {\n registerProvider({\n provide: target,\n type: \"formio:action\"\n });\n }, StoreSet(\"formio:action\", options));\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { FormioAction, SetActionItemMessage } from "../domain/FormioAction";
1
+ import { SetActionItemMessage } from "../domain/FormioAction";
2
+ import { FormioAction } from "@tsed/formio-types";
2
3
  /**
3
4
  * Return the current action context with the following data:
4
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"actionCtx.js","sourceRoot":"","sources":["../../src/decorators/actionCtx.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAGrC;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAAC,UAAmB;IAC3C,OAAO,gBAAO,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC;AAFD,8BAEC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {FormioAction, SetActionItemMessage} from \"../domain/FormioAction\";\n\n/**\n * Return the current action context with the following data:\n *\n * ```typescript\n * export type ActionCtx = {\n * handler: string;\n * method: string;\n * setActionItemMessage: SetActionItemMessage;\n * action: FormioAction;\n * };\n * ```\n * @param expression\n * @constructor\n */\nexport function ActionCtx(expression?: string): ParameterDecorator {\n return Context([\"ACTION_CTX\", expression].filter(Boolean).join(\".\"));\n}\n\nexport type ActionCtx = {\n handler: string;\n method: string;\n setActionItemMessage: SetActionItemMessage;\n action: FormioAction;\n};\n"]}
1
+ {"version":3,"file":"actionCtx.js","sourceRoot":"","sources":["../../src/decorators/actionCtx.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAIrC;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAAC,UAAmB;IAC3C,OAAO,gBAAO,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC;AAFD,8BAEC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioAction} from \"@tsed/formio-types\";\n\n/**\n * Return the current action context with the following data:\n *\n * ```typescript\n * export type ActionCtx = {\n * handler: string;\n * method: string;\n * setActionItemMessage: SetActionItemMessage;\n * action: FormioAction;\n * };\n * ```\n * @param expression\n * @constructor\n */\nexport function ActionCtx(expression?: string): ParameterDecorator {\n return Context([\"ACTION_CTX\", expression].filter(Boolean).join(\".\"));\n}\n\nexport type ActionCtx = {\n handler: string;\n method: string;\n setActionItemMessage: SetActionItemMessage;\n action: FormioAction;\n};\n"]}
@@ -1,32 +1,7 @@
1
1
  import { Request, Response } from "express";
2
2
  import { FormioMongooseSchema } from "./FormioBaseModel";
3
3
  import { FormioComponent } from "./FormioModels";
4
- export interface FormioActionInfo {
5
- name: string;
6
- title: string;
7
- description: string;
8
- priority: number;
9
- defaults: {
10
- handler: string[];
11
- method: string[];
12
- };
13
- access?: {
14
- handler: boolean;
15
- method: boolean;
16
- };
17
- }
18
- export interface FormioAction<Settings = any> {
19
- name: string;
20
- title: string;
21
- action: string;
22
- handler: string[];
23
- method: string[];
24
- priority: number;
25
- form: any;
26
- settings: Settings;
27
- condition?: any;
28
- deleted?: number | null;
29
- }
4
+ import { FormioAction, FormioActionInfo } from "@tsed/formio-types";
30
5
  export interface FormioActionModel extends FormioAction {
31
6
  resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;
32
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FormioAction.js","sourceRoot":"","sources":["../../src/domain/FormioAction.ts"],"names":[],"mappings":"","sourcesContent":["import {Request, Response} from \"express\";\nimport {FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioComponent} from \"./FormioModels\";\n\nexport interface FormioActionInfo {\n name: string;\n title: string;\n description: string;\n priority: number;\n defaults: {\n handler: string[];\n method: string[];\n };\n access?: {\n handler: boolean;\n method: boolean;\n };\n}\n\nexport interface FormioAction<Settings = any> {\n name: string;\n title: string;\n action: string;\n handler: string[];\n method: string[];\n priority: number;\n form: any;\n settings: Settings;\n condition?: any;\n deleted?: number | null;\n}\n\nexport interface FormioActionModel extends FormioAction {\n resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;\n}\n\nexport type FormioActionMongooseSchema = FormioMongooseSchema<FormioAction>;\nexport type SetActionItemMessage = (message: string, data?: any, state?: any) => void;\n\nexport interface FormioActionModelCtor {\n schema?: FormioActionMongooseSchema;\n\n info(req: Request, response: Response, next: (err: any, info: FormioActionInfo) => void): void;\n\n settingsForm(req: Request, response: Response, next: (err: any, info: FormioComponent[]) => void): void;\n\n new (data: FormioAction, req: Request, res: Response): FormioActionModel;\n}\n\nexport interface ActionMethods {\n info?(req: Request, response: Response): Promise<FormioAction>;\n\n settingsForm(req: Request, response: Response): Promise<FormioComponent[]>;\n\n resolve(...args: any[]): Promise<any>;\n}\n"]}
1
+ {"version":3,"file":"FormioAction.js","sourceRoot":"","sources":["../../src/domain/FormioAction.ts"],"names":[],"mappings":"","sourcesContent":["import {Request, Response} from \"express\";\nimport {FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioComponent} from \"./FormioModels\";\nimport {FormioAction, FormioActionInfo} from \"@tsed/formio-types\";\n\nexport interface FormioActionModel extends FormioAction {\n resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;\n}\n\nexport type FormioActionMongooseSchema = FormioMongooseSchema<FormioAction>;\nexport type SetActionItemMessage = (message: string, data?: any, state?: any) => void;\n\nexport interface FormioActionModelCtor {\n schema?: FormioActionMongooseSchema;\n\n info(req: Request, response: Response, next: (err: any, info: FormioActionInfo) => void): void;\n\n settingsForm(req: Request, response: Response, next: (err: any, info: FormioComponent[]) => void): void;\n\n new (data: FormioAction, req: Request, res: Response): FormioActionModel;\n}\n\nexport interface ActionMethods {\n info?(req: Request, response: Response): Promise<FormioAction>;\n\n settingsForm(req: Request, response: Response): Promise<FormioComponent[]>;\n\n resolve(...args: any[]): Promise<any>;\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { MongooseDocument } from "@tsed/mongoose";
2
- import { FormioAction } from "./FormioAction";
3
- import { FormioForm, FormioRole } from "./FormioModels";
2
+ import { FormioAction, FormioForm, FormioRole } from "@tsed/formio-types";
4
3
  export interface FormioCtxMapper {
5
4
  forms: Map<string, MongooseDocument<FormioForm>>;
6
5
  actions: Map<string, MongooseDocument<FormioAction>>;
@@ -1 +1 @@
1
- {"version":3,"file":"FormioCtxMapper.js","sourceRoot":"","sources":["../../src/domain/FormioCtxMapper.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioAction} from \"./FormioAction\";\nimport {FormioForm, FormioRole} from \"./FormioModels\";\n\nexport interface FormioCtxMapper {\n forms: Map<string, MongooseDocument<FormioForm>>;\n actions: Map<string, MongooseDocument<FormioAction>>;\n roles: Map<string, MongooseDocument<FormioRole>>;\n}\n"]}
1
+ {"version":3,"file":"FormioCtxMapper.js","sourceRoot":"","sources":["../../src/domain/FormioCtxMapper.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioAction, FormioForm, FormioRole} from \"@tsed/formio-types\";\n\nexport interface FormioCtxMapper {\n forms: Map<string, MongooseDocument<FormioForm>>;\n actions: Map<string, MongooseDocument<FormioAction>>;\n roles: Map<string, MongooseDocument<FormioRole>>;\n}\n"]}
@@ -2,152 +2,11 @@ import { MongooseDocument } from "@tsed/mongoose";
2
2
  import { Schema } from "mongoose";
3
3
  import { FormioActionModelCtor, FormioActionMongooseSchema } from "./FormioAction";
4
4
  import { FormioBaseModel, FormioModel, FormioMongooseSchema } from "./FormioBaseModel";
5
+ import { FormioActionItem, FormioForm, FormioRole, FormioSchema, FormioSubmission, FormioToken } from "@tsed/formio-types";
6
+ export * from "@tsed/formio-types";
5
7
  export declare type WithID<T> = T & {
6
8
  _id: string;
7
9
  };
8
- export interface FormioActionItem<Data = any> {
9
- _id: string | undefined;
10
- title: string;
11
- form: string;
12
- submission?: string;
13
- action: string;
14
- handler: string;
15
- method: string;
16
- state: "new" | "inprogress" | "complete" | "error";
17
- messages: any[];
18
- data: Data;
19
- }
20
- export interface FormioAccess {
21
- _id: string | undefined;
22
- type: string;
23
- resources: any[];
24
- }
25
- export interface FormioPermission {
26
- type: "create_all" | "read_all" | "update_all" | "delete_all" | "create_own" | "read_own" | "update_own" | "delete_own" | "self";
27
- roles: string[];
28
- }
29
- export interface FormioComponent extends Record<string, any> {
30
- type: string;
31
- input?: boolean;
32
- label?: string;
33
- key: string;
34
- placeholder?: string;
35
- template?: string;
36
- dataSrc?: "json" | "url";
37
- data?: {
38
- json?: any;
39
- url?: string;
40
- [key: string]: any;
41
- };
42
- valueProperty?: string;
43
- multiple?: boolean;
44
- validate?: {
45
- required?: boolean;
46
- [key: string]: any;
47
- };
48
- customConditional?: string;
49
- components?: FormioComponent[];
50
- legend?: string;
51
- tree?: boolean;
52
- tableView?: boolean;
53
- protected?: boolean;
54
- persistent?: boolean;
55
- hidden?: boolean;
56
- clearOnHide?: boolean;
57
- form?: string | FormioForm;
58
- filter?: string;
59
- }
60
- export interface FormioForm {
61
- _id: string | undefined;
62
- /**
63
- * The title for the form
64
- */
65
- title: string;
66
- /**
67
- * The machine name for this form
68
- */
69
- name: string;
70
- /**
71
- * The path for this resource
72
- */
73
- path: string;
74
- /**
75
- * The form type.
76
- */
77
- type: string;
78
- /**
79
- * The display method for this form
80
- */
81
- display?: string;
82
- /**
83
- * A custom action URL to submit the data to.
84
- */
85
- action?: string;
86
- tags?: string[];
87
- deleted: number | null;
88
- /**
89
- * Access rules
90
- */
91
- access: FormioPermission[];
92
- /**
93
- * Submission access ruules
94
- */
95
- submissionAccess: FormioPermission[];
96
- /**
97
- *
98
- */
99
- owner: string;
100
- /**
101
- * Components.
102
- */
103
- components: FormioComponent[];
104
- /**
105
- * Custom form settings object.
106
- */
107
- settings?: any;
108
- /**
109
- * Custom form properties.
110
- */
111
- properties?: any;
112
- [key: string]: any;
113
- }
114
- export interface FormioRole extends Record<string, any> {
115
- _id: string | undefined;
116
- title: string;
117
- description: string;
118
- deleted: number | null;
119
- default: boolean;
120
- admin: boolean;
121
- }
122
- export interface FormioSchema {
123
- key: string;
124
- isLocked: boolean;
125
- version: string;
126
- value: string;
127
- }
128
- export interface FormioSubmission<Data = any> extends Record<string, any> {
129
- _id: string | undefined;
130
- form: string;
131
- data: Data;
132
- owner?: string;
133
- roles?: string[];
134
- access?: FormioAccess[];
135
- externalIds?: {
136
- type?: string;
137
- resource?: string;
138
- id?: string;
139
- }[];
140
- metadata?: Record<string, any>;
141
- created?: string;
142
- updated?: string;
143
- deleted?: string | null;
144
- modified?: string;
145
- }
146
- export interface FormioToken {
147
- key: string;
148
- value: string;
149
- expireAt: Date;
150
- }
151
10
  export interface FormioSchemas {
152
11
  action: FormioActionMongooseSchema;
153
12
  actionItem: Schema<MongooseDocument<FormioActionItem>>;
@@ -1,3 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("@tsed/formio-types"), exports);
3
5
  //# sourceMappingURL=FormioModels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormioModels.js","sourceRoot":"","sources":["../../src/domain/FormioModels.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Schema} from \"mongoose\";\nimport {FormioActionModelCtor, FormioActionMongooseSchema} from \"./FormioAction\";\nimport {FormioBaseModel, FormioModel, FormioMongooseSchema} from \"./FormioBaseModel\";\n\nexport type WithID<T> = T & {_id: string};\n\nexport interface FormioActionItem<Data = any> {\n _id: string | undefined;\n title: string;\n form: string;\n submission?: string;\n action: string;\n handler: string;\n method: string;\n state: \"new\" | \"inprogress\" | \"complete\" | \"error\";\n messages: any[];\n data: Data;\n}\n\nexport interface FormioAccess {\n _id: string | undefined;\n type: string;\n resources: any[];\n}\n\nexport interface FormioPermission {\n type: \"create_all\" | \"read_all\" | \"update_all\" | \"delete_all\" | \"create_own\" | \"read_own\" | \"update_own\" | \"delete_own\" | \"self\";\n roles: string[];\n}\n\nexport interface FormioComponent extends Record<string, any> {\n type: string;\n input?: boolean;\n label?: string;\n key: string;\n placeholder?: string;\n template?: string;\n dataSrc?: \"json\" | \"url\";\n data?: {\n json?: any;\n url?: string;\n\n [key: string]: any;\n };\n valueProperty?: string;\n multiple?: boolean;\n validate?: {\n required?: boolean;\n [key: string]: any;\n };\n customConditional?: string;\n components?: FormioComponent[];\n legend?: string;\n tree?: boolean;\n tableView?: boolean;\n protected?: boolean;\n persistent?: boolean;\n hidden?: boolean;\n clearOnHide?: boolean;\n form?: string | FormioForm;\n filter?: string;\n}\n\nexport interface FormioForm {\n _id: string | undefined;\n /**\n * The title for the form\n */\n title: string;\n /**\n * The machine name for this form\n */\n name: string;\n /**\n * The path for this resource\n */\n path: string;\n /**\n * The form type.\n */\n type: string;\n /**\n * The display method for this form\n */\n display?: string;\n /**\n * A custom action URL to submit the data to.\n */\n action?: string;\n\n tags?: string[];\n\n deleted: number | null;\n /**\n * Access rules\n */\n access: FormioPermission[];\n /**\n * Submission access ruules\n */\n submissionAccess: FormioPermission[];\n /**\n *\n */\n owner: string;\n /**\n * Components.\n */\n components: FormioComponent[];\n /**\n * Custom form settings object.\n */\n settings?: any;\n /**\n * Custom form properties.\n */\n properties?: any;\n\n [key: string]: any;\n}\n\nexport interface FormioRole extends Record<string, any> {\n _id: string | undefined;\n title: string;\n description: string;\n deleted: number | null;\n default: boolean;\n admin: boolean;\n}\n\nexport interface FormioSchema {\n key: string;\n isLocked: boolean;\n version: string;\n value: string;\n}\n\nexport interface FormioSubmission<Data = any> extends Record<string, any> {\n _id: string | undefined;\n form: string;\n data: Data;\n owner?: string;\n // delete?: number | null;\n roles?: string[];\n access?: FormioAccess[];\n externalIds?: {type?: string; resource?: string; id?: string}[];\n metadata?: Record<string, any>;\n created?: string;\n updated?: string;\n deleted?: string | null;\n modified?: string;\n}\n\nexport interface FormioToken {\n key: string;\n value: string;\n expireAt: Date;\n}\n\nexport interface FormioSchemas {\n action: FormioActionMongooseSchema;\n actionItem: Schema<MongooseDocument<FormioActionItem>>;\n form: FormioMongooseSchema<FormioForm>;\n role: FormioMongooseSchema<FormioRole>;\n schema: Schema<MongooseDocument<FormioSchema>>;\n submission: Schema<MongooseDocument<FormioSubmission>>;\n token: Schema<MongooseDocument<FormioToken>>;\n\n [key: string]: Schema<MongooseDocument<any>>;\n}\n\nexport type FormioModelsModels = {\n action: FormioActionModelCtor;\n actionItem: FormioBaseModel<FormioActionItem>;\n form: FormioModel<FormioForm>;\n role: FormioModel<FormioRole>;\n schema: FormioBaseModel<FormioSchema>;\n submission: FormioBaseModel<FormioSubmission>;\n token: FormioBaseModel<FormioToken>;\n} & Record<string, FormioBaseModel>;\n\nexport interface FormioModels {\n schemas: FormioSchemas;\n models: FormioModelsModels;\n specs: {\n action: any;\n actionItem: any;\n form: any;\n role: any;\n schema: any;\n submission: any;\n token: any;\n\n [key: string]: any;\n };\n}\n"]}
1
+ {"version":3,"file":"FormioModels.js","sourceRoot":"","sources":["../../src/domain/FormioModels.ts"],"names":[],"mappings":";;;AAMA,6DAAmC","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Schema} from \"mongoose\";\nimport {FormioActionModelCtor, FormioActionMongooseSchema} from \"./FormioAction\";\nimport {FormioBaseModel, FormioModel, FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioActionItem, FormioForm, FormioRole, FormioSchema, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\n\nexport * from \"@tsed/formio-types\";\n\nexport type WithID<T> = T & {_id: string};\n\nexport interface FormioSchemas {\n action: FormioActionMongooseSchema;\n actionItem: Schema<MongooseDocument<FormioActionItem>>;\n form: FormioMongooseSchema<FormioForm>;\n role: FormioMongooseSchema<FormioRole>;\n schema: Schema<MongooseDocument<FormioSchema>>;\n submission: Schema<MongooseDocument<FormioSubmission>>;\n token: Schema<MongooseDocument<FormioToken>>;\n\n [key: string]: Schema<MongooseDocument<any>>;\n}\n\nexport type FormioModelsModels = {\n action: FormioActionModelCtor;\n actionItem: FormioBaseModel<FormioActionItem>;\n form: FormioModel<FormioForm>;\n role: FormioModel<FormioRole>;\n schema: FormioBaseModel<FormioSchema>;\n submission: FormioBaseModel<FormioSubmission>;\n token: FormioBaseModel<FormioToken>;\n} & Record<string, FormioBaseModel>;\n\nexport interface FormioModels {\n schemas: FormioSchemas;\n models: FormioModelsModels;\n specs: {\n action: any;\n actionItem: any;\n form: any;\n role: any;\n schema: any;\n submission: any;\n token: any;\n\n [key: string]: any;\n };\n}\n"]}
@@ -33,7 +33,7 @@ export declare class FormioAuthService {
33
33
  * Retrieve roles
34
34
  * @param req
35
35
  */
36
- getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & import("../domain/FormioModels").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("../domain/FormioModels").FormioRole>>>[]>;
36
+ getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & import("@tsed/formio-types/lib/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/domain/FormioRole").FormioRole>>>[]>;
37
37
  /**
38
38
  * Update the role of the current user submission
39
39
  * @param _id
@@ -1,8 +1,7 @@
1
1
  /// <reference types="mongoose" />
2
2
  import { MongooseModel } from "@tsed/mongoose";
3
+ import { FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "@tsed/formio-types";
3
4
  import { FormioMapper } from "../builder/FormioMapper";
4
- import { FormioAction } from "../domain/FormioAction";
5
- import { FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "../domain/FormioModels";
6
5
  import { FormioService } from "./FormioService";
7
6
  export declare class FormioDatabase {
8
7
  protected formio: FormioService;
@@ -1 +1 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAE5C,0DAAqD;AAGrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,YAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClH,CAAC;AAG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EAAE,CAAC;IAC7D,CAAC;IAED,QAAQ,CAAC,IAAU;QACjB,IAAI,cAAO,CAAC,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,eAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,eAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAjGC;IADC,WAAM,EAAE;sCACS,6BAAa;8CAAC;AAFrB,cAAc;IAD1B,eAAU,EAAE;GACA,cAAc,CAmG1B;AAnGY,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 {FormioMapper} from \"../builder/FormioMapper\";\nimport {FormioAction} from \"../domain/FormioAction\";\nimport {FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"../domain/FormioModels\";\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.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({machineName: {$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 : {machineName: {$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\n return new this.formModel(mapper.mapToImport(form)).save();\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,0DAAqD;AACrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAA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,KAAK,CAAC,kBAAkB,CAAC,IAAgB;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAE5C,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,CAAC;IAED,QAAQ,CAAC,IAAU;QACjB,IAAI,cAAO,CAAC,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,eAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,eAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAjGC;IADC,WAAM,EAAE;sCACS,6BAAa;8CAAC;AAFrB,cAAc;IAD1B,eAAU,EAAE;GACA,cAAc,CAmG1B;AAnGY,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.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({machineName: {$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 : {machineName: {$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\n return new this.formModel(mapper.mapToImport(form)).save();\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/formio",
3
- "version": "6.76.0",
3
+ "version": "6.78.1",
4
4
  "description": "Formio package for Ts.ED framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/index.js",
@@ -20,23 +20,24 @@
20
20
  "test": "cross-env NODE_ENV=test nyc mocha"
21
21
  },
22
22
  "dependencies": {
23
+ "@tsed/formio-types": "6.78.1",
23
24
  "tslib": "2.2.0"
24
25
  },
25
26
  "devDependencies": {
26
- "@tsed/common": "6.76.0",
27
- "@tsed/core": "6.76.0",
28
- "@tsed/di": "6.76.0",
29
- "@tsed/mongoose": "6.76.0",
27
+ "@tsed/common": "6.78.1",
28
+ "@tsed/core": "6.78.1",
29
+ "@tsed/di": "6.78.1",
30
+ "@tsed/mongoose": "6.78.1",
30
31
  "express": "^4.17.1",
31
32
  "formio": "^2.0.0",
32
33
  "mongodb": "*",
33
34
  "mongoose": "^5.12.2"
34
35
  },
35
36
  "peerDependencies": {
36
- "@tsed/common": "^6.76.0",
37
- "@tsed/core": "^6.76.0",
38
- "@tsed/di": "^6.76.0",
39
- "@tsed/mongoose": "^6.76.0",
37
+ "@tsed/common": "^6.78.1",
38
+ "@tsed/core": "^6.78.1",
39
+ "@tsed/di": "^6.78.1",
40
+ "@tsed/mongoose": "^6.78.1",
40
41
  "express": "^4.17.1",
41
42
  "formio": "^2.0.0",
42
43
  "mongodb": "*",