@sealcode/sealgen 0.18.10 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.xunit +74 -69
- package/@types/add-crud.d.sync-conflict-20250918-184311-TFDLWFG.ts +1 -0
- package/@types/builders/colors-builder.d.sync-conflict-20250918-184323-TFDLWFG.ts +10 -0
- package/@types/builders/colors-builder.d.ts +1 -1
- package/@types/builders/fonts-builder.d.sync-conflict-20250918-184322-TFDLWFG.ts +7 -0
- package/@types/builders/fonts-builder.d.ts +1 -1
- package/@types/controllers/table-add-button.d.ts +6 -0
- package/@types/controllers/table-add-button.stimulus.d.ts +6 -0
- package/@types/crud-field-snippets.d.sync-conflict-20250918-184323-TFDLWFG.ts +1 -0
- package/@types/crud-field-snippets.d.ts +1 -3
- package/@types/forms/controls/array.d.sync-conflict-20250918-184306-TFDLWFG.ts +33 -0
- package/@types/forms/controls/array.d.ts +1 -3
- package/@types/forms/controls/array.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
- package/@types/forms/controls/autocomplete.d.sync-conflict-20250918-222042-TFDLWFG.ts +22 -0
- package/@types/forms/controls/autocomplete.d.ts +1 -1
- package/@types/forms/controls/checkbox-group.d.sync-conflict-20250918-184319-TFDLWFG.ts +21 -0
- package/@types/forms/controls/checkbox-group.d.ts +3 -3
- package/@types/forms/controls/checkboxed-list-input.d.sync-conflict-20250918-184323-TFDLWFG.ts +21 -0
- package/@types/forms/controls/checkboxed-list-input.d.ts +3 -3
- package/@types/forms/controls/controls.d.ts +2 -2
- package/@types/forms/controls/derived-frame.d.sync-conflict-20250918-184314-TFDLWFG.ts +19 -0
- package/@types/forms/controls/derived-frame.d.ts +0 -2
- package/@types/forms/controls/dropdown.d.sync-conflict-20250918-222044-TFDLWFG.ts +30 -0
- package/@types/forms/controls/dropdown.d.ts +1 -1
- package/@types/forms/controls/file.d.sync-conflict-20250918-222045-TFDLWFG.ts +13 -0
- package/@types/forms/controls/file.d.ts +1 -2
- package/@types/forms/controls/form-control.d.sync-conflict-20250918-184322-TFDLWFG.ts +19 -0
- package/@types/forms/controls/form-control.d.sync-conflict-20250918-222046-TFDLWFG.ts +19 -0
- package/@types/forms/controls/form-control.d.ts +7 -4
- package/@types/forms/controls/image.d.ts +19 -0
- package/@types/forms/controls/image.test.d.ts +1 -0
- package/@types/forms/controls/multiple-files.d.sync-conflict-20250918-184318-TFDLWFG.ts +42 -0
- package/@types/forms/controls/multiple-files.d.ts +3 -1
- package/@types/forms/controls/multiple-images.d.ts +19 -0
- package/@types/forms/controls/number.d.sync-conflict-20250918-222046-TFDLWFG.ts +13 -0
- package/@types/forms/controls/number.d.ts +1 -1
- package/@types/forms/controls/photo.d.sync-conflict-20250918-184321-TFDLWFG.ts +19 -0
- package/@types/forms/controls/photo.d.ts +3 -5
- package/@types/forms/controls/simple-input.d.sync-conflict-20250918-184310-TFDLWFG.ts +33 -0
- package/@types/forms/controls/simple-input.d.sync-conflict-20250918-222042-TFDLWFG.ts +33 -0
- package/@types/forms/controls/simple-input.d.ts +5 -4
- package/@types/forms/controls/simple-input.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
- package/@types/forms/controls/single-reference.d.ts +3 -2
- package/@types/forms/controls/table.d.sync-conflict-20250918-184302-TFDLWFG.ts +39 -0
- package/@types/forms/controls/table.d.ts +8 -3
- package/@types/forms/controls/table.sync-conflict-20250918-222042-TFDLWFG.d.ts +39 -0
- package/@types/forms/controls/textarea.d.sync-conflict-20250918-222045-TFDLWFG.ts +25 -0
- package/@types/forms/controls/textarea.d.ts +3 -3
- package/@types/forms/fields/boolean.d.sync-conflict-20250918-184325-TFDLWFG.ts +22 -0
- package/@types/forms/fields/boolean.d.ts +6 -1
- package/@types/forms/fields/boolean.sync-conflict-20250918-222042-TFDLWFG.d.ts +22 -0
- package/@types/forms/fields/checkboxed-list.d.sync-conflict-20250918-184325-TFDLWFG.ts +23 -0
- package/@types/forms/fields/checkboxed-list.d.ts +3 -1
- package/@types/forms/fields/collection-field.d.sync-conflict-20250918-184319-TFDLWFG.ts +22 -0
- package/@types/forms/fields/collection-field.d.sync-conflict-20250918-222047-TFDLWFG.ts +22 -0
- package/@types/forms/fields/collection-field.d.ts +8 -1
- package/@types/forms/fields/color.d.ts +4 -0
- package/@types/forms/fields/coordinates.d.sync-conflict-20250918-222044-TFDLWFG.ts +14 -0
- package/@types/forms/fields/coordinates.d.ts +14 -0
- package/@types/forms/fields/date.d.ts +13 -0
- package/@types/forms/fields/datetime.d.sync-conflict-20250918-222050-TFDLWFG.ts +4 -0
- package/@types/forms/fields/datetime.d.ts +14 -0
- package/@types/forms/fields/deep-reverse-single-reference-list.d.ts +20 -0
- package/@types/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
- package/@types/forms/fields/email.d.sync-conflict-20250918-184303-TFDLWFG.ts +8 -0
- package/@types/forms/fields/email.d.ts +3 -0
- package/@types/forms/fields/enum-multiple-sealious.d.ts +16 -0
- package/@types/forms/fields/enum-multiple-sealious.sync-conflict-20250918-222047-TFDLWFG.d.ts +16 -0
- package/@types/forms/fields/field.d.sync-conflict-20250918-184306-TFDLWFG.ts +70 -0
- package/@types/forms/fields/field.d.ts +37 -5
- package/@types/forms/fields/fields.d.sync-conflict-20250918-184314-TFDLWFG.ts +29 -0
- package/@types/forms/fields/fields.d.ts +23 -8
- package/@types/forms/fields/file.d.sync-conflict-20250918-184310-TFDLWFG.ts +23 -0
- package/@types/forms/fields/file.d.sync-conflict-20250918-222046-TFDLWFG.ts +23 -0
- package/@types/forms/fields/file.d.ts +11 -5
- package/@types/forms/fields/file.sync-conflict-20250918-222049-TFDLWFG.d.ts +23 -0
- package/@types/forms/fields/float.d.ts +4 -0
- package/@types/forms/fields/get-field-for-sealious.d.sync-conflict-20250918-222046-TFDLWFG.ts +29 -0
- package/@types/forms/fields/get-field-for-sealious.d.ts +31 -0
- package/@types/forms/fields/get-field-for-sealious.sync-conflict-20250918-222042-TFDLWFG.d.ts +29 -0
- package/@types/forms/fields/html.d.ts +6 -0
- package/@types/forms/fields/image.d.sync-conflict-20250918-222042-TFDLWFG.ts +5 -0
- package/@types/forms/fields/image.d.ts +5 -0
- package/@types/forms/fields/int.d.ts +6 -0
- package/@types/forms/fields/json.d.ts +13 -0
- package/@types/forms/fields/markdown.d.ts +6 -0
- package/@types/forms/fields/multiple-files.d.sync-conflict-20250918-184304-TFDLWFG.ts +16 -0
- package/@types/forms/fields/multiple-files.d.ts +3 -1
- package/@types/forms/fields/number.d.sync-conflict-20250918-184317-TFDLWFG.ts +25 -0
- package/@types/forms/fields/number.d.sync-conflict-20250918-222047-TFDLWFG.ts +25 -0
- package/@types/forms/fields/number.d.ts +3 -1
- package/@types/forms/fields/password.d.ts +5 -0
- package/@types/forms/fields/pick-from-list-sealious.d.ts +11 -0
- package/@types/forms/fields/pick-from-list.d.sync-conflict-20250918-184322-TFDLWFG.ts +15 -0
- package/@types/forms/fields/pick-from-list.d.ts +4 -3
- package/@types/forms/fields/proxy-field.d.sync-conflict-20250918-184307-TFDLWFG.ts +15 -0
- package/@types/forms/fields/proxy-field.d.ts +3 -1
- package/@types/forms/fields/regexp.d.sync-conflict-20250918-184305-TFDLWFG.ts +21 -0
- package/@types/forms/fields/regexp.d.sync-conflict-20250918-222045-TFDLWFG.ts +21 -0
- package/@types/forms/fields/regexp.d.ts +6 -1
- package/@types/forms/fields/regexp.sync-conflict-20250918-222047-TFDLWFG.d.ts +21 -0
- package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-184309-TFDLWFG.ts +29 -0
- package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-222044-TFDLWFG.ts +29 -0
- package/@types/forms/fields/simple-form-field.d.ts +23 -3
- package/@types/forms/fields/simple-form-field.sync-conflict-20250918-222049-TFDLWFG.d.ts +29 -0
- package/@types/forms/fields/single-reference.d.ts +19 -0
- package/@types/forms/fields/single-reference.sync-conflict-20250918-222043-TFDLWFG.d.ts +10 -0
- package/@types/forms/fields/structured-array.d.sync-conflict-20250918-184302-TFDLWFG.ts +27 -0
- package/@types/forms/fields/structured-array.d.sync-conflict-20250918-222049-TFDLWFG.ts +27 -0
- package/@types/forms/fields/structured-array.d.ts +19 -10
- package/@types/forms/fields/structured-array.sync-conflict-20250918-222047-TFDLWFG.d.ts +27 -0
- package/@types/forms/fields/table.d.sync-conflict-20250918-184303-TFDLWFG.ts +16 -0
- package/@types/forms/fields/table.d.ts +3 -0
- package/@types/forms/fields/text.d.ts +6 -0
- package/@types/forms/fields/url.d.ts +6 -0
- package/@types/forms/form-types.d.sync-conflict-20250918-222045-TFDLWFG.ts +26 -0
- package/@types/forms/form-types.d.ts +2 -0
- package/@types/forms/form.d.sync-conflict-20250918-184315-TFDLWFG.ts +32 -0
- package/@types/forms/form.d.sync-conflict-20250918-222049-TFDLWFG.ts +32 -0
- package/@types/forms/form.d.ts +10 -8
- package/@types/forms/form.sync-conflict-20250918-222049-TFDLWFG.d.ts +33 -0
- package/@types/forms/form.test.d.sync-conflict-20250918-184318-TFDLWFG.ts +6 -0
- package/@types/forms/form.test.d.sync-conflict-20250918-222047-TFDLWFG.ts +6 -0
- package/@types/forms/form.test.d.ts +2 -2
- package/@types/forms/multiform.d.sync-conflict-20250918-184308-TFDLWFG.ts +23 -0
- package/@types/forms/multiform.d.ts +1 -2
- package/@types/forms/multiform.sync-conflict-20250918-222044-TFDLWFG.d.ts +23 -0
- package/@types/index.d.sync-conflict-20250918-184316-TFDLWFG.ts +46 -0
- package/@types/index.d.ts +2 -2
- package/@types/mount.d.sync-conflict-20250918-184320-TFDLWFG.ts +6 -0
- package/@types/mount.d.ts +0 -1
- package/@types/page/list.d.sync-conflict-20250918-184318-TFDLWFG.ts +48 -0
- package/@types/page/list.d.sync-conflict-20250918-222046-TFDLWFG.ts +48 -0
- package/@types/page/list.d.ts +2 -2
- package/@types/page/list.sync-conflict-20250918-222048-TFDLWFG.d.ts +48 -0
- package/@types/page/mountable-with-fields.d.sync-conflict-20250918-184321-TFDLWFG.ts +42 -0
- package/@types/page/mountable-with-fields.d.sync-conflict-20250918-222046-TFDLWFG.ts +42 -0
- package/@types/page/mountable-with-fields.d.ts +3 -3
- package/@types/page/mountable-with-fields.sync-conflict-20250918-222044-TFDLWFG.d.ts +42 -0
- package/@types/page/mountable.d.sync-conflict-20250918-184306-TFDLWFG.ts +10 -0
- package/@types/page/mountable.d.ts +0 -1
- package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +18 -0
- package/@types/page/page.d.ts +0 -1
- package/@types/page/props-parser.d.sync-conflict-20250918-184305-TFDLWFG.ts +15 -0
- package/@types/page/props-parser.d.ts +0 -1
- package/@types/page/stateful-page.d.sync-conflict-20250918-184326-TFDLWFG.ts +62 -0
- package/@types/page/stateful-page.d.ts +0 -1
- package/@types/register-external.d.ts +2 -2
- package/@types/templates/form.d.ts +1 -3
- package/@types/templates/jdd-component.d.ts +1 -1
- package/@types/templates/page.d.ts +1 -1
- package/@types/templates/shared/shared-crud-form-fields.d.sync-conflict-20250918-184306-TFDLWFG.ts +1 -0
- package/@types/templates/shared/shared-crud-form-fields.d.ts +1 -68
- package/@types/templates/templates.d.ts +1 -21
- package/@types/test_utils/test-on-real-app.d.sync-conflict-20250918-184320-TFDLWFG.ts +26 -0
- package/@types/test_utils/test-on-real-app.d.ts +0 -1
- package/@types/utils/extract-fields-from-collection.d.sync-conflict-20250918-184312-TFDLWFG.ts +18 -0
- package/@types/utils/extract-fields-from-collection.d.ts +5 -1
- package/@types/utils/extract-fields-from-collection.sync-conflict-20250918-222045-TFDLWFG.d.ts +18 -0
- package/@types/utils/wrap-attributes.d.ts +3 -0
- package/README.md +5 -0
- package/assets/file-icon.svg +5 -0
- package/eslint.config.mjs +56 -0
- package/lib/add-crud.js +77 -89
- package/lib/add-jdd-component.js +3 -3
- package/lib/add-list-route.test.js +1 -1
- package/lib/add-route.js +2 -9
- package/lib/build.js +6 -4
- package/lib/builders/backend-ts-builder.js +0 -1
- package/lib/builders/colors-builder.js +11 -8
- package/lib/builders/fonts-builder.js +0 -1
- package/lib/builders/frontend-ts-builder.js +0 -1
- package/lib/cli.js +4 -7
- package/lib/components/tabs.js +36 -36
- package/lib/controllers/table-add-button.stimulus.js +35 -0
- package/lib/esbuild-plugins/rewrite-asset-imports.js +7 -10
- package/lib/forms/controls/array.js +25 -22
- package/lib/forms/controls/big-radio-group.js +2 -2
- package/lib/forms/controls/checkbox-group.js +7 -7
- package/lib/forms/controls/checkboxed-list-input.js +7 -1
- package/lib/forms/controls/checkboxed-list-input.test.js +6 -6
- package/lib/forms/controls/controls.js +2 -2
- package/lib/forms/controls/derived-frame.js +8 -4
- package/lib/forms/controls/derived.js +1 -1
- package/lib/forms/controls/dropdown.js +5 -3
- package/lib/forms/controls/editable-collection-subset.js +2 -2
- package/lib/forms/controls/file.js +26 -2
- package/lib/forms/controls/file.test.js +2 -2
- package/lib/forms/controls/form-control.js +1 -1
- package/lib/forms/controls/hidden-input.js +4 -1
- package/lib/forms/controls/{photo.js → image.js} +6 -7
- package/lib/forms/controls/{photo.test.js → image.test.js} +8 -23
- package/lib/forms/controls/multiple-files.js +10 -1
- package/lib/forms/controls/{multiple-photos.js → multiple-images.js} +3 -3
- package/lib/forms/controls/simple-input.js +13 -12
- package/lib/forms/controls/single-reference.js +4 -0
- package/lib/forms/controls/single-reference.test.js +1 -1
- package/lib/forms/controls/table.js +62 -25
- package/lib/forms/controls/textarea.js +5 -3
- package/lib/forms/controls/tickable.js +13 -5
- package/lib/forms/fields/boolean.js +14 -0
- package/lib/forms/fields/checkboxed-list.js +4 -0
- package/lib/forms/fields/collection-field.js +9 -0
- package/lib/forms/fields/color.js +10 -0
- package/lib/forms/fields/coordinates.js +49 -0
- package/lib/forms/fields/date.js +34 -0
- package/lib/forms/fields/datetime.js +46 -0
- package/lib/forms/fields/deep-reverse-single-reference-list.js +81 -0
- package/lib/forms/fields/deep-reverse-single-reference-table.js +122 -0
- package/lib/forms/fields/email.js +7 -0
- package/lib/forms/fields/enum-multiple-sealious.js +32 -0
- package/lib/forms/fields/field.js +32 -4
- package/lib/forms/fields/field.test.js +8 -8
- package/lib/forms/fields/fields.js +23 -8
- package/lib/forms/fields/file.js +33 -9
- package/lib/forms/fields/file.test.js +5 -17
- package/lib/forms/fields/float.js +10 -0
- package/lib/forms/fields/get-field-for-sealious.js +213 -0
- package/lib/forms/fields/html.js +14 -0
- package/lib/forms/fields/image.js +13 -0
- package/lib/forms/fields/int.js +23 -0
- package/lib/forms/fields/json.js +31 -0
- package/lib/forms/fields/markdown.js +14 -0
- package/lib/forms/fields/multiple-files.js +4 -0
- package/lib/forms/fields/number.js +6 -0
- package/lib/forms/fields/password.js +13 -0
- package/lib/forms/fields/pick-from-list-sealious.js +17 -0
- package/lib/forms/fields/pick-from-list.js +6 -2
- package/lib/forms/fields/proxy-field.js +3 -0
- package/lib/forms/fields/regexp.js +14 -0
- package/lib/forms/fields/simple-form-field.js +61 -2
- package/lib/forms/fields/single-reference.js +44 -0
- package/lib/forms/fields/structured-array.js +61 -12
- package/lib/forms/fields/table.js +29 -2
- package/lib/forms/fields/text.js +17 -0
- package/lib/forms/fields/url.js +17 -0
- package/lib/forms/form.js +30 -14
- package/lib/forms/form.test.js +5 -7
- package/lib/forms/multiform.js +10 -9
- package/lib/forms/multiform.test.js +5 -5
- package/lib/generate-collections.js +2 -3
- package/lib/generate-components.js +2 -3
- package/lib/generate-routes.js +3 -5
- package/lib/generate-routes.test.js +7 -16
- package/lib/generate-stimulus.js +4 -4
- package/lib/get-fonts.js +29 -27
- package/lib/index.js +1 -0
- package/lib/make-env.js +1 -1
- package/lib/make-hidden-inputs.js +4 -4
- package/lib/mount.js +11 -1
- package/lib/notifier.js +3 -4
- package/lib/page/list.js +20 -15
- package/lib/page/mountable-with-fields.js +14 -6
- package/lib/page/mountable-with-fields.test.js +1 -1
- package/lib/page/mountable.js +0 -1
- package/lib/page/page.js +0 -1
- package/lib/register-external.js +4 -4
- package/lib/templates/form.js +9 -10
- package/lib/templates/jdd-component.js +1 -1
- package/lib/templates/jdd-editor.js +1 -1
- package/lib/templates/multiform.js +4 -4
- package/lib/templates/page.js +1 -3
- package/lib/templates/shared/collection-create-form.js +31 -44
- package/lib/templates/shared/collection-edit-form.js +43 -81
- package/lib/templates/shared/collection-list.js +13 -21
- package/lib/templates/shared/shared-crud-form-fields.js +28 -98
- package/lib/test_utils/exec_async.js +3 -3
- package/lib/test_utils/test-on-real-app.js +12 -14
- package/lib/utils/extract-fields-from-collection.js +60 -20
- package/lib/utils/make-slug.js +1 -1
- package/lib/utils/wrap-attributes.js +20 -0
- package/lib/utils/write-file.js +1 -1
- package/package.json +11 -9
- package/src/add-collection.ts +1 -3
- package/src/add-crud.ts +84 -100
- package/src/add-jdd-component.ts +4 -5
- package/src/add-list-route.test.ts +1 -1
- package/src/add-route.ts +3 -13
- package/src/build.ts +6 -4
- package/src/builders/backend-ts-builder.ts +0 -1
- package/src/builders/builder.ts +4 -1
- package/src/builders/colors-builder.ts +11 -9
- package/src/builders/css-builder.ts +4 -1
- package/src/builders/fonts-builder.ts +0 -1
- package/src/builders/frontend-ts-builder.ts +0 -1
- package/src/cli.ts +5 -7
- package/src/components/tabs.ts +38 -37
- package/src/components/toggle-modal.ts +1 -1
- package/src/controllers/table-add-button.stimulus.ts +35 -0
- package/src/esbuild-plugins/rewrite-asset-imports.ts +7 -10
- package/src/forms/controls/array.ts +35 -36
- package/src/forms/controls/autocomplete.ts +2 -2
- package/src/forms/controls/big-radio-group.ts +4 -4
- package/src/forms/controls/checkbox-group.ts +10 -10
- package/src/forms/controls/checkboxed-list-input.test.ts +6 -6
- package/src/forms/controls/checkboxed-list-input.ts +16 -8
- package/src/forms/controls/controls.ts +2 -2
- package/src/forms/controls/derived-frame.ts +16 -11
- package/src/forms/controls/derived.ts +7 -6
- package/src/forms/controls/dropdown.ts +13 -13
- package/src/forms/controls/editable-collection-subset.ts +4 -3
- package/src/forms/controls/field-group.ts +1 -1
- package/src/forms/controls/file.test.ts +4 -2
- package/src/forms/controls/file.ts +30 -7
- package/src/forms/controls/form-control.ts +8 -3
- package/src/forms/controls/hidden-input.ts +5 -1
- package/src/forms/controls/html.ts +1 -0
- package/src/forms/controls/{photo.test.ts → image.test.ts} +7 -24
- package/src/forms/controls/{photo.ts → image.ts} +4 -6
- package/src/forms/controls/multiple-files.ts +23 -8
- package/src/forms/controls/{multiple-photos.ts → multiple-images.ts} +2 -2
- package/src/forms/controls/number.ts +1 -1
- package/src/forms/controls/simple-input.ts +21 -33
- package/src/forms/controls/single-reference.test.ts +1 -1
- package/src/forms/controls/single-reference.ts +11 -3
- package/src/forms/controls/table.ts +87 -33
- package/src/forms/controls/textarea.ts +7 -5
- package/src/forms/controls/tickable.ts +13 -7
- package/src/forms/fields/boolean.ts +27 -2
- package/src/forms/fields/checkboxed-list.ts +11 -2
- package/src/forms/fields/collection-field.ts +21 -3
- package/src/forms/fields/color.ts +9 -0
- package/src/forms/fields/coordinates.ts +66 -0
- package/src/forms/fields/date.ts +50 -0
- package/src/forms/fields/datetime.ts +66 -0
- package/src/forms/fields/deep-reverse-single-reference-list.ts +130 -0
- package/src/forms/fields/deep-reverse-single-reference-table.ts +213 -0
- package/src/forms/fields/email.ts +10 -1
- package/src/forms/fields/enum-multiple-sealious.ts +48 -0
- package/src/forms/fields/existing-sealious-value.ts +1 -1
- package/src/forms/fields/field.test.ts +8 -8
- package/src/forms/fields/field.ts +98 -11
- package/src/forms/fields/fields.ts +23 -8
- package/src/forms/fields/file.test.ts +5 -17
- package/src/forms/fields/file.ts +44 -16
- package/src/forms/fields/float.ts +9 -0
- package/src/forms/fields/get-field-for-sealious.ts +337 -0
- package/src/forms/fields/html.ts +15 -0
- package/src/forms/fields/image.ts +12 -0
- package/src/forms/fields/int.ts +25 -0
- package/src/forms/fields/json.ts +48 -0
- package/src/forms/fields/markdown.ts +15 -0
- package/src/forms/fields/multiple-files.ts +10 -1
- package/src/forms/fields/number.ts +10 -3
- package/src/forms/fields/password.ts +13 -0
- package/src/forms/fields/pick-from-list-sealious.ts +22 -0
- package/src/forms/fields/pick-from-list.ts +8 -4
- package/src/forms/fields/proxy-field.ts +7 -1
- package/src/forms/fields/regexp.ts +27 -1
- package/src/forms/fields/simple-form-field.ts +103 -7
- package/src/forms/fields/single-reference.ts +62 -0
- package/src/forms/fields/structured-array.ts +111 -18
- package/src/forms/fields/table.ts +39 -16
- package/src/forms/fields/text.ts +18 -0
- package/src/forms/fields/url.ts +20 -0
- package/src/forms/form-types.ts +5 -4
- package/src/forms/form.test.ts +5 -7
- package/src/forms/form.ts +42 -23
- package/src/forms/forms.css +0 -85
- package/src/forms/multiform.test.ts +9 -9
- package/src/forms/multiform.ts +12 -10
- package/src/generate-collections.ts +2 -3
- package/src/generate-components.ts +2 -3
- package/src/generate-routes.test.ts +7 -16
- package/src/generate-routes.ts +6 -10
- package/src/generate-stimulus.ts +4 -5
- package/src/get-fonts.ts +32 -30
- package/src/index.ts +2 -1
- package/src/make-env.ts +1 -1
- package/src/make-hidden-inputs.ts +8 -7
- package/src/mount.ts +16 -7
- package/src/notifier.ts +4 -7
- package/src/page/default-list-filters.ts +1 -0
- package/src/page/list.ts +33 -28
- package/src/page/mountable-with-fields.test.ts +1 -1
- package/src/page/mountable-with-fields.ts +21 -12
- package/src/page/mountable.ts +0 -1
- package/src/page/page.ts +2 -3
- package/src/page/props-parser.ts +1 -1
- package/src/page/sealious-list.ts +1 -1
- package/src/page/stateful-page.ts +6 -10
- package/src/register-external.ts +5 -5
- package/src/templates/form.ts +9 -11
- package/src/templates/jdd-component.ts +1 -1
- package/src/templates/jdd-editor.ts +2 -4
- package/src/templates/list.ts +0 -1
- package/src/templates/multiform.ts +4 -4
- package/src/templates/page.ts +1 -6
- package/src/templates/shared/collection-create-form.ts +34 -71
- package/src/templates/shared/collection-edit-form.ts +46 -108
- package/src/templates/shared/collection-list.ts +13 -21
- package/src/templates/shared/item-delete.ts +0 -1
- package/src/templates/shared/shared-crud-form-fields.ts +38 -177
- package/src/templates/templates.ts +5 -1
- package/src/test_utils/exec_async.ts +3 -4
- package/src/test_utils/test-on-real-app.ts +13 -14
- package/src/utils/browser-creator.js +0 -1
- package/src/utils/exec.ts +0 -1
- package/src/utils/extract-fields-from-collection.ts +76 -25
- package/src/utils/input-wrapper.ts +1 -1
- package/src/utils/make-slug.ts +1 -1
- package/src/utils/wrap-attributes.ts +17 -0
- package/src/utils/write-file.ts +1 -1
- package/.eslintrc.cjs +0 -39
- package/lib/add-verbose-crud.js +0 -119
- package/lib/crud-field-snippets.js +0 -52
- package/lib/find-css-includes.js +0 -3
- package/lib/forms/controls/reverse-single-reference.js +0 -1
- package/lib/forms/fields/enum-multiple.js +0 -47
- package/lib/forms/fields/enum-multiple.test.js +0 -27
- package/lib/forms/fields/enum.js +0 -41
- package/lib/forms/fields/enum.test.js +0 -21
- package/lib/forms/fields/reverse-single-reference.js +0 -17
- package/lib/templates/shared/handlers/boolean.js +0 -14
- package/lib/templates/shared/handlers/date.js +0 -8
- package/lib/templates/shared/handlers/deep-reverse-single-reference.js +0 -209
- package/lib/templates/shared/handlers/default.js +0 -49
- package/lib/templates/shared/handlers/enum.js +0 -19
- package/lib/templates/shared/handlers/file.js +0 -23
- package/lib/templates/shared/handlers/image.js +0 -32
- package/lib/templates/shared/handlers/int.js +0 -11
- package/lib/templates/shared/handlers/jdd.js +0 -10
- package/lib/templates/shared/handlers/single-reference.js +0 -12
- package/lib/templates/shared/handlers/structured-array.js +0 -33
- package/src/add-verbose-crud.ts +0 -138
- package/src/crud-field-snippets.ts +0 -57
- package/src/find-css-includes.ts +0 -3
- package/src/forms/controls/reverse-single-reference.ts +0 -50
- package/src/forms/fields/enum-multiple.test.ts +0 -31
- package/src/forms/fields/enum-multiple.ts +0 -62
- package/src/forms/fields/enum.test.ts +0 -25
- package/src/forms/fields/enum.ts +0 -56
- package/src/forms/fields/reverse-single-reference.ts +0 -20
- package/src/templates/shared/handlers/boolean.ts +0 -18
- package/src/templates/shared/handlers/date.ts +0 -12
- package/src/templates/shared/handlers/deep-reverse-single-reference.ts +0 -244
- package/src/templates/shared/handlers/default.ts +0 -64
- package/src/templates/shared/handlers/enum.ts +0 -23
- package/src/templates/shared/handlers/file.ts +0 -27
- package/src/templates/shared/handlers/image.ts +0 -45
- package/src/templates/shared/handlers/int.ts +0 -15
- package/src/templates/shared/handlers/jdd.ts +0 -14
- package/src/templates/shared/handlers/single-reference.ts +0 -16
- package/src/templates/shared/handlers/structured-array.ts +0 -42
package/lib/add-verbose-crud.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import _locreq from "locreq";
|
|
2
|
-
import { escape_url_params } from "./utils/escape-url-params.js";
|
|
3
|
-
import prompts from "prompts";
|
|
4
|
-
import { toKebabCase, toPascalCase } from "js-convert-case";
|
|
5
|
-
import { listCollections } from "./utils/list-collections.js";
|
|
6
|
-
import { collectionListTemplate } from "./templates/shared/collection-list.js";
|
|
7
|
-
import { writeFile } from "./utils/write-file.js";
|
|
8
|
-
import { curryImportPath, importPath } from "./utils/import-path.js";
|
|
9
|
-
import { sharedCrudFormFields } from "./templates/shared/shared-crud-form-fields.js";
|
|
10
|
-
import { generateRoutes } from "./generate-routes.js";
|
|
11
|
-
import { createItemFormTemplate } from "./templates/shared/collection-create-form.js";
|
|
12
|
-
import { editItemFormTemplate } from "./templates/shared/collection-edit-form.js";
|
|
13
|
-
import { itemDeleteTemplate } from "./templates/shared/item-delete.js";
|
|
14
|
-
async function addVerboseCRUD(params, app_directory = process.cwd()) {
|
|
15
|
-
const target_locreq = _locreq(app_directory);
|
|
16
|
-
prompts.override(params);
|
|
17
|
-
const response = await prompts([
|
|
18
|
-
{
|
|
19
|
-
type: "autocomplete",
|
|
20
|
-
name: "collection",
|
|
21
|
-
message: "Which sealious collection do you like to add CRUD forms for?",
|
|
22
|
-
choices: (await listCollections()).map((collection) => ({
|
|
23
|
-
title: collection,
|
|
24
|
-
value: collection
|
|
25
|
-
}))
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: "text",
|
|
29
|
-
name: "url",
|
|
30
|
-
message: "Enter a full absolute path for the new route (for example: /admin/users/:id/edit): ",
|
|
31
|
-
validate: (s) => s.trim()[0] == "/" ? true : "Should start with a '/'",
|
|
32
|
-
initial: function(_, { collection }) {
|
|
33
|
-
return "/" + toKebabCase(collection);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]);
|
|
37
|
-
const collection_name = response.collection;
|
|
38
|
-
const url = response.url;
|
|
39
|
-
const list_action_name = toPascalCase(collection_name) + "CRUDList";
|
|
40
|
-
const create_action_name = toPascalCase(collection_name) + "CRUDCreate";
|
|
41
|
-
const edit_action_name = toPascalCase(collection_name) + "CRUDEdit";
|
|
42
|
-
const delete_action_name = toPascalCase(collection_name) + "CRUDDelete";
|
|
43
|
-
const list_path = target_locreq.resolve(
|
|
44
|
-
`src/back/routes/${escape_url_params(url)}/index.list.tsx`
|
|
45
|
-
);
|
|
46
|
-
const list_content = await collectionListTemplate(
|
|
47
|
-
collection_name,
|
|
48
|
-
list_action_name,
|
|
49
|
-
list_path,
|
|
50
|
-
{
|
|
51
|
-
post_import_js: `import { ${create_action_name}URL, ${edit_action_name}URL, ${delete_action_name}URL } from "${importPath(
|
|
52
|
-
list_path,
|
|
53
|
-
"src/back/routes/urls.ts"
|
|
54
|
-
)}";`,
|
|
55
|
-
post_header_html: `<a href={${create_action_name}URL}> Create </a>`,
|
|
56
|
-
render_item: (collection_name2) => ` async renderItem(ctx: Context, item: CollectionItem<typeof ${toPascalCase(
|
|
57
|
-
collection_name2
|
|
58
|
-
)}>) {
|
|
59
|
-
return <tr>
|
|
60
|
-
{displayFields.map(({ field, format }) => {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
|
|
62
|
-
const value = item.get(field as any);
|
|
63
|
-
return <td>{format ? format(value, item) : value}</td>;
|
|
64
|
-
})}
|
|
65
|
-
<td><div class="sealious-list__actions">
|
|
66
|
-
<a href={${edit_action_name}URL(item.id)}>Edit</a>
|
|
67
|
-
<a data-turbo-method="POST" data-turbo-confirm="Delete item?" href={${delete_action_name}URL(item.id)}>Delete</a>
|
|
68
|
-
</div>
|
|
69
|
-
</td>
|
|
70
|
-
</tr>;
|
|
71
|
-
}`
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
await writeFile(list_path, list_content);
|
|
75
|
-
const fields_path = target_locreq.resolve(
|
|
76
|
-
`src/back/routes/${escape_url_params(url)}/shared.ts`
|
|
77
|
-
);
|
|
78
|
-
const fields_content = await sharedCrudFormFields(
|
|
79
|
-
collection_name,
|
|
80
|
-
fields_path
|
|
81
|
-
);
|
|
82
|
-
await writeFile(fields_path, fields_content);
|
|
83
|
-
const create_path = target_locreq.resolve(
|
|
84
|
-
`src/back/routes/${escape_url_params(url)}/create.form.ts`
|
|
85
|
-
);
|
|
86
|
-
const create_content = await createItemFormTemplate(
|
|
87
|
-
create_action_name,
|
|
88
|
-
create_path,
|
|
89
|
-
collection_name,
|
|
90
|
-
list_action_name
|
|
91
|
-
);
|
|
92
|
-
await writeFile(create_path, create_content);
|
|
93
|
-
const edit_path = target_locreq.resolve(
|
|
94
|
-
`src/back/routes/${escape_url_params(url)}/[id]/edit.form.ts`
|
|
95
|
-
);
|
|
96
|
-
const edit_content = await editItemFormTemplate(
|
|
97
|
-
edit_action_name,
|
|
98
|
-
edit_path,
|
|
99
|
-
collection_name,
|
|
100
|
-
list_action_name
|
|
101
|
-
);
|
|
102
|
-
await writeFile(edit_path, edit_content);
|
|
103
|
-
const delete_path = target_locreq.resolve(
|
|
104
|
-
`src/back/routes/${escape_url_params(url)}/[id]/delete.page.tsx`
|
|
105
|
-
);
|
|
106
|
-
const base_import_path = curryImportPath(delete_path);
|
|
107
|
-
const delete_content = await itemDeleteTemplate(
|
|
108
|
-
delete_action_name,
|
|
109
|
-
collection_name,
|
|
110
|
-
list_action_name,
|
|
111
|
-
base_import_path
|
|
112
|
-
);
|
|
113
|
-
await writeFile(delete_path, delete_content);
|
|
114
|
-
await generateRoutes();
|
|
115
|
-
}
|
|
116
|
-
export {
|
|
117
|
-
addVerboseCRUD
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=add-verbose-crud.js.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import _locreq from "locreq";
|
|
2
|
-
import prompts from "prompts";
|
|
3
|
-
import { getFieldHandler } from "./templates/shared/shared-crud-form-fields.js";
|
|
4
|
-
import extract_fields_from_collection from "./utils/extract-fields-from-collection.js";
|
|
5
|
-
import { listCollections } from "./utils/list-collections.js";
|
|
6
|
-
import { formatWithPrettier } from "./utils/prettier.js";
|
|
7
|
-
async function crudFieldSnippets(params, app_directory = process.cwd()) {
|
|
8
|
-
const target_locreq = _locreq(app_directory);
|
|
9
|
-
prompts.override(params);
|
|
10
|
-
const { collection_name } = await prompts([
|
|
11
|
-
{
|
|
12
|
-
type: "autocomplete",
|
|
13
|
-
name: "collection_name",
|
|
14
|
-
message: "Which sealious collection do you like to show a CRUD field config for?",
|
|
15
|
-
choices: (await listCollections()).map((collection) => ({
|
|
16
|
-
title: collection,
|
|
17
|
-
value: collection
|
|
18
|
-
}))
|
|
19
|
-
}
|
|
20
|
-
]);
|
|
21
|
-
const all_fields = await extract_fields_from_collection(collection_name);
|
|
22
|
-
const { field_name } = await prompts([
|
|
23
|
-
{
|
|
24
|
-
type: "autocomplete",
|
|
25
|
-
name: "field_name",
|
|
26
|
-
message: `Which field do you want to show CRUD config for??`,
|
|
27
|
-
choices: all_fields.map((field) => ({
|
|
28
|
-
title: field.name,
|
|
29
|
-
value: field.name
|
|
30
|
-
}))
|
|
31
|
-
}
|
|
32
|
-
]);
|
|
33
|
-
const handler = await getFieldHandler(
|
|
34
|
-
collection_name,
|
|
35
|
-
all_fields.find((e) => e.name == field_name),
|
|
36
|
-
(p) => p
|
|
37
|
-
);
|
|
38
|
-
console.log(`
|
|
39
|
-
|
|
40
|
-
### Field in shared.ts
|
|
41
|
-
|
|
42
|
-
${handler.field}
|
|
43
|
-
|
|
44
|
-
### Control in shared.ts
|
|
45
|
-
|
|
46
|
-
${await formatWithPrettier(handler.controls)}
|
|
47
|
-
`);
|
|
48
|
-
}
|
|
49
|
-
export {
|
|
50
|
-
crudFieldSnippets
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=crud-field-snippets.js.map
|
package/lib/find-css-includes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=reverse-single-reference.js.map
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import { FormField } from "./field.js";
|
|
3
|
-
class EnumMultipleField extends FormField {
|
|
4
|
-
constructor(required, options, error_message = (options2) => options2.join(", ")) {
|
|
5
|
-
super(required);
|
|
6
|
-
this.options = options;
|
|
7
|
-
this.error_message = error_message;
|
|
8
|
-
this.predicate = predicates.enum(this.options);
|
|
9
|
-
}
|
|
10
|
-
async isValueValid(_, values) {
|
|
11
|
-
for (const value of values) {
|
|
12
|
-
if (!is(value, predicates.string)) {
|
|
13
|
-
return { valid: false, message: "expected a string" };
|
|
14
|
-
}
|
|
15
|
-
if (!this.options.includes(value)) {
|
|
16
|
-
return { valid: false, message: "invalid value" };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return { valid: true, message: "" };
|
|
20
|
-
}
|
|
21
|
-
async parse(_, value) {
|
|
22
|
-
if (is(value, predicates.string)) {
|
|
23
|
-
return { parsable: true, parsed_value: [value], error: null };
|
|
24
|
-
} else if (is(value, predicates.array(predicates.string))) {
|
|
25
|
-
return {
|
|
26
|
-
parsable: true,
|
|
27
|
-
parsed_value: value,
|
|
28
|
-
error: null
|
|
29
|
-
};
|
|
30
|
-
} else if (value == null) {
|
|
31
|
-
return { parsable: true, parsed_value: [], error: null };
|
|
32
|
-
} else {
|
|
33
|
-
return {
|
|
34
|
-
parsable: false,
|
|
35
|
-
parsed_value: null,
|
|
36
|
-
error: "Please enter a list of strings"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
getEmptyValue() {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export {
|
|
45
|
-
EnumMultipleField
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=enum-multiple.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { Fields } from "../../index.js";
|
|
3
|
-
describe("enum-multiple field", () => {
|
|
4
|
-
const ctx = {};
|
|
5
|
-
it("validation logic", async () => {
|
|
6
|
-
const field = new Fields.EnumMultipleField(true, ["sa", "mp", "le"]);
|
|
7
|
-
assert.strictEqual((await field.isValueValid(ctx, ["sa", "le"])).valid, true);
|
|
8
|
-
assert.strictEqual((await field.isValueValid(ctx, ["notvalid"])).valid, false);
|
|
9
|
-
assert.strictEqual((await field.isValueValid(ctx, [42])).valid, false);
|
|
10
|
-
});
|
|
11
|
-
it("parse function", async () => {
|
|
12
|
-
const field = new Fields.EnumMultipleField(true, []);
|
|
13
|
-
const string_array_response = await field.parse(ctx, ["42"]);
|
|
14
|
-
const number_response = await field.parse(ctx, 42);
|
|
15
|
-
const string_response = await field.parse(ctx, "sample");
|
|
16
|
-
const null_response = await field.parse(ctx, null);
|
|
17
|
-
assert.strictEqual(string_array_response.parsable, true);
|
|
18
|
-
assert.deepEqual(string_array_response.parsed_value, ["42"]);
|
|
19
|
-
assert.strictEqual(number_response.parsable, false);
|
|
20
|
-
assert.strictEqual(number_response.error, "Please enter a list of strings");
|
|
21
|
-
assert.strictEqual(string_response.parsable, true);
|
|
22
|
-
assert.deepEqual(string_response.parsed_value, ["sample"]);
|
|
23
|
-
assert.strictEqual(null_response.parsable, true);
|
|
24
|
-
assert.deepEqual(null_response.parsed_value, []);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=enum-multiple.test.js.map
|
package/lib/forms/fields/enum.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import { FormField } from "./field.js";
|
|
3
|
-
class EnumField extends FormField {
|
|
4
|
-
constructor(required, options, error_message = (options2) => options2.join(", ")) {
|
|
5
|
-
super(required);
|
|
6
|
-
this.options = options;
|
|
7
|
-
this.error_message = error_message;
|
|
8
|
-
this.predicate = predicates.enum(this.options);
|
|
9
|
-
}
|
|
10
|
-
async isValueValid(_, value) {
|
|
11
|
-
if (!is(value, predicates.string)) {
|
|
12
|
-
return { valid: false, message: "expected a string" };
|
|
13
|
-
}
|
|
14
|
-
if (this.options.includes(value)) {
|
|
15
|
-
return { valid: true, message: "" };
|
|
16
|
-
}
|
|
17
|
-
return { valid: false, message: this.error_message(this.options) };
|
|
18
|
-
}
|
|
19
|
-
async parse(_, value) {
|
|
20
|
-
if (is(value, predicates.string)) {
|
|
21
|
-
return {
|
|
22
|
-
parsable: true,
|
|
23
|
-
parsed_value: value,
|
|
24
|
-
error: null
|
|
25
|
-
};
|
|
26
|
-
} else {
|
|
27
|
-
return {
|
|
28
|
-
parsable: false,
|
|
29
|
-
parsed_value: null,
|
|
30
|
-
error: "Please enter a string"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
getEmptyValue() {
|
|
35
|
-
return "";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
EnumField
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=enum.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { Fields } from "../../index.js";
|
|
3
|
-
describe("enum field", () => {
|
|
4
|
-
const ctx = {};
|
|
5
|
-
it("validation logic", async () => {
|
|
6
|
-
const field = new Fields.EnumField(true, ["sa", "mp", "le"]);
|
|
7
|
-
assert.strictEqual((await field.isValueValid(ctx, 42)).valid, false);
|
|
8
|
-
assert.strictEqual((await field.isValueValid(ctx, "mp")).valid, true);
|
|
9
|
-
assert.strictEqual((await field.isValueValid(ctx, "notvalid")).valid, false);
|
|
10
|
-
});
|
|
11
|
-
it("parse function", async () => {
|
|
12
|
-
const field = new Fields.EnumField(true, []);
|
|
13
|
-
const string_response = await field.parse(ctx, "42");
|
|
14
|
-
const number_response = await field.parse(ctx, 42);
|
|
15
|
-
assert.strictEqual(string_response.parsable, true);
|
|
16
|
-
assert.strictEqual(string_response.parsed_value, "42");
|
|
17
|
-
assert.strictEqual(number_response.parsable, false);
|
|
18
|
-
assert.strictEqual(number_response.error, "Please enter a string");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=enum.test.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FormField } from "./field.js";
|
|
2
|
-
class ReverseSingleReference extends FormField {
|
|
3
|
-
constructor(required, sealious_field) {
|
|
4
|
-
super(required);
|
|
5
|
-
this.sealious_field = sealious_field;
|
|
6
|
-
}
|
|
7
|
-
async parse(ctx, raw_value) {
|
|
8
|
-
return { parsable: true, error: null, parsed_value: raw_value };
|
|
9
|
-
}
|
|
10
|
-
getEmptyValue() {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
ReverseSingleReference
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=reverse-single-reference.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const boolean_handler = async (_, { name }, ___, { is_required_expr, fields_var }) => ({
|
|
2
|
-
field: `${name}: new Fields.Boolean(${is_required_expr})`,
|
|
3
|
-
controls: `new Controls.Checkbox(${fields_var}.${name}, { label: "${name}" })`,
|
|
4
|
-
initial_value_edit: {
|
|
5
|
-
fallback_value: `"false"`,
|
|
6
|
-
parsed_value: `String(item.get("${name}"))`
|
|
7
|
-
},
|
|
8
|
-
main_value_sealious: `!!data.${name}`,
|
|
9
|
-
fallback_value_sealious: "false"
|
|
10
|
-
});
|
|
11
|
-
export {
|
|
12
|
-
boolean_handler
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=boolean.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const date_handler = async (_, { name }, ___, { fields_var }) => ({
|
|
2
|
-
controls: `new Controls.SimpleInput(${fields_var}.${name}, { label: "${name}", type: "date"})`,
|
|
3
|
-
fallback_value_sealious: `undefined`
|
|
4
|
-
});
|
|
5
|
-
export {
|
|
6
|
-
date_handler
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=date.js.map
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { toKebabCase, toPascalCase } from "js-convert-case";
|
|
2
|
-
import extract_fields_from_collection from "../../../utils/extract-fields-from-collection.js";
|
|
3
|
-
const deep_reverse_single_reference_handler = async (collection_name, {
|
|
4
|
-
name,
|
|
5
|
-
target,
|
|
6
|
-
referencing_collection,
|
|
7
|
-
intermediary_field_that_points_there,
|
|
8
|
-
referencing_field
|
|
9
|
-
}, ___, { is_required_expr, fields_var }) => {
|
|
10
|
-
if (!referencing_collection || !target || !intermediary_field_that_points_there || !referencing_field) {
|
|
11
|
-
console.warn(
|
|
12
|
-
"missing referencing_collection, target, intermediary_field_that_points_there, or referencing_field member in extracted field info"
|
|
13
|
-
);
|
|
14
|
-
return { field: "" };
|
|
15
|
-
}
|
|
16
|
-
const referencing_fields = await extract_fields_from_collection(
|
|
17
|
-
referencing_collection
|
|
18
|
-
);
|
|
19
|
-
if (referencing_fields.length == 2) {
|
|
20
|
-
const post_create = (get_id) => `{
|
|
21
|
-
const item_id = ${get_id};
|
|
22
|
-
// First, we remove links refering to current item
|
|
23
|
-
const {items: existing_links } = (await ctx.$app.collections["${referencing_collection}"]
|
|
24
|
-
.list(ctx.$context)
|
|
25
|
-
.filter({"${referencing_field}": item_id})
|
|
26
|
-
.fetch()
|
|
27
|
-
)
|
|
28
|
-
const should_exist_ids = Object.entries(
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
30
|
-
(data["${name}"] as unknown as Record<string, string>) || {}
|
|
31
|
-
)
|
|
32
|
-
.filter(([, value]) => value === "on")
|
|
33
|
-
.map(([key]) => key);
|
|
34
|
-
const to_delete = existing_links.filter(
|
|
35
|
-
(link) => !should_exist_ids.includes(link.get("${intermediary_field_that_points_there}"))
|
|
36
|
-
);
|
|
37
|
-
const to_create_ids = should_exist_ids.filter(
|
|
38
|
-
(id) => !existing_links.map((link) => link.get("${intermediary_field_that_points_there}")).includes(id)
|
|
39
|
-
);
|
|
40
|
-
await Promise.all(to_delete.map((item) => item.remove(ctx.$context)));
|
|
41
|
-
// Then, we iterate over all selected values and insert appropriate missing links
|
|
42
|
-
const promises = to_create_ids.map(async (id) => {
|
|
43
|
-
await ctx.$app.collections["${toKebabCase(referencing_collection)}"].create(
|
|
44
|
-
ctx.$context,
|
|
45
|
-
{
|
|
46
|
-
"${referencing_field}": item_id,
|
|
47
|
-
"${intermediary_field_that_points_there}": id,
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
await Promise.all(promises);
|
|
52
|
-
}`;
|
|
53
|
-
return {
|
|
54
|
-
field: `${name}: new Fields.CheckboxedListField(${is_required_expr}, async (ctx) => {
|
|
55
|
-
const { items } = await ctx.$app.collections["${target}"]
|
|
56
|
-
.list(ctx.$context)
|
|
57
|
-
.fetch();
|
|
58
|
-
|
|
59
|
-
return items.map((s) => ({
|
|
60
|
-
label: s.get("name"),
|
|
61
|
-
value: s.id,
|
|
62
|
-
}));
|
|
63
|
-
})`,
|
|
64
|
-
controls: `new Controls.CheckboxedListInput(${fields_var}.${name}, {
|
|
65
|
-
label: "${name}",
|
|
66
|
-
})`,
|
|
67
|
-
post_edit: post_create(`await this.getID(ctx)`),
|
|
68
|
-
post_create: post_create(`created.id`),
|
|
69
|
-
initial_value_edit: `Object.fromEntries((item.get("${name}") || []).map(id=>[id, "on"]))`,
|
|
70
|
-
sealious_value: () => ""
|
|
71
|
-
};
|
|
72
|
-
} else {
|
|
73
|
-
const initial_value_function_name = `get${toPascalCase(
|
|
74
|
-
name
|
|
75
|
-
)}TableInitialValues`;
|
|
76
|
-
const post_create = (get_id) => `{
|
|
77
|
-
const item_id = ${get_id};
|
|
78
|
-
// First, we remove links refering to current item
|
|
79
|
-
const { items: to_delete } = await ctx.$app.collections[
|
|
80
|
-
"${toKebabCase(referencing_collection)}"
|
|
81
|
-
]
|
|
82
|
-
.list(ctx.$context)
|
|
83
|
-
.filter({ "${referencing_field}": item_id })
|
|
84
|
-
.fetch();
|
|
85
|
-
await Promise.all(to_delete.map((item) => item.remove(ctx.$context)));
|
|
86
|
-
|
|
87
|
-
// Then, we iterate over all selected values and insert appropriate entries for the subcategories relation
|
|
88
|
-
|
|
89
|
-
const promises = (data["${name}"] || [])
|
|
90
|
-
.filter((s) => s.selected == true)
|
|
91
|
-
.map(async (link_info) => {
|
|
92
|
-
await ctx.$app.collections["${toKebabCase(referencing_collection)}"].create(
|
|
93
|
-
ctx.$context,
|
|
94
|
-
{
|
|
95
|
-
"${referencing_field}": item_id,
|
|
96
|
-
"${intermediary_field_that_points_there}": String(link_info["${intermediary_field_that_points_there}"]),
|
|
97
|
-
${referencing_fields.filter(
|
|
98
|
-
({ type }) => type !== "single-reference"
|
|
99
|
-
).map(
|
|
100
|
-
(field) => `"${field.name}": link_info["${field.name}"]`
|
|
101
|
-
).join(",\n")}
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
await Promise.all(promises);
|
|
107
|
-
}`;
|
|
108
|
-
const initial_value = `(await ${initial_value_function_name}(ctx,item)) as unknown as FormDataValue`;
|
|
109
|
-
return {
|
|
110
|
-
imports: {
|
|
111
|
-
shared: `import type { CollectionItem } from "sealious"; import type { Context } from "koa";`,
|
|
112
|
-
edit: `import {${initial_value_function_name}} from "../shared.js"; import type { FormDataValue } from "@sealcode/sealgen";`
|
|
113
|
-
},
|
|
114
|
-
field: `
|
|
115
|
-
${name}: new Fields.Table({
|
|
116
|
-
selected: new Fields.Boolean(false),
|
|
117
|
-
"${referencing_field}": new Fields.SimpleFormField(true),
|
|
118
|
-
"${intermediary_field_that_points_there}": new Fields.SimpleFormField(true),
|
|
119
|
-
${referencing_fields.filter(({ type }) => type !== "single-reference").map(
|
|
120
|
-
(field) => `${field.name}: new Fields.SimpleFormField(true)`
|
|
121
|
-
).join(",\n")}
|
|
122
|
-
})`,
|
|
123
|
-
controls: `
|
|
124
|
-
new Controls.Table(${fields_var}.${name}, {
|
|
125
|
-
render_fields: {
|
|
126
|
-
selected: (fctx, name, value) => /* HTML */ \`<input
|
|
127
|
-
type="checkbox"
|
|
128
|
-
name=\${name}
|
|
129
|
-
\${value?.toString() == "true" ? "checked" : ""}
|
|
130
|
-
form="\${fctx.form_id}"
|
|
131
|
-
autocomplete="off"
|
|
132
|
-
/>\`,
|
|
133
|
-
"${referencing_field}": (fctx, name, value) => /* HTML */ \`<input
|
|
134
|
-
type="hidden"
|
|
135
|
-
name=\${name}
|
|
136
|
-
value="\${value}"
|
|
137
|
-
form="\${fctx.form_id}"
|
|
138
|
-
/>\`,
|
|
139
|
-
"${intermediary_field_that_points_there}": (fctx, name, value) => /* HTML */ \`<input
|
|
140
|
-
type="hidden"
|
|
141
|
-
name=\${name}
|
|
142
|
-
value="\${value}"
|
|
143
|
-
form="\${fctx.form_id}"
|
|
144
|
-
/>\`,
|
|
145
|
-
${referencing_fields.filter(
|
|
146
|
-
({ type }) => type !== "single-reference"
|
|
147
|
-
).map(
|
|
148
|
-
(field) => `${field.name}: (fctx, name, value) => /* HTML */ \`<input
|
|
149
|
-
name=\${name}
|
|
150
|
-
value="\${value}"
|
|
151
|
-
form="\${fctx.form_id}"
|
|
152
|
-
autocomplete="off"
|
|
153
|
-
/>\``
|
|
154
|
-
).join(",\n")}
|
|
155
|
-
},
|
|
156
|
-
allow_adding: false,
|
|
157
|
-
})`,
|
|
158
|
-
top_level_shared: `export async function ${initial_value_function_name}(
|
|
159
|
-
ctx: Context,
|
|
160
|
-
item: CollectionItem<typeof ${toPascalCase(
|
|
161
|
-
collection_name
|
|
162
|
-
)}>
|
|
163
|
-
) {
|
|
164
|
-
// convert from an array to array-like object
|
|
165
|
-
return Object.fromEntries(
|
|
166
|
-
await Promise.all([
|
|
167
|
-
ctx.$app.collections["${toKebabCase(target)}"].list(ctx.$context).fetch(),
|
|
168
|
-
ctx.$app.collections["${toKebabCase(
|
|
169
|
-
referencing_collection
|
|
170
|
-
)}"].list(ctx.$context).fetch(),
|
|
171
|
-
]).then(([{ items: targets }, { items: links }]) =>
|
|
172
|
-
targets
|
|
173
|
-
.map((target) => {
|
|
174
|
-
return {
|
|
175
|
-
selected: (item.get("${name}") || []).includes(
|
|
176
|
-
target.id
|
|
177
|
-
)
|
|
178
|
-
? "on"
|
|
179
|
-
: "off",
|
|
180
|
-
"${referencing_field}": item.id,
|
|
181
|
-
"${intermediary_field_that_points_there}": target.id,
|
|
182
|
-
${referencing_fields.filter(
|
|
183
|
-
({ type }) => type !== "single-reference"
|
|
184
|
-
).map(
|
|
185
|
-
(field) => `"${field.name}": links
|
|
186
|
-
.find(
|
|
187
|
-
(e) =>
|
|
188
|
-
e.get("${intermediary_field_that_points_there}") == target.id &&
|
|
189
|
-
e.get("${referencing_field}") == item.id
|
|
190
|
-
)
|
|
191
|
-
?.get("rank") || 0,`
|
|
192
|
-
).join(",\n")}
|
|
193
|
-
};
|
|
194
|
-
})
|
|
195
|
-
.entries()
|
|
196
|
-
)
|
|
197
|
-
);
|
|
198
|
-
}`,
|
|
199
|
-
initial_value_edit: initial_value,
|
|
200
|
-
initial_value_create: initial_value,
|
|
201
|
-
post_edit: post_create(`await this.getID(ctx)`),
|
|
202
|
-
post_create: post_create(`created.id`)
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
export {
|
|
207
|
-
deep_reverse_single_reference_handler
|
|
208
|
-
};
|
|
209
|
-
//# sourceMappingURL=deep-reverse-single-reference.js.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { toPascalCase } from "js-convert-case";
|
|
2
|
-
const default_handler = async (collection_name, { name, is_readonly, is_required }, _, __, ___, fields_var = `${toPascalCase(collection_name)}FormFields`) => {
|
|
3
|
-
const required_s = `${toPascalCase(
|
|
4
|
-
collection_name
|
|
5
|
-
)}.fields.${name}.required`;
|
|
6
|
-
const fallback_value_initial = `""`;
|
|
7
|
-
const fallback_value_sealious = `""`;
|
|
8
|
-
const main_value_initial = `item.get("${name}")`;
|
|
9
|
-
const main_value_sealious = `data["${name}"]`;
|
|
10
|
-
const parsed_value = main_value_initial;
|
|
11
|
-
return {
|
|
12
|
-
is_required,
|
|
13
|
-
name,
|
|
14
|
-
post_create: "",
|
|
15
|
-
imports: { shared: "", edit: "" },
|
|
16
|
-
hide_field: is_readonly,
|
|
17
|
-
field: `${name}: new Fields.CollectionField(${required_s}, ${toPascalCase(
|
|
18
|
-
collection_name
|
|
19
|
-
)}.fields.${name})`,
|
|
20
|
-
hide_control: is_readonly,
|
|
21
|
-
controls: `new Controls.SimpleInput(${fields_var}.${name}, { label: "${name}"})`,
|
|
22
|
-
is_required_expr: `${toPascalCase(
|
|
23
|
-
collection_name
|
|
24
|
-
)}.fields.${name}.required`,
|
|
25
|
-
fields_var,
|
|
26
|
-
top_level_shared: "",
|
|
27
|
-
hide_initial_value_edit: is_readonly,
|
|
28
|
-
initial_value_edit: {
|
|
29
|
-
fallback_value: fallback_value_initial,
|
|
30
|
-
main_value: main_value_initial,
|
|
31
|
-
parsed_value
|
|
32
|
-
},
|
|
33
|
-
hide_initial_value_create: is_readonly,
|
|
34
|
-
initial_value_create: "",
|
|
35
|
-
pre_edit: "",
|
|
36
|
-
post_edit: "",
|
|
37
|
-
pre_create: "",
|
|
38
|
-
main_value_sealious,
|
|
39
|
-
fallback_value_sealious,
|
|
40
|
-
sealious_value: (result) => {
|
|
41
|
-
return result.is_required ? `${result.name}: ${result.main_value_sealious}` : `${result.name}: ${result.main_value_sealious} != null ? ${result.main_value_sealious} : ${result.fallback_value_sealious}`;
|
|
42
|
-
},
|
|
43
|
-
hide_sealious_value: is_readonly
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
default_handler
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=default.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { toPascalCase } from "js-convert-case";
|
|
2
|
-
const enum_handler = async (collection_name, { name }, _, { fields_var }) => ({
|
|
3
|
-
// this assertion and import is only necessary because required fields
|
|
4
|
-
// in Sealious lose the type information. Once this is fixed, we can remove this import here
|
|
5
|
-
imports: { shared: `import type { FieldTypes } from "sealious";` },
|
|
6
|
-
field: `${name}: new Fields.PickFromListField(
|
|
7
|
-
${toPascalCase(collection_name)}.fields["${name}"].required,
|
|
8
|
-
async (ctx) =>
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
10
|
-
(${toPascalCase(collection_name)}.fields["${name}"])
|
|
11
|
-
.getAllowedValues(ctx.$app)
|
|
12
|
-
.map((value) => ({ value, label: value }))
|
|
13
|
-
)`,
|
|
14
|
-
controls: `new Controls.Dropdown(${fields_var}.${name}, { label: "${name}"})`
|
|
15
|
-
});
|
|
16
|
-
export {
|
|
17
|
-
enum_handler
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=enum.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { toCamelCase } from "js-convert-case";
|
|
2
|
-
const file_handler = async (_, { name, is_required }, importPath, { is_required_expr }) => {
|
|
3
|
-
const tempname = toCamelCase("prepared-" + name);
|
|
4
|
-
return {
|
|
5
|
-
imports: {
|
|
6
|
-
shared: `import { TheFileManager } from "${importPath(
|
|
7
|
-
"src/back/file-manager.js"
|
|
8
|
-
)}";`
|
|
9
|
-
},
|
|
10
|
-
field: `${name}: new Fields.File(${is_required_expr}, TheFileManager)`,
|
|
11
|
-
initial_value_edit: `{old: item.get("${name}")}`,
|
|
12
|
-
pre_edit: `const ${tempname} = data.["${name}"]?.new || data.["${name}"]?.old;
|
|
13
|
-
if(!${tempname}){
|
|
14
|
-
throw new Error("Missing field: ${name}")
|
|
15
|
-
}`,
|
|
16
|
-
fallback_value_sealious: "null",
|
|
17
|
-
...is_required ? { main_value_sealious: tempname } : {}
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
file_handler
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=file.js.map
|