create-react-admin-template 0.0.0-stage → 0.1.0
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/README.md +46 -2
- package/bin/create.mjs +5 -0
- package/package.json +22 -4
- package/template/.dockerignore +12 -0
- package/template/.editorconfig +12 -0
- package/template/.env +14 -0
- package/template/.env.development +5 -0
- package/template/.env.production +2 -0
- package/template/.env.test +5 -0
- package/template/.github/workflows/ci.yml +40 -0
- package/template/.gitlab-ci.yml +208 -0
- package/template/.husky/commit-msg +1 -0
- package/template/.husky/pre-commit +1 -0
- package/template/.nvmrc +1 -0
- package/template/.prettierignore +11 -0
- package/template/.prettierrc +47 -0
- package/template/Dockerfile +16 -0
- package/template/README.md +372 -0
- package/template/build/advancedTable.ts +103 -0
- package/template/build/environment.ts +150 -0
- package/template/commitlint.config.js +32 -0
- package/template/components.json +21 -0
- package/template/deploy/README.md +132 -0
- package/template/deploy/host-nginx/react-admin-api.conf +14 -0
- package/template/deploy/host-nginx/react-admin-web.conf +8 -0
- package/template/deploy/nginx.conf +38 -0
- package/template/docs/activity-status.md +217 -0
- package/template/docs/audit-logs.md +158 -0
- package/template/docs/authentication-adapters.md +219 -0
- package/template/docs/browser-security.md +58 -0
- package/template/docs/bundle-budgets.md +65 -0
- package/template/docs/component-source-governance.md +99 -0
- package/template/docs/data-masking.md +169 -0
- package/template/docs/enterprise-scaffold.md +208 -0
- package/template/docs/feature-data-template.md +227 -0
- package/template/docs/feature-flags.md +169 -0
- package/template/docs/file-capabilities.md +196 -0
- package/template/docs/locale-and-i18n.md +132 -0
- package/template/docs/mutation-idempotency.md +24 -0
- package/template/docs/optional-editors.md +203 -0
- package/template/docs/page-feedback.md +83 -0
- package/template/docs/query-data-conventions.md +178 -0
- package/template/docs/realtime-collaboration.md +140 -0
- package/template/docs/reporting-printing-templates.md +156 -0
- package/template/docs/scaffold-capability-roadmap.md +226 -0
- package/template/docs/scaffold-guide.md +443 -0
- package/template/docs/template-changelog.md +30 -0
- package/template/docs/template-versioning.md +26 -0
- package/template/docs/tenant-workspace-context.md +147 -0
- package/template/docs/unsaved-changes.md +58 -0
- package/template/docs/white-label.md +102 -0
- package/template/eslint.config.js +697 -0
- package/template/gitignore +39 -0
- package/template/index.html +26 -0
- package/template/knip.config.ts +42 -0
- package/template/lint-staged.config.js +8 -0
- package/template/package.json +133 -0
- package/template/pnpm-lock.yaml +8694 -0
- package/template/public/favicon.ico +0 -0
- package/template/public/logo.svg +1 -0
- package/template/public/runtime-config.json +49 -0
- package/template/scaffold.template.json +5 -0
- package/template/src/Application.tsx +114 -0
- package/template/src/api/ApiError.ts +33 -0
- package/template/src/api/activity/ActivityProvider.tsx +167 -0
- package/template/src/api/activity/access.ts +13 -0
- package/template/src/api/activity/errors.ts +17 -0
- package/template/src/api/activity/index.ts +67 -0
- package/template/src/api/activity/model.ts +227 -0
- package/template/src/api/activity/query.ts +163 -0
- package/template/src/api/activity/source.ts +16 -0
- package/template/src/api/activity/subscription.ts +292 -0
- package/template/src/api/activity/transports.ts +271 -0
- package/template/src/api/activity/types.ts +402 -0
- package/template/src/api/authClient.ts +134 -0
- package/template/src/api/authSession.ts +307 -0
- package/template/src/api/clients/configureApiClient.ts +62 -0
- package/template/src/api/clients/httpStatus.ts +4 -0
- package/template/src/api/config/services.json +7 -0
- package/template/src/api/demoAuthClient.ts +46 -0
- package/template/src/api/enums/EnumCatalogProvider.tsx +169 -0
- package/template/src/api/enums/EnumDictionary.ts +55 -0
- package/template/src/api/enums/access.ts +130 -0
- package/template/src/api/enums/catalog.ts +216 -0
- package/template/src/api/enums/errors.ts +21 -0
- package/template/src/api/enums/index.ts +48 -0
- package/template/src/api/enums/query.ts +82 -0
- package/template/src/api/enums/scope.ts +58 -0
- package/template/src/api/enums/types.ts +251 -0
- package/template/src/api/hooks/error.ts +198 -0
- package/template/src/api/hooks/index.ts +4 -0
- package/template/src/api/hooks/request.ts +99 -0
- package/template/src/api/hooks/requestId.ts +65 -0
- package/template/src/api/hooks/response.ts +22 -0
- package/template/src/api/hooks/types.ts +20 -0
- package/template/src/api/idempotency/index.ts +1 -0
- package/template/src/api/idempotency/key.ts +23 -0
- package/template/src/api/index.ts +14 -0
- package/template/src/api/metadata/MetadataProvider.tsx +37 -0
- package/template/src/api/metadata/index.ts +2 -0
- package/template/src/api/metadata/types.ts +30 -0
- package/template/src/api/parameters/GlobalParameterProvider.tsx +210 -0
- package/template/src/api/parameters/access.ts +117 -0
- package/template/src/api/parameters/catalog.ts +170 -0
- package/template/src/api/parameters/errors.ts +21 -0
- package/template/src/api/parameters/index.ts +53 -0
- package/template/src/api/parameters/query.ts +84 -0
- package/template/src/api/parameters/scope.ts +58 -0
- package/template/src/api/parameters/types.ts +214 -0
- package/template/src/api/query/index.ts +13 -0
- package/template/src/api/query/keys.ts +155 -0
- package/template/src/api/query/mutation.ts +48 -0
- package/template/src/api/query/react.ts +36 -0
- package/template/src/api/query/scope.ts +38 -0
- package/template/src/api/query/types.ts +147 -0
- package/template/src/api/types.ts +144 -0
- package/template/src/application/types.ts +52 -0
- package/template/src/auditLogs/errors.ts +17 -0
- package/template/src/auditLogs/export.ts +85 -0
- package/template/src/auditLogs/index.ts +54 -0
- package/template/src/auditLogs/model.ts +526 -0
- package/template/src/auditLogs/query.ts +113 -0
- package/template/src/auditLogs/react.ts +36 -0
- package/template/src/auditLogs/source.ts +51 -0
- package/template/src/auditLogs/types.ts +357 -0
- package/template/src/authentication/controller.ts +351 -0
- package/template/src/authentication/index.ts +8 -0
- package/template/src/authentication/redirect.ts +72 -0
- package/template/src/authentication/types.ts +300 -0
- package/template/src/bootstrap.tsx +96 -0
- package/template/src/components/AppDataTable/AppDataTable.tsx +74 -0
- package/template/src/components/AppDataTable/index.ts +2 -0
- package/template/src/components/AppDataTable/types.ts +27 -0
- package/template/src/components/AppDialog/AppConfirmDialog.tsx +44 -0
- package/template/src/components/AppDialog/AppDialog.tsx +113 -0
- package/template/src/components/AppDialog/index.ts +3 -0
- package/template/src/components/AppDialog/messages.tsx +22 -0
- package/template/src/components/AppDialog/types.ts +53 -0
- package/template/src/components/AppPageForm/AppPageForm.tsx +21 -0
- package/template/src/components/AppPageForm/PageForm.tsx +765 -0
- package/template/src/components/AppPageForm/SOURCE.md +26 -0
- package/template/src/components/AppPageForm/config.ts +253 -0
- package/template/src/components/AppPageForm/controller.ts +580 -0
- package/template/src/components/AppPageForm/index.ts +2 -0
- package/template/src/components/AppPageForm/messages.ts +90 -0
- package/template/src/components/AppPageForm/optionUtils.ts +91 -0
- package/template/src/components/AppPageForm/options.ts +397 -0
- package/template/src/components/AppPageForm/query.ts +44 -0
- package/template/src/components/AppPageForm/style.css +119 -0
- package/template/src/components/AppPageForm/types.ts +632 -0
- package/template/src/components/AppPageForm/validation.ts +233 -0
- package/template/src/components/AppTable/AppTable.tsx +26 -0
- package/template/src/components/AppTable/SOURCE.md +72 -0
- package/template/src/components/AppTable/cell/customCell/TableCellLayer.tsx +73 -0
- package/template/src/components/AppTable/cell/customCell/actions/ActionDropdownCell.tsx +104 -0
- package/template/src/components/AppTable/cell/customCell/cellLayer.ts +358 -0
- package/template/src/components/AppTable/cell/customCell/componentProps.ts +30 -0
- package/template/src/components/AppTable/cell/customCell/date/TemporalPickerEditor.tsx +54 -0
- package/template/src/components/AppTable/cell/customCell/index.ts +2 -0
- package/template/src/components/AppTable/cell/customCell/select/SelectCellEditor.tsx +225 -0
- package/template/src/components/AppTable/cell/customCell/tableCellLayer.css +20 -0
- package/template/src/components/AppTable/cell/customCell/tooltip/TooltipCell.tsx +45 -0
- package/template/src/components/AppTable/cell/customCell/types.ts +63 -0
- package/template/src/components/AppTable/cell/customCell/useCellLayerLifecycle.ts +111 -0
- package/template/src/components/AppTable/cell/frameworkCell/TableCellComponentLayer.tsx +40 -0
- package/template/src/components/AppTable/cell/frameworkCell/cellComponentSession.ts +203 -0
- package/template/src/components/AppTable/cell/frameworkCell/index.ts +3 -0
- package/template/src/components/AppTable/cell/index.ts +2 -0
- package/template/src/components/AppTable/columns/TableColumnEditor.tsx +257 -0
- package/template/src/components/AppTable/columns/index.ts +1 -0
- package/template/src/components/AppTable/columns/useTableColumnPreferenceActions.ts +85 -0
- package/template/src/components/AppTable/config/defaults.ts +46 -0
- package/template/src/components/AppTable/config/index.ts +2 -0
- package/template/src/components/AppTable/config/license.ts +39 -0
- package/template/src/components/AppTable/config/resolver.ts +25 -0
- package/template/src/components/AppTable/config/types.ts +377 -0
- package/template/src/components/AppTable/engine/bottom/index.ts +1 -0
- package/template/src/components/AppTable/engine/bottom/types.ts +14 -0
- package/template/src/components/AppTable/engine/cell/constants.ts +32 -0
- package/template/src/components/AppTable/engine/cell/customCell/actions/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/actions/renderer.ts +162 -0
- package/template/src/components/AppTable/engine/cell/customCell/date/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/date/renderer.ts +116 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/editorBounds.ts +57 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/editorTrigger.ts +46 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/index.ts +3 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/layerEditor.ts +244 -0
- package/template/src/components/AppTable/engine/cell/customCell/index.ts +7 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/columnRenderer.ts +245 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/confirmInput.ts +57 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/display.ts +78 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/index.ts +3 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/itemList.ts +60 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/links.ts +131 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/selection.ts +41 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/shared.ts +71 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/step.ts +37 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/switch.ts +45 -0
- package/template/src/components/AppTable/engine/cell/customCell/select/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/select/renderer.ts +33 -0
- package/template/src/components/AppTable/engine/cell/customCell/tooltip/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/tooltip/tooltip.ts +94 -0
- package/template/src/components/AppTable/engine/cell/customCell/types.ts +82 -0
- package/template/src/components/AppTable/engine/cell/formatting.ts +355 -0
- package/template/src/components/AppTable/engine/cell/formula.ts +145 -0
- package/template/src/components/AppTable/engine/cell/index.ts +7 -0
- package/template/src/components/AppTable/engine/cell/multiSelect.ts +96 -0
- package/template/src/components/AppTable/engine/cell/options.ts +339 -0
- package/template/src/components/AppTable/engine/cell/types.ts +53 -0
- package/template/src/components/AppTable/engine/columns/column.ts +430 -0
- package/template/src/components/AppTable/engine/columns/config/columns.ts +33 -0
- package/template/src/components/AppTable/engine/columns/config/index.ts +4 -0
- package/template/src/components/AppTable/engine/columns/config/mutation.ts +138 -0
- package/template/src/components/AppTable/engine/columns/config/temporal.ts +11 -0
- package/template/src/components/AppTable/engine/columns/config/validation.ts +106 -0
- package/template/src/components/AppTable/engine/columns/constants.ts +6 -0
- package/template/src/components/AppTable/engine/columns/gridColumns.ts +332 -0
- package/template/src/components/AppTable/engine/columns/index.ts +4 -0
- package/template/src/components/AppTable/engine/columns/rendererPolicies.ts +129 -0
- package/template/src/components/AppTable/engine/component/resolver.ts +272 -0
- package/template/src/components/AppTable/engine/component/types.ts +384 -0
- package/template/src/components/AppTable/engine/config/constants.ts +33 -0
- package/template/src/components/AppTable/engine/config/grid/compiler.ts +65 -0
- package/template/src/components/AppTable/engine/config/grid/defaults.ts +82 -0
- package/template/src/components/AppTable/engine/config/grid/ownership.ts +35 -0
- package/template/src/components/AppTable/engine/config/grid/runtimeDelta.ts +34 -0
- package/template/src/components/AppTable/engine/config/grid/types.ts +30 -0
- package/template/src/components/AppTable/engine/pagination/config.ts +75 -0
- package/template/src/components/AppTable/engine/pagination/constants.ts +5 -0
- package/template/src/components/AppTable/engine/pagination/index.ts +3 -0
- package/template/src/components/AppTable/engine/pagination/types.ts +70 -0
- package/template/src/components/AppTable/engine/preference/index.ts +2 -0
- package/template/src/components/AppTable/engine/preference/preference.ts +535 -0
- package/template/src/components/AppTable/engine/preference/types.ts +28 -0
- package/template/src/components/AppTable/engine/right/index.ts +1 -0
- package/template/src/components/AppTable/engine/right/types.ts +18 -0
- package/template/src/components/AppTable/engine/search/config.ts +64 -0
- package/template/src/components/AppTable/engine/search/constants.ts +8 -0
- package/template/src/components/AppTable/engine/search/index.ts +7 -0
- package/template/src/components/AppTable/engine/search/localQuery.ts +145 -0
- package/template/src/components/AppTable/engine/search/query.ts +203 -0
- package/template/src/components/AppTable/engine/search/remoteQuery.ts +99 -0
- package/template/src/components/AppTable/engine/search/searchInteraction.ts +46 -0
- package/template/src/components/AppTable/engine/search/types.ts +155 -0
- package/template/src/components/AppTable/engine/selection/config.ts +13 -0
- package/template/src/components/AppTable/engine/selection/index.ts +4 -0
- package/template/src/components/AppTable/engine/selection/selection.ts +357 -0
- package/template/src/components/AppTable/engine/selection/selectionHeader.ts +88 -0
- package/template/src/components/AppTable/engine/selection/types.ts +66 -0
- package/template/src/components/AppTable/engine/shared/action.ts +11 -0
- package/template/src/components/AppTable/engine/shared/constants.ts +2 -0
- package/template/src/components/AppTable/engine/shared/decimal.ts +114 -0
- package/template/src/components/AppTable/engine/shared/feedback.ts +62 -0
- package/template/src/components/AppTable/engine/shared/index.ts +13 -0
- package/template/src/components/AppTable/engine/shared/interaction.ts +55 -0
- package/template/src/components/AppTable/engine/shared/messages.ts +161 -0
- package/template/src/components/AppTable/engine/shared/row.ts +32 -0
- package/template/src/components/AppTable/engine/shared/scheduler.ts +17 -0
- package/template/src/components/AppTable/engine/shared/tableKey.ts +31 -0
- package/template/src/components/AppTable/engine/shared/theme.ts +196 -0
- package/template/src/components/AppTable/engine/shared/treeRows.ts +155 -0
- package/template/src/components/AppTable/engine/shared/types.ts +58 -0
- package/template/src/components/AppTable/engine/shared/valueSnapshot.ts +46 -0
- package/template/src/components/AppTable/engine/summary/config/export.ts +117 -0
- package/template/src/components/AppTable/engine/summary/config/index.ts +3 -0
- package/template/src/components/AppTable/engine/summary/config/summary.ts +62 -0
- package/template/src/components/AppTable/engine/summary/config/types.ts +93 -0
- package/template/src/components/AppTable/engine/summary/constants.ts +13 -0
- package/template/src/components/AppTable/engine/summary/excelJs.ts +133 -0
- package/template/src/components/AppTable/engine/summary/export.ts +311 -0
- package/template/src/components/AppTable/engine/summary/index.ts +6 -0
- package/template/src/components/AppTable/engine/summary/selectionSum.ts +92 -0
- package/template/src/components/AppTable/engine/summary/summary.ts +457 -0
- package/template/src/components/AppTable/engine/table/clipboard/index.ts +1 -0
- package/template/src/components/AppTable/engine/table/clipboard/transfer.ts +9 -0
- package/template/src/components/AppTable/engine/table/controller/TableController.ts +802 -0
- package/template/src/components/AppTable/engine/table/controller/errors.ts +106 -0
- package/template/src/components/AppTable/engine/table/controller/index.ts +4 -0
- package/template/src/components/AppTable/engine/table/controller/latestAbortableTask.ts +33 -0
- package/template/src/components/AppTable/engine/table/controller/tableDataReplacement.ts +60 -0
- package/template/src/components/AppTable/engine/table/controller/tableDomainConfiguration.ts +94 -0
- package/template/src/components/AppTable/engine/table/controller/tableEditingCommands.ts +163 -0
- package/template/src/components/AppTable/engine/table/controller/tableGridHost.ts +324 -0
- package/template/src/components/AppTable/engine/table/controller/tableIdentity.ts +68 -0
- package/template/src/components/AppTable/engine/table/controller/tableMutationPipeline.ts +79 -0
- package/template/src/components/AppTable/engine/table/controller/tableQueryCoordinator.ts +187 -0
- package/template/src/components/AppTable/engine/table/controller/tableReportingCoordinator.ts +143 -0
- package/template/src/components/AppTable/engine/table/controller/tableSaveCoordinator.ts +227 -0
- package/template/src/components/AppTable/engine/table/controller/tableSaveValidation.ts +29 -0
- package/template/src/components/AppTable/engine/table/controller/tableSnapshot.ts +58 -0
- package/template/src/components/AppTable/engine/table/controller/types.ts +202 -0
- package/template/src/components/AppTable/engine/table/editing/baselineStore.ts +134 -0
- package/template/src/components/AppTable/engine/table/editing/changeSet.ts +492 -0
- package/template/src/components/AppTable/engine/table/editing/changeSetSettlement.ts +633 -0
- package/template/src/components/AppTable/engine/table/editing/commitResultIndex.ts +75 -0
- package/template/src/components/AppTable/engine/table/editing/constants.ts +15 -0
- package/template/src/components/AppTable/engine/table/editing/dirtyCellIndex.ts +96 -0
- package/template/src/components/AppTable/engine/table/editing/index.ts +6 -0
- package/template/src/components/AppTable/engine/table/editing/mutation.ts +173 -0
- package/template/src/components/AppTable/engine/table/editing/rowKey.ts +10 -0
- package/template/src/components/AppTable/engine/table/editing/types.ts +404 -0
- package/template/src/components/AppTable/engine/table/editing/validation.ts +452 -0
- package/template/src/components/AppTable/engine/table/grid/cellMeta.ts +90 -0
- package/template/src/components/AppTable/engine/table/grid/handsontable.ts +25 -0
- package/template/src/components/AppTable/engine/table/grid/handsontableExtensions.d.ts +26 -0
- package/template/src/components/AppTable/engine/table/grid/index.ts +5 -0
- package/template/src/components/AppTable/engine/table/grid/moduleRegistry.ts +39 -0
- package/template/src/components/AppTable/engine/table/grid/runtime.ts +31 -0
- package/template/src/components/AppTable/engine/table/grid/types.ts +25 -0
- package/template/src/components/AppTable/engine/table/hooks/fixedEndHooks.ts +44 -0
- package/template/src/components/AppTable/engine/table/hooks/gridHooks.ts +108 -0
- package/template/src/components/AppTable/engine/table/hooks/headerHooks.ts +103 -0
- package/template/src/components/AppTable/engine/table/hooks/index.ts +3 -0
- package/template/src/components/AppTable/engine/table/index.ts +6 -0
- package/template/src/components/AppTable/engine/table/layout/constants.ts +2 -0
- package/template/src/components/AppTable/engine/table/layout/dropdownMenu.ts +89 -0
- package/template/src/components/AppTable/engine/table/layout/fixedColumns.ts +44 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlay.ts +90 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlayAccessibility.ts +104 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlayRenderer.ts +690 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlaySignature.ts +58 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndRuntime.ts +137 -0
- package/template/src/components/AppTable/engine/table/layout/handsontableDomAdapter.ts +40 -0
- package/template/src/components/AppTable/engine/table/layout/height.ts +72 -0
- package/template/src/components/AppTable/engine/table/layout/index.ts +14 -0
- package/template/src/components/AppTable/engine/table/layout/layoutScheduler.ts +60 -0
- package/template/src/components/AppTable/engine/table/layout/mergeCells.ts +146 -0
- package/template/src/components/AppTable/engine/table/layout/nestedHeaders.ts +271 -0
- package/template/src/components/AppTable/engine/table/layout/types.ts +10 -0
- package/template/src/components/AppTable/engine/toolbar/index.ts +1 -0
- package/template/src/components/AppTable/engine/toolbar/types.ts +56 -0
- package/template/src/components/AppTable/index.ts +11 -0
- package/template/src/components/AppTable/messages.ts +256 -0
- package/template/src/components/AppTable/pagination/TablePaginationBar.tsx +193 -0
- package/template/src/components/AppTable/pagination/index.ts +1 -0
- package/template/src/components/AppTable/pagination/paginationItems.ts +56 -0
- package/template/src/components/AppTable/preference/index.ts +1 -0
- package/template/src/components/AppTable/preference/useTablePreference.ts +208 -0
- package/template/src/components/AppTable/reporting/index.ts +1 -0
- package/template/src/components/AppTable/reporting/useTableReporting.ts +342 -0
- package/template/src/components/AppTable/search/TableSearchBar.tsx +301 -0
- package/template/src/components/AppTable/search/TableSearchConditionEditor.tsx +254 -0
- package/template/src/components/AppTable/search/TableSearchField.tsx +338 -0
- package/template/src/components/AppTable/search/TableSearchFields.tsx +65 -0
- package/template/src/components/AppTable/search/constants.ts +9 -0
- package/template/src/components/AppTable/search/index.ts +3 -0
- package/template/src/components/AppTable/search/tableSearchBar.css +164 -0
- package/template/src/components/AppTable/search/types.ts +7 -0
- package/template/src/components/AppTable/search/useTableQuery.ts +373 -0
- package/template/src/components/AppTable/selection/index.ts +1 -0
- package/template/src/components/AppTable/selection/useTableSelection.ts +188 -0
- package/template/src/components/AppTable/sensitiveData.tsx +41 -0
- package/template/src/components/AppTable/shared/styles.ts +2 -0
- package/template/src/components/AppTable/styles/index.css +6 -0
- package/template/src/components/AppTable/styles/tableComponent.css +297 -0
- package/template/src/components/AppTable/styles/theme.css +133 -0
- package/template/src/components/AppTable/table/components/TableComponent.tsx +567 -0
- package/template/src/components/AppTable/table/components/TableErrorFeedback.tsx +36 -0
- package/template/src/components/AppTable/table/components/TableGridViewport.tsx +85 -0
- package/template/src/components/AppTable/table/components/index.ts +2 -0
- package/template/src/components/AppTable/table/components/types.ts +90 -0
- package/template/src/components/AppTable/table/controller/configuration.ts +89 -0
- package/template/src/components/AppTable/table/controller/index.ts +2 -0
- package/template/src/components/AppTable/table/controller/useTableController.ts +155 -0
- package/template/src/components/AppTable/table/controller/useTableLifecycle.ts +97 -0
- package/template/src/components/AppTable/table/grid/index.ts +1 -0
- package/template/src/components/AppTable/table/grid/useTableGrid.ts +857 -0
- package/template/src/components/AppTable/table/grid/useTableGridRuntimeSettings.ts +49 -0
- package/template/src/components/AppTable/table/index.ts +4 -0
- package/template/src/components/AppTable/table/layout/TablePanels.tsx +389 -0
- package/template/src/components/AppTable/table/layout/index.ts +7 -0
- package/template/src/components/AppTable/table/layout/types.ts +3 -0
- package/template/src/components/AppTable/table/layout/useResizablePanel.ts +213 -0
- package/template/src/components/AppTable/table/layout/useTableAdaptiveHeight.ts +238 -0
- package/template/src/components/AppTable/table/layout/useTablePanels.ts +329 -0
- package/template/src/components/AppTable/table/layout/useTableTheme.ts +123 -0
- package/template/src/components/AppTable/toolbar/TableToolbar.tsx +336 -0
- package/template/src/components/AppTable/toolbar/index.ts +1 -0
- package/template/src/components/BrandLogo/BrandLogo.tsx +41 -0
- package/template/src/components/BrandLogo/index.ts +1 -0
- package/template/src/components/Can/Can.tsx +19 -0
- package/template/src/components/Can/index.ts +7 -0
- package/template/src/components/Can/types.ts +41 -0
- package/template/src/components/EnumBadge/EnumBadge.tsx +44 -0
- package/template/src/components/EnumBadge/index.ts +2 -0
- package/template/src/components/EnumBadge/types.ts +16 -0
- package/template/src/components/EnumText/EnumText.tsx +33 -0
- package/template/src/components/EnumText/index.ts +2 -0
- package/template/src/components/EnumText/types.ts +13 -0
- package/template/src/components/FilePreview/FilePreview.tsx +120 -0
- package/template/src/components/FilePreview/index.ts +11 -0
- package/template/src/components/FilePreview/preview.ts +88 -0
- package/template/src/components/FilePreview/types.ts +91 -0
- package/template/src/components/FileUpload/FileUpload.tsx +172 -0
- package/template/src/components/FileUpload/index.ts +2 -0
- package/template/src/components/FileUpload/types.ts +32 -0
- package/template/src/components/JsonEditor/JsonEditor.tsx +103 -0
- package/template/src/components/JsonEditor/index.ts +1 -0
- package/template/src/components/JsonEditor/types.ts +14 -0
- package/template/src/components/PageFeedback/PageFeedback.tsx +194 -0
- package/template/src/components/PageFeedback/index.ts +10 -0
- package/template/src/components/PageFeedback/types.ts +31 -0
- package/template/src/components/PasswordInput/PasswordInput.tsx +50 -0
- package/template/src/components/PasswordInput/index.ts +1 -0
- package/template/src/components/RouteDialog/RouteDialog.tsx +20 -0
- package/template/src/components/RouteDialog/index.ts +2 -0
- package/template/src/components/RouteDialog/types.ts +8 -0
- package/template/src/components/RouteDialog/useRouteDialogNavigation.ts +30 -0
- package/template/src/components/SensitiveData/SensitiveData.tsx +337 -0
- package/template/src/components/SensitiveData/index.ts +2 -0
- package/template/src/components/SensitiveData/types.ts +31 -0
- package/template/src/components/StatusBadge/StatusBadge.tsx +28 -0
- package/template/src/components/StatusBadge/index.ts +2 -0
- package/template/src/components/StatusBadge/statusBadgeStyles.ts +30 -0
- package/template/src/components/StatusBadge/types.ts +7 -0
- package/template/src/components/layout/AppHeader/AppHeader.tsx +57 -0
- package/template/src/components/layout/AppHeader/HeaderSearch.tsx +160 -0
- package/template/src/components/layout/AppHeader/HeaderUserMenu.tsx +59 -0
- package/template/src/components/layout/AppHeader/ThemeControls.tsx +44 -0
- package/template/src/components/layout/AppHeader/index.ts +1 -0
- package/template/src/components/layout/AppHeader/themeOptions.ts +13 -0
- package/template/src/components/layout/AppSidebar.tsx +268 -0
- package/template/src/components/layout/PageContainer.tsx +16 -0
- package/template/src/components/ui/avatar.tsx +108 -0
- package/template/src/components/ui/badge.tsx +47 -0
- package/template/src/components/ui/button.tsx +63 -0
- package/template/src/components/ui/card.tsx +60 -0
- package/template/src/components/ui/checkbox.tsx +31 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/command.tsx +181 -0
- package/template/src/components/ui/dialog.tsx +157 -0
- package/template/src/components/ui/dropdown-menu.tsx +254 -0
- package/template/src/components/ui/form.tsx +141 -0
- package/template/src/components/ui/input.tsx +20 -0
- package/template/src/components/ui/label.tsx +23 -0
- package/template/src/components/ui/pagination.tsx +127 -0
- package/template/src/components/ui/popover.tsx +41 -0
- package/template/src/components/ui/select.tsx +187 -0
- package/template/src/components/ui/separator.tsx +25 -0
- package/template/src/components/ui/sheet.tsx +142 -0
- package/template/src/components/ui/sidebar.tsx +878 -0
- package/template/src/components/ui/skeleton.tsx +13 -0
- package/template/src/components/ui/sonner.tsx +33 -0
- package/template/src/components/ui/tooltip.tsx +54 -0
- package/template/src/config/RuntimeConfigErrorPage.tsx +48 -0
- package/template/src/config/appConfig.ts +126 -0
- package/template/src/config/buildInfo.ts +8 -0
- package/template/src/config/observabilityAdapter.ts +8 -0
- package/template/src/config/runtimeConfig.ts +360 -0
- package/template/src/config/types.ts +195 -0
- package/template/src/context/ThemeProvider.tsx +84 -0
- package/template/src/context/UnsavedChangesProvider.tsx +123 -0
- package/template/src/context/applicationScope.ts +39 -0
- package/template/src/context/types.ts +41 -0
- package/template/src/dataMasking/index.ts +14 -0
- package/template/src/dataMasking/masking.ts +139 -0
- package/template/src/dataMasking/types.ts +144 -0
- package/template/src/featureFlags/FeatureFlagProvider.tsx +143 -0
- package/template/src/featureFlags/FeatureGate.tsx +12 -0
- package/template/src/featureFlags/catalog.ts +140 -0
- package/template/src/featureFlags/errors.ts +17 -0
- package/template/src/featureFlags/index.ts +43 -0
- package/template/src/featureFlags/query.ts +103 -0
- package/template/src/featureFlags/registry.ts +149 -0
- package/template/src/featureFlags/scope.ts +27 -0
- package/template/src/featureFlags/types.ts +241 -0
- package/template/src/features/auth/AuthLayout.tsx +17 -0
- package/template/src/features/auth/index.ts +2 -0
- package/template/src/features/auth/signIn/components/UserAuthForm.tsx +121 -0
- package/template/src/features/auth/signIn/index.tsx +71 -0
- package/template/src/features/auth/signIn/messages.ts +37 -0
- package/template/src/features/auth/signIn/types.ts +4 -0
- package/template/src/features/errors/ForbiddenError.tsx +34 -0
- package/template/src/features/errors/GeneralError.tsx +46 -0
- package/template/src/features/errors/MaintenanceError.tsx +31 -0
- package/template/src/features/errors/NotFoundError.tsx +34 -0
- package/template/src/features/errors/RouteError.tsx +72 -0
- package/template/src/features/errors/UnauthorizedError.tsx +34 -0
- package/template/src/features/errors/index.ts +6 -0
- package/template/src/features/errors/messages.ts +56 -0
- package/template/src/features/home/index.tsx +107 -0
- package/template/src/features/home/messages.ts +59 -0
- package/template/src/features/showcase/AccessShowcasePage.tsx +284 -0
- package/template/src/features/showcase/AdvancedTableDemo.tsx +120 -0
- package/template/src/features/showcase/FeedbackShowcasePage.tsx +142 -0
- package/template/src/features/showcase/FileShowcasePage.tsx +110 -0
- package/template/src/features/showcase/FormShowcasePage.tsx +156 -0
- package/template/src/features/showcase/MetadataShowcasePage.tsx +241 -0
- package/template/src/features/showcase/ShowcasePageHeader.tsx +24 -0
- package/template/src/features/showcase/TableShowcasePage.tsx +436 -0
- package/template/src/features/showcase/accessMessages.ts +67 -0
- package/template/src/features/showcase/index.ts +6 -0
- package/template/src/features/showcase/messages.ts +192 -0
- package/template/src/files/download.ts +82 -0
- package/template/src/files/errors.ts +15 -0
- package/template/src/files/filename.ts +61 -0
- package/template/src/files/index.ts +38 -0
- package/template/src/files/types.ts +299 -0
- package/template/src/files/useFileTask.ts +153 -0
- package/template/src/files/useFileUpload.ts +117 -0
- package/template/src/files/validation.ts +109 -0
- package/template/src/layouts/AppLayout.tsx +37 -0
- package/template/src/lib/accessControl.ts +42 -0
- package/template/src/lib/navigationRedirect.ts +26 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/locale/LocaleProvider.tsx +37 -0
- package/template/src/locale/context.ts +15 -0
- package/template/src/locale/formatters.ts +123 -0
- package/template/src/locale/hooks.ts +35 -0
- package/template/src/locale/index.ts +17 -0
- package/template/src/locale/messages.ts +151 -0
- package/template/src/locale/types.ts +167 -0
- package/template/src/main.tsx +5 -0
- package/template/src/observability/browser.ts +37 -0
- package/template/src/observability/consoleAdapter.ts +18 -0
- package/template/src/observability/index.ts +26 -0
- package/template/src/observability/observer.ts +118 -0
- package/template/src/observability/redaction.ts +85 -0
- package/template/src/observability/types.ts +119 -0
- package/template/src/optionalEditors/controller.ts +327 -0
- package/template/src/optionalEditors/errors.ts +21 -0
- package/template/src/optionalEditors/index.ts +35 -0
- package/template/src/optionalEditors/model.ts +253 -0
- package/template/src/optionalEditors/react.ts +89 -0
- package/template/src/optionalEditors/types.ts +254 -0
- package/template/src/permissions/index.ts +3 -0
- package/template/src/permissions/types.ts +5 -0
- package/template/src/permissions/usePermission.ts +16 -0
- package/template/src/realtimeCollaboration/controller.ts +355 -0
- package/template/src/realtimeCollaboration/errors.ts +20 -0
- package/template/src/realtimeCollaboration/index.ts +39 -0
- package/template/src/realtimeCollaboration/model.ts +212 -0
- package/template/src/realtimeCollaboration/react.ts +72 -0
- package/template/src/realtimeCollaboration/types.ts +251 -0
- package/template/src/reporting/errors.ts +21 -0
- package/template/src/reporting/generation.ts +87 -0
- package/template/src/reporting/index.ts +42 -0
- package/template/src/reporting/model.ts +373 -0
- package/template/src/reporting/print.ts +16 -0
- package/template/src/reporting/query.ts +50 -0
- package/template/src/reporting/react.ts +17 -0
- package/template/src/reporting/source.ts +13 -0
- package/template/src/reporting/types.ts +219 -0
- package/template/src/router/RootRouteLayout.tsx +11 -0
- package/template/src/router/authLifecycle.ts +39 -0
- package/template/src/router/config.ts +293 -0
- package/template/src/router/interceptors.ts +48 -0
- package/template/src/router/lazyRouteComponents.ts +78 -0
- package/template/src/router/messages.ts +48 -0
- package/template/src/router/navigation.ts +167 -0
- package/template/src/router/router.ts +66 -0
- package/template/src/router/searchSchemas.ts +9 -0
- package/template/src/router/types.ts +76 -0
- package/template/src/stores/authSessionStorage.ts +27 -0
- package/template/src/stores/authStore.ts +165 -0
- package/template/src/stores/types.ts +36 -0
- package/template/src/stores/uiPreferenceStore.ts +34 -0
- package/template/src/styles/index.css +141 -0
- package/template/src/styles/theme.css +213 -0
- package/template/src/tenantWorkspace/TenantWorkspaceProvider.tsx +102 -0
- package/template/src/tenantWorkspace/index.ts +33 -0
- package/template/src/tenantWorkspace/store.ts +184 -0
- package/template/src/tenantWorkspace/switch.ts +206 -0
- package/template/src/tenantWorkspace/types.ts +155 -0
- package/template/src/vite-env.d.ts +20 -0
- package/template/stylelint.config.js +28 -0
- package/template/tests/integration/Application.test.tsx +269 -0
- package/template/tests/integration/layout/AppHeader.test.tsx +182 -0
- package/template/tests/integration/layout/AppSidebar.test.tsx +121 -0
- package/template/tests/integration/layout/__screenshots__/AppHeader.test.tsx/AppHeader-command-search-hides-the-duplicate-header-trigger-when-the-desktop-sidebar-collapses-1.png +0 -0
- package/template/tests/integration/router/__screenshots__/config.test.ts/route-tree-authentication-boundaries-exposes-only-scaffold-navigation-metadata-1.png +0 -0
- package/template/tests/integration/router/config.test.ts +123 -0
- package/template/tests/integration/router/interceptors.test.ts +100 -0
- package/template/tests/setup/accessibility.ts +25 -0
- package/template/tests/setup/runtimeConfig.ts +3 -0
- package/template/tests/unit/api/ApiError.test.ts +25 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-clears-the-session-if-a-refresh-identity-loses-administrator-access-1.png +0 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-creates-a-session-from-the-generated-login-response-for-an-admin-1.png +0 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-rejects-and-revokes-the-generated-login-result-for-an-ordinary-user-1.png +0 -0
- package/template/tests/unit/api/activity/ActivityProvider.test.tsx +131 -0
- package/template/tests/unit/api/activity/__screenshots__/transports.test.ts/activity-transport-adapters-polls-sequentially-and-advances-the-last-event-ID-1.png +0 -0
- package/template/tests/unit/api/activity/modelAndQuery.test.ts +144 -0
- package/template/tests/unit/api/activity/subscription.test.ts +103 -0
- package/template/tests/unit/api/activity/transports.test.ts +145 -0
- package/template/tests/unit/api/authClient.test.ts +110 -0
- package/template/tests/unit/api/authSession.test.ts +289 -0
- package/template/tests/unit/api/clients/configureApiClient.test.ts +198 -0
- package/template/tests/unit/api/demoAuthClient.test.ts +47 -0
- package/template/tests/unit/api/enums/access.test.ts +107 -0
- package/template/tests/unit/api/enums/catalog.test.ts +200 -0
- package/template/tests/unit/api/enums/query.test.ts +110 -0
- package/template/tests/unit/api/enums/useEnum.test.tsx +98 -0
- package/template/tests/unit/api/enums/useEnumCatalog.test.tsx +68 -0
- package/template/tests/unit/api/hooks/error.test.ts +168 -0
- package/template/tests/unit/api/hooks/request.test.ts +170 -0
- package/template/tests/unit/api/hooks/response.test.ts +46 -0
- package/template/tests/unit/api/metadata/MetadataProvider.test.tsx +102 -0
- package/template/tests/unit/api/parameters/catalog.test.ts +147 -0
- package/template/tests/unit/api/parameters/query.test.ts +78 -0
- package/template/tests/unit/api/parameters/useGlobalParameter.test.tsx +89 -0
- package/template/tests/unit/api/query/queryPolicy.test.ts +245 -0
- package/template/tests/unit/api/query/useAppQueryScope.test.tsx +74 -0
- package/template/tests/unit/auditLogs/auditLogHooks.test.tsx +194 -0
- package/template/tests/unit/auditLogs/auditLogs.test.ts +199 -0
- package/template/tests/unit/authentication/__screenshots__/authentication.test.ts/authentication-controller-completes-Step-up-callbacks-without-creating-a-second-login-result-1.png +0 -0
- package/template/tests/unit/authentication/__screenshots__/authentication.test.ts/authentication-controller-moves-from-challenge-to-completion-without-retaining-tokens-in-snapshot-1.png +0 -0
- package/template/tests/unit/authentication/authentication.test.ts +376 -0
- package/template/tests/unit/components/AppDialog.test.tsx +225 -0
- package/template/tests/unit/components/AppTable.test.tsx +129 -0
- package/template/tests/unit/components/AppTableLayoutTransition.test.ts +118 -0
- package/template/tests/unit/components/AppTableLocalization.test.ts +58 -0
- package/template/tests/unit/components/AppTableSensitiveData.test.ts +35 -0
- package/template/tests/unit/components/AppTableUpgrade.test.tsx +179 -0
- package/template/tests/unit/components/AppTableUpgradeCore.test.ts +258 -0
- package/template/tests/unit/components/BrandLogo.test.tsx +24 -0
- package/template/tests/unit/components/Can.test.tsx +80 -0
- package/template/tests/unit/components/Dialog.test.tsx +56 -0
- package/template/tests/unit/components/EnumPresentation.test.tsx +64 -0
- package/template/tests/unit/components/FilePreviewEngine.test.ts +51 -0
- package/template/tests/unit/components/JsonEditor.test.tsx +47 -0
- package/template/tests/unit/components/LocalizedSharedComponents.test.tsx +36 -0
- package/template/tests/unit/components/OverlayLayer.test.tsx +151 -0
- package/template/tests/unit/components/PageFeedback.test.tsx +143 -0
- package/template/tests/unit/components/PageForm.test.tsx +272 -0
- package/template/tests/unit/components/PageFormCore.test.ts +74 -0
- package/template/tests/unit/components/PasswordInput.test.tsx +105 -0
- package/template/tests/unit/components/ScaffoldComponents.test.tsx +64 -0
- package/template/tests/unit/components/SensitiveData.test.tsx +151 -0
- package/template/tests/unit/components/StatusBadge.test.tsx +36 -0
- package/template/tests/unit/components/TableComponent.test.tsx +644 -0
- package/template/tests/unit/components/TableCore.test.ts +145 -0
- package/template/tests/unit/components/ThemeAccessibility.test.tsx +27 -0
- package/template/tests/unit/components/__screenshots__/BatchOperationDialog.test.tsx/confirms-a-batch-action-and-presents-partial-failure-details-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/PageForm.test.tsx/PageForm-writes-uploaded-values-through-the-public-file-field-and-resets-dirty-state-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/PasswordInput.test.tsx/PasswordInput-toggles-the-password-visibility-when-the-show-password-button-is-clicked-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-pins-trailing-action-columns-and-removes-their-header-menu-by-default-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-renders-shadcn-components-through-cellComponent-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-renders-the-toolbar-without-a-bottom-divider-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-resyncs-adaptive-height-after-a-column-resize-changes-wrapped-row-height-1.png +0 -0
- package/template/tests/unit/config/RuntimeConfigErrorPage.test.tsx +23 -0
- package/template/tests/unit/config/appConfig.test.ts +98 -0
- package/template/tests/unit/config/appTableContracts.test.mjs +120 -0
- package/template/tests/unit/config/bundleBudget.test.mjs +190 -0
- package/template/tests/unit/config/componentGovernance.test.mjs +156 -0
- package/template/tests/unit/config/deployConfig.test.mjs +211 -0
- package/template/tests/unit/config/eslintConfig.test.mjs +101 -0
- package/template/tests/unit/config/featureBoundaries.test.mjs +126 -0
- package/template/tests/unit/config/npmPackage.test.mjs +37 -0
- package/template/tests/unit/config/releaseArtifact.test.mjs +105 -0
- package/template/tests/unit/config/runtimeConfig.test.ts +225 -0
- package/template/tests/unit/config/scaffoldCheck.test.mjs +53 -0
- package/template/tests/unit/config/scaffoldFeature.test.mjs +177 -0
- package/template/tests/unit/config/scaffoldInit.test.mjs +218 -0
- package/template/tests/unit/config/scaffoldProject.test.mjs +378 -0
- package/template/tests/unit/config/scaffoldTransaction.test.mjs +77 -0
- package/template/tests/unit/config/viteConfig.test.mjs +371 -0
- package/template/tests/unit/context/ThemeProvider.test.tsx +108 -0
- package/template/tests/unit/context/UnsavedChangesProvider.test.tsx +94 -0
- package/template/tests/unit/context/__screenshots__/ThemeProvider.test.tsx/ThemeProvider-uses-the-neutral-black-palette-for-the-app-and-scoped-table-theme-1.png +0 -0
- package/template/tests/unit/context/applicationScope.test.ts +62 -0
- package/template/tests/unit/dataMasking/dataMasking.test.ts +95 -0
- package/template/tests/unit/featureFlags/featureFlags.test.ts +169 -0
- package/template/tests/unit/featureFlags/useFeatureFlag.test.tsx +108 -0
- package/template/tests/unit/features/FeatureLocalization.test.tsx +54 -0
- package/template/tests/unit/features/RouteError.test.tsx +40 -0
- package/template/tests/unit/features/auth/signIn/UserAuthForm.test.tsx +79 -0
- package/template/tests/unit/features/auth/signIn/__screenshots__/UserAuthForm.test.tsx/UserAuthForm-passes-validated-values-to-onSubmit-1.png +0 -0
- package/template/tests/unit/features/auth/signIn/__screenshots__/UserAuthForm.test.tsx/UserAuthForm-shows-validation-messages-when-submitting-an-empty-form-1.png +0 -0
- package/template/tests/unit/files/fileHooks.test.tsx +130 -0
- package/template/tests/unit/files/files.test.ts +112 -0
- package/template/tests/unit/lib/accessControl.test.ts +69 -0
- package/template/tests/unit/locale/locale.test.tsx +90 -0
- package/template/tests/unit/observability/browser.test.ts +48 -0
- package/template/tests/unit/observability/observer.test.ts +115 -0
- package/template/tests/unit/optionalEditors/__screenshots__/useOptionalEditor.test.tsx/useOptionalEditor-fails-permission-precheck-before-loading-the-project-SDK-1.png +0 -0
- package/template/tests/unit/optionalEditors/__screenshots__/useOptionalEditor.test.tsx/useOptionalEditor-mounts-a-route-scoped-SDK-into-the-dedicated-host-with-permission-1.png +0 -0
- package/template/tests/unit/optionalEditors/optionalEditors.test.ts +313 -0
- package/template/tests/unit/optionalEditors/useOptionalEditor.test.tsx +141 -0
- package/template/tests/unit/realtimeCollaboration/collaboration.test.ts +240 -0
- package/template/tests/unit/realtimeCollaboration/useRealtimeCollaboration.test.tsx +115 -0
- package/template/tests/unit/reporting/reporting.test.ts +195 -0
- package/template/tests/unit/reporting/reportingHooks.test.tsx +203 -0
- package/template/tests/unit/router/authLifecycle.test.ts +55 -0
- package/template/tests/unit/router/navigation.test.ts +55 -0
- package/template/tests/unit/router/redirects.test.ts +22 -0
- package/template/tests/unit/scaffoldFeatureTemplate/featureTemplate.test.ts +42 -0
- package/template/tests/unit/scaffoldFeatureTemplate/publicContract.test.ts +28 -0
- package/template/tests/unit/scaffoldFeatureTemplate/queries.test.tsx +289 -0
- package/template/tests/unit/stores/authStore.test.ts +128 -0
- package/template/tests/unit/stores/uiPreferenceStore.test.ts +56 -0
- package/template/tests/unit/tenantWorkspace/tenantWorkspace.test.tsx +261 -0
- package/template/tools/bundle/budgets.json +48 -0
- package/template/tools/bundle/check.mjs +307 -0
- package/template/tools/component-governance/check.mjs +703 -0
- package/template/tools/component-governance/manifest.json +112 -0
- package/template/tools/deployment/browser-smoke.mjs +76 -0
- package/template/tools/deployment/browser-smoke.sh +141 -0
- package/template/tools/openapi/generate.mjs +268 -0
- package/template/tools/openapi/templates/README.md +14 -0
- package/template/tools/openapi/templates/base/README.md +7 -0
- package/template/tools/openapi/templates/base/data-contracts.eta +44 -0
- package/template/tools/openapi/templates/base/http-client.eta +3 -0
- package/template/tools/openapi/templates/base/http-clients/axios-http-client.eta +132 -0
- package/template/tools/openapi/templates/base/http-clients/fetch-http-client.eta +220 -0
- package/template/tools/openapi/templates/base/route-docs.eta +31 -0
- package/template/tools/openapi/templates/base/route-name.eta +43 -0
- package/template/tools/openapi/templates/base/route-type.eta +22 -0
- package/template/tools/openapi/templates/default/README.md +7 -0
- package/template/tools/openapi/templates/default/api.eta +67 -0
- package/template/tools/openapi/templates/default/http-client.eta +137 -0
- package/template/tools/openapi/templates/default/procedure-call.eta +99 -0
- package/template/tools/openapi/templates/default/route-docs.eta +40 -0
- package/template/tools/openapi/templates/default/route-types.eta +28 -0
- package/template/tools/openapi/templates/modular/README.md +7 -0
- package/template/tools/openapi/templates/modular/api.eta +28 -0
- package/template/tools/openapi/templates/modular/procedure-call.eta +99 -0
- package/template/tools/openapi/templates/modular/route-types.eta +18 -0
- package/template/tools/release/artifact.mjs +258 -0
- package/template/tools/scaffold/add-capability.mjs +409 -0
- package/template/tools/scaffold/capability-catalog.json +163 -0
- package/template/tools/scaffold/check.mjs +326 -0
- package/template/tools/scaffold/create-feature.mjs +444 -0
- package/template/tools/scaffold/create-project.mjs +482 -0
- package/template/tools/scaffold/init.example.json +64 -0
- package/template/tools/scaffold/init.mjs +419 -0
- package/template/tools/scaffold/lockfile.mjs +193 -0
- package/template/tools/scaffold/templates/feature/index.ts +19 -0
- package/template/tools/scaffold/templates/feature/model.ts +142 -0
- package/template/tools/scaffold/templates/feature/queries.ts +154 -0
- package/template/tools/scaffold/templates/feature/repository.ts +206 -0
- package/template/tools/scaffold/templates/feature/types.ts +168 -0
- package/template/tools/scaffold/workspace-transaction.mjs +111 -0
- package/template/tsconfig.app.json +31 -0
- package/template/tsconfig.json +12 -0
- package/template/tsconfig.node.json +24 -0
- package/template/vite.config.ts +121 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { objAppConfig } from '@/config/appConfig'
|
|
3
|
+
import {
|
|
4
|
+
fnCancelTenantWorkspaceSwitch,
|
|
5
|
+
fnGetTenantWorkspaceCurrent,
|
|
6
|
+
fnGetTenantWorkspaceSnapshot,
|
|
7
|
+
fnResetTenantWorkspace,
|
|
8
|
+
fnSwitchTenantWorkspace,
|
|
9
|
+
TenantWorkspaceError,
|
|
10
|
+
TenantWorkspaceProvider,
|
|
11
|
+
useTenantWorkspace,
|
|
12
|
+
type ITenantWorkspaceAdapter,
|
|
13
|
+
} from '@/tenantWorkspace'
|
|
14
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
15
|
+
import { render } from 'vitest-browser-react'
|
|
16
|
+
import { userEvent } from 'vitest/browser'
|
|
17
|
+
import { useAuthStore, type IAuthSession } from '@/stores/authStore'
|
|
18
|
+
|
|
19
|
+
function fnCreateSession(
|
|
20
|
+
strTenantId: string,
|
|
21
|
+
strUserId = 'user-1'
|
|
22
|
+
): IAuthSession {
|
|
23
|
+
return {
|
|
24
|
+
nAccessTokenExpiresAt: Date.now() + 60_000,
|
|
25
|
+
nRefreshTokenExpiresAt: Date.now() + 120_000,
|
|
26
|
+
objUser: {
|
|
27
|
+
arrPermissions: ['workspace:read'],
|
|
28
|
+
arrRoleCodes: ['member'],
|
|
29
|
+
strAccount: strUserId,
|
|
30
|
+
strDisplayName: strUserId,
|
|
31
|
+
strId: strUserId,
|
|
32
|
+
strRole: 'admin',
|
|
33
|
+
strTenantId,
|
|
34
|
+
},
|
|
35
|
+
strAccessToken: `access-${strTenantId}`,
|
|
36
|
+
strRefreshToken: `refresh-${strTenantId}`,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function SwitchConsumer() {
|
|
41
|
+
const { fnClearError, fnRetry, fnSwitch, objCurrent, objTransition } =
|
|
42
|
+
useTenantWorkspace()
|
|
43
|
+
const [strCommandError, fnSetCommandError] = useState('')
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div>
|
|
47
|
+
<output data-workspace={objCurrent.strWorkspaceId}>
|
|
48
|
+
{objTransition.strStatus}
|
|
49
|
+
</output>
|
|
50
|
+
<button
|
|
51
|
+
onClick={() => {
|
|
52
|
+
void fnSwitch({
|
|
53
|
+
strTenantId: 'tenant-a',
|
|
54
|
+
strWorkspaceId: 'workspace-b',
|
|
55
|
+
}).catch((objError: unknown) =>
|
|
56
|
+
fnSetCommandError(
|
|
57
|
+
objError instanceof Error ? objError.message : 'unknown error'
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
}}
|
|
61
|
+
type='button'
|
|
62
|
+
>
|
|
63
|
+
switch
|
|
64
|
+
</button>
|
|
65
|
+
<button
|
|
66
|
+
onClick={() => {
|
|
67
|
+
fnClearError()
|
|
68
|
+
fnSetCommandError('')
|
|
69
|
+
}}
|
|
70
|
+
type='button'
|
|
71
|
+
>
|
|
72
|
+
clear
|
|
73
|
+
</button>
|
|
74
|
+
<button
|
|
75
|
+
onClick={() => {
|
|
76
|
+
void fnRetry().catch((objError: unknown) =>
|
|
77
|
+
fnSetCommandError(
|
|
78
|
+
objError instanceof Error ? objError.message : 'unknown error'
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
}}
|
|
82
|
+
type='button'
|
|
83
|
+
>
|
|
84
|
+
retry
|
|
85
|
+
</button>
|
|
86
|
+
<span>{strCommandError}</span>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
fnCancelTenantWorkspaceSwitch()
|
|
93
|
+
fnResetTenantWorkspace()
|
|
94
|
+
localStorage.removeItem(objAppConfig.storage.strTenantWorkspaceKey)
|
|
95
|
+
useAuthStore.getState().fnClearSession()
|
|
96
|
+
useAuthStore.getState().fnEstablishSession(fnCreateSession('tenant-a'))
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
afterEach(() => {
|
|
100
|
+
fnCancelTenantWorkspaceSwitch()
|
|
101
|
+
fnResetTenantWorkspace()
|
|
102
|
+
localStorage.removeItem(objAppConfig.storage.strTenantWorkspaceKey)
|
|
103
|
+
useAuthStore.getState().fnClearSession()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe('tenant and workspace context', () => {
|
|
107
|
+
it('commits a confirmed workspace after cancelling old scoped requests', async () => {
|
|
108
|
+
const arrOrder: string[] = []
|
|
109
|
+
const objAdapter: ITenantWorkspaceAdapter = {
|
|
110
|
+
fnSwitch: async ({ objCurrent, objTarget }) => {
|
|
111
|
+
arrOrder.push('adapter')
|
|
112
|
+
expect(objCurrent.strWorkspaceId).toBeUndefined()
|
|
113
|
+
return objTarget
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const objCurrent = await fnSwitchTenantWorkspace(
|
|
118
|
+
{ strTenantId: ' tenant-a ', strWorkspaceId: ' workspace-a ' },
|
|
119
|
+
{
|
|
120
|
+
objAdapter,
|
|
121
|
+
fnBeforeCommit: () => {
|
|
122
|
+
arrOrder.push('cancel-queries')
|
|
123
|
+
expect(fnGetTenantWorkspaceCurrent().strWorkspaceId).toBeUndefined()
|
|
124
|
+
},
|
|
125
|
+
fnAfterCommit: () => arrOrder.push('invalidate-router'),
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
expect(arrOrder).toEqual(['adapter', 'cancel-queries', 'invalidate-router'])
|
|
130
|
+
expect(objCurrent).toMatchObject({
|
|
131
|
+
strTenantId: 'tenant-a',
|
|
132
|
+
strWorkspaceId: 'workspace-a',
|
|
133
|
+
})
|
|
134
|
+
expect(fnGetTenantWorkspaceSnapshot().objTransition.strStatus).toBe('idle')
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('keeps the old context when the adapter rejects the switch', async () => {
|
|
138
|
+
await fnSwitchTenantWorkspace(
|
|
139
|
+
{ strTenantId: 'tenant-a', strWorkspaceId: 'workspace-a' },
|
|
140
|
+
{ objAdapter: { fnSwitch: async ({ objTarget }) => objTarget } }
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
await expect(
|
|
144
|
+
fnSwitchTenantWorkspace(
|
|
145
|
+
{ strTenantId: 'tenant-a', strWorkspaceId: 'workspace-b' },
|
|
146
|
+
{
|
|
147
|
+
objAdapter: {
|
|
148
|
+
fnSwitch: async () => {
|
|
149
|
+
throw new Error('backend unavailable')
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
).rejects.toMatchObject({ strCode: 'switch_failed' })
|
|
155
|
+
|
|
156
|
+
expect(fnGetTenantWorkspaceCurrent().strWorkspaceId).toBe('workspace-a')
|
|
157
|
+
expect(fnGetTenantWorkspaceSnapshot().objTransition).toMatchObject({
|
|
158
|
+
strStatus: 'error',
|
|
159
|
+
objTarget: { strWorkspaceId: 'workspace-b' },
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('requires and commits a new authenticated session across tenants', async () => {
|
|
164
|
+
await expect(
|
|
165
|
+
fnSwitchTenantWorkspace(
|
|
166
|
+
{ strTenantId: 'tenant-b', strWorkspaceId: 'workspace-b' },
|
|
167
|
+
{ objAdapter: { fnSwitch: async ({ objTarget }) => objTarget } }
|
|
168
|
+
)
|
|
169
|
+
).rejects.toMatchObject({ strCode: 'session_required' })
|
|
170
|
+
expect(fnGetTenantWorkspaceCurrent().strTenantId).toBe('tenant-a')
|
|
171
|
+
|
|
172
|
+
const objCurrent = await fnSwitchTenantWorkspace(
|
|
173
|
+
{ strTenantId: 'tenant-b', strWorkspaceId: 'workspace-b' },
|
|
174
|
+
{
|
|
175
|
+
objAdapter: {
|
|
176
|
+
fnSwitch: async ({ objTarget }) => ({
|
|
177
|
+
...objTarget,
|
|
178
|
+
objSession: fnCreateSession('tenant-b'),
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
expect(objCurrent).toMatchObject({
|
|
185
|
+
strTenantId: 'tenant-b',
|
|
186
|
+
strWorkspaceId: 'workspace-b',
|
|
187
|
+
})
|
|
188
|
+
expect(useAuthStore.getState().strAccessToken).toBe('access-tenant-b')
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('aborts a stale switch and only lets the latest target commit', async () => {
|
|
192
|
+
const fnFirstAdapter = vi.fn(
|
|
193
|
+
({ objSignal }: Parameters<ITenantWorkspaceAdapter['fnSwitch']>[0]) =>
|
|
194
|
+
new Promise<never>((_fnResolve, fnReject) => {
|
|
195
|
+
objSignal.addEventListener('abort', () =>
|
|
196
|
+
fnReject(new DOMException('aborted', 'AbortError'))
|
|
197
|
+
)
|
|
198
|
+
})
|
|
199
|
+
)
|
|
200
|
+
const objFirstPromise = fnSwitchTenantWorkspace(
|
|
201
|
+
{ strTenantId: 'tenant-a', strWorkspaceId: 'workspace-a' },
|
|
202
|
+
{ objAdapter: { fnSwitch: fnFirstAdapter } }
|
|
203
|
+
)
|
|
204
|
+
await expect.poll(() => fnFirstAdapter).toHaveBeenCalledOnce()
|
|
205
|
+
|
|
206
|
+
const objSecondPromise = fnSwitchTenantWorkspace(
|
|
207
|
+
{ strTenantId: 'tenant-a', strWorkspaceId: 'workspace-b' },
|
|
208
|
+
{ objAdapter: { fnSwitch: async ({ objTarget }) => objTarget } }
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
await expect(objFirstPromise).rejects.toMatchObject({ name: 'AbortError' })
|
|
212
|
+
await expect(objSecondPromise).resolves.toMatchObject({
|
|
213
|
+
strWorkspaceId: 'workspace-b',
|
|
214
|
+
})
|
|
215
|
+
expect(fnGetTenantWorkspaceCurrent().strWorkspaceId).toBe('workspace-b')
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('exposes failed state and retry through the React provider', async () => {
|
|
219
|
+
let nAttempts = 0
|
|
220
|
+
const objAdapter: ITenantWorkspaceAdapter = {
|
|
221
|
+
fnSwitch: async ({ objTarget }) => {
|
|
222
|
+
nAttempts += 1
|
|
223
|
+
if (nAttempts === 1) throw new Error('temporary failure')
|
|
224
|
+
return objTarget
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
const objScreen = await render(
|
|
228
|
+
<TenantWorkspaceProvider objAdapter={objAdapter}>
|
|
229
|
+
<SwitchConsumer />
|
|
230
|
+
</TenantWorkspaceProvider>
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
await userEvent.click(objScreen.getByRole('button', { name: 'switch' }))
|
|
234
|
+
await expect
|
|
235
|
+
.element(objScreen.getByRole('status'))
|
|
236
|
+
.toHaveTextContent('error')
|
|
237
|
+
expect(fnGetTenantWorkspaceCurrent().strWorkspaceId).toBeUndefined()
|
|
238
|
+
|
|
239
|
+
await userEvent.click(objScreen.getByRole('button', { name: 'retry' }))
|
|
240
|
+
await expect
|
|
241
|
+
.element(objScreen.getByRole('status'))
|
|
242
|
+
.toHaveTextContent('idle')
|
|
243
|
+
await expect
|
|
244
|
+
.element(objScreen.getByRole('status'))
|
|
245
|
+
.toHaveAttribute('data-workspace', 'workspace-b')
|
|
246
|
+
expect(nAttempts).toBe(2)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it('uses stable classified errors when no adapter is configured', async () => {
|
|
250
|
+
await expect(
|
|
251
|
+
fnSwitchTenantWorkspace({
|
|
252
|
+
strTenantId: 'tenant-a',
|
|
253
|
+
strWorkspaceId: 'workspace-a',
|
|
254
|
+
})
|
|
255
|
+
).rejects.toBeInstanceOf(TenantWorkspaceError)
|
|
256
|
+
expect(fnGetTenantWorkspaceSnapshot().objTransition).toMatchObject({
|
|
257
|
+
strStatus: 'error',
|
|
258
|
+
objError: { strCode: 'adapter_missing' },
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nSchemaVersion": 1,
|
|
3
|
+
"arrBudgets": [
|
|
4
|
+
{
|
|
5
|
+
"strId": "bootstrap-js",
|
|
6
|
+
"strLabel": "应用启动 JavaScript",
|
|
7
|
+
"strOwner": "应用入口与运行时配置",
|
|
8
|
+
"strKind": "javascript",
|
|
9
|
+
"arrEntries": ["index.html"],
|
|
10
|
+
"nMaxGzipBytes": 86016
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"strId": "sign-in-js",
|
|
14
|
+
"strLabel": "登录旅程 JavaScript",
|
|
15
|
+
"strOwner": "认证 Feature 与访客路由",
|
|
16
|
+
"strKind": "javascript",
|
|
17
|
+
"arrEntries": [
|
|
18
|
+
"index.html",
|
|
19
|
+
"src/Application.tsx",
|
|
20
|
+
"src/router/router.ts",
|
|
21
|
+
"src/features/auth/index.ts"
|
|
22
|
+
],
|
|
23
|
+
"nMaxGzipBytes": 209920
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"strId": "dashboard-js",
|
|
27
|
+
"strLabel": "中性首页旅程 JavaScript",
|
|
28
|
+
"strOwner": "认证后壳层与首页 Feature",
|
|
29
|
+
"strKind": "javascript",
|
|
30
|
+
"arrEntries": [
|
|
31
|
+
"index.html",
|
|
32
|
+
"src/Application.tsx",
|
|
33
|
+
"src/router/router.ts",
|
|
34
|
+
"src/layouts/AppLayout.tsx",
|
|
35
|
+
"src/features/home/index.tsx"
|
|
36
|
+
],
|
|
37
|
+
"nMaxGzipBytes": 243712
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"strId": "bootstrap-css",
|
|
41
|
+
"strLabel": "应用启动 CSS",
|
|
42
|
+
"strOwner": "全局样式与主题",
|
|
43
|
+
"strKind": "stylesheet",
|
|
44
|
+
"arrEntries": ["index.html"],
|
|
45
|
+
"nMaxGzipBytes": 18432
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { lstat, readFile } from 'node:fs/promises'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { gzipSync } from 'node:zlib'
|
|
6
|
+
|
|
7
|
+
const strCurrentDirectory = path.dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
const strDefaultProjectRoot = path.resolve(strCurrentDirectory, '../..')
|
|
9
|
+
const strDefaultBudgetsPath = path.resolve(strCurrentDirectory, 'budgets.json')
|
|
10
|
+
|
|
11
|
+
const objBudgetSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
strId: z
|
|
14
|
+
.string()
|
|
15
|
+
.trim()
|
|
16
|
+
.regex(/^[a-z][a-z0-9-]*$/),
|
|
17
|
+
strLabel: z.string().trim().min(1),
|
|
18
|
+
strOwner: z.string().trim().min(1),
|
|
19
|
+
strKind: z.enum(['javascript', 'stylesheet']),
|
|
20
|
+
arrEntries: z.array(z.string().trim().min(1)).min(1),
|
|
21
|
+
nMaxGzipBytes: z.number().int().positive(),
|
|
22
|
+
})
|
|
23
|
+
.strict()
|
|
24
|
+
|
|
25
|
+
const objBudgetsSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
nSchemaVersion: z.literal(1),
|
|
28
|
+
arrBudgets: z.array(objBudgetSchema).min(1),
|
|
29
|
+
})
|
|
30
|
+
.strict()
|
|
31
|
+
.superRefine((objConfig, objContext) => {
|
|
32
|
+
const objIds = new Set()
|
|
33
|
+
objConfig.arrBudgets.forEach((objBudget, nIndex) => {
|
|
34
|
+
if (objIds.has(objBudget.strId)) {
|
|
35
|
+
objContext.addIssue({
|
|
36
|
+
code: 'custom',
|
|
37
|
+
message: `预算标识重复:${objBudget.strId}`,
|
|
38
|
+
path: ['arrBudgets', nIndex, 'strId'],
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
objIds.add(objBudget.strId)
|
|
42
|
+
if (new Set(objBudget.arrEntries).size !== objBudget.arrEntries.length) {
|
|
43
|
+
objContext.addIssue({
|
|
44
|
+
code: 'custom',
|
|
45
|
+
message: '入口列表不能包含重复项。',
|
|
46
|
+
path: ['arrBudgets', nIndex, 'arrEntries'],
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const objManifestEntrySchema = z
|
|
53
|
+
.object({
|
|
54
|
+
file: z.string().trim().min(1),
|
|
55
|
+
name: z.string().trim().min(1).optional(),
|
|
56
|
+
src: z.string().trim().min(1).optional(),
|
|
57
|
+
imports: z.array(z.string().trim().min(1)).default([]),
|
|
58
|
+
css: z.array(z.string().trim().min(1)).default([]),
|
|
59
|
+
})
|
|
60
|
+
.passthrough()
|
|
61
|
+
const objManifestSchema = z.record(z.string(), objManifestEntrySchema)
|
|
62
|
+
|
|
63
|
+
class BundleBudgetError extends Error {
|
|
64
|
+
constructor(strCode, strMessage) {
|
|
65
|
+
super(strMessage)
|
|
66
|
+
this.name = 'BundleBudgetError'
|
|
67
|
+
this.strCode = strCode
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const fnFormatIssues = (arrIssues) =>
|
|
72
|
+
arrIssues
|
|
73
|
+
.map(
|
|
74
|
+
(objIssue) => `${objIssue.path.join('.') || 'root'}: ${objIssue.message}`
|
|
75
|
+
)
|
|
76
|
+
.join('; ')
|
|
77
|
+
|
|
78
|
+
const fnReadJson = async (strFilePath, strCode) => {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(await readFile(strFilePath, 'utf8'))
|
|
81
|
+
} catch (objError) {
|
|
82
|
+
const strReason =
|
|
83
|
+
objError instanceof Error ? ` 原因:${objError.message}` : ''
|
|
84
|
+
throw new BundleBudgetError(
|
|
85
|
+
strCode,
|
|
86
|
+
`无法读取有效 JSON:${strFilePath}。${strReason}`
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const fnAssertSafeAssetPath = (strAssetPath) => {
|
|
92
|
+
if (
|
|
93
|
+
path.posix.isAbsolute(strAssetPath) ||
|
|
94
|
+
strAssetPath.includes('\\') ||
|
|
95
|
+
strAssetPath.split('/').includes('..')
|
|
96
|
+
) {
|
|
97
|
+
throw new BundleBudgetError(
|
|
98
|
+
'BUNDLE_MANIFEST_INVALID',
|
|
99
|
+
`Manifest 包含不安全的产物路径:${strAssetPath}。`
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const fnValidateBudgets = (objInput) => {
|
|
105
|
+
const objResult = objBudgetsSchema.safeParse(objInput)
|
|
106
|
+
if (!objResult.success) {
|
|
107
|
+
throw new BundleBudgetError(
|
|
108
|
+
'BUNDLE_BUDGET_CONFIG_INVALID',
|
|
109
|
+
`体积预算配置不符合契约:${fnFormatIssues(objResult.error.issues)}`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
return objResult.data
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const fnValidateManifest = (objInput) => {
|
|
116
|
+
const objResult = objManifestSchema.safeParse(objInput)
|
|
117
|
+
if (!objResult.success || Object.keys(objResult.data ?? {}).length === 0) {
|
|
118
|
+
throw new BundleBudgetError(
|
|
119
|
+
'BUNDLE_MANIFEST_INVALID',
|
|
120
|
+
objResult.success
|
|
121
|
+
? 'Vite Manifest 不能为空。'
|
|
122
|
+
: `Vite Manifest 不符合契约:${fnFormatIssues(objResult.error.issues)}`
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
for (const objEntry of Object.values(objResult.data)) {
|
|
126
|
+
fnAssertSafeAssetPath(objEntry.file)
|
|
127
|
+
objEntry.css.forEach(fnAssertSafeAssetPath)
|
|
128
|
+
}
|
|
129
|
+
return objResult.data
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const fnCollectStaticEntries = (objManifest, arrEntryKeys) => {
|
|
133
|
+
const arrPendingKeys = [...arrEntryKeys]
|
|
134
|
+
const objEntryKeys = new Set()
|
|
135
|
+
while (arrPendingKeys.length > 0) {
|
|
136
|
+
const strEntryKey = arrPendingKeys.pop()
|
|
137
|
+
if (!strEntryKey || objEntryKeys.has(strEntryKey)) continue
|
|
138
|
+
const objEntry = objManifest[strEntryKey]
|
|
139
|
+
if (!objEntry) {
|
|
140
|
+
throw new BundleBudgetError(
|
|
141
|
+
'BUNDLE_MANIFEST_ENTRY_MISSING',
|
|
142
|
+
`Vite Manifest 缺少预算入口或静态依赖:${strEntryKey}。`
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
objEntryKeys.add(strEntryKey)
|
|
146
|
+
arrPendingKeys.push(...objEntry.imports)
|
|
147
|
+
}
|
|
148
|
+
return [...objEntryKeys]
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const fnResolveAssetOwner = (strEntryKey, objEntry) =>
|
|
152
|
+
objEntry.src ?? objEntry.name ?? strEntryKey.replace(/^_/, '')
|
|
153
|
+
|
|
154
|
+
const fnCollectBudgetAssets = (objManifest, objBudget) => {
|
|
155
|
+
const arrEntryKeys = fnCollectStaticEntries(objManifest, objBudget.arrEntries)
|
|
156
|
+
const objAssets = new Map()
|
|
157
|
+
for (const strEntryKey of arrEntryKeys) {
|
|
158
|
+
const objEntry = objManifest[strEntryKey]
|
|
159
|
+
const strOwner = fnResolveAssetOwner(strEntryKey, objEntry)
|
|
160
|
+
if (
|
|
161
|
+
objBudget.strKind === 'javascript' &&
|
|
162
|
+
objEntry.file.endsWith('.js') &&
|
|
163
|
+
!objAssets.has(objEntry.file)
|
|
164
|
+
) {
|
|
165
|
+
objAssets.set(objEntry.file, strOwner)
|
|
166
|
+
}
|
|
167
|
+
if (objBudget.strKind === 'stylesheet') {
|
|
168
|
+
for (const strCssFile of objEntry.css) {
|
|
169
|
+
if (!objAssets.has(strCssFile)) objAssets.set(strCssFile, strOwner)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (objAssets.size === 0) {
|
|
174
|
+
throw new BundleBudgetError(
|
|
175
|
+
'BUNDLE_MANIFEST_INVALID',
|
|
176
|
+
`预算 ${objBudget.strId} 没有匹配到 ${objBudget.strKind} 产物。`
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
return objAssets
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const fnReadGzipSize = async (strDistRoot, strAssetPath) => {
|
|
183
|
+
fnAssertSafeAssetPath(strAssetPath)
|
|
184
|
+
const strFilePath = path.resolve(strDistRoot, strAssetPath)
|
|
185
|
+
let objStats
|
|
186
|
+
try {
|
|
187
|
+
objStats = await lstat(strFilePath)
|
|
188
|
+
} catch (objError) {
|
|
189
|
+
const strReason =
|
|
190
|
+
objError instanceof Error ? ` 原因:${objError.message}` : ''
|
|
191
|
+
throw new BundleBudgetError(
|
|
192
|
+
'BUNDLE_ASSET_INVALID',
|
|
193
|
+
`Manifest 产物不存在:${strAssetPath}。${strReason}`
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
if (!objStats.isFile() || objStats.isSymbolicLink()) {
|
|
197
|
+
throw new BundleBudgetError(
|
|
198
|
+
'BUNDLE_ASSET_INVALID',
|
|
199
|
+
`Manifest 产物必须是普通文件且不能是符号链接:${strAssetPath}。`
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
return gzipSync(await readFile(strFilePath), { level: 9 }).length
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 基于 Vite 静态依赖图计算关键用户旅程的 gzip 传输体积。 */
|
|
206
|
+
export async function fnCheckBundleBudgets({
|
|
207
|
+
strBudgetsPath = strDefaultBudgetsPath,
|
|
208
|
+
strDistRoot = path.resolve(strDefaultProjectRoot, 'dist'),
|
|
209
|
+
} = {}) {
|
|
210
|
+
const strResolvedDistRoot = path.resolve(strDistRoot)
|
|
211
|
+
const [objBudgetInput, objManifestInput] = await Promise.all([
|
|
212
|
+
fnReadJson(path.resolve(strBudgetsPath), 'BUNDLE_BUDGET_CONFIG_INVALID'),
|
|
213
|
+
fnReadJson(
|
|
214
|
+
path.resolve(strResolvedDistRoot, '.vite/manifest.json'),
|
|
215
|
+
'BUNDLE_MANIFEST_INVALID'
|
|
216
|
+
),
|
|
217
|
+
])
|
|
218
|
+
const objConfig = fnValidateBudgets(objBudgetInput)
|
|
219
|
+
const objManifest = fnValidateManifest(objManifestInput)
|
|
220
|
+
const objGzipSizeCache = new Map()
|
|
221
|
+
const arrResults = []
|
|
222
|
+
|
|
223
|
+
for (const objBudget of objConfig.arrBudgets) {
|
|
224
|
+
const objAssets = fnCollectBudgetAssets(objManifest, objBudget)
|
|
225
|
+
const arrAssets = []
|
|
226
|
+
for (const [strAssetPath, strOwner] of objAssets) {
|
|
227
|
+
let nGzipBytes = objGzipSizeCache.get(strAssetPath)
|
|
228
|
+
if (nGzipBytes === undefined) {
|
|
229
|
+
nGzipBytes = await fnReadGzipSize(strResolvedDistRoot, strAssetPath)
|
|
230
|
+
objGzipSizeCache.set(strAssetPath, nGzipBytes)
|
|
231
|
+
}
|
|
232
|
+
arrAssets.push({ nGzipBytes, strAssetPath, strOwner })
|
|
233
|
+
}
|
|
234
|
+
arrAssets.sort(
|
|
235
|
+
(objLeft, objRight) => objRight.nGzipBytes - objLeft.nGzipBytes
|
|
236
|
+
)
|
|
237
|
+
const nGzipBytes = arrAssets.reduce(
|
|
238
|
+
(nTotal, objAsset) => nTotal + objAsset.nGzipBytes,
|
|
239
|
+
0
|
|
240
|
+
)
|
|
241
|
+
arrResults.push({
|
|
242
|
+
...objBudget,
|
|
243
|
+
arrAssets,
|
|
244
|
+
bPassed: nGzipBytes <= objBudget.nMaxGzipBytes,
|
|
245
|
+
nGzipBytes,
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
arrResults,
|
|
251
|
+
bPassed: arrResults.every((objResult) => objResult.bPassed),
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const fnFormatKiB = (nBytes) => `${(nBytes / 1024).toFixed(2)} KiB`
|
|
256
|
+
|
|
257
|
+
const fnPrintReport = (objReport) => {
|
|
258
|
+
for (const objResult of objReport.arrResults) {
|
|
259
|
+
const strLevel = objResult.bPassed ? 'PASS' : 'ERROR'
|
|
260
|
+
const strCode = objResult.bPassed
|
|
261
|
+
? 'BUNDLE_BUDGET_OK'
|
|
262
|
+
: 'BUNDLE_BUDGET_EXCEEDED'
|
|
263
|
+
process.stdout.write(
|
|
264
|
+
`[${strLevel}] ${strCode} ${objResult.strId} ${objResult.strLabel}:` +
|
|
265
|
+
`${fnFormatKiB(objResult.nGzipBytes)} / ${fnFormatKiB(objResult.nMaxGzipBytes)};` +
|
|
266
|
+
`Owner:${objResult.strOwner}。\n`
|
|
267
|
+
)
|
|
268
|
+
if (!objResult.bPassed) {
|
|
269
|
+
process.stdout.write(' 主要 Chunk:\n')
|
|
270
|
+
for (const objAsset of objResult.arrAssets.slice(0, 5)) {
|
|
271
|
+
process.stdout.write(
|
|
272
|
+
` - ${objAsset.strOwner} / ${objAsset.strAssetPath} / ` +
|
|
273
|
+
`${fnFormatKiB(objAsset.nGzipBytes)}\n`
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
process.stdout.write(
|
|
277
|
+
' 修复:检查上述入口最近新增的静态依赖,按路由或可选能力拆分后重新构建。\n'
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (!objReport.bPassed) process.exitCode = 1
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const fnRunCli = async () => {
|
|
285
|
+
try {
|
|
286
|
+
if (process.argv.length > 2) {
|
|
287
|
+
throw new BundleBudgetError(
|
|
288
|
+
'BUNDLE_BUDGET_ARGUMENT_INVALID',
|
|
289
|
+
'bundle:check 不接受参数;预算由 tools/bundle/budgets.json 统一维护。'
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
fnPrintReport(await fnCheckBundleBudgets())
|
|
293
|
+
} catch (objError) {
|
|
294
|
+
const strCode =
|
|
295
|
+
objError instanceof BundleBudgetError
|
|
296
|
+
? objError.strCode
|
|
297
|
+
: 'BUNDLE_BUDGET_CHECK_FAILED'
|
|
298
|
+
const strMessage =
|
|
299
|
+
objError instanceof Error ? objError.message : '构建体积检查失败。'
|
|
300
|
+
process.stderr.write(`[ERROR] ${strCode} ${strMessage}\n`)
|
|
301
|
+
process.exitCode = 1
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (path.resolve(process.argv[1] ?? '') === fileURLToPath(import.meta.url)) {
|
|
306
|
+
await fnRunCli()
|
|
307
|
+
}
|