@gcforms/types 0.0.1 → 0.0.2

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