@gcforms/types 0.0.8 → 0.0.10

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,7 +1,7 @@
1
- export type TypeOmit<Type, Key extends PropertyKey> = {
1
+ type TypeOmit<Type, Key extends PropertyKey> = {
2
2
  [Property in keyof Type as Exclude<Property, Key>]: Type[Property];
3
3
  };
4
- export type FormChangeEvent = {
4
+ type FormChangeEvent = {
5
5
  target: {
6
6
  value: string | number | boolean | string[];
7
7
  name?: string;
@@ -9,7 +9,7 @@ export type FormChangeEvent = {
9
9
  checked?: boolean;
10
10
  };
11
11
  };
12
- export type Group = {
12
+ type Group = {
13
13
  name: string;
14
14
  titleEn: string;
15
15
  titleFr: string;
@@ -19,18 +19,13 @@ export type Group = {
19
19
  exitUrlEn?: string;
20
20
  exitUrlFr?: string;
21
21
  };
22
- export type GroupsType = Record<string, Group>;
23
- export type FormValues = Record<string, string | string[]>;
24
- export type ChoiceRule = {
25
- elementId: string;
26
- choiceId: string;
27
- };
28
- export type NextActionRule = {
22
+ type GroupsType = Record<string, Group>;
23
+ type NextActionRule = {
29
24
  groupId: string;
30
25
  choiceId: string;
31
26
  };
32
- export type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
33
- export declare enum FormElementTypes {
27
+ type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
28
+ declare enum FormElementTypes {
34
29
  textField = "textField",
35
30
  textArea = "textArea",
36
31
  dropdown = "dropdown",
@@ -49,10 +44,10 @@ export declare enum FormElementTypes {
49
44
  combobox = "combobox",
50
45
  formattedDate = "formattedDate"
51
46
  }
52
- export type ConditionalRule = {
47
+ type ConditionalRule = {
53
48
  choiceId: string;
54
49
  };
55
- export interface ValidationProperties {
50
+ interface ValidationProperties {
56
51
  required: boolean;
57
52
  type?: HTMLTextInputTypeAttribute;
58
53
  regex?: string;
@@ -61,22 +56,22 @@ export interface ValidationProperties {
61
56
  descriptionFR?: string;
62
57
  [key: string]: unknown;
63
58
  }
64
- export interface PropertyChoices {
59
+ interface PropertyChoices {
65
60
  en: string;
66
61
  fr: string;
67
62
  [key: string]: string;
68
63
  }
69
- export type AddressComponents = {
64
+ type AddressComponents = {
70
65
  canadianOnly?: boolean;
71
66
  splitAddress?: boolean;
72
67
  };
73
- export interface DeliveryOption {
68
+ interface DeliveryOption {
74
69
  emailAddress: string;
75
70
  emailSubjectEn?: string;
76
71
  emailSubjectFr?: string;
77
72
  [key: string]: string | undefined;
78
73
  }
79
- export interface ElementProperties {
74
+ interface ElementProperties {
80
75
  titleEn: string;
81
76
  titleFr: string;
82
77
  placeholderEn?: string;
@@ -99,7 +94,7 @@ export interface ElementProperties {
99
94
  dynamicRow?: dynamicRowType;
100
95
  [key: string]: string | number | boolean | Array<PropertyChoices> | Array<FormElement> | ValidationProperties | Array<ConditionalRule> | AddressComponents | dynamicRowType | undefined;
101
96
  }
102
- export interface BrandProperties {
97
+ interface BrandProperties {
103
98
  name?: string;
104
99
  logoEn: string;
105
100
  logoFr: string;
@@ -110,7 +105,7 @@ export interface BrandProperties {
110
105
  disableGcBranding?: boolean;
111
106
  [key: string]: string | boolean | undefined;
112
107
  }
113
- export interface FormElement {
108
+ interface FormElement {
114
109
  id: number;
115
110
  subId?: string;
116
111
  type: FormElementTypes;
@@ -118,7 +113,7 @@ export interface FormElement {
118
113
  onchange?: (event: FormChangeEvent) => void;
119
114
  brand?: BrandProperties;
120
115
  }
121
- export interface FormProperties {
116
+ interface FormProperties {
122
117
  titleEn: string;
123
118
  titleFr: string;
124
119
  introduction?: Record<string, string>;
@@ -134,7 +129,7 @@ export interface FormProperties {
134
129
  formPurpose?: string;
135
130
  [key: string]: string | number | boolean | Array<string | number | FormElement> | Record<string, string> | BrandProperties | GroupsType | undefined;
136
131
  }
137
- export type dynamicRowType = {
132
+ type dynamicRowType = {
138
133
  rowTitleEn: string;
139
134
  rowTitleFr: string;
140
135
  addButtonTextEn: string;
@@ -142,7 +137,7 @@ export type dynamicRowType = {
142
137
  addButtonTextFr: string;
143
138
  removeButtonTextFr: string;
144
139
  };
145
- export type FormRecord = {
140
+ type FormRecord = {
146
141
  id: string;
147
142
  createdAt?: string;
148
143
  updatedAt?: string;
@@ -156,10 +151,22 @@ export type FormRecord = {
156
151
  saveAndResume?: boolean;
157
152
  [key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
158
153
  };
159
- export type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
160
- export type FormPurpose = "" | "admin" | "nonAdmin";
161
- export type ClosedDetails = {
154
+ type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
155
+ type FormPurpose = "" | "admin" | "nonAdmin";
156
+ type ClosedDetails = {
162
157
  messageEn?: string;
163
158
  messageFr?: string;
164
159
  };
165
- export type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
160
+ type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
161
+
162
+ type Responses = {
163
+ [key: string]: Response;
164
+ };
165
+ type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
166
+ type FileInputResponse = {
167
+ name: string | null;
168
+ size: number | null;
169
+ based64EncodedFile: string | null;
170
+ };
171
+
172
+ export { type AddressComponents, type BrandProperties, type ClosedDetails, type ConditionalRule, type DeliveryOption, type ElementProperties, type FileInputResponse, type FormElement, FormElementTypes, type FormProperties, type FormPurpose, type FormRecord, type Group, type PropertyChoices, type PublicFormRecord, type Response, type Responses, type SecurityAttribute, type ValidationProperties, type dynamicRowType };
@@ -0,0 +1,172 @@
1
+ type TypeOmit<Type, Key extends PropertyKey> = {
2
+ [Property in keyof Type as Exclude<Property, Key>]: Type[Property];
3
+ };
4
+ type FormChangeEvent = {
5
+ target: {
6
+ value: string | number | boolean | string[];
7
+ name?: string;
8
+ type?: string;
9
+ checked?: boolean;
10
+ };
11
+ };
12
+ type Group = {
13
+ name: string;
14
+ titleEn: string;
15
+ titleFr: string;
16
+ nextAction?: string | NextActionRule[];
17
+ elements: string[];
18
+ autoFlow?: boolean;
19
+ exitUrlEn?: string;
20
+ exitUrlFr?: string;
21
+ };
22
+ type GroupsType = Record<string, Group>;
23
+ type NextActionRule = {
24
+ groupId: string;
25
+ choiceId: string;
26
+ };
27
+ type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
28
+ declare enum FormElementTypes {
29
+ textField = "textField",
30
+ textArea = "textArea",
31
+ dropdown = "dropdown",
32
+ radio = "radio",
33
+ checkbox = "checkbox",
34
+ fileInput = "fileInput",
35
+ richText = "richText",
36
+ dynamicRow = "dynamicRow",
37
+ attestation = "attestation",
38
+ address = "address",
39
+ addressComplete = "addressComplete",
40
+ name = "name",
41
+ firstMiddleLastName = "firstMiddleLastName",
42
+ departments = "departments",
43
+ contact = "contact",
44
+ combobox = "combobox",
45
+ formattedDate = "formattedDate"
46
+ }
47
+ type ConditionalRule = {
48
+ choiceId: string;
49
+ };
50
+ interface ValidationProperties {
51
+ required: boolean;
52
+ type?: HTMLTextInputTypeAttribute;
53
+ regex?: string;
54
+ maxLength?: number;
55
+ descriptionEN?: string;
56
+ descriptionFR?: string;
57
+ [key: string]: unknown;
58
+ }
59
+ interface PropertyChoices {
60
+ en: string;
61
+ fr: string;
62
+ [key: string]: string;
63
+ }
64
+ type AddressComponents = {
65
+ canadianOnly?: boolean;
66
+ splitAddress?: boolean;
67
+ };
68
+ interface DeliveryOption {
69
+ emailAddress: string;
70
+ emailSubjectEn?: string;
71
+ emailSubjectFr?: string;
72
+ [key: string]: string | undefined;
73
+ }
74
+ interface ElementProperties {
75
+ titleEn: string;
76
+ titleFr: string;
77
+ placeholderEn?: string;
78
+ placeholderFr?: string;
79
+ descriptionEn?: string;
80
+ descriptionFr?: string;
81
+ validation?: ValidationProperties | undefined;
82
+ choices?: PropertyChoices[];
83
+ managedChoices?: string;
84
+ subElements?: FormElement[];
85
+ fileType?: string | undefined;
86
+ headingLevel?: string | undefined;
87
+ isSectional?: boolean;
88
+ maxNumberOfRows?: number;
89
+ autoComplete?: string;
90
+ dateFormat?: string;
91
+ conditionalRules?: ConditionalRule[];
92
+ full?: boolean;
93
+ addressComponents?: AddressComponents | undefined;
94
+ dynamicRow?: dynamicRowType;
95
+ [key: string]: string | number | boolean | Array<PropertyChoices> | Array<FormElement> | ValidationProperties | Array<ConditionalRule> | AddressComponents | dynamicRowType | undefined;
96
+ }
97
+ interface BrandProperties {
98
+ name?: string;
99
+ logoEn: string;
100
+ logoFr: string;
101
+ logoTitleEn: string;
102
+ logoTitleFr: string;
103
+ urlEn?: string;
104
+ urlFr?: string;
105
+ disableGcBranding?: boolean;
106
+ [key: string]: string | boolean | undefined;
107
+ }
108
+ interface FormElement {
109
+ id: number;
110
+ subId?: string;
111
+ type: FormElementTypes;
112
+ properties: ElementProperties;
113
+ onchange?: (event: FormChangeEvent) => void;
114
+ brand?: BrandProperties;
115
+ }
116
+ interface FormProperties {
117
+ titleEn: string;
118
+ titleFr: string;
119
+ introduction?: Record<string, string>;
120
+ privacyPolicy?: Record<string, string>;
121
+ confirmation?: Record<string, string>;
122
+ closedMessage?: Record<string, string>;
123
+ layout: number[];
124
+ groups?: GroupsType;
125
+ groupsLayout?: string[];
126
+ elements: FormElement[];
127
+ lastGeneratedElementId?: number;
128
+ brand?: BrandProperties;
129
+ formPurpose?: string;
130
+ [key: string]: string | number | boolean | Array<string | number | FormElement> | Record<string, string> | BrandProperties | GroupsType | undefined;
131
+ }
132
+ type dynamicRowType = {
133
+ rowTitleEn: string;
134
+ rowTitleFr: string;
135
+ addButtonTextEn: string;
136
+ removeButtonTextEn: string;
137
+ addButtonTextFr: string;
138
+ removeButtonTextFr: string;
139
+ };
140
+ type FormRecord = {
141
+ id: string;
142
+ createdAt?: string;
143
+ updatedAt?: string;
144
+ name: string;
145
+ form: FormProperties;
146
+ isPublished: boolean;
147
+ deliveryOption?: DeliveryOption;
148
+ securityAttribute: SecurityAttribute;
149
+ closingDate?: string;
150
+ closedDetails?: ClosedDetails;
151
+ saveAndResume?: boolean;
152
+ [key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
153
+ };
154
+ type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
155
+ type FormPurpose = "" | "admin" | "nonAdmin";
156
+ type ClosedDetails = {
157
+ messageEn?: string;
158
+ messageFr?: string;
159
+ };
160
+ type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
161
+
162
+ type Responses = {
163
+ [key: string]: Response;
164
+ };
165
+ type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
166
+ type FileInputResponse = {
167
+ name: string | null;
168
+ size: number | null;
169
+ based64EncodedFile: string | null;
170
+ };
171
+
172
+ export { type AddressComponents, type BrandProperties, type ClosedDetails, type ConditionalRule, type DeliveryOption, type ElementProperties, type FileInputResponse, type FormElement, FormElementTypes, type FormProperties, type FormPurpose, type FormRecord, type Group, type PropertyChoices, type PublicFormRecord, type Response, type Responses, type SecurityAttribute, type ValidationProperties, type dynamicRowType };
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ FormElementTypes: () => FormElementTypes
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/form-types.ts
28
+ var FormElementTypes = /* @__PURE__ */ ((FormElementTypes2) => {
29
+ FormElementTypes2["textField"] = "textField";
30
+ FormElementTypes2["textArea"] = "textArea";
31
+ FormElementTypes2["dropdown"] = "dropdown";
32
+ FormElementTypes2["radio"] = "radio";
33
+ FormElementTypes2["checkbox"] = "checkbox";
34
+ FormElementTypes2["fileInput"] = "fileInput";
35
+ FormElementTypes2["richText"] = "richText";
36
+ FormElementTypes2["dynamicRow"] = "dynamicRow";
37
+ FormElementTypes2["attestation"] = "attestation";
38
+ FormElementTypes2["address"] = "address";
39
+ FormElementTypes2["addressComplete"] = "addressComplete";
40
+ FormElementTypes2["name"] = "name";
41
+ FormElementTypes2["firstMiddleLastName"] = "firstMiddleLastName";
42
+ FormElementTypes2["departments"] = "departments";
43
+ FormElementTypes2["contact"] = "contact";
44
+ FormElementTypes2["combobox"] = "combobox";
45
+ FormElementTypes2["formattedDate"] = "formattedDate";
46
+ return FormElementTypes2;
47
+ })(FormElementTypes || {});
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ FormElementTypes
51
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ // src/form-types.ts
2
+ var FormElementTypes = /* @__PURE__ */ ((FormElementTypes2) => {
3
+ FormElementTypes2["textField"] = "textField";
4
+ FormElementTypes2["textArea"] = "textArea";
5
+ FormElementTypes2["dropdown"] = "dropdown";
6
+ FormElementTypes2["radio"] = "radio";
7
+ FormElementTypes2["checkbox"] = "checkbox";
8
+ FormElementTypes2["fileInput"] = "fileInput";
9
+ FormElementTypes2["richText"] = "richText";
10
+ FormElementTypes2["dynamicRow"] = "dynamicRow";
11
+ FormElementTypes2["attestation"] = "attestation";
12
+ FormElementTypes2["address"] = "address";
13
+ FormElementTypes2["addressComplete"] = "addressComplete";
14
+ FormElementTypes2["name"] = "name";
15
+ FormElementTypes2["firstMiddleLastName"] = "firstMiddleLastName";
16
+ FormElementTypes2["departments"] = "departments";
17
+ FormElementTypes2["contact"] = "contact";
18
+ FormElementTypes2["combobox"] = "combobox";
19
+ FormElementTypes2["formattedDate"] = "formattedDate";
20
+ return FormElementTypes2;
21
+ })(FormElementTypes || {});
22
+ export {
23
+ FormElementTypes
24
+ };
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@gcforms/types",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "author": "Canadian Digital Service",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "type": "module",
10
- "main": "./dist/cjs/index.js",
11
- "module": "./dist/esm/index.js",
12
- "types": "./dist/types/index.d.ts",
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "require": "./dist/index.js",
16
+ "import": "./dist/index.mjs"
17
+ }
18
+ },
13
19
  "files": [
14
- "dist",
15
- "package.json"
20
+ "dist"
16
21
  ],
17
22
  "scripts": {
18
- "build:cjs": "tsc -p tsconfig.cjs.json",
19
- "build:esm": "tsc -p tsconfig.esm.json",
20
- "build": "rm -rf dist && yarn build:cjs && yarn build:esm",
21
- "prepare": "yarn build"
22
- },
23
- "dependencies": {
24
- "axios": "^1.7.9"
23
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
24
+ "prepare": "yarn && yarn build"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^20.11.0",
28
+ "tsup": "^8.3.6",
28
29
  "typescript": "^5.3.3"
29
- },
30
- "packageManager": "yarn@4.6.0"
30
+ }
31
31
  }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormElementTypes = void 0;
4
- // all the possible types of form elements
5
- var FormElementTypes;
6
- (function (FormElementTypes) {
7
- FormElementTypes["textField"] = "textField";
8
- FormElementTypes["textArea"] = "textArea";
9
- FormElementTypes["dropdown"] = "dropdown";
10
- FormElementTypes["radio"] = "radio";
11
- FormElementTypes["checkbox"] = "checkbox";
12
- FormElementTypes["fileInput"] = "fileInput";
13
- FormElementTypes["richText"] = "richText";
14
- FormElementTypes["dynamicRow"] = "dynamicRow";
15
- FormElementTypes["attestation"] = "attestation";
16
- FormElementTypes["address"] = "address";
17
- FormElementTypes["addressComplete"] = "addressComplete";
18
- FormElementTypes["name"] = "name";
19
- FormElementTypes["firstMiddleLastName"] = "firstMiddleLastName";
20
- FormElementTypes["departments"] = "departments";
21
- FormElementTypes["contact"] = "contact";
22
- FormElementTypes["combobox"] = "combobox";
23
- FormElementTypes["formattedDate"] = "formattedDate";
24
- })(FormElementTypes || (exports.FormElementTypes = FormElementTypes = {}));
package/dist/cjs/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormElementTypes = void 0;
4
- var form_types_js_1 = require("./form-types.js");
5
- Object.defineProperty(exports, "FormElementTypes", { enumerable: true, get: function () { return form_types_js_1.FormElementTypes; } });
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- // all the possible types of form elements
2
- export var FormElementTypes;
3
- (function (FormElementTypes) {
4
- FormElementTypes["textField"] = "textField";
5
- FormElementTypes["textArea"] = "textArea";
6
- FormElementTypes["dropdown"] = "dropdown";
7
- FormElementTypes["radio"] = "radio";
8
- FormElementTypes["checkbox"] = "checkbox";
9
- FormElementTypes["fileInput"] = "fileInput";
10
- FormElementTypes["richText"] = "richText";
11
- FormElementTypes["dynamicRow"] = "dynamicRow";
12
- FormElementTypes["attestation"] = "attestation";
13
- FormElementTypes["address"] = "address";
14
- FormElementTypes["addressComplete"] = "addressComplete";
15
- FormElementTypes["name"] = "name";
16
- FormElementTypes["firstMiddleLastName"] = "firstMiddleLastName";
17
- FormElementTypes["departments"] = "departments";
18
- FormElementTypes["contact"] = "contact";
19
- FormElementTypes["combobox"] = "combobox";
20
- FormElementTypes["formattedDate"] = "formattedDate";
21
- })(FormElementTypes || (FormElementTypes = {}));
package/dist/esm/index.js DELETED
@@ -1 +0,0 @@
1
- export { FormElementTypes, } from "./form-types.js";
@@ -1,9 +0,0 @@
1
- export type Responses = {
2
- [key: string]: Response;
3
- };
4
- export type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
5
- export type FileInputResponse = {
6
- name: string | null;
7
- size: number | null;
8
- based64EncodedFile: string | null;
9
- };
@@ -1,2 +0,0 @@
1
- export { FormElementTypes, type dynamicRowType, type FormElement, type Group, type ElementProperties, type PropertyChoices, type BrandProperties, type DeliveryOption, type ConditionalRule, type FormRecord, type SecurityAttribute, type FormPurpose, type PublicFormRecord, type ValidationProperties, type FormProperties, type AddressComponents, type ClosedDetails, } from "./form-types.js";
2
- export type { Response, Responses, FileInputResponse } from "./form-response-types.js";