shutro-erp 0.3.3 → 0.3.5
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/dist/account_portal/.kosh/bindings.js +1 -1
- package/dist/account_portal/.kosh/schema.d.ts +181 -3
- package/dist/account_portal/module.d.ts +359 -6
- package/dist/accounting/.kosh/bindings.js +1 -1
- package/dist/accounting/.kosh/schema.d.ts +181 -3
- package/dist/accounting/index.js +214 -2
- package/dist/accounting/module.d.ts +217 -5
- package/dist/accounting/module.js +23 -2
- package/dist/calendar/.kosh/bindings.d.ts +22 -0
- package/dist/calendar/.kosh/bindings.js +15 -0
- package/dist/calendar/.kosh/schema.d.ts +795 -0
- package/dist/calendar/demo.d.ts +6 -0
- package/dist/calendar/demo.js +24 -0
- package/dist/calendar/index.d.ts +3 -0
- package/dist/calendar/index.js +291 -0
- package/dist/calendar/module.d.ts +1705 -0
- package/dist/calendar/module.js +180 -0
- package/dist/cli/init.js +48 -0
- package/dist/cli/templates.d.ts +1 -1
- package/dist/cli/templates.js +137 -0
- package/dist/contacts/.kosh/bindings.js +1 -1
- package/dist/contacts/.kosh/schema.d.ts +205 -3
- package/dist/contacts/demo.js +30 -1
- package/dist/contacts/index.d.ts +1 -1
- package/dist/contacts/index.js +155 -9
- package/dist/contacts/module.d.ts +338 -2
- package/dist/contacts/module.js +82 -5
- package/dist/crm/.kosh/bindings.d.ts +22 -0
- package/dist/crm/.kosh/bindings.js +15 -0
- package/dist/crm/.kosh/schema.d.ts +799 -0
- package/dist/crm/demo.d.ts +6 -0
- package/dist/crm/demo.js +45 -0
- package/dist/crm/index.d.ts +3 -0
- package/dist/crm/index.js +361 -0
- package/dist/crm/module.d.ts +1843 -0
- package/dist/crm/module.js +207 -0
- package/dist/event/.kosh/bindings.d.ts +22 -0
- package/dist/event/.kosh/bindings.js +15 -0
- package/dist/event/.kosh/schema.d.ts +843 -0
- package/dist/event/demo.d.ts +6 -0
- package/dist/event/demo.js +65 -0
- package/dist/event/index.d.ts +14 -0
- package/dist/event/index.js +333 -0
- package/dist/event/mails.d.ts +15 -0
- package/dist/event/mails.js +112 -0
- package/dist/event/module.d.ts +2800 -0
- package/dist/event/module.js +323 -0
- package/dist/event/web/CheckInBox.d.ts +9 -0
- package/dist/event/web/CheckInBox.js +87 -0
- package/dist/event/web/index.d.ts +11 -0
- package/dist/event/web/index.js +16 -0
- package/dist/event/web/messages.d.ts +2 -0
- package/dist/event/web/messages.js +23 -0
- package/dist/event_account/.kosh/bindings.d.ts +22 -0
- package/dist/event_account/.kosh/bindings.js +15 -0
- package/dist/event_account/.kosh/schema.d.ts +1639 -0
- package/dist/event_account/index.d.ts +3 -0
- package/dist/event_account/index.js +28 -0
- package/dist/event_account/module.d.ts +6968 -0
- package/dist/event_account/module.js +90 -0
- package/dist/hr/.kosh/bindings.d.ts +22 -0
- package/dist/hr/.kosh/bindings.js +15 -0
- package/dist/hr/.kosh/schema.d.ts +878 -0
- package/dist/hr/demo.d.ts +6 -0
- package/dist/hr/demo.js +60 -0
- package/dist/hr/index.d.ts +3 -0
- package/dist/hr/index.js +483 -0
- package/dist/hr/module.d.ts +2611 -0
- package/dist/hr/module.js +350 -0
- package/dist/integrations/index.js +12 -0
- package/dist/integrations/web/OAuthAppsPage.d.ts +9 -0
- package/dist/integrations/web/OAuthAppsPage.js +79 -0
- package/dist/integrations/web/index.d.ts +1 -0
- package/dist/integrations/web/index.js +3 -0
- package/dist/integrations/web/messages.js +58 -0
- package/dist/l10n_bd/.kosh/bindings.js +1 -1
- package/dist/l10n_bd/.kosh/schema.d.ts +181 -3
- package/dist/l10n_bd/module.d.ts +359 -6
- package/dist/l10n_in/.kosh/bindings.js +1 -1
- package/dist/l10n_in/.kosh/schema.d.ts +181 -3
- package/dist/l10n_in/module.d.ts +380 -7
- package/dist/maintenance/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance/.kosh/bindings.js +15 -0
- package/dist/maintenance/.kosh/schema.d.ts +911 -0
- package/dist/maintenance/demo.d.ts +6 -0
- package/dist/maintenance/demo.js +60 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.js +422 -0
- package/dist/maintenance/module.d.ts +3545 -0
- package/dist/maintenance/module.js +446 -0
- package/dist/maintenance_stock/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance_stock/.kosh/bindings.js +15 -0
- package/dist/maintenance_stock/.kosh/schema.d.ts +1371 -0
- package/dist/maintenance_stock/index.d.ts +9 -0
- package/dist/maintenance_stock/index.js +52 -0
- package/dist/maintenance_stock/module.d.ts +6953 -0
- package/dist/maintenance_stock/module.js +192 -0
- package/dist/messaging/web/index.js +1 -1
- package/dist/modules-sdk/index.d.ts +1 -1
- package/dist/modules-sdk/manifest.d.ts +70 -0
- package/dist/modules-sdk/manifest.js +35 -1
- package/dist/mrp/.kosh/bindings.d.ts +22 -0
- package/dist/mrp/.kosh/bindings.js +15 -0
- package/dist/mrp/.kosh/schema.d.ts +1378 -0
- package/dist/mrp/demo.d.ts +7 -0
- package/dist/mrp/demo.js +42 -0
- package/dist/mrp/index.d.ts +3 -0
- package/dist/mrp/index.js +392 -0
- package/dist/mrp/module.d.ts +8608 -0
- package/dist/mrp/module.js +695 -0
- package/dist/mrp_account/.kosh/bindings.d.ts +22 -0
- package/dist/mrp_account/.kosh/bindings.js +15 -0
- package/dist/mrp_account/.kosh/schema.d.ts +2106 -0
- package/dist/mrp_account/index.d.ts +3 -0
- package/dist/mrp_account/index.js +22 -0
- package/dist/mrp_account/module.d.ts +20840 -0
- package/dist/mrp_account/module.js +123 -0
- package/dist/notify/web/index.js +1 -1
- package/dist/payment/.kosh/bindings.js +1 -1
- package/dist/payment/.kosh/schema.d.ts +181 -3
- package/dist/payment/module.d.ts +359 -6
- package/dist/portal/.kosh/bindings.js +1 -1
- package/dist/portal/.kosh/schema.d.ts +205 -3
- package/dist/portal/module.d.ts +166 -2
- package/dist/pos/.kosh/bindings.d.ts +22 -0
- package/dist/pos/.kosh/bindings.js +15 -0
- package/dist/pos/.kosh/schema.d.ts +1690 -0
- package/dist/pos/accounting.d.ts +10 -0
- package/dist/pos/accounting.js +149 -0
- package/dist/pos/demo.d.ts +6 -0
- package/dist/pos/demo.js +90 -0
- package/dist/pos/index.d.ts +9 -0
- package/dist/pos/index.js +349 -0
- package/dist/pos/module.d.ts +9636 -0
- package/dist/pos/module.js +423 -0
- package/dist/pos/routes.d.ts +39 -0
- package/dist/pos/routes.js +368 -0
- package/dist/pos/web/Register.d.ts +9 -0
- package/dist/pos/web/Register.js +252 -0
- package/dist/pos/web/index.d.ts +11 -0
- package/dist/pos/web/index.js +16 -0
- package/dist/pos/web/messages.d.ts +2 -0
- package/dist/pos/web/messages.js +87 -0
- package/dist/pos_stock/.kosh/bindings.d.ts +22 -0
- package/dist/pos_stock/.kosh/bindings.js +15 -0
- package/dist/pos_stock/.kosh/schema.d.ts +2015 -0
- package/dist/pos_stock/index.d.ts +9 -0
- package/dist/pos_stock/index.js +35 -0
- package/dist/pos_stock/module.d.ts +11935 -0
- package/dist/pos_stock/module.js +115 -0
- package/dist/product/.kosh/bindings.js +1 -1
- package/dist/product/.kosh/schema.d.ts +178 -1
- package/dist/product/index.js +81 -4
- package/dist/product/module.d.ts +43 -1
- package/dist/product/module.js +9 -2
- package/dist/project/.kosh/bindings.js +1 -1
- package/dist/project/.kosh/schema.d.ts +181 -3
- package/dist/project/index.js +147 -7
- package/dist/project/module.d.ts +210 -2
- package/dist/project/module.js +52 -5
- package/dist/project_portal/.kosh/bindings.js +1 -1
- package/dist/project_portal/.kosh/schema.d.ts +181 -3
- package/dist/project_portal/module.d.ts +353 -4
- package/dist/purchase/.kosh/bindings.js +1 -1
- package/dist/purchase/.kosh/schema.d.ts +181 -3
- package/dist/purchase/index.js +163 -3
- package/dist/purchase/module.d.ts +215 -3
- package/dist/purchase/module.js +21 -3
- package/dist/purchase_account/.kosh/bindings.js +1 -1
- package/dist/purchase_account/.kosh/schema.d.ts +182 -3
- package/dist/purchase_account/index.js +26 -1
- package/dist/purchase_account/module.d.ts +393 -7
- package/dist/purchase_portal/.kosh/bindings.js +1 -1
- package/dist/purchase_portal/.kosh/schema.d.ts +181 -3
- package/dist/purchase_portal/module.d.ts +366 -5
- package/dist/purchase_stock/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock/.kosh/bindings.js +15 -0
- package/dist/purchase_stock/.kosh/schema.d.ts +1310 -0
- package/dist/purchase_stock/index.d.ts +7 -0
- package/dist/purchase_stock/index.js +91 -0
- package/dist/purchase_stock/module.d.ts +6763 -0
- package/dist/purchase_stock/module.js +144 -0
- package/dist/purchase_stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock_account/.kosh/bindings.js +15 -0
- package/dist/purchase_stock_account/.kosh/schema.d.ts +1959 -0
- package/dist/purchase_stock_account/index.d.ts +3 -0
- package/dist/purchase_stock_account/index.js +24 -0
- package/dist/purchase_stock_account/module.d.ts +35366 -0
- package/dist/purchase_stock_account/module.js +162 -0
- package/dist/recruitment/.kosh/bindings.d.ts +22 -0
- package/dist/recruitment/.kosh/bindings.js +15 -0
- package/dist/recruitment/.kosh/schema.d.ts +990 -0
- package/dist/recruitment/demo.d.ts +6 -0
- package/dist/recruitment/demo.js +45 -0
- package/dist/recruitment/index.d.ts +3 -0
- package/dist/recruitment/index.js +385 -0
- package/dist/recruitment/module.d.ts +3247 -0
- package/dist/recruitment/module.js +193 -0
- package/dist/recruitment/web/HireButton.d.ts +9 -0
- package/dist/recruitment/web/HireButton.js +32 -0
- package/dist/recruitment/web/index.d.ts +11 -0
- package/dist/recruitment/web/index.js +16 -0
- package/dist/recruitment/web/messages.d.ts +2 -0
- package/dist/recruitment/web/messages.js +19 -0
- package/dist/reporting/documents.d.ts +5 -0
- package/dist/reporting/documents.js +28 -1
- package/dist/reporting/index.d.ts +1 -1
- package/dist/reporting/index.js +4 -2
- package/dist/reporting/models.js +9 -0
- package/dist/reporting/overviews.d.ts +16 -0
- package/dist/reporting/overviews.js +56 -0
- package/dist/reporting/routes-documents.js +1 -1
- package/dist/reporting/routes.js +138 -80
- package/dist/reporting/web/DashboardView.d.ts +11 -0
- package/dist/reporting/web/DashboardView.js +2 -2
- package/dist/reporting/web/DesignerView.js +5 -0
- package/dist/reporting/web/Overview.d.ts +9 -0
- package/dist/reporting/web/Overview.js +53 -0
- package/dist/reporting/web/index.d.ts +1 -0
- package/dist/reporting/web/index.js +4 -1
- package/dist/reporting/web/messages.js +9 -0
- package/dist/sale_account/.kosh/bindings.js +1 -1
- package/dist/sale_account/.kosh/schema.d.ts +186 -3
- package/dist/sale_account/index.js +22 -1
- package/dist/sale_account/module.d.ts +461 -7
- package/dist/sale_portal/.kosh/bindings.js +1 -1
- package/dist/sale_portal/.kosh/schema.d.ts +185 -3
- package/dist/sale_portal/module.d.ts +434 -5
- package/dist/sale_project/.kosh/bindings.js +1 -1
- package/dist/sale_project/.kosh/schema.d.ts +187 -3
- package/dist/sale_project/module.d.ts +476 -6
- package/dist/sale_stock/.kosh/bindings.d.ts +22 -0
- package/dist/sale_stock/.kosh/bindings.js +15 -0
- package/dist/sale_stock/.kosh/schema.d.ts +1228 -0
- package/dist/sale_stock/index.d.ts +7 -0
- package/dist/sale_stock/index.js +84 -0
- package/dist/sale_stock/module.d.ts +6791 -0
- package/dist/sale_stock/module.js +146 -0
- package/dist/sales/.kosh/bindings.js +1 -1
- package/dist/sales/.kosh/schema.d.ts +185 -3
- package/dist/sales/index.js +191 -4
- package/dist/sales/module.d.ts +355 -3
- package/dist/sales/module.js +78 -3
- package/dist/server/api/metadata.d.ts +5 -0
- package/dist/server/api/metadata.js +5 -0
- package/dist/server/api/rest.js +64 -1
- package/dist/server/api/views.js +1 -0
- package/dist/server/app-settings.d.ts +7 -0
- package/dist/server/app-settings.js +10 -0
- package/dist/server/auth/base.js +85 -0
- package/dist/server/auth/oauth.d.ts +21 -0
- package/dist/server/auth/oauth.js +579 -0
- package/dist/server/auth/service.d.ts +4 -0
- package/dist/server/auth/service.js +17 -0
- package/dist/server/identity.d.ts +2 -0
- package/dist/server/images.d.ts +12 -0
- package/dist/server/images.js +139 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/server.d.ts +4 -0
- package/dist/server/server.js +9 -1
- package/dist/settings/app-settings.d.ts +2 -0
- package/dist/settings/app-settings.js +518 -0
- package/dist/settings/company.js +3 -1
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.js +15 -0
- package/dist/settings/people.js +32 -6
- package/dist/settings/web/AppSettingsPage.d.ts +11 -0
- package/dist/settings/web/AppSettingsPage.js +210 -0
- package/dist/settings/web/CompaniesPage.js +2 -2
- package/dist/settings/web/CompanyPage.js +13 -2
- package/dist/settings/web/ConnectedAppsPage.d.ts +7 -0
- package/dist/settings/web/ConnectedAppsPage.js +33 -0
- package/dist/settings/web/OverviewPage.js +28 -4
- package/dist/settings/web/PeoplePage.js +23 -18
- package/dist/settings/web/ProfilePage.js +9 -7
- package/dist/settings/web/index.d.ts +2 -0
- package/dist/settings/web/index.js +8 -0
- package/dist/settings/web/messages.js +146 -2
- package/dist/stock/.kosh/bindings.d.ts +22 -0
- package/dist/stock/.kosh/bindings.js +15 -0
- package/dist/stock/.kosh/schema.d.ts +1147 -0
- package/dist/stock/demo.d.ts +7 -0
- package/dist/stock/demo.js +55 -0
- package/dist/stock/index.d.ts +3 -0
- package/dist/stock/index.js +674 -0
- package/dist/stock/module.d.ts +6330 -0
- package/dist/stock/module.js +1325 -0
- package/dist/stock/web/ScanBox.d.ts +8 -0
- package/dist/stock/web/ScanBox.js +90 -0
- package/dist/stock/web/index.d.ts +11 -0
- package/dist/stock/web/index.js +16 -0
- package/dist/stock/web/messages.d.ts +2 -0
- package/dist/stock/web/messages.js +25 -0
- package/dist/stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/stock_account/.kosh/bindings.js +15 -0
- package/dist/stock_account/.kosh/schema.d.ts +1875 -0
- package/dist/stock_account/index.d.ts +3 -0
- package/dist/stock_account/index.js +130 -0
- package/dist/stock_account/module.d.ts +10655 -0
- package/dist/stock_account/module.js +339 -0
- package/dist/storage/attachments.d.ts +5 -0
- package/dist/storage/attachments.js +12 -1
- package/dist/storage/models.js +3 -0
- package/dist/storage/routes.js +13 -2
- package/dist/todo/.kosh/bindings.d.ts +22 -0
- package/dist/todo/.kosh/bindings.js +15 -0
- package/dist/todo/.kosh/schema.d.ts +732 -0
- package/dist/todo/demo.d.ts +6 -0
- package/dist/todo/demo.js +35 -0
- package/dist/todo/index.d.ts +3 -0
- package/dist/todo/index.js +187 -0
- package/dist/todo/module.d.ts +1180 -0
- package/dist/todo/module.js +130 -0
- package/dist/trade_finance/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance/.kosh/bindings.js +15 -0
- package/dist/trade_finance/.kosh/schema.d.ts +884 -0
- package/dist/trade_finance/demo.d.ts +6 -0
- package/dist/trade_finance/demo.js +63 -0
- package/dist/trade_finance/index.d.ts +3 -0
- package/dist/trade_finance/index.js +413 -0
- package/dist/trade_finance/module.d.ts +3779 -0
- package/dist/trade_finance/module.js +505 -0
- package/dist/trade_finance_account/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_account/.kosh/bindings.js +15 -0
- package/dist/trade_finance_account/.kosh/schema.d.ts +1711 -0
- package/dist/trade_finance_account/index.d.ts +3 -0
- package/dist/trade_finance_account/index.js +92 -0
- package/dist/trade_finance_account/module.d.ts +7928 -0
- package/dist/trade_finance_account/module.js +244 -0
- package/dist/trade_finance_purchase/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_purchase/.kosh/bindings.js +15 -0
- package/dist/trade_finance_purchase/.kosh/schema.d.ts +1153 -0
- package/dist/trade_finance_purchase/index.d.ts +8 -0
- package/dist/trade_finance_purchase/index.js +50 -0
- package/dist/trade_finance_purchase/module.d.ts +4252 -0
- package/dist/trade_finance_purchase/module.js +44 -0
- package/dist/trade_finance_sale/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_sale/.kosh/bindings.js +15 -0
- package/dist/trade_finance_sale/.kosh/schema.d.ts +1071 -0
- package/dist/trade_finance_sale/index.d.ts +8 -0
- package/dist/trade_finance_sale/index.js +50 -0
- package/dist/trade_finance_sale/module.d.ts +4280 -0
- package/dist/trade_finance_sale/module.js +44 -0
- package/dist/ui/api.d.ts +6 -1
- package/dist/ui/api.js +2 -1
- package/dist/ui/app.js +51 -17
- package/dist/ui/components/AppIcon.js +33 -1
- package/dist/ui/components/Avatar.d.ts +21 -0
- package/dist/ui/components/Avatar.js +71 -0
- package/dist/ui/components/primitives.d.ts +2 -0
- package/dist/ui/components/primitives.js +7 -1
- package/dist/ui/i18n/messages.d.ts +53 -0
- package/dist/ui/i18n/messages.js +98 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/offline/queue.d.ts +5 -1
- package/dist/ui/offline/queue.js +2 -0
- package/dist/ui/registry.d.ts +12 -1
- package/dist/ui/registry.js +10 -1
- package/dist/ui/search/ViewTabs.d.ts +14 -0
- package/dist/ui/search/ViewTabs.js +42 -0
- package/dist/ui/shell/Consent.d.ts +5 -0
- package/dist/ui/shell/Consent.js +35 -0
- package/dist/ui/shell/Home.js +136 -16
- package/dist/ui/shell/Sidebar.js +15 -22
- package/dist/ui/views/FormView.js +98 -17
- package/dist/ui/views/KanbanView.d.ts +2 -0
- package/dist/ui/views/KanbanView.js +32 -3
- package/dist/ui/views/ListView.js +155 -31
- package/dist/ui/views/StatsRow.d.ts +14 -0
- package/dist/ui/views/StatsRow.js +88 -0
- package/dist/ui/views/widgets.d.ts +2 -1
- package/dist/ui/views/widgets.js +194 -1
- package/dist/views/builders.d.ts +19 -2
- package/dist/views/builders.js +21 -1
- package/dist/views/condition.d.ts +6 -0
- package/dist/views/condition.js +20 -0
- package/dist/views/documents.d.ts +8 -0
- package/dist/views/extend.d.ts +2 -2
- package/dist/views/extend.js +11 -1
- package/dist/views/index.d.ts +2 -2
- package/dist/views/index.js +2 -2
- package/dist/views/types.d.ts +52 -5
- package/dist/views/validate.js +39 -1
- package/dist/website/.kosh/bindings.d.ts +22 -0
- package/dist/website/.kosh/bindings.js +15 -0
- package/dist/website/.kosh/schema.d.ts +881 -0
- package/dist/website/demo.d.ts +6 -0
- package/dist/website/demo.js +115 -0
- package/dist/website/index.d.ts +9 -0
- package/dist/website/index.js +250 -0
- package/dist/website/module.d.ts +2987 -0
- package/dist/website/module.js +281 -0
- package/dist/website/render.d.ts +45 -0
- package/dist/website/render.js +102 -0
- package/dist/website/routes.d.ts +12 -0
- package/dist/website/routes.js +246 -0
- package/dist/website/web/PagePreview.d.ts +7 -0
- package/dist/website/web/PagePreview.js +33 -0
- package/dist/website/web/index.d.ts +11 -0
- package/dist/website/web/index.js +16 -0
- package/dist/website/web/messages.d.ts +2 -0
- package/dist/website/web/messages.js +15 -0
- package/dist/website_crm/.kosh/bindings.d.ts +22 -0
- package/dist/website_crm/.kosh/bindings.js +15 -0
- package/dist/website_crm/.kosh/schema.d.ts +966 -0
- package/dist/website_crm/index.d.ts +3 -0
- package/dist/website_crm/index.js +39 -0
- package/dist/website_crm/module.d.ts +2955 -0
- package/dist/website_crm/module.js +44 -0
- package/package.json +118 -1
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data layer of Workforce (RFC 0021): departments as a tree, positions, employees (separate from users: an
|
|
3
|
+
* employee may never sign in) with their manager, contracts, and leave. Personal details and wages are visible to
|
|
4
|
+
* HR managers only (field security). A leave's working days follow the company's week (the weekend setting) and are
|
|
5
|
+
* checked by the server; a request may not overlap another of the same person, nor go beyond the year's days of its
|
|
6
|
+
* type. Approving and refusing need the decision permission (HR managers) or go through the line manager's route.
|
|
7
|
+
*/
|
|
8
|
+
import { contactsShutro } from '../contacts/index.js';
|
|
9
|
+
import { messagingShutro } from '../messaging/index.js';
|
|
10
|
+
import { installationSetting } from '../server/index.js';
|
|
11
|
+
import { orm } from '../server/orm.js';
|
|
12
|
+
import { check, defineModel, defineModule, f, onchange, record, records, } from './.kosh/bindings.js';
|
|
13
|
+
const READ = ['read'];
|
|
14
|
+
const ALL = ['read', 'write', 'create', 'unlink'];
|
|
15
|
+
const HR = ['hr.manager'];
|
|
16
|
+
const me = { $env: 'uid' };
|
|
17
|
+
/** The weekend of each choice, as JavaScript day numbers (0: Sunday). */
|
|
18
|
+
export const WEEKENDS = {
|
|
19
|
+
fri_sat: [5, 6],
|
|
20
|
+
sat_sun: [6, 0],
|
|
21
|
+
fri: [5],
|
|
22
|
+
};
|
|
23
|
+
/** Working days from `from` to `to` (inclusive, ISO dates) outside the weekend. */
|
|
24
|
+
export function workingDays(from, to, weekend) {
|
|
25
|
+
const start = Date.parse(`${from}T00:00:00Z`);
|
|
26
|
+
const end = Date.parse(`${to}T00:00:00Z`);
|
|
27
|
+
if (Number.isNaN(start) || Number.isNaN(end) || end < start)
|
|
28
|
+
return 0;
|
|
29
|
+
let days = 0;
|
|
30
|
+
for (let t = start; t <= end; t += 86_400_000)
|
|
31
|
+
if (!weekend.includes(new Date(t).getUTCDay()))
|
|
32
|
+
days += 1;
|
|
33
|
+
return days;
|
|
34
|
+
}
|
|
35
|
+
/** The installation's weekend (App settings › Workforce). */
|
|
36
|
+
export async function weekendOf(env) {
|
|
37
|
+
const choice = await installationSetting(env, 'hr.weekend', 'fri_sat');
|
|
38
|
+
return WEEKENDS[String(choice)] ?? WEEKENDS['fri_sat'];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A date as `YYYY-MM-DD`. Date-only values read from PostgreSQL are local midnights: their local parts are the date
|
|
42
|
+
* (`toISOString()` would move them a day back east of UTC).
|
|
43
|
+
*/
|
|
44
|
+
const iso = (v) => {
|
|
45
|
+
if (!(v instanceof Date))
|
|
46
|
+
return String(v ?? '');
|
|
47
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
48
|
+
return `${v.getFullYear()}-${pad(v.getMonth() + 1)}-${pad(v.getDate())}`;
|
|
49
|
+
};
|
|
50
|
+
export const HrDepartment = defineModel('hr.department', {
|
|
51
|
+
label: 'Department',
|
|
52
|
+
recName: 'name',
|
|
53
|
+
order: ['name asc'],
|
|
54
|
+
archivable: true,
|
|
55
|
+
companyScoped: { required: true },
|
|
56
|
+
access: { 'hr.user': READ, 'hr.manager': ALL },
|
|
57
|
+
fields: {
|
|
58
|
+
name: f.char({ required: true }),
|
|
59
|
+
parent: f.many2one('hr.department', { ondelete: 'restrict', label: 'Part of' }),
|
|
60
|
+
head: f.many2one('hr.employee', { ondelete: 'set null', label: 'Head' }),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
export const HrJob = defineModel('hr.job', {
|
|
64
|
+
label: 'Position',
|
|
65
|
+
recName: 'name',
|
|
66
|
+
order: ['name asc'],
|
|
67
|
+
archivable: true,
|
|
68
|
+
companyScoped: { required: true },
|
|
69
|
+
access: { 'hr.user': READ, 'hr.manager': ALL },
|
|
70
|
+
fields: {
|
|
71
|
+
name: f.char({ required: true, translate: true }),
|
|
72
|
+
department: f.many2one('hr.department', { ondelete: 'set null' }),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
export const HrEmployee = defineModel('hr.employee', {
|
|
76
|
+
label: 'Employee',
|
|
77
|
+
recName: 'name',
|
|
78
|
+
order: ['name asc'],
|
|
79
|
+
archivable: true,
|
|
80
|
+
companyScoped: { required: true },
|
|
81
|
+
tracking: ['department', 'job', 'manager'],
|
|
82
|
+
access: { 'hr.user': READ, 'hr.manager': [...ALL, 'export', 'import'] },
|
|
83
|
+
fields: {
|
|
84
|
+
name: f.char({ required: true }),
|
|
85
|
+
/** The person's sign-in, when they have one. */
|
|
86
|
+
user: f.many2one('res.users', { ondelete: 'set null', label: 'User' }),
|
|
87
|
+
department: f.many2one('hr.department', { ondelete: 'set null' }),
|
|
88
|
+
job: f.many2one('hr.job', { ondelete: 'set null', label: 'Position' }),
|
|
89
|
+
manager: f.many2one('hr.employee', { ondelete: 'set null' }),
|
|
90
|
+
team: f.one2many('hr.employee', 'manager', { label: 'Team' }),
|
|
91
|
+
workEmail: f.char({ label: 'Work email' }),
|
|
92
|
+
workPhone: f.char({ label: 'Work phone' }),
|
|
93
|
+
hireDate: f.date({ label: 'Joined' }),
|
|
94
|
+
// Personal: HR managers only.
|
|
95
|
+
birthday: f.date({ groups: HR }),
|
|
96
|
+
nationalId: f.char({ label: 'National ID', groups: HR }),
|
|
97
|
+
privateAddress: f.text({ label: 'Home address', groups: HR }),
|
|
98
|
+
emergencyContact: f.char({ label: 'Emergency contact', groups: HR }),
|
|
99
|
+
},
|
|
100
|
+
constraints: {
|
|
101
|
+
oneEmployeePerUser: {
|
|
102
|
+
...check('hr.employee', ['user'], async (employees) => employees.env.asSuperuser({ reason: 'one employee per user' }, async (su) => {
|
|
103
|
+
const failing = [];
|
|
104
|
+
for (const e of employees) {
|
|
105
|
+
if (e.user === null)
|
|
106
|
+
continue;
|
|
107
|
+
const twins = await su
|
|
108
|
+
.withFlags({ activeTest: false })
|
|
109
|
+
.model('hr.employee')
|
|
110
|
+
.search({ where: { user: e.user.id, id: { ne: e.id } }, limit: 1 });
|
|
111
|
+
if (twins.length > 0)
|
|
112
|
+
failing.push(e.id);
|
|
113
|
+
}
|
|
114
|
+
return failing;
|
|
115
|
+
})),
|
|
116
|
+
message: 'This user is already another employee.',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
export const HrContract = defineModel('hr.contract', {
|
|
121
|
+
label: 'Contract',
|
|
122
|
+
recName: 'name',
|
|
123
|
+
order: ['dateStart desc', 'id desc'],
|
|
124
|
+
companyScoped: { required: true },
|
|
125
|
+
tracking: ['state', 'dateEnd', 'wage'],
|
|
126
|
+
access: { 'hr.user': READ, 'hr.manager': ALL },
|
|
127
|
+
rules: {
|
|
128
|
+
own: { groups: ['hr.user'], perms: ['read'], domain: { 'employee.user': me } },
|
|
129
|
+
all: { groups: ['hr.manager'], perms: [...ALL], domain: {} },
|
|
130
|
+
},
|
|
131
|
+
fields: {
|
|
132
|
+
name: f.char({ required: true, label: 'Reference' }),
|
|
133
|
+
employee: f.many2one('hr.employee', { required: true, ondelete: 'cascade' }),
|
|
134
|
+
kind: f.selection({ permanent: 'Permanent', fixed: 'Fixed term', probation: 'Probation', intern: 'Internship' }, { required: true, default: 'permanent', label: 'Type' }),
|
|
135
|
+
dateStart: f.date({ required: true, label: 'Starts' }),
|
|
136
|
+
dateEnd: f.date({ label: 'Ends' }),
|
|
137
|
+
wage: f.decimal({ scale: 2, label: 'Monthly wage', groups: HR }),
|
|
138
|
+
state: f.state({
|
|
139
|
+
states: { draft: 'Draft', running: 'Running', ended: 'Ended', cancelled: 'Cancelled' },
|
|
140
|
+
initial: 'draft',
|
|
141
|
+
transitions: {
|
|
142
|
+
start: { from: ['draft'], to: 'running' },
|
|
143
|
+
end: { from: ['running'], to: 'ended' },
|
|
144
|
+
cancel: { from: ['draft', 'running'], to: 'cancelled' },
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
sqlConstraints: {
|
|
149
|
+
endsAfterStart: {
|
|
150
|
+
check: orm.sql `date_end IS NULL OR date_end >= date_start`,
|
|
151
|
+
message: 'A contract ends after it starts.',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
export const HrLeaveType = defineModel('hr.leave.type', {
|
|
156
|
+
label: 'Leave type',
|
|
157
|
+
recName: 'name',
|
|
158
|
+
order: ['name asc'],
|
|
159
|
+
archivable: true,
|
|
160
|
+
access: { 'hr.user': READ, 'hr.manager': ALL },
|
|
161
|
+
fields: {
|
|
162
|
+
name: f.char({ required: true, translate: true }),
|
|
163
|
+
/** Days per calendar year for each person; empty: no balance (unpaid leave). */
|
|
164
|
+
daysPerYear: f.integer({ label: 'Days per year' }),
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
export const HrLeave = defineModel('hr.leave', {
|
|
168
|
+
label: 'Leave',
|
|
169
|
+
order: ['dateFrom desc', 'id desc'],
|
|
170
|
+
companyScoped: { required: true },
|
|
171
|
+
tracking: ['state', 'dateFrom', 'dateTo'],
|
|
172
|
+
access: { 'hr.user': ALL, 'hr.manager': ALL },
|
|
173
|
+
rules: {
|
|
174
|
+
// One's own requests in full; changed while still a draft.
|
|
175
|
+
seeOwn: { groups: ['hr.user'], perms: ['read'], domain: { 'employee.user': me } },
|
|
176
|
+
draftOwn: {
|
|
177
|
+
groups: ['hr.user'],
|
|
178
|
+
perms: ['write', 'create', 'unlink'],
|
|
179
|
+
domain: { 'employee.user': me, state: 'draft' },
|
|
180
|
+
},
|
|
181
|
+
// Line managers see their team's.
|
|
182
|
+
team: { groups: ['hr.user'], perms: ['read'], domain: { 'employee.manager.user': me } },
|
|
183
|
+
all: { groups: ['hr.manager'], perms: [...ALL], domain: {} },
|
|
184
|
+
},
|
|
185
|
+
fields: {
|
|
186
|
+
employee: f.many2one('hr.employee', { required: true, ondelete: 'cascade' }),
|
|
187
|
+
type: f.many2one('hr.leave.type', { required: true, ondelete: 'restrict', label: 'Type' }),
|
|
188
|
+
dateFrom: f.date({ required: true, label: 'From' }),
|
|
189
|
+
dateTo: f.date({ required: true, label: 'To' }),
|
|
190
|
+
/** Working days, by the company's week; checked by the server. */
|
|
191
|
+
days: f.integer({ required: true, default: 0, label: 'Working days' }),
|
|
192
|
+
reason: f.text(),
|
|
193
|
+
state: f.state({
|
|
194
|
+
states: { draft: 'Draft', submitted: 'Waiting', approved: 'Approved', refused: 'Refused' },
|
|
195
|
+
initial: 'draft',
|
|
196
|
+
transitions: {
|
|
197
|
+
submit: { from: ['draft'], to: 'submitted' },
|
|
198
|
+
// Never by the person asking, HR managers included.
|
|
199
|
+
approve: {
|
|
200
|
+
from: ['submitted'],
|
|
201
|
+
to: 'approved',
|
|
202
|
+
requires: 'hr.leave_decide',
|
|
203
|
+
guard: records('hr.leave', (leaves) => notOwn(leaves)),
|
|
204
|
+
message: 'Someone else decides your leave.',
|
|
205
|
+
},
|
|
206
|
+
refuse: {
|
|
207
|
+
from: ['submitted'],
|
|
208
|
+
to: 'refused',
|
|
209
|
+
requires: 'hr.leave_decide',
|
|
210
|
+
guard: records('hr.leave', (leaves) => notOwn(leaves)),
|
|
211
|
+
message: 'Someone else decides your leave.',
|
|
212
|
+
},
|
|
213
|
+
redraft: { from: ['submitted', 'refused'], to: 'draft' },
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
},
|
|
217
|
+
sqlConstraints: {
|
|
218
|
+
ordered: {
|
|
219
|
+
check: orm.sql `date_to >= date_from`,
|
|
220
|
+
message: 'A leave ends on or after it starts.',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
constraints: {
|
|
224
|
+
// The days the form says are the working days the server counts.
|
|
225
|
+
workingDays: {
|
|
226
|
+
...check('hr.leave', ['dateFrom', 'dateTo', 'days'], async (leaves) => {
|
|
227
|
+
const weekend = await weekendOf(leaves.env);
|
|
228
|
+
return [...leaves]
|
|
229
|
+
.filter((l) => {
|
|
230
|
+
const days = workingDays(iso(l.dateFrom), iso(l.dateTo), weekend);
|
|
231
|
+
return days === 0 || l.days !== days;
|
|
232
|
+
})
|
|
233
|
+
.map((l) => l.id);
|
|
234
|
+
}),
|
|
235
|
+
message: 'The working days do not match the dates (or none falls on a working day).',
|
|
236
|
+
},
|
|
237
|
+
noOverlap: {
|
|
238
|
+
...check('hr.leave', ['employee', 'dateFrom', 'dateTo', 'state'], async (leaves) => leaves.env.asSuperuser({ reason: 'overlapping leave' }, async (su) => {
|
|
239
|
+
const failing = [];
|
|
240
|
+
for (const l of leaves) {
|
|
241
|
+
if (l.state === 'refused')
|
|
242
|
+
continue;
|
|
243
|
+
const clash = await su.model('hr.leave').search({
|
|
244
|
+
where: {
|
|
245
|
+
employee: l.employee.id,
|
|
246
|
+
id: { ne: l.id },
|
|
247
|
+
state: { in: ['draft', 'submitted', 'approved'] },
|
|
248
|
+
dateFrom: { lte: l.dateTo },
|
|
249
|
+
dateTo: { gte: l.dateFrom },
|
|
250
|
+
},
|
|
251
|
+
limit: 1,
|
|
252
|
+
});
|
|
253
|
+
if (clash.length > 0)
|
|
254
|
+
failing.push(l.id);
|
|
255
|
+
}
|
|
256
|
+
return failing;
|
|
257
|
+
})),
|
|
258
|
+
message: 'This person already has leave on some of these days.',
|
|
259
|
+
},
|
|
260
|
+
// The year's days of its type: what is waiting and approved, this one included.
|
|
261
|
+
balance: {
|
|
262
|
+
...check('hr.leave', ['employee', 'type', 'days', 'dateFrom', 'state'], async (leaves) => leaves.env.asSuperuser({ reason: 'leave balance' }, async (su) => {
|
|
263
|
+
const failing = [];
|
|
264
|
+
for (const l of leaves) {
|
|
265
|
+
if (l.state !== 'submitted' && l.state !== 'approved')
|
|
266
|
+
continue;
|
|
267
|
+
const [type] = (await su.model('hr.leave.type').browse([l.type.id]).load(['daysPerYear'])).read(['daysPerYear']);
|
|
268
|
+
const allowed = type?.['daysPerYear'];
|
|
269
|
+
if (allowed === null || allowed === undefined)
|
|
270
|
+
continue;
|
|
271
|
+
const year = iso(l.dateFrom).slice(0, 4);
|
|
272
|
+
const taken = (await (await su.model('hr.leave').search({
|
|
273
|
+
where: {
|
|
274
|
+
employee: l.employee.id,
|
|
275
|
+
type: l.type.id,
|
|
276
|
+
state: { in: ['submitted', 'approved'] },
|
|
277
|
+
dateFrom: { gte: `${year}-01-01`, lte: `${year}-12-31` },
|
|
278
|
+
},
|
|
279
|
+
})).load(['days']))
|
|
280
|
+
.read(['days'])
|
|
281
|
+
.reduce((sum, r) => sum + Number(r['days'] ?? 0), 0);
|
|
282
|
+
if (taken > Number(allowed))
|
|
283
|
+
failing.push(l.id);
|
|
284
|
+
}
|
|
285
|
+
return failing;
|
|
286
|
+
})),
|
|
287
|
+
message: 'Not enough days left of this leave type this year.',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
onchange: {
|
|
291
|
+
dateFrom: onchange('hr.leave', async (d, env) => fillDays(d, env)),
|
|
292
|
+
dateTo: onchange('hr.leave', async (d, env) => fillDays(d, env)),
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
/** The leaves among `records` that the acting user asked for themself. */
|
|
296
|
+
async function notOwn(records) {
|
|
297
|
+
const { env, ids } = records;
|
|
298
|
+
return env.asSuperuser({ reason: 'own leave' }, async (su) => {
|
|
299
|
+
const leaves = (await su
|
|
300
|
+
.model('hr.leave')
|
|
301
|
+
.browse([...ids])
|
|
302
|
+
.load(['employee'])).read(['id', 'employee']);
|
|
303
|
+
const people = new Map((await su
|
|
304
|
+
.model('hr.employee')
|
|
305
|
+
.browse(leaves.map((l) => l['employee']))
|
|
306
|
+
.load(['user']))
|
|
307
|
+
.read(['id', 'user'])
|
|
308
|
+
.map((e) => [e['id'], e['user']]));
|
|
309
|
+
return leaves
|
|
310
|
+
.filter((l) => people.get(l['employee']) === env.uid)
|
|
311
|
+
.map((l) => l['id']);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/** The form's working days, from the dates and the company's week. */
|
|
315
|
+
async function fillDays(d, env) {
|
|
316
|
+
const from = d.get('dateFrom');
|
|
317
|
+
const to = d.get('dateTo');
|
|
318
|
+
if (from === null || from === undefined)
|
|
319
|
+
return;
|
|
320
|
+
if (to === null || to === undefined || iso(to) < iso(from))
|
|
321
|
+
d.set('dateTo', iso(from));
|
|
322
|
+
d.set('days', workingDays(iso(from), iso(d.get('dateTo') ?? from), await weekendOf(env)));
|
|
323
|
+
}
|
|
324
|
+
export const hrShutro = defineModule({
|
|
325
|
+
name: 'hr',
|
|
326
|
+
version: '0.1.0',
|
|
327
|
+
depends: [contactsShutro, messagingShutro],
|
|
328
|
+
groups: [
|
|
329
|
+
orm.defineGroup({ code: 'hr.user', label: 'Employee', implies: ['messaging.user'] }),
|
|
330
|
+
orm.defineGroup({
|
|
331
|
+
code: 'hr.manager',
|
|
332
|
+
label: 'HR manager',
|
|
333
|
+
implies: ['hr.user', 'contacts.user'],
|
|
334
|
+
}),
|
|
335
|
+
],
|
|
336
|
+
permissions: [
|
|
337
|
+
orm.definePermission({
|
|
338
|
+
code: 'hr.leave_decide',
|
|
339
|
+
label: 'Approve and refuse leave',
|
|
340
|
+
groups: ['hr.manager'],
|
|
341
|
+
}),
|
|
342
|
+
],
|
|
343
|
+
models: [HrDepartment, HrJob, HrEmployee, HrContract, HrLeaveType, HrLeave],
|
|
344
|
+
data: [
|
|
345
|
+
record('hr.leave.type', 'leave_casual', { name: 'Casual leave', daysPerYear: 10 }, { noupdate: true }),
|
|
346
|
+
record('hr.leave.type', 'leave_sick', { name: 'Sick leave', daysPerYear: 14 }, { noupdate: true }),
|
|
347
|
+
record('hr.leave.type', 'leave_annual', { name: 'Earned leave', daysPerYear: 20 }, { noupdate: true }),
|
|
348
|
+
record('hr.leave.type', 'leave_unpaid', { name: 'Unpaid leave' }, { noupdate: true }),
|
|
349
|
+
],
|
|
350
|
+
});
|
|
@@ -299,6 +299,11 @@ export function integrationsModule(options = {}) {
|
|
|
299
299
|
label: 'Inbound calls',
|
|
300
300
|
views: ['list', 'form'],
|
|
301
301
|
}),
|
|
302
|
+
'integrations.action_oauth_apps': {
|
|
303
|
+
type: 'client',
|
|
304
|
+
page: 'integrations.OAuthApps',
|
|
305
|
+
label: 'OAuth apps',
|
|
306
|
+
},
|
|
302
307
|
},
|
|
303
308
|
menus: [
|
|
304
309
|
{ id: 'integrations.root', label: 'Integrations', app: 'integrations' },
|
|
@@ -330,6 +335,13 @@ export function integrationsModule(options = {}) {
|
|
|
330
335
|
action: 'integrations.action_inbound',
|
|
331
336
|
sequence: 4,
|
|
332
337
|
},
|
|
338
|
+
{
|
|
339
|
+
id: 'integrations.oauth_apps',
|
|
340
|
+
parent: 'integrations.root',
|
|
341
|
+
label: 'OAuth apps',
|
|
342
|
+
action: 'integrations.action_oauth_apps',
|
|
343
|
+
sequence: 5,
|
|
344
|
+
},
|
|
333
345
|
],
|
|
334
346
|
views: {
|
|
335
347
|
'webhook.subscription.list': list('webhook.subscription', {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integrations › OAuth apps (RFC 0017 §5.2): the third-party apps that may ask users for access — their client id,
|
|
3
|
+
* redirect addresses and the scopes they may ask for. A new app's client secret is shown once (public apps have none
|
|
4
|
+
* and use PKCE); a new secret replaces the old at once; an app switched off stops every token it holds. The server
|
|
5
|
+
* checks the addresses and scopes and audits every change.
|
|
6
|
+
*/
|
|
7
|
+
import { type PageProps } from '../../ui/index.js';
|
|
8
|
+
import { type ReactElement } from 'react';
|
|
9
|
+
export declare function OAuthAppsPage({ api }: PageProps): ReactElement;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Integrations › OAuth apps (RFC 0017 §5.2): the third-party apps that may ask users for access — their client id,
|
|
4
|
+
* redirect addresses and the scopes they may ask for. A new app's client secret is shown once (public apps have none
|
|
5
|
+
* and use PKCE); a new secret replaces the old at once; an app switched off stops every token it holds. The server
|
|
6
|
+
* checks the addresses and scopes and audits every change.
|
|
7
|
+
*/
|
|
8
|
+
import { Alert, ApiError, Badge, Button, Checkbox, Dialog, Input, Label, } from '../../ui/index.js';
|
|
9
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
10
|
+
import { Check, Copy, KeyRound, Plus } from 'lucide-react';
|
|
11
|
+
import { useEffect, useId, useState } from 'react';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
const message = (error) => (error instanceof ApiError ? error.message : String(error));
|
|
14
|
+
/** A value to copy, with a button that says when it is copied. */
|
|
15
|
+
function Copyable({ value, label, }) {
|
|
16
|
+
const { t } = useTranslation('integrations');
|
|
17
|
+
const [copied, setCopied] = useState(false);
|
|
18
|
+
return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("code", { className: "min-w-0 flex-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs", children: value }), _jsx(Button, { size: "icon", variant: "ghost", "aria-label": t('oauth.copy', { what: label }), onClick: () => {
|
|
19
|
+
void navigator.clipboard?.writeText(value).then(() => setCopied(true));
|
|
20
|
+
}, children: copied ? _jsx(Check, { "aria-hidden": true }) : _jsx(Copy, { "aria-hidden": true }) })] }));
|
|
21
|
+
}
|
|
22
|
+
function NewAppDialog({ api, open, onOpenChange, }) {
|
|
23
|
+
const { t } = useTranslation('integrations');
|
|
24
|
+
const id = useId();
|
|
25
|
+
const queryClient = useQueryClient();
|
|
26
|
+
const [name, setName] = useState('');
|
|
27
|
+
const [uris, setUris] = useState('');
|
|
28
|
+
const [chosen, setChosen] = useState([]);
|
|
29
|
+
const [confidential, setConfidential] = useState(true);
|
|
30
|
+
const scopes = useQuery({
|
|
31
|
+
queryKey: ['auth', 'scopes'],
|
|
32
|
+
queryFn: () => api.call('GET', '/api/v1/auth/scopes'),
|
|
33
|
+
});
|
|
34
|
+
const create = useMutation({
|
|
35
|
+
mutationFn: () => api.call('POST', '/api/v1/oauth/apps', {
|
|
36
|
+
name,
|
|
37
|
+
confidential,
|
|
38
|
+
redirectUris: uris
|
|
39
|
+
.split(/\s+/)
|
|
40
|
+
.map((u) => u.trim())
|
|
41
|
+
.filter((u) => u !== ''),
|
|
42
|
+
scopes: chosen,
|
|
43
|
+
}),
|
|
44
|
+
onSuccess: () => void queryClient.invalidateQueries({ queryKey: ['oauth', 'apps'] }),
|
|
45
|
+
});
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!open) {
|
|
48
|
+
setName('');
|
|
49
|
+
setUris('');
|
|
50
|
+
setChosen([]);
|
|
51
|
+
setConfidential(true);
|
|
52
|
+
create.reset();
|
|
53
|
+
}
|
|
54
|
+
}, [open, create.reset]);
|
|
55
|
+
const made = create.data;
|
|
56
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, title: t('oauth.newTitle'), description: t('oauth.newHint'), wide: true, footer: made === undefined ? (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: () => onOpenChange(false), children: t('oauth.cancel') }), _jsx(Button, { variant: "primary", busy: create.isPending, disabled: name.trim() === '' || uris.trim() === '' || chosen.length === 0, onClick: () => create.mutate(), children: t('oauth.create') })] })) : (_jsx(Button, { variant: "primary", onClick: () => onOpenChange(false), children: t('oauth.done') })), children: made !== undefined ? (_jsxs("div", { className: "grid gap-3", children: [_jsx(Alert, { tone: "warning", children: made.clientSecret === null ? t('oauth.publicMade') : t('oauth.secretOnce') }), _jsxs("div", { className: "grid gap-1", children: [_jsx("span", { className: "text-sm font-medium", children: t('oauth.clientId') }), _jsx(Copyable, { value: made.clientId, label: t('oauth.clientId') })] }), made.clientSecret === null ? null : (_jsxs("div", { className: "grid gap-1", "data-testid": "oauth-secret", children: [_jsx("span", { className: "text-sm font-medium", children: t('oauth.clientSecret') }), _jsx(Copyable, { value: made.clientSecret, label: t('oauth.clientSecret') })] }))] })) : (_jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `${id}-name`, children: t('oauth.name') }), _jsx(Input, { id: `${id}-name`, value: name, onChange: (e) => setName(e.target.value) })] }), _jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `${id}-uris`, children: t('oauth.redirects') }), _jsx("textarea", { id: `${id}-uris`, rows: 2, className: "rounded-md border bg-surface px-3 py-2 font-mono text-sm", placeholder: "https://partner.example.com/oauth/callback", value: uris, onChange: (e) => setUris(e.target.value) }), _jsx("p", { className: "text-xs text-muted-foreground", children: t('oauth.redirectsHint') })] }), _jsxs("fieldset", { className: "grid gap-2", children: [_jsx("legend", { className: "mb-1 text-sm font-medium", children: t('oauth.scopes') }), _jsx("div", { className: "grid max-h-48 gap-1.5 overflow-auto rounded-md border p-2 sm:grid-cols-2", children: (scopes.data?.scopes ?? []).map((s) => (_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { id: `${id}-scope-${s.scope}`, checked: chosen.includes(s.scope), onCheckedChange: (on) => setChosen((all) => on === true ? [...all, s.scope] : all.filter((x) => x !== s.scope)) }), _jsx(Label, { htmlFor: `${id}-scope-${s.scope}`, className: "font-normal", children: s.label }), _jsx("code", { className: "ms-auto font-mono text-xs text-muted-foreground", children: s.scope })] }, s.scope))) })] }), _jsxs("div", { className: "flex items-start gap-2 text-sm", children: [_jsx(Checkbox, { id: `${id}-public`, checked: !confidential, onCheckedChange: (on) => setConfidential(on !== true) }), _jsxs(Label, { htmlFor: `${id}-public`, className: "font-normal", children: [t('oauth.public'), _jsx("span", { className: "block text-xs text-muted-foreground", children: t('oauth.publicHint') })] })] }), create.error === null ? null : _jsx(Alert, { tone: "danger", children: message(create.error) })] })) }));
|
|
57
|
+
}
|
|
58
|
+
export function OAuthAppsPage({ api }) {
|
|
59
|
+
const { t } = useTranslation('integrations');
|
|
60
|
+
const queryClient = useQueryClient();
|
|
61
|
+
const [creating, setCreating] = useState(false);
|
|
62
|
+
const [secret, setSecret] = useState(null);
|
|
63
|
+
const apps = useQuery({
|
|
64
|
+
queryKey: ['oauth', 'apps'],
|
|
65
|
+
queryFn: () => api.call('GET', '/api/v1/oauth/apps'),
|
|
66
|
+
});
|
|
67
|
+
const refresh = () => void queryClient.invalidateQueries({ queryKey: ['oauth', 'apps'] });
|
|
68
|
+
const rotate = useMutation({
|
|
69
|
+
mutationFn: (app) => api
|
|
70
|
+
.call('POST', `/api/v1/oauth/apps/${app.id}/secret`)
|
|
71
|
+
.then((r) => setSecret({ app: app.name, value: r.clientSecret })),
|
|
72
|
+
});
|
|
73
|
+
const toggle = useMutation({
|
|
74
|
+
mutationFn: (app) => api.call('PATCH', `/api/v1/oauth/apps/${app.id}`, { active: !app.active }),
|
|
75
|
+
onSuccess: refresh,
|
|
76
|
+
});
|
|
77
|
+
const error = apps.error ?? rotate.error ?? toggle.error;
|
|
78
|
+
return (_jsxs("div", { className: "mx-auto grid max-w-4xl gap-6", children: [_jsxs("header", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-xl font-semibold", children: t('oauth.title') }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('oauth.intro') })] }), _jsxs(Button, { variant: "primary", onClick: () => setCreating(true), children: [_jsx(Plus, { className: "size-4", "aria-hidden": true }), t('oauth.new')] })] }), error === null ? null : _jsx(Alert, { tone: "danger", children: message(error) }), secret === null ? null : (_jsxs(Alert, { tone: "warning", children: [_jsx("p", { className: "mb-2", children: t('oauth.newSecret', { app: secret.app }) }), _jsx(Copyable, { value: secret.value, label: t('oauth.clientSecret') })] })), apps.data === undefined ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "\u2026" })) : apps.data.apps.length === 0 ? (_jsx("p", { className: "rounded-lg border bg-surface p-6 text-center text-sm text-muted-foreground", children: t('oauth.none') })) : (_jsx("ul", { className: "grid gap-3", children: apps.data.apps.map((a) => (_jsxs("li", { className: "grid gap-3 rounded-lg border bg-surface p-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(KeyRound, { className: "size-4 text-muted-foreground", "aria-hidden": true }), _jsx("span", { className: "font-medium", children: a.name }), _jsx(Badge, { tone: a.confidential ? 'neutral' : 'info', children: a.confidential ? t('oauth.confidential') : t('oauth.publicBadge') }), a.active ? null : _jsx(Badge, { tone: "warning", children: t('oauth.inactive') }), _jsx("span", { className: "flex-1" }), a.confidential ? (_jsx(Button, { size: "sm", busy: rotate.isPending && rotate.variables?.id === a.id, onClick: () => rotate.mutate(a), children: t('oauth.rotate') })) : null, _jsx(Button, { size: "sm", variant: "ghost", busy: toggle.isPending && toggle.variables?.id === a.id, onClick: () => toggle.mutate(a), children: a.active ? t('oauth.deactivate') : t('oauth.activate') })] }), _jsxs("dl", { className: "grid gap-2 text-sm sm:grid-cols-[10rem_1fr]", children: [_jsx("dt", { className: "text-muted-foreground", children: t('oauth.clientId') }), _jsx("dd", { children: _jsx(Copyable, { value: a.clientId, label: t('oauth.clientId') }) }), _jsx("dt", { className: "text-muted-foreground", children: t('oauth.redirects') }), _jsx("dd", { className: "break-all font-mono text-xs", children: a.redirectUris.join('\n') }), _jsx("dt", { className: "text-muted-foreground", children: t('oauth.scopes') }), _jsx("dd", { className: "flex flex-wrap gap-1", children: a.scopes.map((s) => (_jsx(Badge, { children: _jsx("span", { className: "font-mono text-xs", children: s }) }, s))) })] })] }, a.id))) })), _jsx(NewAppDialog, { api: api, open: creating, onOpenChange: setCreating })] }));
|
|
79
|
+
}
|
|
@@ -10,6 +10,7 @@ import { messages } from './messages.js';
|
|
|
10
10
|
export { DeliveryTools } from './DeliveryTools.js';
|
|
11
11
|
export { EndpointTools } from './EndpointTools.js';
|
|
12
12
|
export { InboundTools } from './InboundTools.js';
|
|
13
|
+
export { OAuthAppsPage } from './OAuthAppsPage.js';
|
|
13
14
|
export { WebhookTools } from './WebhookTools.js';
|
|
14
15
|
/** Registers the components (and the messages in `i18n`, when given). */
|
|
15
16
|
export declare function registerIntegrationsWeb(registry: Registry, i18n?: i18n): Registry;
|
|
@@ -9,10 +9,12 @@ import { DeliveryTools } from './DeliveryTools.js';
|
|
|
9
9
|
import { EndpointTools } from './EndpointTools.js';
|
|
10
10
|
import { InboundTools } from './InboundTools.js';
|
|
11
11
|
import { messages } from './messages.js';
|
|
12
|
+
import { OAuthAppsPage } from './OAuthAppsPage.js';
|
|
12
13
|
import { WebhookTools } from './WebhookTools.js';
|
|
13
14
|
export { DeliveryTools } from './DeliveryTools.js';
|
|
14
15
|
export { EndpointTools } from './EndpointTools.js';
|
|
15
16
|
export { InboundTools } from './InboundTools.js';
|
|
17
|
+
export { OAuthAppsPage } from './OAuthAppsPage.js';
|
|
16
18
|
export { WebhookTools } from './WebhookTools.js';
|
|
17
19
|
/** Registers the components (and the messages in `i18n`, when given). */
|
|
18
20
|
export function registerIntegrationsWeb(registry, i18n) {
|
|
@@ -20,6 +22,7 @@ export function registerIntegrationsWeb(registry, i18n) {
|
|
|
20
22
|
registry.registerComponent('integrations.DeliveryTools', DeliveryTools);
|
|
21
23
|
registry.registerComponent('integrations.EndpointTools', EndpointTools);
|
|
22
24
|
registry.registerComponent('integrations.InboundTools', InboundTools);
|
|
25
|
+
registry.registerPage('integrations.OAuthApps', OAuthAppsPage);
|
|
23
26
|
if (i18n !== undefined)
|
|
24
27
|
addMessages(i18n, 'integrations', messages);
|
|
25
28
|
return registry;
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
/** Messages of the Integrations app (namespace `integrations`), in English and Bangla. */
|
|
2
2
|
export const messages = {
|
|
3
3
|
en: {
|
|
4
|
+
oauth: {
|
|
5
|
+
title: 'OAuth apps',
|
|
6
|
+
intro: 'Apps of other companies that may ask your users for access. Each user decides; an app never does more than its user may.',
|
|
7
|
+
new: 'New app',
|
|
8
|
+
newTitle: 'A new OAuth app',
|
|
9
|
+
newHint: 'Where users are sent back after they allow it, and what it may ask for.',
|
|
10
|
+
name: 'Name',
|
|
11
|
+
redirects: 'Redirect addresses',
|
|
12
|
+
redirectsHint: 'One per line, https (http only for localhost). The address must match exactly.',
|
|
13
|
+
scopes: 'Scopes it may ask for',
|
|
14
|
+
public: 'A public app (phone or browser app: no secret, PKCE only)',
|
|
15
|
+
publicHint: 'It cannot keep a secret, so every sign-in proves itself with PKCE.',
|
|
16
|
+
create: 'Create',
|
|
17
|
+
cancel: 'Cancel',
|
|
18
|
+
done: 'Done',
|
|
19
|
+
clientId: 'Client id',
|
|
20
|
+
clientSecret: 'Client secret',
|
|
21
|
+
secretOnce: 'Copy the client secret now: it is shown only once.',
|
|
22
|
+
publicMade: 'A public app has no secret: give the developer its client id.',
|
|
23
|
+
newSecret: 'The new secret of {{app}}: copy it now. The old one stops working.',
|
|
24
|
+
copy: 'Copy the {{what}}',
|
|
25
|
+
none: 'No OAuth apps yet.',
|
|
26
|
+
confidential: 'Confidential',
|
|
27
|
+
publicBadge: 'Public',
|
|
28
|
+
inactive: 'Switched off',
|
|
29
|
+
rotate: 'New secret',
|
|
30
|
+
deactivate: 'Switch off',
|
|
31
|
+
activate: 'Switch on',
|
|
32
|
+
},
|
|
4
33
|
tools: {
|
|
5
34
|
title: 'Webhook tools',
|
|
6
35
|
ping: 'Send a test event',
|
|
@@ -26,6 +55,35 @@ export const messages = {
|
|
|
26
55
|
},
|
|
27
56
|
},
|
|
28
57
|
bn: {
|
|
58
|
+
oauth: {
|
|
59
|
+
title: 'OAuth অ্যাপ',
|
|
60
|
+
intro: 'অন্য প্রতিষ্ঠানের অ্যাপ যা আপনার ব্যবহারকারীদের কাছে অনুমতি চাইতে পারে। প্রতিটি ব্যবহারকারী নিজে সিদ্ধান্ত নেন।',
|
|
61
|
+
new: 'নতুন অ্যাপ',
|
|
62
|
+
newTitle: 'নতুন OAuth অ্যাপ',
|
|
63
|
+
newHint: 'অনুমতির পর ব্যবহারকারীরা কোথায় ফিরবেন, আর এটি কী চাইতে পারে।',
|
|
64
|
+
name: 'নাম',
|
|
65
|
+
redirects: 'ফেরত ঠিকানা',
|
|
66
|
+
redirectsHint: 'প্রতি লাইনে একটি, https (localhost এর জন্য http)। ঠিকানা হুবহু মিলতে হবে।',
|
|
67
|
+
scopes: 'যে স্কোপ চাইতে পারে',
|
|
68
|
+
public: 'পাবলিক অ্যাপ (ফোন বা ব্রাউজার: সিক্রেট নেই, শুধু PKCE)',
|
|
69
|
+
publicHint: 'এটি সিক্রেট রাখতে পারে না, তাই প্রতিটি সাইন-ইন PKCE দিয়ে প্রমাণ করে।',
|
|
70
|
+
create: 'তৈরি করুন',
|
|
71
|
+
cancel: 'বাতিল',
|
|
72
|
+
done: 'শেষ',
|
|
73
|
+
clientId: 'ক্লায়েন্ট আইডি',
|
|
74
|
+
clientSecret: 'ক্লায়েন্ট সিক্রেট',
|
|
75
|
+
secretOnce: 'এখনই সিক্রেট কপি করুন: এটি একবারই দেখানো হয়।',
|
|
76
|
+
publicMade: 'পাবলিক অ্যাপের সিক্রেট নেই: ডেভেলপারকে ক্লায়েন্ট আইডি দিন।',
|
|
77
|
+
newSecret: '{{app}}-এর নতুন সিক্রেট: এখনই কপি করুন। পুরনোটি আর কাজ করবে না।',
|
|
78
|
+
copy: '{{what}} কপি করুন',
|
|
79
|
+
none: 'এখনো কোনো OAuth অ্যাপ নেই।',
|
|
80
|
+
confidential: 'গোপনীয়',
|
|
81
|
+
publicBadge: 'পাবলিক',
|
|
82
|
+
inactive: 'বন্ধ',
|
|
83
|
+
rotate: 'নতুন সিক্রেট',
|
|
84
|
+
deactivate: 'বন্ধ করুন',
|
|
85
|
+
activate: 'চালু করুন',
|
|
86
|
+
},
|
|
29
87
|
tools: {
|
|
30
88
|
title: 'ওয়েবহুক সরঞ্জাম',
|
|
31
89
|
ping: 'পরীক্ষামূলক ইভেন্ট পাঠান',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash:
|
|
1
|
+
// GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: f724be50cf2472e1
|
|
2
2
|
// Bindings of module `l10n_bd`: import the definition API from here to get types scoped to what it can see.
|
|
3
3
|
export { defineModel, defineModule, extendModel, f, replace } from '../../server/orm.js';
|
|
4
4
|
import { definitions } from '../../server/orm.js';
|