xcore-doctype 0.3.0__py3-none-any.whl
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.
- xcore_doctype/__init__.py +64 -0
- xcore_doctype/aggregation.py +268 -0
- xcore_doctype/api/__init__.py +0 -0
- xcore_doctype/api/collab.py +201 -0
- xcore_doctype/api/desk.py +317 -0
- xcore_doctype/api/files.py +143 -0
- xcore_doctype/api/http.py +375 -0
- xcore_doctype/api/print.py +167 -0
- xcore_doctype/builder.py +504 -0
- xcore_doctype/channels.py +213 -0
- xcore_doctype/cli.py +480 -0
- xcore_doctype/collaboration.py +627 -0
- xcore_doctype/compute.py +313 -0
- xcore_doctype/context.py +179 -0
- xcore_doctype/csv_import.py +308 -0
- xcore_doctype/dashboards.py +318 -0
- xcore_doctype/db/__init__.py +0 -0
- xcore_doctype/db/access.py +68 -0
- xcore_doctype/db/rls.py +72 -0
- xcore_doctype/db/tables.py +286 -0
- xcore_doctype/decimals.py +50 -0
- xcore_doctype/desk_extensions.py +92 -0
- xcore_doctype/desk_template/README.md +34 -0
- xcore_doctype/desk_template/index.js +52 -0
- xcore_doctype/devtools.py +87 -0
- xcore_doctype/directory.py +107 -0
- xcore_doctype/document.py +3383 -0
- xcore_doctype/errors.py +115 -0
- xcore_doctype/expr.py +358 -0
- xcore_doctype/ext/__init__.py +1 -0
- xcore_doctype/ext/pubsub/README.md +122 -0
- xcore_doctype/ext/pubsub/__init__.py +0 -0
- xcore_doctype/ext/pubsub/provider/__init__.py +16 -0
- xcore_doctype/ext/pubsub/provider/base.py +49 -0
- xcore_doctype/ext/pubsub/provider/hyvemq.py +276 -0
- xcore_doctype/ext/pubsub/provider/memory.py +53 -0
- xcore_doctype/ext/pubsub/provider/redis.py +148 -0
- xcore_doctype/ext/pubsub/provider/section.py +43 -0
- xcore_doctype/ext/pubsub/service.py +163 -0
- xcore_doctype/ext/xpay/LICENSE +21 -0
- xcore_doctype/ext/xpay/README.md +1 -0
- xcore_doctype/ext/xpay/__init__.py +1 -0
- xcore_doctype/ext/xpay/providers/__init__.py +1 -0
- xcore_doctype/ext/xpay/providers/base.py +306 -0
- xcore_doctype/ext/xpay/providers/stripes/__init__.py +465 -0
- xcore_doctype/ext/xpay/providers/stripes/config.py +43 -0
- xcore_doctype/ext/xpay/service.py +152 -0
- xcore_doctype/ext/xstorage/__init__.py +1 -0
- xcore_doctype/ext/xstorage/backends.py +586 -0
- xcore_doctype/ext/xstorage/main.py +167 -0
- xcore_doctype/ext/xstorage/tenant_paths.py +77 -0
- xcore_doctype/ext/xstorage/uploader.py +273 -0
- xcore_doctype/ext/xwebsocket/CONTRIBUTORS.yml +10 -0
- xcore_doctype/ext/xwebsocket/INTEGRATION.md +87 -0
- xcore_doctype/ext/xwebsocket/README.md +74 -0
- xcore_doctype/ext/xwebsocket/__init__.py +1 -0
- xcore_doctype/ext/xwebsocket/main.py +121 -0
- xcore_doctype/ext/xwebsocket/service.yaml +9 -0
- xcore_doctype/ext/xwebsocket/ws.py +102 -0
- xcore_doctype/extensions.py +143 -0
- xcore_doctype/fieldtypes.py +258 -0
- xcore_doctype/file_library.py +207 -0
- xcore_doctype/file_service.py +268 -0
- xcore_doctype/files.py +182 -0
- xcore_doctype/flow_nodes_service.py +89 -0
- xcore_doctype/flownodes.py +203 -0
- xcore_doctype/flows.py +101 -0
- xcore_doctype/grants.py +54 -0
- xcore_doctype/hooks.py +389 -0
- xcore_doctype/integrity.py +72 -0
- xcore_doctype/mapping.py +203 -0
- xcore_doctype/memory.py +209 -0
- xcore_doctype/mount.py +61 -0
- xcore_doctype/naming.py +81 -0
- xcore_doctype/notification_rules.py +500 -0
- xcore_doctype/notifier.py +62 -0
- xcore_doctype/overrides.py +976 -0
- xcore_doctype/pdf.py +167 -0
- xcore_doctype/permissions.py +161 -0
- xcore_doctype/platform/xflow/INTEGRATION.md +729 -0
- xcore_doctype/platform/xflow/README.md +258 -0
- xcore_doctype/platform/xflow/docs/api-reference.md +121 -0
- xcore_doctype/platform/xflow/docs/examples.md +124 -0
- xcore_doctype/platform/xflow/docs/getting-started.md +139 -0
- xcore_doctype/platform/xflow/docs/installation.md +88 -0
- xcore_doctype/platform/xflow/docs/ipc-registry.md +49 -0
- xcore_doctype/platform/xflow/docs/plugin-integration.md +84 -0
- xcore_doctype/platform/xflow/docs/security.md +37 -0
- xcore_doctype/platform/xflow/docs/troubleshooting.md +56 -0
- xcore_doctype/platform/xflow/docs/workflow-dsl.md +241 -0
- xcore_doctype/platform/xflow/examples/ai_pipeline.yaml +105 -0
- xcore_doctype/platform/xflow/examples/onboarding_client.yaml +66 -0
- xcore_doctype/platform/xflow/examples/relance_facture.yaml +58 -0
- xcore_doctype/platform/xflow/migrations/env.py +91 -0
- xcore_doctype/platform/xflow/migrations/script.py.mako +28 -0
- xcore_doctype/platform/xflow/migrations/versions/952584a8d052_first_migration.py +81 -0
- xcore_doctype/platform/xflow/migrations/versions/c7a1e5d2f904_webhook_secrets.py +43 -0
- xcore_doctype/platform/xflow/plugin.yaml +167 -0
- xcore_doctype/platform/xflow/requirements.txt +25 -0
- xcore_doctype/platform/xflow/src/__init__.py +1 -0
- xcore_doctype/platform/xflow/src/main.py +890 -0
- xcore_doctype/platform/xflow/src/repositories/__init__.py +25 -0
- xcore_doctype/platform/xflow/src/repositories/models.py +147 -0
- xcore_doctype/platform/xflow/src/repositories/workflow.py +444 -0
- xcore_doctype/platform/xflow/src/runtime/__init__.py +12 -0
- xcore_doctype/platform/xflow/src/runtime/condition.py +119 -0
- xcore_doctype/platform/xflow/src/runtime/engine.py +529 -0
- xcore_doctype/platform/xflow/src/runtime/retry.py +82 -0
- xcore_doctype/platform/xflow/src/schemas/__init__.py +71 -0
- xcore_doctype/platform/xflow/src/schemas/composite.py +90 -0
- xcore_doctype/platform/xflow/src/schemas/events.py +47 -0
- xcore_doctype/platform/xflow/src/schemas/workflow.py +370 -0
- xcore_doctype/platform/xflow/src/services/__init__.py +15 -0
- xcore_doctype/platform/xflow/src/services/ai_gen.py +111 -0
- xcore_doctype/platform/xflow/src/services/composites.py +185 -0
- xcore_doctype/platform/xflow/src/services/discovery.py +156 -0
- xcore_doctype/platform/xflow/src/services/event_catalog.py +95 -0
- xcore_doctype/platform/xflow/src/services/registry.py +77 -0
- xcore_doctype/platform/xflow/src/services/scheduler.py +123 -0
- xcore_doctype/platform/xflow/src/services/webhook_auth.py +220 -0
- xcore_doctype/platform/xflow/src/services/webhooks.py +92 -0
- xcore_doctype/platform/xflow/src/workers/__init__.py +3 -0
- xcore_doctype/platform/xflow/src/workers/local_queue.py +49 -0
- xcore_doctype/platform/xlicense/CONTRIBUTORS.yaml +29 -0
- xcore_doctype/platform/xlicense/INTEGRATION.md +80 -0
- xcore_doctype/platform/xlicense/README.md +59 -0
- xcore_doctype/platform/xlicense/doctypes/license.yaml +33 -0
- xcore_doctype/platform/xlicense/doctypes/module.yaml +39 -0
- xcore_doctype/platform/xlicense/doctypes/tenant_module.yaml +38 -0
- xcore_doctype/platform/xlicense/migrations/env.py +71 -0
- xcore_doctype/platform/xlicense/migrations/versions/0001_initial.py +69 -0
- xcore_doctype/platform/xlicense/migrations/versions/0002_plan_modules.py +36 -0
- xcore_doctype/platform/xlicense/migrations/versions/0003_license_last_rotated_at.py +36 -0
- xcore_doctype/platform/xlicense/migrations/versions/0004_license_key_length.py +32 -0
- xcore_doctype/platform/xlicense/migrations/versions/0005_license_modules.py +51 -0
- xcore_doctype/platform/xlicense/migrations/versions/0006_tenant_modules.py +55 -0
- xcore_doctype/platform/xlicense/plugin.yaml +173 -0
- xcore_doctype/platform/xlicense/requirements.txt +3 -0
- xcore_doctype/platform/xlicense/src/doctypes.py +263 -0
- xcore_doctype/platform/xlicense/src/main.py +773 -0
- xcore_doctype/platform/xlicense/src/middleware.py +348 -0
- xcore_doctype/platform/xlicense/src/models/license.py +244 -0
- xcore_doctype/platform/xlicense/src/repositories/base.py +42 -0
- xcore_doctype/platform/xlicense/src/repositories/license.py +201 -0
- xcore_doctype/platform/xlicense/src/routes.py +962 -0
- xcore_doctype/platform/xlicense/src/schema_upgrade.py +31 -0
- xcore_doctype/platform/xlicense/src/schemas.py +49 -0
- xcore_doctype/platform/xlicense/src/services/__init__.py +5 -0
- xcore_doctype/platform/xlicense/src/services/events.py +128 -0
- xcore_doctype/platform/xlicense/src/services/jwt.py +134 -0
- xcore_doctype/platform/xlicense/src/services/license.py +750 -0
- xcore_doctype/platform/xlicense/src/services/seed.py +252 -0
- xcore_doctype/platform/xlicense/src/services/webhook.py +94 -0
- xcore_doctype/platform/xlicense/src/state_machine.py +141 -0
- xcore_doctype/platform/xlicense/workspaces/xlicense.yaml +18 -0
- xcore_doctype/platform/xprint/README.md +40 -0
- xcore_doctype/platform/xprint/plugin.yaml +17 -0
- xcore_doctype/platform/xprint/print/Delivery Note/standard.yaml +27 -0
- xcore_doctype/platform/xprint/print/Payment Entry/standard.yaml +22 -0
- xcore_doctype/platform/xprint/print/Purchase Order/standard.yaml +32 -0
- xcore_doctype/platform/xprint/print/Quotation/standard.yaml +34 -0
- xcore_doctype/platform/xprint/print/Sales Invoice/standard.yaml +38 -0
- xcore_doctype/platform/xprint/print/Sales Order/standard.yaml +31 -0
- xcore_doctype/platform/xprint/src/main.py +28 -0
- xcore_doctype/platform/xpulse/INTEGRATION.md +340 -0
- xcore_doctype/platform/xpulse/README.md +61 -0
- xcore_doctype/platform/xpulse/contributor.yaml +26 -0
- xcore_doctype/platform/xpulse/plugin.yaml +84 -0
- xcore_doctype/platform/xpulse/requirements.txt +8 -0
- xcore_doctype/platform/xpulse/src/bridge/__init__.py +3 -0
- xcore_doctype/platform/xpulse/src/bridge/billing.py +179 -0
- xcore_doctype/platform/xpulse/src/bridge/handlers.py +204 -0
- xcore_doctype/platform/xpulse/src/bridge/ipc.py +185 -0
- xcore_doctype/platform/xpulse/src/main.py +129 -0
- xcore_doctype/platform/xpulse/src/routes/__init__.py +20 -0
- xcore_doctype/platform/xpulse/src/routes/sse.py +201 -0
- xcore_doctype/platform/xpulse/src/utils.py +104 -0
- xcore_doctype/plugin.py +1132 -0
- xcore_doctype/plugin_dir/plugin.yaml +67 -0
- xcore_doctype/plugin_dir/src/main.py +7 -0
- xcore_doctype/preferences.py +77 -0
- xcore_doctype/print_document.py +436 -0
- xcore_doctype/print_service.py +485 -0
- xcore_doctype/printing.py +820 -0
- xcore_doctype/query.py +1585 -0
- xcore_doctype/realtime.py +68 -0
- xcore_doctype/registry.py +1138 -0
- xcore_doctype/schema.py +1378 -0
- xcore_doctype/sealing.py +53 -0
- xcore_doctype/sources.py +103 -0
- xcore_doctype/system_plugin_dir/doctypes/notification_rule.yaml +36 -0
- xcore_doctype/system_plugin_dir/doctypes/notification_rule_recipient.yaml +7 -0
- xcore_doctype/system_plugin_dir/doctypes/system_settings.yaml +28 -0
- xcore_doctype/system_plugin_dir/doctypes/user_permission.yaml +23 -0
- xcore_doctype/system_plugin_dir/plugin.yaml +8 -0
- xcore_doctype/system_plugin_dir/src/main.py +25 -0
- xcore_doctype/system_plugin_dir/translations/en.yaml +80 -0
- xcore_doctype/system_plugin_dir/translations/fr.yaml +4 -0
- xcore_doctype/system_plugin_dir/workspaces/system.yaml +13 -0
- xcore_doctype/tags.py +45 -0
- xcore_doctype/translations.py +189 -0
- xcore_doctype/ui/dist/assets/AccountSettings-DbBT9Sb3.js +1 -0
- xcore_doctype/ui/dist/assets/ApiDocsView-C9aAbqlf.js +1 -0
- xcore_doctype/ui/dist/assets/ApiDocsView-tegXkOfu.css +1 -0
- xcore_doctype/ui/dist/assets/ApiSettings-Bdf7oWyH.js +1 -0
- xcore_doctype/ui/dist/assets/AuditSettings-DV1SjGKs.js +1 -0
- xcore_doctype/ui/dist/assets/AutomationsView-GcY3kdz8.css +1 -0
- xcore_doctype/ui/dist/assets/AutomationsView-QRHi1BXA.js +1 -0
- xcore_doctype/ui/dist/assets/BillingReturnView-ClHxccyt.js +1 -0
- xcore_doctype/ui/dist/assets/BillingReturnView-DVLIzha2.css +1 -0
- xcore_doctype/ui/dist/assets/BlockEditor-8yuCDvGt.css +1 -0
- xcore_doctype/ui/dist/assets/BlockEditor-qoDD8GDM.js +251 -0
- xcore_doctype/ui/dist/assets/BlockGrid-CLFFObbc.css +1 -0
- xcore_doctype/ui/dist/assets/BlockGrid-Rlx4lkHi.js +1 -0
- xcore_doctype/ui/dist/assets/CanvasControls-DzeGdtNK.js +26 -0
- xcore_doctype/ui/dist/assets/CanvasControls-KAul5iyb.css +1 -0
- xcore_doctype/ui/dist/assets/DoctypeBuilderView-Bdfz4OdS.js +3 -0
- xcore_doctype/ui/dist/assets/FieldControl-BCFHDOH_.js +309 -0
- xcore_doctype/ui/dist/assets/FieldControl-C76Il2qP.css +1 -0
- xcore_doctype/ui/dist/assets/FilesView-CIkvgfER.js +1 -0
- xcore_doctype/ui/dist/assets/FilesView-sfX5slpb.css +1 -0
- xcore_doctype/ui/dist/assets/FlowBuilderView-Aw2lBAuR.js +1 -0
- xcore_doctype/ui/dist/assets/FlowNodesView-Chg0y9c3.js +3 -0
- xcore_doctype/ui/dist/assets/ForgotPasswordView-C3l3J6Go.js +1 -0
- xcore_doctype/ui/dist/assets/FormBuilderView-YDuCee4h.js +4 -0
- xcore_doctype/ui/dist/assets/FormView-BoNYRlb7.css +1 -0
- xcore_doctype/ui/dist/assets/FormView-CQzR77y6.js +1 -0
- xcore_doctype/ui/dist/assets/HomeView-DMFv9TTZ.css +1 -0
- xcore_doctype/ui/dist/assets/HomeView-LXYalOIO.js +1 -0
- xcore_doctype/ui/dist/assets/InviteView-ivSaAHdF.js +1 -0
- xcore_doctype/ui/dist/assets/ListView-C7n988S9.js +52 -0
- xcore_doctype/ui/dist/assets/ListView-DxWVzx8O.css +1 -0
- xcore_doctype/ui/dist/assets/LoginView-Dp4VcXee.css +1 -0
- xcore_doctype/ui/dist/assets/LoginView-Pon1rnWR.js +1 -0
- xcore_doctype/ui/dist/assets/MailSettings-CLh3HLoA.js +1 -0
- xcore_doctype/ui/dist/assets/ModulesView-CLjLJnW8.js +1 -0
- xcore_doctype/ui/dist/assets/ModulesView-DEmx4gh0.css +1 -0
- xcore_doctype/ui/dist/assets/NotFoundView-DlQiXKSL.js +1 -0
- xcore_doctype/ui/dist/assets/OAuthCallbackView-DSlvI0Vm.js +1 -0
- xcore_doctype/ui/dist/assets/OnboardingView-7SMOmggr.js +1 -0
- xcore_doctype/ui/dist/assets/OrganisationSettings-CI1lt7PA.js +1 -0
- xcore_doctype/ui/dist/assets/PermissionsCatalog-qHwjxsf2.js +1 -0
- xcore_doctype/ui/dist/assets/PlatformAccounts-ChZXE8Ha.js +1 -0
- xcore_doctype/ui/dist/assets/PrintBuilderView-CbENofmf.css +1 -0
- xcore_doctype/ui/dist/assets/PrintBuilderView-LsgTnYmy.js +13 -0
- xcore_doctype/ui/dist/assets/ProfileView-B-XkZ3IF.js +1 -0
- xcore_doctype/ui/dist/assets/RegisterView-BModgkY7.js +1 -0
- xcore_doctype/ui/dist/assets/ResetPasswordView-Cb7scXzf.js +1 -0
- xcore_doctype/ui/dist/assets/RichTextField-Dp5rnitZ.js +1 -0
- xcore_doctype/ui/dist/assets/RolesSettings-qbqoqxAZ.js +1 -0
- xcore_doctype/ui/dist/assets/SectionPanel-DYREM0cd.js +1 -0
- xcore_doctype/ui/dist/assets/SettingsView-pbZ3b0oC.js +2 -0
- xcore_doctype/ui/dist/assets/SharedView-Bs0IvurZ.js +1 -0
- xcore_doctype/ui/dist/assets/SharedView-wZOdbmxJ.css +1 -0
- xcore_doctype/ui/dist/assets/TasksView-CjGRBA0E.js +1 -0
- xcore_doctype/ui/dist/assets/TrashView-CZc2I25L.js +1 -0
- xcore_doctype/ui/dist/assets/TrashView-CanjxEgn.css +1 -0
- xcore_doctype/ui/dist/assets/UsersSettings-DvRpZF95.js +1 -0
- xcore_doctype/ui/dist/assets/WorkflowBuilderView-BhQaLQDt.js +1 -0
- xcore_doctype/ui/dist/assets/WorkspaceView-BGm6-OAJ.js +1 -0
- xcore_doctype/ui/dist/assets/automations-hhDKXkp6.js +1 -0
- xcore_doctype/ui/dist/assets/brand-CNTnXVwI.js +1 -0
- xcore_doctype/ui/dist/assets/checkbox-ef0y1kzn.js +142 -0
- xcore_doctype/ui/dist/assets/chip-DADHHEbU.js +532 -0
- xcore_doctype/ui/dist/assets/commands-C66pYMgo.js +1 -0
- xcore_doctype/ui/dist/assets/datatable-DN_NHK2H.js +783 -0
- xcore_doctype/ui/dist/assets/devtools-CxgSYwGp-CFZdhifa.js +1 -0
- xcore_doctype/ui/dist/assets/dist-CULTfZAs.js +130 -0
- xcore_doctype/ui/dist/assets/docstatus-BpU1uF2g.js +1 -0
- xcore_doctype/ui/dist/assets/download-D4dig1ly.js +1 -0
- xcore_doctype/ui/dist/assets/feed-BQBwhFiT.js +1 -0
- xcore_doctype/ui/dist/assets/flowcatalog-BNgMmaFY.js +1 -0
- xcore_doctype/ui/dist/assets/host-BrtqNGfZ.css +1 -0
- xcore_doctype/ui/dist/assets/host-DGiTWmyR.js +1 -0
- xcore_doctype/ui/dist/assets/index-BvChwCD-.css +1 -0
- xcore_doctype/ui/dist/assets/index-Cp9ZkRhM.js +398 -0
- xcore_doctype/ui/dist/assets/inputnumber-BsXb8eOF.js +196 -0
- xcore_doctype/ui/dist/assets/inputtext-oq2nczMW.js +79 -0
- xcore_doctype/ui/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- xcore_doctype/ui/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- xcore_doctype/ui/dist/assets/links-D17LZCPu.js +1040 -0
- xcore_doctype/ui/dist/assets/menu-DHipytHn.js +84 -0
- xcore_doctype/ui/dist/assets/message-Z-k_YRYE.js +316 -0
- xcore_doctype/ui/dist/assets/navstate-C6swSvNR.js +1 -0
- xcore_doctype/ui/dist/assets/paginator-0XRqpflA.js +126 -0
- xcore_doctype/ui/dist/assets/password-DEwoUl03.js +101 -0
- xcore_doctype/ui/dist/assets/preferences-y97M_zZr.js +1 -0
- xcore_doctype/ui/dist/assets/primeicons-C6QP2o4f.woff2 +0 -0
- xcore_doctype/ui/dist/assets/primeicons-DMOk5skT.eot +0 -0
- xcore_doctype/ui/dist/assets/primeicons-Dr5RGzOO.svg +345 -0
- xcore_doctype/ui/dist/assets/primeicons-MpK4pl85.ttf +0 -0
- xcore_doctype/ui/dist/assets/primeicons-WjwUDZjB.woff +0 -0
- xcore_doctype/ui/dist/assets/profile-CXi_Q171.js +1 -0
- xcore_doctype/ui/dist/assets/progressspinner-DOLCuzfk.js +74 -0
- xcore_doctype/ui/dist/assets/recents-D6_VGybi.js +1 -0
- xcore_doctype/ui/dist/assets/router-DjppRwu3.js +2 -0
- xcore_doctype/ui/dist/assets/runtime-dom.esm-bundler-s_FaoJf2.js +4 -0
- xcore_doctype/ui/dist/assets/select-D4g7v3dO.js +360 -0
- xcore_doctype/ui/dist/assets/selectbutton-BJDpAdcS.js +164 -0
- xcore_doctype/ui/dist/assets/session-P2yPOYPm.js +1 -0
- xcore_doctype/ui/dist/assets/tags-DbqUJmyX.js +1 -0
- xcore_doctype/ui/dist/assets/tasks-onnxPH8z.js +1 -0
- xcore_doctype/ui/dist/assets/textarea-D6vS6Msa.js +84 -0
- xcore_doctype/ui/dist/assets/units-DN6Pu1t7.css +1 -0
- xcore_doctype/ui/dist/assets/units-HQzRc9T3.js +1 -0
- xcore_doctype/ui/dist/assets/useAuth-BVFtKvqf.js +1 -0
- xcore_doctype/ui/dist/assets/useLive-C1ArRUjY.js +1 -0
- xcore_doctype/ui/dist/assets/useconfirm-0TwEId56.js +1 -0
- xcore_doctype/ui/dist/assets/users-B_7N1yU2.js +1 -0
- xcore_doctype/ui/dist/assets/vue-router-Ba5enW5N.js +1 -0
- xcore_doctype/ui/dist/assets/workspaces-BbKV_QlK.js +1 -0
- xcore_doctype/ui/dist/assets/xauth-mkWpqw7L.js +1 -0
- xcore_doctype/ui/dist/assets/xlicense-DJaSnq1j.js +1 -0
- xcore_doctype/ui/dist/index.html +38 -0
- xcore_doctype/ui/dist/shared/sdk.js +85 -0
- xcore_doctype/ui/dist/shared/vue.js +1 -0
- xcore_doctype/user_permissions.py +73 -0
- xcore_doctype/versions.py +37 -0
- xcore_doctype/workspaces.py +146 -0
- xcore_doctype/writer.py +151 -0
- xcore_doctype-0.3.0.dist-info/METADATA +175 -0
- xcore_doctype-0.3.0.dist-info/RECORD +329 -0
- xcore_doctype-0.3.0.dist-info/WHEEL +4 -0
- xcore_doctype-0.3.0.dist-info/entry_points.txt +6 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""xcore-doctype : moteur de DocTypes pour xcore.
|
|
2
|
+
|
|
3
|
+
API publique pour les auteurs de hooks (process/doctype.md D2, D16) :
|
|
4
|
+
|
|
5
|
+
from xcore_doctype import DocumentValidationError, HookEvent
|
|
6
|
+
|
|
7
|
+
async def check_credit(event: HookEvent) -> None:
|
|
8
|
+
if event.data.get("credit_limit", 0) > 100_000:
|
|
9
|
+
raise DocumentValidationError("Plafond trop élevé")
|
|
10
|
+
|
|
11
|
+
# dans on_load d'un plugin qui déclare `requires: [xcore-doctype]` :
|
|
12
|
+
self.get_service("doctype_hooks").register("sales.check_credit", check_credit, owner=self.ctx.name)
|
|
13
|
+
# dans on_unload :
|
|
14
|
+
self.get_service("doctype_hooks").unregister_owner(self.ctx.name)
|
|
15
|
+
|
|
16
|
+
Puis, dans la définition du DocType : `hooks: {validate: ["sales.check_credit"]}`.
|
|
17
|
+
|
|
18
|
+
Un plugin métier apporte aussi ses DocTypes (leur `module` doit être le nom du plugin) :
|
|
19
|
+
|
|
20
|
+
self.get_service("doctype_registry").load_dir(self.ctx.name, Path(__file__).parent.parent / "doctypes") # on_load
|
|
21
|
+
self.get_service("doctype_registry").unregister_owner(self.ctx.name) # on_unload
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from importlib import metadata, resources
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
from .errors import DocumentValidationError, HookRegistrationError
|
|
28
|
+
from .hooks import HookEvent, HookRegistry
|
|
29
|
+
from .mount import Config, mount_desk
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
__version__ = metadata.version("xcore-doctype")
|
|
33
|
+
except metadata.PackageNotFoundError: # exécuté depuis des sources non installées
|
|
34
|
+
__version__ = "0+unknown"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def plugin_dir() -> Path:
|
|
38
|
+
"""Le dossier de plugin embarqué (`plugin.yaml` + `src/main.py`), dans le paquet installé.
|
|
39
|
+
|
|
40
|
+
C'est aussi la cible de l'entry point `xcore.plugins` que le paquet déclare (process/doctype.md D1) : xcore ne le lit pas
|
|
41
|
+
encore (il ne découvre que des dossiers), `xcore-doctype install` pose donc une copie dans l'instance. Voir process/phase4.md.
|
|
42
|
+
"""
|
|
43
|
+
return Path(str(resources.files("xcore_doctype") / "plugin_dir"))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def system_plugin_dir() -> Path:
|
|
47
|
+
"""Le plugin `system` embarqué (réglages globaux : `System Settings`), que `xcore-doctype install` dépose à côté du moteur."""
|
|
48
|
+
return Path(str(resources.files("xcore_doctype") / "system_plugin_dir"))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
PLATFORM_PLUGINS = ("xlicense", "xpulse", "xprint", "xflow") # livrés par le paquet, posés par `xcore-doctype install` à côté du moteur
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def platform_plugins_dir() -> Path:
|
|
55
|
+
"""Les plugins de la PLATEFORME embarqués (`xlicense` : licences, modules et abonnements ; `xpulse` : notifications en temps réel,
|
|
56
|
+
SSE), que `xcore-doctype install` dépose à côté du moteur. Leurs extensions de service sont, elles, importées depuis le paquet
|
|
57
|
+
(`xcore_doctype.ext.*`, à nommer dans `services.extensions` d'integration.yaml) : rien à copier pour elles."""
|
|
58
|
+
return Path(str(resources.files("xcore_doctype") / "platform"))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
"Config", "DocumentValidationError", "HookEvent", "HookRegistrationError", "HookRegistry",
|
|
63
|
+
"mount_desk", "platform_plugins_dir", "plugin_dir", "system_plugin_dir", "__version__",
|
|
64
|
+
]
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"""Agrégats : compter, additionner, regrouper (palier 70 %, phases I et J, `process/palier70.md`).
|
|
2
|
+
|
|
3
|
+
C'est ce qui alimente les cartes de nombres, les graphiques, la vue Rapport (regroupements, totaux) et le tableau de bord d'un type
|
|
4
|
+
de document. Une requête d'agrégat se décrit par :
|
|
5
|
+
|
|
6
|
+
- un REGROUPEMENT (`Group`) : un champ Select, Link, Boolean ou Date (avec un `bucket` : `day`, `month`, `year`), ou une colonne système
|
|
7
|
+
(`docstatus`, `owner`, et `creation` / `modified` avec un `bucket`, lus en UTC) ; ou aucun, et le résultat est une ligne unique ;
|
|
8
|
+
- des MESURES (`Metric`) : `count`, ou `sum` / `avg` / `min` / `max` d'un champ Number ou Decimal ;
|
|
9
|
+
- des filtres typés, EXACTEMENT ceux de la liste (`CompiledDocType.coerce_filter`) ;
|
|
10
|
+
- une fenêtre de temps (`periods`) pour un regroupement par date : les N derniers jours, mois ou années, l'actuel compris.
|
|
11
|
+
|
|
12
|
+
Rien ici ne construit de SQL (`query.py` est le seul à le faire) : ce module valide, calcule la fenêtre, comble les périodes vides et
|
|
13
|
+
remet les valeurs sous leur forme canonique (un Decimal reste une chaîne exacte, jamais un flottant). La même validation sert au
|
|
14
|
+
chargement d'un tableau de bord (`resolve` sur la définition, une faute est une erreur de chargement) et à chaque requête.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from dataclasses import dataclass
|
|
20
|
+
from datetime import UTC, date, datetime, timedelta, tzinfo
|
|
21
|
+
from decimal import ROUND_HALF_EVEN, Decimal
|
|
22
|
+
from typing import TYPE_CHECKING, Any, Mapping, Sequence
|
|
23
|
+
|
|
24
|
+
from .decimals import canonical
|
|
25
|
+
from .errors import ValidationFailed
|
|
26
|
+
from .tags import TAG_FILTER, supports_tags
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING: # pragma: no cover - schema importe dashboards, qui importe ce module
|
|
29
|
+
from .schema import DocTypeDef
|
|
30
|
+
|
|
31
|
+
FUNCTIONS = ("count", "sum", "avg", "min", "max")
|
|
32
|
+
BUCKETS = ("day", "month", "year")
|
|
33
|
+
# Types de champ sur lesquels on regroupe : des valeurs en nombre limité (un texte libre donnerait un groupe par document).
|
|
34
|
+
GROUP_TYPES = ("Select", "Link", "Boolean", "Date", "Datetime")
|
|
35
|
+
METRIC_TYPES = ("Number", "Decimal", "Currency", "Rating", "Int", "Percent", "Duration")
|
|
36
|
+
# Colonnes système : `docstatus` et `owner` sont des catégories ; `creation` et `modified` sont des instants (UTC), donc à découper.
|
|
37
|
+
SYSTEM_CATEGORIES = ("docstatus", "owner")
|
|
38
|
+
SYSTEM_TIMES = ("creation", "modified")
|
|
39
|
+
|
|
40
|
+
MAX_GROUPS = 400
|
|
41
|
+
DEFAULT_GROUPS = 50
|
|
42
|
+
# Combien de périodes au plus, selon le découpage : un an de jours, dix ans de mois, cinquante ans d'années.
|
|
43
|
+
MAX_PERIODS = {"day": 366, "month": 120, "year": 50}
|
|
44
|
+
BUCKET_WIDTH = {"year": 4, "month": 7, "day": 10} # « 2026 », « 2026-10 », « 2026-10-17 » : l'ordre des chaînes est l'ordre du temps
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(frozen=True, slots=True)
|
|
48
|
+
class Metric:
|
|
49
|
+
function: str
|
|
50
|
+
field: str | None = None # `count` n'en a pas ; les autres exigent un champ Number ou Decimal
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def parse(cls, text: Any) -> "Metric":
|
|
54
|
+
"""`count`, `sum:qty`. Une autre forme est refusée telle quelle (jamais devinée)."""
|
|
55
|
+
if not isinstance(text, str):
|
|
56
|
+
raise ValidationFailed("une mesure s'écrit « count » ou « fonction:champ » (ex. sum:qty)")
|
|
57
|
+
function, sep, field = text.partition(":")
|
|
58
|
+
if function not in FUNCTIONS or bool(sep) != (function != "count") or (sep and not field):
|
|
59
|
+
raise ValidationFailed(f"mesure invalide {text!r} : « count » ou « sum|avg|min|max:champ »")
|
|
60
|
+
return cls(function, field or None)
|
|
61
|
+
|
|
62
|
+
def __str__(self) -> str:
|
|
63
|
+
return self.function if self.field is None else f"{self.function}:{self.field}"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True, slots=True)
|
|
67
|
+
class Group:
|
|
68
|
+
field: str
|
|
69
|
+
bucket: str | None = None # seulement pour une date ou un instant
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def is_time(self) -> bool:
|
|
73
|
+
return self.bucket is not None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass(frozen=True, slots=True)
|
|
77
|
+
class AggSpec:
|
|
78
|
+
group: Group | None
|
|
79
|
+
metrics: tuple[Metric, ...]
|
|
80
|
+
periods: int | None
|
|
81
|
+
limit: int
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def resolve(
|
|
85
|
+
defn: DocTypeDef,
|
|
86
|
+
*,
|
|
87
|
+
group_by: str | None = None,
|
|
88
|
+
bucket: str | None = None,
|
|
89
|
+
metrics: Sequence[Metric | str] | None = None,
|
|
90
|
+
periods: int | None = None,
|
|
91
|
+
limit: int = DEFAULT_GROUPS,
|
|
92
|
+
) -> AggSpec:
|
|
93
|
+
"""Valide une demande d'agrégat contre la définition du DocType, ou lève `ValidationFailed` (message pour un humain)."""
|
|
94
|
+
fields = defn.field_map
|
|
95
|
+
parsed = tuple(m if isinstance(m, Metric) else Metric.parse(m) for m in (metrics or ["count"]))
|
|
96
|
+
if not 1 <= len(parsed) <= 8:
|
|
97
|
+
raise ValidationFailed("de 1 à 8 mesures")
|
|
98
|
+
if len(set(parsed)) != len(parsed):
|
|
99
|
+
raise ValidationFailed("une mesure est demandée deux fois")
|
|
100
|
+
for m in parsed:
|
|
101
|
+
if m.function == "count":
|
|
102
|
+
continue
|
|
103
|
+
target = fields.get(m.field or "")
|
|
104
|
+
if target is None:
|
|
105
|
+
raise ValidationFailed(f"{m}: champ inconnu {m.field!r}")
|
|
106
|
+
if target.fieldtype not in METRIC_TYPES:
|
|
107
|
+
raise ValidationFailed(f"{m}: {m.field!r} est un {target.fieldtype}, seul un Number, un Decimal, une Currency, un Int, un Percent, une Duration ou un Rating s'additionne ou se moyenne")
|
|
108
|
+
|
|
109
|
+
if isinstance(limit, bool) or not isinstance(limit, int) or not 1 <= limit <= MAX_GROUPS:
|
|
110
|
+
raise ValidationFailed(f"limit doit être entre 1 et {MAX_GROUPS}")
|
|
111
|
+
|
|
112
|
+
group: Group | None = None
|
|
113
|
+
if group_by is None:
|
|
114
|
+
if bucket is not None or periods is not None:
|
|
115
|
+
raise ValidationFailed("`bucket` et `periods` exigent un regroupement (`group_by`)")
|
|
116
|
+
else:
|
|
117
|
+
if group_by in SYSTEM_CATEGORIES:
|
|
118
|
+
kind = "category"
|
|
119
|
+
elif group_by in SYSTEM_TIMES:
|
|
120
|
+
kind = "time"
|
|
121
|
+
else:
|
|
122
|
+
target = fields.get(group_by)
|
|
123
|
+
if target is None:
|
|
124
|
+
raise ValidationFailed(f"regroupement sur un champ inconnu : {group_by!r}")
|
|
125
|
+
if target.fieldtype not in GROUP_TYPES:
|
|
126
|
+
raise ValidationFailed(
|
|
127
|
+
f"regroupement impossible sur {group_by!r} ({target.fieldtype}) : "
|
|
128
|
+
f"seulement {', '.join(GROUP_TYPES)}, des valeurs en nombre limité"
|
|
129
|
+
)
|
|
130
|
+
kind = "time" if target.fieldtype in ("Date", "Datetime") else "category"
|
|
131
|
+
if kind == "time":
|
|
132
|
+
bucket = bucket or "month"
|
|
133
|
+
if bucket not in BUCKETS:
|
|
134
|
+
raise ValidationFailed(f"bucket inconnu {bucket!r} (permis : {', '.join(BUCKETS)})")
|
|
135
|
+
elif bucket is not None:
|
|
136
|
+
raise ValidationFailed(f"`bucket` n'a de sens que pour une date : {group_by!r} se regroupe par valeur")
|
|
137
|
+
group = Group(group_by, bucket)
|
|
138
|
+
|
|
139
|
+
if periods is not None:
|
|
140
|
+
if group is None or not group.is_time:
|
|
141
|
+
raise ValidationFailed("`periods` n'a de sens que pour un regroupement par date")
|
|
142
|
+
cap = MAX_PERIODS[group.bucket or "month"]
|
|
143
|
+
if isinstance(periods, bool) or not isinstance(periods, int) or not 1 <= periods <= cap:
|
|
144
|
+
raise ValidationFailed(f"periods doit être entre 1 et {cap} (découpage {group.bucket})")
|
|
145
|
+
# Une fenêtre de N périodes rend N lignes : un `limit` plus petit en retrancherait les plus anciennes sans le dire.
|
|
146
|
+
return AggSpec(group, parsed, periods, max(limit, periods or 0))
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# ── Fenêtre de temps ──────────────────────────────────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _shift_months(year: int, month: int, delta: int) -> tuple[int, int]:
|
|
153
|
+
index = year * 12 + (month - 1) + delta
|
|
154
|
+
return index // 12, index % 12 + 1
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def bucket_keys(bucket: str, today: date, periods: int) -> list[str]:
|
|
158
|
+
"""Les `periods` découpages qui se terminent par celui d'aujourd'hui, du plus ancien au plus récent."""
|
|
159
|
+
if bucket == "day":
|
|
160
|
+
return [(today - timedelta(days=n)).isoformat() for n in range(periods - 1, -1, -1)]
|
|
161
|
+
if bucket == "month":
|
|
162
|
+
return ["%04d-%02d" % _shift_months(today.year, today.month, -n) for n in range(periods - 1, -1, -1)]
|
|
163
|
+
return [f"{today.year - n:04d}" for n in range(periods - 1, -1, -1)]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def window(spec: AggSpec, *, now: datetime, tz: tzinfo) -> list[str] | None:
|
|
167
|
+
"""Les clés de la fenêtre demandée (`None` : pas de fenêtre). Une colonne système se découpe en UTC, une date dans le fuseau de
|
|
168
|
+
l'organisation : « ce mois » est celui du bureau, pas celui d'un serveur à l'autre bout du monde."""
|
|
169
|
+
if spec.group is None or spec.periods is None:
|
|
170
|
+
return None
|
|
171
|
+
zone = UTC if spec.group.field in SYSTEM_TIMES else tz
|
|
172
|
+
return bucket_keys(spec.group.bucket or "month", now.astimezone(zone).date(), spec.periods)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# ── Résultat ──────────────────────────────────────────────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _metric_decimals(defn: DocTypeDef, m: Metric) -> int | None:
|
|
179
|
+
field = defn.field_map.get(m.field or "")
|
|
180
|
+
return field.decimals if field is not None and field.fieldtype in ("Decimal", "Currency") else None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _finish(value: Any, m: Metric, decimals: int | None) -> Any:
|
|
184
|
+
"""La valeur d'une mesure sous sa forme d'API : un entier pour `count`, une chaîne exacte pour un Decimal, un nombre sinon."""
|
|
185
|
+
if m.function == "count":
|
|
186
|
+
return int(value or 0)
|
|
187
|
+
if value is None:
|
|
188
|
+
return None if m.function != "sum" else (canonical(0, decimals) if decimals is not None else 0)
|
|
189
|
+
if decimals is not None:
|
|
190
|
+
exact = value if isinstance(value, Decimal) else Decimal(str(value)) # SQLite additionne en double : on rend la valeur lisible
|
|
191
|
+
return canonical(exact.quantize(Decimal(1).scaleb(-decimals), rounding=ROUND_HALF_EVEN), decimals)
|
|
192
|
+
number = float(value)
|
|
193
|
+
return int(number) if number.is_integer() and abs(number) < 2**53 else number
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _zero_row(spec: AggSpec, defn: DocTypeDef) -> list[Any]:
|
|
197
|
+
return [_finish(0 if m.function in ("count", "sum") else None, m, _metric_decimals(defn, m)) for m in spec.metrics]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def describe(defn: DocTypeDef, spec: AggSpec) -> dict[str, Any]:
|
|
201
|
+
"""Ce dont un client a besoin pour lire les lignes sans connaître le DocType : le type du regroupement et les décimales des mesures."""
|
|
202
|
+
group: dict[str, Any] | None = None
|
|
203
|
+
if spec.group is not None:
|
|
204
|
+
field = defn.field_map.get(spec.group.field)
|
|
205
|
+
group = {"field": spec.group.field, "bucket": spec.group.bucket, "fieldtype": field.fieldtype if field else None}
|
|
206
|
+
if field is not None and field.fieldtype in ("Select", "Link"):
|
|
207
|
+
group["options"] = field.options
|
|
208
|
+
if field is not None:
|
|
209
|
+
group["label"] = field.label or field.fieldname
|
|
210
|
+
metrics = []
|
|
211
|
+
for m in spec.metrics:
|
|
212
|
+
field = defn.field_map.get(m.field or "")
|
|
213
|
+
metrics.append(
|
|
214
|
+
{"function": m.function, "field": m.field, "label": (field.label or field.fieldname) if field else None,
|
|
215
|
+
"decimals": _metric_decimals(defn, m)}
|
|
216
|
+
)
|
|
217
|
+
return {"group": group, "metrics": metrics}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def result(defn: DocTypeDef, spec: AggSpec, rows: Sequence[Sequence[Any]], keys: list[str] | None, *, truncated: bool) -> dict[str, Any]:
|
|
221
|
+
"""Assemble la réponse. `rows` : `(clé, *valeurs)` par groupe, ou `(*valeurs)` sans regroupement.
|
|
222
|
+
|
|
223
|
+
Un regroupement par date comble ses périodes vides (un graphique doit montrer le mois sans mouvement, à zéro) ; il se lit du plus
|
|
224
|
+
ancien au plus récent. Un autre regroupement garde l'ordre de la requête (la plus grosse valeur d'abord).
|
|
225
|
+
"""
|
|
226
|
+
decimals = [_metric_decimals(defn, m) for m in spec.metrics]
|
|
227
|
+
|
|
228
|
+
def values(raw: Sequence[Any]) -> list[Any]:
|
|
229
|
+
return [_finish(v, m, d) for v, m, d in zip(raw, spec.metrics, decimals, strict=True)]
|
|
230
|
+
|
|
231
|
+
out: list[dict[str, Any]]
|
|
232
|
+
if spec.group is None:
|
|
233
|
+
out = [{"key": None, "values": values(rows[0] if rows else [None] * len(spec.metrics))}]
|
|
234
|
+
else:
|
|
235
|
+
out = [{"key": _key(r[0]), "values": values(r[1:])} for r in rows]
|
|
236
|
+
if spec.group.is_time:
|
|
237
|
+
out.sort(key=lambda r: str(r["key"]))
|
|
238
|
+
if keys is not None:
|
|
239
|
+
have = {r["key"]: r for r in out}
|
|
240
|
+
out = [have.get(k) or {"key": k, "values": _zero_row(spec, defn)} for k in keys]
|
|
241
|
+
return {**describe(defn, spec), "rows": out, "truncated": truncated}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _key(raw: Any) -> Any:
|
|
245
|
+
return raw if raw is None or isinstance(raw, (bool, int)) else str(raw)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def validate_filters(compiled: Any, filters: Mapping[str, Any] | None) -> dict[str, Any]:
|
|
249
|
+
"""Les filtres de la liste, validés par type. `compiled` : le `CompiledDocType` du DocType interrogé."""
|
|
250
|
+
from .builder import SYSTEM_FILTERS # import tardif : builder importe schema, comme ce module
|
|
251
|
+
|
|
252
|
+
defn = compiled.definition
|
|
253
|
+
if filters is None:
|
|
254
|
+
return {}
|
|
255
|
+
if not isinstance(filters, Mapping):
|
|
256
|
+
raise ValidationFailed("filters doit être un objet")
|
|
257
|
+
tables = {f.fieldname for f in defn.fields if f.fieldtype == "Table"}
|
|
258
|
+
if tables & set(filters):
|
|
259
|
+
raise ValidationFailed(f"filtre impossible sur un champ Table : {sorted(tables & set(filters))}")
|
|
260
|
+
# `_tag` : les étiquettes du document (`tags.py`), là seulement où un document peut en porter.
|
|
261
|
+
tagged = {TAG_FILTER} if supports_tags(defn) else set()
|
|
262
|
+
# Filtrer par état sur un type sans workflow ne rendrait jamais rien : mieux vaut le dire que de servir une liste vide.
|
|
263
|
+
if "workflow_state" in filters and defn.workflow is None:
|
|
264
|
+
raise ValidationFailed(f"{defn.name} n'a pas de workflow : filtrer par état n'a pas de sens", code="no_workflow")
|
|
265
|
+
unknown = sorted(set(filters) - set(compiled.adapters) - set(SYSTEM_FILTERS) - tagged)
|
|
266
|
+
if unknown:
|
|
267
|
+
raise ValidationFailed(f"filtre sur des champs inconnus : {unknown}")
|
|
268
|
+
return {k: compiled.coerce_filter(k, v) for k, v in filters.items()}
|
|
File without changes
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""Routes de la collaboration : commentaires, assignations, pièces jointes et étiquettes d'un document (voir `collaboration.py`).
|
|
2
|
+
|
|
3
|
+
Toutes exigent une identité ; le droit de lire le DOCUMENT est jugé par le service à chaque appel (un document hors périmètre est « introuvable »).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from fastapi import APIRouter, Depends, File, HTTPException, Query, Response, UploadFile
|
|
12
|
+
from pydantic import BaseModel, ConfigDict
|
|
13
|
+
|
|
14
|
+
from ..collaboration import CollaborationService
|
|
15
|
+
from ..context import ContextSettings, RequestContext, http_context
|
|
16
|
+
from ..errors import DoctypeError
|
|
17
|
+
from ..files import MAX_MB
|
|
18
|
+
|
|
19
|
+
_READ_LIMIT = MAX_MB * 1024 * 1024 + 1 # lu en mémoire : borné AVANT de le garder (comme les champs fichier)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CommentBody(BaseModel):
|
|
23
|
+
model_config = ConfigDict(extra="forbid")
|
|
24
|
+
content: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AssignBody(BaseModel):
|
|
28
|
+
model_config = ConfigDict(extra="forbid")
|
|
29
|
+
assignee: str
|
|
30
|
+
description: str | None = None
|
|
31
|
+
due_date: str | None = None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AssignManyBody(BaseModel):
|
|
35
|
+
model_config = ConfigDict(extra="forbid")
|
|
36
|
+
names: list[str]
|
|
37
|
+
assignee: str
|
|
38
|
+
description: str | None = None
|
|
39
|
+
due_date: str | None = None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ShareBody(BaseModel):
|
|
43
|
+
model_config = ConfigDict(extra="forbid")
|
|
44
|
+
member: str
|
|
45
|
+
write: bool = False
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TagBody(BaseModel):
|
|
49
|
+
model_config = ConfigDict(extra="forbid")
|
|
50
|
+
add: list[Any] | None = None
|
|
51
|
+
remove: list[Any] | None = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class TagManyBody(TagBody):
|
|
55
|
+
names: list[str]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NamesBody(BaseModel):
|
|
59
|
+
model_config = ConfigDict(extra="forbid")
|
|
60
|
+
names: list[str]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class AssignmentPatch(BaseModel):
|
|
64
|
+
model_config = ConfigDict(extra="forbid")
|
|
65
|
+
status: str | None = None
|
|
66
|
+
description: str | None = None
|
|
67
|
+
due_date: str | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _raise(e: DoctypeError) -> None:
|
|
71
|
+
raise HTTPException(status_code=e.status, detail=e.as_detail()) from e
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def _guard(awaitable: Any) -> Any:
|
|
75
|
+
try:
|
|
76
|
+
return await awaitable
|
|
77
|
+
except DoctypeError as e:
|
|
78
|
+
_raise(e)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def build_collab_router(collab: CollaborationService, settings: ContextSettings) -> APIRouter:
|
|
82
|
+
ctx_dep = http_context(settings)
|
|
83
|
+
router = APIRouter(dependencies=[Depends(ctx_dep)])
|
|
84
|
+
|
|
85
|
+
@router.get("/collab/{doctype}/{name}")
|
|
86
|
+
async def around(doctype: str, name: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
87
|
+
return await _guard(collab.get(ctx, doctype, name))
|
|
88
|
+
|
|
89
|
+
@router.post("/comments/{doctype}/{name}", status_code=201)
|
|
90
|
+
async def comment_add(doctype: str, name: str, body: CommentBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
91
|
+
return await _guard(collab.add_comment(ctx, doctype, name, body.content))
|
|
92
|
+
|
|
93
|
+
@router.put("/comments/{comment_id}")
|
|
94
|
+
async def comment_edit(comment_id: str, body: CommentBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
95
|
+
return await _guard(collab.edit_comment(ctx, comment_id, body.content))
|
|
96
|
+
|
|
97
|
+
@router.delete("/comments/{comment_id}", status_code=204)
|
|
98
|
+
async def comment_delete(comment_id: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
99
|
+
await _guard(collab.delete_comment(ctx, comment_id))
|
|
100
|
+
return Response(status_code=204)
|
|
101
|
+
|
|
102
|
+
@router.post("/assignments/{doctype}/{name}", status_code=201)
|
|
103
|
+
async def assign(doctype: str, name: str, body: AssignBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
104
|
+
return await _guard(collab.assign(ctx, doctype, name, assignee=body.assignee, description=body.description, due_date=body.due_date))
|
|
105
|
+
|
|
106
|
+
@router.post("/assign-many/{doctype}")
|
|
107
|
+
async def assign_many(doctype: str, body: AssignManyBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
108
|
+
return await _guard(collab.assign_many(ctx, doctype, body.names, assignee=body.assignee, description=body.description, due_date=body.due_date))
|
|
109
|
+
|
|
110
|
+
@router.put("/assignments/{assignment_id}")
|
|
111
|
+
async def assignment_update(assignment_id: str, body: AssignmentPatch, ctx: RequestContext = Depends(ctx_dep)):
|
|
112
|
+
return await _guard(collab.update_assignment(ctx, assignment_id, **body.model_dump(exclude_unset=True)))
|
|
113
|
+
|
|
114
|
+
@router.get("/my-assignments")
|
|
115
|
+
async def mine(status: str | None = Query("open"), limit: int = Query(100), ctx: RequestContext = Depends(ctx_dep)):
|
|
116
|
+
return await _guard(collab.mine(ctx, status=None if status == "all" else status, limit=limit))
|
|
117
|
+
|
|
118
|
+
@router.get("/users")
|
|
119
|
+
async def users(ids: list[str] = Query(default=[]), ctx: RequestContext = Depends(ctx_dep)):
|
|
120
|
+
"""De quoi afficher des identifiants (`?ids=a&ids=b`) : `{items: {id: {id, email, name}}}`, les membres de l'organisation de l'appelant."""
|
|
121
|
+
return await _guard(collab.resolve(ctx, ids))
|
|
122
|
+
|
|
123
|
+
@router.get("/mentionable/{doctype}/{name}")
|
|
124
|
+
async def mentionable(doctype: str, name: str, q: str = Query(""), ctx: RequestContext = Depends(ctx_dep)):
|
|
125
|
+
"""Des membres à citer dans un commentaire de ce document (`@adresse`) : il suffit de pouvoir le lire."""
|
|
126
|
+
return await _guard(collab.mentionable(ctx, doctype, name, q=q))
|
|
127
|
+
|
|
128
|
+
@router.get("/people/{doctype}")
|
|
129
|
+
async def people(doctype: str, q: str = Query(""), ctx: RequestContext = Depends(ctx_dep)):
|
|
130
|
+
return await _guard(collab.people(ctx, doctype, q=q))
|
|
131
|
+
|
|
132
|
+
@router.get("/shares/{doctype}/{name}")
|
|
133
|
+
async def shares(doctype: str, name: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
134
|
+
"""Avec qui ce document est partagé (la liste complète pour qui peut l'écrire, son propre partage pour les autres)."""
|
|
135
|
+
return await _guard(collab.shares(ctx, doctype, name))
|
|
136
|
+
|
|
137
|
+
@router.post("/shares/{doctype}/{name}")
|
|
138
|
+
async def share(doctype: str, name: str, body: ShareBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
139
|
+
"""`{member, write}` : partager avec un membre (son e-mail ou son identifiant), en lecture ou en écriture. Il faut écrire le document."""
|
|
140
|
+
return await _guard(collab.share(ctx, doctype, name, member=body.member, write=body.write))
|
|
141
|
+
|
|
142
|
+
@router.delete("/shares/{doctype}/{name}", status_code=204)
|
|
143
|
+
async def unshare(doctype: str, name: str, member: str = Query(...), ctx: RequestContext = Depends(ctx_dep)):
|
|
144
|
+
await _guard(collab.unshare(ctx, doctype, name, member=member))
|
|
145
|
+
return Response(status_code=204)
|
|
146
|
+
|
|
147
|
+
@router.get("/shared-with-me")
|
|
148
|
+
async def shared_with_me(limit: int = Query(100), ctx: RequestContext = Depends(ctx_dep)):
|
|
149
|
+
return await _guard(collab.shared_with_me(ctx, limit=limit))
|
|
150
|
+
|
|
151
|
+
@router.get("/tags/{doctype}/{name}")
|
|
152
|
+
async def tags(doctype: str, name: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
153
|
+
"""Les étiquettes du document (il faut le lire) et `can_tag` (peut-il en poser : l'écrire)."""
|
|
154
|
+
return await _guard(collab.tags(ctx, doctype, name))
|
|
155
|
+
|
|
156
|
+
@router.post("/tags/{doctype}/{name}")
|
|
157
|
+
async def tag(doctype: str, name: str, body: TagBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
158
|
+
"""`{add: [...], remove: [...]}` en une transaction ; répond les étiquettes du document après."""
|
|
159
|
+
return await _guard(collab.tag(ctx, doctype, name, add=body.add, remove=body.remove))
|
|
160
|
+
|
|
161
|
+
@router.post("/tags-of/{doctype}")
|
|
162
|
+
async def tags_of(doctype: str, body: NamesBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
163
|
+
"""Les étiquettes d'une page de liste : `{items: {nom: [étiquettes]}}`, les documents lisibles seulement."""
|
|
164
|
+
return await _guard(collab.tags_of(ctx, doctype, body.names))
|
|
165
|
+
|
|
166
|
+
@router.get("/tag-counts/{doctype}")
|
|
167
|
+
async def tag_counts(
|
|
168
|
+
doctype: str,
|
|
169
|
+
q: str = Query(""),
|
|
170
|
+
filters: str | None = Query(None, description="les filtres de /list"),
|
|
171
|
+
limit: int = Query(20),
|
|
172
|
+
ctx: RequestContext = Depends(ctx_dep),
|
|
173
|
+
):
|
|
174
|
+
"""Les étiquettes en usage, avec leur nombre de documents lisibles que `filters` retient (barre latérale, propositions de saisie)."""
|
|
175
|
+
try:
|
|
176
|
+
parsed = json.loads(filters) if filters else None
|
|
177
|
+
except ValueError:
|
|
178
|
+
raise HTTPException(status_code=422, detail={"code": "validation_failed", "msg": "filters n'est pas du JSON valide"}) from None
|
|
179
|
+
return await _guard(collab.tag_counts(ctx, doctype, q=q, filters=parsed, limit=limit))
|
|
180
|
+
|
|
181
|
+
@router.get("/tags-used/{doctype}")
|
|
182
|
+
async def tags_used(doctype: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
183
|
+
"""`{used: bool}` : une étiquette existe-t-elle sur un document lisible de ce type ?"""
|
|
184
|
+
return await _guard(collab.tags_used(ctx, doctype))
|
|
185
|
+
|
|
186
|
+
@router.post("/tag-many/{doctype}")
|
|
187
|
+
async def tag_many(doctype: str, body: TagManyBody, ctx: RequestContext = Depends(ctx_dep)):
|
|
188
|
+
"""Étiqueter une sélection : chaque document est jugé seul, la réponse donne `ok`/code/message par document."""
|
|
189
|
+
return await _guard(collab.tag_many(ctx, doctype, body.names, add=body.add, remove=body.remove))
|
|
190
|
+
|
|
191
|
+
@router.post("/attachments/{doctype}/{name}", status_code=201)
|
|
192
|
+
async def attach(doctype: str, name: str, file: UploadFile = File(...), ctx: RequestContext = Depends(ctx_dep)):
|
|
193
|
+
content = await file.read(_READ_LIMIT)
|
|
194
|
+
return await _guard(collab.attach(ctx, doctype, name, content=content, filename=file.filename, content_type=file.content_type))
|
|
195
|
+
|
|
196
|
+
@router.delete("/attachments/{attachment_id}", status_code=204)
|
|
197
|
+
async def detach(attachment_id: str, ctx: RequestContext = Depends(ctx_dep)):
|
|
198
|
+
await _guard(collab.detach(ctx, attachment_id))
|
|
199
|
+
return Response(status_code=204)
|
|
200
|
+
|
|
201
|
+
return router
|