adula 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +149 -18
  2. package/build/agent/AGENTS.template.md +4 -4
  3. package/build/agent/capabilities.md +22 -11
  4. package/build/agent/skills/adula-frontend-design/SKILL.md +1 -1
  5. package/build/agent/skills/idea-review/SKILL.md +2 -2
  6. package/build/commands/adula_outbox.d.ts +10 -0
  7. package/build/commands/adula_outbox.js +11 -0
  8. package/build/commands/adula_restore_reconcile.d.ts +10 -0
  9. package/build/commands/adula_restore_reconcile.js +34 -0
  10. package/build/commands/adula_runtime_health.d.ts +10 -0
  11. package/build/commands/adula_runtime_health.js +27 -0
  12. package/build/commands/adula_uploads_prune.d.ts +10 -0
  13. package/build/commands/adula_uploads_prune.js +16 -0
  14. package/build/commands/app.d.ts +10 -0
  15. package/build/commands/app.js +64 -0
  16. package/build/commands/backup_create.d.ts +11 -0
  17. package/build/commands/backup_create.js +99 -0
  18. package/build/commands/backup_restore_files.d.ts +11 -0
  19. package/build/commands/backup_restore_files.js +44 -0
  20. package/build/commands/backup_restore_test.d.ts +12 -0
  21. package/build/commands/backup_restore_test.js +185 -0
  22. package/build/commands/backup_services.d.ts +31 -0
  23. package/build/commands/backup_services.js +6 -0
  24. package/build/commands/backup_verify.d.ts +9 -0
  25. package/build/commands/backup_verify.js +59 -0
  26. package/build/commands/backup_verify_snapshot.d.ts +10 -0
  27. package/build/commands/backup_verify_snapshot.js +37 -0
  28. package/build/commands/client.d.ts +16 -0
  29. package/build/commands/client.js +71 -0
  30. package/build/commands/doctor.js +4 -1
  31. package/build/commands/install.d.ts +8 -0
  32. package/build/commands/install.js +63 -45
  33. package/build/commands/main.d.ts +3 -2
  34. package/build/commands/main.js +26 -0
  35. package/build/commands/module_add.js +4 -20
  36. package/build/commands/resource.d.ts +2 -0
  37. package/build/commands/resource.js +12 -3
  38. package/build/commands/resource_migration.d.ts +15 -0
  39. package/build/commands/resource_migration.js +72 -0
  40. package/build/commands/resource_snapshot.d.ts +2 -0
  41. package/build/commands/resource_snapshot.js +3 -0
  42. package/build/commands/sla_evaluate.d.ts +14 -0
  43. package/build/commands/sla_evaluate.js +16 -0
  44. package/build/commands/ui.js +5 -3
  45. package/build/commands/ui_css.d.ts +9 -0
  46. package/build/commands/ui_css.js +19 -0
  47. package/build/commands/upgrade.d.ts +1 -1
  48. package/build/commands/upgrade.js +1 -1
  49. package/build/configure.js +1 -1
  50. package/build/database/migrations/1770000000020_two_factor.d.ts +5 -0
  51. package/build/database/migrations/1770000000020_two_factor.js +10 -0
  52. package/build/database/migrations/1770000000041_import_modes.d.ts +5 -0
  53. package/build/database/migrations/1770000000041_import_modes.js +10 -0
  54. package/build/database/migrations/1770000000042_sync_jobs.d.ts +5 -0
  55. package/build/database/migrations/1770000000042_sync_jobs.js +10 -0
  56. package/build/database/migrations/1770000000043_notification_channels.d.ts +5 -0
  57. package/build/database/migrations/1770000000043_notification_channels.js +10 -0
  58. package/build/database/migrations/1770000000044_channel_confirmations.d.ts +5 -0
  59. package/build/database/migrations/1770000000044_channel_confirmations.js +10 -0
  60. package/build/database/migrations/1770000000045_import_leases.d.ts +5 -0
  61. package/build/database/migrations/1770000000045_import_leases.js +10 -0
  62. package/build/database/migrations/1770000000046_workflow_delegation_sla.d.ts +5 -0
  63. package/build/database/migrations/1770000000046_workflow_delegation_sla.js +10 -0
  64. package/build/database/migrations/1770000000049_print_templates.d.ts +5 -0
  65. package/build/database/migrations/1770000000049_print_templates.js +10 -0
  66. package/build/index.d.ts +56 -10
  67. package/build/index.js +34 -6
  68. package/build/providers/adula_provider.d.ts +2 -0
  69. package/build/providers/adula_provider.js +7 -0
  70. package/build/src/admin/contracts.js +1 -1
  71. package/build/src/admin/controller.d.ts +14 -1
  72. package/build/src/admin/controller.js +77 -13
  73. package/build/src/admin/errors.d.ts +32 -0
  74. package/build/src/admin/errors.js +63 -1
  75. package/build/src/admin/presentation.d.ts +21 -2
  76. package/build/src/admin/resource/editor.d.ts +59 -0
  77. package/build/src/admin/resource/editor.js +323 -0
  78. package/build/src/admin/resource/export.d.ts +37 -0
  79. package/build/src/admin/resource/export.js +181 -0
  80. package/build/src/admin/resource/lifecycle.d.ts +21 -0
  81. package/build/src/admin/resource/lifecycle.js +91 -0
  82. package/build/src/admin/resource/query.d.ts +100 -0
  83. package/build/src/admin/resource/query.js +508 -0
  84. package/build/src/admin/resource/read.d.ts +106 -0
  85. package/build/src/admin/resource/read.js +327 -0
  86. package/build/src/admin/resource/shared.d.ts +77 -0
  87. package/build/src/admin/resource/shared.js +222 -0
  88. package/build/src/admin/resource/trash.d.ts +10 -0
  89. package/build/src/admin/resource/trash.js +56 -0
  90. package/build/src/admin/resource/write.d.ts +57 -0
  91. package/build/src/admin/resource/write.js +574 -0
  92. package/build/src/admin/resource_service.d.ts +66 -193
  93. package/build/src/admin/resource_service.js +69 -1345
  94. package/build/src/attachments/attachment_service.d.ts +46 -2
  95. package/build/src/attachments/attachment_service.js +96 -4
  96. package/build/src/auth/conditions.d.ts +5 -0
  97. package/build/src/auth/conditions.js +26 -3
  98. package/build/src/auth/sql.js +17 -5
  99. package/build/src/auth/two_factor.d.ts +96 -0
  100. package/build/src/auth/two_factor.js +259 -0
  101. package/build/src/collaboration/assignments.d.ts +36 -1
  102. package/build/src/collaboration/assignments.js +132 -66
  103. package/build/src/collaboration/record_collaboration.d.ts +2 -3
  104. package/build/src/collaboration/record_collaboration.js +19 -16
  105. package/build/src/collaboration/shared.d.ts +16 -0
  106. package/build/src/collaboration/shared.js +21 -0
  107. package/build/src/commands/app_scaffold.d.ts +72 -0
  108. package/build/src/commands/app_scaffold.js +285 -0
  109. package/build/src/commands/capabilities.js +34 -8
  110. package/build/src/commands/doctor.d.ts +14 -2
  111. package/build/src/commands/doctor.js +50 -5
  112. package/build/src/commands/gap_report.d.ts +1 -1
  113. package/build/src/commands/gap_report.js +2 -2
  114. package/build/src/commands/generator.d.ts +37 -1
  115. package/build/src/commands/generator.js +61 -18
  116. package/build/src/commands/snapshot.d.ts +10 -13
  117. package/build/src/commands/snapshot.js +31 -14
  118. package/build/src/commands/source_markers.d.ts +10 -0
  119. package/build/src/commands/source_markers.js +29 -0
  120. package/build/src/core/activity.d.ts +2 -0
  121. package/build/src/core/activity.js +7 -1
  122. package/build/src/core/administrators.d.ts +38 -0
  123. package/build/src/core/administrators.js +129 -0
  124. package/build/src/core/html_sanitizer.d.ts +20 -0
  125. package/build/src/core/html_sanitizer.js +261 -0
  126. package/build/src/core/like.d.ts +5 -0
  127. package/build/src/core/like.js +5 -0
  128. package/build/src/core/lookups.d.ts +80 -0
  129. package/build/src/core/lookups.js +319 -0
  130. package/build/src/core/message_templates.d.ts +7 -2
  131. package/build/src/core/message_templates.js +72 -11
  132. package/build/src/core/module_seed.js +2 -1
  133. package/build/src/core/notification_channels.d.ts +235 -0
  134. package/build/src/core/notification_channels.js +660 -0
  135. package/build/src/core/roles.js +2 -2
  136. package/build/src/core/saved_views.d.ts +8 -1
  137. package/build/src/core/saved_views.js +36 -2
  138. package/build/src/core/sequences.d.ts +32 -0
  139. package/build/src/core/sequences.js +97 -0
  140. package/build/src/core/settings.d.ts +5 -0
  141. package/build/src/core/settings.js +19 -2
  142. package/build/src/core/template_language.d.ts +61 -0
  143. package/build/src/core/template_language.js +141 -0
  144. package/build/src/core/ui_preferences.d.ts +4 -0
  145. package/build/src/core/ui_preferences.js +4 -1
  146. package/build/src/core/user_invitations.d.ts +5 -1
  147. package/build/src/core/user_invitations.js +7 -1
  148. package/build/src/core/users.js +1 -1
  149. package/build/src/database/calendar_days.d.ts +19 -0
  150. package/build/src/database/calendar_days.js +36 -0
  151. package/build/src/database/schema.d.ts +155 -2
  152. package/build/src/database/schema.js +531 -59
  153. package/build/src/database/schema_diff.d.ts +56 -0
  154. package/build/src/database/schema_diff.js +157 -0
  155. package/build/src/events/record_mutation.d.ts +2 -1
  156. package/build/src/events/record_mutation.js +1 -0
  157. package/build/src/integrations/api_client.d.ts +37 -0
  158. package/build/src/integrations/api_client.js +552 -0
  159. package/build/src/integrations/import_adapters.d.ts +37 -0
  160. package/build/src/integrations/import_adapters.js +35 -0
  161. package/build/src/integrations/imports.d.ts +118 -16
  162. package/build/src/integrations/imports.js +406 -73
  163. package/build/src/integrations/openapi.d.ts +3 -1
  164. package/build/src/integrations/openapi.js +454 -31
  165. package/build/src/integrations/outbound.d.ts +51 -0
  166. package/build/src/integrations/outbound.js +195 -0
  167. package/build/src/integrations/print.d.ts +21 -1
  168. package/build/src/integrations/print.js +63 -21
  169. package/build/src/integrations/print_templates.d.ts +216 -0
  170. package/build/src/integrations/print_templates.js +1015 -0
  171. package/build/src/integrations/sync_jobs.d.ts +139 -0
  172. package/build/src/integrations/sync_jobs.js +416 -0
  173. package/build/src/integrations/webhooks.d.ts +12 -12
  174. package/build/src/integrations/webhooks.js +34 -43
  175. package/build/src/languages/ar.d.ts +11 -0
  176. package/build/src/languages/ar.js +336 -0
  177. package/build/src/languages/ar_ui.d.ts +332 -0
  178. package/build/src/languages/ar_ui.js +333 -0
  179. package/build/src/languages/catalog.d.ts +66 -0
  180. package/build/src/languages/catalog.js +152 -0
  181. package/build/src/languages/en.d.ts +7 -0
  182. package/build/src/languages/en.js +330 -0
  183. package/build/src/languages/en_ui.d.ts +3 -0
  184. package/build/src/languages/en_ui.js +328 -0
  185. package/build/src/languages/validation.d.ts +26 -0
  186. package/build/src/languages/validation.js +60 -0
  187. package/build/src/lists/bulk_actions.d.ts +89 -0
  188. package/build/src/lists/bulk_actions.js +268 -0
  189. package/build/src/lists/dashboards.d.ts +96 -0
  190. package/build/src/lists/dashboards.js +241 -0
  191. package/build/src/mcp/tools.js +1 -1
  192. package/build/src/resource/define_resource.d.ts +18 -1
  193. package/build/src/resource/define_resource.js +205 -18
  194. package/build/src/resource/definition.d.ts +44 -0
  195. package/build/src/resource/definition.js +171 -0
  196. package/build/src/resource/registry.js +15 -4
  197. package/build/src/resource/types.d.ts +304 -16
  198. package/build/src/resource/values.d.ts +56 -1
  199. package/build/src/resource/values.js +237 -5
  200. package/build/src/services/settings.d.ts +2 -0
  201. package/build/src/services/settings.js +5 -1
  202. package/build/src/upgrade/legacy.js +2 -2
  203. package/build/src/workflows/calendar.d.ts +9 -0
  204. package/build/src/workflows/calendar.js +44 -0
  205. package/build/src/workflows/define_workflow.d.ts +48 -3
  206. package/build/src/workflows/define_workflow.js +57 -13
  207. package/build/src/workflows/delegations.d.ts +93 -0
  208. package/build/src/workflows/delegations.js +287 -0
  209. package/build/src/workflows/engine.d.ts +69 -4
  210. package/build/src/workflows/engine.js +441 -83
  211. package/build/src/workflows/sla.d.ts +15 -0
  212. package/build/src/workflows/sla.js +8 -0
  213. package/build/stubs/resource_contract.txt +12 -1
  214. package/package.json +5 -2
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createImportLeasesSchema } from '../../src/database/schema.js';
3
+ export default class ImportLeases extends BaseSchema {
4
+ async up() {
5
+ await createImportLeasesSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class WorkflowDelegationSla extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createWorkflowDelegationSlaSchema } from '../../src/database/schema.js';
3
+ export default class WorkflowDelegationSla extends BaseSchema {
4
+ async up() {
5
+ await createWorkflowDelegationSlaSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class PrintTemplates extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createPrintTemplatesSchema } from '../../src/database/schema.js';
3
+ export default class PrintTemplates extends BaseSchema {
4
+ async up() {
5
+ await createPrintTemplatesSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { defineResource, columnName } from './src/resource/define_resource.js';
1
+ export { defineResource, columnName, joinTable } from './src/resource/define_resource.js';
2
2
  export { configure } from './configure.js';
3
3
  export { withAdulaDatabase } from './src/database/configure.js';
4
4
  export { createResourceController } from './src/admin/controller.js';
@@ -14,19 +14,53 @@ export { accessibleBy, authorizationSql, conditionSql } from './src/auth/sql.js'
14
14
  export { ACTOR_ID, resolveActorConditions } from './src/auth/conditions.js';
15
15
  export { ResourceService, canQueryField } from './src/admin/resource_service.js';
16
16
  export type { AggregateOptions, AggregateRow, ListOptions } from './src/admin/resource_service.js';
17
+ export { EXPORT_ROW_LIMIT } from './src/admin/resource_service.js';
18
+ export type { CsvExport, ExportOptions, ListFilterScalar, ListFilterValue, } from './src/admin/resource_service.js';
19
+ export { BulkActions, defineBulkActions, BULK_ID_LIMIT } from './src/lists/bulk_actions.js';
20
+ export type { BulkActionDefinition, BulkActionOption, BulkActionSet, BulkActionsOptions, BulkFailure, BulkRequest, BulkResult, } from './src/lists/bulk_actions.js';
21
+ export { Dashboards, defineDashboard } from './src/lists/dashboards.js';
22
+ export type { DashboardDefinition, DashboardFormat, DashboardGroupRow, DashboardMeasure, DashboardResult, DashboardSummary, DashboardWidgetDefinition, DashboardWidgetResult, } from './src/lists/dashboards.js';
17
23
  export { serialize, writableInput, selectedFields } from './src/admin/contracts.js';
18
24
  export { AdulaError } from './src/admin/errors.js';
19
- export { createCoreSchema, createResourceTable, createAttachmentsSchema, createSavedViewsSchema, createCollaborationSchema, createAssignmentsSchema, createMessagingSchema, createWebhooksSchema, createImportsSchema, createWorkflowSchema, createManagedAssignmentsSchema, createRoleKeysSchema, createNotificationTargetsSchema, createUploadGrantsSchema, createInboundWebhooksSchema, } from './src/database/schema.js';
25
+ export { BASE_LANGUAGE, registerLanguage, registeredLanguages, enabledLanguages, resolveLanguage, languageDirection, translate, localizeText, messageKeyOf, clientMessages, runWithLanguage, currentLanguage, labelText, } from './src/languages/catalog.js';
26
+ export type { MessageCatalog, MessageParams, TextDirection, LanguageInfo, LanguageOptions, } from './src/languages/catalog.js';
27
+ export { arabicMessages } from './src/languages/ar.js';
28
+ export { englishMessages } from './src/languages/en.js';
29
+ export { CatalogMessagesProvider, installCatalogMessages } from './src/languages/validation.js';
30
+ export { TwoFactor, normalizeRecoveryCode, RECOVERY_CODE_COUNT, TWO_FACTOR_PERIOD, TWO_FACTOR_DIGITS, TWO_FACTOR_WINDOW, TWO_FACTOR_UNREADABLE, } from './src/auth/two_factor.js';
31
+ export type { TwoFactorStatus, TwoFactorEnrolment, TwoFactorResult, TwoFactorOptions, TwoFactorVerifyOptions, } from './src/auth/two_factor.js';
32
+ export { createCoreSchema, createResourceTable, createAttachmentsSchema, createSavedViewsSchema, createCollaborationSchema, createAssignmentsSchema, createMessagingSchema, createWebhooksSchema, createImportsSchema, createWorkflowSchema, createManagedAssignmentsSchema, createRoleKeysSchema, createNotificationTargetsSchema, createUploadGrantsSchema, createInboundWebhooksSchema, createTwoFactorSchema, createWorkflowDelegationSlaSchema, resourceSchema, alterResourceTable, fieldColumnType, } from './src/database/schema.js';
33
+ export type { ResourceSchema, ResourceColumn, ResourceUniqueIndex, ResourceJoinTable, ResourceAddition, ResourceTableDefinition, } from './src/database/schema.js';
34
+ export { schemaDrift, resourceAddition, describeDrift } from './src/database/schema_diff.js';
35
+ export type { SchemaDrift } from './src/database/schema_diff.js';
36
+ export { definitionSchema, definitionValidator, resourceValidator, isVisible, applyVisibility, } from './src/resource/definition.js';
37
+ export { FieldValueError, canonicalDecimal, decimalShape, isMultipleAttachment, attachmentLimit, MULTIPLE_ATTACHMENT_LIMIT, MULTIPLE_ATTACHMENT_MAX, } from './src/resource/values.js';
20
38
  export { defineWorkflow, nextStep } from './src/workflows/define_workflow.js';
21
- export type { WorkflowDefinition, WorkflowInput, WorkflowStep, WorkflowEvent, StepContext, Recipients, DecisionOutcome, } from './src/workflows/define_workflow.js';
22
- export { WorkflowEngine, workflowListeners } from './src/workflows/engine.js';
23
- export type { WorkflowRun, WorkflowRunStatus, WorkflowOptions, WorkflowDecisionForm, } from './src/workflows/engine.js';
39
+ export type { WorkflowDefinition, WorkflowInput, WorkflowStep, WorkflowEvent, StepContext, Recipients, DecisionOutcome, StepSla, SlaEscalation, EscalationTarget, } from './src/workflows/define_workflow.js';
40
+ export { WorkflowEngine, workflowListeners, slaState } from './src/workflows/engine.js';
41
+ export type { WorkflowRun, WorkflowRunStatus, WorkflowOptions, WorkflowDecisionForm, SlaState, WorkflowSlaStatus, SlaEvaluation, } from './src/workflows/engine.js';
42
+ export { WorkflowDelegations } from './src/workflows/delegations.js';
43
+ export type { WorkflowDelegation, WorkflowDelegationInput, WorkflowDelegationOptions, } from './src/workflows/delegations.js';
24
44
  export { ImportBatches, importCell, IMPORT_ROW_LIMIT } from './src/integrations/imports.js';
25
45
  export type { ImportBatch, ImportStatus, ImportTarget, ActorSource, } from './src/integrations/imports.js';
46
+ export type { ImportBatchRecord, ImportBatchStatus, ImportTargetField, ImportMode, ImportReportRow, ImportBatchesOptions, ImportCreateInput, ImportStartOptions, } from './src/integrations/imports.js';
47
+ export { csvImportAdapter, importFile } from './src/integrations/import_adapters.js';
48
+ export type { ImportAdapter, ImportFile, ImportTable } from './src/integrations/import_adapters.js';
49
+ export { createImportModesSchema, createImportLeasesSchema } from './src/database/schema.js';
26
50
  export { openApiDocument } from './src/integrations/openapi.js';
27
- export { renderPrintHtml, htmlToPdf } from './src/integrations/print.js';
51
+ export { apiClientSource, apiClientDeclarations } from './src/integrations/api_client.js';
52
+ export type { ApiClientDocument, ApiClientOptions } from './src/integrations/api_client.js';
53
+ export { renderPrintHtml, htmlToPdf, imageDataUri, PRINT_LOGO_LIMIT, } from './src/integrations/print.js';
28
54
  export type { PrintIdentity, PrintInput } from './src/integrations/print.js';
55
+ export { PrintTemplates, DEFAULT_PRINT_TEMPLATE, PRINT_HELPERS, PRINT_PAPERS, PRINT_ORIENTATIONS, codeTemplateVersion, renderTemplateDocument, printableGroups, PRINT_LINE_LIMIT, } from './src/integrations/print_templates.js';
56
+ export type { PrintTemplateDetail, PrintTemplateDraft, PrintTemplateInput, PrintTemplateOption, PrintTemplateSource, PrintTemplateSummary, PrintTemplateVersion, PrintedDocument, PrintOptions, PrintSource, PrintLayout, } from './src/integrations/print_templates.js';
57
+ export { sanitizePrintHtml } from './src/core/html_sanitizer.js';
58
+ export { parseTemplate } from './src/core/template_language.js';
59
+ export type { TemplateNode, TemplateRef } from './src/core/template_language.js';
60
+ export { createPrintTemplatesSchema } from './src/database/schema.js';
29
61
  export { Webhooks, signWebhook, WEBHOOK_MAX_ATTEMPTS } from './src/integrations/webhooks.js';
62
+ export { createOutboundPoster, isBlockedAddress, outboundErrorCategory, } from './src/integrations/outbound.js';
63
+ export type { OutboundOptions, OutboundRequest, OutboundTarget, OutboundErrorCategory, } from './src/integrations/outbound.js';
30
64
  export { InboundWebhooks, inboundEventName, INBOUND_BODY_LIMIT, INBOUND_RETENTION_DAYS, } from './src/integrations/inbound_webhooks.js';
31
65
  export type { InboundSource, InboundSourceInput, InboundDelivery, InboundReceipt, } from './src/integrations/inbound_webhooks.js';
32
66
  export type { SecretBox, Webhook, WebhookDelivery, WebhookOptions, HttpPoster, } from './src/integrations/webhooks.js';
@@ -37,17 +71,17 @@ export type { Assignment, AssignmentPage, AssignmentOptions, CloseNotePolicy, As
37
71
  export { RecordCollaboration, followerListeners } from './src/collaboration/record_collaboration.js';
38
72
  export type { ActorLoader, CommentEntry, FieldChangeEntry, RecordCollaborationState, MentionCandidate, } from './src/collaboration/record_collaboration.js';
39
73
  export type { FieldChange } from './src/events/record_mutation.js';
40
- export { registerUpload, findAttachment, loadAttachments, claimAttachment, releaseAttachment, summarizeAttachment, attachmentUrl, isAttachmentId, isRelativeDiskPath, attachmentPolicy, pendingUploadCount, staleUploads, forgetUpload, DEFAULT_ATTACHMENT_EXTENSIONS, PENDING_UPLOAD_LIMIT, UNBOUND_UPLOAD_TTL_MS, } from './src/attachments/attachment_service.js';
41
- export type { AttachmentRecord, AttachmentSummary, UploadInput, ClaimInput, } from './src/attachments/attachment_service.js';
74
+ export { registerUpload, findAttachment, loadAttachments, claimAttachment, releaseAttachment, summarizeAttachment, attachmentUrl, isAttachmentId, isRelativeDiskPath, attachmentPolicy, attachmentPreview, attachmentHeaders, pendingUploadCount, staleUploads, forgetUpload, DEFAULT_ATTACHMENT_EXTENSIONS, PENDING_UPLOAD_LIMIT, UNBOUND_UPLOAD_TTL_MS, } from './src/attachments/attachment_service.js';
75
+ export type { AttachmentRecord, AttachmentSummary, AttachmentPreview, AttachmentPreviewOptions, UploadInput, ClaimInput, } from './src/attachments/attachment_service.js';
42
76
  export { grantUpload, redeemUploadGrant, pruneUploadGrants, UPLOAD_GRANT_MAX_TTL_MS, } from './src/attachments/upload_grants.js';
43
77
  export type { UploadGrantInput, UploadGrant, RedeemedUploadGrant, } from './src/attachments/upload_grants.js';
44
78
  export { migrateStorage } from './src/attachments/storage_migrate.js';
45
79
  export type { StorageDisk, StorageMigrationOptions, StorageMigrationResult, } from './src/attachments/storage_migrate.js';
46
80
  export { diagnoseAttachments } from './src/attachments/doctor.js';
47
- export { Settings, sequence, notify } from './src/services/settings.js';
81
+ export { Settings, sequence, formatSequence, notify } from './src/services/settings.js';
48
82
  export type { NotificationTarget } from './src/services/settings.js';
49
83
  export { uiPreferences, validateUiPreferences, UI_PREFERENCES_KEY, DEFAULT_UI_PREFERENCES, } from './src/core/ui_preferences.js';
50
- export type { UiPreferences, CalendarSystem, CalendarPreference, } from './src/core/ui_preferences.js';
84
+ export type { UiPreferences, CalendarSystem, CalendarPreference, DigitsPreference, } from './src/core/ui_preferences.js';
51
85
  export { moveOrgUnit } from './src/org/org_service.js';
52
86
  export { publishOutbox, consumeEvent } from './src/events/outbox.js';
53
87
  export type { Jobs, DomainEvent, Listener } from './src/events/outbox.js';
@@ -72,9 +106,21 @@ export { NotificationsAdmin } from './src/core/notifications.js';
72
106
  export type { Notification, NotificationPage } from './src/core/notifications.js';
73
107
  export { SettingsAdmin, isProtectedSetting, parseSettingValue, SETTING_SCOPES, PROTECTED_SETTING_KEYS, } from './src/core/settings.js';
74
108
  export type { SettingScope, SettingRow, SettingInput } from './src/core/settings.js';
109
+ export { LookupsAdmin } from './src/core/lookups.js';
110
+ export type { LookupFieldUse, LookupGroupSummary, LookupValue, LookupInput, LookupUpdate, } from './src/core/lookups.js';
111
+ export { SequencesAdmin } from './src/core/sequences.js';
112
+ export type { SequenceRow } from './src/core/sequences.js';
75
113
  export { runtimeHealth, isBackupStale, backupStale, heartbeat, HEARTBEAT_MAX_AGE_MS, BACKUP_MAX_AGE_MS, } from './src/core/health.js';
76
114
  export type { RuntimeHealth, HeartbeatStatus, QueueSnapshot, QueueCounts, FailedJob, } from './src/core/health.js';
77
115
  export { MailDeliveryTest, MAIL_TEST_KEY, type MailTestState } from './src/core/mail_test.js';
78
116
  export { InitialSetup, type SetupCheck } from './src/core/setup.js';
117
+ export { administratorExists, grantInstallAdministrator, resolveInstallAdministrator, } from './src/core/administrators.js';
79
118
  export { ADULA_VERSION } from './src/version.js';
80
119
  export { capabilityCatalog, SERVICES as CAPABILITY_SERVICES, FIELD_TYPES, WORKFLOW_STEPS, } from './src/commands/capabilities.js';
120
+ export { createSyncJobsSchema } from './src/database/schema.js';
121
+ export { defineSyncJob, SyncJobs, SyncJobError, syncErrorCategory, SYNC_DEFAULT_TIMEOUT_MS, } from './src/integrations/sync_jobs.js';
122
+ export type { SyncJobDefinition, SyncJobInput, SyncJobContext, SyncJobSummary, SyncJobsOptions, SyncSaveOptions, SyncRun, SyncRunStatus, SyncTrigger, SyncErrorCategory, SyncStats, SyncLogger, } from './src/integrations/sync_jobs.js';
123
+ export { createNotificationChannelsSchema, createChannelConfirmationsSchema, } from './src/database/schema.js';
124
+ export { NotificationChannels, HttpChannelSettings, ChannelDeliveryError, inAppChannel, mailChannel, httpNotificationChannel, phoneAddress, IN_APP_CHANNEL, MAIL_CHANNEL, CHANNEL_MAX_ATTEMPTS, HTTP_CHANNEL_SETTING_KEY, HTTP_CHANNEL_KINDS, CHANNEL_KIND_LABELS, } from './src/core/notification_channels.js';
125
+ export type { NotificationChannel, ChannelLabel, ChannelMessage, ChannelRecipient, ChannelContext, ChannelDelivery, ChannelPreference, ChannelPreferenceInput, ChannelDispatchResult, HttpChannelOptions, HttpChannelKind, HttpChannelConfig, HttpChannelInput, } from './src/core/notification_channels.js';
126
+ export { isSealedSetting } from './src/core/settings.js';
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { defineResource, columnName } from './src/resource/define_resource.js';
1
+ export { defineResource, columnName, joinTable } from './src/resource/define_resource.js';
2
2
  export { configure } from './configure.js';
3
3
  export { withAdulaDatabase } from './src/database/configure.js';
4
4
  export { createResourceController } from './src/admin/controller.js';
@@ -9,24 +9,44 @@ export { ActorStore } from './src/auth/actor_store.js';
9
9
  export { accessibleBy, authorizationSql, conditionSql } from './src/auth/sql.js';
10
10
  export { ACTOR_ID, resolveActorConditions } from './src/auth/conditions.js';
11
11
  export { ResourceService, canQueryField } from './src/admin/resource_service.js';
12
+ export { EXPORT_ROW_LIMIT } from './src/admin/resource_service.js';
13
+ export { BulkActions, defineBulkActions, BULK_ID_LIMIT } from './src/lists/bulk_actions.js';
14
+ export { Dashboards, defineDashboard } from './src/lists/dashboards.js';
12
15
  export { serialize, writableInput, selectedFields } from './src/admin/contracts.js';
13
16
  export { AdulaError } from './src/admin/errors.js';
14
- export { createCoreSchema, createResourceTable, createAttachmentsSchema, createSavedViewsSchema, createCollaborationSchema, createAssignmentsSchema, createMessagingSchema, createWebhooksSchema, createImportsSchema, createWorkflowSchema, createManagedAssignmentsSchema, createRoleKeysSchema, createNotificationTargetsSchema, createUploadGrantsSchema, createInboundWebhooksSchema, } from './src/database/schema.js';
17
+ export { BASE_LANGUAGE, registerLanguage, registeredLanguages, enabledLanguages, resolveLanguage, languageDirection, translate, localizeText, messageKeyOf, clientMessages, runWithLanguage, currentLanguage, labelText, } from './src/languages/catalog.js';
18
+ export { arabicMessages } from './src/languages/ar.js';
19
+ export { englishMessages } from './src/languages/en.js';
20
+ export { CatalogMessagesProvider, installCatalogMessages } from './src/languages/validation.js';
21
+ export { TwoFactor, normalizeRecoveryCode, RECOVERY_CODE_COUNT, TWO_FACTOR_PERIOD, TWO_FACTOR_DIGITS, TWO_FACTOR_WINDOW, TWO_FACTOR_UNREADABLE, } from './src/auth/two_factor.js';
22
+ export { createCoreSchema, createResourceTable, createAttachmentsSchema, createSavedViewsSchema, createCollaborationSchema, createAssignmentsSchema, createMessagingSchema, createWebhooksSchema, createImportsSchema, createWorkflowSchema, createManagedAssignmentsSchema, createRoleKeysSchema, createNotificationTargetsSchema, createUploadGrantsSchema, createInboundWebhooksSchema, createTwoFactorSchema, createWorkflowDelegationSlaSchema, resourceSchema, alterResourceTable, fieldColumnType, } from './src/database/schema.js';
23
+ export { schemaDrift, resourceAddition, describeDrift } from './src/database/schema_diff.js';
24
+ export { definitionSchema, definitionValidator, resourceValidator, isVisible, applyVisibility, } from './src/resource/definition.js';
25
+ export { FieldValueError, canonicalDecimal, decimalShape, isMultipleAttachment, attachmentLimit, MULTIPLE_ATTACHMENT_LIMIT, MULTIPLE_ATTACHMENT_MAX, } from './src/resource/values.js';
15
26
  export { defineWorkflow, nextStep } from './src/workflows/define_workflow.js';
16
- export { WorkflowEngine, workflowListeners } from './src/workflows/engine.js';
27
+ export { WorkflowEngine, workflowListeners, slaState } from './src/workflows/engine.js';
28
+ export { WorkflowDelegations } from './src/workflows/delegations.js';
17
29
  export { ImportBatches, importCell, IMPORT_ROW_LIMIT } from './src/integrations/imports.js';
30
+ export { csvImportAdapter, importFile } from './src/integrations/import_adapters.js';
31
+ export { createImportModesSchema, createImportLeasesSchema } from './src/database/schema.js';
18
32
  export { openApiDocument } from './src/integrations/openapi.js';
19
- export { renderPrintHtml, htmlToPdf } from './src/integrations/print.js';
33
+ export { apiClientSource, apiClientDeclarations } from './src/integrations/api_client.js';
34
+ export { renderPrintHtml, htmlToPdf, imageDataUri, PRINT_LOGO_LIMIT, } from './src/integrations/print.js';
35
+ export { PrintTemplates, DEFAULT_PRINT_TEMPLATE, PRINT_HELPERS, PRINT_PAPERS, PRINT_ORIENTATIONS, codeTemplateVersion, renderTemplateDocument, printableGroups, PRINT_LINE_LIMIT, } from './src/integrations/print_templates.js';
36
+ export { sanitizePrintHtml } from './src/core/html_sanitizer.js';
37
+ export { parseTemplate } from './src/core/template_language.js';
38
+ export { createPrintTemplatesSchema } from './src/database/schema.js';
20
39
  export { Webhooks, signWebhook, WEBHOOK_MAX_ATTEMPTS } from './src/integrations/webhooks.js';
40
+ export { createOutboundPoster, isBlockedAddress, outboundErrorCategory, } from './src/integrations/outbound.js';
21
41
  export { InboundWebhooks, inboundEventName, INBOUND_BODY_LIMIT, INBOUND_RETENTION_DAYS, } from './src/integrations/inbound_webhooks.js';
22
42
  export { MessageTemplates, DEFAULT_TEMPLATES, renderTemplate, notifyWithTemplate, deliverNotificationMail, listenForNotifications, } from './src/core/message_templates.js';
23
43
  export { Assignments } from './src/collaboration/assignments.js';
24
44
  export { RecordCollaboration, followerListeners } from './src/collaboration/record_collaboration.js';
25
- export { registerUpload, findAttachment, loadAttachments, claimAttachment, releaseAttachment, summarizeAttachment, attachmentUrl, isAttachmentId, isRelativeDiskPath, attachmentPolicy, pendingUploadCount, staleUploads, forgetUpload, DEFAULT_ATTACHMENT_EXTENSIONS, PENDING_UPLOAD_LIMIT, UNBOUND_UPLOAD_TTL_MS, } from './src/attachments/attachment_service.js';
45
+ export { registerUpload, findAttachment, loadAttachments, claimAttachment, releaseAttachment, summarizeAttachment, attachmentUrl, isAttachmentId, isRelativeDiskPath, attachmentPolicy, attachmentPreview, attachmentHeaders, pendingUploadCount, staleUploads, forgetUpload, DEFAULT_ATTACHMENT_EXTENSIONS, PENDING_UPLOAD_LIMIT, UNBOUND_UPLOAD_TTL_MS, } from './src/attachments/attachment_service.js';
26
46
  export { grantUpload, redeemUploadGrant, pruneUploadGrants, UPLOAD_GRANT_MAX_TTL_MS, } from './src/attachments/upload_grants.js';
27
47
  export { migrateStorage } from './src/attachments/storage_migrate.js';
28
48
  export { diagnoseAttachments } from './src/attachments/doctor.js';
29
- export { Settings, sequence, notify } from './src/services/settings.js';
49
+ export { Settings, sequence, formatSequence, notify } from './src/services/settings.js';
30
50
  export { uiPreferences, validateUiPreferences, UI_PREFERENCES_KEY, DEFAULT_UI_PREFERENCES, } from './src/core/ui_preferences.js';
31
51
  export { moveOrgUnit } from './src/org/org_service.js';
32
52
  export { publishOutbox, consumeEvent } from './src/events/outbox.js';
@@ -42,8 +62,16 @@ export { OrgUnitsAdmin } from './src/core/org_units.js';
42
62
  export { SavedViews } from './src/core/saved_views.js';
43
63
  export { NotificationsAdmin } from './src/core/notifications.js';
44
64
  export { SettingsAdmin, isProtectedSetting, parseSettingValue, SETTING_SCOPES, PROTECTED_SETTING_KEYS, } from './src/core/settings.js';
65
+ export { LookupsAdmin } from './src/core/lookups.js';
66
+ export { SequencesAdmin } from './src/core/sequences.js';
45
67
  export { runtimeHealth, isBackupStale, backupStale, heartbeat, HEARTBEAT_MAX_AGE_MS, BACKUP_MAX_AGE_MS, } from './src/core/health.js';
46
68
  export { MailDeliveryTest, MAIL_TEST_KEY } from './src/core/mail_test.js';
47
69
  export { InitialSetup } from './src/core/setup.js';
70
+ export { administratorExists, grantInstallAdministrator, resolveInstallAdministrator, } from './src/core/administrators.js';
48
71
  export { ADULA_VERSION } from './src/version.js';
49
72
  export { capabilityCatalog, SERVICES as CAPABILITY_SERVICES, FIELD_TYPES, WORKFLOW_STEPS, } from './src/commands/capabilities.js';
73
+ export { createSyncJobsSchema } from './src/database/schema.js';
74
+ export { defineSyncJob, SyncJobs, SyncJobError, syncErrorCategory, SYNC_DEFAULT_TIMEOUT_MS, } from './src/integrations/sync_jobs.js';
75
+ export { createNotificationChannelsSchema, createChannelConfirmationsSchema, } from './src/database/schema.js';
76
+ export { NotificationChannels, HttpChannelSettings, ChannelDeliveryError, inAppChannel, mailChannel, httpNotificationChannel, phoneAddress, IN_APP_CHANNEL, MAIL_CHANNEL, CHANNEL_MAX_ATTEMPTS, HTTP_CHANNEL_SETTING_KEY, HTTP_CHANNEL_KINDS, CHANNEL_KIND_LABELS, } from './src/core/notification_channels.js';
77
+ export { isSealedSetting } from './src/core/settings.js';
@@ -3,4 +3,6 @@ export default class AdulaProvider {
3
3
  protected app: ApplicationService;
4
4
  constructor(app: ApplicationService);
5
5
  register(): void;
6
+ /** DATE columns stay calendar days in every time zone (see keepCalendarDays). */
7
+ boot(): Promise<void>;
6
8
  }
@@ -1,4 +1,5 @@
1
1
  import { ResourceRegistry } from '../src/resource/registry.js';
2
+ import { keepCalendarDays } from '../src/database/calendar_days.js';
2
3
  export default class AdulaProvider {
3
4
  app;
4
5
  constructor(app) {
@@ -7,4 +8,10 @@ export default class AdulaProvider {
7
8
  register() {
8
9
  this.app.container.singleton(ResourceRegistry, () => new ResourceRegistry());
9
10
  }
11
+ /** DATE columns stay calendar days in every time zone (see keepCalendarDays). */
12
+ async boot() {
13
+ if (!this.app.container.hasBinding('lucid.db'))
14
+ return;
15
+ keepCalendarDays((await this.app.container.make('lucid.db')));
16
+ }
10
17
  }
@@ -17,7 +17,7 @@ export function selectedFields(resource, ability, options = {}) {
17
17
  ...(options.extra ?? []),
18
18
  ...conditionFields(ability, resource),
19
19
  ]),
20
- ].filter((key) => key !== 'orgPath' && resource.fields[key]?.type !== 'hasMany');
20
+ ].filter((key) => key !== 'orgPath' && !['hasMany', 'manyToMany'].includes(resource.fields[key]?.type ?? ''));
21
21
  }
22
22
  const rowKeys = new WeakMap();
23
23
  /** Record keys and their columns for a resource, computed once per definition. */
@@ -3,10 +3,13 @@ import type { Actor } from '../auth/ability.js';
3
3
  import type { ResourceRegistry } from '../resource/registry.js';
4
4
  import type { Resource } from '../resource/types.js';
5
5
  import type { ResourceService } from './resource_service.js';
6
+ import { BulkActions } from '../lists/bulk_actions.js';
6
7
  export type ResourceRuntime = {
7
8
  registry: ResourceRegistry;
8
9
  resources: ResourceService;
9
10
  actor: Actor;
11
+ /** Bulk actions with the application's definitions; built-in actions only when absent. */
12
+ bulk?: BulkActions;
10
13
  };
11
14
  export type ResourceList = Awaited<ReturnType<ResourceService['list']>>;
12
15
  export type ResourceEditor = Awaited<ReturnType<ResourceService['editor']>>;
@@ -27,6 +30,16 @@ export interface ResourceController {
27
30
  edit(ctx: HttpContext): Promise<unknown>;
28
31
  options(ctx: HttpContext): Promise<unknown>;
29
32
  aggregate(ctx: HttpContext): Promise<unknown>;
33
+ /** GET …/export: the filtered list as CSV (ADR 046). */
34
+ export(ctx: HttpContext): Promise<unknown>;
35
+ /** GET …/trash: soft-deleted records for actors who may delete (ADR 046). */
36
+ trash(ctx: HttpContext): Promise<unknown>;
37
+ /** POST …/:id/restore */
38
+ restore(ctx: HttpContext): Promise<unknown>;
39
+ /** GET …/bulk: the bulk actions the actor may offer. */
40
+ bulkActions(ctx: HttpContext): Promise<unknown>;
41
+ /** POST …/bulk: { action, ids, versions? } → { data: { succeeded, failed } }. */
42
+ bulk(ctx: HttpContext): Promise<unknown>;
30
43
  }
31
44
  /** The host supplies its authenticated actor; ResourceService authorizes every action. */
32
- export declare function createResourceController(resolveRuntime: (ctx: HttpContext) => Promise<ResourceRuntime>, renderList?: (ctx: HttpContext, resource: Resource, result: ResourceList) => unknown, renderForm?: (ctx: HttpContext, resource: Resource, editor: ResourceEditor) => unknown, renderShow?: (ctx: HttpContext, resource: Resource, result: ResourceShow) => unknown): new () => ResourceController;
45
+ export declare function createResourceController(resolveRuntime: (ctx: HttpContext) => Promise<ResourceRuntime>, renderList?: (ctx: HttpContext, resource: Resource, result: ResourceList) => unknown, renderForm?: (ctx: HttpContext, resource: Resource, editor: ResourceEditor) => unknown, renderShow?: (ctx: HttpContext, resource: Resource, result: ResourceShow) => unknown, renderTrash?: (ctx: HttpContext, resource: Resource, result: ResourceList) => unknown): new () => ResourceController;
@@ -1,6 +1,8 @@
1
1
  import { AdulaError } from './errors.js';
2
+ import { translate } from '../languages/catalog.js';
3
+ import { BulkActions } from '../lists/bulk_actions.js';
2
4
  /** The host supplies its authenticated actor; ResourceService authorizes every action. */
3
- export function createResourceController(resolveRuntime, renderList, renderForm, renderShow) {
5
+ export function createResourceController(resolveRuntime, renderList, renderForm, renderShow, renderTrash) {
4
6
  return class ResourcesController {
5
7
  async create(ctx) {
6
8
  return this.#execute(ctx, async ({ resources, actor }, resource) => {
@@ -26,21 +28,74 @@ export function createResourceController(resolveRuntime, renderList, renderForm,
26
28
  }
27
29
  async index(ctx) {
28
30
  return this.#execute(ctx, async ({ resources, actor }, resource) => {
29
- const result = await resources.list(resource.name, actor, {
30
- limit: ctx.request.input('limit'),
31
- cursor: ctx.request.input('cursor'),
32
- search: ctx.request.input('search'),
33
- sort: ctx.request.input('sort'),
34
- direction: ctx.request.input('direction'),
35
- filters: ctx.request.input('filters'),
36
- tag: ctx.request.input('tag'),
37
- estimate: ctx.request.input('estimate') !== 'false' && ctx.request.input('estimate') !== false,
38
- });
31
+ const result = await resources.list(resource.name, actor, this.#listOptions(ctx));
39
32
  return renderList && ctx.request.accepts(['html', 'json']) === 'html'
40
33
  ? renderList(ctx, resource, result)
41
34
  : result;
42
35
  });
43
36
  }
37
+ async trash(ctx) {
38
+ return this.#execute(ctx, async ({ resources, actor }, resource) => {
39
+ const result = await resources.list(resource.name, actor, {
40
+ ...this.#listOptions(ctx),
41
+ trashed: true,
42
+ });
43
+ return renderTrash && ctx.request.accepts(['html', 'json']) === 'html'
44
+ ? renderTrash(ctx, resource, result)
45
+ : result;
46
+ });
47
+ }
48
+ async export(ctx) {
49
+ return this.#execute(ctx, async ({ resources, actor }, resource) => {
50
+ const { search, sort, direction, filters, tag } = this.#listOptions(ctx);
51
+ const file = await resources.export(resource.name, actor, {
52
+ search,
53
+ sort,
54
+ direction,
55
+ filters,
56
+ tag,
57
+ trashed: ctx.request.input('trashed') === 'true' || ctx.request.input('trashed') === true,
58
+ });
59
+ ctx.response.header('Content-Type', 'text/csv; charset=utf-8');
60
+ ctx.response.header('Content-Disposition', `attachment; filename="${file.asciiFilename}"; filename*=UTF-8''${rfc5987(file.filename)}`);
61
+ ctx.response.header('Cache-Control', 'no-store');
62
+ ctx.response.send(file.content);
63
+ });
64
+ }
65
+ async restore(ctx) {
66
+ return this.#execute(ctx, async ({ resources, actor }, resource) => ({
67
+ data: await resources.restore(resource.name, this.#id(ctx), actor),
68
+ }));
69
+ }
70
+ async bulkActions(ctx) {
71
+ return this.#execute(ctx, async (runtime, resource) => ({
72
+ data: this.#bulk(runtime).available(resource.name, runtime.actor),
73
+ }));
74
+ }
75
+ async bulk(ctx) {
76
+ return this.#execute(ctx, async (runtime, resource) => ({
77
+ data: await this.#bulk(runtime).run(resource.name, runtime.actor, {
78
+ action: ctx.request.input('action'),
79
+ ids: ctx.request.input('ids'),
80
+ versions: ctx.request.input('versions'),
81
+ }),
82
+ }));
83
+ }
84
+ #bulk(runtime) {
85
+ return runtime.bulk ?? new BulkActions(runtime.registry, runtime.resources);
86
+ }
87
+ #listOptions(ctx) {
88
+ return {
89
+ limit: ctx.request.input('limit'),
90
+ cursor: ctx.request.input('cursor'),
91
+ search: ctx.request.input('search'),
92
+ sort: ctx.request.input('sort'),
93
+ direction: ctx.request.input('direction'),
94
+ filters: ctx.request.input('filters'),
95
+ tag: ctx.request.input('tag'),
96
+ estimate: ctx.request.input('estimate') !== 'false' && ctx.request.input('estimate') !== false,
97
+ };
98
+ }
44
99
  async show(ctx) {
45
100
  return this.#execute(ctx, async ({ resources, actor }, resource) => {
46
101
  const result = await resources.show(resource.name, this.#id(ctx), actor);
@@ -154,14 +209,23 @@ export function createResourceController(resolveRuntime, renderList, renderForm,
154
209
  .send({ error: { code: error.code, message: error.message } });
155
210
  if (error?.code === '23505')
156
211
  return ctx.response.conflict({
157
- error: { code: 'E_DUPLICATE', message: 'هذه القيمة مستخدمة في سجل آخر' },
212
+ error: { code: 'E_DUPLICATE', message: translate('errors.E_DUPLICATE') },
213
+ });
214
+ // A NOT NULL column the definition lets be empty (see adula:resource:migration).
215
+ if (error?.code === '23502')
216
+ return ctx.response.unprocessableEntity({
217
+ error: { code: 'E_NOT_NULL', message: translate('errors.E_NOT_NULL') },
158
218
  });
159
219
  if (error?.code === '23503')
160
220
  return ctx.response.unprocessableEntity({
161
- error: { code: 'E_RELATION', message: 'تحقق من السجلات المرتبطة' },
221
+ error: { code: 'E_RELATION', message: translate('errors.E_RELATION') },
162
222
  });
163
223
  throw error;
164
224
  }
165
225
  }
166
226
  };
