diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.ddb.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.ddb.ts new file mode 100644 index 00000000000..fad02b3d26e --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.ddb.ts @@ -0,0 +1,3351 @@ +export const user = { + id: "admin", + type: "admin", + displayName: "Admin" +}; + +export const createFormsData = () => { + return [ + // Form with 1 revision published + { + PK: "T#root#L#en-US#FB#F#65c0a07038a36e00082095ea", + SK: "L", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "fi0rrnUHdl" + } + ], + formId: "65c0a07038a36e00082095ea", + id: "65c0a07038a36e00082095ea#0001", + locale: "en-US", + locked: true, + name: "Demo form 1", + ownedBy: user, + published: true, + publishedOn: "2024-02-05T08:47:01.134Z", + savedOn: "2024-02-05T08:47:01.134Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65c0a07038a36e00082095ea", + stats: { + submissions: 5000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["fi0rrnUHdl"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-05T08:47:01.152Z", + _et: "FormBuilderForm", + _md: "2024-02-05T08:47:01.152Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c0a07038a36e00082095ea", + SK: "LP", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "fi0rrnUHdl" + } + ], + formId: "65c0a07038a36e00082095ea", + id: "65c0a07038a36e00082095ea#0001", + locale: "en-US", + locked: true, + name: "Demo form 1", + ownedBy: user, + published: true, + publishedOn: "2024-02-05T08:47:01.134Z", + savedOn: "2024-02-05T08:47:01.134Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65c0a07038a36e00082095ea", + stats: { + submissions: 5000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["fi0rrnUHdl"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-05T08:47:01.152Z", + _et: "FormBuilderForm", + _md: "2024-02-05T08:47:01.152Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c0a07038a36e00082095ea", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "fi0rrnUHdl" + } + ], + formId: "65c0a07038a36e00082095ea", + id: "65c0a07038a36e00082095ea#0001", + locale: "en-US", + locked: true, + name: "Demo form 1", + ownedBy: user, + published: true, + publishedOn: "2024-02-05T08:47:01.134Z", + savedOn: "2024-02-05T08:47:01.134Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65c0a07038a36e00082095ea", + stats: { + submissions: 5000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["fi0rrnUHdl"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-05T08:47:01.152Z", + _et: "FormBuilderForm", + _md: "2024-02-05T08:47:01.152Z" + }, + + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#FB#F#65c479873ff56c0008735714", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T06:50:17.141Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "QwlAelzDaq" + } + ], + formId: "65c479873ff56c0008735714", + id: "65c479873ff56c0008735714#0002", + locale: "en-US", + locked: false, + name: "Demo form 2", + ownedBy: user, + published: false, + savedOn: "2024-02-08T06:50:17.141Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65c479873ff56c0008735714", + stats: { + submissions: 500, + views: 1000 + }, + status: "draft", + steps: [ + { + layout: [["QwlAelzDaq"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-02-08T06:50:17.141Z", + _et: "FormBuilderForm", + _md: "2024-02-08T06:50:17.141Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c479873ff56c0008735714", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "QwlAelzDaq" + } + ], + formId: "65c479873ff56c0008735714", + id: "65c479873ff56c0008735714#0001", + locale: "en-US", + locked: true, + name: "Demo form 2", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T06:50:06.306Z", + savedOn: "2024-02-08T06:50:06.306Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65c479873ff56c0008735714", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["QwlAelzDaq"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T06:50:06.311Z", + _et: "FormBuilderForm", + _md: "2024-02-08T06:50:06.311Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c479873ff56c0008735714", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "QwlAelzDaq" + } + ], + formId: "65c479873ff56c0008735714", + id: "65c479873ff56c0008735714#0001", + locale: "en-US", + locked: true, + name: "Demo form 2", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T06:50:06.306Z", + savedOn: "2024-02-08T06:50:06.306Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65c479873ff56c0008735714", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["QwlAelzDaq"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T06:50:06.311Z", + _et: "FormBuilderForm", + _md: "2024-02-08T06:50:06.311Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c479873ff56c0008735714", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-02-08T06:50:17.141Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "QwlAelzDaq" + } + ], + formId: "65c479873ff56c0008735714", + id: "65c479873ff56c0008735714#0002", + locale: "en-US", + locked: false, + name: "Demo form 2", + ownedBy: user, + published: false, + savedOn: "2024-02-08T06:50:17.141Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65c479873ff56c0008735714", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["QwlAelzDaq"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-02-08T06:50:17.141Z", + _et: "FormBuilderForm", + _md: "2024-02-08T06:50:17.141Z" + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#FB#F#65c492e1766cb000084357d1", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T08:37:53.951Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "Ua0cd7oJZD" + } + ], + formId: "65c492e1766cb000084357d1", + id: "65c492e1766cb000084357d1#0001", + locale: "en-US", + locked: false, + name: "Demo form 3", + ownedBy: user, + published: false, + savedOn: "2024-02-08T08:38:06.346Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65c492e1766cb000084357d1", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["Ua0cd7oJZD"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T08:38:06.352Z", + _et: "FormBuilderForm", + _md: "2024-02-08T08:38:06.352Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c492e1766cb000084357d1", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T08:37:53.951Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "Ua0cd7oJZD" + } + ], + formId: "65c492e1766cb000084357d1", + id: "65c492e1766cb000084357d1#0001", + locale: "en-US", + locked: false, + name: "Demo form 3", + ownedBy: user, + published: false, + savedOn: "2024-02-08T08:38:06.346Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65c492e1766cb000084357d1", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["Ua0cd7oJZD"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T08:38:06.352Z", + _et: "FormBuilderForm", + _md: "2024-02-08T08:38:06.352Z" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T09:06:08.967Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0004", + locale: "en-US", + locked: false, + name: "Demo form 4", + ownedBy: user, + published: false, + savedOn: "2024-02-08T09:06:08.967Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 4, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:06:08.967Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:06:08.967Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T09:05:37.331Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0002", + locale: "en-US", + locked: true, + name: "Demo form 4", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T09:05:41.633Z", + savedOn: "2024-02-08T09:05:41.633Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 10000, + views: 20000 + }, + status: "published", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:05:41.646Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:05:41.646Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0001", + locale: "en-US", + locked: true, + name: "Demo form 4", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T09:05:30.590Z", + savedOn: "2024-02-08T09:05:30.590Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:05:30.595Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:05:30.595Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-02-08T09:05:37.331Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0002", + locale: "en-US", + locked: true, + name: "Demo form 4", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T09:05:41.633Z", + savedOn: "2024-02-08T09:05:41.633Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 10000, + views: 20000 + }, + status: "published", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:05:41.646Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:05:41.646Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "REV#0003", + createdBy: user, + createdOn: "2024-02-08T09:05:49.726Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0003", + locale: "en-US", + locked: true, + name: "Demo form 4", + ownedBy: user, + published: false, + publishedOn: "2024-02-08T09:05:57.306Z", + savedOn: "2024-02-08T09:06:04.286Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 200, + views: 1000 + }, + status: "locked", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 3, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:06:04.326Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:06:04.326Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4994929b99b0008bd6167", + SK: "REV#0004", + createdBy: user, + createdOn: "2024-02-08T09:06:08.967Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "h4WRtUvT1t" + } + ], + formId: "65c4994929b99b0008bd6167", + id: "65c4994929b99b0008bd6167#0004", + locale: "en-US", + locked: false, + name: "Demo form 4", + ownedBy: user, + published: false, + savedOn: "2024-02-08T09:06:08.967Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65c4994929b99b0008bd6167", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["h4WRtUvT1t"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 4, + webinyVersion: "0.0.0", + _ct: "2024-02-08T09:06:08.967Z", + _et: "FormBuilderForm", + _md: "2024-02-08T09:06:08.967Z" + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#FB#F#65c4a67e371e020008a5a8cb", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + fields: [ + { + fieldId: "firstName", + helpText: null, + label: "First name", + name: "firstName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "LdjAJR41d" + }, + { + fieldId: "lastName", + helpText: null, + label: "Last name", + name: "lastName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "UNZrnwfMR" + }, + { + fieldId: "email", + helpText: null, + label: "Email", + name: "email", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid e-mail.", + name: "pattern", + settings: { + flags: null, + preset: "email", + regex: null + } + }, + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "r6fATib8h" + }, + { + fieldId: "phoneNumber", + helpText: null, + label: "Phone number", + name: "phoneNumber", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "aQH7A-jP8" + }, + { + fieldId: "website", + helpText: null, + label: "Website", + name: "website", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid URL.", + name: "pattern", + settings: { + flags: null, + preset: "url", + regex: null + } + } + ], + _id: "Di_Wwktpk" + } + ], + formId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + locale: "en-US", + locked: true, + name: "Demo form 5", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T10:02:12.516Z", + savedOn: "2024-02-08T10:02:12.516Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-5-65c4a67e371e020008a5a8cb", + stats: { + submissions: 1000, + views: 5000 + }, + status: "published", + steps: [ + { + layout: [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + title: "Step 1" + }, + { + layout: [["aQH7A-jP8"], ["Di_Wwktpk"]], + title: "Step 2" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T10:02:12.532Z", + _et: "FormBuilderForm", + _md: "2024-02-08T10:02:12.532Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4a67e371e020008a5a8cb", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + fields: [ + { + fieldId: "firstName", + helpText: null, + label: "First name", + name: "firstName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "LdjAJR41d" + }, + { + fieldId: "lastName", + helpText: null, + label: "Last name", + name: "lastName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "UNZrnwfMR" + }, + { + fieldId: "email", + helpText: null, + label: "Email", + name: "email", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid e-mail.", + name: "pattern", + settings: { + flags: null, + preset: "email", + regex: null + } + }, + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "r6fATib8h" + }, + { + fieldId: "phoneNumber", + helpText: null, + label: "Phone number", + name: "phoneNumber", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "aQH7A-jP8" + }, + { + fieldId: "website", + helpText: null, + label: "Website", + name: "website", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid URL.", + name: "pattern", + settings: { + flags: null, + preset: "url", + regex: null + } + } + ], + _id: "Di_Wwktpk" + } + ], + formId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + locale: "en-US", + locked: true, + name: "Demo form 5", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T10:02:12.516Z", + savedOn: "2024-02-08T10:02:12.516Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-5-65c4a67e371e020008a5a8cb", + stats: { + submissions: 1000, + views: 5000 + }, + status: "published", + steps: [ + { + layout: [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + title: "Step 1" + }, + { + layout: [["aQH7A-jP8"], ["Di_Wwktpk"]], + title: "Step 2" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T10:02:12.532Z", + _et: "FormBuilderForm", + _md: "2024-02-08T10:02:12.532Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4a67e371e020008a5a8cb", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + fields: [ + { + fieldId: "firstName", + helpText: null, + label: "First name", + name: "firstName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "LdjAJR41d" + }, + { + fieldId: "lastName", + helpText: null, + label: "Last name", + name: "lastName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "UNZrnwfMR" + }, + { + fieldId: "email", + helpText: null, + label: "Email", + name: "email", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid e-mail.", + name: "pattern", + settings: { + flags: null, + preset: "email", + regex: null + } + }, + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "r6fATib8h" + }, + { + fieldId: "phoneNumber", + helpText: null, + label: "Phone number", + name: "phoneNumber", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "aQH7A-jP8" + }, + { + fieldId: "website", + helpText: null, + label: "Website", + name: "website", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid URL.", + name: "pattern", + settings: { + flags: null, + preset: "url", + regex: null + } + } + ], + _id: "Di_Wwktpk" + } + ], + formId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + locale: "en-US", + locked: true, + name: "Demo form 5", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T10:02:12.516Z", + savedOn: "2024-02-08T10:02:12.516Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-5-65c4a67e371e020008a5a8cb", + stats: { + submissions: 1000, + views: 5000 + }, + status: "published", + steps: [ + { + layout: [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + title: "Step 1" + }, + { + layout: [["aQH7A-jP8"], ["Di_Wwktpk"]], + title: "Step 2" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T10:02:12.532Z", + _et: "FormBuilderForm", + _md: "2024-02-08T10:02:12.532Z" + }, + + // Form with default fields + { + PK: "T#root#L#en-US#FB#F#65c4c9d05e7aad0008b21715", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + fields: [ + { + fieldId: "hiddenField", + helpText: "Hidden field help text", + label: "Hidden field", + name: "hidden", + options: [], + placeholderText: null, + settings: { + defaultValue: "Hidden field default value" + }, + type: "hidden", + validation: [], + _id: "iSDmskA_Tt" + }, + { + fieldId: "selectField", + helpText: "Select field help text", + label: "Select field", + name: "select", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: "Select field placeholder text", + settings: { + defaultValue: "option2" + }, + type: "select", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "CBZ0tNIQaV" + }, + { + fieldId: "shortText", + helpText: "Short text help text", + label: "Short text", + name: "text", + options: [], + placeholderText: "Short text placeholder text", + settings: { + defaultValue: "Short text default value" + }, + type: "text", + validation: [], + _id: "B8dDiYSSRF" + }, + { + fieldId: "longText", + helpText: "Long text help text", + label: "Long text", + name: "textarea", + options: [], + placeholderText: "Long text placeholder text", + settings: { + defaultValue: "Long text default value", + rows: "10" + }, + type: "textarea", + validation: [ + { + message: "Value is too short.", + name: "minLength", + settings: { + value: "1" + } + }, + { + message: "Value is too long.", + name: "maxLength", + settings: { + value: "100" + } + } + ], + _id: "iDfaI8P1dZ" + }, + { + fieldId: "numberField", + helpText: "Number field help text", + label: "Number field", + name: "number", + options: [], + placeholderText: "Number field placeholder text", + settings: { + defaultValue: null + }, + type: "number", + validation: [], + _id: "KR1AHgvW1L" + }, + { + fieldId: "radioField", + helpText: "Radio field help text", + label: "Radio field", + name: "radio", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: "option2", + otherOption: true + }, + type: "radio", + validation: [], + _id: "pUgH-pWnkW" + }, + { + fieldId: "checkboxesField", + helpText: "Checkboxes field help text", + label: "Checkboxes field", + name: "checkbox", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: ["option2"], + otherOption: true + }, + type: "checkbox", + validation: [], + _id: "nFYVV5X8Tn" + }, + { + fieldId: "dateTimeField", + helpText: "DateTime field help text", + label: "DateTime field", + name: "date", + options: [], + placeholderText: null, + settings: { + defaultValue: null, + format: "date" + }, + type: "datetime", + validation: [], + _id: "P0dxAwg20f" + } + ], + formId: "65c4c9d05e7aad0008b21715", + id: "65c4c9d05e7aad0008b21715#0001", + locale: "en-US", + locked: true, + name: "Demo form 6", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T12:36:36.667Z", + savedOn: "2024-02-08T12:36:36.667Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-6-65c4c9d05e7aad0008b21715", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T12:36:36.672Z", + _et: "FormBuilderForm", + _md: "2024-02-08T12:36:36.672Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4c9d05e7aad0008b21715", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + fields: [ + { + fieldId: "hiddenField", + helpText: "Hidden field help text", + label: "Hidden field", + name: "hidden", + options: [], + placeholderText: null, + settings: { + defaultValue: "Hidden field default value" + }, + type: "hidden", + validation: [], + _id: "iSDmskA_Tt" + }, + { + fieldId: "selectField", + helpText: "Select field help text", + label: "Select field", + name: "select", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: "Select field placeholder text", + settings: { + defaultValue: "option2" + }, + type: "select", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "CBZ0tNIQaV" + }, + { + fieldId: "shortText", + helpText: "Short text help text", + label: "Short text", + name: "text", + options: [], + placeholderText: "Short text placeholder text", + settings: { + defaultValue: "Short text default value" + }, + type: "text", + validation: [], + _id: "B8dDiYSSRF" + }, + { + fieldId: "longText", + helpText: "Long text help text", + label: "Long text", + name: "textarea", + options: [], + placeholderText: "Long text placeholder text", + settings: { + defaultValue: "Long text default value", + rows: "10" + }, + type: "textarea", + validation: [ + { + message: "Value is too short.", + name: "minLength", + settings: { + value: "1" + } + }, + { + message: "Value is too long.", + name: "maxLength", + settings: { + value: "100" + } + } + ], + _id: "iDfaI8P1dZ" + }, + { + fieldId: "numberField", + helpText: "Number field help text", + label: "Number field", + name: "number", + options: [], + placeholderText: "Number field placeholder text", + settings: { + defaultValue: null + }, + type: "number", + validation: [], + _id: "KR1AHgvW1L" + }, + { + fieldId: "radioField", + helpText: "Radio field help text", + label: "Radio field", + name: "radio", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: "option2", + otherOption: true + }, + type: "radio", + validation: [], + _id: "pUgH-pWnkW" + }, + { + fieldId: "checkboxesField", + helpText: "Checkboxes field help text", + label: "Checkboxes field", + name: "checkbox", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: ["option2"], + otherOption: true + }, + type: "checkbox", + validation: [], + _id: "nFYVV5X8Tn" + }, + { + fieldId: "dateTimeField", + helpText: "DateTime field help text", + label: "DateTime field", + name: "date", + options: [], + placeholderText: null, + settings: { + defaultValue: null, + format: "date" + }, + type: "datetime", + validation: [], + _id: "P0dxAwg20f" + } + ], + formId: "65c4c9d05e7aad0008b21715", + id: "65c4c9d05e7aad0008b21715#0001", + locale: "en-US", + locked: true, + name: "Demo form 6", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T12:36:36.667Z", + savedOn: "2024-02-08T12:36:36.667Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-6-65c4c9d05e7aad0008b21715", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T12:36:36.672Z", + _et: "FormBuilderForm", + _md: "2024-02-08T12:36:36.672Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4c9d05e7aad0008b21715", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + fields: [ + { + fieldId: "hiddenField", + helpText: "Hidden field help text", + label: "Hidden field", + name: "hidden", + options: [], + placeholderText: null, + settings: { + defaultValue: "Hidden field default value" + }, + type: "hidden", + validation: [], + _id: "iSDmskA_Tt" + }, + { + fieldId: "selectField", + helpText: "Select field help text", + label: "Select field", + name: "select", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: "Select field placeholder text", + settings: { + defaultValue: "option2" + }, + type: "select", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "CBZ0tNIQaV" + }, + { + fieldId: "shortText", + helpText: "Short text help text", + label: "Short text", + name: "text", + options: [], + placeholderText: "Short text placeholder text", + settings: { + defaultValue: "Short text default value" + }, + type: "text", + validation: [], + _id: "B8dDiYSSRF" + }, + { + fieldId: "longText", + helpText: "Long text help text", + label: "Long text", + name: "textarea", + options: [], + placeholderText: "Long text placeholder text", + settings: { + defaultValue: "Long text default value", + rows: "10" + }, + type: "textarea", + validation: [ + { + message: "Value is too short.", + name: "minLength", + settings: { + value: "1" + } + }, + { + message: "Value is too long.", + name: "maxLength", + settings: { + value: "100" + } + } + ], + _id: "iDfaI8P1dZ" + }, + { + fieldId: "numberField", + helpText: "Number field help text", + label: "Number field", + name: "number", + options: [], + placeholderText: "Number field placeholder text", + settings: { + defaultValue: null + }, + type: "number", + validation: [], + _id: "KR1AHgvW1L" + }, + { + fieldId: "radioField", + helpText: "Radio field help text", + label: "Radio field", + name: "radio", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: "option2", + otherOption: true + }, + type: "radio", + validation: [], + _id: "pUgH-pWnkW" + }, + { + fieldId: "checkboxesField", + helpText: "Checkboxes field help text", + label: "Checkboxes field", + name: "checkbox", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: ["option2"], + otherOption: true + }, + type: "checkbox", + validation: [], + _id: "nFYVV5X8Tn" + }, + { + fieldId: "dateTimeField", + helpText: "DateTime field help text", + label: "DateTime field", + name: "date", + options: [], + placeholderText: null, + settings: { + defaultValue: null, + format: "date" + }, + type: "datetime", + validation: [], + _id: "P0dxAwg20f" + } + ], + formId: "65c4c9d05e7aad0008b21715", + id: "65c4c9d05e7aad0008b21715#0001", + locale: "en-US", + locked: true, + name: "Demo form 6", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T12:36:36.667Z", + savedOn: "2024-02-08T12:36:36.667Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-6-65c4c9d05e7aad0008b21715", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T12:36:36.672Z", + _et: "FormBuilderForm", + _md: "2024-02-08T12:36:36.672Z" + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#FB#F#65c4d1dfb0bf8a00087fbcd6", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T13:06:39.264Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "ItPh6LB1jL" + } + ], + formId: "65c4d1dfb0bf8a00087fbcd6", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + locale: "en-US", + locked: false, + name: "Demo form 7", + ownedBy: user, + published: false, + savedOn: "2024-02-08T13:07:56.618Z", + settings: { + fullWidthSubmitButton: true, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: "Custom submit button label", + successMessage: [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "A6l0TC3oER", + type: "paragraph" + } + ], + termsOfServiceMessage: { + enabled: true, + errorMessage: "Custom error message", + message: [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "3UTfrPvarm", + type: "paragraph" + } + ] + } + }, + slug: "demo-form-7-65c4d1dfb0bf8a00087fbcd6", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["ItPh6LB1jL"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T13:07:56.623Z", + _et: "FormBuilderForm", + _md: "2024-02-08T13:07:56.623Z" + }, + { + PK: "T#root#L#en-US#FB#F#65c4d1dfb0bf8a00087fbcd6", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T13:06:39.264Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "ItPh6LB1jL" + } + ], + formId: "65c4d1dfb0bf8a00087fbcd6", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + locale: "en-US", + locked: false, + name: "Demo form 7", + ownedBy: user, + published: false, + savedOn: "2024-02-08T13:07:56.618Z", + settings: { + fullWidthSubmitButton: true, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: "Custom submit button label", + successMessage: [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "A6l0TC3oER", + type: "paragraph" + } + ], + termsOfServiceMessage: { + enabled: true, + errorMessage: "Custom error message", + message: [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "3UTfrPvarm", + type: "paragraph" + } + ] + } + }, + slug: "demo-form-7-65c4d1dfb0bf8a00087fbcd6", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["ItPh6LB1jL"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T13:07:56.623Z", + _et: "FormBuilderForm", + _md: "2024-02-08T13:07:56.623Z" + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1e9", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6kr" + } + ], + formId: "65c4ea4ac04244000878b1e9", + id: "65c4ea4ac04244000878b1e9#0001", + locale: "de-DE", + locked: true, + name: "Demo form 8", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-8-65c4ea4ac04244000878b1e9", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6kr"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1e9", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6kr" + } + ], + formId: "65c4ea4ac04244000878b1e9", + id: "65c4ea4ac04244000878b1e9#0001", + locale: "de-DE", + locked: true, + name: "Demo form 8", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-8-65c4ea4ac04244000878b1e9", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6kr"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1e9", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6kr" + } + ], + formId: "65c4ea4ac04244000878b1e9", + id: "65c4ea4ac04244000878b1e9#0001", + locale: "de-DE", + locked: true, + name: "Demo form 8", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-8-65c4ea4ac04244000878b1e9", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6kr"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1f0", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6l3" + } + ], + formId: "65c4ea4ac04244000878b1f0", + id: "65c4ea4ac04244000878b1f0#0001", + locale: "de-DE", + locked: true, + name: "Demo form 9", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65c4ea4ac04244000878b1f0", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6l3"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1f0", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6l3" + } + ], + formId: "65c4ea4ac04244000878b1f0", + id: "65c4ea4ac04244000878b1f0#0001", + locale: "de-DE", + locked: true, + name: "Demo form 9", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65c4ea4ac04244000878b1f0", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6l3"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#de-DE#FB#F#65c4ea4ac04244000878b1f0", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6l3" + } + ], + formId: "65c4ea4ac04244000878b1f0", + id: "65c4ea4ac04244000878b1f0#0001", + locale: "de-DE", + locked: true, + name: "Demo form 9", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65c4ea4ac04244000878b1f0", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6l3"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#FB#F#65c4ea4ac04244000878b1f1", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6m2" + } + ], + formId: "65c4ea4ac04244000878b1f1", + id: "65c4ea4ac04244000878b1f1#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 10", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-10-65c4ea4ac04244000878b1f1", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6m2"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#fr-FR#FB#F#65c4ea4ac04244000878b1f1", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6m2" + } + ], + formId: "65c4ea4ac04244000878b1f1", + id: "65c4ea4ac04244000878b1f1#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 10", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-10-65c4ea4ac04244000878b1f1", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6m2"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#root#L#fr-FR#FB#F#65c4ea4ac04244000878b1f1", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0UDy6m2" + } + ], + formId: "65c4ea4ac04244000878b1f1", + id: "65c4ea4ac04244000878b1f1#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 10", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-10-65c4ea4ac04244000878b1f1", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0UDy6m2"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + + // Form 1 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f2", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0VQh3n5" + } + ], + formId: "65c4ea4ac04244000878b1f2", + id: "65c4ea4ac04244000878b1f2#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 11", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65c4ea4ac04244000878b1f2", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0VQh3n5"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f2", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0VQh3n5" + } + ], + formId: "65c4ea4ac04244000878b1f2", + id: "65c4ea4ac04244000878b1f2#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 11", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65c4ea4ac04244000878b1f2", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0VQh3n5"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f2", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0VQh3n5" + } + ], + formId: "65c4ea4ac04244000878b1f2", + id: "65c4ea4ac04244000878b1f2#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 11", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65c4ea4ac04244000878b1f2", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0VQh3n5"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + + // Form 2 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f3", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0Tj8p4z" + } + ], + formId: "65c4ea4ac04244000878b1f3", + id: "65c4ea4ac04244000878b1f3#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 12", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-12-65c4ea4ac04244000878b1f3", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0Tj8p4z"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f3", + SK: "LP", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0Tj8p4z" + } + ], + formId: "65c4ea4ac04244000878b1f3", + id: "65c4ea4ac04244000878b1f3#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 12", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-12-65c4ea4ac04244000878b1f3", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0Tj8p4z"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F#65c4ea4ac04244000878b1f3", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "-WO0Tj8p4z" + } + ], + formId: "65c4ea4ac04244000878b1f3", + id: "65c4ea4ac04244000878b1f3#0001", + locale: "fr-FR", + locked: true, + name: "Demo form 12", + ownedBy: user, + published: true, + publishedOn: "2024-02-08T14:51:05.869Z", + savedOn: "2024-02-08T14:51:05.869Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-12-65c4ea4ac04244000878b1f3", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["-WO0Tj8p4z"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-02-08T14:51:05.877Z", + _et: "FormBuilderForm", + _md: "2024-02-08T14:51:05.877Z" + } + ]; +}; + +export const createTenantsData = () => { + return [ + { + PK: "T#root", + SK: "A", + createdOn: "2023-01-25T09:37:58.183Z", + description: "The top-level Webiny tenant.", + GSI1_PK: "TENANTS", + GSI1_SK: "T#null#2023-01-25T09:37:58.183Z", + data: { + id: "root", + name: "Root", + savedOn: "2023-01-25T09:37:58.183Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + }, + { + PK: "T#otherTenant", + SK: "A", + createdOn: "2023-03-11T09:59:17.327Z", + description: "Tenant #1", + GSI1_PK: "TENANTS", + GSI1_SK: "T#root#2023-03-11T09:59:17.327Z", + data: { + id: "otherTenant", + name: "Other Tenant", + parent: "root", + savedOn: "2023-03-11T09:59:17.327Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + } + ]; +}; + +export const createLocalesData = () => { + return [ + { + PK: `T#root#I18N#L`, + SK: "en-US", + code: "en-US", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + } + ]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.es.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.es.ts new file mode 100644 index 00000000000..6acc44ca98c --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.es.ts @@ -0,0 +1,255 @@ +import { user } from "./001.ddb"; + +export const createEsFormsData = () => { + return [ + // Form with 1 revision published + { + formId: "65c0a07038a36e00082095ea", + savedOn: "2024-02-05T08:47:01.134Z", + publishedOn: "2024-02-05T08:47:01.134Z", + published: true, + locale: "en-US", + createdOn: "2024-02-05T08:46:40.354Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 1", + id: "65c0a07038a36e00082095ea#0001", + locked: true, + ownedBy: user, + slug: "demo-form-1-65c0a07038a36e00082095ea", + tenant: "root", + status: "published" + }, + + // Form with 2 revisions: 1° published, 2° draft + { + formId: "65c479873ff56c0008735714", + savedOn: "2024-02-08T06:50:17.141Z", + publishedOn: null, + published: false, + locale: "en-US", + createdOn: "2024-02-08T06:50:17.141Z", + version: 2, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 2", + id: "65c479873ff56c0008735714#0002", + locked: false, + ownedBy: user, + slug: "demo-form-2-65c479873ff56c0008735714", + tenant: "root", + status: "draft" + }, + + // Form with 1 draft revision + { + formId: "65c492e1766cb000084357d1", + savedOn: "2024-02-08T08:38:06.346Z", + published: false, + locale: "en-US", + createdOn: "2024-02-08T08:37:53.951Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 3", + id: "65c492e1766cb000084357d1#0001", + locked: false, + ownedBy: user, + slug: "demo-form-3-65c492e1766cb000084357d1", + tenant: "root", + status: "draft" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + formId: "65c4994929b99b0008bd6167", + savedOn: "2024-02-08T09:06:08.967Z", + publishedOn: null, + published: false, + locale: "en-US", + createdOn: "2024-02-08T09:06:08.967Z", + version: 4, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 4", + id: "65c4994929b99b0008bd6167#0004", + locked: false, + ownedBy: user, + slug: "demo-form-4-65c4994929b99b0008bd6167", + tenant: "root", + status: "draft" + }, + + // Form with contact fields, required, organised in 2 steps + { + formId: "65c4a67e371e020008a5a8cb", + savedOn: "2024-02-08T10:02:12.516Z", + publishedOn: "2024-02-08T10:02:12.516Z", + published: true, + locale: "en-US", + createdOn: "2024-02-08T10:01:34.873Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 5", + id: "65c4a67e371e020008a5a8cb#0001", + locked: true, + ownedBy: user, + slug: "demo-form-5-65c4a67e371e020008a5a8cb", + tenant: "root", + status: "published" + }, + + // Form with default fields + { + formId: "65c4c9d05e7aad0008b21715", + savedOn: "2024-02-08T12:36:36.667Z", + publishedOn: "2024-02-08T12:36:36.667Z", + published: true, + locale: "en-US", + createdOn: "2024-02-08T12:32:16.133Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 6", + id: "65c4c9d05e7aad0008b21715#0001", + locked: true, + ownedBy: user, + slug: "demo-form-6-65c4c9d05e7aad0008b21715", + tenant: "root", + status: "published" + }, + + // Form with custom settings + { + formId: "65c4d1dfb0bf8a00087fbcd6", + savedOn: "2024-02-08T13:07:56.618Z", + published: false, + locale: "en-US", + createdOn: "2024-02-08T13:06:39.264Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 7", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + locked: false, + ownedBy: user, + slug: "demo-form-7-65c4d1dfb0bf8a00087fbcd6", + tenant: "root", + status: "draft" + }, + + // Form 1 from root tenant, locale de-DE + { + formId: "65c4ea4ac04244000878b1e9", + savedOn: "2024-02-08T14:51:05.869Z", + publishedOn: "2024-02-08T14:51:05.869Z", + published: true, + locale: "de-DE", + createdOn: "2024-02-08T14:50:50.570Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 8", + id: "65c4ea4ac04244000878b1e9#0001", + locked: true, + ownedBy: user, + slug: "demo-form-8-65c4ea4ac04244000878b1e9", + tenant: "root", + status: "published" + }, + + // Form 2 from root tenant, locale de-DE + { + formId: "65c4ea4ac04244000878b1f0", + savedOn: "2024-02-08T14:51:05.869Z", + publishedOn: "2024-02-08T14:51:05.869Z", + published: true, + locale: "de-DE", + createdOn: "2024-02-08T14:50:50.570Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 9", + id: "65c4ea4ac04244000878b1f0#0001", + locked: true, + ownedBy: user, + slug: "demo-form-9-65c4ea4ac04244000878b1f0", + tenant: "root", + status: "published" + }, + + // Form 1 from root tenant, locale fr-FR + { + formId: "65c4ea4ac04244000878b1f1", + savedOn: "2024-02-08T14:51:05.869Z", + publishedOn: "2024-02-08T14:51:05.869Z", + published: true, + locale: "fr-FR", + createdOn: "2024-02-08T14:50:50.570Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 10", + id: "65c4ea4ac04244000878b1f1#0001", + locked: true, + ownedBy: user, + slug: "demo-form-10-65c4ea4ac04244000878b1f1", + tenant: "root", + status: "published" + }, + + // Form 1 from otherTenant, locale fr-FR + { + formId: "65c4ea4ac04244000878b1f2", + savedOn: "2024-02-08T14:51:05.869Z", + publishedOn: "2024-02-08T14:51:05.869Z", + published: true, + locale: "fr-FR", + createdOn: "2024-02-08T14:50:50.570Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 11", + id: "65c4ea4ac04244000878b1f2#0001", + locked: true, + ownedBy: user, + slug: "demo-form-11-65c4ea4ac04244000878b1f2", + tenant: "otherTenant", + status: "published" + }, + + // Form 2 from otherTenant, locale fr-FR + { + formId: "65c4ea4ac04244000878b1f3", + savedOn: "2024-02-08T14:51:05.869Z", + publishedOn: "2024-02-08T14:51:05.869Z", + published: true, + locale: "fr-FR", + createdOn: "2024-02-08T14:50:50.570Z", + version: 1, + createdBy: user, + webinyVersion: "0.0.0", + __type: "fb.form", + name: "Demo form 12", + id: "65c4ea4ac04244000878b1f3#0001", + locked: true, + ownedBy: user, + slug: "demo-form-12-65c4ea4ac04244000878b1f3", + tenant: "otherTenant", + status: "published" + } + ]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddb.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddb.ts new file mode 100644 index 00000000000..5355a1a60a5 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddb.ts @@ -0,0 +1,3828 @@ +import { createFormsData, user } from "./001.ddb"; + +export const migratedDdbFormData = [ + // Form with 1 revision published + { + PK: "T#root#L#en-US#CMS#CME#65c0a07038a36e00082095ea", + SK: "L", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + entryId: "65c0a07038a36e00082095ea", + firstPublishedBy: user, + firstPublishedOn: "2024-02-05T08:47:01.134Z", + id: "65c0a07038a36e00082095ea#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-05T08:47:01.134Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-05T08:47:01.134Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-05T08:46:40.354Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-05T08:47:01.134Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-05T08:47:01.134Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-05T08:47:01.134Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-05T08:47:01.134Z", + savedBy: user, + savedOn: "2024-02-05T08:47:01.134Z", + status: "published", + tenant: "root", + values: { + "json@triggers": null, + "object@fields": [ + { + "object@options": [], + "text@helpText": null, + "text@placeholderText": null, + "json@settings": { + defaultValue: null + }, + "object@validation": [], + "text@fieldId": "demoField", + "text@label": "Demo field", + "text@name": "text", + "text@type": "text", + "text@_id": "fi0rrnUHdl" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["fi0rrnUHdl"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c0a07038a36e00082095ea", + "text@name": "Demo form 1", + "text@slug": "demo-form-1-65c0a07038a36e00082095ea" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c0a07038a36e00082095ea", + SK: "P", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + entryId: "65c0a07038a36e00082095ea", + firstPublishedBy: user, + firstPublishedOn: "2024-02-05T08:47:01.134Z", + id: "65c0a07038a36e00082095ea#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-05T08:47:01.134Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-05T08:47:01.134Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-05T08:46:40.354Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-05T08:47:01.134Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-05T08:47:01.134Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-05T08:47:01.134Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-05T08:47:01.134Z", + savedBy: user, + savedOn: "2024-02-05T08:47:01.134Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "object@options": [], + "text@helpText": null, + "text@placeholderText": null, + "json@settings": { + defaultValue: null + }, + "object@validation": [], + "text@fieldId": "demoField", + "text@label": "Demo field", + "text@name": "text", + "text@type": "text", + "text@_id": "fi0rrnUHdl" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["fi0rrnUHdl"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c0a07038a36e00082095ea", + "text@name": "Demo form 1", + "text@slug": "demo-form-1-65c0a07038a36e00082095ea" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c0a07038a36e00082095ea", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-05T08:46:40.354Z", + entryId: "65c0a07038a36e00082095ea", + firstPublishedBy: user, + firstPublishedOn: "2024-02-05T08:47:01.134Z", + id: "65c0a07038a36e00082095ea#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-05T08:47:01.134Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-05T08:47:01.134Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-05T08:46:40.354Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-05T08:47:01.134Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-05T08:47:01.134Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-05T08:47:01.134Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-05T08:47:01.134Z", + savedBy: user, + savedOn: "2024-02-05T08:47:01.134Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "object@options": [], + "text@helpText": null, + "text@placeholderText": null, + "json@settings": { + defaultValue: null + }, + "object@validation": [], + "text@fieldId": "demoField", + "text@label": "Demo field", + "text@name": "text", + "text@type": "text", + "text@_id": "fi0rrnUHdl" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["fi0rrnUHdl"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c0a07038a36e00082095ea", + "text@name": "Demo form 1", + "text@slug": "demo-form-1-65c0a07038a36e00082095ea" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + entryId: "65c479873ff56c0008735714", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + id: "65c479873ff56c0008735714#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T06:50:06.306Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T06:50:17.141Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T06:50:17.141Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T06:50:17.141Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T06:50:17.141Z", + savedBy: user, + savedOn: "2024-02-08T06:50:17.141Z", + status: "draft", + tenant: "root", + + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "QwlAelzDaq" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["QwlAelzDaq"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + entryId: "65c479873ff56c0008735714", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + id: "65c479873ff56c0008735714#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T06:50:06.306Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T06:50:06.306Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T06:49:43.380Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T06:50:06.306Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T06:50:06.306Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T06:50:06.306Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T06:50:06.306Z", + savedBy: user, + savedOn: "2024-02-08T06:50:06.306Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "QwlAelzDaq" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["QwlAelzDaq"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + entryId: "65c479873ff56c0008735714", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + id: "65c479873ff56c0008735714#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T06:50:06.306Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T06:50:06.306Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T06:49:43.380Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T06:50:06.306Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T06:50:06.306Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T06:50:06.306Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T06:50:06.306Z", + savedBy: user, + savedOn: "2024-02-08T06:50:06.306Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "QwlAelzDaq" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["QwlAelzDaq"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-02-08T06:49:43.380Z", + entryId: "65c479873ff56c0008735714", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + id: "65c479873ff56c0008735714#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T06:50:06.306Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T06:50:17.141Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T06:50:17.141Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T06:50:17.141Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T06:50:17.141Z", + savedBy: user, + savedOn: "2024-02-08T06:50:17.141Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "QwlAelzDaq" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["QwlAelzDaq"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + version: 2, + webinyVersion: "0.0.0" + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#CMS#CME#65c492e1766cb000084357d1", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T08:37:53.951Z", + entryId: "65c492e1766cb000084357d1", + id: "65c492e1766cb000084357d1#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T08:38:06.346Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T08:37:53.951Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T08:38:06.346Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T08:38:06.346Z", + savedBy: user, + savedOn: "2024-02-08T08:38:06.346Z", + status: "draft", + tenant: "root", + + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Ua0cd7oJZD" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Ua0cd7oJZD"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c492e1766cb000084357d1", + "text@name": "Demo form 3", + "text@slug": "demo-form-3-65c492e1766cb000084357d1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c492e1766cb000084357d1", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T08:37:53.951Z", + entryId: "65c492e1766cb000084357d1", + id: "65c492e1766cb000084357d1#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T08:38:06.346Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T08:37:53.951Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T08:38:06.346Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T08:38:06.346Z", + savedBy: user, + savedOn: "2024-02-08T08:38:06.346Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Ua0cd7oJZD" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Ua0cd7oJZD"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c492e1766cb000084357d1", + "text@name": "Demo form 3", + "text@slug": "demo-form-3-65c492e1766cb000084357d1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0004", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:06:08.967Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:06:08.967Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:06:08.967Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:06:08.967Z", + savedBy: user, + savedOn: "2024-02-08T09:06:08.967Z", + status: "draft", + tenant: "root", + + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 4, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:05:41.633Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:05:37.331Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T09:05:41.633Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:05:41.633Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:05:41.633Z", + savedBy: user, + savedOn: "2024-02-08T09:05:41.633Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:05:30.590Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:05:13.764Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T09:05:41.633Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:05:30.590Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:05:30.590Z", + savedBy: user, + savedOn: "2024-02-08T09:05:30.590Z", + status: "unpublished", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:05:41.633Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:05:37.331Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T09:05:41.633Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:05:41.633Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:05:41.633Z", + savedBy: user, + savedOn: "2024-02-08T09:05:41.633Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "REV#0003", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0003", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:06:04.286Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:05:49.726Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T09:05:41.633Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:06:04.286Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:06:04.286Z", + savedBy: user, + savedOn: "2024-02-08T09:06:04.286Z", + status: "unpublished", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 3, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "REV#0004", + createdBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + entryId: "65c4994929b99b0008bd6167", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + id: "65c4994929b99b0008bd6167#0004", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T09:06:08.967Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T09:06:08.967Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T09:06:08.967Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T09:06:08.967Z", + savedBy: user, + savedOn: "2024-02-08T09:06:08.967Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "h4WRtUvT1t" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["h4WRtUvT1t"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + version: 4, + webinyVersion: "0.0.0" + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#CMS#CME#65c4a67e371e020008a5a8cb", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T10:02:12.516Z", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T10:02:12.516Z", + entryId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T10:02:12.516Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T10:01:34.873Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T10:02:12.516Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T10:02:12.516Z", + revisionLastPublishedBy: user, + savedBy: user, + savedOn: "2024-02-08T10:02:12.516Z", + status: "published", + tenant: "root", + + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "firstName", + "text@helpText": null, + "text@label": "First name", + "text@name": "firstName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "LdjAJR41d" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "lastName", + "text@helpText": null, + "text@label": "Last name", + "text@name": "lastName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "UNZrnwfMR" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "email", + regex: null + }, + "text@message": "Please enter a valid e-mail.", + "text@name": "pattern" + }, + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "email", + "text@helpText": null, + "text@label": "Email", + "text@name": "email", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "r6fATib8h" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "phoneNumber", + "text@helpText": null, + "text@label": "Phone number", + "text@name": "phoneNumber", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "aQH7A-jP8" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "url", + regex: null + }, + "text@message": "Please enter a valid URL.", + "text@name": "pattern" + } + ], + "text@fieldId": "website", + "text@helpText": null, + "text@label": "Website", + "text@name": "website", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Di_Wwktpk" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + "text@title": "Step 1" + }, + { + "json@layout": [["aQH7A-jP8"], ["Di_Wwktpk"]], + "text@title": "Step 2" + } + ], + "text@formId": "65c4a67e371e020008a5a8cb", + "text@name": "Demo form 5", + "text@slug": "demo-form-5-65c4a67e371e020008a5a8cb" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4a67e371e020008a5a8cb", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + entryId: "65c4a67e371e020008a5a8cb", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T10:02:12.516Z", + id: "65c4a67e371e020008a5a8cb#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T10:02:12.516Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T10:02:12.516Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T10:01:34.873Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T10:02:12.516Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T10:02:12.516Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T10:02:12.516Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T10:02:12.516Z", + savedBy: user, + savedOn: "2024-02-08T10:02:12.516Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "firstName", + "text@helpText": null, + "text@label": "First name", + "text@name": "firstName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "LdjAJR41d" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "lastName", + "text@helpText": null, + "text@label": "Last name", + "text@name": "lastName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "UNZrnwfMR" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "email", + regex: null + }, + "text@message": "Please enter a valid e-mail.", + "text@name": "pattern" + }, + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "email", + "text@helpText": null, + "text@label": "Email", + "text@name": "email", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "r6fATib8h" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "phoneNumber", + "text@helpText": null, + "text@label": "Phone number", + "text@name": "phoneNumber", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "aQH7A-jP8" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "url", + regex: null + }, + "text@message": "Please enter a valid URL.", + "text@name": "pattern" + } + ], + "text@fieldId": "website", + "text@helpText": null, + "text@label": "Website", + "text@name": "website", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Di_Wwktpk" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + "text@title": "Step 1" + }, + { + "json@layout": [["aQH7A-jP8"], ["Di_Wwktpk"]], + "text@title": "Step 2" + } + ], + "text@formId": "65c4a67e371e020008a5a8cb", + "text@name": "Demo form 5", + "text@slug": "demo-form-5-65c4a67e371e020008a5a8cb" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4a67e371e020008a5a8cb", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T10:01:34.873Z", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T10:02:12.516Z", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T10:02:12.516Z", + entryId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T10:02:12.516Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T10:01:34.873Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T10:02:12.516Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T10:02:12.516Z", + revisionLastPublishedBy: user, + savedBy: user, + savedOn: "2024-02-08T10:02:12.516Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "firstName", + "text@helpText": null, + "text@label": "First name", + "text@name": "firstName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "LdjAJR41d" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "lastName", + "text@helpText": null, + "text@label": "Last name", + "text@name": "lastName", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "UNZrnwfMR" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "email", + regex: null + }, + "text@message": "Please enter a valid e-mail.", + "text@name": "pattern" + }, + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "email", + "text@helpText": null, + "text@label": "Email", + "text@name": "email", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "r6fATib8h" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "phoneNumber", + "text@helpText": null, + "text@label": "Phone number", + "text@name": "phoneNumber", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "aQH7A-jP8" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "url", + regex: null + }, + "text@message": "Please enter a valid URL.", + "text@name": "pattern" + } + ], + "text@fieldId": "website", + "text@helpText": null, + "text@label": "Website", + "text@name": "website", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Di_Wwktpk" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]], + "text@title": "Step 1" + }, + { + "json@layout": [["aQH7A-jP8"], ["Di_Wwktpk"]], + "text@title": "Step 2" + } + ], + "text@formId": "65c4a67e371e020008a5a8cb", + "text@name": "Demo form 5", + "text@slug": "demo-form-5-65c4a67e371e020008a5a8cb" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with default fields + { + PK: "T#root#L#en-US#CMS#CME#65c4c9d05e7aad0008b21715", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + entryId: "65c4c9d05e7aad0008b21715", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T12:36:36.667Z", + id: "65c4c9d05e7aad0008b21715#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T12:36:36.667Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T12:36:36.667Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T12:32:16.133Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T12:36:36.667Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T12:36:36.667Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T12:36:36.667Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T12:36:36.667Z", + savedBy: user, + savedOn: "2024-02-08T12:36:36.667Z", + status: "published", + tenant: "root", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: "Hidden field default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "hiddenField", + "text@helpText": "Hidden field help text", + "text@label": "Hidden field", + "text@name": "hidden", + "text@placeholderText": null, + "text@type": "hidden", + "text@_id": "iSDmskA_Tt" + }, + { + "json@settings": { + defaultValue: "option2" + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "selectField", + "text@helpText": "Select field help text", + "text@label": "Select field", + "text@name": "select", + "text@placeholderText": "Select field placeholder text", + "text@type": "select", + "text@_id": "CBZ0tNIQaV" + }, + { + "json@settings": { + defaultValue: "Short text default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "shortText", + "text@helpText": "Short text help text", + "text@label": "Short text", + "text@name": "text", + "text@placeholderText": "Short text placeholder text", + "text@type": "text", + "text@_id": "B8dDiYSSRF" + }, + { + "json@settings": { + defaultValue: "Long text default value", + rows: "10" + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + value: "1" + }, + "text@message": "Value is too short.", + "text@name": "minLength" + }, + { + "json@settings": { + value: "100" + }, + "text@message": "Value is too long.", + "text@name": "maxLength" + } + ], + "text@fieldId": "longText", + "text@helpText": "Long text help text", + "text@label": "Long text", + "text@name": "textarea", + "text@placeholderText": "Long text placeholder text", + "text@type": "textarea", + "text@_id": "iDfaI8P1dZ" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "numberField", + "text@helpText": "Number field help text", + "text@label": "Number field", + "text@name": "number", + "text@placeholderText": "Number field placeholder text", + "text@type": "number", + "text@_id": "KR1AHgvW1L" + }, + { + "json@settings": { + defaultValue: "option2", + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "radioField", + "text@helpText": "Radio field help text", + "text@label": "Radio field", + "text@name": "radio", + "text@placeholderText": null, + "text@type": "radio", + "text@_id": "pUgH-pWnkW" + }, + { + "json@settings": { + defaultValue: ["option2"], + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "checkboxesField", + "text@helpText": "Checkboxes field help text", + "text@label": "Checkboxes field", + "text@name": "checkbox", + "text@placeholderText": null, + "text@type": "checkbox", + "text@_id": "nFYVV5X8Tn" + }, + { + "json@settings": { + defaultValue: null, + format: "date" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "dateTimeField", + "text@helpText": "DateTime field help text", + "text@label": "DateTime field", + "text@name": "date", + "text@placeholderText": null, + "text@type": "datetime", + "text@_id": "P0dxAwg20f" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + "text@title": "Step 1" + } + ], + "text@formId": "65c4c9d05e7aad0008b21715", + "text@name": "Demo form 6", + "text@slug": "demo-form-6-65c4c9d05e7aad0008b21715" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4c9d05e7aad0008b21715", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + entryId: "65c4c9d05e7aad0008b21715", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T12:36:36.667Z", + id: "65c4c9d05e7aad0008b21715#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T12:36:36.667Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T12:36:36.667Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T12:32:16.133Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T12:36:36.667Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T12:36:36.667Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T12:36:36.667Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T12:36:36.667Z", + savedBy: user, + savedOn: "2024-02-08T12:36:36.667Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: "Hidden field default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "hiddenField", + "text@helpText": "Hidden field help text", + "text@label": "Hidden field", + "text@name": "hidden", + "text@placeholderText": null, + "text@type": "hidden", + "text@_id": "iSDmskA_Tt" + }, + { + "json@settings": { + defaultValue: "option2" + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "selectField", + "text@helpText": "Select field help text", + "text@label": "Select field", + "text@name": "select", + "text@placeholderText": "Select field placeholder text", + "text@type": "select", + "text@_id": "CBZ0tNIQaV" + }, + { + "json@settings": { + defaultValue: "Short text default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "shortText", + "text@helpText": "Short text help text", + "text@label": "Short text", + "text@name": "text", + "text@placeholderText": "Short text placeholder text", + "text@type": "text", + "text@_id": "B8dDiYSSRF" + }, + { + "json@settings": { + defaultValue: "Long text default value", + rows: "10" + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + value: "1" + }, + "text@message": "Value is too short.", + "text@name": "minLength" + }, + { + "json@settings": { + value: "100" + }, + "text@message": "Value is too long.", + "text@name": "maxLength" + } + ], + "text@fieldId": "longText", + "text@helpText": "Long text help text", + "text@label": "Long text", + "text@name": "textarea", + "text@placeholderText": "Long text placeholder text", + "text@type": "textarea", + "text@_id": "iDfaI8P1dZ" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "numberField", + "text@helpText": "Number field help text", + "text@label": "Number field", + "text@name": "number", + "text@placeholderText": "Number field placeholder text", + "text@type": "number", + "text@_id": "KR1AHgvW1L" + }, + { + "json@settings": { + defaultValue: "option2", + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "radioField", + "text@helpText": "Radio field help text", + "text@label": "Radio field", + "text@name": "radio", + "text@placeholderText": null, + "text@type": "radio", + "text@_id": "pUgH-pWnkW" + }, + { + "json@settings": { + defaultValue: ["option2"], + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "checkboxesField", + "text@helpText": "Checkboxes field help text", + "text@label": "Checkboxes field", + "text@name": "checkbox", + "text@placeholderText": null, + "text@type": "checkbox", + "text@_id": "nFYVV5X8Tn" + }, + { + "json@settings": { + defaultValue: null, + format: "date" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "dateTimeField", + "text@helpText": "DateTime field help text", + "text@label": "DateTime field", + "text@name": "date", + "text@placeholderText": null, + "text@type": "datetime", + "text@_id": "P0dxAwg20f" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + "text@title": "Step 1" + } + ], + "text@formId": "65c4c9d05e7aad0008b21715", + "text@name": "Demo form 6", + "text@slug": "demo-form-6-65c4c9d05e7aad0008b21715" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4c9d05e7aad0008b21715", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T12:32:16.133Z", + entryId: "65c4c9d05e7aad0008b21715", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T12:36:36.667Z", + id: "65c4c9d05e7aad0008b21715#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T12:36:36.667Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T12:36:36.667Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T12:32:16.133Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T12:36:36.667Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T12:36:36.667Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T12:36:36.667Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T12:36:36.667Z", + savedBy: user, + savedOn: "2024-02-08T12:36:36.667Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: "Hidden field default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "hiddenField", + "text@helpText": "Hidden field help text", + "text@label": "Hidden field", + "text@name": "hidden", + "text@placeholderText": null, + "text@type": "hidden", + "text@_id": "iSDmskA_Tt" + }, + { + "json@settings": { + defaultValue: "option2" + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "selectField", + "text@helpText": "Select field help text", + "text@label": "Select field", + "text@name": "select", + "text@placeholderText": "Select field placeholder text", + "text@type": "select", + "text@_id": "CBZ0tNIQaV" + }, + { + "json@settings": { + defaultValue: "Short text default value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "shortText", + "text@helpText": "Short text help text", + "text@label": "Short text", + "text@name": "text", + "text@placeholderText": "Short text placeholder text", + "text@type": "text", + "text@_id": "B8dDiYSSRF" + }, + { + "json@settings": { + defaultValue: "Long text default value", + rows: "10" + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + value: "1" + }, + "text@message": "Value is too short.", + "text@name": "minLength" + }, + { + "json@settings": { + value: "100" + }, + "text@message": "Value is too long.", + "text@name": "maxLength" + } + ], + "text@fieldId": "longText", + "text@helpText": "Long text help text", + "text@label": "Long text", + "text@name": "textarea", + "text@placeholderText": "Long text placeholder text", + "text@type": "textarea", + "text@_id": "iDfaI8P1dZ" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "numberField", + "text@helpText": "Number field help text", + "text@label": "Number field", + "text@name": "number", + "text@placeholderText": "Number field placeholder text", + "text@type": "number", + "text@_id": "KR1AHgvW1L" + }, + { + "json@settings": { + defaultValue: "option2", + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "radioField", + "text@helpText": "Radio field help text", + "text@label": "Radio field", + "text@name": "radio", + "text@placeholderText": null, + "text@type": "radio", + "text@_id": "pUgH-pWnkW" + }, + { + "json@settings": { + defaultValue: ["option2"], + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "checkboxesField", + "text@helpText": "Checkboxes field help text", + "text@label": "Checkboxes field", + "text@name": "checkbox", + "text@placeholderText": null, + "text@type": "checkbox", + "text@_id": "nFYVV5X8Tn" + }, + { + "json@settings": { + defaultValue: null, + format: "date" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "dateTimeField", + "text@helpText": "DateTime field help text", + "text@label": "DateTime field", + "text@name": "date", + "text@placeholderText": null, + "text@type": "datetime", + "text@_id": "P0dxAwg20f" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ], + "text@title": "Step 1" + } + ], + "text@formId": "65c4c9d05e7aad0008b21715", + "text@name": "Demo form 6", + "text@slug": "demo-form-6-65c4c9d05e7aad0008b21715" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#CMS#CME#65c4d1dfb0bf8a00087fbcd6", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T13:06:39.264Z", + entryId: "65c4d1dfb0bf8a00087fbcd6", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T13:07:56.618Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T13:06:39.264Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T13:07:56.618Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T13:07:56.618Z", + savedBy: user, + savedOn: "2024-02-08T13:07:56.618Z", + status: "draft", + tenant: "root", + + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "ItPh6LB1jL" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": true, + "json@successMessage": [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "A6l0TC3oER", + type: "paragraph" + } + ], + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "object@termsOfServiceMessage": { + "boolean@enabled": true, + "json@message": [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "3UTfrPvarm", + type: "paragraph" + } + ], + "text@errorMessage": "Custom error message" + }, + "text@submitButtonLabel": "Custom submit button label" + }, + "object@steps": [ + { + "json@layout": [["ItPh6LB1jL"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4d1dfb0bf8a00087fbcd6", + "text@name": "Demo form 7", + "text@slug": "demo-form-7-65c4d1dfb0bf8a00087fbcd6" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4d1dfb0bf8a00087fbcd6", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T13:06:39.264Z", + entryId: "65c4d1dfb0bf8a00087fbcd6", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T13:07:56.618Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T13:06:39.264Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T13:07:56.618Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T13:07:56.618Z", + savedBy: user, + savedOn: "2024-02-08T13:07:56.618Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "ItPh6LB1jL" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": true, + "json@successMessage": [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "A6l0TC3oER", + type: "paragraph" + } + ], + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "object@termsOfServiceMessage": { + "boolean@enabled": true, + "json@message": [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "3UTfrPvarm", + type: "paragraph" + } + ], + "text@errorMessage": "Custom error message" + }, + "text@submitButtonLabel": "Custom submit button label" + }, + "object@steps": [ + { + "json@layout": [["ItPh6LB1jL"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4d1dfb0bf8a00087fbcd6", + "text@name": "Demo form 7", + "text@slug": "demo-form-7-65c4d1dfb0bf8a00087fbcd6" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1e9", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1e9", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1e9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6kr" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6kr"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1e9", + "text@name": "Demo form 8", + "text@slug": "demo-form-8-65c4ea4ac04244000878b1e9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1e9", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1e9", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1e9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6kr" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6kr"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1e9", + "text@name": "Demo form 8", + "text@slug": "demo-form-8-65c4ea4ac04244000878b1e9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1e9", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1e9", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1e9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6kr" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6kr"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1e9", + "text@name": "Demo form 8", + "text@slug": "demo-form-8-65c4ea4ac04244000878b1e9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1f0", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f0", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f0#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6l3" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6l3"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f0", + "text@name": "Demo form 9", + "text@slug": "demo-form-9-65c4ea4ac04244000878b1f0" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1f0", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f0", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f0#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6l3" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6l3"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f0", + "text@name": "Demo form 9", + "text@slug": "demo-form-9-65c4ea4ac04244000878b1f0" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1f0", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f0", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f0#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6l3" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6l3"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f0", + "text@name": "Demo form 9", + "text@slug": "demo-form-9-65c4ea4ac04244000878b1f0" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f1", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f1", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f1#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6m2" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6m2"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f1", + "text@name": "Demo form 10", + "text@slug": "demo-form-10-65c4ea4ac04244000878b1f1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f1", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f1", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f1#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6m2" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6m2"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f1", + "text@name": "Demo form 10", + "text@slug": "demo-form-10-65c4ea4ac04244000878b1f1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f1", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f1", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f1#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0UDy6m2" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0UDy6m2"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f1", + "text@name": "Demo form 10", + "text@slug": "demo-form-10-65c4ea4ac04244000878b1f1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from otherTenant tenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f2", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f2", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f2#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0VQh3n5" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0VQh3n5"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f2", + "text@name": "Demo form 11", + "text@slug": "demo-form-11-65c4ea4ac04244000878b1f2" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f2", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f2", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f2#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0VQh3n5" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0VQh3n5"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f2", + "text@name": "Demo form 11", + "text@slug": "demo-form-11-65c4ea4ac04244000878b1f2" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f2", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f2", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f2#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0VQh3n5" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0VQh3n5"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f2", + "text@name": "Demo form 11", + "text@slug": "demo-form-11-65c4ea4ac04244000878b1f2" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from otherTenant tenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f3", + SK: "L", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f3", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f3#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0Tj8p4z" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0Tj8p4z"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f3", + "text@name": "Demo form 12", + "text@slug": "demo-form-12-65c4ea4ac04244000878b1f3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f3", + SK: "P", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f3", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f3#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0Tj8p4z" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0Tj8p4z"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f3", + "text@name": "Demo form 12", + "text@slug": "demo-form-12-65c4ea4ac04244000878b1f3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f3", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-02-08T14:50:50.570Z", + entryId: "65c4ea4ac04244000878b1f3", + firstPublishedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + id: "65c4ea4ac04244000878b1f3#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionSavedBy: user, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + savedBy: user, + savedOn: "2024-02-08T14:51:05.869Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "-WO0Tj8p4z" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["-WO0Tj8p4z"]], + "text@title": "Step 1" + } + ], + "text@formId": "65c4ea4ac04244000878b1f3", + "text@name": "Demo form 12", + "text@slug": "demo-form-12-65c4ea4ac04244000878b1f3" + }, + version: 1, + webinyVersion: "0.0.0" + } +]; + +export const getMigratedFormStatsData = () => { + const forms = createFormsData().filter(form => form.TYPE === "fb.form"); + + const stats = []; + + for (const form of forms) { + const [formId, revisionId] = form.id.split("#"); + + const commonFields = { + createdBy: user, + createdOn: form.createdOn, + entryId: `${formId}-${revisionId}-stats`, + id: `${formId}-${revisionId}-stats#0001`, + locale: form.locale, + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: form.createdOn, + revisionSavedBy: user, + revisionSavedOn: form.savedOn, + savedOn: form.savedOn, + savedBy: user, + status: "draft", + tenant: form.tenant, + values: { + "text@formId": form.formId, + "number@formVersion": form.version, + "number@views": form.stats.views, + "number@submissions": form.stats.submissions + }, + version: 1, + webinyVersion: form.webinyVersion + }; + + const revision = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${formId}-${revisionId}-stats`, + SK: "REV#0001", + TYPE: "cms.entry", + ...commonFields + }; + + stats.push(revision); + + const latest = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${formId}-${revisionId}-stats`, + SK: "L", + TYPE: "cms.entry.l", + ...commonFields + }; + + stats.push(latest); + } + + return stats; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddbEs.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddbEs.ts new file mode 100644 index 00000000000..63a7bfdb2aa --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.migrated.ddbEs.ts @@ -0,0 +1,2475 @@ +import { createFormsData, user } from "./001.ddb"; + +// Note that the data is decompressed. +const migratedDdbEsFormData = [ + // Form with 1 revision published + { + PK: "T#root#L#en-US#CMS#CME#65c0a07038a36e00082095ea", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-05T08:46:40.354Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c0a07038a36e00082095ea", + id: "65c0a07038a36e00082095ea#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-05T08:47:01.134Z", + locale: "en-US", + savedOn: "2024-02-05T08:47:01.134Z", + values: { + "text@formId": "65c0a07038a36e00082095ea", + "text@name": "Demo form 1", + "object@fields": [ + { + "text@_id": "fi0rrnUHdl", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "object@options": [], + "object@validation": [], + "text@helpText": null, + "text@placeholderText": null + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-1-65c0a07038a36e00082095ea" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-05T08:46:40.354Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-05T08:47:01.134Z", + revisionFirstPublishedOn: "2024-02-05T08:47:01.134Z", + revisionLastPublishedOn: "2024-02-05T08:47:01.134Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-05T08:47:01.134Z", + firstPublishedOn: "2024-02-05T08:47:01.134Z", + lastPublishedOn: "2024-02-05T08:47:01.134Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["fi0rrnUHdl"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#en-US#CMS#CME#65c0a07038a36e00082095ea", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-05T08:46:40.354Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c0a07038a36e00082095ea", + id: "65c0a07038a36e00082095ea#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-05T08:47:01.134Z", + locale: "en-US", + savedOn: "2024-02-05T08:47:01.134Z", + values: { + "text@formId": "65c0a07038a36e00082095ea", + "text@name": "Demo form 1", + "object@fields": [ + { + "text@_id": "fi0rrnUHdl", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "object@options": [], + "object@validation": [], + "text@helpText": null, + "text@placeholderText": null + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-1-65c0a07038a36e00082095ea" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-05T08:47:01.134Z", + createdOn: "2024-02-05T08:46:40.354Z", + modifiedOn: "2024-02-05T08:47:01.134Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-05T08:47:01.134Z", + lastPublishedOn: "2024-02-05T08:47:01.134Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-05T08:47:01.134Z", + revisionLastPublishedOn: "2024-02-05T08:47:01.134Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["fi0rrnUHdl"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T06:50:17.141Z", + lastPublishedOn: "2024-02-08T06:50:06.306Z", + status: "draft", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c479873ff56c0008735714", + lastPublishedBy: user, + id: "65c479873ff56c0008735714#0002", + savedBy: user, + version: 2, + location: { folderId: "root" }, + firstPublishedBy: user, + revisionSavedOn: "2024-02-08T06:50:17.141Z", + locale: "en-US", + savedOn: "2024-02-08T06:50:17.141Z", + revisionFirstPublishedBy: null, + values: { + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "object@fields": [ + { + "text@_id": "QwlAelzDaq", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + revisionSavedBy: user, + revisionFirstPublishedOn: null, + tenant: "root", + revisionModifiedOn: "2024-02-08T06:50:17.141Z", + revisionLastPublishedBy: null, + createdOn: "2024-02-08T06:49:43.380Z", + modifiedOn: "2024-02-08T06:50:17.141Z", + locked: false, + webinyVersion: "0.0.0", + revisionLastPublishedOn: null, + modifiedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["QwlAelzDaq"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#en-US#CMS#CME#65c479873ff56c0008735714", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T06:49:43.380Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c479873ff56c0008735714", + id: "65c479873ff56c0008735714#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T06:50:06.306Z", + locale: "en-US", + savedOn: "2024-02-08T06:50:06.306Z", + values: { + "text@formId": "65c479873ff56c0008735714", + "text@name": "Demo form 2", + "object@fields": [ + { + "text@_id": "QwlAelzDaq", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-2-65c479873ff56c0008735714" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T06:50:06.306Z", + createdOn: "2024-02-08T06:49:43.380Z", + modifiedOn: "2024-02-08T06:50:06.306Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T06:50:06.306Z", + lastPublishedOn: "2024-02-08T06:50:06.306Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T06:50:06.306Z", + revisionLastPublishedOn: "2024-02-08T06:50:06.306Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["QwlAelzDaq"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#CMS#CME#65c492e1766cb000084357d1", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T08:37:53.951Z", + status: "draft", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c492e1766cb000084357d1", + id: "65c492e1766cb000084357d1#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T08:38:06.346Z", + locale: "en-US", + savedOn: "2024-02-08T08:38:06.346Z", + values: { + "text@formId": "65c492e1766cb000084357d1", + "text@name": "Demo form 3", + "object@fields": [ + { + "text@_id": "Ua0cd7oJZD", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-3-65c492e1766cb000084357d1" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T08:37:53.951Z", + locked: false, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T08:38:06.346Z", + revisionFirstPublishedOn: null, + revisionLastPublishedOn: null, + revisionModifiedBy: user, + revisionFirstPublishedBy: null, + revisionLastPublishedBy: null, + modifiedOn: "2024-02-08T08:38:06.346Z", + firstPublishedOn: null, + lastPublishedOn: null, + modifiedBy: user, + firstPublishedBy: null, + lastPublishedBy: null, + meta: {}, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["Ua0cd7oJZD"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T09:06:08.967Z", + lastPublishedOn: "2024-02-08T09:05:41.633Z", + meta: {}, + status: "draft", + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4994929b99b0008bd6167", + lastPublishedBy: user, + id: "65c4994929b99b0008bd6167#0004", + savedBy: user, + version: 4, + firstPublishedBy: user, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T09:06:08.967Z", + locale: "en-US", + savedOn: "2024-02-08T09:06:08.967Z", + revisionFirstPublishedBy: null, + values: { + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "object@fields": [ + { + "text@_id": "h4WRtUvT1t", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionSavedBy: user, + revisionFirstPublishedOn: null, + tenant: "root", + revisionModifiedOn: "2024-02-08T09:06:08.967Z", + revisionLastPublishedBy: null, + createdOn: "2024-02-08T09:05:13.764Z", + modifiedOn: "2024-02-08T09:06:08.967Z", + locked: false, + webinyVersion: "0.0.0", + revisionLastPublishedOn: null, + modifiedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["h4WRtUvT1t"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4994929b99b0008bd6167", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T09:05:37.331Z", + lastPublishedOn: "2024-02-08T09:05:41.633Z", + meta: {}, + status: "published", + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4994929b99b0008bd6167", + lastPublishedBy: user, + id: "65c4994929b99b0008bd6167#0002", + savedBy: user, + version: 2, + firstPublishedBy: user, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T09:05:41.633Z", + locale: "en-US", + savedOn: "2024-02-08T09:05:41.633Z", + revisionFirstPublishedBy: user, + values: { + "text@formId": "65c4994929b99b0008bd6167", + "text@name": "Demo form 4", + "object@fields": [ + { + "text@_id": "h4WRtUvT1t", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-4-65c4994929b99b0008bd6167" + }, + firstPublishedOn: "2024-02-08T09:05:41.633Z", + revisionSavedBy: user, + revisionFirstPublishedOn: "2024-02-08T09:05:41.633Z", + tenant: "root", + revisionModifiedOn: "2024-02-08T09:05:41.633Z", + revisionLastPublishedBy: user, + createdOn: "2024-02-08T09:05:13.764Z", + modifiedOn: "2024-02-08T09:05:41.633Z", + locked: true, + webinyVersion: "0.0.0", + revisionLastPublishedOn: "2024-02-08T09:05:41.633Z", + modifiedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] } + ], + "object@steps": [{ "json@layout": [["h4WRtUvT1t"]] }], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#CMS#CME#65c4a67e371e020008a5a8cb", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T10:01:34.873Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T10:02:12.516Z", + locale: "en-US", + savedOn: "2024-02-08T10:02:12.516Z", + values: { + "text@formId": "65c4a67e371e020008a5a8cb", + "text@name": "Demo form 5", + "object@fields": [ + { + "text@_id": "LdjAJR41d", + "text@fieldId": "firstName", + "text@type": "text", + "text@name": "firstName", + "text@label": "First name", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "UNZrnwfMR", + "text@fieldId": "lastName", + "text@type": "text", + "text@name": "lastName", + "text@label": "Last name", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "r6fATib8h", + "text@fieldId": "email", + "text@type": "text", + "text@name": "email", + "text@label": "Email", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { + "text@name": "pattern", + "text@message": "Please enter a valid e-mail." + }, + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "aQH7A-jP8", + "text@fieldId": "phoneNumber", + "text@type": "text", + "text@name": "phoneNumber", + "text@label": "Phone number", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "Di_Wwktpk", + "text@fieldId": "website", + "text@type": "text", + "text@name": "website", + "text@label": "Website", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { "text@name": "pattern", "text@message": "Please enter a valid URL." } + ] + } + ], + "object@steps": [{ "text@title": "Step 1" }, { "text@title": "Step 2" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-5-65c4a67e371e020008a5a8cb" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T10:01:34.873Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedOn: "2024-02-08T10:02:12.516Z", + revisionLastPublishedOn: "2024-02-08T10:02:12.516Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T10:02:12.516Z", + firstPublishedOn: "2024-02-08T10:02:12.516Z", + lastPublishedOn: "2024-02-08T10:02:12.516Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { + "object@validation": [ + { "json@settings": { flags: null, regex: null, preset: "email" } }, + { "json@settings": {} } + ], + "json@settings": { defaultValue: null } + }, + { + "object@validation": [{ "json@settings": {} }], + "json@settings": { defaultValue: null } + }, + { + "object@validation": [ + { "json@settings": { flags: null, regex: null, preset: "url" } } + ], + "json@settings": { defaultValue: null } + } + ], + "object@steps": [ + { "json@layout": [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]] }, + { "json@layout": [["aQH7A-jP8"], ["Di_Wwktpk"]] } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4a67e371e020008a5a8cb", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T10:01:34.873Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4a67e371e020008a5a8cb", + id: "65c4a67e371e020008a5a8cb#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T10:02:12.516Z", + locale: "en-US", + savedOn: "2024-02-08T10:02:12.516Z", + values: { + "text@formId": "65c4a67e371e020008a5a8cb", + "text@name": "Demo form 5", + "object@fields": [ + { + "text@_id": "LdjAJR41d", + "text@fieldId": "firstName", + "text@type": "text", + "text@name": "firstName", + "text@label": "First name", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "UNZrnwfMR", + "text@fieldId": "lastName", + "text@type": "text", + "text@name": "lastName", + "text@label": "Last name", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "r6fATib8h", + "text@fieldId": "email", + "text@type": "text", + "text@name": "email", + "text@label": "Email", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { + "text@name": "pattern", + "text@message": "Please enter a valid e-mail." + }, + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "aQH7A-jP8", + "text@fieldId": "phoneNumber", + "text@type": "text", + "text@name": "phoneNumber", + "text@label": "Phone number", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "Di_Wwktpk", + "text@fieldId": "website", + "text@type": "text", + "text@name": "website", + "text@label": "Website", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [ + { "text@name": "pattern", "text@message": "Please enter a valid URL." } + ] + } + ], + "object@steps": [{ "text@title": "Step 1" }, { "text@title": "Step 2" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-5-65c4a67e371e020008a5a8cb" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T10:02:12.516Z", + createdOn: "2024-02-08T10:01:34.873Z", + modifiedOn: "2024-02-08T10:02:12.516Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T10:02:12.516Z", + lastPublishedOn: "2024-02-08T10:02:12.516Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T10:02:12.516Z", + revisionLastPublishedOn: "2024-02-08T10:02:12.516Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { + "object@validation": [ + { "json@settings": { flags: null, regex: null, preset: "email" } }, + { "json@settings": {} } + ], + "json@settings": { defaultValue: null } + }, + { + "object@validation": [{ "json@settings": {} }], + "json@settings": { defaultValue: null } + }, + { + "object@validation": [ + { "json@settings": { flags: null, regex: null, preset: "url" } } + ], + "json@settings": { defaultValue: null } + } + ], + "object@steps": [ + { "json@layout": [["r6fATib8h"], ["LdjAJR41d"], ["UNZrnwfMR"]] }, + { "json@layout": [["aQH7A-jP8"], ["Di_Wwktpk"]] } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form with default fields + { + PK: "T#root#L#en-US#CMS#CME#65c4c9d05e7aad0008b21715", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T12:32:16.133Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4c9d05e7aad0008b21715", + id: "65c4c9d05e7aad0008b21715#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T12:36:36.667Z", + locale: "en-US", + savedOn: "2024-02-08T12:36:36.667Z", + values: { + "text@formId": "65c4c9d05e7aad0008b21715", + "text@name": "Demo form 6", + "object@fields": [ + { + "text@_id": "iSDmskA_Tt", + "text@fieldId": "hiddenField", + "text@type": "hidden", + "text@name": "hidden", + "text@label": "Hidden field", + "text@placeholderText": null, + "text@helpText": "Hidden field help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "CBZ0tNIQaV", + "text@fieldId": "selectField", + "text@type": "select", + "text@name": "select", + "text@label": "Select field", + "text@placeholderText": "Select field placeholder text", + "text@helpText": "Select field help text", + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ], + "object@validation": [ + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "B8dDiYSSRF", + "text@fieldId": "shortText", + "text@type": "text", + "text@name": "text", + "text@label": "Short text", + "text@placeholderText": "Short text placeholder text", + "text@helpText": "Short text help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "iDfaI8P1dZ", + "text@fieldId": "longText", + "text@type": "textarea", + "text@name": "textarea", + "text@label": "Long text", + "text@placeholderText": "Long text placeholder text", + "text@helpText": "Long text help text", + "object@validation": [ + { "text@name": "minLength", "text@message": "Value is too short." }, + { "text@name": "maxLength", "text@message": "Value is too long." } + ], + "object@options": [] + }, + { + "text@_id": "KR1AHgvW1L", + "text@fieldId": "numberField", + "text@type": "number", + "text@name": "number", + "text@label": "Number field", + "text@placeholderText": "Number field placeholder text", + "text@helpText": "Number field help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "pUgH-pWnkW", + "text@fieldId": "radioField", + "text@type": "radio", + "text@name": "radio", + "text@label": "Radio field", + "text@placeholderText": null, + "text@helpText": "Radio field help text", + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ], + "object@validation": [] + }, + { + "text@_id": "nFYVV5X8Tn", + "text@fieldId": "checkboxesField", + "text@type": "checkbox", + "text@name": "checkbox", + "text@label": "Checkboxes field", + "text@placeholderText": null, + "text@helpText": "Checkboxes field help text", + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ], + "object@validation": [] + }, + { + "text@_id": "P0dxAwg20f", + "text@fieldId": "dateTimeField", + "text@type": "datetime", + "text@name": "date", + "text@label": "DateTime field", + "text@placeholderText": null, + "text@helpText": "DateTime field help text", + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-6-65c4c9d05e7aad0008b21715" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T12:32:16.133Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T12:36:36.667Z", + revisionFirstPublishedOn: "2024-02-08T12:36:36.667Z", + revisionLastPublishedOn: "2024-02-08T12:36:36.667Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T12:36:36.667Z", + firstPublishedOn: "2024-02-08T12:36:36.667Z", + lastPublishedOn: "2024-02-08T12:36:36.667Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { defaultValue: "Hidden field default value" }, + "object@validation": [] + }, + { + "object@validation": [{ "json@settings": {} }], + "json@settings": { defaultValue: "option2" } + }, + { + "json@settings": { defaultValue: "Short text default value" }, + "object@validation": [] + }, + { + "object@validation": [ + { "json@settings": { value: "1" } }, + { "json@settings": { value: "100" } } + ], + "json@settings": { rows: "10", defaultValue: "Long text default value" } + }, + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { + "json@settings": { defaultValue: "option2", otherOption: true }, + "object@validation": [] + }, + { + "object@validation": [], + "json@settings": { defaultValue: ["option2"], otherOption: true } + }, + { + "json@settings": { format: "date", defaultValue: null }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#en-US#CMS#CME#65c4c9d05e7aad0008b21715", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T12:32:16.133Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4c9d05e7aad0008b21715", + id: "65c4c9d05e7aad0008b21715#0001", + savedBy: user, + version: 1, + location: { folderId: "root" }, + revisionSavedOn: "2024-02-08T12:36:36.667Z", + locale: "en-US", + savedOn: "2024-02-08T12:36:36.667Z", + values: { + "text@formId": "65c4c9d05e7aad0008b21715", + "text@name": "Demo form 6", + "object@fields": [ + { + "text@_id": "iSDmskA_Tt", + "text@fieldId": "hiddenField", + "text@type": "hidden", + "text@name": "hidden", + "text@label": "Hidden field", + "text@placeholderText": null, + "text@helpText": "Hidden field help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "CBZ0tNIQaV", + "text@fieldId": "selectField", + "text@type": "select", + "text@name": "select", + "text@label": "Select field", + "text@placeholderText": "Select field placeholder text", + "text@helpText": "Select field help text", + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ], + "object@validation": [ + { "text@name": "required", "text@message": "Value is required." } + ] + }, + { + "text@_id": "B8dDiYSSRF", + "text@fieldId": "shortText", + "text@type": "text", + "text@name": "text", + "text@label": "Short text", + "text@placeholderText": "Short text placeholder text", + "text@helpText": "Short text help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "iDfaI8P1dZ", + "text@fieldId": "longText", + "text@type": "textarea", + "text@name": "textarea", + "text@label": "Long text", + "text@placeholderText": "Long text placeholder text", + "text@helpText": "Long text help text", + "object@options": [], + "object@validation": [ + { "text@name": "minLength", "text@message": "Value is too short." }, + { "text@name": "maxLength", "text@message": "Value is too long." } + ] + }, + { + "text@_id": "KR1AHgvW1L", + "text@fieldId": "numberField", + "text@type": "number", + "text@name": "number", + "text@label": "Number field", + "text@placeholderText": "Number field placeholder text", + "text@helpText": "Number field help text", + "object@options": [], + "object@validation": [] + }, + { + "text@_id": "pUgH-pWnkW", + "text@fieldId": "radioField", + "text@type": "radio", + "text@name": "radio", + "text@label": "Radio field", + "text@placeholderText": null, + "text@helpText": "Radio field help text", + "object@validation": [], + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ] + }, + { + "text@_id": "nFYVV5X8Tn", + "text@fieldId": "checkboxesField", + "text@type": "checkbox", + "text@name": "checkbox", + "text@label": "Checkboxes field", + "text@placeholderText": null, + "text@helpText": "Checkboxes field help text", + "object@options": [ + { "text@label": "Option 1", "text@value": "option1" }, + { "text@label": "Option 2", "text@value": "option2" }, + { "text@label": "Option 3", "text@value": "option3" } + ], + "object@validation": [] + }, + { + "text@_id": "P0dxAwg20f", + "text@fieldId": "dateTimeField", + "text@type": "datetime", + "text@name": "date", + "text@label": "DateTime field", + "text@placeholderText": null, + "text@helpText": "DateTime field help text", + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [{ "text@title": "Step 1" }], + "object@settings": { + "object@layout": { "text@renderer": "default" }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-6-65c4c9d05e7aad0008b21715" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T12:36:36.667Z", + createdOn: "2024-02-08T12:32:16.133Z", + modifiedOn: "2024-02-08T12:36:36.667Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T12:36:36.667Z", + lastPublishedOn: "2024-02-08T12:36:36.667Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T12:36:36.667Z", + revisionLastPublishedOn: "2024-02-08T12:36:36.667Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { defaultValue: "Hidden field default value" }, + "object@validation": [] + }, + { + "object@validation": [{ "json@settings": {} }], + "json@settings": { defaultValue: "option2" } + }, + { + "json@settings": { defaultValue: "Short text default value" }, + "object@validation": [] + }, + { + "object@validation": [ + { "json@settings": { value: "1" } }, + { "json@settings": { value: "100" } } + ], + "json@settings": { rows: "10", defaultValue: "Long text default value" } + }, + { "json@settings": { defaultValue: null }, "object@validation": [] }, + { + "json@settings": { defaultValue: "option2", otherOption: true }, + "object@validation": [] + }, + { + "json@settings": { defaultValue: ["option2"], otherOption: true }, + "object@validation": [] + }, + { + "json@settings": { format: "date", defaultValue: null }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [ + ["iSDmskA_Tt"], + ["CBZ0tNIQaV"], + ["B8dDiYSSRF"], + ["iDfaI8P1dZ"], + ["KR1AHgvW1L"], + ["pUgH-pWnkW", "nFYVV5X8Tn"], + ["P0dxAwg20f"] + ] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#CMS#CME#65c4d1dfb0bf8a00087fbcd6", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T13:06:39.264Z", + status: "draft", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4d1dfb0bf8a00087fbcd6", + id: "65c4d1dfb0bf8a00087fbcd6#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T13:07:56.618Z", + locale: "en-US", + savedOn: "2024-02-08T13:07:56.618Z", + values: { + "text@formId": "65c4d1dfb0bf8a00087fbcd6", + "text@name": "Demo form 7", + "object@fields": [ + { + "text@_id": "ItPh6LB1jL", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": "Custom submit button label", + "boolean@fullWidthSubmitButton": true, + "object@termsOfServiceMessage": { + "boolean@enabled": true, + "text@errorMessage": "Custom error message" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-7-65c4d1dfb0bf8a00087fbcd6" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T13:06:39.264Z", + locked: false, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T13:07:56.618Z", + revisionFirstPublishedOn: null, + revisionLastPublishedOn: null, + revisionModifiedBy: user, + revisionFirstPublishedBy: null, + revisionLastPublishedBy: null, + modifiedOn: "2024-02-08T13:07:56.618Z", + firstPublishedOn: null, + lastPublishedOn: null, + modifiedBy: user, + firstPublishedBy: null, + lastPublishedBy: null, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["ItPh6LB1jL"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": [ + { + type: "paragraph", + data: { + textAlign: "start", + className: null, + text: "Custom success message" + }, + id: "A6l0TC3oER" + } + ], + "object@termsOfServiceMessage": { + "json@message": [ + { + type: "paragraph", + data: { + textAlign: "start", + className: null, + text: "Custom term of service message" + }, + id: "3UTfrPvarm" + } + ] + }, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1e9", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1e9", + id: "65c4ea4ac04244000878b1e9#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1e9", + "text@name": "Demo form 8", + "object@fields": [ + { + "text@_id": "-WO0UDy6kr", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-8-65c4ea4ac04244000878b1e9" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T14:50:50.570Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6kr"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1e9", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1e9", + id: "65c4ea4ac04244000878b1e9#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1e9", + "text@name": "Demo form 8", + "object@fields": [ + { + "text@_id": "-WO0UDy6kr", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-8-65c4ea4ac04244000878b1e9" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + createdOn: "2024-02-08T14:50:50.570Z", + modifiedOn: "2024-02-08T14:51:05.869Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6kr"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1f0", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f0", + id: "65c4ea4ac04244000878b1f0#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f0", + "text@name": "Demo form 9", + "object@fields": [ + { + "text@_id": "-WO0UDy6l3", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-9-65c4ea4ac04244000878b1f0" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T14:50:50.570Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6l3"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#de-DE#CMS#CME#65c4ea4ac04244000878b1f0", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f0", + id: "65c4ea4ac04244000878b1f0#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "de-DE", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f0", + "text@name": "Demo form 9", + "object@fields": [ + { + "text@_id": "-WO0UDy6l3", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-9-65c4ea4ac04244000878b1f0" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + createdOn: "2024-02-08T14:50:50.570Z", + modifiedOn: "2024-02-08T14:51:05.869Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6l3"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f1", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f1", + id: "65c4ea4ac04244000878b1f1#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f1", + "text@name": "Demo form 10", + "object@fields": [ + { + "text@_id": "-WO0UDy6m2", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-10-65c4ea4ac04244000878b1f1" + }, + revisionSavedBy: user, + tenant: "root", + createdOn: "2024-02-08T14:50:50.570Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6m2"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#root#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f1", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f1", + id: "65c4ea4ac04244000878b1f1#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f1", + "text@name": "Demo form 10", + "object@fields": [ + { + "text@_id": "-WO0UDy6m2", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-10-65c4ea4ac04244000878b1f1" + }, + revisionSavedBy: user, + tenant: "root", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + createdOn: "2024-02-08T14:50:50.570Z", + modifiedOn: "2024-02-08T14:51:05.869Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0UDy6m2"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form 1 from otherTenant tenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f2", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f2", + id: "65c4ea4ac04244000878b1f2#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f2", + "text@name": "Demo form 11", + "object@fields": [ + { + "text@_id": "-WO0VQh3n5", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-11-65c4ea4ac04244000878b1f2" + }, + revisionSavedBy: user, + tenant: "otherTenant", + createdOn: "2024-02-08T14:50:50.570Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0VQh3n5"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f2", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f2", + id: "65c4ea4ac04244000878b1f2#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f2", + "text@name": "Demo form 11", + "object@fields": [ + { + "text@_id": "-WO0VQh3n5", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-11-65c4ea4ac04244000878b1f2" + }, + revisionSavedBy: user, + tenant: "otherTenant", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + createdOn: "2024-02-08T14:50:50.570Z", + modifiedOn: "2024-02-08T14:51:05.869Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0VQh3n5"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + }, + + // Form 2 from otherTenant tenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f3", + SK: "L", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + revisionCreatedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f3", + id: "65c4ea4ac04244000878b1f3#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f3", + "text@name": "Demo form 12", + "object@fields": [ + { + "text@_id": "-WO0Tj8p4z", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-12-65c4ea4ac04244000878b1f3" + }, + revisionSavedBy: user, + tenant: "otherTenant", + createdOn: "2024-02-08T14:50:50.570Z", + locked: true, + webinyVersion: "0.0.0", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionModifiedBy: user, + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + modifiedOn: "2024-02-08T14:51:05.869Z", + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + modifiedBy: user, + firstPublishedBy: user, + lastPublishedBy: user, + meta: {}, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0Tj8p4z"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#65c4ea4ac04244000878b1f3", + SK: "P", + data: { + modelId: "fbForm", + revisionCreatedOn: "2024-02-08T14:50:50.570Z", + status: "published", + meta: {}, + revisionCreatedBy: user, + revisionModifiedBy: user, + createdBy: user, + entryId: "65c4ea4ac04244000878b1f3", + id: "65c4ea4ac04244000878b1f3#0001", + savedBy: user, + version: 1, + location: { + folderId: "root" + }, + revisionSavedOn: "2024-02-08T14:51:05.869Z", + locale: "fr-FR", + savedOn: "2024-02-08T14:51:05.869Z", + values: { + "text@formId": "65c4ea4ac04244000878b1f3", + "text@name": "Demo form 12", + "object@fields": [ + { + "text@_id": "-WO0Tj8p4z", + "text@fieldId": "demoField", + "text@type": "text", + "text@name": "text", + "text@label": "Demo field", + "text@placeholderText": null, + "text@helpText": null, + "object@options": [], + "object@validation": [] + } + ], + "object@steps": [ + { + "text@title": "Step 1" + } + ], + "object@settings": { + "object@layout": { + "text@renderer": "default" + }, + "text@submitButtonLabel": null, + "boolean@fullWidthSubmitButton": null, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + } + }, + "text@slug": "demo-form-12-65c4ea4ac04244000878b1f3" + }, + revisionSavedBy: user, + tenant: "otherTenant", + revisionModifiedOn: "2024-02-08T14:51:05.869Z", + createdOn: "2024-02-08T14:50:50.570Z", + modifiedOn: "2024-02-08T14:51:05.869Z", + locked: true, + webinyVersion: "0.0.0", + modifiedBy: user, + firstPublishedOn: "2024-02-08T14:51:05.869Z", + lastPublishedOn: "2024-02-08T14:51:05.869Z", + firstPublishedBy: user, + lastPublishedBy: user, + revisionFirstPublishedOn: "2024-02-08T14:51:05.869Z", + revisionLastPublishedOn: "2024-02-08T14:51:05.869Z", + revisionFirstPublishedBy: user, + revisionLastPublishedBy: user, + rawValues: { + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [] + } + ], + "object@steps": [ + { + "json@layout": [["-WO0Tj8p4z"]] + } + ], + "object@settings": { + "object@layout": {}, + "json@successMessage": null, + "object@reCaptcha": {} + }, + "json@triggers": null + }, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + } + } +]; + +const getMigratedDdbEsFormStatsData = () => { + const forms = createFormsData().filter(form => form.TYPE === "fb.form"); + + return forms.map(form => { + const [formId, revisionId] = form.id.split("#"); + + return { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${formId}-${revisionId}-stats`, + SK: "L", + data: { + webinyVersion: form.webinyVersion, + tenant: form.tenant, + entryId: `${formId}-${revisionId}-stats`, + id: `${formId}-${revisionId}-stats#0001`, + modelId: "fbFormStat", + locale: form.locale, + createdOn: form.createdOn, + savedOn: form.savedOn, + createdBy: user, + savedBy: user, + revisionCreatedOn: form.createdOn, + revisionSavedOn: form.savedOn, + revisionCreatedBy: user, + revisionSavedBy: user, + version: 1, + status: "draft", + locked: false, + values: { + "text@formId": form.formId, + "number@formVersion": form.version, + "number@views": form.stats.views, + "number@submissions": form.stats.submissions + }, + location: { folderId: "root" }, + rawValues: {}, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }; + }); +}; + +export const createMigratedDdbEsData = () => { + const migratedDdbEsFormStatsData = getMigratedDdbEsFormStatsData(); + + return [...migratedDdbEsFormData, ...migratedDdbEsFormStatsData]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.test.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.test.ts new file mode 100644 index 00000000000..8bcba8709fc --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/001.test.ts @@ -0,0 +1,260 @@ +import sortBy from "lodash/sortBy"; +import { + assertNotError, + createDdbEsMigrationHandler, + getDynamoToEsTable, + getPrimaryDynamoDbTable, + groupMigrations, + insertDynamoDbTestData as insertTestData, + logTestNameBeforeEachTest, + scanTable +} from "~tests/utils"; +import { FormBuilder_5_40_0_001 } from "~/migrations/5.40.0/001/ddb-es"; +import { insertElasticsearchTestData } from "~tests/utils/insertElasticsearchTestData"; +import { esGetIndexName } from "~/utils"; +import { createElasticsearchClient } from "@webiny/project-utils/testing/elasticsearch/createClient"; +import { + createLocalesData, + createTenantsData, + createFormsData +} from "~tests/migrations/5.40.0/001/ddb-es/001.ddb"; +import { createEsFormsData } from "~tests/migrations/5.40.0/001/ddb-es/001.es"; +import { + getMigratedFormStatsData, + migratedDdbFormData +} from "~tests/migrations/5.40.0/001/ddb-es/001.migrated.ddb"; +import { createMigratedDdbEsData } from "~tests/migrations/5.40.0/001/ddb-es/001.migrated.ddbEs"; +import { getDecompressedData } from "~tests/migrations/5.40.0/001/ddb-es/helpers"; + +jest.retryTimes(0); +jest.setTimeout(900000); + +describe("5.40.0-001", () => { + const primaryTable = getPrimaryDynamoDbTable(); + const dynamoToEsTable = getDynamoToEsTable(); + const elasticsearchClient = createElasticsearchClient(); + + beforeAll(async () => { + process.env.ELASTIC_SEARCH_INDEX_PREFIX = + new Date().toISOString().replace(/\.|\:/g, "-").toLowerCase() + "-"; + + await elasticsearchClient.indices.deleteAll(); + }); + + afterEach(async () => { + await elasticsearchClient.indices.deleteAll(); + }); + + logTestNameBeforeEachTest(); + + it("should not run if no tenant found", async () => { + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no locale found", async () => { + await insertTestData(primaryTable, [...createTenantsData()]); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no forms found", async () => { + await insertTestData(primaryTable, [...createTenantsData(), ...createLocalesData()]); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should execute migration", async () => { + await insertTestData(primaryTable, [ + ...createFormsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + await insertElasticsearchTestData(elasticsearchClient, createEsFormsData(), item => { + return esGetIndexName({ + tenant: item.tenant, + locale: item.locale, + isHeadlessCmsModel: false, + type: "form-builder" + }); + }); + + await elasticsearchClient.indices.refreshAll(); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(1); + expect(grouped.skipped.length).toBe(0); + expect(grouped.notApplicable.length).toBe(0); + + // Check DDB Form entries + const ddbFormEntries = await scanTable(primaryTable, { + filters: [ + { + attr: "modelId", + eq: "fbForm" + } + ] + }); + + expect(sortBy(ddbFormEntries, ["PK", "SK"])).toEqual( + sortBy(migratedDdbFormData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + + // Check DDB Stats entries + const ddbStatsEntries = await scanTable(primaryTable, { + filters: [ + { + attr: "modelId", + eq: "fbFormStat" + } + ] + }); + + const migratedFormStatsData = getMigratedFormStatsData(); + + expect(sortBy(ddbStatsEntries, ["PK", "SK"])).toEqual( + sortBy(migratedFormStatsData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + + // Check DDB + ES Form / Form Stats entries + const ddbEsFormEntries = await scanTable(dynamoToEsTable, { + limit: 1_000_000 + }); + + const ddbEsFormEntriesDecompressed = await Promise.all( + ddbEsFormEntries.map(async item => { + return { + ...item, + data: await getDecompressedData(item.data) + }; + }) + ); + + const migratedDdbEsData = createMigratedDdbEsData(); + + expect(sortBy(ddbEsFormEntriesDecompressed, ["PK", "SK"])).toEqual( + sortBy(migratedDdbEsData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntriesElasticsearch", + index: expect.any(String), + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + }); + + it("should not run migration if data is already in the expected shape", async () => { + await insertTestData(primaryTable, [ + ...createFormsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + await insertElasticsearchTestData(elasticsearchClient, createEsFormsData(), item => { + return esGetIndexName({ + tenant: item.tenant, + locale: item.locale, + isHeadlessCmsModel: false, + type: "form-builder" + }); + }); + + await elasticsearchClient.indices.refreshAll(); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_001] + }); + + // Should run the migration + { + process.stdout.write("[First run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(1); + } + + // Should skip the migration + { + process.stdout.write("[Second run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + } + }); +}); diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/helpers.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/helpers.ts new file mode 100644 index 00000000000..1c75693b159 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb-es/helpers.ts @@ -0,0 +1,7 @@ +import { createGzipCompression } from "@webiny/api-elasticsearch"; + +export const getDecompressedData = async (data: any): Promise => { + const compression = createGzipCompression(); + + return (await compression.decompress(data)) as unknown as R; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.data.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.data.ts new file mode 100644 index 00000000000..7f4d943f398 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.data.ts @@ -0,0 +1,2746 @@ +export const user = { + id: "admin", + type: "admin", + displayName: "Admin" +}; + +export const createFormsData = () => { + return [ + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#FB#F", + SK: "65b12c8ecd6a580008f2fa31#0001", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "Pr3Pj3w2zO" + } + ], + formId: "65b12c8ecd6a580008f2fa31", + GSI1_PK: "T#root#L#en-US#FB#F#65b12c8ecd6a580008f2fa31", + GSI1_SK: "1", + id: "65b12c8ecd6a580008f2fa31#0001", + locale: "en-US", + locked: true, + name: "Demo Form 1", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T15:28:31.263Z", + savedOn: "2024-01-24T15:28:31.263Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65b12c8ecd6a580008f2fa31", + stats: { + submissions: 100, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["Pr3Pj3w2zO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T15:28:31.283Z", + _et: "FormBuilderForm", + _md: "2024-01-24T15:28:31.283Z" + }, + { + PK: "T#root#L#en-US#FB#F", + SK: "65b12c8ecd6a580008f2fa31#0002", + createdBy: user, + createdOn: "2024-01-24T15:28:37.723Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "Pr3Pj3w2zO" + } + ], + formId: "65b12c8ecd6a580008f2fa31", + GSI1_PK: "T#root#L#en-US#FB#F#65b12c8ecd6a580008f2fa31", + GSI1_SK: "2", + id: "65b12c8ecd6a580008f2fa31#0002", + locale: "en-US", + locked: false, + name: "Demo Form 1", + ownedBy: user, + published: false, + savedOn: "2024-01-24T15:28:41.543Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65b12c8ecd6a580008f2fa31", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["Pr3Pj3w2zO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-24T15:28:41.548Z", + _et: "FormBuilderForm", + _md: "2024-01-24T15:28:41.548Z" + }, + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b12c8ecd6a580008f2fa31", + createdBy: user, + createdOn: "2024-01-24T15:28:37.723Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "Pr3Pj3w2zO" + } + ], + formId: "65b12c8ecd6a580008f2fa31", + id: "65b12c8ecd6a580008f2fa31#0002", + locale: "en-US", + locked: false, + name: "Demo Form 1", + ownedBy: user, + published: false, + savedOn: "2024-01-24T15:28:41.543Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65b12c8ecd6a580008f2fa31", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["Pr3Pj3w2zO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-24T15:28:41.549Z", + _et: "FormBuilderForm", + _md: "2024-01-24T15:28:41.549Z" + }, + { + PK: "T#root#L#en-US#FB#F#LP", + SK: "65b12c8ecd6a580008f2fa31", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "Pr3Pj3w2zO" + } + ], + formId: "65b12c8ecd6a580008f2fa31", + id: "65b12c8ecd6a580008f2fa31#0001", + locale: "en-US", + locked: true, + name: "Demo Form 1", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T15:28:31.263Z", + savedOn: "2024-01-24T15:28:31.263Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-1-65b12c8ecd6a580008f2fa31", + stats: { + submissions: 10, + views: 100 + }, + status: "published", + steps: [ + { + layout: [["Pr3Pj3w2zO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T15:28:31.283Z", + _et: "FormBuilderForm", + _md: "2024-01-24T15:28:31.283Z" + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#FB#F", + SK: "65b139b15cb71f0008718ac9#0001", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "kpBvlR4SjU" + } + ], + formId: "65b139b15cb71f0008718ac9", + GSI1_PK: "T#root#L#en-US#FB#F#65b139b15cb71f0008718ac9", + GSI1_SK: "1", + id: "65b139b15cb71f0008718ac9#0001", + locale: "en-US", + locked: false, + name: "Demo form 2", + ownedBy: user, + published: false, + savedOn: "2024-01-24T16:24:34.090Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65b139b15cb71f0008718ac9", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["kpBvlR4SjU"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T16:24:34.109Z", + _et: "FormBuilderForm", + _md: "2024-01-24T16:24:34.109Z" + }, + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b139b15cb71f0008718ac9", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "kpBvlR4SjU" + } + ], + formId: "65b139b15cb71f0008718ac9", + id: "65b139b15cb71f0008718ac9#0001", + locale: "en-US", + locked: false, + name: "Demo form 2", + ownedBy: user, + published: false, + savedOn: "2024-01-24T16:24:34.090Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-2-65b139b15cb71f0008718ac9", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["kpBvlR4SjU"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T16:24:34.110Z", + _et: "FormBuilderForm", + _md: "2024-01-24T16:24:34.110Z" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#FB#F", + SK: "65b14a9982c87000081f93b3#0001", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + GSI1_PK: "T#root#L#en-US#FB#F#65b14a9982c87000081f93b3", + GSI1_SK: "1", + id: "65b14a9982c87000081f93b3#0001", + locale: "en-US", + locked: true, + name: "Demo Form 3", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T17:36:45.577Z", + savedOn: "2024-01-24T17:36:45.577Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 10, + views: 100 + }, + status: "published", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:36:45.583Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:36:45.583Z" + }, + { + PK: "T#root#L#en-US#FB#F", + SK: "65b14a9982c87000081f93b3#0002", + createdBy: user, + createdOn: "2024-01-24T17:37:08.943Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + GSI1_PK: "T#root#L#en-US#FB#F#65b14a9982c87000081f93b3", + GSI1_SK: "2", + id: "65b14a9982c87000081f93b3#0002", + locale: "en-US", + locked: true, + name: "Demo Form 3", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T17:37:13.678Z", + savedOn: "2024-01-24T17:37:13.678Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 20, + views: 200 + }, + status: "published", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:37:13.682Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:37:13.682Z" + }, + { + PK: "T#root#L#en-US#FB#F", + SK: "65b14a9982c87000081f93b3#0003", + createdBy: user, + createdOn: "2024-01-24T17:38:28.497Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + GSI1_PK: "T#root#L#en-US#FB#F#65b14a9982c87000081f93b3", + GSI1_SK: "3", + id: "65b14a9982c87000081f93b3#0003", + locale: "en-US", + locked: true, + name: "Demo Form 3", + ownedBy: user, + published: false, + publishedOn: "2024-01-24T17:38:49.877Z", + savedOn: "2024-01-24T17:39:26.457Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 0, + views: 0 + }, + status: "locked", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 3, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:39:26.498Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:39:26.498Z" + }, + { + PK: "T#root#L#en-US#FB#F", + SK: "65b14a9982c87000081f93b3#0004", + createdBy: user, + createdOn: "2024-01-24T17:39:11.428Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + GSI1_PK: "T#root#L#en-US#FB#F#65b14a9982c87000081f93b3", + GSI1_SK: "4", + id: "65b14a9982c87000081f93b3#0004", + locale: "en-US", + locked: false, + name: "Demo Form 3", + ownedBy: user, + published: false, + savedOn: "2024-01-24T17:39:11.428Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 4, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:39:11.429Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:39:11.429Z" + }, + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b14a9982c87000081f93b3", + createdBy: user, + createdOn: "2024-01-24T17:39:11.428Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + id: "65b14a9982c87000081f93b3#0004", + locale: "en-US", + locked: false, + name: "Demo Form 3", + ownedBy: user, + published: false, + savedOn: "2024-01-24T17:39:11.428Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 4, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:39:11.429Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:39:11.429Z" + }, + { + PK: "T#root#L#en-US#FB#F#LP", + SK: "65b14a9982c87000081f93b3", + createdBy: user, + createdOn: "2024-01-24T17:37:08.943Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "VLGQV3Wx-o" + } + ], + formId: "65b14a9982c87000081f93b3", + GSI1_PK: "T#root#L#en-US#FB#F#65b14a9982c87000081f93b3", + GSI1_SK: "2", + id: "65b14a9982c87000081f93b3#0002", + locale: "en-US", + locked: true, + name: "Demo Form 3", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T17:37:13.678Z", + savedOn: "2024-01-24T17:37:13.678Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-3-65b14a9982c87000081f93b3", + stats: { + submissions: 20, + views: 200 + }, + status: "published", + steps: [ + { + layout: [["VLGQV3Wx-o"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-24T17:37:13.682Z", + _et: "FormBuilderForm", + _md: "2024-01-24T17:37:13.682Z" + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b16a8d7918760008c0ea56", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + fields: [ + { + fieldId: "firstName", + helpText: null, + label: "First name", + name: "firstName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "wKBpJ6lq0" + }, + { + fieldId: "lastName", + helpText: null, + label: "Last name", + name: "lastName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "ylPaYyVaM" + }, + { + fieldId: "email", + helpText: null, + label: "Email", + name: "email", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid e-mail.", + name: "pattern", + settings: { + flags: null, + preset: "email", + regex: null + } + }, + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "u1miDVk2r" + }, + { + fieldId: "phoneNumber", + helpText: null, + label: "Phone number", + name: "phoneNumber", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "54ED5X_p6" + } + ], + formId: "65b16a8d7918760008c0ea56", + id: "65b16a8d7918760008c0ea56#0001", + locale: "en-US", + locked: false, + name: "Demo Form 4", + ownedBy: user, + published: false, + savedOn: "2024-01-24T19:53:54.458Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65b16a8d7918760008c0ea56", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["wKBpJ6lq0"], ["ylPaYyVaM"]], + title: "Step 1" + }, + { + layout: [["u1miDVk2r"], ["54ED5X_p6"]], + title: "New Step" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T19:53:54.477Z", + _et: "FormBuilderForm", + _md: "2024-01-24T19:53:54.477Z" + }, + { + PK: "T#root#L#en-US#FB#F", + SK: "65b16a8d7918760008c0ea56#0001", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + fields: [ + { + fieldId: "firstName", + helpText: null, + label: "First name", + name: "firstName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "wKBpJ6lq0" + }, + { + fieldId: "lastName", + helpText: null, + label: "Last name", + name: "lastName", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "ylPaYyVaM" + }, + { + fieldId: "email", + helpText: null, + label: "Email", + name: "email", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Please enter a valid e-mail.", + name: "pattern", + settings: { + flags: null, + preset: "email", + regex: null + } + }, + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "u1miDVk2r" + }, + { + fieldId: "phoneNumber", + helpText: null, + label: "Phone number", + name: "phoneNumber", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "54ED5X_p6" + } + ], + formId: "65b16a8d7918760008c0ea56", + GSI1_PK: "T#root#L#en-US#FB#F#65b16a8d7918760008c0ea56", + GSI1_SK: "1", + id: "65b16a8d7918760008c0ea56#0001", + locale: "en-US", + locked: false, + name: "Demo Form 4", + ownedBy: user, + published: false, + savedOn: "2024-01-24T19:53:54.458Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-4-65b16a8d7918760008c0ea56", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["wKBpJ6lq0"], ["ylPaYyVaM"]], + title: "Step 1" + }, + { + layout: [["u1miDVk2r"], ["54ED5X_p6"]], + title: "New Step" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T19:53:54.477Z", + _et: "FormBuilderForm", + _md: "2024-01-24T19:53:54.477Z" + }, + + // Form with default fields + { + PK: "T#root#L#en-US#FB#F", + SK: "65b189f16f69800008e6161b#0001", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + fields: [ + { + fieldId: "hiddenField", + helpText: "Hidden Field - Help Text", + label: "Hidden Field", + name: "hidden", + options: [], + placeholderText: null, + settings: { + defaultValue: "Hidden Field - Default Value" + }, + type: "hidden", + validation: [], + _id: "NZWPSHZRIN" + }, + { + fieldId: "selectField", + helpText: "Select Field - Help Text", + label: "Select Field", + name: "select", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: "Select Field - Help Text", + settings: { + defaultValue: "option2" + }, + type: "select", + validation: [], + _id: "vxI0OE-flE" + }, + { + fieldId: "shortText", + helpText: "Short Text - Help Text", + label: "Short Text", + name: "text", + options: [], + placeholderText: "Short Text - Placeholder Text", + settings: { + defaultValue: "Short Text - Default Value" + }, + type: "text", + validation: [ + { + message: "Value is too short.", + name: "minLength", + settings: { + value: "1" + } + }, + { + message: "Value is too long.", + name: "maxLength", + settings: { + value: "6" + } + } + ], + _id: "1om83kly5s" + }, + { + fieldId: "longText", + helpText: "Long Text - Help Text", + label: "Long Text", + name: "textarea", + options: [], + placeholderText: "Long Text - Placeholder Text", + settings: { + defaultValue: "Long Text - Default Text", + rows: "10" + }, + type: "textarea", + validation: [], + _id: "9L3Wgow6-b" + }, + { + fieldId: "numberField", + helpText: "Number Field - Help Text", + label: "Number Field", + name: "number", + options: [], + placeholderText: "Number Field - Placeholder Text", + settings: { + defaultValue: null + }, + type: "number", + validation: [], + _id: "2gUedk4Aa1" + }, + { + fieldId: "radioField", + helpText: "Radio Field - Help Text", + label: "Radio Field", + name: "radio", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: "option2", + otherOption: true + }, + type: "radio", + validation: [], + _id: "tiR3t0uctA" + }, + { + fieldId: "checkboxField", + helpText: "Checkbox Field - Help Text", + label: "Checkbox Field", + name: "checkbox", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: ["option3"], + otherOption: true + }, + type: "checkbox", + validation: [], + _id: "W99qOcY4ie" + }, + { + fieldId: "dateTimeField", + helpText: "DateTime Field - Help Text", + label: "DateTime Field", + name: "date", + options: [], + placeholderText: null, + settings: { + defaultValue: null, + format: "dateTimeWithTimezone" + }, + type: "datetime", + validation: [], + _id: "1e542PkJHp" + } + ], + formId: "65b189f16f69800008e6161b", + GSI1_PK: "T#root#L#en-US#FB#F#65b189f16f69800008e6161b", + GSI1_SK: "1", + id: "65b189f16f69800008e6161b#0001", + locale: "en-US", + locked: false, + name: "Demo Form 5", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:13:12.913Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-5-65b189f16f69800008e6161b", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [ + ["NZWPSHZRIN"], + ["vxI0OE-flE"], + ["1om83kly5s", "9L3Wgow6-b"], + ["2gUedk4Aa1"], + ["tiR3t0uctA", "W99qOcY4ie"], + ["1e542PkJHp"] + ], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:13:12.945Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:13:12.945Z" + }, + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b189f16f69800008e6161b", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + fields: [ + { + fieldId: "hiddenField", + helpText: "Hidden Field - Help Text", + label: "Hidden Field", + name: "hidden", + options: [], + placeholderText: null, + settings: { + defaultValue: "Hidden Field - Default Value" + }, + type: "hidden", + validation: [], + _id: "NZWPSHZRIN" + }, + { + fieldId: "selectField", + helpText: "Select Field - Help Text", + label: "Select Field", + name: "select", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: "Select Field - Help Text", + settings: { + defaultValue: "option2" + }, + type: "select", + validation: [], + _id: "vxI0OE-flE" + }, + { + fieldId: "shortText", + helpText: "Short Text - Help Text", + label: "Short Text", + name: "text", + options: [], + placeholderText: "Short Text - Placeholder Text", + settings: { + defaultValue: "Short Text - Default Value" + }, + type: "text", + validation: [ + { + message: "Value is too short.", + name: "minLength", + settings: { + value: "1" + } + }, + { + message: "Value is too long.", + name: "maxLength", + settings: { + value: "6" + } + } + ], + _id: "1om83kly5s" + }, + { + fieldId: "longText", + helpText: "Long Text - Help Text", + label: "Long Text", + name: "textarea", + options: [], + placeholderText: "Long Text - Placeholder Text", + settings: { + defaultValue: "Long Text - Default Text", + rows: "10" + }, + type: "textarea", + validation: [], + _id: "9L3Wgow6-b" + }, + { + fieldId: "numberField", + helpText: "Number Field - Help Text", + label: "Number Field", + name: "number", + options: [], + placeholderText: "Number Field - Placeholder Text", + settings: { + defaultValue: null + }, + type: "number", + validation: [], + _id: "2gUedk4Aa1" + }, + { + fieldId: "radioField", + helpText: "Radio Field - Help Text", + label: "Radio Field", + name: "radio", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: "option2", + otherOption: true + }, + type: "radio", + validation: [], + _id: "tiR3t0uctA" + }, + { + fieldId: "checkboxField", + helpText: "Checkbox Field - Help Text", + label: "Checkbox Field", + name: "checkbox", + options: [ + { + label: "Option 1", + value: "option1" + }, + { + label: "Option 2", + value: "option2" + }, + { + label: "Option 3", + value: "option3" + } + ], + placeholderText: null, + settings: { + defaultValue: ["option3"], + otherOption: true + }, + type: "checkbox", + validation: [], + _id: "W99qOcY4ie" + }, + { + fieldId: "dateTimeField", + helpText: "DateTime Field - Help Text", + label: "DateTime Field", + name: "date", + options: [], + placeholderText: null, + settings: { + defaultValue: null, + format: "dateTimeWithTimezone" + }, + type: "datetime", + validation: [], + _id: "1e542PkJHp" + } + ], + formId: "65b189f16f69800008e6161b", + id: "65b189f16f69800008e6161b#0001", + locale: "en-US", + locked: false, + name: "Demo Form 5", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:13:12.913Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-5-65b189f16f69800008e6161b", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [ + ["NZWPSHZRIN"], + ["vxI0OE-flE"], + ["1om83kly5s", "9L3Wgow6-b"], + ["2gUedk4Aa1"], + ["tiR3t0uctA", "W99qOcY4ie"], + ["1e542PkJHp"] + ], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:13:12.945Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:13:12.945Z" + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#FB#F", + SK: "65b18df865a46200087864f9#0001", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "dMWqYyLYQV" + } + ], + formId: "65b18df865a46200087864f9", + GSI1_PK: "T#root#L#en-US#FB#F#65b18df865a46200087864f9", + GSI1_SK: "1", + id: "65b18df865a46200087864f9#0001", + locale: "en-US", + locked: false, + name: "Demo Form 6", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:26:03.138Z", + settings: { + fullWidthSubmitButton: true, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: true, + errorMessage: "Custom Captcha error message" + }, + submitButtonLabel: "Custom submit button label", + successMessage: [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "fjiaYeH_wW", + type: "paragraph" + } + ], + termsOfServiceMessage: { + enabled: true, + errorMessage: "Custom error message", + message: [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "kjBMY6NBnA", + type: "paragraph" + } + ] + } + }, + slug: "demo-form-6-65b18df865a46200087864f9", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["dMWqYyLYQV"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:26:03.155Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:26:03.155Z" + }, + { + PK: "T#root#L#en-US#FB#F#L", + SK: "65b18df865a46200087864f9", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "dMWqYyLYQV" + } + ], + formId: "65b18df865a46200087864f9", + id: "65b18df865a46200087864f9#0001", + locale: "en-US", + locked: false, + name: "Demo Form 6", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:26:03.138Z", + settings: { + fullWidthSubmitButton: true, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: true, + errorMessage: "Custom Captcha error message" + }, + submitButtonLabel: "Custom submit button label", + successMessage: [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "fjiaYeH_wW", + type: "paragraph" + } + ], + termsOfServiceMessage: { + enabled: true, + errorMessage: "Custom error message", + message: [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "kjBMY6NBnA", + type: "paragraph" + } + ] + } + }, + slug: "demo-form-6-65b18df865a46200087864f9", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["dMWqYyLYQV"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:26:03.156Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:26:03.156Z" + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#FB#F#L", + SK: "65b190cad481d800089f2479", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "dV3wx0ForO" + } + ], + formId: "65b190cad481d800089f2479", + id: "65b190cad481d800089f2479#0001", + locale: "de-DE", + locked: true, + name: "Demo Form 7", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T22:36:12.348Z", + savedOn: "2024-01-24T22:36:12.348Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-7-65b190cad481d800089f2479", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["dV3wx0ForO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:36:12.362Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:36:12.362Z" + }, + { + PK: "T#root#L#de-DE#FB#F#LP", + SK: "65b190cad481d800089f2479", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "dV3wx0ForO" + } + ], + formId: "65b190cad481d800089f2479", + id: "65b190cad481d800089f2479#0001", + locale: "de-DE", + locked: true, + name: "Demo Form 7", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T22:36:12.348Z", + savedOn: "2024-01-24T22:36:12.348Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-7-65b190cad481d800089f2479", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["dV3wx0ForO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:36:12.362Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:36:12.362Z" + }, + { + PK: "T#root#L#de-DE#FB#F", + SK: "65b190cad481d800089f2479#0001", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "dV3wx0ForO" + } + ], + formId: "65b190cad481d800089f2479", + GSI1_PK: "T#root#L#de-DE#FB#F#65b190cad481d800089f2479", + GSI1_SK: "1", + id: "65b190cad481d800089f2479#0001", + locale: "de-DE", + locked: true, + name: "Demo Form 7", + ownedBy: user, + published: true, + publishedOn: "2024-01-24T22:36:12.348Z", + savedOn: "2024-01-24T22:36:12.348Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-7-65b190cad481d800089f2479", + stats: { + submissions: 1000, + views: 10000 + }, + status: "published", + steps: [ + { + layout: [["dV3wx0ForO"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:36:12.361Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:36:12.361Z" + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#FB#F#L", + SK: "65b19428b583b90008e7a3bc", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "njnnUb42N6" + } + ], + formId: "65b19428b583b90008e7a3bc", + id: "65b19428b583b90008e7a3bc#0001", + locale: "fr-FR", + locked: false, + name: "Demo Form 8", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:50:26.517Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-8-65b19428b583b90008e7a3bc", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["njnnUb42N6"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:50:26.538Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:50:26.538Z" + }, + { + PK: "T#root#L#fr-FR#FB#F", + SK: "65b19428b583b90008e7a3bc#0001", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "njnnUb42N6" + } + ], + formId: "65b19428b583b90008e7a3bc", + GSI1_PK: "T#root#L#fr-FR#FB#F#65b19428b583b90008e7a3bc", + GSI1_SK: "1", + id: "65b19428b583b90008e7a3bc#0001", + locale: "fr-FR", + locked: false, + name: "Demo Form 8", + ownedBy: user, + published: false, + savedOn: "2024-01-24T22:50:26.517Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-8-65b19428b583b90008e7a3bc", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["njnnUb42N6"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-24T22:50:26.537Z", + _et: "FormBuilderForm", + _md: "2024-01-24T22:50:26.537Z" + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#FB#F#LP", + SK: "65b2050e264766000809d7aa", + createdBy: user, + createdOn: "2024-01-25T06:52:56.840Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "1vzUX-cmPP" + } + ], + formId: "65b2050e264766000809d7aa", + id: "65b2050e264766000809d7aa#0002", + locale: "de-DE", + locked: true, + name: "Demo Form 9", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T06:53:03.955Z", + savedOn: "2024-01-25T06:53:03.955Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65b2050e264766000809d7aa", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [["1vzUX-cmPP"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latestPublished", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-25T06:53:04.001Z", + _et: "FormBuilderForm", + _md: "2024-01-25T06:53:04.001Z" + }, + { + PK: "T#root#L#de-DE#FB#F#L", + SK: "65b2050e264766000809d7aa", + createdBy: user, + createdOn: "2024-01-25T06:52:56.840Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "1vzUX-cmPP" + } + ], + formId: "65b2050e264766000809d7aa", + id: "65b2050e264766000809d7aa#0002", + locale: "de-DE", + locked: true, + name: "Demo Form 9", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T06:53:03.955Z", + savedOn: "2024-01-25T06:53:03.955Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65b2050e264766000809d7aa", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [["1vzUX-cmPP"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form.latest", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-25T06:53:04.001Z", + _et: "FormBuilderForm", + _md: "2024-01-25T06:53:04.001Z" + }, + { + PK: "T#root#L#de-DE#FB#F", + SK: "65b2050e264766000809d7aa#0001", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "1vzUX-cmPP" + } + ], + formId: "65b2050e264766000809d7aa", + GSI1_PK: "T#root#L#de-DE#FB#F#65b2050e264766000809d7aa", + GSI1_SK: "1", + id: "65b2050e264766000809d7aa#0001", + locale: "de-DE", + locked: true, + name: "Demo Form 9", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T06:52:51.920Z", + savedOn: "2024-01-25T06:52:51.920Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65b2050e264766000809d7aa", + stats: { + submissions: 100, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["1vzUX-cmPP"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T06:52:51.995Z", + _et: "FormBuilderForm", + _md: "2024-01-25T06:52:51.995Z" + }, + { + PK: "T#root#L#de-DE#FB#F", + SK: "65b2050e264766000809d7aa#0002", + createdBy: user, + createdOn: "2024-01-25T06:52:56.840Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [ + { + message: "Value is required.", + name: "required", + settings: {} + } + ], + _id: "1vzUX-cmPP" + } + ], + formId: "65b2050e264766000809d7aa", + GSI1_PK: "T#root#L#de-DE#FB#F#65b2050e264766000809d7aa", + GSI1_SK: "2", + id: "65b2050e264766000809d7aa#0002", + locale: "de-DE", + locked: true, + name: "Demo Form 9", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T06:53:03.955Z", + savedOn: "2024-01-25T06:53:03.955Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-9-65b2050e264766000809d7aa", + stats: { + submissions: 0, + views: 0 + }, + status: "published", + steps: [ + { + layout: [["1vzUX-cmPP"]], + title: "Step 1" + } + ], + tenant: "root", + TYPE: "fb.form", + version: 2, + webinyVersion: "0.0.0", + _ct: "2024-01-25T06:53:04.001Z", + _et: "FormBuilderForm", + _md: "2024-01-25T06:53:04.001Z" + }, + + // Form 1 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#FB#F#L", + SK: "65b20b8f0321db00083d35c1", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "EBPeRi4u0Z" + } + ], + formId: "65b20b8f0321db00083d35c1", + id: "65b20b8f0321db00083d35c1#0001", + locale: "fr-FR", + locked: false, + name: "Demo Form 10", + ownedBy: user, + published: false, + savedOn: "2024-01-25T07:19:51.052Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-10-65b20b8f0321db00083d35c1", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["EBPeRi4u0Z"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T07:19:51.076Z", + _et: "FormBuilderForm", + _md: "2024-01-25T07:19:51.076Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F", + SK: "65b20b8f0321db00083d35c1#0001", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "EBPeRi4u0Z" + } + ], + formId: "65b20b8f0321db00083d35c1", + GSI1_PK: "T#otherTenant#L#fr-FR#FB#F#65b20b8f0321db00083d35c1", + GSI1_SK: "1", + id: "65b20b8f0321db00083d35c1#0001", + locale: "fr-FR", + locked: false, + name: "Demo Form 10", + ownedBy: user, + published: false, + savedOn: "2024-01-25T07:19:51.052Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-10-65b20b8f0321db00083d35c1", + stats: { + submissions: 0, + views: 0 + }, + status: "draft", + steps: [ + { + layout: [["EBPeRi4u0Z"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T07:19:51.075Z", + _et: "FormBuilderForm", + _md: "2024-01-25T07:19:51.075Z" + }, + + // Form 2 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#FB#F#LP", + SK: "65b20bc00321db00083d35c9", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "tk4jYhc8DI" + } + ], + formId: "65b20bc00321db00083d35c9", + id: "65b20bc00321db00083d35c9#0001", + locale: "fr-FR", + locked: true, + name: "Demo Form 11", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T07:20:49.543Z", + savedOn: "2024-01-25T07:20:49.543Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65b20bc00321db00083d35c9", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["tk4jYhc8DI"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latestPublished", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T07:20:49.553Z", + _et: "FormBuilderForm", + _md: "2024-01-25T07:20:49.553Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F#L", + SK: "65b20bc00321db00083d35c9", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "tk4jYhc8DI" + } + ], + formId: "65b20bc00321db00083d35c9", + id: "65b20bc00321db00083d35c9#0001", + locale: "fr-FR", + locked: true, + name: "Demo Form 11", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T07:20:49.543Z", + savedOn: "2024-01-25T07:20:49.543Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65b20bc00321db00083d35c9", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["tk4jYhc8DI"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form.latest", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T07:20:49.553Z", + _et: "FormBuilderForm", + _md: "2024-01-25T07:20:49.553Z" + }, + { + PK: "T#otherTenant#L#fr-FR#FB#F", + SK: "65b20bc00321db00083d35c9#0001", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + fields: [ + { + fieldId: "demoField", + helpText: null, + label: "Demo Field", + name: "text", + options: [], + placeholderText: null, + settings: { + defaultValue: null + }, + type: "text", + validation: [], + _id: "tk4jYhc8DI" + } + ], + formId: "65b20bc00321db00083d35c9", + GSI1_PK: "T#otherTenant#L#fr-FR#FB#F#65b20bc00321db00083d35c9", + GSI1_SK: "1", + id: "65b20bc00321db00083d35c9#0001", + locale: "fr-FR", + locked: true, + name: "Demo Form 11", + ownedBy: user, + published: true, + publishedOn: "2024-01-25T07:20:49.543Z", + savedOn: "2024-01-25T07:20:49.543Z", + settings: { + fullWidthSubmitButton: null, + layout: { + renderer: "default" + }, + reCaptcha: { + enabled: null, + errorMessage: "Please verify that you are not a robot." + }, + submitButtonLabel: null, + successMessage: null, + termsOfServiceMessage: null + }, + slug: "demo-form-11-65b20bc00321db00083d35c9", + stats: { + submissions: 500, + views: 1000 + }, + status: "published", + steps: [ + { + layout: [["tk4jYhc8DI"]], + title: "Step 1" + } + ], + tenant: "otherTenant", + TYPE: "fb.form", + version: 1, + webinyVersion: "0.0.0", + _ct: "2024-01-25T07:20:49.553Z", + _et: "FormBuilderForm", + _md: "2024-01-25T07:20:49.553Z" + } + ]; +}; + +export const createTenantsData = () => { + return [ + { + PK: "T#root", + SK: "A", + createdOn: "2023-01-25T09:37:58.183Z", + description: "The top-level Webiny tenant.", + GSI1_PK: "TENANTS", + GSI1_SK: "T#null#2023-01-25T09:37:58.183Z", + data: { + id: "root", + name: "Root", + savedOn: "2023-01-25T09:37:58.183Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + }, + { + PK: "T#otherTenant", + SK: "A", + createdOn: "2023-03-11T09:59:17.327Z", + description: "Tenant #1", + GSI1_PK: "TENANTS", + GSI1_SK: "T#root#2023-03-11T09:59:17.327Z", + data: { + id: "otherTenant", + name: "Other Tenant", + parent: "root", + savedOn: "2023-03-11T09:59:17.327Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + } + ]; +}; + +export const createLocalesData = () => { + return [ + { + PK: `T#root#I18N#L`, + SK: "en-US", + code: "en-US", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + } + ]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.migratedData.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.migratedData.ts new file mode 100644 index 00000000000..a6d529eb4b7 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.migratedData.ts @@ -0,0 +1,4139 @@ +export const user = { + id: "admin", + type: "admin", + displayName: "Admin" +}; + +export const migratedFormData = [ + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T15:28:31.263Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b12c8ecd6a580008f2fa31#0002", + id: "65b12c8ecd6a580008f2fa31#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T15:28:31.263Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T15:28:41.543Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:37.723Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T15:28:41.543Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:41.543Z", + savedBy: user, + savedOn: "2024-01-24T15:28:41.543Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Pr3Pj3w2zO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Pr3Pj3w2zO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b12c8ecd6a580008f2fa31", + "text@name": "Demo Form 1", + "text@slug": "demo-form-1-65b12c8ecd6a580008f2fa31" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31", + SK: "P", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T15:28:31.263Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#P", + GSI1_SK: "65b12c8ecd6a580008f2fa31#0001", + id: "65b12c8ecd6a580008f2fa31#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T15:28:31.263Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T15:28:31.263Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:14.710Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T15:28:31.263Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T15:28:31.263Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T15:28:31.263Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:31.263Z", + savedBy: user, + savedOn: "2024-01-24T15:28:31.263Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@type": "text", + "text@placeholderText": null, + "text@_id": "Pr3Pj3w2zO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Pr3Pj3w2zO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b12c8ecd6a580008f2fa31", + "text@name": "Demo Form 1", + "text@slug": "demo-form-1-65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T15:28:31.263Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b12c8ecd6a580008f2fa31#0001", + id: "65b12c8ecd6a580008f2fa31#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T15:28:31.263Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T15:28:31.263Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:14.710Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T15:28:31.263Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T15:28:31.263Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T15:28:31.263Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:31.263Z", + savedBy: user, + savedOn: "2024-01-24T15:28:31.263Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Pr3Pj3w2zO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Pr3Pj3w2zO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b12c8ecd6a580008f2fa31", + "text@name": "Demo Form 1", + "text@slug": "demo-form-1-65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T15:28:31.263Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b12c8ecd6a580008f2fa31#0002", + id: "65b12c8ecd6a580008f2fa31#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T15:28:31.263Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T15:28:41.543Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:37.723Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T15:28:41.543Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:41.543Z", + savedBy: user, + savedOn: "2024-01-24T15:28:41.543Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "Pr3Pj3w2zO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["Pr3Pj3w2zO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b12c8ecd6a580008f2fa31", + "text@name": "Demo Form 1", + "text@slug": "demo-form-1-65b12c8ecd6a580008f2fa31" + }, + version: 2, + webinyVersion: "0.0.0" + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#CMS#CME#CME#65b139b15cb71f0008718ac9", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + entryId: "65b139b15cb71f0008718ac9", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b139b15cb71f0008718ac9#0001", + id: "65b139b15cb71f0008718ac9#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T16:24:34.090Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T16:24:17.185Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T16:24:34.090Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T16:24:34.090Z", + savedBy: user, + savedOn: "2024-01-24T16:24:34.090Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [], + "object@options": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "kpBvlR4SjU" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["kpBvlR4SjU"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b139b15cb71f0008718ac9", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65b139b15cb71f0008718ac9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b139b15cb71f0008718ac9", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + entryId: "65b139b15cb71f0008718ac9", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b139b15cb71f0008718ac9#0001", + id: "65b139b15cb71f0008718ac9#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T16:24:34.090Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T16:24:17.185Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T16:24:34.090Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T16:24:34.090Z", + savedBy: user, + savedOn: "2024-01-24T16:24:34.090Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "kpBvlR4SjU" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["kpBvlR4SjU"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b139b15cb71f0008718ac9", + "text@name": "Demo form 2", + "text@slug": "demo-form-2-65b139b15cb71f0008718ac9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b14a9982c87000081f93b3#0004", + id: "65b14a9982c87000081f93b3#0004", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:39:11.428Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:39:11.428Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:39:11.428Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:11.428Z", + savedBy: user, + savedOn: "2024-01-24T17:39:11.428Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [], + "object@options": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 4, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "P", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#P", + GSI1_SK: "65b14a9982c87000081f93b3#0002", + id: "65b14a9982c87000081f93b3#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:37:13.678Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:37:08.943Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T17:37:13.678Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T17:37:13.678Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:37:13.678Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:37:13.678Z", + savedBy: user, + savedOn: "2024-01-24T17:37:13.678Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b14a9982c87000081f93b3#0001", + id: "65b14a9982c87000081f93b3#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:36:45.577Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:36:25.519Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T17:37:13.678Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T17:37:13.678Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:36:45.577Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:36:45.577Z", + savedBy: user, + savedOn: "2024-01-24T17:36:45.577Z", + status: "unpublished", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b14a9982c87000081f93b3#0002", + id: "65b14a9982c87000081f93b3#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:37:13.678Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:37:08.943Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T17:37:13.678Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T17:37:13.678Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:37:13.678Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:37:13.678Z", + savedBy: user, + savedOn: "2024-01-24T17:37:13.678Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "REV#0003", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b14a9982c87000081f93b3#0003", + id: "65b14a9982c87000081f93b3#0003", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:39:26.457Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:38:28.497Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T17:37:13.678Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T17:37:13.678Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:39:26.457Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:26.457Z", + savedBy: user, + savedOn: "2024-01-24T17:39:26.457Z", + status: "unpublished", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@type": "text", + "text@placeholderText": null, + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 3, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3", + SK: "REV#0004", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T17:37:13.678Z", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b14a9982c87000081f93b3#0004", + id: "65b14a9982c87000081f93b3#0004", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T17:37:13.678Z", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T17:39:11.428Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:39:11.428Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T17:39:11.428Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:11.428Z", + savedBy: user, + savedOn: "2024-01-24T17:39:11.428Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "VLGQV3Wx-o" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["VLGQV3Wx-o"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b14a9982c87000081f93b3", + "text@name": "Demo Form 3", + "text@slug": "demo-form-3-65b14a9982c87000081f93b3" + }, + version: 4, + webinyVersion: "0.0.0" + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#CMS#CME#CME#65b16a8d7918760008c0ea56", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + entryId: "65b16a8d7918760008c0ea56", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b16a8d7918760008c0ea56#0001", + id: "65b16a8d7918760008c0ea56#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T19:53:54.458Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T19:52:45.637Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T19:53:54.458Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T19:53:54.458Z", + savedBy: user, + savedOn: "2024-01-24T19:53:54.458Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "firstName", + "text@label": "First name", + "text@name": "firstName", + "text@helpText": null, + "text@placeholderText": null, + "text@type": "text", + "text@_id": "wKBpJ6lq0" + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "object@options": [], + "text@fieldId": "lastName", + "text@helpText": null, + "text@label": "Last name", + "text@name": "lastName", + "text@type": "text", + "text@placeholderText": null, + "text@_id": "ylPaYyVaM" + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "email", + regex: null + }, + "text@message": "Please enter a valid e-mail.", + "text@name": "pattern" + }, + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "email", + "text@label": "Email", + "text@name": "email", + "text@type": "text", + "text@_id": "u1miDVk2r", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "phoneNumber", + "text@label": "Phone number", + "text@name": "phoneNumber", + "text@type": "text", + "text@_id": "54ED5X_p6", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["wKBpJ6lq0"], ["ylPaYyVaM"]], + "text@title": "Step 1" + }, + { + "json@layout": [["u1miDVk2r"], ["54ED5X_p6"]], + "text@title": "New Step" + } + ], + "text@formId": "65b16a8d7918760008c0ea56", + "text@name": "Demo Form 4", + "text@slug": "demo-form-4-65b16a8d7918760008c0ea56" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b16a8d7918760008c0ea56", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + entryId: "65b16a8d7918760008c0ea56", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b16a8d7918760008c0ea56#0001", + id: "65b16a8d7918760008c0ea56#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T19:53:54.458Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T19:52:45.637Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T19:53:54.458Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T19:53:54.458Z", + savedBy: user, + savedOn: "2024-01-24T19:53:54.458Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "firstName", + "text@label": "First name", + "text@name": "firstName", + "text@type": "text", + "text@_id": "wKBpJ6lq0", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "lastName", + "text@label": "Last name", + "text@name": "lastName", + "text@type": "text", + "text@_id": "ylPaYyVaM", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": { + flags: null, + preset: "email", + regex: null + }, + "text@message": "Please enter a valid e-mail.", + "text@name": "pattern" + }, + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "email", + "text@label": "Email", + "text@name": "email", + "text@type": "text", + "text@_id": "u1miDVk2r", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + }, + { + "json@settings": { + defaultValue: null + }, + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "phoneNumber", + "text@label": "Phone number", + "text@name": "phoneNumber", + "text@type": "text", + "text@_id": "54ED5X_p6", + "object@options": [], + "text@helpText": null, + "text@placeholderText": null + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["wKBpJ6lq0"], ["ylPaYyVaM"]], + "text@title": "Step 1" + }, + { + "json@layout": [["u1miDVk2r"], ["54ED5X_p6"]], + "text@title": "New Step" + } + ], + "text@formId": "65b16a8d7918760008c0ea56", + "text@name": "Demo Form 4", + "text@slug": "demo-form-4-65b16a8d7918760008c0ea56" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with default fields + { + PK: "T#root#L#en-US#CMS#CME#CME#65b189f16f69800008e6161b", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + entryId: "65b189f16f69800008e6161b", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b189f16f69800008e6161b#0001", + id: "65b189f16f69800008e6161b#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:13:12.913Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:06:41.291Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:13:12.913Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:13:12.913Z", + savedBy: user, + savedOn: "2024-01-24T22:13:12.913Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: "Hidden Field - Default Value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "hiddenField", + "text@helpText": "Hidden Field - Help Text", + "text@label": "Hidden Field", + "text@name": "hidden", + "text@placeholderText": null, + "text@type": "hidden", + "text@_id": "NZWPSHZRIN" + }, + { + "json@settings": { + defaultValue: "option2" + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "selectField", + "text@helpText": "Select Field - Help Text", + "text@label": "Select Field", + "text@name": "select", + "text@placeholderText": "Select Field - Help Text", + "text@type": "select", + "text@_id": "vxI0OE-flE" + }, + { + "json@settings": { + defaultValue: "Short Text - Default Value" + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + value: "1" + }, + "text@message": "Value is too short.", + "text@name": "minLength" + }, + { + "json@settings": { + value: "6" + }, + "text@message": "Value is too long.", + "text@name": "maxLength" + } + ], + "text@fieldId": "shortText", + "text@helpText": "Short Text - Help Text", + "text@label": "Short Text", + "text@name": "text", + "text@placeholderText": "Short Text - Placeholder Text", + "text@type": "text", + "text@_id": "1om83kly5s" + }, + { + "json@settings": { + defaultValue: "Long Text - Default Text", + rows: "10" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "longText", + "text@helpText": "Long Text - Help Text", + "text@label": "Long Text", + "text@name": "textarea", + "text@placeholderText": "Long Text - Placeholder Text", + "text@type": "textarea", + "text@_id": "9L3Wgow6-b" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "numberField", + "text@helpText": "Number Field - Help Text", + "text@label": "Number Field", + "text@name": "number", + "text@placeholderText": "Number Field - Placeholder Text", + "text@type": "number", + "text@_id": "2gUedk4Aa1" + }, + { + "json@settings": { + defaultValue: "option2", + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "radioField", + "text@helpText": "Radio Field - Help Text", + "text@label": "Radio Field", + "text@name": "radio", + "text@placeholderText": null, + "text@type": "radio", + "text@_id": "tiR3t0uctA" + }, + { + "json@settings": { + defaultValue: ["option3"], + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "checkboxField", + "text@helpText": "Checkbox Field - Help Text", + "text@label": "Checkbox Field", + "text@name": "checkbox", + "text@placeholderText": null, + "text@type": "checkbox", + "text@_id": "W99qOcY4ie" + }, + { + "json@settings": { + defaultValue: null, + format: "dateTimeWithTimezone" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "dateTimeField", + "text@helpText": "DateTime Field - Help Text", + "text@label": "DateTime Field", + "text@name": "date", + "text@placeholderText": null, + "text@type": "datetime", + "text@_id": "1e542PkJHp" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [ + ["NZWPSHZRIN"], + ["vxI0OE-flE"], + ["1om83kly5s", "9L3Wgow6-b"], + ["2gUedk4Aa1"], + ["tiR3t0uctA", "W99qOcY4ie"], + ["1e542PkJHp"] + ], + "text@title": "Step 1" + } + ], + "text@formId": "65b189f16f69800008e6161b", + "text@name": "Demo Form 5", + "text@slug": "demo-form-5-65b189f16f69800008e6161b" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b189f16f69800008e6161b", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + entryId: "65b189f16f69800008e6161b", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b189f16f69800008e6161b#0001", + id: "65b189f16f69800008e6161b#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:13:12.913Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:06:41.291Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:13:12.913Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:13:12.913Z", + savedBy: user, + savedOn: "2024-01-24T22:13:12.913Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: "Hidden Field - Default Value" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "hiddenField", + "text@helpText": "Hidden Field - Help Text", + "text@label": "Hidden Field", + "text@name": "hidden", + "text@placeholderText": null, + "text@type": "hidden", + "text@_id": "NZWPSHZRIN" + }, + { + "json@settings": { + defaultValue: "option2" + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "selectField", + "text@helpText": "Select Field - Help Text", + "text@label": "Select Field", + "text@name": "select", + "text@placeholderText": "Select Field - Help Text", + "text@type": "select", + "text@_id": "vxI0OE-flE" + }, + { + "json@settings": { + defaultValue: "Short Text - Default Value" + }, + "object@options": [], + "object@validation": [ + { + "json@settings": { + value: "1" + }, + "text@message": "Value is too short.", + "text@name": "minLength" + }, + { + "json@settings": { + value: "6" + }, + "text@message": "Value is too long.", + "text@name": "maxLength" + } + ], + "text@fieldId": "shortText", + "text@helpText": "Short Text - Help Text", + "text@label": "Short Text", + "text@name": "text", + "text@placeholderText": "Short Text - Placeholder Text", + "text@type": "text", + "text@_id": "1om83kly5s" + }, + { + "json@settings": { + defaultValue: "Long Text - Default Text", + rows: "10" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "longText", + "text@helpText": "Long Text - Help Text", + "text@label": "Long Text", + "text@name": "textarea", + "text@placeholderText": "Long Text - Placeholder Text", + "text@type": "textarea", + "text@_id": "9L3Wgow6-b" + }, + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "numberField", + "text@helpText": "Number Field - Help Text", + "text@label": "Number Field", + "text@name": "number", + "text@placeholderText": "Number Field - Placeholder Text", + "text@type": "number", + "text@_id": "2gUedk4Aa1" + }, + { + "json@settings": { + defaultValue: "option2", + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "radioField", + "text@helpText": "Radio Field - Help Text", + "text@label": "Radio Field", + "text@name": "radio", + "text@placeholderText": null, + "text@type": "radio", + "text@_id": "tiR3t0uctA" + }, + { + "json@settings": { + defaultValue: ["option3"], + otherOption: true + }, + "object@options": [ + { + "text@label": "Option 1", + "text@value": "option1" + }, + { + "text@label": "Option 2", + "text@value": "option2" + }, + { + "text@label": "Option 3", + "text@value": "option3" + } + ], + "object@validation": [], + "text@fieldId": "checkboxField", + "text@helpText": "Checkbox Field - Help Text", + "text@label": "Checkbox Field", + "text@name": "checkbox", + "text@placeholderText": null, + "text@type": "checkbox", + "text@_id": "W99qOcY4ie" + }, + { + "json@settings": { + defaultValue: null, + format: "dateTimeWithTimezone" + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "dateTimeField", + "text@helpText": "DateTime Field - Help Text", + "text@label": "DateTime Field", + "text@name": "date", + "text@placeholderText": null, + "text@type": "datetime", + "text@_id": "1e542PkJHp" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [ + ["NZWPSHZRIN"], + ["vxI0OE-flE"], + ["1om83kly5s", "9L3Wgow6-b"], + ["2gUedk4Aa1"], + ["tiR3t0uctA", "W99qOcY4ie"], + ["1e542PkJHp"] + ], + "text@title": "Step 1" + } + ], + "text@formId": "65b189f16f69800008e6161b", + "text@name": "Demo Form 5", + "text@slug": "demo-form-5-65b189f16f69800008e6161b" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#CMS#CME#CME#65b18df865a46200087864f9", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + entryId: "65b18df865a46200087864f9", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#L", + GSI1_SK: "65b18df865a46200087864f9#0001", + id: "65b18df865a46200087864f9#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:26:03.138Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:23:52.364Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:26:03.138Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:26:03.138Z", + savedBy: user, + savedOn: "2024-01-24T22:26:03.138Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "dMWqYyLYQV" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": true, + "json@successMessage": [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "fjiaYeH_wW", + type: "paragraph" + } + ], + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": true, + "text@errorMessage": "Custom Captcha error message" + }, + "object@termsOfServiceMessage": { + "boolean@enabled": true, + "json@message": [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "kjBMY6NBnA", + type: "paragraph" + } + ], + "text@errorMessage": "Custom error message" + }, + "text@submitButtonLabel": "Custom submit button label" + }, + "object@steps": [ + { + "json@layout": [["dMWqYyLYQV"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b18df865a46200087864f9", + "text@name": "Demo Form 6", + "text@slug": "demo-form-6-65b18df865a46200087864f9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b18df865a46200087864f9", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + entryId: "65b18df865a46200087864f9", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbForm#A", + GSI1_SK: "65b18df865a46200087864f9#0001", + id: "65b18df865a46200087864f9#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:26:03.138Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:23:52.364Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:26:03.138Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:26:03.138Z", + savedBy: user, + savedOn: "2024-01-24T22:26:03.138Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "dMWqYyLYQV" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": true, + "json@successMessage": [ + { + data: { + className: null, + text: "Custom success message", + textAlign: "start" + }, + id: "fjiaYeH_wW", + type: "paragraph" + } + ], + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": true, + "text@errorMessage": "Custom Captcha error message" + }, + "object@termsOfServiceMessage": { + "boolean@enabled": true, + "json@message": [ + { + data: { + className: null, + text: "Custom term of service message", + textAlign: "start" + }, + id: "kjBMY6NBnA", + type: "paragraph" + } + ], + "text@errorMessage": "Custom error message" + }, + "text@submitButtonLabel": "Custom submit button label" + }, + "object@steps": [ + { + "json@layout": [["dMWqYyLYQV"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b18df865a46200087864f9", + "text@name": "Demo Form 6", + "text@slug": "demo-form-6-65b18df865a46200087864f9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b190cad481d800089f2479", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + entryId: "65b190cad481d800089f2479", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T22:36:12.348Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#L", + GSI1_SK: "65b190cad481d800089f2479#0001", + id: "65b190cad481d800089f2479#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T22:36:12.348Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:36:12.348Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:35:54.384Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T22:36:12.348Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T22:36:12.348Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:36:12.348Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:36:12.348Z", + savedBy: user, + savedOn: "2024-01-24T22:36:12.348Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "dV3wx0ForO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["dV3wx0ForO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b190cad481d800089f2479", + "text@name": "Demo Form 7", + "text@slug": "demo-form-7-65b190cad481d800089f2479" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b190cad481d800089f2479", + SK: "P", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + entryId: "65b190cad481d800089f2479", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T22:36:12.348Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#P", + GSI1_SK: "65b190cad481d800089f2479#0001", + id: "65b190cad481d800089f2479#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T22:36:12.348Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:36:12.348Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:35:54.384Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T22:36:12.348Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T22:36:12.348Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:36:12.348Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:36:12.348Z", + savedBy: user, + savedOn: "2024-01-24T22:36:12.348Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "dV3wx0ForO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["dV3wx0ForO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b190cad481d800089f2479", + "text@name": "Demo Form 7", + "text@slug": "demo-form-7-65b190cad481d800089f2479" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b190cad481d800089f2479", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + entryId: "65b190cad481d800089f2479", + firstPublishedBy: user, + firstPublishedOn: "2024-01-24T22:36:12.348Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#A", + GSI1_SK: "65b190cad481d800089f2479#0001", + id: "65b190cad481d800089f2479#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-24T22:36:12.348Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:36:12.348Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:35:54.384Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-24T22:36:12.348Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-24T22:36:12.348Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:36:12.348Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:36:12.348Z", + savedBy: user, + savedOn: "2024-01-24T22:36:12.348Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "dV3wx0ForO" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["dV3wx0ForO"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b190cad481d800089f2479", + "text@name": "Demo Form 7", + "text@slug": "demo-form-7-65b190cad481d800089f2479" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#CMS#CME#CME#65b19428b583b90008e7a3bc", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + entryId: "65b19428b583b90008e7a3bc", + GSI1_PK: "T#root#L#fr-FR#CMS#CME#M#fbForm#L", + GSI1_SK: "65b19428b583b90008e7a3bc#0001", + id: "65b19428b583b90008e7a3bc#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:50:26.517Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:50:16.158Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:50:26.517Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:50:26.517Z", + savedBy: user, + savedOn: "2024-01-24T22:50:26.517Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "njnnUb42N6" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["njnnUb42N6"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b19428b583b90008e7a3bc", + "text@name": "Demo Form 8", + "text@slug": "demo-form-8-65b19428b583b90008e7a3bc" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#fr-FR#CMS#CME#CME#65b19428b583b90008e7a3bc", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + entryId: "65b19428b583b90008e7a3bc", + GSI1_PK: "T#root#L#fr-FR#CMS#CME#M#fbForm#A", + GSI1_SK: "65b19428b583b90008e7a3bc#0001", + id: "65b19428b583b90008e7a3bc#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-24T22:50:26.517Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:50:16.158Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-24T22:50:26.517Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:50:26.517Z", + savedBy: user, + savedOn: "2024-01-24T22:50:26.517Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "njnnUb42N6" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["njnnUb42N6"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b19428b583b90008e7a3bc", + "text@name": "Demo Form 8", + "text@slug": "demo-form-8-65b19428b583b90008e7a3bc" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T06:53:03.955Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#L", + GSI1_SK: "65b2050e264766000809d7aa#0002", + id: "65b2050e264766000809d7aa#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T06:53:03.955Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T06:53:03.955Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:52:56.840Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T06:53:03.955Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T06:53:03.955Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T06:53:03.955Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:53:03.955Z", + savedBy: user, + savedOn: "2024-01-25T06:53:03.955Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "1vzUX-cmPP" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["1vzUX-cmPP"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b2050e264766000809d7aa", + "text@name": "Demo Form 9", + "text@slug": "demo-form-9-65b2050e264766000809d7aa" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa", + SK: "P", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T06:53:03.955Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#P", + GSI1_SK: "65b2050e264766000809d7aa#0002", + id: "65b2050e264766000809d7aa#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T06:53:03.955Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T06:53:03.955Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:52:56.840Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T06:53:03.955Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T06:53:03.955Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T06:53:03.955Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:53:03.955Z", + savedBy: user, + savedOn: "2024-01-25T06:53:03.955Z", + status: "published", + tenant: "root", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "1vzUX-cmPP" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["1vzUX-cmPP"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b2050e264766000809d7aa", + "text@name": "Demo Form 9", + "text@slug": "demo-form-9-65b2050e264766000809d7aa" + }, + version: 2, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T06:53:03.955Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#A", + GSI1_SK: "65b2050e264766000809d7aa#0001", + id: "65b2050e264766000809d7aa#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T06:53:03.955Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T06:52:51.920Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:51:58.036Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T06:53:03.955Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T06:53:03.955Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T06:52:51.920Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:52:51.920Z", + savedBy: user, + savedOn: "2024-01-25T06:52:51.920Z", + status: "unpublished", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@label": "Demo Field", + "text@name": "text", + "text@type": "text", + "text@_id": "1vzUX-cmPP", + "text@helpText": null, + "text@placeholderText": null + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["1vzUX-cmPP"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b2050e264766000809d7aa", + "text@name": "Demo Form 9", + "text@slug": "demo-form-9-65b2050e264766000809d7aa" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa", + SK: "REV#0002", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T06:53:03.955Z", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbForm#A", + GSI1_SK: "65b2050e264766000809d7aa#0002", + id: "65b2050e264766000809d7aa#0002", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T06:53:03.955Z", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T06:53:03.955Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:52:56.840Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T06:53:03.955Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T06:53:03.955Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T06:53:03.955Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:53:03.955Z", + savedBy: user, + savedOn: "2024-01-25T06:53:03.955Z", + status: "published", + tenant: "root", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [ + { + "json@settings": {}, + "text@message": "Value is required.", + "text@name": "required" + } + ], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "1vzUX-cmPP" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["1vzUX-cmPP"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b2050e264766000809d7aa", + "text@name": "Demo Form 9", + "text@slug": "demo-form-9-65b2050e264766000809d7aa" + }, + version: 2, + webinyVersion: "0.0.0" + }, + + // Form 1 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20b8f0321db00083d35c1", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + entryId: "65b20b8f0321db00083d35c1", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbForm#L", + GSI1_SK: "65b20b8f0321db00083d35c1#0001", + id: "65b20b8f0321db00083d35c1#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T07:19:51.052Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:19:43.219Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T07:19:51.052Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:19:51.052Z", + savedBy: user, + savedOn: "2024-01-25T07:19:51.052Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "EBPeRi4u0Z" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["EBPeRi4u0Z"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b20b8f0321db00083d35c1", + "text@name": "Demo Form 10", + "text@slug": "demo-form-10-65b20b8f0321db00083d35c1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20b8f0321db00083d35c1", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + entryId: "65b20b8f0321db00083d35c1", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbForm#A", + GSI1_SK: "65b20b8f0321db00083d35c1#0001", + id: "65b20b8f0321db00083d35c1#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T07:19:51.052Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:19:43.219Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T07:19:51.052Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:19:51.052Z", + savedBy: user, + savedOn: "2024-01-25T07:19:51.052Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "EBPeRi4u0Z" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["EBPeRi4u0Z"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b20b8f0321db00083d35c1", + "text@name": "Demo Form 10", + "text@slug": "demo-form-10-65b20b8f0321db00083d35c1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20bc00321db00083d35c9", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + entryId: "65b20bc00321db00083d35c9", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T07:20:49.543Z", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbForm#L", + GSI1_SK: "65b20bc00321db00083d35c9#0001", + id: "65b20bc00321db00083d35c9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T07:20:49.543Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T07:20:49.543Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:20:32.550Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T07:20:49.543Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T07:20:49.543Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T07:20:49.543Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:20:49.543Z", + savedBy: user, + savedOn: "2024-01-25T07:20:49.543Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry.l", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "tk4jYhc8DI" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["tk4jYhc8DI"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b20bc00321db00083d35c9", + "text@name": "Demo Form 11", + "text@slug": "demo-form-11-65b20bc00321db00083d35c9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20bc00321db00083d35c9", + SK: "P", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + entryId: "65b20bc00321db00083d35c9", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T07:20:49.543Z", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbForm#P", + GSI1_SK: "65b20bc00321db00083d35c9#0001", + id: "65b20bc00321db00083d35c9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T07:20:49.543Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T07:20:49.543Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:20:32.550Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T07:20:49.543Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T07:20:49.543Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T07:20:49.543Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:20:49.543Z", + savedBy: user, + savedOn: "2024-01-25T07:20:49.543Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry.p", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "tk4jYhc8DI" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["tk4jYhc8DI"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b20bc00321db00083d35c9", + "text@name": "Demo Form 11", + "text@slug": "demo-form-11-65b20bc00321db00083d35c9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20bc00321db00083d35c9", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + entryId: "65b20bc00321db00083d35c9", + firstPublishedBy: user, + firstPublishedOn: "2024-01-25T07:20:49.543Z", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbForm#A", + GSI1_SK: "65b20bc00321db00083d35c9#0001", + id: "65b20bc00321db00083d35c9#0001", + lastPublishedBy: user, + lastPublishedOn: "2024-01-25T07:20:49.543Z", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: true, + meta: {}, + modelId: "fbForm", + modifiedBy: user, + modifiedOn: "2024-01-25T07:20:49.543Z", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:20:32.550Z", + revisionFirstPublishedBy: user, + revisionFirstPublishedOn: "2024-01-25T07:20:49.543Z", + revisionLastPublishedBy: user, + revisionLastPublishedOn: "2024-01-25T07:20:49.543Z", + revisionModifiedBy: user, + revisionModifiedOn: "2024-01-25T07:20:49.543Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:20:49.543Z", + savedBy: user, + savedOn: "2024-01-25T07:20:49.543Z", + status: "published", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "json@triggers": null, + "object@fields": [ + { + "json@settings": { + defaultValue: null + }, + "object@options": [], + "object@validation": [], + "text@fieldId": "demoField", + "text@helpText": null, + "text@label": "Demo Field", + "text@name": "text", + "text@placeholderText": null, + "text@type": "text", + "text@_id": "tk4jYhc8DI" + } + ], + "object@settings": { + "boolean@fullWidthSubmitButton": null, + "json@successMessage": null, + "object@layout": { + "text@renderer": "default" + }, + "object@reCaptcha": { + "boolean@enabled": null, + "text@errorMessage": "Please verify that you are not a robot." + }, + "text@submitButtonLabel": null + }, + "object@steps": [ + { + "json@layout": [["tk4jYhc8DI"]], + "text@title": "Step 1" + } + ], + "text@formId": "65b20bc00321db00083d35c9", + "text@name": "Demo Form 11", + "text@slug": "demo-form-11-65b20bc00321db00083d35c9" + }, + version: 1, + webinyVersion: "0.0.0" + } +]; + +export const migratedFormStatsData = [ + // Form with 2 revisions: 1° published, 2° draft + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b12c8ecd6a580008f2fa31-0001-stats#0001", + id: "65b12c8ecd6a580008f2fa31-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:14.710Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:31.263Z", + savedBy: user, + savedOn: "2024-01-24T15:28:31.263Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 100, + "number@views": 1000, + "text@formId": "65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T15:28:14.710Z", + entryId: "65b12c8ecd6a580008f2fa31-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b12c8ecd6a580008f2fa31-0001-stats#0001", + id: "65b12c8ecd6a580008f2fa31-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:14.710Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:31.263Z", + savedBy: user, + savedOn: "2024-01-24T15:28:31.263Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 100, + "number@views": 1000, + "text@formId": "65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31-0002-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T15:28:37.723Z", + entryId: "65b12c8ecd6a580008f2fa31-0002-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b12c8ecd6a580008f2fa31-0002-stats#0001", + id: "65b12c8ecd6a580008f2fa31-0002-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:37.723Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:41.543Z", + savedBy: user, + savedOn: "2024-01-24T15:28:41.543Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 2, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b12c8ecd6a580008f2fa31-0002-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T15:28:37.723Z", + entryId: "65b12c8ecd6a580008f2fa31-0002-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b12c8ecd6a580008f2fa31-0002-stats#0001", + id: "65b12c8ecd6a580008f2fa31-0002-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T15:28:37.723Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T15:28:41.543Z", + savedBy: user, + savedOn: "2024-01-24T15:28:41.543Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 2, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b12c8ecd6a580008f2fa31" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with 1 draft revision + { + PK: "T#root#L#en-US#CMS#CME#CME#65b139b15cb71f0008718ac9-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + entryId: "65b139b15cb71f0008718ac9-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b139b15cb71f0008718ac9-0001-stats#0001", + id: "65b139b15cb71f0008718ac9-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T16:24:17.185Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T16:24:34.090Z", + savedBy: user, + savedOn: "2024-01-24T16:24:34.090Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b139b15cb71f0008718ac9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b139b15cb71f0008718ac9-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T16:24:17.185Z", + entryId: "65b139b15cb71f0008718ac9-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b139b15cb71f0008718ac9-0001-stats#0001", + id: "65b139b15cb71f0008718ac9-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T16:24:17.185Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T16:24:34.090Z", + savedBy: user, + savedOn: "2024-01-24T16:24:34.090Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b139b15cb71f0008718ac9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with 4 revisions: 1° published, 2° published, 3° unpublished, 4° draft + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0003-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T17:38:28.497Z", + entryId: "65b14a9982c87000081f93b3-0003-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b14a9982c87000081f93b3-0003-stats#0001", + id: "65b14a9982c87000081f93b3-0003-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:38:28.497Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:26.457Z", + savedBy: user, + savedOn: "2024-01-24T17:39:26.457Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 3, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0003-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T17:38:28.497Z", + entryId: "65b14a9982c87000081f93b3-0003-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b14a9982c87000081f93b3-0003-stats#0001", + id: "65b14a9982c87000081f93b3-0003-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:38:28.497Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:26.457Z", + savedBy: user, + savedOn: "2024-01-24T17:39:26.457Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 3, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b14a9982c87000081f93b3-0001-stats#0001", + id: "65b14a9982c87000081f93b3-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:36:25.519Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:36:45.577Z", + savedBy: user, + savedOn: "2024-01-24T17:36:45.577Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 10, + "number@views": 100, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T17:36:25.519Z", + entryId: "65b14a9982c87000081f93b3-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b14a9982c87000081f93b3-0001-stats#0001", + id: "65b14a9982c87000081f93b3-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:36:25.519Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:36:45.577Z", + savedBy: user, + savedOn: "2024-01-24T17:36:45.577Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 10, + "number@views": 100, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0004-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T17:39:11.428Z", + entryId: "65b14a9982c87000081f93b3-0004-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b14a9982c87000081f93b3-0004-stats#0001", + id: "65b14a9982c87000081f93b3-0004-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:39:11.428Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:11.428Z", + savedBy: user, + savedOn: "2024-01-24T17:39:11.428Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 4, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0004-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T17:39:11.428Z", + entryId: "65b14a9982c87000081f93b3-0004-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b14a9982c87000081f93b3-0004-stats#0001", + id: "65b14a9982c87000081f93b3-0004-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:39:11.428Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:39:11.428Z", + savedBy: user, + savedOn: "2024-01-24T17:39:11.428Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 4, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0002-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T17:37:08.943Z", + entryId: "65b14a9982c87000081f93b3-0002-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b14a9982c87000081f93b3-0002-stats#0001", + id: "65b14a9982c87000081f93b3-0002-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:37:08.943Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:37:13.678Z", + savedBy: user, + savedOn: "2024-01-24T17:37:13.678Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 2, + "number@submissions": 20, + "number@views": 200, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b14a9982c87000081f93b3-0002-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T17:37:08.943Z", + entryId: "65b14a9982c87000081f93b3-0002-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b14a9982c87000081f93b3-0002-stats#0001", + id: "65b14a9982c87000081f93b3-0002-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T17:37:08.943Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T17:37:13.678Z", + savedBy: user, + savedOn: "2024-01-24T17:37:13.678Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 2, + "number@submissions": 20, + "number@views": 200, + "text@formId": "65b14a9982c87000081f93b3" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with contact fields, required, organised in 2 steps + { + PK: "T#root#L#en-US#CMS#CME#CME#65b16a8d7918760008c0ea56-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + entryId: "65b16a8d7918760008c0ea56-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b16a8d7918760008c0ea56-0001-stats#0001", + id: "65b16a8d7918760008c0ea56-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T19:52:45.637Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T19:53:54.458Z", + savedBy: user, + savedOn: "2024-01-24T19:53:54.458Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b16a8d7918760008c0ea56" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b16a8d7918760008c0ea56-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T19:52:45.637Z", + entryId: "65b16a8d7918760008c0ea56-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b16a8d7918760008c0ea56-0001-stats#0001", + id: "65b16a8d7918760008c0ea56-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T19:52:45.637Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T19:53:54.458Z", + savedBy: user, + savedOn: "2024-01-24T19:53:54.458Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b16a8d7918760008c0ea56" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with default fields + { + PK: "T#root#L#en-US#CMS#CME#CME#65b189f16f69800008e6161b-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + entryId: "65b189f16f69800008e6161b-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b189f16f69800008e6161b-0001-stats#0001", + id: "65b189f16f69800008e6161b-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:06:41.291Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:13:12.913Z", + savedBy: user, + savedOn: "2024-01-24T22:13:12.913Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b189f16f69800008e6161b" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b189f16f69800008e6161b-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:06:41.291Z", + entryId: "65b189f16f69800008e6161b-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b189f16f69800008e6161b-0001-stats#0001", + id: "65b189f16f69800008e6161b-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:06:41.291Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:13:12.913Z", + savedBy: user, + savedOn: "2024-01-24T22:13:12.913Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b189f16f69800008e6161b" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form with custom settings + { + PK: "T#root#L#en-US#CMS#CME#CME#65b18df865a46200087864f9-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + entryId: "65b18df865a46200087864f9-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b18df865a46200087864f9-0001-stats#0001", + id: "65b18df865a46200087864f9-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:23:52.364Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:26:03.138Z", + savedBy: user, + savedOn: "2024-01-24T22:26:03.138Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b18df865a46200087864f9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#en-US#CMS#CME#CME#65b18df865a46200087864f9-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:23:52.364Z", + entryId: "65b18df865a46200087864f9-0001-stats", + GSI1_PK: "T#root#L#en-US#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b18df865a46200087864f9-0001-stats#0001", + id: "65b18df865a46200087864f9-0001-stats#0001", + locale: "en-US", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:23:52.364Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:26:03.138Z", + savedBy: user, + savedOn: "2024-01-24T22:26:03.138Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b18df865a46200087864f9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b190cad481d800089f2479-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + entryId: "65b190cad481d800089f2479-0001-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b190cad481d800089f2479-0001-stats#0001", + id: "65b190cad481d800089f2479-0001-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:35:54.384Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:36:12.348Z", + savedBy: user, + savedOn: "2024-01-24T22:36:12.348Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 1000, + "number@views": 10000, + "text@formId": "65b190cad481d800089f2479" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b190cad481d800089f2479-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:35:54.384Z", + entryId: "65b190cad481d800089f2479-0001-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b190cad481d800089f2479-0001-stats#0001", + id: "65b190cad481d800089f2479-0001-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:35:54.384Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:36:12.348Z", + savedBy: user, + savedOn: "2024-01-24T22:36:12.348Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 1000, + "number@views": 10000, + "text@formId": "65b190cad481d800089f2479" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from root tenant, locale de-DE + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa-0001-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b2050e264766000809d7aa-0001-stats#0001", + id: "65b2050e264766000809d7aa-0001-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:51:58.036Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:52:51.920Z", + savedBy: user, + savedOn: "2024-01-25T06:52:51.920Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 100, + "number@views": 1000, + "text@formId": "65b2050e264766000809d7aa" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T06:51:58.036Z", + entryId: "65b2050e264766000809d7aa-0001-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b2050e264766000809d7aa-0001-stats#0001", + id: "65b2050e264766000809d7aa-0001-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:51:58.036Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:52:51.920Z", + savedBy: user, + savedOn: "2024-01-25T06:52:51.920Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 100, + "number@views": 1000, + "text@formId": "65b2050e264766000809d7aa" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa-0002-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T06:52:56.840Z", + entryId: "65b2050e264766000809d7aa-0002-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b2050e264766000809d7aa-0002-stats#0001", + id: "65b2050e264766000809d7aa-0002-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:52:56.840Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:53:03.955Z", + savedBy: user, + savedOn: "2024-01-25T06:53:03.955Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 2, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b2050e264766000809d7aa" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#de-DE#CMS#CME#CME#65b2050e264766000809d7aa-0002-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T06:52:56.840Z", + entryId: "65b2050e264766000809d7aa-0002-stats", + GSI1_PK: "T#root#L#de-DE#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b2050e264766000809d7aa-0002-stats#0001", + id: "65b2050e264766000809d7aa-0002-stats#0001", + locale: "de-DE", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T06:52:56.840Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T06:53:03.955Z", + savedBy: user, + savedOn: "2024-01-25T06:53:03.955Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 2, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b2050e264766000809d7aa" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from root tenant, locale fr-FR + { + PK: "T#root#L#fr-FR#CMS#CME#CME#65b19428b583b90008e7a3bc-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + entryId: "65b19428b583b90008e7a3bc-0001-stats", + GSI1_PK: "T#root#L#fr-FR#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b19428b583b90008e7a3bc-0001-stats#0001", + id: "65b19428b583b90008e7a3bc-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:50:16.158Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:50:26.517Z", + savedBy: user, + savedOn: "2024-01-24T22:50:26.517Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b19428b583b90008e7a3bc" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#root#L#fr-FR#CMS#CME#CME#65b19428b583b90008e7a3bc-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-24T22:50:16.158Z", + entryId: "65b19428b583b90008e7a3bc-0001-stats", + GSI1_PK: "T#root#L#fr-FR#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b19428b583b90008e7a3bc-0001-stats#0001", + id: "65b19428b583b90008e7a3bc-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-24T22:50:16.158Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-24T22:50:26.517Z", + savedBy: user, + savedOn: "2024-01-24T22:50:26.517Z", + status: "draft", + tenant: "root", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b19428b583b90008e7a3bc" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 1 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20b8f0321db00083d35c1-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + entryId: "65b20b8f0321db00083d35c1-0001-stats", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b20b8f0321db00083d35c1-0001-stats#0001", + id: "65b20b8f0321db00083d35c1-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:19:43.219Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:19:51.052Z", + savedBy: user, + savedOn: "2024-01-25T07:19:51.052Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b20b8f0321db00083d35c1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20b8f0321db00083d35c1-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T07:19:43.219Z", + entryId: "65b20b8f0321db00083d35c1-0001-stats", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b20b8f0321db00083d35c1-0001-stats#0001", + id: "65b20b8f0321db00083d35c1-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:19:43.219Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:19:51.052Z", + savedBy: user, + savedOn: "2024-01-25T07:19:51.052Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 0, + "number@views": 0, + "text@formId": "65b20b8f0321db00083d35c1" + }, + version: 1, + webinyVersion: "0.0.0" + }, + + // Form 2 from otherTenant, locale fr-FR + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20bc00321db00083d35c9-0001-stats", + SK: "L", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + entryId: "65b20bc00321db00083d35c9-0001-stats", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbFormStat#L", + GSI1_SK: "65b20bc00321db00083d35c9-0001-stats#0001", + id: "65b20bc00321db00083d35c9-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:20:32.550Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:20:49.543Z", + savedBy: user, + savedOn: "2024-01-25T07:20:49.543Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry.l", + values: { + "number@formVersion": 1, + "number@submissions": 500, + "number@views": 1000, + "text@formId": "65b20bc00321db00083d35c9" + }, + version: 1, + webinyVersion: "0.0.0" + }, + { + PK: "T#otherTenant#L#fr-FR#CMS#CME#CME#65b20bc00321db00083d35c9-0001-stats", + SK: "REV#0001", + createdBy: user, + createdOn: "2024-01-25T07:20:32.550Z", + entryId: "65b20bc00321db00083d35c9-0001-stats", + GSI1_PK: "T#otherTenant#L#fr-FR#CMS#CME#M#fbFormStat#A", + GSI1_SK: "65b20bc00321db00083d35c9-0001-stats#0001", + id: "65b20bc00321db00083d35c9-0001-stats#0001", + locale: "fr-FR", + location: { + folderId: "root" + }, + locked: false, + modelId: "fbFormStat", + revisionCreatedBy: user, + revisionCreatedOn: "2024-01-25T07:20:32.550Z", + revisionSavedBy: user, + revisionSavedOn: "2024-01-25T07:20:49.543Z", + savedBy: user, + savedOn: "2024-01-25T07:20:49.543Z", + status: "draft", + tenant: "otherTenant", + TYPE: "cms.entry", + values: { + "number@formVersion": 1, + "number@submissions": 500, + "number@views": 1000, + "text@formId": "65b20bc00321db00083d35c9" + }, + version: 1, + webinyVersion: "0.0.0" + } +]; diff --git a/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.test.ts b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.test.ts new file mode 100644 index 00000000000..d4a151aaf34 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.test.ts @@ -0,0 +1,167 @@ +import sortBy from "lodash/sortBy"; +import { + assertNotError, + createDdbMigrationHandler, + getPrimaryDynamoDbTable, + groupMigrations, + insertDynamoDbTestData as insertTestData, + logTestNameBeforeEachTest, + scanTable +} from "~tests/utils"; +import { FormBuilder_5_40_0_001 } from "~/migrations/5.40.0/001/ddb"; +import { createFormsData, createLocalesData, createTenantsData } from "./001.data"; +import { migratedFormData, migratedFormStatsData } from "./001.migratedData"; + +jest.retryTimes(0); +jest.setTimeout(900000); + +describe("5.40.0-001", () => { + const table = getPrimaryDynamoDbTable(); + + logTestNameBeforeEachTest(); + + it("should not run if no tenant found", async () => { + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no locale found", async () => { + await insertTestData(table, [...createTenantsData()]); + + const handler = createDdbMigrationHandler({ table, migrations: [FormBuilder_5_40_0_001] }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no forms found", async () => { + await insertTestData(table, [...createTenantsData(), ...createLocalesData()]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_001] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should execute migration", async () => { + await insertTestData(table, [ + ...createFormsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_001] + }); + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(1); + expect(grouped.skipped.length).toBe(0); + expect(grouped.notApplicable.length).toBe(0); + + // Check Form entries + const formEntries = await scanTable(table, { + filters: [ + { + attr: "modelId", + eq: "fbForm" + } + ] + }); + + expect(sortBy(formEntries, ["PK", "SK"])).toEqual( + sortBy(migratedFormData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + + // Check FormStats entries + const formStatsEntries = await scanTable(table, { + filters: [ + { + attr: "modelId", + eq: "fbFormStat" + } + ] + }); + + expect(sortBy(formStatsEntries, ["PK", "SK"])).toEqual( + sortBy(migratedFormStatsData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + }); + + it("should not run migration if data is already in the expected shape", async () => { + await insertTestData(table, [ + ...createFormsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_001] + }); + + // Should run the migration + { + process.stdout.write("[First run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(1); + } + + // Should skip the migration + { + process.stdout.write("[Second run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + } + }); +}); diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.ddb.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.ddb.ts new file mode 100644 index 00000000000..11f3cfd821c --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.ddb.ts @@ -0,0 +1,175 @@ +import { createFormsData } from "~tests/migrations/5.40.0/001/ddb-es/001.ddb"; + +export { createFormsData }; + +export const user = { + id: "admin", + type: "admin", + displayName: "Admin" +}; + +export const createFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const item = { + PK: `T#${form.tenant}#L#${form.locale}#FB#F#${form.formId}`, + SK: `FS#${form.id}-submission-${i}`, + createdOn: form.createdOn, + data: form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + logs: [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + form: { + fields: form.fields, + steps: form.steps, + id: form.id, + name: form.name, + parent: form.formId, + version: form.version + }, + id: `${form.id}-submission-${i}`, + locale: form.locale, + meta: { + ip: "0.0.0.0", + submittedOn: form.createdOn, + url: { + location: `https://${form.formId}.website.com/any`, + query: { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + } + } + }, + ownedBy: user, + savedOn: form.savedOn, + tenant: form.tenant, + TYPE: "fb.formSubmission", + webinyVersion: form.webinyVersion, + _ct: form.createdOn, + _et: "FormBuilderSubmission", + _md: form.savedOn + }; + + submissions.push(item); + } + } + + return submissions; +}; + +export const createTenantsData = () => { + return [ + { + PK: "T#root", + SK: "A", + createdOn: "2023-01-25T09:37:58.183Z", + description: "The top-level Webiny tenant.", + GSI1_PK: "TENANTS", + GSI1_SK: "T#null#2023-01-25T09:37:58.183Z", + data: { + id: "root", + name: "Root", + savedOn: "2023-01-25T09:37:58.183Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + }, + { + PK: "T#otherTenant", + SK: "A", + createdOn: "2023-03-11T09:59:17.327Z", + description: "Tenant #1", + GSI1_PK: "TENANTS", + GSI1_SK: "T#root#2023-03-11T09:59:17.327Z", + data: { + id: "otherTenant", + name: "Other Tenant", + parent: "root", + savedOn: "2023-03-11T09:59:17.327Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + } + ]; +}; + +export const createLocalesData = () => { + return [ + { + PK: `T#root#I18N#L`, + SK: "en-US", + code: "en-US", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + } + ]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.es.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.es.ts new file mode 100644 index 00000000000..bbd7dbc987c --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.es.ts @@ -0,0 +1,63 @@ +import { createFormsData, user } from "./002.ddb"; + +export { createEsFormsData } from "~tests/migrations/5.40.0/001/ddb-es/001.es"; + +export const createEsFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const item = { + data: form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + form: { + fields: form.fields, + steps: form.steps, + id: form.id, + name: form.name, + parent: form.formId, + version: form.version + }, + webinyVersion: form.webinyVersion, + meta: { + ip: "0.0.0.0", + submittedOn: form.createdOn, + url: { + location: `https://${form.formId}.website.com/any`, + query: { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + } + } + }, + savedOn: form.savedOn, + __type: "fb.submission", + id: `${form.id}-submission-${i}`, + locale: form.locale, + createdOn: form.createdOn, + ownedBy: user, + logs: [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + tenant: form.tenant + }; + + submissions.push(item); + } + } + + return submissions; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddb.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddb.ts new file mode 100644 index 00000000000..9f7dfbe357d --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddb.ts @@ -0,0 +1,113 @@ +import { createFormsData } from "./002.ddb"; +import { Status } from "~/migrations/5.40.0/002/types"; + +export const createMigratedFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const commonFields = { + entryId: `${form.id}-submission-${i}`, + id: `${form.id}-submission-${i}#0001`, + locale: form.locale, + locked: false, + location: { + folderId: "root" + }, + modelId: "fbSubmission", + status: Status.DRAFT, + tenant: form.tenant, + webinyVersion: form.webinyVersion, + version: 1, + values: { + "json@data": form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + "json@logs": [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + "object@form": { + "object@fields": form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText, + "text@type": field.type, + "text@_id": field._id + })), + "object@steps": form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@id": form.id, + "text@name": form.name, + "text@parent": form.formId, + "text@version": form.version + }, + "object@meta": { + "text@ip": "0.0.0.0", + "datetime@submittedOn": form.createdOn, + "object@url": { + "json@query": { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + }, + "text@location": `https://${form.formId}.website.com/any` + } + } + }, + createdOn: form.createdOn, + createdBy: form.createdBy, + savedBy: form.createdBy, + savedOn: form.savedOn, + revisionCreatedBy: form.createdBy, + revisionCreatedOn: form.createdOn, + revisionSavedBy: form.createdBy, + revisionSavedOn: form.savedOn + }; + + const revision = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${form.id}-submission-${i}`, + SK: "REV#0001", + TYPE: "cms.entry", + ...commonFields + }; + + submissions.push(revision); + + const latest = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${form.id}-submission-${i}`, + SK: "L", + TYPE: "cms.entry.l", + ...commonFields + }; + + submissions.push(latest); + } + } + + return submissions; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddbEs.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddbEs.ts new file mode 100644 index 00000000000..271d7e0bcff --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.migrated.ddbEs.ts @@ -0,0 +1,105 @@ +import { createFormsData } from "./002.ddb"; +import { Status } from "~/migrations/5.40.0/002/types"; + +// Note that the data is decompressed. +export const createMigratedDdbEsFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const latest = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#${form.id}-submission-${i}`, + SK: "L", + data: { + entryId: `${form.id}-submission-${i}`, + id: `${form.id}-submission-${i}#0001`, + locale: form.locale, + locked: false, + location: { + folderId: "root" + }, + modelId: "fbSubmission", + status: Status.DRAFT, + tenant: form.tenant, + webinyVersion: form.webinyVersion, + version: 1, + values: { + "json@data": form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + "json@logs": [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + "object@form": { + "object@fields": form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText, + "text@type": field.type, + "text@_id": field._id + })), + "object@steps": form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@id": form.id, + "text@name": form.name, + "text@parent": form.formId, + "text@version": form.version + }, + "object@meta": { + "text@ip": "0.0.0.0", + "datetime@submittedOn": form.createdOn, + "object@url": { + "json@query": { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + }, + "text@location": `https://${form.formId}.website.com/any` + } + } + }, + createdBy: form.createdBy, + createdOn: form.createdOn, + savedBy: form.ownedBy, + savedOn: form.savedOn, + revisionCreatedBy: form.createdBy, + revisionCreatedOn: form.createdOn, + revisionSavedOn: form.savedOn, + revisionSavedBy: form.ownedBy, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + } + }; + + submissions.push(latest); + } + } + + return submissions; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.test.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.test.ts new file mode 100644 index 00000000000..4e8071484fb --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/002.test.ts @@ -0,0 +1,248 @@ +import sortBy from "lodash/sortBy"; +import { + assertNotError, + createDdbEsMigrationHandler, + getDynamoToEsTable, + getPrimaryDynamoDbTable, + groupMigrations, + insertDynamoDbTestData as insertTestData, + logTestNameBeforeEachTest, + scanTable +} from "~tests/utils"; +import { FormBuilder_5_40_0_002 } from "~/migrations/5.40.0/002/ddb-es"; +import { insertElasticsearchTestData } from "~tests/utils/insertElasticsearchTestData"; +import { esGetIndexName } from "~/utils"; +import { createElasticsearchClient } from "@webiny/project-utils/testing/elasticsearch/createClient"; +import { + createLocalesData, + createTenantsData, + createFormsData, + createFormSubmissionsData +} from "~tests/migrations/5.40.0/002/ddb-es/002.ddb"; +import { + createEsFormsData, + createEsFormSubmissionsData +} from "~tests/migrations/5.40.0/002/ddb-es/002.es"; +import { createMigratedFormSubmissionsData } from "~tests/migrations/5.40.0/002/ddb-es/002.migrated.ddb"; +import { createMigratedDdbEsFormSubmissionsData } from "./002.migrated.ddbEs"; +import { getDecompressedData } from "~tests/migrations/5.40.0/002/ddb-es/helpers"; + +jest.retryTimes(0); +jest.setTimeout(900000); + +describe("5.40.0-002", () => { + const primaryTable = getPrimaryDynamoDbTable(); + const dynamoToEsTable = getDynamoToEsTable(); + const elasticsearchClient = createElasticsearchClient(); + + beforeAll(async () => { + process.env.ELASTIC_SEARCH_INDEX_PREFIX = + new Date().toISOString().replace(/\.|\:/g, "-").toLowerCase() + "-"; + + await elasticsearchClient.indices.deleteAll(); + }); + + afterEach(async () => { + await elasticsearchClient.indices.deleteAll(); + }); + + logTestNameBeforeEachTest(); + + it("should not run if no tenant found", async () => { + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no locale found", async () => { + await insertTestData(primaryTable, [...createTenantsData()]); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no forms found", async () => { + await insertTestData(primaryTable, [...createTenantsData(), ...createLocalesData()]); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should execute migration", async () => { + await insertTestData(primaryTable, [ + ...createFormsData(), + ...createFormSubmissionsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + await insertElasticsearchTestData( + elasticsearchClient, + [...createEsFormsData(), ...createEsFormSubmissionsData()], + item => { + return esGetIndexName({ + tenant: item.tenant, + locale: item.locale, + isHeadlessCmsModel: false, + type: "form-builder" + }); + } + ); + + await elasticsearchClient.indices.refreshAll(); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(1); + expect(grouped.skipped.length).toBe(0); + expect(grouped.notApplicable.length).toBe(0); + + // Check DDB Submissions entries + const ddbSubmissionEntries = await scanTable(primaryTable, { + filters: [ + { + attr: "modelId", + eq: "fbSubmission" + } + ] + }); + + expect(sortBy(ddbSubmissionEntries, ["PK", "SK"])).toEqual( + sortBy(createMigratedFormSubmissionsData(), ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + + // Check DDB + ES Submissions entries + const ddbEsFormEntries = await scanTable(dynamoToEsTable, { + limit: 1_000_000 + }); + + const ddbEsFormEntriesDecompressed = await Promise.all( + ddbEsFormEntries.map(async item => { + return { + ...item, + data: await getDecompressedData(item.data) + }; + }) + ); + + const migratedDdbEsData = createMigratedDdbEsFormSubmissionsData(); + + expect(sortBy(ddbEsFormEntriesDecompressed, ["PK", "SK"])).toEqual( + sortBy(migratedDdbEsData, ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntriesElasticsearch", + index: expect.any(String), + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + }); + + it("should not run migration if data is already in the expected shape", async () => { + await insertTestData(primaryTable, [ + ...createFormsData(), + ...createFormSubmissionsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + await insertElasticsearchTestData( + elasticsearchClient, + [...createEsFormsData(), ...createEsFormSubmissionsData()], + item => { + return esGetIndexName({ + tenant: item.tenant, + locale: item.locale, + isHeadlessCmsModel: false, + type: "form-builder" + }); + } + ); + + await elasticsearchClient.indices.refreshAll(); + + const handler = createDdbEsMigrationHandler({ + primaryTable, + dynamoToEsTable, + elasticsearchClient, + migrations: [FormBuilder_5_40_0_002] + }); + + // Should run the migration + { + process.stdout.write("[First run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(1); + } + + // Should skip the migration + { + process.stdout.write("[Second run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + } + }); +}); diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/helpers.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/helpers.ts new file mode 100644 index 00000000000..1c75693b159 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb-es/helpers.ts @@ -0,0 +1,7 @@ +import { createGzipCompression } from "@webiny/api-elasticsearch"; + +export const getDecompressedData = async (data: any): Promise => { + const compression = createGzipCompression(); + + return (await compression.decompress(data)) as unknown as R; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.data.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.data.ts new file mode 100644 index 00000000000..eb0efc74710 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.data.ts @@ -0,0 +1,175 @@ +import { createFormsData } from "~tests/migrations/5.40.0/001/ddb/001.data"; + +export { createFormsData }; + +export const user = { + id: "admin", + type: "admin", + displayName: "Admin" +}; + +export const createFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const item = { + PK: `T#${form.tenant}#L#${form.locale}#FB#FS#${form.formId}`, + SK: `${form.id}-submission-${i}`, + createdOn: form.createdOn, + data: form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + logs: [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + form: { + fields: form.fields, + steps: form.steps, + id: form.id, + name: form.name, + parent: form.formId, + version: form.version + }, + id: `${form.id}-submission-${i}`, + locale: form.locale, + meta: { + ip: "0.0.0.0", + submittedOn: form.createdOn, + url: { + location: `https://${form.formId}.website.com/any`, + query: { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + } + } + }, + ownedBy: user, + savedOn: form.savedOn, + tenant: form.tenant, + TYPE: "fb.formSubmission", + webinyVersion: form.webinyVersion, + _ct: form.createdOn, + _et: "FormBuilderSubmission", + _md: form.savedOn + }; + + submissions.push(item); + } + } + + return submissions; +}; + +export const createTenantsData = () => { + return [ + { + PK: "T#root", + SK: "A", + createdOn: "2023-01-25T09:37:58.183Z", + description: "The top-level Webiny tenant.", + GSI1_PK: "TENANTS", + GSI1_SK: "T#null#2023-01-25T09:37:58.183Z", + data: { + id: "root", + name: "Root", + savedOn: "2023-01-25T09:37:58.183Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + }, + { + PK: "T#otherTenant", + SK: "A", + createdOn: "2023-03-11T09:59:17.327Z", + description: "Tenant #1", + GSI1_PK: "TENANTS", + GSI1_SK: "T#root#2023-03-11T09:59:17.327Z", + data: { + id: "otherTenant", + name: "Other Tenant", + parent: "root", + savedOn: "2023-03-11T09:59:17.327Z", + settings: { + domains: [] + }, + status: "active", + TYPE: "tenancy.tenant", + webinyVersion: "0.0.0", + createdBy: user + } + } + ]; +}; + +export const createLocalesData = () => { + return [ + { + PK: `T#root#I18N#L`, + SK: "en-US", + code: "en-US", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#root#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "root", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "fr-FR", + code: "fr-FR", + default: false, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + }, + { + PK: `T#otherTenant#I18N#L`, + SK: "de-DE", + code: "de-DE", + default: true, + createdOn: "2023-01-25T09:37:58.220Z", + createdBy: user, + tenant: "otherTenant", + webinyVersion: "0.0.0" + } + ]; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.migratedData.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.migratedData.ts new file mode 100644 index 00000000000..7d15d334b78 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.migratedData.ts @@ -0,0 +1,117 @@ +import { createFormsData } from "~tests/migrations/5.40.0/001/ddb/001.data"; +import { Status } from "~/migrations/5.40.0/002/types"; + +export const createMigratedFormSubmissionsData = () => { + const forms = createFormsData().filter( + form => form.TYPE === "fb.form" && form.stats.submissions > 0 + ); + + const submissions = []; + + for (const form of forms) { + for (let i = 0; i < form.stats.submissions; i++) { + const commonFields = { + entryId: `${form.id}-submission-${i}`, + id: `${form.id}-submission-${i}`, + locale: form.locale, + locked: false, + location: { + folderId: "root" + }, + modelId: "fbSubmission", + status: Status.DRAFT, + tenant: form.tenant, + webinyVersion: form.webinyVersion, + version: 1, + values: { + "json@data": form.fields.map(field => ({ + [field.fieldId]: `${field.label} submission ${i}` + })), + "json@logs": [ + { + type: "info", + message: "Form submission created." + }, + { + type: "success", + message: "Form submitted successfully." + } + ], + "object@form": { + "object@fields": form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText, + "text@type": field.type, + "text@_id": field._id + })), + "object@steps": form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@id": form.id, + "text@name": form.name, + "text@parent": form.formId, + "text@version": form.version + }, + "object@meta": { + "text@ip": "0.0.0.0", + "datetime@submittedOn": form.createdOn, + "object@url": { + "json@query": { + formId: form.formId, + tenant: form.tenant, + locale: form.locale + }, + "text@location": `https://${form.formId}.website.com/any` + } + } + }, + createdOn: form.createdOn, + createdBy: form.createdBy, + savedBy: form.createdBy, + savedOn: form.savedOn, + revisionCreatedBy: form.createdBy, + revisionCreatedOn: form.createdOn, + revisionSavedBy: form.createdBy, + revisionSavedOn: form.savedOn + }; + + const revision = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#CME#${form.id}-submission-${i}`, + SK: "REV#0001", + GSI1_PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#M#fbSubmission#A`, + GSI1_SK: `${form.id}-submission-${i}#0001`, + TYPE: "cms.entry", + ...commonFields + }; + + submissions.push(revision); + + const latest = { + PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#CME#${form.id}-submission-${i}`, + SK: "L", + GSI1_PK: `T#${form.tenant}#L#${form.locale}#CMS#CME#M#fbSubmission#L`, + GSI1_SK: `${form.id}-submission-${i}#0001`, + TYPE: "cms.entry.l", + ...commonFields + }; + + submissions.push(latest); + } + } + + return submissions; +}; diff --git a/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.test.ts b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.test.ts new file mode 100644 index 00000000000..7733903ee54 --- /dev/null +++ b/packages/migrations/__tests__/migrations/5.40.0/002/ddb/002.test.ts @@ -0,0 +1,153 @@ +import sortBy from "lodash/sortBy"; +import { + assertNotError, + createDdbMigrationHandler, + getPrimaryDynamoDbTable, + groupMigrations, + insertDynamoDbTestData as insertTestData, + logTestNameBeforeEachTest, + scanTable +} from "~tests/utils"; +import { FormBuilder_5_40_0_002 } from "~/migrations/5.40.0/002/ddb"; +import { + createFormsData, + createFormSubmissionsData, + createLocalesData, + createTenantsData +} from "./002.data"; +import { createMigratedFormSubmissionsData } from "./002.migratedData"; + +jest.retryTimes(0); +jest.setTimeout(900000); + +describe("5.40.0-002", () => { + const table = getPrimaryDynamoDbTable(); + + logTestNameBeforeEachTest(); + + it("should not run if no tenant found", async () => { + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no locale found", async () => { + await insertTestData(table, [...createTenantsData()]); + + const handler = createDdbMigrationHandler({ table, migrations: [FormBuilder_5_40_0_002] }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should not run if no forms found", async () => { + await insertTestData(table, [...createTenantsData(), ...createLocalesData()]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_002] + }); + + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + }); + + it("should execute migration", async () => { + await insertTestData(table, [ + ...createFormsData(), + ...createFormSubmissionsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_002] + }); + const { data, error } = await handler(); + + assertNotError(error); + const grouped = groupMigrations(data.migrations); + + expect(grouped.executed.length).toBe(1); + expect(grouped.skipped.length).toBe(0); + expect(grouped.notApplicable.length).toBe(0); + + // Check Form submissions entries + const formSubmissionEntries = await scanTable(table, { + filters: [ + { + attr: "modelId", + eq: "fbSubmission" + } + ] + }); + + expect(sortBy(formSubmissionEntries, ["PK", "SK"])).toEqual( + sortBy(createMigratedFormSubmissionsData(), ["PK", "SK"]).map(data => { + return { + ...data, + entity: "CmsEntries", + created: expect.any(String), + modified: expect.any(String) + }; + }) + ); + }); + + it("should not run migration if data is already in the expected shape", async () => { + await insertTestData(table, [ + ...createFormsData(), + ...createFormSubmissionsData(), + ...createTenantsData(), + ...createLocalesData() + ]); + + const handler = createDdbMigrationHandler({ + table, + migrations: [FormBuilder_5_40_0_002] + }); + + // Should run the migration + { + process.stdout.write("[First run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(1); + } + + // Should skip the migration + { + process.stdout.write("[Second run]\n"); + const { data, error } = await handler(); + assertNotError(error); + const grouped = groupMigrations(data.migrations); + expect(grouped.executed.length).toBe(0); + expect(grouped.skipped.length).toBe(1); + expect(grouped.notApplicable.length).toBe(0); + } + }); +}); diff --git a/packages/migrations/src/ddb-es.ts b/packages/migrations/src/ddb-es.ts index 3455d0e5cae..9a1c6ddfe9a 100644 --- a/packages/migrations/src/ddb-es.ts +++ b/packages/migrations/src/ddb-es.ts @@ -21,6 +21,9 @@ import { PageBlocks_5_38_0_003 } from "~/migrations/5.38.0/003/ddb"; // 5.39.0 import { CmsEntriesInitNewMetaFields_5_39_0_001 } from "~/migrations/5.39.0/001/ddb-es"; import { FileManager_5_39_0_002 } from "~/migrations/5.39.0/002/ddb-es"; +// 5.40.0 +import { FormBuilder_5_40_0_001 } from "~/migrations/5.40.0/001/ddb-es"; +import { FormBuilder_5_40_0_002 } from "~/migrations/5.40.0/002/ddb-es"; export const migrations = () => { return [ @@ -45,6 +48,9 @@ export const migrations = () => { PageBlocks_5_38_0_003, // 5.39.0 CmsEntriesInitNewMetaFields_5_39_0_001, - FileManager_5_39_0_002 + FileManager_5_39_0_002, + // 5.40.0 + FormBuilder_5_40_0_001, + FormBuilder_5_40_0_002 ]; }; diff --git a/packages/migrations/src/ddb.ts b/packages/migrations/src/ddb.ts index 727e2aeb2bb..436107e0430 100644 --- a/packages/migrations/src/ddb.ts +++ b/packages/migrations/src/ddb.ts @@ -20,6 +20,9 @@ import { PageBlocks_5_38_0_003 } from "~/migrations/5.38.0/003/ddb"; // 5.39.0 import { CmsEntriesInitNewMetaFields_5_39_0_001 } from "~/migrations/5.39.0/001/ddb"; import { FileManager_5_39_0_002 } from "~/migrations/5.39.0/002/ddb"; +// 5.40.0 +import { FormBuilder_5_40_0_001 } from "~/migrations/5.40.0/001/ddb"; +import { FormBuilder_5_40_0_002 } from "~/migrations/5.40.0/002/ddb"; export const migrations = () => { return [ @@ -44,6 +47,9 @@ export const migrations = () => { PageBlocks_5_38_0_003, // 5.39.0 CmsEntriesInitNewMetaFields_5_39_0_001, - FileManager_5_39_0_002 + FileManager_5_39_0_002, + // 5.40.0 + FormBuilder_5_40_0_001, + FormBuilder_5_40_0_002 ]; }; diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormLatestMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormLatestMigration.ts new file mode 100644 index 00000000000..8153b9e2b79 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormLatestMigration.ts @@ -0,0 +1,376 @@ +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { Client } from "@elastic/elasticsearch"; +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { + batchWriteAll, + esCreateIndex, + esFindOne, + esGetIndexExist, + esGetIndexName, + esGetIndexSettings, + esPutIndexSettings, + esQueryAll, + forEachTenantLocale, + queryOne +} from "~/utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "~/migrations/5.40.0/001/types"; +import { + createDdbCmsEntity, + createDdbEsCmsEntity +} from "~/migrations/5.40.0/001/entities/createCmsEntity"; +import { + getCompressedData, + getDdbEsFormCommonFields, + getDdbEsFirstLastPublishedOnBy, + getDdbEsOldestRevisionCreatedOn, + getDdbEsRevisionStatus, + getFormCommonFields, + getMetaFields +} from "~/migrations/5.40.0/001/utils"; +import { executeWithRetry } from "@webiny/utils"; + +export class FormBuilder_5_40_0_001_FormLatest implements DataMigration { + private readonly table: Table; + private readonly esClient: Client; + private readonly ddbCmsEntity: ReturnType; + private readonly ddbEsCmsEntity: ReturnType; + private ddbFormEntity: ReturnType; + + constructor( + table: Table, + esTable: Table, + esClient: Client + ) { + this.table = table; + this.esClient = esClient; + this.ddbCmsEntity = createDdbCmsEntity(table); + this.ddbEsCmsEntity = createDdbEsCmsEntity(esTable); + this.ddbFormEntity = createFormEntity(table); + } + + getId(): string { + return "Form Latest Entries"; + } + + getDescription(): string { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form latest entries for ${tenantId} - ${localeCode}.`); + + const indexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...indexNameParams + }); + + if (!indexExists) { + logger.info( + `No Elasticsearch index found for forms in tenant "${tenantId}" and locale "${localeCode}"; skipping.` + ); + shouldExecute = false; + return true; + } + + // Fetch latest form record from ES + const latestForm = await esFindOne({ + elasticsearchClient: this.esClient, + index: esGetIndexName(indexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.form" } } + ] + } + }, + sort: [ + { + "id.keyword": { order: "asc", unmapped_type: "keyword" } + } + ] + } + }); + + if (!latestForm) { + logger.info( + `No forms found in tenant "${tenantId}" and locale "${localeCode}".` + ); + shouldExecute = false; + return true; + } + + // Fetch latest HCMS form record from DDB using latest form "formId" + const cmsEntry = await queryOne({ + entity: this.ddbCmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#${latestForm.formId}`, + options: { + eq: "L" + } + }); + + if (!cmsEntry) { + logger.info( + `No latest CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form latest entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + const formBuilderIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const fbFormHcmsIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "fbform", + isHeadlessCmsModel: true + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...formBuilderIndexNameParams + }); + + if (!indexExists) { + logger.info( + `No form-builder index found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + const esRecords = await esQueryAll({ + elasticsearchClient: this.esClient, + index: esGetIndexName(formBuilderIndexNameParams), + body: { + query: { + bool: { + filter: [{ term: { "__type.keyword": "fb.form" } }] + } + }, + size: 10000 + } + }); + + if (!esRecords.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + logger.info(`Migrating form latest entries for ${tenantId} - ${localeCode}.`); + + // Since it might be the first time we add a HCMS form record, we also need to create the index + const fbFormHcmsIndex = await esCreateIndex({ + elasticsearchClient: this.esClient, + ...fbFormHcmsIndexNameParams + }); + + // Saving HCMS forms index settings, we are going to reset them and save the original ones later + const settings = await esGetIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + fields: ["number_of_replicas", "refresh_interval"] + }); + + logger.trace( + `Replacing existing settings with default from "${fbFormHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + settings: { + number_of_replicas: 0, + refresh_interval: -1 + } + }); + + try { + const formIds = esRecords.map(item => item.formId).filter(Boolean); + const uniqueFormIds = [...new Set(formIds)]; + + const ddbItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + const ddbEsItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + + // Let's create the latest entry for each form found + for (const formId of uniqueFormIds) { + const form = await queryOne({ + entity: this.ddbFormEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#${formId}`, + options: { + eq: "L" + } + }); + + // No form latest entry found: we don't need to create an HCMS entry for it + if (!form) { + continue; + } + + // Get the status field, based on the revision and the published entry + const status = await getDdbEsRevisionStatus({ + form, + formEntity: this.ddbFormEntity + }); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getDdbEsOldestRevisionCreatedOn({ + form, + formEntity: this.ddbFormEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getDdbEsFirstLastPublishedOnBy({ + form, + formEntity: this.ddbFormEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + // Get DDB common fields + const ddbEntryCommonFields = getFormCommonFields(form); + + // Get DDB+ES common fields + const ddbEsEntryCommonFields = getDdbEsFormCommonFields(form); + + const ddbItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}`, + SK: "L", + ...ddbEntryCommonFields, + ...entryMetaFields, + status + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbItem)); + + const ddbEsItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}`, + SK: "L", + index: fbFormHcmsIndex, + data: await getCompressedData({ + ...ddbEsEntryCommonFields, + ...entryMetaFields, + status, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + }) + }; + + ddbEsItems.push(this.ddbEsCmsEntity.putBatch(ddbEsItem)); + } + + const executeDdb = () => { + return batchWriteAll({ + table: this.ddbCmsEntity.table, + items: ddbItems + }); + }; + + const executeDdbEs = () => { + return batchWriteAll({ + table: this.ddbEsCmsEntity.table, + items: ddbEsItems + }); + }; + + await executeWithRetry(executeDdb, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + await executeWithRetry(executeDdbEs, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb + es" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info(`Migrated form latest entries for ${tenantId} - ${localeCode}.`); + } finally { + // Saving back HCMS forms index settings + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + settings: { + number_of_replicas: settings.number_of_replicas || null, + refresh_interval: settings.refresh_interval || null + } + }); + + logger.trace( + `Successfully set back the previously found settings from "${fbFormHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + } + + return true; + } + }); + + logger.info("Updated all latest forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormPublishedMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormPublishedMigration.ts new file mode 100644 index 00000000000..e8eb79b8b78 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormPublishedMigration.ts @@ -0,0 +1,377 @@ +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { Client } from "@elastic/elasticsearch"; +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { + batchWriteAll, + esCreateIndex, + esFindOne, + esGetIndexExist, + esGetIndexName, + esGetIndexSettings, + esPutIndexSettings, + esQueryAll, + forEachTenantLocale, + queryOne +} from "~/utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "~/migrations/5.40.0/001/types"; +import { + createDdbCmsEntity, + createDdbEsCmsEntity +} from "~/migrations/5.40.0/001/entities/createCmsEntity"; +import { + getCompressedData, + getDdbEsFormCommonFields, + getDdbEsFirstLastPublishedOnBy, + getDdbEsOldestRevisionCreatedOn, + getDdbEsRevisionStatus, + getFormCommonFields, + getMetaFields +} from "~/migrations/5.40.0/001/utils"; +import { executeWithRetry } from "@webiny/utils"; + +export class FormBuilder_5_40_0_001_FormPublished implements DataMigration { + private readonly table: Table; + private readonly esClient: Client; + private readonly ddbCmsEntity: ReturnType; + private readonly ddbEsCmsEntity: ReturnType; + private ddbFormEntity: ReturnType; + + constructor( + table: Table, + esTable: Table, + esClient: Client + ) { + this.table = table; + this.esClient = esClient; + this.ddbCmsEntity = createDdbCmsEntity(table); + this.ddbEsCmsEntity = createDdbEsCmsEntity(esTable); + this.ddbFormEntity = createFormEntity(table); + } + + getId(): string { + return "Form Published Entries"; + } + + getDescription(): string { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form published entries for ${tenantId} - ${localeCode}.`); + + const indexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...indexNameParams + }); + + if (!indexExists) { + logger.info( + `No Elasticsearch index found for forms in tenant "${tenantId}" and locale "${localeCode}"; skipping.` + ); + shouldExecute = false; + return true; + } + + // Fetch latest form record from ES + const latestForm = await esFindOne({ + elasticsearchClient: this.esClient, + index: esGetIndexName(indexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.form" } } + ] + } + }, + sort: [ + { + "id.keyword": { order: "asc", unmapped_type: "keyword" } + } + ] + } + }); + + if (!latestForm) { + logger.info( + `No forms found in tenant "${tenantId}" and locale "${localeCode}".` + ); + shouldExecute = false; + return true; + } + + // Fetch latest HCMS form record from DDB using latest form "formId" + const cmsEntry = await queryOne({ + entity: this.ddbCmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#${latestForm.formId}`, + options: { + eq: "P" + } + }); + + if (!cmsEntry) { + logger.info( + `No published CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form published entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + const formBuilderIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const fbFormHcmsIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "fbform", + isHeadlessCmsModel: true + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...formBuilderIndexNameParams + }); + + if (!indexExists) { + logger.info( + `No form-builder index found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + const esRecords = await esQueryAll({ + elasticsearchClient: this.esClient, + index: esGetIndexName(formBuilderIndexNameParams), + body: { + query: { + bool: { + filter: [{ term: { "__type.keyword": "fb.form" } }] + } + }, + size: 10000 + } + }); + + if (!esRecords.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + logger.info(`Migrating form published entries for ${tenantId} - ${localeCode}.`); + + // Since it might be the first time we add a HCMS form record, we also need to create the index + const fbFormHcmsIndex = await esCreateIndex({ + elasticsearchClient: this.esClient, + ...fbFormHcmsIndexNameParams + }); + + // Saving HCMS forms index settings, we are going to reset them and save the original ones later + const settings = await esGetIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + fields: ["number_of_replicas", "refresh_interval"] + }); + + logger.trace( + `Replacing existing settings with default from "${fbFormHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + settings: { + number_of_replicas: 0, + refresh_interval: -1 + } + }); + + try { + const formIds = esRecords.map(item => item.formId).filter(Boolean); + const uniqueFormIds = [...new Set(formIds)]; + + const ddbItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + const ddbEsItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + + // Let's create the published entry for each form found + for (const formId of uniqueFormIds) { + const form = await queryOne({ + entity: this.ddbFormEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#${formId}`, + options: { + eq: "LP" + } + }); + + // No form published form entry found: we don't need to create an HCMS entry for it + if (!form) { + continue; + } + + // Get the status field, based on the revision and the published entry + const status = await getDdbEsRevisionStatus({ + form, + formEntity: this.ddbFormEntity + }); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getDdbEsOldestRevisionCreatedOn({ + form, + formEntity: this.ddbFormEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getDdbEsFirstLastPublishedOnBy({ + form, + formEntity: this.ddbFormEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + // Get DDB common fields + const ddbEntryCommonFields = getFormCommonFields(form); + + // Get DDB+ES common fields + const ddbEsEntryCommonFields = getDdbEsFormCommonFields(form); + + const ddbItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}`, + SK: "P", + TYPE: "cms.entry.p", + ...ddbEntryCommonFields, + ...entryMetaFields, + status + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbItem)); + + const ddbEsItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}`, + SK: "P", + index: fbFormHcmsIndex, + data: await getCompressedData({ + ...ddbEsEntryCommonFields, + ...entryMetaFields, + status, + published: true, + TYPE: "cms.entry.p", + __type: "cms.entry.p" + }) + }; + + ddbEsItems.push(this.ddbEsCmsEntity.putBatch(ddbEsItem)); + } + + const executeDdb = () => { + return batchWriteAll({ + table: this.ddbCmsEntity.table, + items: ddbItems + }); + }; + + const executeDdbEs = () => { + return batchWriteAll({ + table: this.ddbEsCmsEntity.table, + items: ddbEsItems + }); + }; + + await executeWithRetry(executeDdb, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + await executeWithRetry(executeDdbEs, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb + es" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info(`Migrated form published entries for ${tenantId} - ${localeCode}.`); + } finally { + // Saving back HCMS forms index settings + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormHcmsIndex, + settings: { + number_of_replicas: settings.number_of_replicas || null, + refresh_interval: settings.refresh_interval || null + } + }); + + logger.trace( + `Successfully set back the previously found settings from "${fbFormHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + } + + return true; + } + }); + + logger.info("Updated all published forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormRevisionsMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormRevisionsMigration.ts new file mode 100644 index 00000000000..13402fe56eb --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormRevisionsMigration.ts @@ -0,0 +1,276 @@ +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { Client } from "@elastic/elasticsearch"; +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { + batchWriteAll, + esFindOne, + esGetIndexExist, + esGetIndexName, + esQueryAll, + forEachTenantLocale, + queryAll, + queryOne +} from "~/utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "~/migrations/5.40.0/001/types"; +import { createDdbCmsEntity } from "~/migrations/5.40.0/001/entities/createCmsEntity"; +import { + getDdbEsFirstLastPublishedOnBy, + getDdbEsOldestRevisionCreatedOn, + getDdbEsRevisionStatus, + getFormCommonFields, + getMetaFields +} from "~/migrations/5.40.0/001/utils"; +import { executeWithRetry } from "@webiny/utils"; + +export class FormBuilder_5_40_0_001_FormRevisions implements DataMigration { + private readonly table: Table; + private readonly esClient: Client; + private readonly ddbCmsEntity: ReturnType; + private ddbFormEntity: ReturnType; + + constructor( + table: Table, + esTable: Table, + esClient: Client + ) { + this.table = table; + this.esClient = esClient; + this.ddbCmsEntity = createDdbCmsEntity(table); + this.ddbFormEntity = createFormEntity(table); + } + + getId(): string { + return "Form Revision Entries"; + } + + getDescription(): string { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form revisions entries for ${tenantId} - ${localeCode}.`); + + const indexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...indexNameParams + }); + + if (!indexExists) { + logger.info( + `No Elasticsearch index found for forms in tenant "${tenantId}" and locale "${localeCode}"; skipping.` + ); + shouldExecute = false; + return true; + } + + // Fetch latest form record from ES + const latestForm = await esFindOne({ + elasticsearchClient: this.esClient, + index: esGetIndexName(indexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.form" } } + ] + } + }, + sort: [ + { + "id.keyword": { order: "asc", unmapped_type: "keyword" } + } + ] + } + }); + + if (!latestForm) { + logger.info( + `No forms found in tenant "${tenantId}" and locale "${localeCode}".` + ); + shouldExecute = false; + return true; + } + + // Fetch revision HCMS form record from DDB using latest form "formId" + const cmsEntry = await queryOne({ + entity: this.ddbCmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#${latestForm.formId}`, + options: { + beginsWith: "REV#" + } + }); + + if (!cmsEntry) { + logger.info( + `No revisions CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form revisions entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + const formBuilderIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...formBuilderIndexNameParams + }); + + if (!indexExists) { + logger.info( + `No form-builder index found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + const esRecords = await esQueryAll({ + elasticsearchClient: this.esClient, + index: esGetIndexName(formBuilderIndexNameParams), + body: { + query: { + bool: { + filter: [{ term: { "__type.keyword": "fb.form" } }] + } + }, + size: 10000 + } + }); + + if (!esRecords.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + logger.info(`Migrating form revisions entries for ${tenantId} - ${localeCode}.`); + + const formIds = esRecords.map(item => item.formId).filter(Boolean); + const uniqueFormIds = [...new Set(formIds)]; + + const ddbItems: ReturnType["putBatch"]>[] = + []; + + for (const formId of uniqueFormIds) { + const forms = await queryAll({ + entity: this.ddbFormEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#${formId}`, + options: { + beginsWith: "REV#" + } + }); + + if (!forms.length) { + continue; + } + + for (const form of forms) { + const [formId, revisionId] = form.id.split("#"); + + // Get the status field, based on the revision and the published entry + const status = await getDdbEsRevisionStatus({ + form, + formEntity: this.ddbFormEntity + }); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getDdbEsOldestRevisionCreatedOn({ + form, + formEntity: this.ddbFormEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getDdbEsFirstLastPublishedOnBy({ + form, + formEntity: this.ddbFormEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + // Get DDB common fields + const ddbEntryCommonFields = getFormCommonFields(form); + + const ddbItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}`, + SK: `REV#${revisionId}`, + TYPE: "cms.entry", + ...ddbEntryCommonFields, + ...entryMetaFields, + status + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbItem)); + } + } + + const executeDdb = () => { + return batchWriteAll({ + table: this.ddbCmsEntity.table, + items: ddbItems + }); + }; + + await executeWithRetry(executeDdb, { + onFailedAttempt: error => { + logger.error(`"batchWriteAll ddb" attempt #${error.attemptNumber} failed.`); + logger.error(error.message); + } + }); + + logger.info(`Migrated form revision entries for ${tenantId} - ${localeCode}.`); + + return true; + } + }); + + logger.info("Updated all revision forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormStatsMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormStatsMigration.ts new file mode 100644 index 00000000000..1223b6014c4 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb-es/FormStatsMigration.ts @@ -0,0 +1,360 @@ +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { Client } from "@elastic/elasticsearch"; +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { + batchWriteAll, + esCreateIndex, + esFindOne, + esGetIndexExist, + esGetIndexName, + esGetIndexSettings, + esPutIndexSettings, + esQueryAll, + forEachTenantLocale, + queryAll, + queryOne +} from "~/utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "~/migrations/5.40.0/001/types"; +import { + createDdbCmsEntity, + createDdbEsCmsEntity +} from "~/migrations/5.40.0/001/entities/createCmsEntity"; +import { + getCompressedData, + getFormStatsMetaFields, + getStatsCommonFields +} from "~/migrations/5.40.0/001/utils"; +import { executeWithRetry } from "@webiny/utils"; + +export class FormBuilder_5_40_0_001_FormStats implements DataMigration { + private readonly table: Table; + private readonly esClient: Client; + private readonly ddbCmsEntity: ReturnType; + private readonly ddbEsCmsEntity: ReturnType; + private ddbFormEntity: ReturnType; + + constructor( + table: Table, + esTable: Table, + esClient: Client + ) { + this.table = table; + this.esClient = esClient; + this.ddbCmsEntity = createDdbCmsEntity(table); + this.ddbEsCmsEntity = createDdbEsCmsEntity(esTable); + this.ddbFormEntity = createFormEntity(table); + } + + getId(): string { + return "Form Stats Entries"; + } + + getDescription(): string { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form stats entries for ${tenantId} - ${localeCode}.`); + + const indexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...indexNameParams + }); + + if (!indexExists) { + logger.info( + `No Elasticsearch index found for forms in tenant "${tenantId}" and locale "${localeCode}"; skipping.` + ); + shouldExecute = false; + return true; + } + + // Fetch latest form record from ES + const latestForm = await esFindOne({ + elasticsearchClient: this.esClient, + index: esGetIndexName(indexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.form" } } + ] + } + }, + sort: [ + { + "id.keyword": { order: "asc", unmapped_type: "keyword" } + } + ] + } + }); + + if (!latestForm) { + logger.info( + `No forms found in tenant "${tenantId}" and locale "${localeCode}".` + ); + shouldExecute = false; + return true; + } + + // Fetch HCMS form stats records from DDB using latest form "id" + const [formId, revisionId] = latestForm.id.split("#"); + const cmsEntry = await queryOne({ + entity: this.ddbCmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}-${revisionId}-stats`, + options: { + eq: "L" + } + }); + + if (!cmsEntry) { + logger.info( + `No revisions CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form revisions entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Migrating form stats entries for ${tenantId} - ${localeCode}.`); + + const formBuilderIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const fbFormStatsHcmsIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "fbformstat", + isHeadlessCmsModel: true + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...formBuilderIndexNameParams + }); + + if (!indexExists) { + // Continue with next locale. + return true; + } + + const esRecords = await esQueryAll({ + elasticsearchClient: this.esClient, + index: esGetIndexName(formBuilderIndexNameParams), + body: { + query: { + bool: { + filter: [{ term: { "__type.keyword": "fb.form" } }] + } + }, + size: 10000 + } + }); + + if (!esRecords.length) { + // Continue with next locale. + return true; + } + + // Since it might be the first time we add a HCMS formStats record, we also need to create the index + const fbFormStatsHcmsIndex = await esCreateIndex({ + elasticsearchClient: this.esClient, + ...fbFormStatsHcmsIndexNameParams + }); + + // Saving HCMS formStats index settings, we are going to reset them and save the original ones later + const settings = await esGetIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormStatsHcmsIndex, + fields: ["number_of_replicas", "refresh_interval"] + }); + + logger.trace( + `Replacing existing settings with default from "${fbFormStatsHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormStatsHcmsIndex, + settings: { + number_of_replicas: 0, + refresh_interval: -1 + } + }); + + try { + const formIds = esRecords.map(item => item.formId).filter(Boolean); + const uniqueFormIds = [...new Set(formIds)]; + + const ddbItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + + const ddbEsItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const formId of uniqueFormIds) { + const forms = await queryAll({ + entity: this.ddbFormEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#${formId}`, + options: { + beginsWith: "REV#" + } + }); + + // No form revision entry found: we don't need to create an HCMS entry for it + if (!forms.length) { + continue; + } + + for (const form of forms) { + const [formId, revisionId] = form.id.split("#"); + + // Get common fields + const commonFields = getStatsCommonFields(form); + + // Get the new meta fields + const entryMetaFields = getFormStatsMetaFields(form); + + const ddbRevisionItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}-${revisionId}-stats`, + SK: `REV#0001`, + TYPE: "cms.entry", + ...commonFields, + ...entryMetaFields + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbRevisionItem)); + + const ddbLatestItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}-${revisionId}-stats`, + SK: "L", + TYPE: "cms.entry.l", + ...commonFields, + ...entryMetaFields + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbLatestItem)); + + const ddbEsItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${formId}-${revisionId}-stats`, + SK: "L", + index: fbFormStatsHcmsIndex, + data: await getCompressedData({ + ...commonFields, + ...entryMetaFields, + rawValues: {}, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + }) + }; + + ddbEsItems.push(this.ddbEsCmsEntity.putBatch(ddbEsItem)); + } + } + + const executeDdb = () => { + return batchWriteAll({ + table: this.ddbCmsEntity.table, + items: ddbItems + }); + }; + + const executeDdbEs = () => { + return batchWriteAll({ + table: this.ddbEsCmsEntity.table, + items: ddbEsItems + }); + }; + + await executeWithRetry(executeDdb, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + await executeWithRetry(executeDdbEs, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb + es" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info(`Migrated form stats entries for ${tenantId} - ${localeCode}.`); + } finally { + // Saving back HCMS formStats index settings + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormStatsHcmsIndex, + settings: { + number_of_replicas: settings.number_of_replicas || null, + refresh_interval: settings.refresh_interval || null + } + }); + + logger.trace( + `Successfully set back the previously found settings from "${fbFormStatsHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + } + + return true; + } + }); + + logger.info("Updated all stats forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb-es/index.ts b/packages/migrations/src/migrations/5.40.0/001/ddb-es/index.ts new file mode 100644 index 00000000000..e8593effe23 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb-es/index.ts @@ -0,0 +1,68 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { Client } from "@elastic/elasticsearch"; +import { + DataMigration, + DataMigrationContext, + ElasticsearchClientSymbol, + ElasticsearchDynamoTableSymbol, + getChildLogger, + PrimaryDynamoTableSymbol +} from "@webiny/data-migration"; +import { makeInjectable, inject } from "@webiny/ioc"; +import { FormBuilder_5_40_0_001_FormLatest } from "./FormLatestMigration"; +import { FormBuilder_5_40_0_001_FormPublished } from "~/migrations/5.40.0/001/ddb-es/FormPublishedMigration"; +import { FormBuilder_5_40_0_001_FormRevisions } from "~/migrations/5.40.0/001/ddb-es/FormRevisionsMigration"; +import { FormBuilder_5_40_0_001_FormStats } from "~/migrations/5.40.0/001/ddb-es/FormStatsMigration"; +export * from "../types"; + +export class FormBuilder_5_40_0_001 implements DataMigration { + private migrations: DataMigration[]; + + constructor( + table: Table, + esTable: Table, + elasticsearchClient: Client + ) { + this.migrations = [ + new FormBuilder_5_40_0_001_FormLatest(table, esTable, elasticsearchClient), + new FormBuilder_5_40_0_001_FormPublished(table, esTable, elasticsearchClient), + new FormBuilder_5_40_0_001_FormRevisions(table, esTable, elasticsearchClient), + new FormBuilder_5_40_0_001_FormStats(table, esTable, elasticsearchClient) + ]; + } + + getId(): string { + return "5.40.0-001"; + } + + getDescription(): string { + return "Upgrade Form Builder (forms) to use HCMS storage operations."; + } + + async shouldExecute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + return true; + } + } + return false; + } + + async execute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + await migration.execute(childContext); + } + } + } +} + +makeInjectable(FormBuilder_5_40_0_001, [ + inject(PrimaryDynamoTableSymbol), + inject(ElasticsearchDynamoTableSymbol), + inject(ElasticsearchClientSymbol) +]); diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb/FormLatestMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb/FormLatestMigration.ts new file mode 100644 index 00000000000..8c14709158a --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb/FormLatestMigration.ts @@ -0,0 +1,190 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { createFormEntity } from "../entities/createFormEntity"; +import { createDdbCmsEntity } from "../entities/createCmsEntity"; +import { batchWriteAll, ddbQueryAllWithCallback, forEachTenantLocale, queryOne } from "~/utils"; +import { executeWithRetry } from "@webiny/utils"; + +import { + getFirstLastPublishedOnBy, + getFormCommonFields, + getMetaFields, + getOldestRevisionCreatedOn, + getRevisionStatus +} from "../utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "../types"; + +export class FormBuilder_5_40_0_001_FormLatest implements DataMigration { + private readonly formEntity: ReturnType; + private readonly cmsEntity: ReturnType; + private readonly table: Table; + + constructor(table: Table) { + this.table = table; + this.formEntity = createFormEntity(table); + this.cmsEntity = createDdbCmsEntity(table); + } + + getId() { + return "Form Latest Entries"; + } + + getDescription() { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form latest entries for ${tenantId} - ${localeCode}.`); + + const form = await queryOne({ + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#L` + }); + + if (!form) { + logger.info( + `No form latest entry found for ${tenantId} - ${localeCode}: skipping migration.` + ); + shouldExecute = false; + return true; + } + + const [formId] = form.id.split("#"); + + const cmsEntry = await queryOne({ + entity: this.cmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + options: { + eq: "L" + } + }); + + if (!cmsEntry) { + logger.info( + `No latest CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form latest entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + await ddbQueryAllWithCallback( + { + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#L` + }, + async forms => { + if (!forms.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return; + } + + logger.info( + `Migrating form latest entries for ${tenantId} - ${localeCode}.` + ); + + const items: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const form of forms) { + const [formId] = form.id.split("#"); + + // Get common fields + const entryCommonFields = getFormCommonFields(form); + + // Get the status field, based on the revision and the published entry + const status = await getRevisionStatus({ + form, + formEntity: this.formEntity + }); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getOldestRevisionCreatedOn({ + form, + formEntity: this.formEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({ + form, + formEntity: this.formEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + const item = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + SK: "L", + GSI1_PK: `T#${tenantId}#L#${localeCode}#CMS#CME#M#fbForm#L`, + GSI1_SK: `${form.id}`, + TYPE: "cms.entry.l", + ...entryCommonFields, + ...entryMetaFields, + status + }; + + items.push(this.cmsEntity.putBatch(item)); + } + + const execute = () => { + return batchWriteAll({ table: this.cmsEntity.table, items }); + }; + + await executeWithRetry(execute, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info( + `Migrated form latest entries for ${tenantId} - ${localeCode}.` + ); + } + ); + + return true; + } + }); + + logger.info("Updated all latest forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb/FormPublishedMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb/FormPublishedMigration.ts new file mode 100644 index 00000000000..ddc33dde26c --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb/FormPublishedMigration.ts @@ -0,0 +1,182 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { createFormEntity } from "../entities/createFormEntity"; +import { createDdbCmsEntity } from "../entities/createCmsEntity"; +import { batchWriteAll, ddbQueryAllWithCallback, forEachTenantLocale, queryOne } from "~/utils"; +import { executeWithRetry } from "@webiny/utils"; + +import { + getFirstLastPublishedOnBy, + getFormCommonFields, + getMetaFields, + getOldestRevisionCreatedOn +} from "../utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "../types"; + +export class FormBuilder_5_40_0_001_FormPublished implements DataMigration { + private readonly formEntity: ReturnType; + private readonly cmsEntity: ReturnType; + private readonly table: Table; + + constructor(table: Table) { + this.table = table; + this.formEntity = createFormEntity(table); + this.cmsEntity = createDdbCmsEntity(table); + } + + getId() { + return "Form Published Entries"; + } + + getDescription() { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form published entries for ${tenantId} - ${localeCode}.`); + + const form = await queryOne({ + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#LP` + }); + + if (!form) { + logger.info( + `No form published entry found for ${tenantId} - ${localeCode}: skipping migration.` + ); + shouldExecute = false; + return true; + } + + const [formId] = form.id.split("#"); + + const cmsEntry = await queryOne({ + entity: this.cmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + options: { + eq: "P" + } + }); + + if (!cmsEntry) { + logger.info( + `No published CMS entries found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form published entries already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + await ddbQueryAllWithCallback( + { + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F#LP` + }, + async forms => { + if (!forms.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return; + } + + logger.info( + `Migrating form published entries for ${tenantId} - ${localeCode}.` + ); + + const items: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const form of forms) { + const [formId] = form.id.split("#"); + + // Get common fields + const entryCommonFields = getFormCommonFields(form); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getOldestRevisionCreatedOn({ + form, + formEntity: this.formEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({ + form, + formEntity: this.formEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + const item = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + SK: "P", + GSI1_PK: `T#${tenantId}#L#${localeCode}#CMS#CME#M#fbForm#P`, + GSI1_SK: `${form.id}`, + TYPE: "cms.entry.p", + ...entryCommonFields, + ...entryMetaFields + }; + + items.push(this.cmsEntity.putBatch(item)); + } + + const execute = () => { + return batchWriteAll({ table: this.cmsEntity.table, items }); + }; + + await executeWithRetry(execute, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info( + `Migrated form published entries for ${tenantId} - ${localeCode}.` + ); + } + ); + + return true; + } + }); + + logger.info("Updated all published forms."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb/FormRevisionsMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb/FormRevisionsMigration.ts new file mode 100644 index 00000000000..24b8d4e68be --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb/FormRevisionsMigration.ts @@ -0,0 +1,190 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { createFormEntity } from "../entities/createFormEntity"; +import { createDdbCmsEntity } from "../entities/createCmsEntity"; +import { batchWriteAll, ddbQueryAllWithCallback, forEachTenantLocale, queryOne } from "~/utils"; +import { executeWithRetry } from "@webiny/utils"; + +import { + getFirstLastPublishedOnBy, + getFormCommonFields, + getMetaFields, + getOldestRevisionCreatedOn, + getRevisionStatus +} from "../utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "../types"; + +export class FormBuilder_5_40_0_001_FormRevisions implements DataMigration { + private readonly formEntity: ReturnType; + private readonly cmsEntity: ReturnType; + private readonly table: Table; + + constructor(table: Table) { + this.table = table; + this.formEntity = createFormEntity(table); + this.cmsEntity = createDdbCmsEntity(table); + } + + getId() { + return "Form Revision Entries"; + } + + getDescription() { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form revisions for ${tenantId} - ${localeCode}.`); + + const formRevision = await queryOne({ + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F` + }); + + if (!formRevision) { + logger.info( + `No form revisions found for ${tenantId} - ${localeCode}: skipping migration.` + ); + shouldExecute = false; + return true; + } + + const [formId, revisionId] = formRevision.id.split("#"); + + const cmsRevision = await queryOne({ + entity: this.cmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + options: { + eq: `REV#${revisionId}` + } + }); + + if (!cmsRevision) { + logger.info( + `No CMS entries revisions found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form revisions already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + await ddbQueryAllWithCallback( + { + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F` + }, + async forms => { + if (!forms.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return; + } + + logger.info( + `Migrating form revision entries for ${tenantId} - ${localeCode}.` + ); + + const items: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const form of forms) { + const [formId, revisionId] = form.id.split("#"); + + // Get common fields + const entryCommonFields = getFormCommonFields(form); + + // Get the status field, based on the revision and the published entry + const status = await getRevisionStatus({ + form, + formEntity: this.formEntity + }); + + // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value. + const createdOn = await getOldestRevisionCreatedOn({ + form, + formEntity: this.formEntity + }); + + // Get first/last published meta fields + const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({ + form, + formEntity: this.formEntity + }); + + // Create the new meta fields + const entryMetaFields = getMetaFields(form, { + createdOn, + ...firstLastPublishedOnByFields + }); + + const item = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}`, + SK: `REV#${revisionId}`, + GSI1_PK: `T#${tenantId}#L#${localeCode}#CMS#CME#M#fbForm#A`, + GSI1_SK: `${form.id}`, + TYPE: "cms.entry", + ...entryCommonFields, + ...entryMetaFields, + status + }; + + items.push(this.cmsEntity.putBatch(item)); + } + + const execute = () => { + return batchWriteAll({ table: this.cmsEntity.table, items }); + }; + + await executeWithRetry(execute, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info( + `Migrated form revision entries for ${tenantId} - ${localeCode}.` + ); + } + ); + + return true; + } + }); + + logger.info("Updated all form revisions."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb/FormStatsMigration.ts b/packages/migrations/src/migrations/5.40.0/001/ddb/FormStatsMigration.ts new file mode 100644 index 00000000000..b04ceb27f21 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb/FormStatsMigration.ts @@ -0,0 +1,172 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { createFormEntity } from "../entities/createFormEntity"; +import { createDdbCmsEntity } from "../entities/createCmsEntity"; +import { batchWriteAll, ddbQueryAllWithCallback, forEachTenantLocale, queryOne } from "~/utils"; +import { executeWithRetry } from "@webiny/utils"; + +import { getFormStatsMetaFields, getStatsCommonFields } from "../utils"; +import { CmsEntryWithMeta, FbForm, MigrationCheckpoint } from "../types"; + +export class FormBuilder_5_40_0_001_FormStats implements DataMigration { + private readonly formEntity: ReturnType; + private readonly cmsEntity: ReturnType; + private readonly table: Table; + + constructor(table: Table) { + this.table = table; + this.formEntity = createFormEntity(table); + this.cmsEntity = createDdbCmsEntity(table); + } + + getId() { + return "Form Stats Entries"; + } + + getDescription() { + return ""; + } + + async shouldExecute({ + logger, + checkpoint, + forceExecute + }: DataMigrationContext): Promise { + if (checkpoint || forceExecute) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form stats for ${tenantId} - ${localeCode}.`); + + const formRevision = await queryOne({ + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F` + }); + + if (!formRevision) { + logger.info( + `No form revisions found for ${tenantId} - ${localeCode}: skipping migration.` + ); + shouldExecute = false; + return true; + } + + const [formId, revisionId] = formRevision.id.split("#"); + + const cmsStats = await queryOne({ + entity: this.cmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}-${revisionId}-stats`, + options: { + eq: "L" + } + }); + + if (!cmsStats) { + logger.info( + `No CMS entries for Form stats found for ${tenantId} - ${localeCode}: executing migration.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form stats already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ logger }: DataMigrationContext): Promise { + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + await ddbQueryAllWithCallback( + { + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F` + }, + async forms => { + if (!forms.length) { + logger.info( + `No forms found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return; + } + + logger.info( + `Migrating form stats entries for ${tenantId} - ${localeCode}.` + ); + + const items: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const form of forms) { + const [formId, revisionId] = form.id.split("#"); + + // Get common fields + const commonFields = getStatsCommonFields(form); + + // Get the new meta fields + const entryMetaFields = getFormStatsMetaFields(form); + + const revision = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}-${revisionId}-stats`, + SK: `REV#0001`, + GSI1_PK: `T#${tenantId}#L#${localeCode}#CMS#CME#M#fbFormStat#A`, + GSI1_SK: `${formId}-${revisionId}-stats#0001`, + TYPE: "cms.entry", + ...commonFields, + ...entryMetaFields + }; + + items.push(this.cmsEntity.putBatch(revision)); + + const latest = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formId}-${revisionId}-stats`, + SK: "L", + GSI1_PK: `T#${tenantId}#L#${localeCode}#CMS#CME#M#fbFormStat#L`, + GSI1_SK: `${formId}-${revisionId}-stats#0001`, + TYPE: "cms.entry.l", + ...commonFields, + ...entryMetaFields + }; + + items.push(this.cmsEntity.putBatch(latest)); + } + + const execute = () => { + return batchWriteAll({ table: this.cmsEntity.table, items }); + }; + + await executeWithRetry(execute, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + logger.info(`Migrated form stats entries for ${tenantId} - ${localeCode}.`); + } + ); + + return true; + } + }); + + logger.info("Updated all form stats."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/001/ddb/index.ts b/packages/migrations/src/migrations/5.40.0/001/ddb/index.ts new file mode 100644 index 00000000000..4cd60be8918 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/ddb/index.ts @@ -0,0 +1,56 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { + DataMigration, + DataMigrationContext, + getChildLogger, + PrimaryDynamoTableSymbol +} from "@webiny/data-migration"; +import { makeInjectable, inject } from "@webiny/ioc"; +import { FormBuilder_5_40_0_001_FormLatest } from "./FormLatestMigration"; +import { FormBuilder_5_40_0_001_FormPublished } from "./FormPublishedMigration"; +import { FormBuilder_5_40_0_001_FormRevisions } from "./FormRevisionsMigration"; +import { FormBuilder_5_40_0_001_FormStats } from "./FormStatsMigration"; + +export class FormBuilder_5_40_0_001 implements DataMigration { + private migrations: DataMigration[]; + + constructor(table: Table) { + this.migrations = [ + new FormBuilder_5_40_0_001_FormRevisions(table), + new FormBuilder_5_40_0_001_FormPublished(table), + new FormBuilder_5_40_0_001_FormLatest(table), + new FormBuilder_5_40_0_001_FormStats(table) + ]; + } + + getId(): string { + return "5.40.0-001"; + } + + getDescription(): string { + return "Upgrade Form Builder (forms) to use HCMS storage operations."; + } + + async shouldExecute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + return true; + } + } + return false; + } + + async execute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + await migration.execute(childContext); + } + } + } +} + +makeInjectable(FormBuilder_5_40_0_001, [inject(PrimaryDynamoTableSymbol)]); diff --git a/packages/migrations/src/migrations/5.40.0/001/entities/createCmsEntity.ts b/packages/migrations/src/migrations/5.40.0/001/entities/createCmsEntity.ts new file mode 100644 index 00000000000..4503cbca026 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/entities/createCmsEntity.ts @@ -0,0 +1,112 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createLegacyEntity, createStandardEntity } from "~/utils"; + +const cmsAttributes: Parameters[2] = { + PK: { + type: "string", + partitionKey: true + }, + SK: { + type: "string", + sortKey: true + }, + GSI1_PK: { + type: "string" + }, + GSI1_SK: { + type: "string" + }, + TYPE: { + type: "string" + }, + __type: { + type: "string" + }, + webinyVersion: { + type: "string" + }, + tenant: { + type: "string" + }, + entryId: { + type: "string" + }, + id: { + type: "string" + }, + location: { + type: "map" + }, + modelId: { + type: "string" + }, + locale: { + type: "string" + }, + version: { + type: "number" + }, + locked: { + type: "boolean" + }, + status: { + type: "string" + }, + values: { + type: "map" + }, + meta: { + type: "map" + }, + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedOn: { type: "string" }, + revisionSavedOn: { type: "string" }, + revisionModifiedOn: { type: "string" }, + revisionFirstPublishedOn: { type: "string" }, + revisionLastPublishedOn: { type: "string" }, + revisionCreatedBy: { type: "map" }, + revisionSavedBy: { type: "map" }, + revisionModifiedBy: { type: "map" }, + revisionFirstPublishedBy: { type: "map" }, + revisionLastPublishedBy: { type: "map" }, + /** + * Entry-level meta fields. 👇 + */ + createdOn: { type: "string" }, + savedOn: { type: "string" }, + modifiedOn: { type: "string" }, + firstPublishedOn: { type: "string" }, + lastPublishedOn: { type: "string" }, + createdBy: { type: "map" }, + savedBy: { type: "map" }, + modifiedBy: { type: "map" }, + firstPublishedBy: { type: "map" }, + lastPublishedBy: { type: "map" } +}; + +const cmsEsAttributes: Parameters[2] = { + PK: { + type: "string", + partitionKey: true + }, + SK: { + type: "string", + sortKey: true + }, + index: { + type: "string" + }, + data: { + type: "map" + } +}; + +export const createDdbCmsEntity = (table: Table) => { + return createLegacyEntity(table, "CmsEntries", cmsAttributes); +}; + +export const createDdbEsCmsEntity = (table: Table) => { + return createStandardEntity(table, "CmsEntriesElasticsearch", cmsEsAttributes); +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/entities/createFormEntity.ts b/packages/migrations/src/migrations/5.40.0/001/entities/createFormEntity.ts new file mode 100644 index 00000000000..2999aedf4d2 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/entities/createFormEntity.ts @@ -0,0 +1,85 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createLegacyEntity } from "~/utils"; + +export const createFormEntity = (table: Table) => { + return createLegacyEntity(table, "FormBuilderForm", { + PK: { + partitionKey: true + }, + SK: { + sortKey: true + }, + GSI1_PK: { + type: "string" + }, + GSI1_SK: { + type: "string" + }, + TYPE: { + type: "string" + }, + id: { + type: "string" + }, + formId: { + type: "string" + }, + tenant: { + type: "string" + }, + locale: { + type: "string" + }, + createdBy: { + type: "map" + }, + ownedBy: { + type: "map" + }, + savedOn: { + type: "string" + }, + createdOn: { + type: "string" + }, + name: { + type: "string" + }, + slug: { + type: "string" + }, + version: { + type: "number" + }, + locked: { + type: "boolean" + }, + published: { + type: "boolean" + }, + publishedOn: { + type: "string" + }, + status: { + type: "string" + }, + fields: { + type: "list" + }, + steps: { + type: "list" + }, + stats: { + type: "map" + }, + settings: { + type: "map" + }, + triggers: { + type: "map" + }, + webinyVersion: { + type: "string" + } + }); +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/types.ts b/packages/migrations/src/migrations/5.40.0/001/types.ts new file mode 100644 index 00000000000..2dddf14954a --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/types.ts @@ -0,0 +1,280 @@ +// General +interface LastEvaluatedKey { + PK: string; + SK: string; + GSI1_PK: string; + GSI1_SK: string; +} + +export interface MigrationCheckpoint { + lastEvaluatedKey?: LastEvaluatedKey | boolean; +} + +export interface I18NLocale { + code: string; +} + +export interface Identity { + id: string; + displayName: string | null; + type: string; +} + +export enum Status { + PUBLISHED = "published", + UNPUBLISHED = "unpublished", + DRAFT = "draft" +} + +// Forms - 5.38.0 +export interface FbFormFieldOption { + label?: string; + value?: string; +} + +export interface FbFormField { + _id: string; + fieldId: string; + type: string; + name: string; + label: string; + placeholderText: string | null; + helpText: string | null; + options: FbFormFieldOption[]; + validation: FbFormFieldValidator[]; + settings: JSON; +} + +export type FbFormLayout = Array>; + +interface FbFormStep { + title: string; + layout: FbFormLayout; +} + +interface FbFormFieldValidatorSettings { + /** + * In. + */ + values?: string[]; + /** + * gte, lte, max, min + */ + value?: string; + /** + * Pattern. + */ + preset?: string; + [key: string]: any; +} + +interface FbFormFieldValidator { + name: string; + message: any; + settings: FbFormFieldValidatorSettings; +} + +export interface FbFormStats { + submissions: number; + views: number; +} + +export interface FbFormSettings { + fullWidthSubmitButton: boolean | null; + successMessage: JSON[] | null; + submitButtonLabel: string | null; + layout: { + renderer: string | null; + } | null; + reCaptcha: { + enabled: boolean | null; + errorMessage: string | null; + }; + termsOfServiceMessage: { + enabled: boolean | null; + errorMessage: string | null; + message: JSON[] | null; + } | null; +} + +export interface FbForm { + id: string; + tenant: string; + locale: string; + createdBy: Identity; + ownedBy: Identity; + savedOn: string; + createdOn: string; + name: string; + slug: string; + version: number; + locked: boolean; + published: boolean; + publishedOn: string | null; + status: Status; + fields: FbFormField[]; + steps: FbFormStep[]; + stats: FbFormStats; + settings: FbFormSettings; + triggers: Record | null; + formId: string; + webinyVersion: string; +} + +// CMS Entries / Forms - 5.40.0 +export interface CmsEntryValues { + [key: string]: any; +} + +export interface CmsEntryRawValues { + [key: string]: any; +} + +export interface MetaFields { + /** + * Entry-level meta fields. 👇 + */ + createdOn: string; + savedOn: string; + modifiedOn: string | null; + firstPublishedOn: string | null; + lastPublishedOn: string | null; + createdBy: Identity; + savedBy: Identity; + modifiedBy: Identity | null; + firstPublishedBy: Identity | null; + lastPublishedBy: Identity | null; + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedOn: string; + revisionSavedOn: string; + revisionModifiedOn: string | null; + revisionFirstPublishedOn: string | null; + revisionLastPublishedOn: string | null; + revisionCreatedBy: Identity; + revisionSavedBy: Identity; + revisionModifiedBy: Identity | null; + revisionFirstPublishedBy: Identity | null; + revisionLastPublishedBy: Identity | null; +} + +export interface CmsEntry { + webinyVersion: string; + tenant: string; + entryId: string; + id: string; + modelId: string; + locale: string; + location: { + folderId: string; + }; + version: number; + locked: boolean; + status: Status; + values: T; + meta?: { + [key: string]: any; + }; +} + +export interface FormEntryCommonField { + "json@settings": JSON | null; + "object@options": Array<{ + "text@label"?: string; + "text@value"?: string; + }> | null; + "object@validation": { + "json@settings": FbFormFieldValidatorSettings; + "text@message": any; + "text@name": string; + }[]; + "text@fieldId": string; + "text@helpText": string | null; + "text@label": string; + "text@name": string; + "text@placeholderText": string | null; + "text@type": string; + "text@_id": string; +} + +export interface FormEntryCommonSteps { + "json@layout": FbFormLayout; + "text@title": string; +} + +export interface CmsEntryWithMeta extends CmsEntry, MetaFields {} + +export interface CmsEntryDdbEs extends CmsEntry { + rawValues: R; +} + +export interface FormEntryValues { + "json@triggers": Record | null; + "object@fields": FormEntryCommonField[]; + "object@settings": { + "boolean@fullWidthSubmitButton": boolean | null; + "json@successMessage": JSON[] | null; + "text@submitButtonLabel": string | null; + "object@layout": { + "text@renderer": string | null; + } | null; + "object@reCaptcha": { + "boolean@enabled": boolean | null; + "text@errorMessage": string | null; + }; + "object@termsOfServiceMessage"?: { + "boolean@enabled": boolean | null; + "json@message": JSON[] | null; + "text@errorMessage": string | null; + }; + }; + "object@steps": FormEntryCommonSteps[]; + "text@formId": string; + "text@name": string; + "text@slug": string; +} + +export interface FormEntryDdbEsValues { + "text@formId": string; + "text@name": string; + "text@slug": string; + "object@fields": Omit[]; + "object@steps": Omit[]; + "object@settings": { + "object@layout": { + "text@renderer": string | null; + } | null; + "text@submitButtonLabel": string | null; + "boolean@fullWidthSubmitButton": boolean | null; + "object@termsOfServiceMessage"?: { + "boolean@enabled": boolean | null; + "text@errorMessage": string | null; + }; + "object@reCaptcha": { + "boolean@enabled": boolean | null; + "text@errorMessage": string | null; + }; + }; +} + +export interface FormEntryDdbEsRawValues { + "object@fields": Pick[]; + "object@steps": Pick[]; + "object@settings": { + "object@layout": Record; + "object@reCaptcha": Record; + "json@successMessage": JSON[] | null; + "object@termsOfServiceMessage"?: { + "json@message": JSON[] | null; + }; + }; + "json@triggers": Record | null; +} + +export interface FormStatsValues { + "number@formVersion": number; + "number@submissions": number; + "number@views": number; + "text@formId": string; +} diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getCompressedData.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getCompressedData.ts new file mode 100644 index 00000000000..31f77e45314 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getCompressedData.ts @@ -0,0 +1,13 @@ +import { compress as gzip } from "@webiny/utils/compression/gzip"; + +const GZIP = "gzip"; +const TO_STORAGE_ENCODING = "base64"; + +export const getCompressedData = async (data: any) => { + const value = await gzip(JSON.stringify(data)); + + return { + compression: GZIP, + value: value.toString(TO_STORAGE_ENCODING) + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getDdbEsFormCommonFields.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getDdbEsFormCommonFields.ts new file mode 100644 index 00000000000..b6d8dffc60e --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getDdbEsFormCommonFields.ts @@ -0,0 +1,85 @@ +import { CmsEntryDdbEs, FbForm, FormEntryDdbEsRawValues, FormEntryDdbEsValues } from "../types"; + +export const getDdbEsFormCommonFields = ( + form: FbForm +): CmsEntryDdbEs => { + return { + entryId: form.formId, + id: form.id, + locked: form.locked, + locale: form.locale, + location: { + folderId: "root" + }, + modelId: "fbForm", + status: form.status, + tenant: form.tenant, + version: form.version, + webinyVersion: String(process.env.WEBINY_VERSION), + meta: {}, + values: { + "text@formId": form.formId, + "text@name": form.name, + "text@slug": form.slug, + "object@fields": form.fields.map(field => ({ + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(validation => ({ + "text@message": validation.message, + "text@name": validation.name + })), + "text@_id": field._id, + "text@fieldId": field.fieldId, + "text@type": field.type, + "text@name": field.name, + "text@label": field.label, + "text@helpText": field.helpText ?? null, + "text@placeholderText": field.placeholderText ?? null + })), + "object@steps": form.steps.map(step => ({ + "text@title": step.title + })), + "object@settings": { + "object@layout": { + "text@renderer": form.settings.layout?.renderer || null + }, + "text@submitButtonLabel": form.settings.submitButtonLabel, + "boolean@fullWidthSubmitButton": form.settings.fullWidthSubmitButton, + "object@reCaptcha": { + "boolean@enabled": form.settings.reCaptcha.enabled, + "text@errorMessage": form.settings.reCaptcha.errorMessage + }, + ...(form.settings.termsOfServiceMessage && { + "object@termsOfServiceMessage": { + "boolean@enabled": form.settings.termsOfServiceMessage.enabled, + "text@errorMessage": form.settings.termsOfServiceMessage.errorMessage + } + }) + } + }, + rawValues: { + "object@fields": form.fields.map(field => ({ + "json@settings": field.settings, + "object@validation": field.validation.map(validation => ({ + "json@settings": validation.settings + })) + })), + "object@steps": form.steps.map(step => ({ + "json@layout": step.layout + })), + "object@settings": { + "object@layout": {}, + "object@reCaptcha": {}, + "json@successMessage": form.settings.successMessage, + ...(form.settings.termsOfServiceMessage && { + "object@termsOfServiceMessage": { + "json@message": form.settings.termsOfServiceMessage.message + } + }) + }, + "json@triggers": form.triggers ?? null + } + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getEntryStatus.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getEntryStatus.ts new file mode 100644 index 00000000000..eaff0d25947 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getEntryStatus.ts @@ -0,0 +1,60 @@ +import { FbForm, Status } from "~/migrations/5.40.0/001/types"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { queryOne } from "~/utils"; + +export interface GetRevisionStatusParams { + form: FbForm; + formEntity: ReturnType; +} + +export const getRevisionStatus = async (params: GetRevisionStatusParams): Promise => { + const { form, formEntity } = params; + + const result = await formEntity.query(`T#${form.tenant}#L#${form.locale}#FB#F#LP`, { + limit: 1, + eq: form.formId, + attributes: ["id"] + }); + + const publishedForm = result.Items?.[0]; + + // If published entry is not provided OR the revision id differs from the published id + if (!publishedForm || form.id !== publishedForm.id) { + // If the revision is locked: this means the revision has been published and unpublished + if (form.locked) { + return Status.UNPUBLISHED; + } + + // else the revision is in draft + return Status.DRAFT; + } + + // Return published + return Status.PUBLISHED; +}; + +export const getDdbEsRevisionStatus = async (params: GetRevisionStatusParams): Promise => { + const { form, formEntity } = params; + + const publishedForm = await queryOne({ + entity: formEntity, + partitionKey: `T#${form.tenant}#L#${form.locale}#FB#F#${form.formId}`, + options: { + eq: "LP" + } + }); + + // If published entry is not provided OR the revision id differs from the published id + if (!publishedForm || form.id !== publishedForm.id) { + // If the revision is locked: this means the revision has been published and unpublished + if (form.locked) { + return Status.UNPUBLISHED; + } + + // else the revision is in draft + return Status.DRAFT; + } + + // Return published + return Status.PUBLISHED; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getFirstLastPublishedOn.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getFirstLastPublishedOn.ts new file mode 100644 index 00000000000..0e605269211 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getFirstLastPublishedOn.ts @@ -0,0 +1,84 @@ +import { CmsEntryWithMeta } from "../types"; +import { FbForm } from "~/migrations/5.40.0/001/types"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { queryOne } from "@webiny/db-dynamodb"; + +const cachedFormFirstLastPublishedOnBy: Record< + string, + Pick< + CmsEntryWithMeta, + "firstPublishedOn" | "lastPublishedOn" | "firstPublishedBy" | "lastPublishedBy" + > +> = {}; + +export interface getFirstLastPublishedOnParams { + form: FbForm; + formEntity: ReturnType; +} + +export const getFirstLastPublishedOnBy = async (params: getFirstLastPublishedOnParams) => { + const { form, formEntity } = params; + + if (cachedFormFirstLastPublishedOnBy[form.formId]) { + return cachedFormFirstLastPublishedOnBy[form.formId]; + } + + cachedFormFirstLastPublishedOnBy[form.formId] = { + firstPublishedOn: null, + lastPublishedOn: null, + firstPublishedBy: null, + lastPublishedBy: null + }; + + const result = await formEntity.query(`T#${form.tenant}#L#${form.locale}#FB#F#LP`, { + limit: 1, + eq: form.formId, + attributes: ["createdBy", "publishedOn"] + }); + + const publishedForm = result.Items?.[0]; + if (publishedForm) { + cachedFormFirstLastPublishedOnBy[form.formId] = { + firstPublishedOn: publishedForm.publishedOn || null, + lastPublishedOn: publishedForm.publishedOn || null, + firstPublishedBy: form.createdBy || null, + lastPublishedBy: form.createdBy || null + }; + } + + return cachedFormFirstLastPublishedOnBy[form.formId]; +}; + +export const getDdbEsFirstLastPublishedOnBy = async (params: getFirstLastPublishedOnParams) => { + const { form, formEntity } = params; + + if (cachedFormFirstLastPublishedOnBy[form.formId]) { + return cachedFormFirstLastPublishedOnBy[form.formId]; + } + + cachedFormFirstLastPublishedOnBy[form.formId] = { + firstPublishedOn: null, + lastPublishedOn: null, + firstPublishedBy: null, + lastPublishedBy: null + }; + + const publishedForm = await queryOne({ + entity: formEntity, + partitionKey: `T#${form.tenant}#L#${form.locale}#FB#F#${form.formId}`, + options: { + eq: "LP" + } + }); + + if (publishedForm) { + cachedFormFirstLastPublishedOnBy[form.formId] = { + firstPublishedOn: publishedForm.publishedOn || null, + lastPublishedOn: publishedForm.publishedOn || null, + firstPublishedBy: form.createdBy || null, + lastPublishedBy: form.createdBy || null + }; + } + + return cachedFormFirstLastPublishedOnBy[form.formId]; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getFormCommonFields.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getFormCommonFields.ts new file mode 100644 index 00000000000..8a85245b727 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getFormCommonFields.ts @@ -0,0 +1,67 @@ +import { CmsEntry, FbForm, FormEntryValues } from "../types"; + +export const getFormCommonFields = (form: FbForm): CmsEntry => { + return { + entryId: form.formId, + id: form.id, + locked: form.locked, + locale: form.locale, + location: { + folderId: "root" + }, + modelId: "fbForm", + status: form.status, + tenant: form.tenant, + version: form.version, + webinyVersion: String(process.env.WEBINY_VERSION), + meta: {}, + values: { + "json@triggers": form.triggers ?? null, + "object@fields": form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText ?? null, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText ?? null, + "text@type": field.type, + "text@_id": field._id + })), + "object@settings": { + "boolean@fullWidthSubmitButton": form.settings.fullWidthSubmitButton, + "json@successMessage": form.settings.successMessage, + "text@submitButtonLabel": form.settings.submitButtonLabel, + "object@layout": { + "text@renderer": form.settings.layout?.renderer || null + }, + "object@reCaptcha": { + "boolean@enabled": form.settings.reCaptcha.enabled, + "text@errorMessage": form.settings.reCaptcha.errorMessage + }, + ...(form.settings.termsOfServiceMessage && { + "object@termsOfServiceMessage": { + "boolean@enabled": form.settings.termsOfServiceMessage.enabled, + "json@message": form.settings.termsOfServiceMessage.message, + "text@errorMessage": form.settings.termsOfServiceMessage.errorMessage + } + }) + }, + "object@steps": form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@formId": form.formId, + "text@name": form.name, + "text@slug": form.slug + } + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getFormStatsMetaFields.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getFormStatsMetaFields.ts new file mode 100644 index 00000000000..7ee5826c544 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getFormStatsMetaFields.ts @@ -0,0 +1,21 @@ +import { FbForm } from "../types"; + +export const getFormStatsMetaFields = (form: FbForm) => { + return { + /** + * Entry-level meta fields. 👇 + */ + createdBy: form.createdBy, + createdOn: form.createdOn, + savedBy: form.createdBy, + savedOn: form.savedOn, + + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedBy: form.createdBy, + revisionCreatedOn: form.createdOn, + revisionSavedBy: form.createdBy, + revisionSavedOn: form.savedOn + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getMetaFields.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getMetaFields.ts new file mode 100644 index 00000000000..7dacb38ec67 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getMetaFields.ts @@ -0,0 +1,56 @@ +import { FbForm } from "../types"; +import { CmsIdentity } from "@webiny/api-headless-cms/types"; + +interface SpecialFields { + createdOn: string; + firstPublishedOn: string | null; + lastPublishedOn: string | null; + firstPublishedBy: CmsIdentity | null; + lastPublishedBy: CmsIdentity | null; +} + +export const getMetaFields = (form: FbForm, specialFields: SpecialFields) => { + const isDraft = form.status === "draft"; + + // We don't have `publishedBy`, that's why we're relying on `modifiedBy` or `createdBy`. + const revisionFirstLastPublishedOn = isDraft ? null : specialFields.firstPublishedOn || null; + const revisionFirstLastPublishedBy = isDraft + ? null + : specialFields.firstPublishedBy || form.createdBy; + + return { + // Revision-level meta fields. + revisionCreatedOn: form.createdOn, + + // `modifiedOn` does not exist, that's why we're using `savedOn`. + revisionModifiedOn: form.savedOn, + + revisionSavedOn: form.savedOn, + revisionCreatedBy: form.createdBy, + revisionModifiedBy: form.createdBy, + revisionSavedBy: form.createdBy, + + revisionFirstPublishedOn: revisionFirstLastPublishedOn, + revisionFirstPublishedBy: revisionFirstLastPublishedBy, + + revisionLastPublishedOn: revisionFirstLastPublishedOn, + revisionLastPublishedBy: revisionFirstLastPublishedBy, + + // Entry-level meta fields. + createdOn: specialFields.createdOn, + + // `modifiedOn` does not exist, that's why we're using `savedOn`. + modifiedOn: form.savedOn, + + savedOn: form.savedOn, + createdBy: form.createdBy, + modifiedBy: form.createdBy, + savedBy: form.createdBy, + + firstPublishedOn: specialFields.firstPublishedOn, + firstPublishedBy: specialFields.firstPublishedBy, + + lastPublishedOn: specialFields.lastPublishedOn, + lastPublishedBy: specialFields.lastPublishedBy + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getOldestRevisionCreatedOn.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getOldestRevisionCreatedOn.ts new file mode 100644 index 00000000000..f7aae86db9a --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getOldestRevisionCreatedOn.ts @@ -0,0 +1,61 @@ +import { FbForm } from "~/migrations/5.40.0/001/types"; +import { createFormEntity } from "~/migrations/5.40.0/001/entities/createFormEntity"; +import { queryOne } from "@webiny/db-dynamodb"; + +const cachedFormCreatedOn: Record = {}; + +export interface GetOldestRevisionCreatedOnParams { + form: FbForm; + formEntity: ReturnType; +} + +export const getOldestRevisionCreatedOn = async (params: GetOldestRevisionCreatedOnParams) => { + const { form, formEntity } = params; + + if (cachedFormCreatedOn[form.formId]) { + return cachedFormCreatedOn[form.formId]; + } + + if (form.version === 1) { + cachedFormCreatedOn[form.formId] = form.createdOn; + } else { + const result = await formEntity.query(`T#${form.tenant}#L#${form.locale}#FB#F`, { + limit: 1, + beginsWith: `${form.formId}#`, + attributes: ["createdOn"] + }); + + const oldestRevision = result.Items?.[0]; + if (oldestRevision) { + cachedFormCreatedOn[form.formId] = oldestRevision.createdOn; + } + } + + return cachedFormCreatedOn[form.formId]; +}; + +export const getDdbEsOldestRevisionCreatedOn = async (params: GetOldestRevisionCreatedOnParams) => { + const { form, formEntity } = params; + + if (cachedFormCreatedOn[form.formId]) { + return cachedFormCreatedOn[form.formId]; + } + + if (form.version === 1) { + cachedFormCreatedOn[form.formId] = form.createdOn; + } else { + const oldestRevision = await queryOne({ + entity: formEntity, + partitionKey: `T#${form.tenant}#L#${form.locale}#FB#F#${form.formId}`, + options: { + beginsWith: "REV#" + } + }); + + if (oldestRevision) { + cachedFormCreatedOn[form.formId] = oldestRevision.createdOn; + } + } + + return cachedFormCreatedOn[form.formId]; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/getStatsCommonFields.ts b/packages/migrations/src/migrations/5.40.0/001/utils/getStatsCommonFields.ts new file mode 100644 index 00000000000..dd570cd0d0b --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/getStatsCommonFields.ts @@ -0,0 +1,26 @@ +import { CmsEntry, FbForm, FormStatsValues, Status } from "../types"; + +export const getStatsCommonFields = (form: FbForm): CmsEntry => { + const [formId, revisionId] = form.id.split("#"); + + return { + entryId: `${formId}-${revisionId}-stats`, + id: `${formId}-${revisionId}-stats#0001`, + locked: false, + locale: form.locale, + location: { + folderId: "root" + }, + modelId: "fbFormStat", + status: Status.DRAFT, + tenant: form.tenant, + version: 1, + webinyVersion: String(process.env.WEBINY_VERSION), + values: { + "number@formVersion": form.version, + "number@submissions": form.stats.submissions, + "number@views": form.stats.views, + "text@formId": formId + } + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/001/utils/index.ts b/packages/migrations/src/migrations/5.40.0/001/utils/index.ts new file mode 100644 index 00000000000..5ec7db59727 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/001/utils/index.ts @@ -0,0 +1,9 @@ +export * from "./getCompressedData"; +export * from "./getDdbEsFormCommonFields"; +export * from "./getMetaFields"; +export * from "./getFormCommonFields"; +export * from "./getEntryStatus"; +export * from "./getFirstLastPublishedOn"; +export * from "./getOldestRevisionCreatedOn"; +export * from "./getStatsCommonFields"; +export * from "./getFormStatsMetaFields"; diff --git a/packages/migrations/src/migrations/5.40.0/002/ddb-es/FormSubmissionsMigration.ts b/packages/migrations/src/migrations/5.40.0/002/ddb-es/FormSubmissionsMigration.ts new file mode 100644 index 00000000000..ee3dd5b4f48 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/ddb-es/FormSubmissionsMigration.ts @@ -0,0 +1,402 @@ +import chunk from "lodash/chunk"; +import { DataMigration, DataMigrationContext } from "@webiny/data-migration"; +import { Client } from "@elastic/elasticsearch"; +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { + batchWriteAll, + esCreateIndex, + esFindOne, + esGetIndexExist, + esGetIndexName, + esGetIndexSettings, + esPutIndexSettings, + esQueryAllWithCallback, + forEachTenantLocale, + queryOne +} from "~/utils"; +import { CmsEntryWithMeta, FbForm, FbSubmission } from "../types"; +import { createDdbCmsEntity, createDdbEsCmsEntity } from "../entities"; +import { + getCompressedData, + getFormSubmissionMetaFields, + getDdbEsFormSubmissionCommonFields +} from "../utils"; +import { executeWithRetry } from "@webiny/utils"; +import { PrimitiveValue } from "@webiny/api-elasticsearch/types"; + +const isGroupMigrationCompleted = ( + status: PrimitiveValue[] | boolean | undefined +): status is boolean => { + return typeof status === "boolean"; +}; + +type FormSubmissionsDataMigrationCheckpoint = Record< + string, + PrimitiveValue[] | boolean | undefined +>; + +export class FormBuilder_5_40_0_002_FormSubmissions + implements DataMigration +{ + private readonly table: Table; + private readonly esClient: Client; + private readonly ddbCmsEntity: ReturnType; + private readonly ddbEsCmsEntity: ReturnType; + + constructor( + table: Table, + esTable: Table, + esClient: Client + ) { + this.table = table; + this.esClient = esClient; + this.ddbCmsEntity = createDdbCmsEntity(table); + this.ddbEsCmsEntity = createDdbEsCmsEntity(esTable); + } + + getId(): string { + return "Form Submissions Entries"; + } + + getDescription(): string { + return ""; + } + + async shouldExecute({ logger, checkpoint }: DataMigrationContext): Promise { + if (checkpoint) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form submissions for ${tenantId} - ${localeCode}.`); + + const indexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const indexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...indexNameParams + }); + + if (!indexExists) { + logger.info( + `No Elasticsearch index found for forms in tenant "${tenantId}" and locale "${localeCode}"; skipping.` + ); + shouldExecute = false; + return true; + } + + // Fetch latest form submission from ES + const formSubmission = await esFindOne({ + elasticsearchClient: this.esClient, + index: esGetIndexName(indexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.submission" } } + ] + } + }, + sort: [ + { + "id.keyword": { order: "asc", unmapped_type: "keyword" } + } + ] + } + }); + + if (!formSubmission) { + logger.trace( + `No form submissions found in tenant "${tenantId}" and locale "${localeCode}".` + ); + + shouldExecute = false; + return true; + } + + // Fetch HCMS submission records from DDB using latest submission "id" + const cmsSubmission = await queryOne({ + entity: this.ddbCmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#${formSubmission.id}`, + options: { + eq: "L" + } + }); + + if (!cmsSubmission) { + logger.trace( + `Form submissions found for tenant "${tenantId}" and locale "${localeCode}": need migration!.` + ); + shouldExecute = true; + return false; + } + + // Continue to the next locale. + logger.info( + `Form submissions already migrated for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + }); + + return shouldExecute; + } + + async execute({ + logger, + ...context + }: DataMigrationContext): Promise { + const migrationStatus = context.checkpoint || {}; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Migrating form submissions for ${tenantId} - ${localeCode}.`); + + const groupId = `${tenantId}:${localeCode}`; + const status = migrationStatus[groupId]; + + if (isGroupMigrationCompleted(status)) { + logger.info( + `Migration completed ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + let batch = 0; + + const formBuilderIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "form-builder", + isHeadlessCmsModel: false + }; + + const fbFormSubmissionsHcmsIndexNameParams = { + tenant: tenantId, + locale: localeCode, + type: "fbsubmission", + isHeadlessCmsModel: true + }; + + const formIndexExists = await esGetIndexExist({ + elasticsearchClient: this.esClient, + ...formBuilderIndexNameParams + }); + + if (!formIndexExists) { + logger.info( + `No form-builder index found for ${tenantId} - ${localeCode}: skipping migration.` + ); + return true; + } + + // Since it might be the first time we add a HCMS form submission record, we also need to create the index + const fbFormSubmissionsHcmsIndex = await esCreateIndex({ + elasticsearchClient: this.esClient, + ...fbFormSubmissionsHcmsIndexNameParams + }); + + // Saving HCMS forms submissions index settings, we are going to reset them and save the original ones later + const settings = await esGetIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormSubmissionsHcmsIndex, + fields: ["number_of_replicas", "refresh_interval"] + }); + + logger.trace( + `Replacing existing settings with default from "${fbFormSubmissionsHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormSubmissionsHcmsIndex, + settings: { + number_of_replicas: 0, + refresh_interval: -1 + } + }); + + try { + await esQueryAllWithCallback({ + elasticsearchClient: this.esClient, + index: esGetIndexName(formBuilderIndexNameParams), + body: { + query: { + bool: { + filter: [ + { term: { "tenant.keyword": tenantId } }, + { term: { "locale.keyword": localeCode } }, + { term: { "__type.keyword": "fb.submission" } } + ] + } + }, + size: 1000, + sort: [ + { + "id.keyword": "asc" + } + ], + search_after: status + }, + onError: error => { + const x = JSON.stringify(error); + if (x.includes("No mapping found")) { + return; + } + throw error; + }, + callback: async (submissions, cursor) => { + batch++; + logger.info( + `Processing batch #${batch} in group ${groupId} (${submissions.length} submissions).` + ); + + const ddbItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + const ddbEsItems: ReturnType< + ReturnType["putBatch"] + >[] = []; + + for (const submission of submissions) { + // Get common fields + const commonFields = getDdbEsFormSubmissionCommonFields(submission); + + // Get the new meta fields + const entryMetaFields = getFormSubmissionMetaFields(submission); + + const ddbRevItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${submission.id}`, + SK: "REV#0001", + TYPE: "cms.entry", + ...commonFields, + ...entryMetaFields + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbRevItem)); + + const ddbLatestItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${submission.id}`, + SK: "L", + TYPE: "cms.entry.l", + ...commonFields, + ...entryMetaFields + }; + + ddbItems.push(this.ddbCmsEntity.putBatch(ddbLatestItem)); + + const ddbEsItem = { + PK: `T#${tenantId}#L#${localeCode}#CMS#CME#${submission.id}`, + SK: "L", + index: fbFormSubmissionsHcmsIndex, + data: await getCompressedData({ + ...commonFields, + ...entryMetaFields, + latest: true, + TYPE: "cms.entry.l", + __type: "cms.entry.l" + }) + }; + + ddbEsItems.push(this.ddbEsCmsEntity.putBatch(ddbEsItem)); + } + + const executeDdb = () => { + return Promise.all( + chunk(ddbItems, 500).map(ddbItemsChunk => { + return batchWriteAll({ + table: this.ddbCmsEntity.table, + items: ddbItemsChunk + }); + }) + ); + }; + + const executeDdbEs = () => { + return Promise.all( + chunk(ddbEsItems, 500).map(ddbEsItemsChunk => { + return batchWriteAll({ + table: this.ddbEsCmsEntity.table, + items: ddbEsItemsChunk + }); + }) + ); + }; + + await executeWithRetry(executeDdb, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + await executeWithRetry(executeDdbEs, { + onFailedAttempt: error => { + logger.error( + `"batchWriteAll ddb + es" attempt #${error.attemptNumber} failed.` + ); + logger.error(error.message); + } + }); + + // Update checkpoint after every batch + migrationStatus[groupId] = cursor; + + // Check if we should store checkpoint and exit. + if (context.runningOutOfTime()) { + await context.createCheckpointAndExit(migrationStatus); + } else { + await context.createCheckpoint(migrationStatus); + } + } + }); + + migrationStatus[groupId] = true; + await context.createCheckpoint(migrationStatus); + + logger.info( + `Migrated form submission entries for ${tenantId} - ${localeCode}.` + ); + } finally { + // Saving back HCMS forms submissions index settings + await esPutIndexSettings({ + elasticsearchClient: this.esClient, + index: fbFormSubmissionsHcmsIndex, + settings: { + number_of_replicas: settings.number_of_replicas || null, + refresh_interval: settings.refresh_interval || null + } + }); + + logger.trace( + `Successfully set back the previously found settings from "${fbFormSubmissionsHcmsIndex}": ${JSON.stringify( + settings + )}` + ); + } + + return true; + } + }); + + logger.info("Updated all form submissions."); + } +} diff --git a/packages/migrations/src/migrations/5.40.0/002/ddb-es/index.ts b/packages/migrations/src/migrations/5.40.0/002/ddb-es/index.ts new file mode 100644 index 00000000000..6b11fa0ec9b --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/ddb-es/index.ts @@ -0,0 +1,62 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { Client } from "@elastic/elasticsearch"; +import { + DataMigration, + DataMigrationContext, + ElasticsearchClientSymbol, + ElasticsearchDynamoTableSymbol, + getChildLogger, + PrimaryDynamoTableSymbol +} from "@webiny/data-migration"; +import { makeInjectable, inject } from "@webiny/ioc"; +import { FormBuilder_5_40_0_002_FormSubmissions } from "~/migrations/5.40.0/002/ddb-es/FormSubmissionsMigration"; +export * from "../types"; + +export class FormBuilder_5_40_0_002 implements DataMigration { + private migrations: DataMigration[]; + + constructor( + table: Table, + esTable: Table, + elasticsearchClient: Client + ) { + this.migrations = [ + new FormBuilder_5_40_0_002_FormSubmissions(table, esTable, elasticsearchClient) + ]; + } + + getId(): string { + return "5.40.0-002"; + } + + getDescription(): string { + return "Upgrade Form Builder (submissions) to use HCMS storage operations."; + } + + async shouldExecute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + return true; + } + } + return false; + } + + async execute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + await migration.execute(childContext); + } + } + } +} + +makeInjectable(FormBuilder_5_40_0_002, [ + inject(PrimaryDynamoTableSymbol), + inject(ElasticsearchDynamoTableSymbol), + inject(ElasticsearchClientSymbol) +]); diff --git a/packages/migrations/src/migrations/5.40.0/002/ddb/FormSubmissionsMigration.ts b/packages/migrations/src/migrations/5.40.0/002/ddb/FormSubmissionsMigration.ts new file mode 100644 index 00000000000..0b18e5ce43d --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/ddb/FormSubmissionsMigration.ts @@ -0,0 +1,232 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { inject, makeInjectable } from "@webiny/ioc"; +import { executeWithRetry } from "@webiny/utils"; +import { + DataMigration, + DataMigrationContext, + PrimaryDynamoTableSymbol +} from "@webiny/data-migration"; +import { createDdbCmsEntity, createFormEntity, createFormSubmissionEntity } from "../entities"; +import { + batchWriteAll, + BatchWriteItem, + ddbQueryAllWithCallback, + ddbScanWithCallback, + forEachTenantLocale, + queryOne +} from "~/utils"; +import { getFormSubmissionCommonFields, getFormSubmissionMetaFields } from "../utils"; +import { CmsEntryWithMeta, FbForm, FbSubmission } from "../types"; + +interface LastEvaluatedKey { + PK: string; + SK: string; +} + +interface FormSubmissionsDataMigrationCheckpoint { + lastEvaluatedKey?: LastEvaluatedKey | boolean; +} + +export class FormBuilder_5_40_0_002_FormSubmissions implements DataMigration { + private readonly formEntity: ReturnType; + private readonly formSubmissionEntity: ReturnType; + private readonly cmsEntity: ReturnType; + private readonly table: Table; + + constructor(table: Table) { + this.table = table; + this.formEntity = createFormEntity(table); + this.formSubmissionEntity = createFormSubmissionEntity(table); + this.cmsEntity = createDdbCmsEntity(table); + } + + getId() { + return "Form Submission Entries"; + } + + getDescription() { + return ""; + } + + async shouldExecute({ logger, checkpoint }: DataMigrationContext): Promise { + if (checkpoint) { + return true; + } + + let shouldExecute = false; + + await forEachTenantLocale({ + table: this.table, + logger, + callback: async ({ tenantId, localeCode }) => { + logger.info(`Checking form submissions for ${tenantId} - ${localeCode}.`); + + await ddbQueryAllWithCallback( + { + entity: this.formEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#F` + }, + async forms => { + for (const form of forms) { + const [formId] = form.id.split("#"); + logger.trace( + `Checking form submissions for form with id: ${formId} (${tenantId} - ${localeCode}).` + ); + + const formSubmission = await queryOne({ + entity: this.formSubmissionEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#FB#FS#${formId}` + }); + + // If no form submission found -> continue with next form + if (!formSubmission) { + logger.trace( + `No form submissions found for form with id: ${formId} (${tenantId} - ${localeCode}).` + ); + continue; + } + + const cmsSubmission = await queryOne({ + entity: this.cmsEntity, + partitionKey: `T#${tenantId}#L#${localeCode}#CMS#CME#CME#${formSubmission.id}`, + options: { + eq: "L" + } + }); + + if (!cmsSubmission) { + logger.trace( + `Form submissions found for form with id: ${formId} (${tenantId} - ${localeCode}): need migration!.` + ); + shouldExecute = true; + continue; + } + + logger.trace( + `Form submissions already migrated for form with id: ${formId} (${tenantId} - ${localeCode}).` + ); + } + } + ); + + // Let's stop it if previous locale iteration found submissions to migrate. + if (shouldExecute) { + logger.info( + `Form submissions found for ${tenantId} - ${localeCode}: executing migration.` + ); + } else { + logger.info( + `No form submissions found for ${tenantId} - ${localeCode}: skipping migration.` + ); + } + + return !shouldExecute; + } + }); + + return shouldExecute; + } + + async execute({ + logger, + ...context + }: DataMigrationContext): Promise { + const migrationStatus = context.checkpoint || {}; + + if (migrationStatus.lastEvaluatedKey === true) { + logger.info(`Migration completed, no need to start again.`); + return; + } + + let usingKey = ""; + if (migrationStatus?.lastEvaluatedKey) { + usingKey = JSON.stringify(migrationStatus.lastEvaluatedKey); + } + + logger.debug(`Scanning DynamoDB table... ${usingKey}`); + + await ddbScanWithCallback( + { + entity: this.formSubmissionEntity, + options: { + filters: [ + { + attr: "TYPE", + beginsWith: "fb.formSubmission" + } + ], + startKey: migrationStatus.lastEvaluatedKey || undefined, + limit: 1000 + } + }, + async result => { + logger.info(`Migrating form submissions: processing ${result.items.length} items.`); + const items: BatchWriteItem[] = []; + + for (const item of result.items) { + const { tenant, locale, id } = item; + + // Get common fields + const commonFields = getFormSubmissionCommonFields(item); + + // Get the new meta fields + const entryMetaFields = getFormSubmissionMetaFields(item); + + const revision = { + PK: `T#${tenant}#L#${locale}#CMS#CME#CME#${id}`, + SK: `REV#0001`, + GSI1_PK: `T#${tenant}#L#${locale}#CMS#CME#M#fbSubmission#A`, + GSI1_SK: `${id}#0001`, + TYPE: "cms.entry", + ...commonFields, + ...entryMetaFields + }; + + items.push(this.cmsEntity.putBatch(revision)); + + const latest = { + PK: `T#${tenant}#L#${locale}#CMS#CME#CME#${id}`, + SK: "L", + GSI1_PK: `T#${tenant}#L#${locale}#CMS#CME#M#fbSubmission#L`, + GSI1_SK: `${id}#0001`, + TYPE: "cms.entry.l", + ...commonFields, + ...entryMetaFields + }; + + items.push(this.cmsEntity.putBatch(latest)); + } + + const execute = () => { + return batchWriteAll({ table: this.cmsEntity.table, items }); + }; + + await executeWithRetry(execute, { + onFailedAttempt: error => { + logger.error(`"batchWriteAll" attempt #${error.attemptNumber} failed.`); + logger.error(error.message); + } + }); + + // Update checkpoint after every batch + migrationStatus.lastEvaluatedKey = result.lastEvaluatedKey?.PK + ? (result.lastEvaluatedKey as unknown as LastEvaluatedKey) + : true; + + // Check if we should store checkpoint and exit. + if (context.runningOutOfTime()) { + await context.createCheckpointAndExit(migrationStatus); + } else { + await context.createCheckpoint(migrationStatus); + } + } + ); + + migrationStatus.lastEvaluatedKey = true; + context.createCheckpoint(migrationStatus); + + logger.info("Updated all form submissions."); + } +} + +makeInjectable(FormBuilder_5_40_0_002_FormSubmissions, [inject(PrimaryDynamoTableSymbol)]); diff --git a/packages/migrations/src/migrations/5.40.0/002/ddb/index.ts b/packages/migrations/src/migrations/5.40.0/002/ddb/index.ts new file mode 100644 index 00000000000..fe6034b8c84 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/ddb/index.ts @@ -0,0 +1,48 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { + DataMigration, + DataMigrationContext, + getChildLogger, + PrimaryDynamoTableSymbol +} from "@webiny/data-migration"; +import { makeInjectable, inject } from "@webiny/ioc"; +import { FormBuilder_5_40_0_002_FormSubmissions } from "~/migrations/5.40.0/002/ddb/FormSubmissionsMigration"; + +export class FormBuilder_5_40_0_002 implements DataMigration { + private migrations: DataMigration[]; + + constructor(table: Table) { + this.migrations = [new FormBuilder_5_40_0_002_FormSubmissions(table)]; + } + + getId(): string { + return "5.40.0-002"; + } + + getDescription(): string { + return "Upgrade Form Builder (submissions) to use HCMS storage operations."; + } + + async shouldExecute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + return true; + } + } + return false; + } + + async execute(context: DataMigrationContext): Promise { + for (const migration of this.migrations) { + const childLogger = getChildLogger(context.logger, migration); + const childContext = { ...context, logger: childLogger }; + if (await migration.shouldExecute(childContext)) { + await migration.execute(childContext); + } + } + } +} + +makeInjectable(FormBuilder_5_40_0_002, [inject(PrimaryDynamoTableSymbol)]); diff --git a/packages/migrations/src/migrations/5.40.0/002/entities/createCmsEntity.ts b/packages/migrations/src/migrations/5.40.0/002/entities/createCmsEntity.ts new file mode 100644 index 00000000000..4503cbca026 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/entities/createCmsEntity.ts @@ -0,0 +1,112 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createLegacyEntity, createStandardEntity } from "~/utils"; + +const cmsAttributes: Parameters[2] = { + PK: { + type: "string", + partitionKey: true + }, + SK: { + type: "string", + sortKey: true + }, + GSI1_PK: { + type: "string" + }, + GSI1_SK: { + type: "string" + }, + TYPE: { + type: "string" + }, + __type: { + type: "string" + }, + webinyVersion: { + type: "string" + }, + tenant: { + type: "string" + }, + entryId: { + type: "string" + }, + id: { + type: "string" + }, + location: { + type: "map" + }, + modelId: { + type: "string" + }, + locale: { + type: "string" + }, + version: { + type: "number" + }, + locked: { + type: "boolean" + }, + status: { + type: "string" + }, + values: { + type: "map" + }, + meta: { + type: "map" + }, + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedOn: { type: "string" }, + revisionSavedOn: { type: "string" }, + revisionModifiedOn: { type: "string" }, + revisionFirstPublishedOn: { type: "string" }, + revisionLastPublishedOn: { type: "string" }, + revisionCreatedBy: { type: "map" }, + revisionSavedBy: { type: "map" }, + revisionModifiedBy: { type: "map" }, + revisionFirstPublishedBy: { type: "map" }, + revisionLastPublishedBy: { type: "map" }, + /** + * Entry-level meta fields. 👇 + */ + createdOn: { type: "string" }, + savedOn: { type: "string" }, + modifiedOn: { type: "string" }, + firstPublishedOn: { type: "string" }, + lastPublishedOn: { type: "string" }, + createdBy: { type: "map" }, + savedBy: { type: "map" }, + modifiedBy: { type: "map" }, + firstPublishedBy: { type: "map" }, + lastPublishedBy: { type: "map" } +}; + +const cmsEsAttributes: Parameters[2] = { + PK: { + type: "string", + partitionKey: true + }, + SK: { + type: "string", + sortKey: true + }, + index: { + type: "string" + }, + data: { + type: "map" + } +}; + +export const createDdbCmsEntity = (table: Table) => { + return createLegacyEntity(table, "CmsEntries", cmsAttributes); +}; + +export const createDdbEsCmsEntity = (table: Table) => { + return createStandardEntity(table, "CmsEntriesElasticsearch", cmsEsAttributes); +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/entities/createFormEntity.ts b/packages/migrations/src/migrations/5.40.0/002/entities/createFormEntity.ts new file mode 100644 index 00000000000..2999aedf4d2 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/entities/createFormEntity.ts @@ -0,0 +1,85 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createLegacyEntity } from "~/utils"; + +export const createFormEntity = (table: Table) => { + return createLegacyEntity(table, "FormBuilderForm", { + PK: { + partitionKey: true + }, + SK: { + sortKey: true + }, + GSI1_PK: { + type: "string" + }, + GSI1_SK: { + type: "string" + }, + TYPE: { + type: "string" + }, + id: { + type: "string" + }, + formId: { + type: "string" + }, + tenant: { + type: "string" + }, + locale: { + type: "string" + }, + createdBy: { + type: "map" + }, + ownedBy: { + type: "map" + }, + savedOn: { + type: "string" + }, + createdOn: { + type: "string" + }, + name: { + type: "string" + }, + slug: { + type: "string" + }, + version: { + type: "number" + }, + locked: { + type: "boolean" + }, + published: { + type: "boolean" + }, + publishedOn: { + type: "string" + }, + status: { + type: "string" + }, + fields: { + type: "list" + }, + steps: { + type: "list" + }, + stats: { + type: "map" + }, + settings: { + type: "map" + }, + triggers: { + type: "map" + }, + webinyVersion: { + type: "string" + } + }); +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/entities/createFormSubmissionEntity.ts b/packages/migrations/src/migrations/5.40.0/002/entities/createFormSubmissionEntity.ts new file mode 100644 index 00000000000..f0d93761244 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/entities/createFormSubmissionEntity.ts @@ -0,0 +1,49 @@ +import { Table } from "@webiny/db-dynamodb/toolbox"; +import { createLegacyEntity } from "~/utils"; + +export const createFormSubmissionEntity = (table: Table) => { + return createLegacyEntity(table, "FormBuilderSubmission", { + PK: { + partitionKey: true + }, + SK: { + sortKey: true + }, + id: { + type: "string" + }, + TYPE: { + type: "string" + }, + data: { + type: "map" + }, + meta: { + type: "map" + }, + form: { + type: "map" + }, + logs: { + type: "list" + }, + createdOn: { + type: "string" + }, + savedOn: { + type: "string" + }, + ownedBy: { + type: "map" + }, + tenant: { + type: "string" + }, + locale: { + type: "string" + }, + webinyVersion: { + type: "string" + } + }); +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/entities/index.ts b/packages/migrations/src/migrations/5.40.0/002/entities/index.ts new file mode 100644 index 00000000000..05bcfd4e2e3 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/entities/index.ts @@ -0,0 +1,3 @@ +export * from "./createCmsEntity"; +export * from "./createFormEntity"; +export * from "./createFormSubmissionEntity"; diff --git a/packages/migrations/src/migrations/5.40.0/002/types.ts b/packages/migrations/src/migrations/5.40.0/002/types.ts new file mode 100644 index 00000000000..f7bbe2a3ec2 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/types.ts @@ -0,0 +1,237 @@ +// General +export interface Identity { + id: string; + displayName: string | null; + type: string; +} + +export enum Status { + PUBLISHED = "published", + UNPUBLISHED = "unpublished", + DRAFT = "draft" +} + +// Forms - 5.38.0 +export interface FbFormFieldOption { + label?: string; + value?: string; +} + +export interface FbFormField { + _id: string; + fieldId: string; + type: string; + name: string; + label: string; + placeholderText: string | null; + helpText: string | null; + options: FbFormFieldOption[]; + validation: FbFormFieldValidator[]; + settings: JSON; +} + +export type FbFormLayout = Array>; + +interface FbFormStep { + title: string; + layout: FbFormLayout; +} + +interface FbFormFieldValidatorSettings { + /** + * In. + */ + values?: string[]; + /** + * gte, lte, max, min + */ + value?: string; + /** + * Pattern. + */ + preset?: string; + [key: string]: any; +} + +interface FbFormFieldValidator { + name: string; + message: any; + settings: FbFormFieldValidatorSettings; +} + +export interface FbFormStats { + submissions: number; + views: number; +} + +export interface FbFormSettings { + fullWidthSubmitButton: boolean | null; + successMessage: JSON[] | null; + submitButtonLabel: string | null; + layout: { + renderer: string | null; + } | null; + reCaptcha: { + enabled: boolean | null; + errorMessage: string | null; + }; + termsOfServiceMessage: { + enabled: boolean | null; + errorMessage: string | null; + message: JSON[] | null; + } | null; +} + +export interface FbForm { + id: string; + tenant: string; + locale: string; + createdBy: Identity; + ownedBy: Identity; + savedOn: string; + createdOn: string; + name: string; + slug: string; + version: number; + locked: boolean; + published: boolean; + publishedOn: string | null; + status: Status; + fields: FbFormField[]; + steps: FbFormStep[]; + stats: FbFormStats; + settings: FbFormSettings; + triggers: Record | null; + formId: string; + webinyVersion: string; +} + +export interface FbSubmission { + id: string; + locale: string; + ownedBy: Identity; + data: Record; + meta: { + ip: string; + submittedOn: string; + url: { + location: string; + query: JSON; + }; + }; + form: { + id: string; + parent: string; + name: string; + version: number; + fields: FbFormField[]; + layout: string[][]; + steps: FbFormStep[]; + }; + logs: Record[]; + createdOn: string; + savedOn: string; + webinyVersion: string; + tenant: string; +} + +// CMS Entries / Forms - 5.40.0 +export interface CmsEntryValues { + [key: string]: any; +} + +export interface MetaFields { + /** + * Entry-level meta fields. 👇 + */ + createdOn: string; + savedOn: string; + modifiedOn: string | null; + firstPublishedOn: string | null; + lastPublishedOn: string | null; + createdBy: Identity; + savedBy: Identity; + modifiedBy: Identity | null; + firstPublishedBy: Identity | null; + lastPublishedBy: Identity | null; + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedOn: string; + revisionSavedOn: string; + revisionModifiedOn: string | null; + revisionFirstPublishedOn: string | null; + revisionLastPublishedOn: string | null; + revisionCreatedBy: Identity; + revisionSavedBy: Identity; + revisionModifiedBy: Identity | null; + revisionFirstPublishedBy: Identity | null; + revisionLastPublishedBy: Identity | null; +} + +export interface CmsEntry { + webinyVersion: string; + tenant: string; + entryId: string; + id: string; + modelId: string; + locale: string; + location: { + folderId: string; + }; + version: number; + locked: boolean; + status: Status; + values: T; + meta?: { + [key: string]: any; + }; +} + +export interface CmsEntryWithMeta extends CmsEntry, MetaFields {} + +export interface FormEntryCommonField { + "json@settings": JSON | null; + "object@options": Array<{ + "text@label"?: string; + "text@value"?: string; + }> | null; + "object@validation": { + "json@settings": FbFormFieldValidatorSettings; + "text@message": any; + "text@name": string; + }[]; + "text@fieldId": string; + "text@helpText": string | null; + "text@label": string; + "text@name": string; + "text@placeholderText": string | null; + "text@type": string; + "text@_id": string; +} + +export interface FormEntryCommonSteps { + "json@layout": FbFormLayout; + "text@title": string; +} + +export interface FormSubmissionValues { + "json@data": Record; + "json@logs": Record[]; + "object@form": { + "object@fields": FormEntryCommonField[]; + "object@steps": FormEntryCommonSteps[]; + "text@id": string; + "text@name": string; + "text@parent": string; + "text@version": number; + }; + "object@meta": { + "datetime@submittedOn": string; + "object@url": { + "json@query": JSON; + "text@location": string; + }; + "text@ip": string; + }; +} diff --git a/packages/migrations/src/migrations/5.40.0/002/utils/getCompressedData.ts b/packages/migrations/src/migrations/5.40.0/002/utils/getCompressedData.ts new file mode 100644 index 00000000000..31f77e45314 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/utils/getCompressedData.ts @@ -0,0 +1,13 @@ +import { compress as gzip } from "@webiny/utils/compression/gzip"; + +const GZIP = "gzip"; +const TO_STORAGE_ENCODING = "base64"; + +export const getCompressedData = async (data: any) => { + const value = await gzip(JSON.stringify(data)); + + return { + compression: GZIP, + value: value.toString(TO_STORAGE_ENCODING) + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/utils/getDdbEsFormSubmissionCommonFields.ts b/packages/migrations/src/migrations/5.40.0/002/utils/getDdbEsFormSubmissionCommonFields.ts new file mode 100644 index 00000000000..325b0e06b54 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/utils/getDdbEsFormSubmissionCommonFields.ts @@ -0,0 +1,61 @@ +import { CmsEntry, FbSubmission, FormSubmissionValues, Status } from "../types"; + +export const getDdbEsFormSubmissionCommonFields = ( + submission: FbSubmission +): CmsEntry => { + return { + entryId: submission.id, + id: `${submission.id}#0001`, + locale: submission.locale, + locked: false, + location: { + folderId: "root" + }, + modelId: "fbSubmission", + status: Status.DRAFT, + tenant: submission.tenant, + webinyVersion: submission.webinyVersion, + version: 1, + values: { + "json@data": submission.data, + "json@logs": submission.logs ?? [], + "object@form": { + "object@fields": submission.form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText ?? null, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText ?? null, + "text@type": field.type, + "text@_id": field._id + })), + "object@steps": submission.form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@id": submission.form.id, + "text@name": submission.form.name, + "text@parent": submission.form.parent, + "text@version": submission.form.version + }, + "object@meta": { + "text@ip": submission.meta.ip, + "datetime@submittedOn": submission.meta.submittedOn, + "object@url": { + "json@query": submission.meta.url.query, + "text@location": submission.meta.url.location + } + } + } + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionCommonFields.ts b/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionCommonFields.ts new file mode 100644 index 00000000000..99a5b3a322c --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionCommonFields.ts @@ -0,0 +1,66 @@ +import { + CmsEntry, + FbSubmission, + FormSubmissionValues, + Status +} from "~/migrations/5.40.0/002/types"; + +export const getFormSubmissionCommonFields = ( + submission: FbSubmission +): CmsEntry => { + return { + entryId: submission.id, + id: submission.id, + locale: submission.locale, + locked: false, + location: { + folderId: "root" + }, + modelId: "fbSubmission", + status: Status.DRAFT, + tenant: submission.tenant, + webinyVersion: submission.webinyVersion, + version: 1, + values: { + "json@data": submission.data, + "json@logs": submission.logs ?? [], + "object@form": { + "object@fields": submission.form.fields.map(field => ({ + "json@settings": field.settings, + "object@options": field.options.map(option => ({ + "text@label": option.label, + "text@value": option.value + })), + "object@validation": field.validation.map(v => ({ + "text@message": v.message, + "text@name": v.name, + "json@settings": v.settings + })), + "text@fieldId": field.fieldId, + "text@helpText": field.helpText ?? null, + "text@label": field.label, + "text@name": field.name, + "text@placeholderText": field.placeholderText ?? null, + "text@type": field.type, + "text@_id": field._id + })), + "object@steps": submission.form.steps.map(step => ({ + "json@layout": step.layout, + "text@title": step.title + })), + "text@id": submission.form.id, + "text@name": submission.form.name, + "text@parent": submission.form.parent, + "text@version": submission.form.version + }, + "object@meta": { + "text@ip": submission.meta.ip, + "datetime@submittedOn": submission.meta.submittedOn, + "object@url": { + "json@query": submission.meta.url.query, + "text@location": submission.meta.url.location + } + } + } + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionMetaFields.ts b/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionMetaFields.ts new file mode 100644 index 00000000000..82a5b73fb49 --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/utils/getFormSubmissionMetaFields.ts @@ -0,0 +1,21 @@ +import { FbSubmission } from "../types"; + +export const getFormSubmissionMetaFields = (submission: FbSubmission) => { + return { + /** + * Entry-level meta fields. 👇 + */ + createdBy: submission.ownedBy, + createdOn: submission.createdOn, + savedBy: submission.ownedBy, + savedOn: submission.savedOn, + + /** + * Revision-level meta fields. 👇 + */ + revisionCreatedBy: submission.ownedBy, + revisionCreatedOn: submission.createdOn, + revisionSavedBy: submission.ownedBy, + revisionSavedOn: submission.savedOn + }; +}; diff --git a/packages/migrations/src/migrations/5.40.0/002/utils/index.ts b/packages/migrations/src/migrations/5.40.0/002/utils/index.ts new file mode 100644 index 00000000000..cbbab06664f --- /dev/null +++ b/packages/migrations/src/migrations/5.40.0/002/utils/index.ts @@ -0,0 +1,4 @@ +export * from "./getCompressedData"; +export * from "./getDdbEsFormSubmissionCommonFields"; +export * from "./getFormSubmissionCommonFields"; +export * from "./getFormSubmissionMetaFields";