@defra/forms-model 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/component-types.js +201 -219
- package/dist/browser/components/component-types.js.map +1 -1
- package/dist/browser/components/conditional-component-types.js +9 -27
- package/dist/browser/components/conditional-component-types.js.map +1 -1
- package/dist/browser/components/enums.js +27 -45
- package/dist/browser/components/enums.js.map +1 -1
- package/dist/browser/components/index.js +3 -35
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/components/types.js +1 -15
- package/dist/browser/conditions/condition-abstract.js +42 -60
- package/dist/browser/conditions/condition-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-field.js +23 -41
- package/dist/browser/conditions/condition-field.js.map +1 -1
- package/dist/browser/conditions/condition-group-def.js +23 -42
- package/dist/browser/conditions/condition-group-def.js.map +1 -1
- package/dist/browser/conditions/condition-group.js +43 -61
- package/dist/browser/conditions/condition-group.js.map +1 -1
- package/dist/browser/conditions/condition-model.js +185 -196
- package/dist/browser/conditions/condition-model.js.map +1 -1
- package/dist/browser/conditions/condition-operators.js +103 -124
- package/dist/browser/conditions/condition-operators.js.map +1 -1
- package/dist/browser/conditions/condition-ref.js +29 -47
- package/dist/browser/conditions/condition-ref.js.map +1 -1
- package/dist/browser/conditions/condition-value-abstract.js +19 -37
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-value-registration.js +15 -34
- package/dist/browser/conditions/condition-value-registration.js.map +1 -1
- package/dist/browser/conditions/condition-values.js +98 -118
- package/dist/browser/conditions/condition-values.js.map +1 -1
- package/dist/browser/conditions/condition.js +36 -51
- package/dist/browser/conditions/condition.js.map +1 -1
- package/dist/browser/conditions/enums.js +5 -23
- package/dist/browser/conditions/enums.js.map +1 -1
- package/dist/browser/conditions/helpers.js +6 -25
- package/dist/browser/conditions/helpers.js.map +1 -1
- package/dist/browser/conditions/index.js +10 -143
- package/dist/browser/conditions/index.js.map +1 -1
- package/dist/browser/conditions/inline-condition-model.js +372 -394
- package/dist/browser/conditions/inline-condition-model.js.map +1 -1
- package/dist/browser/conditions/inline-condition-operators.js +103 -124
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -1
- package/dist/browser/conditions/inline-condition-values.js +123 -145
- package/dist/browser/conditions/inline-condition-values.js.map +1 -1
- package/dist/browser/conditions/types.js +1 -15
- package/dist/browser/conditions/types.js.map +1 -1
- package/dist/browser/data-model/conditions-wrapper.js +27 -45
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -1
- package/dist/browser/data-model/enums.js +6 -24
- package/dist/browser/data-model/enums.js.map +1 -1
- package/dist/browser/data-model/index.js +3 -35
- package/dist/browser/data-model/index.js.map +1 -1
- package/dist/browser/data-model/input-wrapper.js +28 -46
- package/dist/browser/data-model/input-wrapper.js.map +1 -1
- package/dist/browser/data-model/types.js +7 -25
- package/dist/browser/data-model/types.js.map +1 -1
- package/dist/browser/form/form-configuration.js +16 -35
- package/dist/browser/form/form-configuration.js.map +1 -1
- package/dist/browser/form/index.js +1 -23
- package/dist/browser/form/index.js.map +1 -1
- package/dist/browser/index.js +8 -97
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/migration/index.js +1 -23
- package/dist/browser/migration/index.js.map +1 -1
- package/dist/browser/migration/migration.0-2.js +42 -60
- package/dist/browser/migration/migration.0-2.js.map +1 -1
- package/dist/browser/migration/migration.1-2.js +83 -99
- package/dist/browser/migration/migration.1-2.js.map +1 -1
- package/dist/browser/migration/types.js +1 -15
- package/dist/browser/migration/whichMigrations.js +20 -36
- package/dist/browser/migration/whichMigrations.js.map +1 -1
- package/dist/browser/schema/index.js +1 -29
- package/dist/browser/schema/index.js.map +1 -1
- package/dist/browser/schema/schema.js +231 -249
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/utils/helpers.js +22 -43
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/logger.js +24 -43
- package/dist/browser/utils/logger.js.map +1 -1
- package/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +1 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +1 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +1 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"input-wrapper.js","names":["InputWrapper","constructor","rawData","page","options","_defineProperty","undefined","_classPrivateFieldInitSpec","
|
1
|
+
{"version":3,"file":"input-wrapper.js","names":["clone","_parentItemName","WeakMap","InputWrapper","constructor","rawData","page","options","_defineProperty","undefined","_classPrivateFieldInitSpec","Object","assign","myPage","components","propertyPath","ignoreSection","section","name","_classPrivateFieldSet","parentItemName","displayName","titleWithContext","_classPrivateFieldGet","title"],"sources":["../../../src/data-model/input-wrapper.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type Page } from '~/src/data-model/types.js'\nimport { clone } from '~/src/utils/helpers.js'\n\nexport class InputWrapper {\n name: string | undefined = undefined\n title: string | undefined = undefined\n type: string | undefined = undefined\n propertyPath: string | undefined\n #parentItemName: string | undefined\n page: Page\n\n constructor(\n rawData: ComponentDef,\n page: Page,\n options: { ignoreSection?: boolean; parentItemName?: string }\n ) {\n Object.assign(this, rawData)\n const myPage = clone(page)\n\n delete myPage.components\n\n this.page = myPage\n this.propertyPath =\n !options.ignoreSection && page.section\n ? `${page.section}.${this.name}`\n : this.name\n this.#parentItemName = options.parentItemName\n }\n\n get displayName(): string | undefined {\n const titleWithContext = this.#parentItemName\n ? `${this.title} under ${this.#parentItemName}`\n : this.title\n\n return this.page.section\n ? `${titleWithContext} in ${this.page.section}`\n : titleWithContext\n }\n}\n"],"mappings":";;;;;;;;AAEA,SAASA,KAAK;AAAgC,IAAAC,eAAA,oBAAAC,OAAA;AAE9C,OAAO,MAAMC,YAAY,CAAC;EAQxBC,WAAWA,CACTC,OAAqB,EACrBC,IAAU,EACVC,OAA6D,EAC7D;IAAAC,eAAA,eAXyBC,SAAS;IAAAD,eAAA,gBACRC,SAAS;IAAAD,eAAA,eACVC,SAAS;IAAAD,eAAA;IAAAE,0BAAA,OAAAT,eAAA;IAAAO,eAAA;IAUlCG,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEP,OAAO,CAAC;IAC5B,MAAMQ,MAAM,GAAGb,KAAK,CAACM,IAAI,CAAC;IAE1B,OAAOO,MAAM,CAACC,UAAU;IAExB,IAAI,CAACR,IAAI,GAAGO,MAAM;IAClB,IAAI,CAACE,YAAY,GACf,CAACR,OAAO,CAACS,aAAa,IAAIV,IAAI,CAACW,OAAO,GACjC,GAAEX,IAAI,CAACW,OAAQ,IAAG,IAAI,CAACC,IAAK,EAAC,GAC9B,IAAI,CAACA,IAAI;IACfC,qBAAA,CAAAlB,eAAA,MAAI,EAAmBM,OAAO,CAACa,cAAc;EAC/C;EAEA,IAAIC,WAAWA,CAAA,EAAuB;IACpC,MAAMC,gBAAgB,GAAGC,qBAAA,CAAAtB,eAAA,MAAI,IACxB,GAAE,IAAI,CAACuB,KAAM,UAAOD,qBAAA,CAAAtB,eAAA,EAAE,IAAI,CAAiB,EAAC,GAC7C,IAAI,CAACuB,KAAK;IAEd,OAAO,IAAI,CAAClB,IAAI,CAACW,OAAO,GACnB,GAAEK,gBAAiB,OAAM,IAAI,CAAChB,IAAI,CAACW,OAAQ,EAAC,GAC7CK,gBAAgB;EACtB;AACF"}
|
@@ -1,27 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
factory(exports);
|
6
|
-
} else {
|
7
|
-
var mod = {
|
8
|
-
exports: {}
|
9
|
-
};
|
10
|
-
factory(mod.exports);
|
11
|
-
global.types = mod.exports;
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
|
14
|
-
"use strict";
|
1
|
+
export function isMultipleApiKey(payApiKey) {
|
2
|
+
const obj = payApiKey;
|
3
|
+
return obj.test !== undefined || obj.production !== undefined;
|
4
|
+
}
|
15
5
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const obj = payApiKey;
|
20
|
-
return obj.test !== undefined || obj.production !== undefined;
|
21
|
-
}
|
22
|
-
|
23
|
-
/**
|
24
|
-
* `FormDefinition` is a typescript representation of `Schema`
|
25
|
-
*/
|
26
|
-
});
|
6
|
+
/**
|
7
|
+
* `FormDefinition` is a typescript representation of `Schema`
|
8
|
+
*/
|
27
9
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":["isMultipleApiKey","payApiKey","obj","test","undefined","production"],"sources":["../../../src/data-model/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types'\nimport { type Condition } from '~/src/conditions/condition'\nimport { type OutputType } from '~/src/data-model/enums'\n\ntype Toggleable<T> = boolean | T\n\nexport interface Next {\n path: string\n condition?: string\n}\nexport type Link = Next\n\nexport interface Page {\n title: string\n path: string\n controller: string\n components?: ComponentDef[]\n section: string // the section ID\n next?: { path: string; condition?: string }[]\n}\n\nexport interface RepeatingFieldPage extends Page {\n controller: 'RepeatingFieldPageController'\n options: {\n summaryDisplayMode?: {\n samePage?: boolean\n separatePage?: boolean\n hideRowTitles?: boolean\n }\n customText?: {\n separatePageTitle?: string\n }\n }\n}\n\nexport interface Section {\n name: string\n title: string\n hideTitle: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: 'string' | 'number' | 'boolean'\n items: Item[]\n}\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport type PhaseBanner = {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport type MultipleApiKeys = {\n test?: string\n production?: string\n}\n\nexport type EmailOutputConfiguration = {\n emailAddress: string\n}\n\nexport type NotifyOutputConfiguration = {\n apiKey: string\n templateId: string\n emailField: string\n personalisation: string[]\n personalisationFieldCustomisation?: {\n [personalisationName: string]: string[]\n }\n addReferencesToPersonalisation?: boolean\n emailReplyToIdConfiguration?: {\n emailReplyToId: string\n condition?: string | undefined\n }[]\n}\n\nexport type WebhookOutputConfiguration = {\n url: string\n}\n\nexport type OutputConfiguration =\n | EmailOutputConfiguration\n | NotifyOutputConfiguration\n | WebhookOutputConfiguration\n\nexport type Output = {\n name: string\n title: string\n type: OutputType\n outputConfiguration: OutputConfiguration\n}\n\nexport type ConfirmationPage = {\n customText: {\n title: string\n paymentSkipped: Toggleable<string>\n nextSteps: Toggleable<string>\n }\n components: ComponentDef[]\n}\n\nexport type PaymentSkippedWarningPage = {\n customText: {\n title: string\n caption: string\n body: string\n }\n}\n\nexport type SpecialPages = {\n confirmationPage?: ConfirmationPage\n paymentSkippedWarningPage?: PaymentSkippedWarningPage\n}\n\nexport function isMultipleApiKey(\n payApiKey: string | MultipleApiKeys | undefined\n): payApiKey is MultipleApiKeys {\n const obj = payApiKey as MultipleApiKeys\n return obj.test !== undefined || obj.production !== undefined\n}\n\nexport type Fee = {\n description: string\n amount: number\n multiplier?: string\n condition?: string\n prefix?: string\n}\n\nexport type FeeOptions = {\n paymentReferenceFormat?: string\n payReturnUrl?: string\n allowSubmissionWithoutPayment: boolean\n maxAttempts: number\n customPayErrorMessage?: string\n showPaymentSkippedWarningPage: boolean\n}\n\nexport type ConditionWrapperValue =\n | string\n | {\n name: string\n conditions: Condition[]\n }\n\nexport type ConditionRawData = {\n name: string\n displayName: string\n value: ConditionWrapperValue\n}\n\n/**\n * `FormDefinition` is a typescript representation of `Schema`\n */\nexport type FormDefinition = {\n pages: Array<Page | RepeatingFieldPage>\n conditions: ConditionRawData[]\n lists: List[]\n sections: Section[]\n startPage?: Page['path'] | undefined\n name?: string | undefined\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n fees: Fee[]\n skipSummary?: boolean | undefined\n outputs: Output[]\n declaration?: string | undefined\n metadata?: Record<string, any>\n payApiKey?: string | MultipleApiKeys | undefined\n specialPages?: SpecialPages\n paymentReferenceFormat?: string\n feeOptions: FeeOptions\n}\n"],"mappings":"
|
1
|
+
{"version":3,"file":"types.js","names":["isMultipleApiKey","payApiKey","obj","test","undefined","production"],"sources":["../../../src/data-model/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type Condition } from '~/src/conditions/condition.js'\nimport { type OutputType } from '~/src/data-model/enums.js'\n\ntype Toggleable<T> = boolean | T\n\nexport interface Next {\n path: string\n condition?: string\n}\nexport type Link = Next\n\nexport interface Page {\n title: string\n path: string\n controller: string\n components?: ComponentDef[]\n section: string // the section ID\n next?: { path: string; condition?: string }[]\n}\n\nexport interface RepeatingFieldPage extends Page {\n controller: 'RepeatingFieldPageController'\n options: {\n summaryDisplayMode?: {\n samePage?: boolean\n separatePage?: boolean\n hideRowTitles?: boolean\n }\n customText?: {\n separatePageTitle?: string\n }\n }\n}\n\nexport interface Section {\n name: string\n title: string\n hideTitle: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: 'string' | 'number' | 'boolean'\n items: Item[]\n}\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport type PhaseBanner = {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport type MultipleApiKeys = {\n test?: string\n production?: string\n}\n\nexport type EmailOutputConfiguration = {\n emailAddress: string\n}\n\nexport type NotifyOutputConfiguration = {\n apiKey: string\n templateId: string\n emailField: string\n personalisation: string[]\n personalisationFieldCustomisation?: {\n [personalisationName: string]: string[]\n }\n addReferencesToPersonalisation?: boolean\n emailReplyToIdConfiguration?: {\n emailReplyToId: string\n condition?: string | undefined\n }[]\n}\n\nexport type WebhookOutputConfiguration = {\n url: string\n}\n\nexport type OutputConfiguration =\n | EmailOutputConfiguration\n | NotifyOutputConfiguration\n | WebhookOutputConfiguration\n\nexport type Output = {\n name: string\n title: string\n type: OutputType\n outputConfiguration: OutputConfiguration\n}\n\nexport type ConfirmationPage = {\n customText: {\n title: string\n paymentSkipped: Toggleable<string>\n nextSteps: Toggleable<string>\n }\n components: ComponentDef[]\n}\n\nexport type PaymentSkippedWarningPage = {\n customText: {\n title: string\n caption: string\n body: string\n }\n}\n\nexport type SpecialPages = {\n confirmationPage?: ConfirmationPage\n paymentSkippedWarningPage?: PaymentSkippedWarningPage\n}\n\nexport function isMultipleApiKey(\n payApiKey: string | MultipleApiKeys | undefined\n): payApiKey is MultipleApiKeys {\n const obj = payApiKey as MultipleApiKeys\n return obj.test !== undefined || obj.production !== undefined\n}\n\nexport type Fee = {\n description: string\n amount: number\n multiplier?: string\n condition?: string\n prefix?: string\n}\n\nexport type FeeOptions = {\n paymentReferenceFormat?: string\n payReturnUrl?: string\n allowSubmissionWithoutPayment: boolean\n maxAttempts: number\n customPayErrorMessage?: string\n showPaymentSkippedWarningPage: boolean\n}\n\nexport type ConditionWrapperValue =\n | string\n | {\n name: string\n conditions: Condition[]\n }\n\nexport type ConditionRawData = {\n name: string\n displayName: string\n value: ConditionWrapperValue\n}\n\n/**\n * `FormDefinition` is a typescript representation of `Schema`\n */\nexport type FormDefinition = {\n pages: Array<Page | RepeatingFieldPage>\n conditions: ConditionRawData[]\n lists: List[]\n sections: Section[]\n startPage?: Page['path'] | undefined\n name?: string | undefined\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n fees: Fee[]\n skipSummary?: boolean | undefined\n outputs: Output[]\n declaration?: string | undefined\n metadata?: Record<string, any>\n payApiKey?: string | MultipleApiKeys | undefined\n specialPages?: SpecialPages\n paymentReferenceFormat?: string\n feeOptions: FeeOptions\n}\n"],"mappings":"AAgIA,OAAO,SAASA,gBAAgBA,CAC9BC,SAA+C,EACjB;EAC9B,MAAMC,GAAG,GAAGD,SAA4B;EACxC,OAAOC,GAAG,CAACC,IAAI,KAAKC,SAAS,IAAIF,GAAG,CAACG,UAAU,KAAKD,SAAS;AAC/D;;AAgCA;AACA;AACA"}
|
@@ -1,38 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
_exports.FormConfiguration = void 0;
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
20
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
21
|
-
class FormConfiguration {
|
22
|
-
constructor(Key, DisplayName, LastModified, feedbackForm) {
|
23
|
-
_defineProperty(this, "Key", void 0);
|
24
|
-
_defineProperty(this, "DisplayName", void 0);
|
25
|
-
_defineProperty(this, "LastModified", void 0);
|
26
|
-
_defineProperty(this, "feedbackForm", void 0);
|
27
|
-
if (!Key) {
|
28
|
-
throw Error('Form configuration must have a key');
|
29
|
-
}
|
30
|
-
this.Key = Key;
|
31
|
-
this.DisplayName = DisplayName || Key;
|
32
|
-
this.LastModified = LastModified;
|
33
|
-
this.feedbackForm = feedbackForm || false;
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
export class FormConfiguration {
|
5
|
+
constructor(Key, DisplayName, LastModified, feedbackForm) {
|
6
|
+
_defineProperty(this, "Key", void 0);
|
7
|
+
_defineProperty(this, "DisplayName", void 0);
|
8
|
+
_defineProperty(this, "LastModified", void 0);
|
9
|
+
_defineProperty(this, "feedbackForm", void 0);
|
10
|
+
if (!Key) {
|
11
|
+
throw Error('Form configuration must have a key');
|
34
12
|
}
|
13
|
+
this.Key = Key;
|
14
|
+
this.DisplayName = DisplayName || Key;
|
15
|
+
this.LastModified = LastModified;
|
16
|
+
this.feedbackForm = feedbackForm || false;
|
35
17
|
}
|
36
|
-
|
37
|
-
});
|
18
|
+
}
|
38
19
|
//# sourceMappingURL=form-configuration.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"form-configuration.js","names":["FormConfiguration","constructor","Key","DisplayName","LastModified","feedbackForm","_defineProperty","Error"
|
1
|
+
{"version":3,"file":"form-configuration.js","names":["FormConfiguration","constructor","Key","DisplayName","LastModified","feedbackForm","_defineProperty","Error"],"sources":["../../../src/form/form-configuration.ts"],"sourcesContent":["export class FormConfiguration {\n Key: string\n DisplayName: string\n LastModified: string | undefined\n feedbackForm: boolean | undefined\n\n constructor(\n Key: string,\n DisplayName?: string,\n LastModified?: string,\n feedbackForm?: boolean\n ) {\n if (!Key) {\n throw Error('Form configuration must have a key')\n }\n this.Key = Key\n this.DisplayName = DisplayName || Key\n this.LastModified = LastModified\n this.feedbackForm = feedbackForm || false\n }\n}\n"],"mappings":";;;AAAA,OAAO,MAAMA,iBAAiB,CAAC;EAM7BC,WAAWA,CACTC,GAAW,EACXC,WAAoB,EACpBC,YAAqB,EACrBC,YAAsB,EACtB;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACA,IAAI,CAACJ,GAAG,EAAE;MACR,MAAMK,KAAK,CAAC,oCAAoC,CAAC;IACnD;IACA,IAAI,CAACL,GAAG,GAAGA,GAAG;IACd,IAAI,CAACC,WAAW,GAAGA,WAAW,IAAID,GAAG;IACrC,IAAI,CAACE,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,YAAY,GAAGA,YAAY,IAAI,KAAK;EAC3C;AACF"}
|
@@ -1,24 +1,2 @@
|
|
1
|
-
|
2
|
-
if (typeof define === "function" && define.amd) {
|
3
|
-
define(["exports", "./form-configuration"], factory);
|
4
|
-
} else if (typeof exports !== "undefined") {
|
5
|
-
factory(exports, require("./form-configuration"));
|
6
|
-
} else {
|
7
|
-
var mod = {
|
8
|
-
exports: {}
|
9
|
-
};
|
10
|
-
factory(mod.exports, global.formConfiguration);
|
11
|
-
global.index = mod.exports;
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _formConfiguration) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
Object.defineProperty(_exports, "FormConfiguration", {
|
18
|
-
enumerable: true,
|
19
|
-
get: function () {
|
20
|
-
return _formConfiguration.FormConfiguration;
|
21
|
-
}
|
22
|
-
});
|
23
|
-
});
|
1
|
+
export { FormConfiguration } from "./form-configuration.js";
|
24
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/form/index.ts"],"sourcesContent":["export { FormConfiguration } from '~/src/form/form-configuration'\n"],"mappings":""}
|
1
|
+
{"version":3,"file":"index.js","names":["FormConfiguration"],"sources":["../../../src/form/index.ts"],"sourcesContent":["export { FormConfiguration } from '~/src/form/form-configuration.js'\n"],"mappings":"AAAA,SAASA,iBAAiB"}
|
package/dist/browser/index.js
CHANGED
@@ -1,98 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
};
|
10
|
-
factory(mod.exports, global.schema, global.dataModel, global.logger, global.form, global.components, global.conditions, global.helpers, global.migration);
|
11
|
-
global.index = mod.exports;
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _schema, _dataModel, _logger, _form, _components, _conditions, _helpers, _migration) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
Object.keys(_schema).forEach(function (key) {
|
18
|
-
if (key === "default" || key === "__esModule") return;
|
19
|
-
if (key in _exports && _exports[key] === _schema[key]) return;
|
20
|
-
Object.defineProperty(_exports, key, {
|
21
|
-
enumerable: true,
|
22
|
-
get: function () {
|
23
|
-
return _schema[key];
|
24
|
-
}
|
25
|
-
});
|
26
|
-
});
|
27
|
-
Object.keys(_dataModel).forEach(function (key) {
|
28
|
-
if (key === "default" || key === "__esModule") return;
|
29
|
-
if (key in _exports && _exports[key] === _dataModel[key]) return;
|
30
|
-
Object.defineProperty(_exports, key, {
|
31
|
-
enumerable: true,
|
32
|
-
get: function () {
|
33
|
-
return _dataModel[key];
|
34
|
-
}
|
35
|
-
});
|
36
|
-
});
|
37
|
-
Object.keys(_logger).forEach(function (key) {
|
38
|
-
if (key === "default" || key === "__esModule") return;
|
39
|
-
if (key in _exports && _exports[key] === _logger[key]) return;
|
40
|
-
Object.defineProperty(_exports, key, {
|
41
|
-
enumerable: true,
|
42
|
-
get: function () {
|
43
|
-
return _logger[key];
|
44
|
-
}
|
45
|
-
});
|
46
|
-
});
|
47
|
-
Object.keys(_form).forEach(function (key) {
|
48
|
-
if (key === "default" || key === "__esModule") return;
|
49
|
-
if (key in _exports && _exports[key] === _form[key]) return;
|
50
|
-
Object.defineProperty(_exports, key, {
|
51
|
-
enumerable: true,
|
52
|
-
get: function () {
|
53
|
-
return _form[key];
|
54
|
-
}
|
55
|
-
});
|
56
|
-
});
|
57
|
-
Object.keys(_components).forEach(function (key) {
|
58
|
-
if (key === "default" || key === "__esModule") return;
|
59
|
-
if (key in _exports && _exports[key] === _components[key]) return;
|
60
|
-
Object.defineProperty(_exports, key, {
|
61
|
-
enumerable: true,
|
62
|
-
get: function () {
|
63
|
-
return _components[key];
|
64
|
-
}
|
65
|
-
});
|
66
|
-
});
|
67
|
-
Object.keys(_conditions).forEach(function (key) {
|
68
|
-
if (key === "default" || key === "__esModule") return;
|
69
|
-
if (key in _exports && _exports[key] === _conditions[key]) return;
|
70
|
-
Object.defineProperty(_exports, key, {
|
71
|
-
enumerable: true,
|
72
|
-
get: function () {
|
73
|
-
return _conditions[key];
|
74
|
-
}
|
75
|
-
});
|
76
|
-
});
|
77
|
-
Object.keys(_helpers).forEach(function (key) {
|
78
|
-
if (key === "default" || key === "__esModule") return;
|
79
|
-
if (key in _exports && _exports[key] === _helpers[key]) return;
|
80
|
-
Object.defineProperty(_exports, key, {
|
81
|
-
enumerable: true,
|
82
|
-
get: function () {
|
83
|
-
return _helpers[key];
|
84
|
-
}
|
85
|
-
});
|
86
|
-
});
|
87
|
-
Object.keys(_migration).forEach(function (key) {
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
89
|
-
if (key in _exports && _exports[key] === _migration[key]) return;
|
90
|
-
Object.defineProperty(_exports, key, {
|
91
|
-
enumerable: true,
|
92
|
-
get: function () {
|
93
|
-
return _migration[key];
|
94
|
-
}
|
95
|
-
});
|
96
|
-
});
|
97
|
-
});
|
1
|
+
export * from "./schema/index.js";
|
2
|
+
export * from "./data-model/index.js";
|
3
|
+
export * from "./utils/logger.js";
|
4
|
+
export * from "./form/index.js";
|
5
|
+
export * from "./components/index.js";
|
6
|
+
export * from "./conditions/index.js";
|
7
|
+
export * from "./utils/helpers.js";
|
8
|
+
export * from "./migration/index.js";
|
98
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/schema/index.js'\nexport * from '~/src/data-model/index.js'\nexport * from '~/src/utils/logger.js'\nexport * from '~/src/form/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/utils/helpers.js'\nexport * from '~/src/migration/index.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/data-model/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
@@ -1,24 +1,2 @@
|
|
1
|
-
|
2
|
-
if (typeof define === "function" && define.amd) {
|
3
|
-
define(["exports", "./whichMigrations"], factory);
|
4
|
-
} else if (typeof exports !== "undefined") {
|
5
|
-
factory(exports, require("./whichMigrations"));
|
6
|
-
} else {
|
7
|
-
var mod = {
|
8
|
-
exports: {}
|
9
|
-
};
|
10
|
-
factory(mod.exports, global.whichMigrations);
|
11
|
-
global.index = mod.exports;
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _whichMigrations) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
Object.defineProperty(_exports, "whichMigrations", {
|
18
|
-
enumerable: true,
|
19
|
-
get: function () {
|
20
|
-
return _whichMigrations.whichMigrations;
|
21
|
-
}
|
22
|
-
});
|
23
|
-
});
|
1
|
+
export { whichMigrations } from "./whichMigrations.js";
|
24
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/migration/index.ts"],"sourcesContent":["export { whichMigrations } from '~/src/migration/whichMigrations'\n"],"mappings":""}
|
1
|
+
{"version":3,"file":"index.js","names":["whichMigrations"],"sources":["../../../src/migration/index.ts"],"sourcesContent":["export { whichMigrations } from '~/src/migration/whichMigrations.js'\n"],"mappings":"AAAA,SAASA,eAAe"}
|
@@ -1,65 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const _excluded = ["list"];
|
19
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
20
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
25
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
26
|
-
function needsUpgrade(data) {
|
27
|
-
var _data$pages;
|
28
|
-
return !!((_data$pages = data.pages) !== null && _data$pages !== void 0 ? _data$pages : []).flatMap(page => page.components).find(component => {
|
29
|
-
var _component$options;
|
30
|
-
return (_component$options = component.options) === null || _component$options === void 0 ? void 0 : _component$options.list;
|
31
|
-
});
|
32
|
-
}
|
33
|
-
function migrate(data) {
|
34
|
-
if (!needsUpgrade(data)) {
|
35
|
-
return _objectSpread(_objectSpread({}, data), {}, {
|
36
|
-
version: 2
|
37
|
-
});
|
38
|
-
}
|
39
|
-
const {
|
40
|
-
pages
|
41
|
-
} = data;
|
42
|
-
const newPages = pages.flatMap(page => {
|
43
|
-
return page.components.map(component => {
|
44
|
-
var _component$options2;
|
45
|
-
if (!((_component$options2 = component.options) !== null && _component$options2 !== void 0 && _component$options2.list)) {
|
46
|
-
return component;
|
47
|
-
}
|
48
|
-
const _component$options3 = component.options,
|
49
|
-
{
|
50
|
-
list
|
51
|
-
} = _component$options3,
|
52
|
-
rest = _objectWithoutProperties(_component$options3, _excluded);
|
53
|
-
return _objectSpread(_objectSpread({}, component), {}, {
|
54
|
-
list,
|
55
|
-
options: _objectSpread({}, rest)
|
56
|
-
});
|
57
|
-
});
|
58
|
-
});
|
1
|
+
const _excluded = ["list"];
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
8
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
9
|
+
function needsUpgrade(data) {
|
10
|
+
var _data$pages;
|
11
|
+
return !!((_data$pages = data.pages) !== null && _data$pages !== void 0 ? _data$pages : []).flatMap(page => page.components).find(component => {
|
12
|
+
var _component$options;
|
13
|
+
return (_component$options = component.options) === null || _component$options === void 0 ? void 0 : _component$options.list;
|
14
|
+
});
|
15
|
+
}
|
16
|
+
export function migrate(data) {
|
17
|
+
if (!needsUpgrade(data)) {
|
59
18
|
return _objectSpread(_objectSpread({}, data), {}, {
|
60
|
-
pages: newPages,
|
61
19
|
version: 2
|
62
20
|
});
|
63
21
|
}
|
64
|
-
|
22
|
+
const {
|
23
|
+
pages
|
24
|
+
} = data;
|
25
|
+
const newPages = pages.flatMap(page => {
|
26
|
+
return page.components.map(component => {
|
27
|
+
var _component$options2;
|
28
|
+
if (!((_component$options2 = component.options) !== null && _component$options2 !== void 0 && _component$options2.list)) {
|
29
|
+
return component;
|
30
|
+
}
|
31
|
+
const _component$options3 = component.options,
|
32
|
+
{
|
33
|
+
list
|
34
|
+
} = _component$options3,
|
35
|
+
rest = _objectWithoutProperties(_component$options3, _excluded);
|
36
|
+
return _objectSpread(_objectSpread({}, component), {}, {
|
37
|
+
list,
|
38
|
+
options: _objectSpread({}, rest)
|
39
|
+
});
|
40
|
+
});
|
41
|
+
});
|
42
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
43
|
+
pages: newPages,
|
44
|
+
version: 2
|
45
|
+
});
|
46
|
+
}
|
65
47
|
//# sourceMappingURL=migration.0-2.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migration.0-2.js","names":["needsUpgrade","data","_data$pages","pages","flatMap","page","components","find","component","_component$options","options","list","migrate","_objectSpread","version","newPages","map","_component$options2","_component$options3","rest","_objectWithoutProperties","_excluded"],"sources":["../../../src/migration/migration.0-2.ts"],"sourcesContent":["import { type MigrationScript } from '~/src/migration/types'\n\nfunction needsUpgrade(data) {\n return !!(data.pages ?? [])\n .flatMap((page) => page.components)\n .find((component) => component.options?.list)\n}\n\nexport function migrate(data): MigrationScript {\n if (!needsUpgrade(data)) {\n return { ...data, version: 2 }\n }\n const { pages } = data\n const newPages = pages.flatMap((page) => {\n return page.components.map((component) => {\n if (!component.options?.list) {\n return component\n }\n const { list, ...rest } = component.options\n return { ...component, list, options: { ...rest } }\n })\n })\n\n return {\n ...data,\n pages: newPages,\n version: 2\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"file":"migration.0-2.js","names":["needsUpgrade","data","_data$pages","pages","flatMap","page","components","find","component","_component$options","options","list","migrate","_objectSpread","version","newPages","map","_component$options2","_component$options3","rest","_objectWithoutProperties","_excluded"],"sources":["../../../src/migration/migration.0-2.ts"],"sourcesContent":["import { type MigrationScript } from '~/src/migration/types.js'\n\nfunction needsUpgrade(data) {\n return !!(data.pages ?? [])\n .flatMap((page) => page.components)\n .find((component) => component.options?.list)\n}\n\nexport function migrate(data): MigrationScript {\n if (!needsUpgrade(data)) {\n return { ...data, version: 2 }\n }\n const { pages } = data\n const newPages = pages.flatMap((page) => {\n return page.components.map((component) => {\n if (!component.options?.list) {\n return component\n }\n const { list, ...rest } = component.options\n return { ...component, list, options: { ...rest } }\n })\n })\n\n return {\n ...data,\n pages: newPages,\n version: 2\n }\n}\n"],"mappings":";;;;;;;;AAEA,SAASA,YAAYA,CAACC,IAAI,EAAE;EAAA,IAAAC,WAAA;EAC1B,OAAO,CAAC,CAAC,EAAAA,WAAA,GAACD,IAAI,CAACE,KAAK,cAAAD,WAAA,cAAAA,WAAA,GAAI,EAAE,EACvBE,OAAO,CAAEC,IAAI,IAAKA,IAAI,CAACC,UAAU,CAAC,CAClCC,IAAI,CAAEC,SAAS;IAAA,IAAAC,kBAAA;IAAA,QAAAA,kBAAA,GAAKD,SAAS,CAACE,OAAO,cAAAD,kBAAA,uBAAjBA,kBAAA,CAAmBE,IAAI;EAAA,EAAC;AACjD;AAEA,OAAO,SAASC,OAAOA,CAACX,IAAI,EAAmB;EAC7C,IAAI,CAACD,YAAY,CAACC,IAAI,CAAC,EAAE;IACvB,OAAAY,aAAA,CAAAA,aAAA,KAAYZ,IAAI;MAAEa,OAAO,EAAE;IAAC;EAC9B;EACA,MAAM;IAAEX;EAAM,CAAC,GAAGF,IAAI;EACtB,MAAMc,QAAQ,GAAGZ,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAK;IACvC,OAAOA,IAAI,CAACC,UAAU,CAACU,GAAG,CAAER,SAAS,IAAK;MAAA,IAAAS,mBAAA;MACxC,IAAI,GAAAA,mBAAA,GAACT,SAAS,CAACE,OAAO,cAAAO,mBAAA,eAAjBA,mBAAA,CAAmBN,IAAI,GAAE;QAC5B,OAAOH,SAAS;MAClB;MACA,MAAAU,mBAAA,GAA0BV,SAAS,CAACE,OAAO;QAArC;UAAEC;QAAc,CAAC,GAAAO,mBAAA;QAANC,IAAI,GAAAC,wBAAA,CAAAF,mBAAA,EAAAG,SAAA;MACrB,OAAAR,aAAA,CAAAA,aAAA,KAAYL,SAAS;QAAEG,IAAI;QAAED,OAAO,EAAAG,aAAA,KAAOM,IAAI;MAAE;IACnD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAAN,aAAA,CAAAA,aAAA,KACKZ,IAAI;IACPE,KAAK,EAAEY,QAAQ;IACfD,OAAO,EAAE;EAAC;AAEd"}
|