@antelopejs/dms 0.25.6-next.1105.g9b73018 → 0.25.6
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/CHANGELOG.md +60 -0
- package/README.md +16 -16
- package/data/mockup-spec.schema.json +289 -5
- package/dist/implementations/dms-auth/account-emails.js +2 -2
- package/dist/implementations/dms-auth/account-emails.js.map +1 -1
- package/dist/implementations/dms-auth/index.js +1 -2
- package/dist/implementations/dms-auth/index.js.map +1 -1
- package/dist/implementations/dms-base/group-order.d.ts +18 -0
- package/dist/implementations/dms-base/group-order.js +66 -0
- package/dist/implementations/dms-base/group-order.js.map +1 -0
- package/dist/implementations/dms-base/search-route.js +8 -5
- package/dist/implementations/dms-base/search-route.js.map +1 -1
- package/dist/implementations/dms-builder/engine/cell-displays.js +4 -1
- package/dist/implementations/dms-builder/engine/cell-displays.js.map +1 -1
- package/dist/implementations/dms-builder/engine/mapped-displays.js +5 -1
- package/dist/implementations/dms-builder/engine/mapped-displays.js.map +1 -1
- package/dist/implementations/dms-builder/engine/resource-emit.js +4 -0
- package/dist/implementations/dms-builder/engine/resource-emit.js.map +1 -1
- package/dist/implementations/dms-builder/engine/theme-assets.js +5 -17
- package/dist/implementations/dms-builder/engine/theme-assets.js.map +1 -1
- package/dist/mcp/tools/mockup-apply-to-page.js +1 -1
- package/dist/mcp/tools/mockup-apply-to-page.js.map +1 -1
- package/dist/mcp/tools/mockup-patch-spec.js +1 -1
- package/dist/mcp/tools/mockup-patch-spec.js.map +1 -1
- package/dist/mcp/tools/mockup-write-spec.js +1 -1
- package/dist/mcp/tools/mockup-write-spec.js.map +1 -1
- package/dist/mockup/apply-notes.d.ts +1 -1
- package/dist/mockup/apply-notes.js +2 -1
- package/dist/mockup/apply-notes.js.map +1 -1
- package/dist/mockup/apply-plan.js +3 -0
- package/dist/mockup/apply-plan.js.map +1 -1
- package/dist/mockup/capture-routes.d.ts +18 -0
- package/dist/mockup/capture-routes.js +101 -0
- package/dist/mockup/capture-routes.js.map +1 -0
- package/dist/mockup/capture.d.ts +10 -0
- package/dist/mockup/capture.js +64 -0
- package/dist/mockup/capture.js.map +1 -0
- package/dist/mockup/compile.js +16 -8
- package/dist/mockup/compile.js.map +1 -1
- package/dist/mockup/controller-blocks.js +62 -10
- package/dist/mockup/controller-blocks.js.map +1 -1
- package/dist/mockup/display-values.js +1 -1
- package/dist/mockup/display-values.js.map +1 -1
- package/dist/mockup/files.d.ts +2 -1
- package/dist/mockup/files.js +3 -2
- package/dist/mockup/files.js.map +1 -1
- package/dist/mockup/fixtures.d.ts +3 -1
- package/dist/mockup/fixtures.js +25 -2
- package/dist/mockup/fixtures.js.map +1 -1
- package/dist/mockup/form-fields.js +10 -1
- package/dist/mockup/form-fields.js.map +1 -1
- package/dist/mockup/header-action.d.ts +47 -0
- package/dist/mockup/header-action.js +46 -0
- package/dist/mockup/header-action.js.map +1 -0
- package/dist/mockup/history-routes.js +8 -1
- package/dist/mockup/history-routes.js.map +1 -1
- package/dist/mockup/json-schema-header.d.ts +2 -0
- package/dist/mockup/json-schema-header.js +69 -0
- package/dist/mockup/json-schema-header.js.map +1 -0
- package/dist/mockup/json-schema-layout.d.ts +2 -0
- package/dist/mockup/json-schema-layout.js +61 -0
- package/dist/mockup/json-schema-layout.js.map +1 -0
- package/dist/mockup/json-schema.js +5 -16
- package/dist/mockup/json-schema.js.map +1 -1
- package/dist/mockup/model.d.ts +204 -18
- package/dist/mockup/model.js +46 -12
- package/dist/mockup/model.js.map +1 -1
- package/dist/mockup/page-links.d.ts +2 -1
- package/dist/mockup/page-links.js +14 -3
- package/dist/mockup/page-links.js.map +1 -1
- package/dist/mockup/refusals.d.ts +1 -0
- package/dist/mockup/refusals.js +1 -0
- package/dist/mockup/refusals.js.map +1 -1
- package/dist/mockup/routes.js +11 -1
- package/dist/mockup/routes.js.map +1 -1
- package/dist/mockup/sample-rows.js +4 -0
- package/dist/mockup/sample-rows.js.map +1 -1
- package/dist/mockup/store.d.ts +1 -0
- package/dist/mockup/store.js +9 -19
- package/dist/mockup/store.js.map +1 -1
- package/dist/mockup/summary-fields.d.ts +20 -0
- package/dist/mockup/summary-fields.js +22 -0
- package/dist/mockup/summary-fields.js.map +1 -0
- package/dist/mockup/table-columns.js +9 -3
- package/dist/mockup/table-columns.js.map +1 -1
- package/dist/mockup/table-options.d.ts +4 -1
- package/dist/mockup/table-options.js +40 -2
- package/dist/mockup/table-options.js.map +1 -1
- package/dist/mockup/table-param-filters.d.ts +52 -0
- package/dist/mockup/table-param-filters.js +83 -0
- package/dist/mockup/table-param-filters.js.map +1 -0
- package/dist/mockup/table-row-actions.d.ts +2 -0
- package/dist/mockup/table-row-actions.js +85 -0
- package/dist/mockup/table-row-actions.js.map +1 -0
- package/dist/mockup/unknown-keys.d.ts +3 -0
- package/dist/mockup/unknown-keys.js +45 -0
- package/dist/mockup/unknown-keys.js.map +1 -0
- package/dist/mockup/validate.d.ts +7 -1
- package/dist/mockup/validate.js +76 -3
- package/dist/mockup/validate.js.map +1 -1
- package/dist/pages/account.d.ts +1 -0
- package/dist/pages/account.js +1 -0
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/settings/overview/account-summary.d.ts +2 -0
- package/dist/pages/settings/overview/account-summary.js +17 -8
- package/dist/pages/settings/overview/account-summary.js.map +1 -1
- package/dist/pages/settings/settings-index.js +2 -1
- package/dist/pages/settings/settings-index.js.map +1 -1
- package/dist/realtime/sse.js +2 -4
- package/dist/realtime/sse.js.map +1 -1
- package/dist/store/internal/frontend/dev-reload.js +7 -1
- package/dist/store/internal/frontend/dev-reload.js.map +1 -1
- package/dist/utils/account-notifications.js +1 -0
- package/dist/utils/account-notifications.js.map +1 -1
- package/dist/utils/email-change-mail.js +2 -2
- package/dist/utils/email-change-mail.js.map +1 -1
- package/dist/utils/email-plain-text.d.ts +1 -0
- package/dist/utils/email-plain-text.js +95 -0
- package/dist/utils/email-plain-text.js.map +1 -0
- package/dist/utils/export-jobs.js +2 -2
- package/dist/utils/export-jobs.js.map +1 -1
- package/dist/utils/html-email.d.ts +8 -0
- package/dist/utils/html-email.js +9 -0
- package/dist/utils/html-email.js.map +1 -0
- package/dist/utils/image-signatures.d.ts +3 -0
- package/dist/utils/image-signatures.js +22 -0
- package/dist/utils/image-signatures.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/sse-keepalive/index.d.ts +3 -0
- package/dist/utils/sse-keepalive/index.js +8 -0
- package/dist/utils/sse-keepalive/index.js.map +1 -0
- package/dist/validation/allowed-keys.d.ts +2 -0
- package/dist/validation/allowed-keys.js +16 -0
- package/dist/validation/allowed-keys.js.map +1 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/index.js.map +1 -1
- package/frontend-vue/eslint-globals.generated.mjs +2 -2
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/2fa.vue +3 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/backup.vue +3 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/forgot-validation.vue +3 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/forgot.vue +3 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/login.vue +4 -1
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/recover.vue +3 -0
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/signup.vue +17 -1
- package/frontend-vue/layers/dms-auth/app/custom-pages/auth/validate.vue +3 -0
- package/frontend-vue/layers/dms-auth/i18n/locales/auth-fr-FR.json +10 -10
- package/frontend-vue/layers/dms-core/app/build/composables/api-error.ts +8 -0
- package/frontend-vue/layers/dms-core/app/build/composables/field-errors.ts +485 -0
- package/frontend-vue/layers/dms-core/app/build/composables/useHydrated.ts +27 -0
- package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/translation/useUniqueLocales.ts +23 -5
- package/frontend-vue/layers/dms-core/app/composables/useApiErrorPresenter.ts +1 -0
- package/frontend-vue/layers/dms-core/app/composables/useFieldErrors.ts +12 -443
- package/frontend-vue/layers/dms-core/app/entries/composables/useHydrated.ts +1 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +8 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +8 -0
- package/frontend-vue/layers/dms-core/shared/types/app-config.ts +2 -0
- package/frontend-vue/layers/dms-layout/app/app.config.ts +1 -0
- package/frontend-vue/layers/dms-layout/app/build/components/layout/DashboardHeader.vue +7 -4
- package/frontend-vue/layers/dms-layout/app/build/components/layout/EmptyLayoutBrand.vue +49 -0
- package/frontend-vue/layers/dms-layout/app/build/components/layout/LayoutFooter.vue +2 -0
- package/frontend-vue/layers/dms-layout/app/build/components/layout/PreviewPageHeader.vue +19 -3
- package/frontend-vue/layers/dms-layout/app/build/components/layout/mockupMenu.ts +3 -8
- package/frontend-vue/layers/dms-layout/app/build/components/notification/NotificationPopover.vue +8 -2
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationInboxItem.vue +6 -9
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationMatrixCategory.vue +6 -2
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationMatrixSubject.vue +27 -22
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationPreferencesForm.vue +8 -10
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/notificationDisplay.ts +39 -3
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsShell.vue +38 -5
- package/frontend-vue/layers/dms-layout/app/build/composables/settings/profile/useProfilePreferences.ts +1 -3
- package/frontend-vue/layers/dms-layout/app/build/utils/dev-reload-stream.ts +23 -4
- package/frontend-vue/layers/dms-layout/app/custom-layouts/EmptyLayout.vue +39 -31
- package/frontend-vue/layers/dms-layout/app/custom-layouts/PreviewLayout.vue +60 -4
- package/frontend-vue/layers/dms-layout/app/entries/components/pages/settings/shell/SettingsShell.ts +2 -0
- package/frontend-vue/layers/dms-layout/app/error.vue +1 -1
- package/frontend-vue/layers/dms-layout/app/middleware/module-routing.global.ts +7 -1
- package/frontend-vue/layers/dms-layout/app/plugins/dms-menu-sync.client.ts +14 -1
- package/frontend-vue/layers/dms-layout/app/utils/breadcrumb.ts +13 -0
- package/frontend-vue/layers/dms-layout/i18n/locales/layout-en-GB.json +1 -1
- package/frontend-vue/layers/dms-layout/i18n/locales/layout-fr-FR.json +5 -5
- package/frontend-vue/layers/dms-onboarding/app/build/components/onboarding/steps/StepPlatform.vue +3 -0
- package/frontend-vue/layers/dms-onboarding/app/components/onboarding/steps/StepRegister.vue +3 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/BlockPreviewSketch.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupHeaderActions.vue +1 -4
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspector.vue +2 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupIssues.vue +22 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverview.vue +125 -178
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewArrows.vue +110 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewFrameImage.vue +75 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSlot.vue +113 -4
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewZoom.vue +67 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinLayer.vue +10 -4
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkbench.vue +8 -1
- package/frontend-vue/layers/dms-ui/app/build/components/table-view/ExpandedRowDetail.vue +26 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewCapture.ts +247 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewCaptureAssets.ts +181 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewNavigation.ts +8 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewRaster.ts +45 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockPreviewEmbed.ts +46 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupOverview.ts +109 -35
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageFrame.ts +4 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRoutePage.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerPages.ts +3 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useOverviewCaptures.ts +136 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +68 -8
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewLinks.ts +17 -7
- package/frontend-vue/layers/dms-ui/app/build/composables/confirm/fetchedConfirmDialog.ts +6 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultDisplayComponents.ts +4 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultPrimitiveTypes.ts +38 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/registerFieldTypes.ts +69 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/useColumnValueRenderer.ts +20 -7
- package/frontend-vue/layers/dms-ui/app/build/composables/form/keyValueRows.ts +36 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/form/useInstantForm.ts +4 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewGrouping.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewListing.ts +21 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewSorting.ts +8 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useGroupedRows.ts +32 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableFooter.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableRows.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/displayOptions.ts +14 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/groupedRows.ts +68 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/tableQuery.ts +5 -0
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCard.vue +73 -48
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +18 -11
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupThumbnail.vue +34 -124
- package/frontend-vue/layers/dms-ui/app/build/mockups/manage.ts +7 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewCapture.ts +96 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewChannel.ts +10 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +29 -118
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewRects.ts +61 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/dotGrid.ts +37 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/legalIdentifier.ts +279 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +34 -5
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCaptures.ts +130 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupFrame.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupLinks.ts +35 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverview.ts +44 -17
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +26 -14
- package/frontend-vue/layers/dms-ui/app/build/utils/previewHeader.ts +154 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageLayout.ts +149 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageQuery.ts +42 -0
- package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +56 -6
- package/frontend-vue/layers/dms-ui/app/components/confirm/ConfirmModal.vue +7 -7
- package/frontend-vue/layers/dms-ui/app/components/flow-canvas/FlowCanvas.vue +4 -7
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputIdentifier.vue +90 -0
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputPhone.vue +5 -0
- package/frontend-vue/layers/dms-ui/app/components/form/components/KeyValue.vue +2 -20
- package/frontend-vue/layers/dms-ui/app/components/key-value-list/KeyValueList.vue +51 -15
- package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +3 -8
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/config.ts +10 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/previewCapture.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/previewCaptureAssets.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/usePreviewFrame.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/table-view/utils/displayOptions.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/mockups/manage.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/blockPreview.ts +3 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/legalIdentifier.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupCaptures.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/types/table/query.ts +5 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +2 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +12 -10
- package/frontend-vue/scripts/check-invariants.mjs +101 -0
- package/package.json +8 -8
- package/skills/dms/SKILL.md +4 -2
- package/skills/dms-module/SKILL.md +3 -0
|
@@ -7,6 +7,7 @@ import AuthFormAlert from "../../build/components/AuthFormAlert.vue";
|
|
|
7
7
|
import AuthResendCode from "../../build/components/AuthResendCode.vue";
|
|
8
8
|
import { useAuthFormError } from "../../build/composables/useAuthFormError";
|
|
9
9
|
import { codeEntryError } from "#dms-core/app/composables/useFormValidation";
|
|
10
|
+
import { useHydrated } from "#dms-core/app/entries/composables/useHydrated";
|
|
10
11
|
|
|
11
12
|
const route = useDmsRoute();
|
|
12
13
|
const { processApiMessage } = useTranslation();
|
|
@@ -17,6 +18,7 @@ const homepage = useHomepage();
|
|
|
17
18
|
const { $authFetch } = useAuthFetch();
|
|
18
19
|
const { formError, showFormError, clearFormError, showError } =
|
|
19
20
|
useAuthFormError();
|
|
21
|
+
const hydrated = useHydrated();
|
|
20
22
|
|
|
21
23
|
if (!route.query.id) {
|
|
22
24
|
throw createDmsError({
|
|
@@ -155,6 +157,7 @@ async function requestEmailValidation() {
|
|
|
155
157
|
|
|
156
158
|
<UButton
|
|
157
159
|
:loading="isLoading"
|
|
160
|
+
:disabled="!hydrated"
|
|
158
161
|
:label="$t('page.validate.submit')"
|
|
159
162
|
type="submit"
|
|
160
163
|
size="lg"
|
|
@@ -190,10 +190,10 @@
|
|
|
190
190
|
"saved": "Profil enregistré",
|
|
191
191
|
"save_error": "Votre profil n'a pas pu être enregistré. Réessayez.",
|
|
192
192
|
"security_title": "Connexion et sécurité",
|
|
193
|
-
"security_description": "Mot de passe, e-mail,
|
|
193
|
+
"security_description": "Mot de passe, e-mail, authentification à deux facteurs et sessions.",
|
|
194
194
|
"security_attention": "{count} point demande votre attention | {count} points demandent votre attention",
|
|
195
195
|
"security_all_good": "Tout est en ordre",
|
|
196
|
-
"security_two_factor_on": "
|
|
196
|
+
"security_two_factor_on": "Authentification à deux facteurs activée",
|
|
197
197
|
"security_sessions": "{count} session active | {count} sessions actives",
|
|
198
198
|
"security_facts": "{twoFactor}, {sessions}.",
|
|
199
199
|
"security_open": "Ouvrir Sécurité",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"title": "Vos données",
|
|
238
238
|
"description": "Récupérez une copie de tout ce que le tableau de bord conserve à votre sujet, ou fermez votre compte.",
|
|
239
239
|
"export_title": "Exporter mes données",
|
|
240
|
-
"export_description": "Un fichier JSON avec votre profil, vos préférences, vos espaces et rôles, vos notifications, vos sessions, les fournisseurs de connexion liés et les invitations que vous avez envoyées. Les mots de passe, secrets
|
|
240
|
+
"export_description": "Un fichier JSON avec votre profil, vos préférences, vos espaces et rôles, vos notifications, vos sessions, les fournisseurs de connexion liés et les invitations que vous avez envoyées. Les mots de passe, secrets d'authentification à deux facteurs et jetons n'y figurent jamais.",
|
|
241
241
|
"export_button": "Exporter mes données",
|
|
242
242
|
"export_done": "Vos données ont été téléchargées",
|
|
243
243
|
"export_error": "Vos données n'ont pas pu être exportées. Réessayez.",
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
"description": {
|
|
269
269
|
"profile": "Comment les autres membres vous voient, et ce que le tableau de bord conserve à votre sujet.",
|
|
270
270
|
"sessions": "Consultez et gérez vos sessions actives sur tous vos appareils",
|
|
271
|
-
"security": "Mot de passe, e-mail de connexion,
|
|
271
|
+
"security": "Mot de passe, e-mail de connexion, authentification à deux facteurs et appareils connectés à votre compte."
|
|
272
272
|
},
|
|
273
273
|
"security": {
|
|
274
274
|
"on": "Activée",
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
"email_title": "E-mail de connexion",
|
|
290
290
|
"email_description": "Le modifier demande votre mot de passe actuel, puis un code envoyé à la nouvelle adresse avant qu'elle ne prenne effet.",
|
|
291
291
|
"status": {
|
|
292
|
-
"two_factor": "
|
|
292
|
+
"two_factor": "Authentification à deux facteurs",
|
|
293
293
|
"methods_both": "Codes appli + e-mail",
|
|
294
294
|
"methods_totp": "Application d'authentification",
|
|
295
295
|
"methods_email": "Codes par e-mail",
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"codes_unsaved": "Pas encore sauvegardés",
|
|
300
300
|
"codes_saved": "Sauvegardés le {date}",
|
|
301
301
|
"codes_use": "Codes de récupération à usage unique",
|
|
302
|
-
"codes_need_two_factor": "Fournis avec
|
|
302
|
+
"codes_need_two_factor": "Fournis avec l'authentification à deux facteurs",
|
|
303
303
|
"password": "Mot de passe",
|
|
304
304
|
"password_not_set": "Non défini",
|
|
305
305
|
"password_sso": "Vous vous connectez par authentification unique",
|
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
"sessions_detail": "Cet appareil uniquement | Cet appareil + {count} autre | Cet appareil + {count} autres"
|
|
310
310
|
},
|
|
311
311
|
"attention": {
|
|
312
|
-
"two_factor_off": "
|
|
312
|
+
"two_factor_off": "l'authentification à deux facteurs est désactivée",
|
|
313
313
|
"backup_codes_unsaved": "vos codes de secours n'ont pas encore été sauvegardés",
|
|
314
314
|
"backup_codes_low": "il vous reste peu de codes de secours"
|
|
315
315
|
},
|
|
@@ -373,10 +373,10 @@
|
|
|
373
373
|
"code_label_any": "Code de votre application ou reçu par e-mail",
|
|
374
374
|
"remove": "Supprimer…",
|
|
375
375
|
"remove_title": "Supprimer « {method} » ?",
|
|
376
|
-
"remove_keeps_on": "Saisissez votre code de vérification actuel pour confirmer. « {method} » reste activée,
|
|
377
|
-
"remove_turns_off": "Saisissez votre code de vérification actuel pour confirmer. C'est votre dernière méthode :
|
|
376
|
+
"remove_keeps_on": "Saisissez votre code de vérification actuel pour confirmer. « {method} » reste activée, l'authentification à deux facteurs reste donc active.",
|
|
377
|
+
"remove_turns_off": "Saisissez votre code de vérification actuel pour confirmer. C'est votre dernière méthode : l'authentification à deux facteurs sera désactivée et vos codes de secours ne fonctionneront plus.",
|
|
378
378
|
"remove_confirm": "Supprimer la méthode",
|
|
379
|
-
"off_title": "
|
|
379
|
+
"off_title": "Authentification à deux facteurs désactivée",
|
|
380
380
|
"off_meta": "Ajoutez une application d'authentification ou des codes par e-mail pour protéger votre compte.",
|
|
381
381
|
"keep_two": "Gardez au moins deux méthodes pour ne jamais perdre l'accès.",
|
|
382
382
|
"add_method": "Ajouter une méthode",
|
|
@@ -27,6 +27,7 @@ const recordSchema = z.object({
|
|
|
27
27
|
data: z.unknown().optional(),
|
|
28
28
|
_data: z.unknown().optional(),
|
|
29
29
|
message: z.unknown().optional(),
|
|
30
|
+
text: z.unknown().optional(),
|
|
30
31
|
name: z.unknown().optional(),
|
|
31
32
|
severity: z.unknown().optional(),
|
|
32
33
|
params: z.unknown().optional(),
|
|
@@ -37,6 +38,7 @@ const recordSchema = z.object({
|
|
|
37
38
|
|
|
38
39
|
interface DecodedBody {
|
|
39
40
|
key?: string;
|
|
41
|
+
text?: string;
|
|
40
42
|
params?: ApiErrorParams;
|
|
41
43
|
severity?: ApiErrorSeverity;
|
|
42
44
|
status?: number;
|
|
@@ -47,6 +49,8 @@ export interface DecodedApiFailure {
|
|
|
47
49
|
cancelled: boolean;
|
|
48
50
|
identity: object | null;
|
|
49
51
|
key?: string;
|
|
52
|
+
/** A sentence the server wrote for a refusal (a 4xx), shown as it is. */
|
|
53
|
+
text?: string;
|
|
50
54
|
params?: ApiErrorParams;
|
|
51
55
|
severity: ApiErrorSeverity;
|
|
52
56
|
}
|
|
@@ -93,6 +97,7 @@ function decodeBody(input: FailureInput): DecodedBody {
|
|
|
93
97
|
}
|
|
94
98
|
return {
|
|
95
99
|
key: z.string().safeParse(body.message).data,
|
|
100
|
+
text: z.string().trim().min(1).safeParse(body.text).data,
|
|
96
101
|
severity: severitySchema.safeParse(body.severity).data,
|
|
97
102
|
params: paramsSchema.safeParse(body.params).data,
|
|
98
103
|
status,
|
|
@@ -165,6 +170,9 @@ export function decodeApiFailure(error: FailureInput): DecodedApiFailure {
|
|
|
165
170
|
cancelled: cancelled && !hasFailedResponse,
|
|
166
171
|
identity,
|
|
167
172
|
key: body.key,
|
|
173
|
+
...(body.text &&
|
|
174
|
+
status !== undefined &&
|
|
175
|
+
status <= HTTP_CLIENT_MAX && { text: body.text }),
|
|
168
176
|
params: { ...params, ...body.params },
|
|
169
177
|
severity: severityOf(body, status),
|
|
170
178
|
};
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import type { I18nTranslate } from "../../composables/translation/useTranslation";
|
|
2
|
+
import type { ApiErrorPresenter } from "../../composables/useApiErrorPresenter";
|
|
3
|
+
import { resolveApiErrorMessage } from "../../composables/resolveApiError";
|
|
4
|
+
import {
|
|
5
|
+
isBoolean,
|
|
6
|
+
isNumber,
|
|
7
|
+
isObject,
|
|
8
|
+
isString,
|
|
9
|
+
} from "../../utils/type-check";
|
|
10
|
+
|
|
11
|
+
/** An API error tied to one field, before translation. */
|
|
12
|
+
export interface ApiFieldError {
|
|
13
|
+
/** Id of the field, as the form names it (the request body key). */
|
|
14
|
+
field: string;
|
|
15
|
+
/** Server translation key, resolved by the API error presenter. */
|
|
16
|
+
message: string;
|
|
17
|
+
/**
|
|
18
|
+
* A sentence the server wrote in the reader's language, shown as it is
|
|
19
|
+
* (as text, never as HTML) in place of the translated `message`:
|
|
20
|
+
* `{ field: "iban", text: "This IBAN is not valid." }`.
|
|
21
|
+
*/
|
|
22
|
+
text?: string;
|
|
23
|
+
/** Caller key used only when the server's message is not translated. */
|
|
24
|
+
fallbackKey?: string;
|
|
25
|
+
/** The values of the field the error names (addresses of a list…). */
|
|
26
|
+
values?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Values filling the placeholders of the translated message: a body
|
|
29
|
+
* `{ field: "budget", message: "$page.error.budget_max", params: { max: 5000 } }`
|
|
30
|
+
* shows "At most 5000" for a translation `"At most {max}"`.
|
|
31
|
+
*/
|
|
32
|
+
params?: ApiFieldErrorParams;
|
|
33
|
+
/**
|
|
34
|
+
* The part of the field the error names, as a dotted path from the field
|
|
35
|
+
* (`address.streetName`, `title.fr`); absent when it names the field.
|
|
36
|
+
*/
|
|
37
|
+
path?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Placeholder values of a field error's message. */
|
|
41
|
+
export type ApiFieldErrorParams = Record<string, string | number | boolean>;
|
|
42
|
+
|
|
43
|
+
/** A code the API answers with that belongs to a field. */
|
|
44
|
+
export type FieldErrorCode<F extends string = string> =
|
|
45
|
+
| F
|
|
46
|
+
| {
|
|
47
|
+
field: F;
|
|
48
|
+
/** Shown instead of the code's own text. */
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export interface ResolveFieldErrorsOptions<F extends string = string> {
|
|
53
|
+
/**
|
|
54
|
+
* The fields of the form. An error naming another field (or none) is not
|
|
55
|
+
* one the form can show: it stays a toast.
|
|
56
|
+
*/
|
|
57
|
+
fields: readonly F[];
|
|
58
|
+
/** API error codes (`error.xxx`, `$page.…`) that belong to a field. */
|
|
59
|
+
codes?: Readonly<Record<string, FieldErrorCode<NoInfer<F>>>>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface FieldErrorResolution {
|
|
63
|
+
/** Errors to show under their field. */
|
|
64
|
+
fields: ApiFieldError[];
|
|
65
|
+
/**
|
|
66
|
+
* The error also carries something no field of the form can show (a
|
|
67
|
+
* validation issue on an unknown key): a toast tells about it.
|
|
68
|
+
*/
|
|
69
|
+
hasUnmatched: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface FetchErrorLike {
|
|
73
|
+
statusCode?: number;
|
|
74
|
+
status?: number;
|
|
75
|
+
response?: { status?: number };
|
|
76
|
+
data?: unknown;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface FieldErrorBody {
|
|
80
|
+
field?: unknown;
|
|
81
|
+
message?: unknown;
|
|
82
|
+
text?: unknown;
|
|
83
|
+
values?: unknown;
|
|
84
|
+
params?: unknown;
|
|
85
|
+
code?: unknown;
|
|
86
|
+
fields?: unknown;
|
|
87
|
+
issues?: unknown;
|
|
88
|
+
errors?: unknown;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A zod issue, as the API serializes it or as zod hands it to an error map. */
|
|
92
|
+
export interface ValidationIssue {
|
|
93
|
+
path?: unknown;
|
|
94
|
+
message?: unknown;
|
|
95
|
+
code?: unknown;
|
|
96
|
+
format?: unknown;
|
|
97
|
+
minimum?: unknown;
|
|
98
|
+
origin?: unknown;
|
|
99
|
+
/** zod 3's `origin`, in an issue list a module still on zod 3 sends. */
|
|
100
|
+
type?: unknown;
|
|
101
|
+
/** zod 3's `format`, in an issue list a module still on zod 3 sends. */
|
|
102
|
+
validation?: unknown;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** What a size issue measured, as zod 4 (`origin`) or zod 3 (`type`) names it. */
|
|
106
|
+
function sizeOrigin(issue: ValidationIssue): string | undefined {
|
|
107
|
+
const origin = issue.origin ?? issue.type;
|
|
108
|
+
return origin === undefined ? undefined : String(origin);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const HTTP_BAD_REQUEST = 400;
|
|
112
|
+
const HTTP_CONFLICT = 409;
|
|
113
|
+
const HTTP_UNPROCESSABLE = 422;
|
|
114
|
+
const HTTP_FORBIDDEN = 403;
|
|
115
|
+
const HTTP_TOO_MANY_REQUESTS = 429;
|
|
116
|
+
const HTTP_CLIENT_ERROR_MIN = 400;
|
|
117
|
+
const HTTP_CLIENT_ERROR_MAX = 499;
|
|
118
|
+
|
|
119
|
+
/** Statuses whose body may name the field it refuses. */
|
|
120
|
+
const VALIDATION_STATUSES = new Set([
|
|
121
|
+
HTTP_BAD_REQUEST,
|
|
122
|
+
HTTP_CONFLICT,
|
|
123
|
+
HTTP_UNPROCESSABLE,
|
|
124
|
+
]);
|
|
125
|
+
|
|
126
|
+
/** Never about a field, whatever the body says. */
|
|
127
|
+
const GLOBAL_STATUSES = new Set([HTTP_FORBIDDEN, HTTP_TOO_MANY_REQUESTS]);
|
|
128
|
+
|
|
129
|
+
const FIELD_ERROR_KEYS = {
|
|
130
|
+
required: "$dms.field_errors.required",
|
|
131
|
+
invalid: "$dms.field_errors.invalid",
|
|
132
|
+
invalidEmail: "$dms.field_errors.invalid_email",
|
|
133
|
+
tooLong: "$dms.field_errors.too_long",
|
|
134
|
+
tooShort: "$dms.field_errors.too_short",
|
|
135
|
+
tooSmall: "$dms.field_errors.too_small",
|
|
136
|
+
tooLarge: "$dms.field_errors.too_large",
|
|
137
|
+
} as const;
|
|
138
|
+
|
|
139
|
+
/** Issue origins whose size is a count (characters, items), not a value. */
|
|
140
|
+
const COUNTED_ORIGINS = new Set(["string", "array", "set"]);
|
|
141
|
+
|
|
142
|
+
const DATA_API_CODES: Readonly<
|
|
143
|
+
Record<ReturnType<typeof resolveApiErrorMessage>, ApiFieldError["message"]>
|
|
144
|
+
> = {
|
|
145
|
+
missing_mandatory_fields: FIELD_ERROR_KEYS.required,
|
|
146
|
+
invalid_field_types: FIELD_ERROR_KEYS.invalid,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const NAMED_FIELD_ERROR_KEYS: Readonly<
|
|
150
|
+
Record<ApiFieldError["message"], Parameters<I18nTranslate>[0]>
|
|
151
|
+
> = {
|
|
152
|
+
[FIELD_ERROR_KEYS.required]: "dms.field_errors.named_required",
|
|
153
|
+
[FIELD_ERROR_KEYS.invalid]: "dms.field_errors.named_invalid",
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const FIELD_PREFIXED_MESSAGE = /^([\w.]+):\s+(\S.*|\s)$/s;
|
|
157
|
+
|
|
158
|
+
const BARE_I18N_KEY = /^\w+(?:\.\w+)+$/;
|
|
159
|
+
|
|
160
|
+
/** The HTTP status of a fetch error; undefined for a network failure. */
|
|
161
|
+
export function apiErrorStatus(
|
|
162
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
163
|
+
): number | undefined {
|
|
164
|
+
if (!isObject(error) || error === null) return undefined;
|
|
165
|
+
const { statusCode, status, response }: FetchErrorLike = error;
|
|
166
|
+
return statusCode ?? status ?? response?.status;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The error body, parsed when the server sent JSON as plain text. */
|
|
170
|
+
function bodyOf(
|
|
171
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
172
|
+
): FetchErrorLike["data"] {
|
|
173
|
+
if (!isObject(error) || error === null) return undefined;
|
|
174
|
+
const { data } = error;
|
|
175
|
+
if (!isString(data)) return data;
|
|
176
|
+
const text = data.trim();
|
|
177
|
+
if (!text.startsWith("[") && !text.startsWith("{")) return data;
|
|
178
|
+
try {
|
|
179
|
+
return JSON.parse(text);
|
|
180
|
+
} catch {
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Whether a message is an i18n key rather than (English) prose. */
|
|
186
|
+
function isI18nKey(message: string): boolean {
|
|
187
|
+
return message.startsWith("$") || BARE_I18N_KEY.test(message);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** A zod issue's own message when it is a key, else a generic one. */
|
|
191
|
+
function tooSmallMessage(issue: ValidationIssue): string {
|
|
192
|
+
const origin = sizeOrigin(issue);
|
|
193
|
+
if (origin !== undefined && !COUNTED_ORIGINS.has(origin)) {
|
|
194
|
+
return FIELD_ERROR_KEYS.tooSmall;
|
|
195
|
+
}
|
|
196
|
+
return isNumber(issue.minimum) && issue.minimum <= 1
|
|
197
|
+
? FIELD_ERROR_KEYS.required
|
|
198
|
+
: FIELD_ERROR_KEYS.tooShort;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The message of a zod issue: its own when it is an i18n key, else a generic
|
|
203
|
+
* `$dms.field_errors.*` key by issue code (zod words its own in English).
|
|
204
|
+
*/
|
|
205
|
+
export function validationIssueMessage(issue: ValidationIssue): string {
|
|
206
|
+
if (isString(issue.message) && isI18nKey(issue.message)) {
|
|
207
|
+
return issue.message;
|
|
208
|
+
}
|
|
209
|
+
switch (issue.code) {
|
|
210
|
+
case "too_small":
|
|
211
|
+
return tooSmallMessage(issue);
|
|
212
|
+
case "too_big": {
|
|
213
|
+
const origin = sizeOrigin(issue);
|
|
214
|
+
return origin !== undefined && !COUNTED_ORIGINS.has(origin)
|
|
215
|
+
? FIELD_ERROR_KEYS.tooLarge
|
|
216
|
+
: FIELD_ERROR_KEYS.tooLong;
|
|
217
|
+
}
|
|
218
|
+
case "invalid_format":
|
|
219
|
+
case "invalid_string":
|
|
220
|
+
return (issue.format ?? issue.validation) === "email"
|
|
221
|
+
? FIELD_ERROR_KEYS.invalidEmail
|
|
222
|
+
: FIELD_ERROR_KEYS.invalid;
|
|
223
|
+
default:
|
|
224
|
+
return FIELD_ERROR_KEYS.invalid;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type PathedIssue = ValidationIssue & { path: unknown[] };
|
|
229
|
+
|
|
230
|
+
function isIssueList(
|
|
231
|
+
body: ReturnType<typeof bodyOf>,
|
|
232
|
+
): body is [PathedIssue, ...PathedIssue[]] {
|
|
233
|
+
return (
|
|
234
|
+
Array.isArray(body) &&
|
|
235
|
+
body.length > 0 &&
|
|
236
|
+
body.every(
|
|
237
|
+
(issue) => isObject(issue) && issue !== null && Array.isArray(issue.path),
|
|
238
|
+
)
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** `field.part.0` for a path reaching into a field, else undefined. */
|
|
243
|
+
function partPath(path: readonly unknown[]): string | undefined {
|
|
244
|
+
if (path.length < 2) return undefined;
|
|
245
|
+
return path.every((step) => isString(step) || isNumber(step))
|
|
246
|
+
? path.join(".")
|
|
247
|
+
: undefined;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function fromIssues(issues: PathedIssue[]): ApiFieldError[] {
|
|
251
|
+
return issues.map((issue) => {
|
|
252
|
+
const path = issue.path;
|
|
253
|
+
const [field] = path;
|
|
254
|
+
const part = partPath(path);
|
|
255
|
+
return {
|
|
256
|
+
field: isString(field) ? field : "",
|
|
257
|
+
message: validationIssueMessage(issue),
|
|
258
|
+
...(part && { path: part }),
|
|
259
|
+
};
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The placeholder values of a body, keeping only the plain ones. */
|
|
264
|
+
function paramsOf(
|
|
265
|
+
params: FieldErrorBody["params"],
|
|
266
|
+
): ApiFieldErrorParams | undefined {
|
|
267
|
+
if (!isObject(params) || params === null || Array.isArray(params)) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
const entries = Object.entries(params).filter(
|
|
271
|
+
(entry): entry is [string, ApiFieldErrorParams[string]] =>
|
|
272
|
+
isString(entry[1]) || isNumber(entry[1]) || isBoolean(entry[1]),
|
|
273
|
+
);
|
|
274
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** A body's `text`, when it holds a sentence to show. */
|
|
278
|
+
function sentenceOf(text: FieldErrorBody["text"]): string | undefined {
|
|
279
|
+
return isString(text) && text.trim() ? text.trim() : undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* `{ field, message, values?, params? }`, the shape the DMS answers with, or
|
|
284
|
+
* `{ field, text }` with a sentence of the server's own.
|
|
285
|
+
*/
|
|
286
|
+
function fromFieldObject(body: FieldErrorBody): ApiFieldError[] {
|
|
287
|
+
const { field, message, values, params } = body;
|
|
288
|
+
const text = sentenceOf(body.text);
|
|
289
|
+
if (!isString(field) || (!isString(message) && !text)) return [];
|
|
290
|
+
const placeholders = paramsOf(params);
|
|
291
|
+
return [
|
|
292
|
+
{
|
|
293
|
+
field,
|
|
294
|
+
message: isString(message) ? message : FIELD_ERROR_KEYS.invalid,
|
|
295
|
+
...(text && { text }),
|
|
296
|
+
values: Array.isArray(values) ? values.filter(isString) : undefined,
|
|
297
|
+
...(placeholders && { params: placeholders }),
|
|
298
|
+
},
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** `{ code, fields }`, the data API's refusal of a body; undefined otherwise. */
|
|
303
|
+
function fromCodedFields(body: FieldErrorBody): ApiFieldError[] | undefined {
|
|
304
|
+
const { code, fields } = body;
|
|
305
|
+
const message = isString(code) ? DATA_API_CODES[code] : undefined;
|
|
306
|
+
if (!message || !Array.isArray(fields)) return undefined;
|
|
307
|
+
return fields.filter(isString).map((field) => ({ field, message }));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function fromText(text: string): ApiFieldError[] {
|
|
311
|
+
const prefixed = FIELD_PREFIXED_MESSAGE.exec(text);
|
|
312
|
+
if (prefixed) {
|
|
313
|
+
const [, field = "", message = ""] = prefixed;
|
|
314
|
+
const path = field.split(".");
|
|
315
|
+
const part = partPath(path);
|
|
316
|
+
return [
|
|
317
|
+
{
|
|
318
|
+
field: path[0] ?? field,
|
|
319
|
+
message: isI18nKey(message) ? message : FIELD_ERROR_KEYS.invalid,
|
|
320
|
+
...(part && { path: part }),
|
|
321
|
+
},
|
|
322
|
+
];
|
|
323
|
+
}
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** The text code of an error body: the body itself or its `message`. */
|
|
328
|
+
function codeOf(body: ReturnType<typeof bodyOf>): string | undefined {
|
|
329
|
+
if (isString(body)) return body;
|
|
330
|
+
if (isObject(body) && body !== null && !Array.isArray(body)) {
|
|
331
|
+
const { message } = body;
|
|
332
|
+
return isString(message) ? message : undefined;
|
|
333
|
+
}
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function lookupCode<F extends string>(
|
|
338
|
+
body: ReturnType<typeof bodyOf>,
|
|
339
|
+
codes: Readonly<Record<string, FieldErrorCode<F>>> | undefined,
|
|
340
|
+
): ApiFieldError | undefined {
|
|
341
|
+
const code = codeOf(body);
|
|
342
|
+
if (!code || !codes) return undefined;
|
|
343
|
+
const bare = code.startsWith("$") ? code.slice(1) : code;
|
|
344
|
+
const own = (key: string) =>
|
|
345
|
+
Object.hasOwn(codes, key) ? codes[key] : undefined;
|
|
346
|
+
const entry = own(code) ?? own(bare) ?? own(`$${bare}`);
|
|
347
|
+
if (!entry) return undefined;
|
|
348
|
+
const record: FieldErrorBody = isObject(body) && body !== null ? body : {};
|
|
349
|
+
const text = sentenceOf(record.text);
|
|
350
|
+
return {
|
|
351
|
+
...(isString(entry)
|
|
352
|
+
? { field: entry, message: code }
|
|
353
|
+
: { field: entry.field, message: code, fallbackKey: entry.message }),
|
|
354
|
+
...(text && { text }),
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function fromBody(body: ReturnType<typeof bodyOf>): ApiFieldError[] {
|
|
359
|
+
if (isIssueList(body)) return fromIssues(body);
|
|
360
|
+
if (isString(body)) return fromText(body);
|
|
361
|
+
if (!isObject(body) || body === null) return [];
|
|
362
|
+
const record: FieldErrorBody = body;
|
|
363
|
+
if (isIssueList(record.issues)) return fromIssues(record.issues);
|
|
364
|
+
if (isIssueList(record.errors)) return fromIssues(record.errors);
|
|
365
|
+
return fromCodedFields(record) ?? fromFieldObject(record);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function isClientError(status: number | undefined): status is number {
|
|
369
|
+
return (
|
|
370
|
+
status !== undefined &&
|
|
371
|
+
status >= HTTP_CLIENT_ERROR_MIN &&
|
|
372
|
+
status <= HTTP_CLIENT_ERROR_MAX &&
|
|
373
|
+
!GLOBAL_STATUSES.has(status)
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Splits what a request threw into the errors its form shows under fields.
|
|
379
|
+
*
|
|
380
|
+
* Read, in order: a code the form maps to a field (`codes`, for any 4xx), a
|
|
381
|
+
* zod issue list (what `assertValidation` answers), a `{ field, message }`
|
|
382
|
+
* body (with optional `text`, `values` and `params`), the data API's
|
|
383
|
+
* `{ code, fields }` and a `field: message` text. A network failure, a 403, a 429
|
|
384
|
+
* or a 5xx never resolves to a field.
|
|
385
|
+
*
|
|
386
|
+
* @returns The field errors, one per field (the first issue wins), and
|
|
387
|
+
* whether part of the error belongs to no field of the form
|
|
388
|
+
*/
|
|
389
|
+
export function resolveFieldErrors<F extends string>(
|
|
390
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
391
|
+
options: ResolveFieldErrorsOptions<F>,
|
|
392
|
+
): FieldErrorResolution {
|
|
393
|
+
const status = apiErrorStatus(error);
|
|
394
|
+
if (!isClientError(status)) return { fields: [], hasUnmatched: true };
|
|
395
|
+
const body = bodyOf(error);
|
|
396
|
+
const mapped = lookupCode(body, options.codes);
|
|
397
|
+
const candidates = mapped
|
|
398
|
+
? [mapped]
|
|
399
|
+
: VALIDATION_STATUSES.has(status)
|
|
400
|
+
? fromBody(body)
|
|
401
|
+
: [];
|
|
402
|
+
const known = new Set<string>(options.fields);
|
|
403
|
+
const fields: ApiFieldError[] = [];
|
|
404
|
+
let hasUnmatched = candidates.length === 0;
|
|
405
|
+
for (const candidate of candidates) {
|
|
406
|
+
if (!known.has(candidate.field)) {
|
|
407
|
+
hasUnmatched = true;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (fields.some((entry) => entry.field === candidate.field)) continue;
|
|
411
|
+
fields.push(candidate);
|
|
412
|
+
}
|
|
413
|
+
return { fields, hasUnmatched: hasUnmatched || fields.length === 0 };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* The sentence a field error shows: the server's own `text`, else its
|
|
418
|
+
* `message` translated (its `fallbackKey`, else the generic invalid value,
|
|
419
|
+
* when no translation is loaded).
|
|
420
|
+
*/
|
|
421
|
+
export function fieldErrorMessage(
|
|
422
|
+
entry: Pick<ApiFieldError, "message" | "text" | "fallbackKey" | "params">,
|
|
423
|
+
resolveError: ApiErrorPresenter["resolveError"],
|
|
424
|
+
): string | undefined {
|
|
425
|
+
if (entry.text) return entry.text;
|
|
426
|
+
return resolveError(entry.message, {
|
|
427
|
+
fallbackKey: entry.fallbackKey ?? "dms.field_errors.invalid",
|
|
428
|
+
params: entry.params,
|
|
429
|
+
})?.message;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The data API's refusal of a body (`{ code, fields }`) as one sentence per
|
|
434
|
+
* field naming it, translated: "Loss reason is required." Undefined for any
|
|
435
|
+
* other error. `labelOf` gives a field's label, translated; the field's id
|
|
436
|
+
* stands in for one it does not know.
|
|
437
|
+
*/
|
|
438
|
+
export function describeFieldErrors(
|
|
439
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
440
|
+
translate: I18nTranslate,
|
|
441
|
+
labelOf: (field: string) => string | undefined,
|
|
442
|
+
): string | undefined {
|
|
443
|
+
const status = apiErrorStatus(error);
|
|
444
|
+
if (status === undefined || !VALIDATION_STATUSES.has(status)) {
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
const body = bodyOf(error);
|
|
448
|
+
if (!isObject(body) || body === null || Array.isArray(body)) {
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
const entries = fromCodedFields(body);
|
|
452
|
+
if (!entries?.length) return undefined;
|
|
453
|
+
return entries
|
|
454
|
+
.map(({ field, message }) =>
|
|
455
|
+
translate(NAMED_FIELD_ERROR_KEYS[message] ?? message, {
|
|
456
|
+
field: labelOf(field) ?? field,
|
|
457
|
+
}),
|
|
458
|
+
)
|
|
459
|
+
.join(" ");
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The message of an error that belongs to no field, for its toast: the API's
|
|
464
|
+
* message key, the first validation issue's (or a generic one), else the
|
|
465
|
+
* generic server error.
|
|
466
|
+
*/
|
|
467
|
+
export function describeApiError(
|
|
468
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
469
|
+
): string {
|
|
470
|
+
return apiErrorText(error) ?? resolveApiErrorMessage(error);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* The message an error body carries (its text, its `message`, or its first
|
|
475
|
+
* validation issue's), or `undefined` when it carries none (a network
|
|
476
|
+
* failure).
|
|
477
|
+
*/
|
|
478
|
+
export function apiErrorText(
|
|
479
|
+
error: Parameters<typeof resolveApiErrorMessage>[0],
|
|
480
|
+
): string | undefined {
|
|
481
|
+
const body = bodyOf(error);
|
|
482
|
+
if (isIssueList(body)) return validationIssueMessage(body[0]);
|
|
483
|
+
const text = codeOf(body);
|
|
484
|
+
return text || undefined;
|
|
485
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getCurrentInstance, onMounted, shallowRef, type Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether the component's handlers are live in the browser.
|
|
5
|
+
*
|
|
6
|
+
* A server-rendered form is live HTML before the browser hydrates it: a
|
|
7
|
+
* submit in that window (a slow device, a script still loading) is a native
|
|
8
|
+
* POST of the page URL, which no server answers with the page. A submit
|
|
9
|
+
* button bound to this stays `disabled` in the server's HTML and in the
|
|
10
|
+
* render that hydrates it, which must match, and comes alive on mount: the
|
|
11
|
+
* implicit submission of the Enter key follows the default button, so it
|
|
12
|
+
* waits too. A page the browser creates outside a hydration (a client
|
|
13
|
+
* navigation) has no server HTML to match and starts live, as does a call
|
|
14
|
+
* outside a component.
|
|
15
|
+
*/
|
|
16
|
+
export function useHydrated(): Readonly<Ref<boolean>> {
|
|
17
|
+
const inComponent = getCurrentInstance() !== null;
|
|
18
|
+
const hydrated = shallowRef(
|
|
19
|
+
!inComponent || (!import.meta.env.SSR && !isDmsHydrating()),
|
|
20
|
+
);
|
|
21
|
+
if (!hydrated.value) {
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
hydrated.value = true;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return hydrated;
|
|
27
|
+
}
|
|
@@ -8,8 +8,9 @@ export type RecordWithDefault<T> = Record<string, T> & { default: T };
|
|
|
8
8
|
* fields; it is absent elsewhere (forms, filters) and must be optional.
|
|
9
9
|
*
|
|
10
10
|
* Keys of a data type's `formatter` record: `default` (required), `cell` (a
|
|
11
|
-
* shorter grid rendering), `
|
|
12
|
-
*
|
|
11
|
+
* shorter grid rendering), `full` (the whole value, for a `fullWidth` field of
|
|
12
|
+
* a detail band), `empty` (drawn instead of the fallback for a null/undefined
|
|
13
|
+
* value), and one per compare mode for filter chips.
|
|
13
14
|
*
|
|
14
15
|
* @typeParam Value - What a field of the row holds, the formatted one included.
|
|
15
16
|
* @typeParam Options - The options of the field's control.
|