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,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cloneTableRows,
|
|
3
|
+
flattenTableRows,
|
|
4
|
+
removeTableRows,
|
|
5
|
+
replaceTableRow,
|
|
6
|
+
replaceTableRows,
|
|
7
|
+
} from '../../shared/treeRows'
|
|
8
|
+
import type { TableRow } from '../../shared/types'
|
|
9
|
+
import { cloneTableValue } from '../../shared/valueSnapshot'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 最近一次服务端基线。树快照负责放弃修改,按 key 索引负责 patch/版本查询;两者只能
|
|
13
|
+
* 通过本类同步更新,避免提交结算遗漏其中一份状态。
|
|
14
|
+
*/
|
|
15
|
+
export class TableBaselineStore<T extends TableRow> {
|
|
16
|
+
private rows: T[] = []
|
|
17
|
+
private byKey = new Map<string, T>()
|
|
18
|
+
private versions = new Map<string, string | number | undefined>()
|
|
19
|
+
|
|
20
|
+
prepareReset(
|
|
21
|
+
rows: readonly T[],
|
|
22
|
+
getEncodedKey: (row: T) => string,
|
|
23
|
+
getVersion?: (row: T) => string | number | undefined,
|
|
24
|
+
resolvedEncodedKeys?: readonly string[]
|
|
25
|
+
) {
|
|
26
|
+
const snapshot = cloneTableRows(rows)
|
|
27
|
+
const byKey = new Map<string, T>()
|
|
28
|
+
const versions = new Map<string, string | number | undefined>()
|
|
29
|
+
const flattened = flattenTableRows(snapshot)
|
|
30
|
+
if (
|
|
31
|
+
resolvedEncodedKeys &&
|
|
32
|
+
resolvedEncodedKeys.length !== flattened.length
|
|
33
|
+
) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
'[TableComponent] Prepared row identity count does not match the data tree.'
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
flattened.forEach((row, index) => {
|
|
39
|
+
const key = resolvedEncodedKeys?.[index] ?? getEncodedKey(row)
|
|
40
|
+
byKey.set(key, row)
|
|
41
|
+
versions.set(key, getVersion?.(row))
|
|
42
|
+
})
|
|
43
|
+
return () => {
|
|
44
|
+
this.rows = snapshot
|
|
45
|
+
this.byKey.clear()
|
|
46
|
+
byKey.forEach((row, key) => this.byKey.set(key, row))
|
|
47
|
+
this.versions.clear()
|
|
48
|
+
versions.forEach((version, key) => this.versions.set(key, version))
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
cloneRows() {
|
|
53
|
+
return cloneTableRows(this.rows)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getRow(key: string) {
|
|
57
|
+
return this.byKey.get(key)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getVersion(key: string) {
|
|
61
|
+
return this.versions.get(key)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set(key: string, row: T, version?: string | number) {
|
|
65
|
+
this.byKey.set(key, row)
|
|
66
|
+
this.versions.set(key, version)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
delete(key: string) {
|
|
70
|
+
this.byKey.delete(key)
|
|
71
|
+
this.versions.delete(key)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
replaceRow(
|
|
75
|
+
key: string,
|
|
76
|
+
row: T,
|
|
77
|
+
version: string | number | undefined,
|
|
78
|
+
matches: (row: T) => boolean
|
|
79
|
+
) {
|
|
80
|
+
this.set(key, row, version)
|
|
81
|
+
this.rows = replaceTableRow(this.rows, matches, cloneTableValue(row)).rows
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 在不修改当前基线的前提下计算完整提交结果。调用返回的 commit 只交换已经构建
|
|
86
|
+
* 完成的集合,业务 rowKey/getVersion 回调不会进入最终提交区。
|
|
87
|
+
*/
|
|
88
|
+
prepareSettlement(options: {
|
|
89
|
+
upserts: readonly {
|
|
90
|
+
key: string
|
|
91
|
+
row: T
|
|
92
|
+
version: string | number | undefined
|
|
93
|
+
rootIndex?: number
|
|
94
|
+
}[]
|
|
95
|
+
removedKeys: ReadonlySet<string>
|
|
96
|
+
getEncodedKey: (row: T) => string
|
|
97
|
+
}) {
|
|
98
|
+
const nextByKey = new Map(this.byKey)
|
|
99
|
+
const nextVersions = new Map(this.versions)
|
|
100
|
+
const replacements = new Map<string, T>()
|
|
101
|
+
let nextRows = this.rows
|
|
102
|
+
|
|
103
|
+
options.upserts.forEach(({ key, row, version, rootIndex }) => {
|
|
104
|
+
const snapshot = cloneTableValue(row)
|
|
105
|
+
nextByKey.set(key, snapshot)
|
|
106
|
+
nextVersions.set(key, version)
|
|
107
|
+
replacements.set(key, snapshot)
|
|
108
|
+
if (rootIndex !== undefined) {
|
|
109
|
+
nextRows = [...nextRows]
|
|
110
|
+
nextRows.splice(
|
|
111
|
+
rootIndex < 0 ? nextRows.length : rootIndex,
|
|
112
|
+
0,
|
|
113
|
+
cloneTableValue(snapshot)
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
options.removedKeys.forEach((key) => {
|
|
118
|
+
nextByKey.delete(key)
|
|
119
|
+
nextVersions.delete(key)
|
|
120
|
+
})
|
|
121
|
+
nextRows = replaceTableRows(nextRows, options.getEncodedKey, replacements)
|
|
122
|
+
if (options.removedKeys.size) {
|
|
123
|
+
nextRows = removeTableRows(nextRows, (row) =>
|
|
124
|
+
options.removedKeys.has(options.getEncodedKey(row))
|
|
125
|
+
).rows
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
this.rows = nextRows
|
|
130
|
+
this.byKey = nextByKey
|
|
131
|
+
this.versions = nextVersions
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import { TABLE_ENGINE_MESSAGES_ZH_CN } from '../../shared/messages'
|
|
2
|
+
import {
|
|
3
|
+
deleteTableRowValue,
|
|
4
|
+
getTableRowValue,
|
|
5
|
+
setTableRowValue,
|
|
6
|
+
} from '../../shared/row'
|
|
7
|
+
import { findTableRowEntry } from '../../shared/treeRows'
|
|
8
|
+
import type { TableRow } from '../../shared/types'
|
|
9
|
+
import { cloneTableValue } from '../../shared/valueSnapshot'
|
|
10
|
+
import { TableBaselineStore } from './baselineStore'
|
|
11
|
+
import {
|
|
12
|
+
applyTableCommitSettlement,
|
|
13
|
+
type PendingCreate,
|
|
14
|
+
type PendingRemove,
|
|
15
|
+
} from './changeSetSettlement'
|
|
16
|
+
import { TABLE_CLIENT_ROW_KEY_PREFIX } from './constants'
|
|
17
|
+
import {
|
|
18
|
+
createDirtyCellKey as cellKey,
|
|
19
|
+
TableDirtyCellIndex,
|
|
20
|
+
} from './dirtyCellIndex'
|
|
21
|
+
import { encodeTableRowKey, isRowKey } from './rowKey'
|
|
22
|
+
import type {
|
|
23
|
+
ChangeSet,
|
|
24
|
+
ChangeTrackerOptions,
|
|
25
|
+
CommitResult,
|
|
26
|
+
ConflictResolution,
|
|
27
|
+
DirtyCell,
|
|
28
|
+
RowKey,
|
|
29
|
+
TableCommitSettlement,
|
|
30
|
+
TableChangeSubmission,
|
|
31
|
+
VersionConflict,
|
|
32
|
+
} from './types'
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
ChangeSet,
|
|
36
|
+
ChangeSetHandler,
|
|
37
|
+
CommitResult,
|
|
38
|
+
ConflictResolution,
|
|
39
|
+
DirtyCell,
|
|
40
|
+
RowKey,
|
|
41
|
+
RowKeyResolver,
|
|
42
|
+
TableChangeSubmission,
|
|
43
|
+
VersionConflict,
|
|
44
|
+
} from './types'
|
|
45
|
+
|
|
46
|
+
let fallbackClientKey = 0
|
|
47
|
+
|
|
48
|
+
const defaultClientKey = () => {
|
|
49
|
+
const id = globalThis.crypto?.randomUUID?.()
|
|
50
|
+
return `${TABLE_CLIENT_ROW_KEY_PREFIX}${id ?? `${Date.now()}:${++fallbackClientKey}`}`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 显式保存模式的变更跟踪器。
|
|
55
|
+
*
|
|
56
|
+
* baseline 保存最近一次查询或成功提交后的服务端状态;dirtyCells/creates/removes 只
|
|
57
|
+
* 保存相对基线的增量。部分提交失败不会清空成功以外的变更,版本冲突也保留用户
|
|
58
|
+
* patch,供调用方选择“使用服务端”或“基于新版本保留我的修改”。
|
|
59
|
+
*/
|
|
60
|
+
export class TableChangeTracker<T extends TableRow = TableRow> {
|
|
61
|
+
private readonly baseline = new TableBaselineStore<T>()
|
|
62
|
+
private dirtyCells = new TableDirtyCellIndex()
|
|
63
|
+
private creates = new Map<string, PendingCreate<T>>()
|
|
64
|
+
private removes = new Map<string, PendingRemove<T>>()
|
|
65
|
+
private versionConflicts = new Map<string, VersionConflict<T>>()
|
|
66
|
+
private conflictListCache: readonly VersionConflict<T>[] | null = null
|
|
67
|
+
private conflictCellKeys = new Set<string>()
|
|
68
|
+
private generation = 0
|
|
69
|
+
private fieldGenerations = new Map<string, number>()
|
|
70
|
+
private activeSubmissionGeneration: number | null = null
|
|
71
|
+
|
|
72
|
+
constructor(private readonly options: ChangeTrackerOptions<T>) {}
|
|
73
|
+
|
|
74
|
+
/** 返回 Controller 装配时验证过的统一行身份解析器。 */
|
|
75
|
+
get rowKeyResolver() {
|
|
76
|
+
return this.options.rowKey
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get isDirty() {
|
|
80
|
+
return Boolean(
|
|
81
|
+
this.dirtyCells.size ||
|
|
82
|
+
this.creates.size ||
|
|
83
|
+
this.removes.size ||
|
|
84
|
+
this.versionConflicts.size
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get dirtyCount() {
|
|
89
|
+
return this.dirtyCells.size + this.creates.size + this.removes.size
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get pendingCreateCount() {
|
|
93
|
+
return this.creates.size
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get pendingRemoveCount() {
|
|
97
|
+
return this.removes.size
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get cells(): readonly DirtyCell[] {
|
|
101
|
+
return this.dirtyCells.cells
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get conflicts(): readonly VersionConflict<T>[] {
|
|
105
|
+
this.conflictListCache ??= Object.freeze(
|
|
106
|
+
[...this.versionConflicts.values()].map((conflict) =>
|
|
107
|
+
Object.freeze({
|
|
108
|
+
...conflict,
|
|
109
|
+
fields: [...conflict.fields],
|
|
110
|
+
userPatch: cloneTableValue(conflict.userPatch),
|
|
111
|
+
serverRow: cloneTableValue(conflict.serverRow),
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
return this.conflictListCache
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 按行身份和字段常量时间读取最近一次提交错误。 */
|
|
119
|
+
getCellError(rowKey: RowKey, prop: string) {
|
|
120
|
+
return this.dirtyCells.get(cellKey(rowKey, prop))?.error
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** 按行身份和字段常量时间判断是否存在版本冲突。 */
|
|
124
|
+
hasCellConflict(rowKey: RowKey, prop: string) {
|
|
125
|
+
return this.conflictCellKeys.has(cellKey(rowKey, prop))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** 返回变更世代,用于保存前确认异步校验期间没有发生新编辑。 */
|
|
129
|
+
get revision() {
|
|
130
|
+
return this.generation
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getRowKey(row: T): RowKey {
|
|
134
|
+
const value =
|
|
135
|
+
typeof this.options.rowKey === 'function'
|
|
136
|
+
? this.options.rowKey(row)
|
|
137
|
+
: getTableRowValue(row, this.options.rowKey)
|
|
138
|
+
if (!isRowKey(value)) {
|
|
139
|
+
throw new Error('[TableComponent] Every editable row requires a rowKey.')
|
|
140
|
+
}
|
|
141
|
+
return value
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private setRowKey(row: T, rowKey: RowKey) {
|
|
145
|
+
const resolver = this.options.rowKey
|
|
146
|
+
if (typeof resolver === 'function') return
|
|
147
|
+
setTableRowValue(row, resolver, rowKey)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** 预先构建完整编辑基线;返回函数执行前不会改写 tracker。 */
|
|
151
|
+
prepareReset(rows: readonly T[], resolvedKeys?: readonly RowKey[]) {
|
|
152
|
+
const commitBaseline = this.baseline.prepareReset(
|
|
153
|
+
rows,
|
|
154
|
+
(row) => encodeTableRowKey(this.getRowKey(row)),
|
|
155
|
+
this.options.getVersion,
|
|
156
|
+
resolvedKeys?.map(encodeTableRowKey)
|
|
157
|
+
)
|
|
158
|
+
return () => {
|
|
159
|
+
commitBaseline()
|
|
160
|
+
this.clearPendingState()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
reset(rows: readonly T[], resolvedKeys?: readonly RowKey[]) {
|
|
165
|
+
// reset 只允许在数据整体替换或确认提交基线后调用,会清除全部待处理事务状态。
|
|
166
|
+
this.prepareReset(rows, resolvedKeys)()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private clearPendingState() {
|
|
170
|
+
this.clearDirtyCells()
|
|
171
|
+
this.creates.clear()
|
|
172
|
+
this.removes.clear()
|
|
173
|
+
this.versionConflicts.clear()
|
|
174
|
+
this.conflictListCache = null
|
|
175
|
+
this.conflictCellKeys.clear()
|
|
176
|
+
this.fieldGenerations.clear()
|
|
177
|
+
this.activeSubmissionGeneration = null
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
trackCell(row: T, prop: string, oldValue: unknown, newValue: unknown) {
|
|
181
|
+
const rowKey = this.getRowKey(row)
|
|
182
|
+
const generation = ++this.generation
|
|
183
|
+
const key = cellKey(rowKey, prop)
|
|
184
|
+
const created = this.creates.get(String(rowKey))
|
|
185
|
+
if (created) {
|
|
186
|
+
created.row = row
|
|
187
|
+
created.error = undefined
|
|
188
|
+
if (this.activeSubmissionGeneration !== null)
|
|
189
|
+
this.fieldGenerations.set(key, generation)
|
|
190
|
+
else this.fieldGenerations.delete(key)
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const existing = this.dirtyCells.get(key)
|
|
195
|
+
const original = existing?.original ?? oldValue
|
|
196
|
+
// 用户改回原值时删除脏记录,而不是生成空 patch。
|
|
197
|
+
if (Object.is(original, newValue)) {
|
|
198
|
+
this.removeDirtyCell(key)
|
|
199
|
+
if (this.activeSubmissionGeneration === null)
|
|
200
|
+
this.fieldGenerations.delete(key)
|
|
201
|
+
else this.fieldGenerations.set(key, generation)
|
|
202
|
+
} else {
|
|
203
|
+
this.fieldGenerations.set(key, generation)
|
|
204
|
+
this.upsertDirtyCell(key, {
|
|
205
|
+
rowKey,
|
|
206
|
+
prop,
|
|
207
|
+
original,
|
|
208
|
+
current: newValue,
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const conflictKey = encodeTableRowKey(rowKey)
|
|
213
|
+
const conflict = this.versionConflicts.get(conflictKey)
|
|
214
|
+
if (conflict) {
|
|
215
|
+
const userPatch = cloneTableValue(conflict.userPatch)
|
|
216
|
+
if (Object.is(getTableRowValue(conflict.serverRow, prop), newValue)) {
|
|
217
|
+
deleteTableRowValue(userPatch, prop)
|
|
218
|
+
} else {
|
|
219
|
+
setTableRowValue(userPatch, prop, newValue)
|
|
220
|
+
}
|
|
221
|
+
this.versionConflicts.set(conflictKey, {
|
|
222
|
+
...conflict,
|
|
223
|
+
userPatch,
|
|
224
|
+
fields: Object.keys(userPatch),
|
|
225
|
+
})
|
|
226
|
+
this.invalidateConflictCaches()
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** 为新增行预留 client key;提交前失败可恢复调用方原始行对象。 */
|
|
231
|
+
prepareAdd(
|
|
232
|
+
row: T,
|
|
233
|
+
clientKey = this.options.createClientKey?.() ?? defaultClientKey()
|
|
234
|
+
) {
|
|
235
|
+
// client: 前缀把未落库行与真实后端身份隔离,也供选择状态机识别。
|
|
236
|
+
if (!clientKey.startsWith(TABLE_CLIENT_ROW_KEY_PREFIX)) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`[TableComponent] Client row keys must start with "${TABLE_CLIENT_ROW_KEY_PREFIX}".`
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
const resolver = this.options.rowKey
|
|
242
|
+
const previousKey =
|
|
243
|
+
typeof resolver === 'function'
|
|
244
|
+
? undefined
|
|
245
|
+
: cloneTableValue(getTableRowValue(row, resolver))
|
|
246
|
+
this.setRowKey(row, clientKey)
|
|
247
|
+
let completed = false
|
|
248
|
+
return {
|
|
249
|
+
clientKey,
|
|
250
|
+
commit: () => {
|
|
251
|
+
if (completed) return
|
|
252
|
+
completed = true
|
|
253
|
+
this.creates.set(clientKey, { row })
|
|
254
|
+
this.generation += 1
|
|
255
|
+
},
|
|
256
|
+
rollback: () => {
|
|
257
|
+
if (completed || typeof resolver === 'function') return
|
|
258
|
+
if (previousKey === undefined) deleteTableRowValue(row, resolver)
|
|
259
|
+
else setTableRowValue(row, resolver, previousKey)
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
add(
|
|
265
|
+
row: T,
|
|
266
|
+
clientKey = this.options.createClientKey?.() ?? defaultClientKey()
|
|
267
|
+
) {
|
|
268
|
+
const prepared = this.prepareAdd(row, clientKey)
|
|
269
|
+
prepared.commit()
|
|
270
|
+
return prepared.clientKey
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** 预解析整批行身份;返回的提交只修改内部集合且不再调用业务 rowKey 函数。 */
|
|
274
|
+
prepareRemoveRows(rows: readonly T[]) {
|
|
275
|
+
const prepared = rows.map((row) => ({ row, rowKey: this.getRowKey(row) }))
|
|
276
|
+
return () => {
|
|
277
|
+
prepared.forEach(({ row, rowKey }) => this.removePrepared(row, rowKey))
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
remove(row: T) {
|
|
282
|
+
this.prepareRemoveRows([row])()
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private removePrepared(row: T, rowKey: RowKey) {
|
|
286
|
+
if (typeof rowKey === 'string' && this.creates.delete(rowKey)) {
|
|
287
|
+
this.deleteDirtyCells(rowKey)
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
this.removes.set(encodeTableRowKey(rowKey), { row: { ...row } })
|
|
291
|
+
this.generation += 1
|
|
292
|
+
this.deleteDirtyCells(rowKey)
|
|
293
|
+
if (this.versionConflicts.delete(encodeTableRowKey(rowKey)))
|
|
294
|
+
this.invalidateConflictCaches()
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private deleteDirtyCells(rowKey: RowKey) {
|
|
298
|
+
const rowPrefix = `${encodeTableRowKey(rowKey)}\u0000`
|
|
299
|
+
this.dirtyCells.deleteRow(rowKey)
|
|
300
|
+
for (const key of this.fieldGenerations.keys()) {
|
|
301
|
+
if (key.startsWith(rowPrefix)) this.fieldGenerations.delete(key)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private upsertDirtyCell(key: string, cell: DirtyCell) {
|
|
306
|
+
return this.dirtyCells.upsert(key, cell)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private removeDirtyCell(key: string) {
|
|
310
|
+
return this.dirtyCells.delete(key)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private clearDirtyCells() {
|
|
314
|
+
this.dirtyCells.clear()
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
private invalidateConflictCaches() {
|
|
318
|
+
this.conflictListCache = null
|
|
319
|
+
this.conflictCellKeys = new Set(
|
|
320
|
+
[...this.versionConflicts.values()].flatMap((conflict) =>
|
|
321
|
+
conflict.fields.map((prop) => cellKey(conflict.rowKey, prop))
|
|
322
|
+
)
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** 代际只服务于进行中的保存结算;事务结束后只保留仍脏字段,避免长期编辑泄漏。 */
|
|
327
|
+
private pruneFieldGenerations() {
|
|
328
|
+
for (const key of this.fieldGenerations.keys()) {
|
|
329
|
+
if (!this.dirtyCells.has(key)) this.fieldGenerations.delete(key)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
getChangeSet(): ChangeSet<T> {
|
|
334
|
+
// 多个脏单元格按 rowKey 聚合成一条 update patch。
|
|
335
|
+
const updates = new Map<string, ChangeSet<T>['updates'][number]>()
|
|
336
|
+
for (const cell of this.dirtyCells.values()) {
|
|
337
|
+
if (this.removes.has(encodeTableRowKey(cell.rowKey))) continue
|
|
338
|
+
const key = encodeTableRowKey(cell.rowKey)
|
|
339
|
+
const baseline = this.baseline.getRow(key)
|
|
340
|
+
let update = updates.get(key)
|
|
341
|
+
if (!update) {
|
|
342
|
+
const patch: Partial<T> = {}
|
|
343
|
+
update = {
|
|
344
|
+
rowKey: cell.rowKey,
|
|
345
|
+
baseVersion: baseline ? this.baseline.getVersion(key) : undefined,
|
|
346
|
+
patch,
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
setTableRowValue(update.patch, cell.prop, cell.current)
|
|
350
|
+
updates.set(key, update)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
creates: [...this.creates.entries()].map(([clientKey, item]) => ({
|
|
355
|
+
clientKey,
|
|
356
|
+
value: { ...item.row },
|
|
357
|
+
})),
|
|
358
|
+
updates: [...updates.values()],
|
|
359
|
+
removes: [...this.removes.entries()].map(([key, item]) => ({
|
|
360
|
+
rowKey: this.getRowKey(item.row),
|
|
361
|
+
baseVersion:
|
|
362
|
+
this.baseline.getVersion(key) ?? this.options.getVersion?.(item.row),
|
|
363
|
+
})),
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** 捕获保存请求对应的不可变 ChangeSet 与字段世代。 */
|
|
368
|
+
createSubmission(): TableChangeSubmission<T> {
|
|
369
|
+
this.activeSubmissionGeneration = this.generation
|
|
370
|
+
const submittedCellsByRow = new Map<string, Map<string, number>>()
|
|
371
|
+
this.dirtyCells.forEach((cell) => {
|
|
372
|
+
const key = cellKey(cell.rowKey, cell.prop)
|
|
373
|
+
const rowKey = encodeTableRowKey(cell.rowKey)
|
|
374
|
+
let rowCells = submittedCellsByRow.get(rowKey)
|
|
375
|
+
if (!rowCells) {
|
|
376
|
+
rowCells = new Map()
|
|
377
|
+
submittedCellsByRow.set(rowKey, rowCells)
|
|
378
|
+
}
|
|
379
|
+
rowCells.set(cell.prop, this.fieldGenerations.get(key) ?? 0)
|
|
380
|
+
})
|
|
381
|
+
return {
|
|
382
|
+
generation: this.generation,
|
|
383
|
+
changeSet: cloneTableValue(this.getChangeSet()),
|
|
384
|
+
cellGenerationsByRow: submittedCellsByRow,
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** 无论保存成功、失败或取消,都关闭 submission 世代并回收非脏字段记录。 */
|
|
389
|
+
finishSubmission(submission: TableChangeSubmission<T>) {
|
|
390
|
+
if (this.activeSubmissionGeneration !== submission.generation) return
|
|
391
|
+
this.activeSubmissionGeneration = null
|
|
392
|
+
this.pruneFieldGenerations()
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
discardRows(): T[] {
|
|
396
|
+
const rows = this.baseline.cloneRows()
|
|
397
|
+
// baseline 本身就是最近一次服务端快照,无需为了放弃修改再复制第二次。
|
|
398
|
+
this.clearPendingState()
|
|
399
|
+
return rows
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
resolveConflict(
|
|
403
|
+
rows: T[],
|
|
404
|
+
rowKey: RowKey,
|
|
405
|
+
resolution: ConflictResolution
|
|
406
|
+
): T[] {
|
|
407
|
+
const key = encodeTableRowKey(rowKey)
|
|
408
|
+
const conflict = this.versionConflicts.get(key)
|
|
409
|
+
if (!conflict) {
|
|
410
|
+
throw new Error(
|
|
411
|
+
`[TableComponent] No version conflict exists for row "${String(rowKey)}".`
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
const entry = findTableRowEntry(
|
|
415
|
+
rows,
|
|
416
|
+
(row) => this.getRowKey(row) === rowKey
|
|
417
|
+
)
|
|
418
|
+
if (!entry) {
|
|
419
|
+
throw new Error(
|
|
420
|
+
`[TableComponent] Cannot resolve conflict for missing row "${String(rowKey)}".`
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const serverRow = cloneTableValue(conflict.serverRow)
|
|
425
|
+
this.baseline.replaceRow(
|
|
426
|
+
key,
|
|
427
|
+
serverRow,
|
|
428
|
+
conflict.serverVersion ?? this.options.getVersion?.(serverRow),
|
|
429
|
+
(row) => this.getRowKey(row) === rowKey
|
|
430
|
+
)
|
|
431
|
+
if (this.versionConflicts.delete(key)) this.invalidateConflictCaches()
|
|
432
|
+
if (resolution === 'server') {
|
|
433
|
+
// 接受服务端版本:替换当前行并清除该行所有本地修改。
|
|
434
|
+
entry.parentRows[entry.index] = cloneTableValue(serverRow)
|
|
435
|
+
this.deleteDirtyCells(rowKey)
|
|
436
|
+
return rows
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// 保留我的修改:先更新基线,再把用户 patch 重新叠加为新的待提交变更。
|
|
440
|
+
const rebasedRow: T = { ...serverRow, ...conflict.userPatch }
|
|
441
|
+
entry.parentRows[entry.index] = rebasedRow
|
|
442
|
+
this.deleteDirtyCells(rowKey)
|
|
443
|
+
Object.entries(conflict.userPatch).forEach(([prop, current]) => {
|
|
444
|
+
const original = getTableRowValue(serverRow, prop)
|
|
445
|
+
if (!Object.is(original, current)) {
|
|
446
|
+
this.upsertDirtyCell(cellKey(rowKey, prop), {
|
|
447
|
+
rowKey,
|
|
448
|
+
prop,
|
|
449
|
+
original,
|
|
450
|
+
current,
|
|
451
|
+
})
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
return rows
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 结算请求发出前捕获的 submission。所有业务回调在修改 tracker 前完成;主键迁移
|
|
459
|
+
* 作为返回值交给 Controller,避免外部副作用进入 engine 提交区。
|
|
460
|
+
*/
|
|
461
|
+
applyCommitResult(
|
|
462
|
+
rows: T[],
|
|
463
|
+
result: CommitResult<T> | undefined,
|
|
464
|
+
submission: TableChangeSubmission<T>
|
|
465
|
+
): TableCommitSettlement<T> {
|
|
466
|
+
const settlement = applyTableCommitSettlement({
|
|
467
|
+
host: {
|
|
468
|
+
baseline: this.baseline,
|
|
469
|
+
dirtyCells: this.dirtyCells,
|
|
470
|
+
creates: this.creates,
|
|
471
|
+
removes: this.removes,
|
|
472
|
+
fieldGenerations: this.fieldGenerations,
|
|
473
|
+
versionConflicts: this.versionConflicts,
|
|
474
|
+
getRowKey: (row) => this.getRowKey(row),
|
|
475
|
+
setRowKey: (row, rowKey) => this.setRowKey(row, rowKey),
|
|
476
|
+
getVersion: this.options.getVersion,
|
|
477
|
+
deleteDirtyCells: (rowKey) => this.deleteDirtyCells(rowKey),
|
|
478
|
+
invalidateConflictCaches: () => this.invalidateConflictCaches(),
|
|
479
|
+
messages: this.options.messages ?? TABLE_ENGINE_MESSAGES_ZH_CN,
|
|
480
|
+
},
|
|
481
|
+
rows,
|
|
482
|
+
result,
|
|
483
|
+
submission,
|
|
484
|
+
})
|
|
485
|
+
this.finishSubmission(submission)
|
|
486
|
+
return settlement
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export const createTableChangeTracker = <T extends TableRow>(
|
|
491
|
+
options: ChangeTrackerOptions<T>
|
|
492
|
+
) => new TableChangeTracker(options)
|