167
227
  }
228
+ /** RFC 5987 ext-value encoding of a UTF-8 file name. */
229
+ function rfc5987(value) {
230
+ return encodeURIComponent(value).replace(/['()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
231
+ }
@@ -1,5 +1,37 @@
1
+ /**
2
+ * A refusal the caller can act on. The message is Arabic text from the catalog
3
+ * (src/languages/ar.ts); inside a request running in another language (see
4
+ * runWithLanguage) it is translated when that language translates the text, so a
5
+ * response, flash or MCP answer built from `message` is already localized.
6
+ */
1
7
  export declare class AdulaError extends Error {
2
8
  status: number;
3
9
  code: string;
10
+ /** The catalog key of the Arabic message, when the catalog defines it. */
11
+ readonly messageKey?: string;
4
12
  constructor(status: number, code: string, message: string);
5
13
  }
14
+ /** 403 E_FORBIDDEN: the actor may not perform the action. */
15
+ export declare function forbiddenAction(): AdulaError;
16
+ /** 404 E_NOT_FOUND: a record (by default) or another target outside the actor's reach. */
17
+ export declare function notFound(message?: string): AdulaError;
18
+ /** 403 E_FIELD_FORBIDDEN: a field the actor may not read, query or write. */
19
+ export declare function forbiddenField(message: string): AdulaError;
20
+ /** 422 E_FILTER: an unsupported or invalid filter. */
21
+ export declare function invalidFilter(message: string): AdulaError;
22
+ /** 403 E_SEARCH: full-text search is not available to the actor. */
23
+ export declare function searchUnavailable(): AdulaError;
24
+ /** 422 E_CURSOR: a malformed or mismatched pagination cursor. */
25
+ export declare function invalidCursor(): AdulaError;
26
+ /** 409 E_DOCUMENT_LOCKED: a submitted or cancelled document cannot change this way. */
27
+ export declare function documentLocked(message?: string): AdulaError;
28
+ /** 409 E_DOCUMENT_STATE: the document is not in a state that allows the transition. */
29
+ export declare function invalidDocumentState(message: string): AdulaError;
30
+ /** 422 E_REQUIRED: a required field has no value. */
31
+ export declare function requiredField(key: string): AdulaError;
32
+ /** 422 E_ACTOR: a system write without the author it needs. */
33
+ export declare function missingActor(message: string): AdulaError;
34
+ /** 422 E_INLINE: malformed inline rows. */
35
+ export declare function invalidInline(message: string): AdulaError;
36
+ /** 422 E_INLINE_SCOPE: inline rows and their parent must share one organization unit. */
37
+ export declare function inlineScope(message: string): AdulaError;
@@ -1,9 +1,71 @@
1
+ import { localizeText, messageKeyOf } from '../languages/catalog.js';
2
+ /**
3
+ * A refusal the caller can act on. The message is Arabic text from the catalog
4
+ * (src/languages/ar.ts); inside a request running in another language (see
5
+ * runWithLanguage) it is translated when that language translates the text, so a
6
+ * response, flash or MCP answer built from `message` is already localized.
7
+ */
1
8
  export class AdulaError extends Error {
2
9
  status;
3
10
  code;
11
+ /** The catalog key of the Arabic message, when the catalog defines it. */
12
+ messageKey;
4
13
  constructor(status, code, message) {
5
- super(message);
14
+ super(localizeText(message));
6
15
  this.status = status;
7
16
  this.code = code;
17
+ this.messageKey = messageKeyOf(message);
8
18
  }
9
19
  }
20
+ /*
21
+ * Named constructors for errors that recur across the resource service. Each keeps the
22
+ * exact status, code and message of the sites it replaced; clients and tests rely on them.
23
+ */
24
+ /** 403 E_FORBIDDEN: the actor may not perform the action. */
25
+ export function forbiddenAction() {
26
+ return new AdulaError(403, 'E_FORBIDDEN', 'ليس لديك صلاحية لهذا الإجراء');
27
+ }
28
+ /** 404 E_NOT_FOUND: a record (by default) or another target outside the actor's reach. */
29
+ export function notFound(message = 'السجل غير موجود') {
30
+ return new AdulaError(404, 'E_NOT_FOUND', message);
31
+ }
32
+ /** 403 E_FIELD_FORBIDDEN: a field the actor may not read, query or write. */
33
+ export function forbiddenField(message) {
34
+ return new AdulaError(403, 'E_FIELD_FORBIDDEN', message);
35
+ }
36
+ /** 422 E_FILTER: an unsupported or invalid filter. */
37
+ export function invalidFilter(message) {
38
+ return new AdulaError(422, 'E_FILTER', message);
39
+ }
40
+ /** 403 E_SEARCH: full-text search is not available to the actor. */
41
+ export function searchUnavailable() {
42
+ return new AdulaError(403, 'E_SEARCH', 'Search is unavailable');
43
+ }
44
+ /** 422 E_CURSOR: a malformed or mismatched pagination cursor. */
45
+ export function invalidCursor() {
46
+ return new AdulaError(422, 'E_CURSOR', 'Invalid cursor');
47
+ }
48
+ /** 409 E_DOCUMENT_LOCKED: a submitted or cancelled document cannot change this way. */
49
+ export function documentLocked(message = 'Only draft documents can be edited') {
50
+ return new AdulaError(409, 'E_DOCUMENT_LOCKED', message);
51
+ }
52
+ /** 409 E_DOCUMENT_STATE: the document is not in a state that allows the transition. */
53
+ export function invalidDocumentState(message) {
54
+ return new AdulaError(409, 'E_DOCUMENT_STATE', message);
55
+ }
56
+ /** 422 E_REQUIRED: a required field has no value. */
57
+ export function requiredField(key) {
58
+ return new AdulaError(422, 'E_REQUIRED', `Required field: ${key}`);
59
+ }
60
+ /** 422 E_ACTOR: a system write without the author it needs. */
61
+ export function missingActor(message) {
62
+ return new AdulaError(422, 'E_ACTOR', message);
63
+ }
64
+ /** 422 E_INLINE: malformed inline rows. */
65
+ export function invalidInline(message) {
66
+ return new AdulaError(422, 'E_INLINE', message);
67
+ }
68
+ /** 422 E_INLINE_SCOPE: inline rows and their parent must share one organization unit. */
69
+ export function inlineScope(message) {
70
+ return new AdulaError(422, 'E_INLINE_SCOPE', message);
71
+ }
@@ -1,8 +1,9 @@
1
- import type { Action, Field } from '../resource/types.js';
1
+ import type { Action, Field, Label } from '../resource/types.js';
2
2
  export type ResourceField = Field & {
3
3
  key: string;
4
4
  };
5
- export type RecordPermissions = Partial<Record<Action, boolean>>;
5
+ /** Per-record permissions; `restore` appears on rows of a trashed list (ADR 046). */
6
+ export type RecordPermissions = Partial<Record<Action | 'restore', boolean>>;
6
7
  export type ResourceDescription = {
7
8
  name: string;
8
9
  label: string;
@@ -17,6 +18,24 @@ export type ResourceDescription = {
17
18
  canCreate: boolean;
18
19
  scoped: boolean;
19
20
  submittable: boolean;
21
+ /**
22
+ * Whether the actor may open «المحذوفات» (the trashed list) and restore records: the
23
+ * resource offers delete and the actor holds it (ADR 046). Optional for compatibility
24
+ * with descriptions built by older code.
25
+ */
26
+ trash?: boolean;
27
+ /** The list can be exported as CSV through GET …/export (ADR 046). */
28
+ exportable?: boolean;
29
+ /** Whether GET …/bulk may offer any action to this actor; the list decides each action. */
30
+ bulk?: boolean;
31
+ /**
32
+ * Print templates declared in code (ADR 048); present only when the resource has some.
33
+ * GET …/print-templates also lists administrator templates.
34
+ */
35
+ printTemplates?: {
36
+ key: string;
37
+ label: Label;
38
+ }[];
20
39
  };
21
40
  export type ResourceNavigation = {
22
41
  name: string;