adula 2.1.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 +4 -2
  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
@@ -1,10 +1,111 @@
1
1
  import type { Knex } from 'knex';
2
- import type { Resource } from '../resource/types.js';
2
+ import type { Field, Resource, Scalar } from '../resource/types.js';
3
3
  export declare function createCoreSchema(db: Knex): Promise<void>;
4
4
  /** Attachment metadata lives in one table so ownership, restore drills and disk moves see every file. */
5
5
  export declare function createAttachmentsSchema(db: Knex): Promise<void>;
6
6
  export declare function createSavedViewsSchema(db: Knex): Promise<void>;
7
- export declare function createResourceTable(db: Knex, resource: Pick<Resource, 'name' | 'scoped' | 'version' | 'submittable' | 'customFields' | 'fields'>): Promise<void>;
7
+ /** The definition parts that decide a resource table (what create-migrations embed). */
8
+ export type ResourceTableDefinition = Pick<Resource, 'name' | 'scoped' | 'version' | 'submittable' | 'fields'> & {
9
+ unique?: readonly (readonly string[])[];
10
+ };
11
+ /** One column of a resource table; `type` is PostgreSQL's format_type() spelling. */
12
+ export type ResourceColumn = {
13
+ name: string;
14
+ type: string;
15
+ nullable: boolean;
16
+ /** The column default of a field `default` (scalar types only). */
17
+ default?: Scalar;
18
+ /** The referenced table of a foreign key. */
19
+ references?: string;
20
+ /** The field key, or null for a standard column. */
21
+ field: string | null;
22
+ };
23
+ /**
24
+ * A partial unique index over these columns: over live rows (`WHERE deleted_at IS NULL`)
25
+ * and, on a submittable resource, also excluding cancelled documents
26
+ * (`AND doc_status <> 2`) so an amended copy may keep the values of its original.
27
+ */
28
+ export type ResourceUniqueIndex = {
29
+ name: string;
30
+ columns: string[];
31
+ fields: string[];
32
+ /** The predicate also excludes cancelled documents (submittable resources). */
33
+ excludeCancelled: boolean;
34
+ };
35
+ /** The join table of one manyToMany field. */
36
+ export type ResourceJoinTable = {
37
+ table: string;
38
+ field: string;
39
+ /** Column referencing the owner table. */
40
+ owner: string;
41
+ /** Column referencing the target table. */
42
+ target: string;
43
+ resource: string;
44
+ };
45
+ /** The table shape a definition expects; see resourceSchema(). */
46
+ export type ResourceSchema = {
47
+ table: string;
48
+ columns: ResourceColumn[];
49
+ unique: ResourceUniqueIndex[];
50
+ joinTables: ResourceJoinTable[];
51
+ /** Columns of the generated search_vector, in order. */
52
+ searchable: string[];
53
+ };
54
+ /** The column type of one stored field (format_type() spelling), or null when it has none. */
55
+ export declare function fieldColumnType(field: Field): string | null;
56
+ /**
57
+ * The table a definition expects: standard and field columns with their types,
58
+ * nullability and defaults, the partial unique indexes (single fields and the
59
+ * resource's composite `unique`) and the join tables of manyToMany fields.
60
+ * createResourceTable builds it and the `resources.schema` doctor check compares it
61
+ * with the live database.
62
+ */
63
+ export declare function resourceSchema(resource: ResourceTableDefinition): ResourceSchema;
64
+ export declare function createResourceTable(db: Knex, resource: ResourceTableDefinition & {
65
+ /**
66
+ * @deprecated The `customFields` resource flag was removed. Kept only so create-migrations
67
+ * generated before the removal still compile and replay unchanged on a new database
68
+ * (migrations are immutable); new definitions cannot set it (`defineResource` refuses it).
69
+ */
70
+ customFields?: boolean;
71
+ }): Promise<void>;
72
+ /**
73
+ * What an additive resource migration changes on an existing table: new field columns
74
+ * (and the join tables of new manyToMany fields), embedded as definition snapshots,
75
+ * partial unique indexes by column name, and two relaxing changes: NOT NULL dropped from
76
+ * columns the definition now lets be empty, and unique indexes recreated so cancelled
77
+ * documents no longer count. Generated by `node ace adula:resource:migration`.
78
+ */
79
+ export type ResourceAddition = {
80
+ fields?: Record<string, Field>;
81
+ /** Unique indexes over live rows, each a list of column names. */
82
+ unique?: readonly (readonly string[])[];
83
+ /**
84
+ * Columns whose NOT NULL constraint is dropped, for example after `visibleWhen` was
85
+ * added to a required field (a hidden field stores null). Only relaxes: NOT NULL is
86
+ * never added automatically.
87
+ */
88
+ dropNotNull?: readonly string[];
89
+ /**
90
+ * Unique indexes of a submittable table that still count cancelled documents: each is
91
+ * dropped by name and created again over live rows that are not cancelled, so an
92
+ * amended copy can keep the values of its cancelled original. Only relaxes.
93
+ */
94
+ recreateUnique?: readonly {
95
+ index: string;
96
+ columns: readonly string[];
97
+ }[];
98
+ };
99
+ /**
100
+ * Applies a ResourceAddition: drops NOT NULL from the named columns, adds the columns
101
+ * (NOT NULL only with a default, since the table may hold rows), creates join tables,
102
+ * recreates the named unique indexes with the cancelled-document predicate and creates
103
+ * the new unique indexes (excluding cancelled documents on a submittable table). It never
104
+ * tightens a constraint or drops data, so released migrations replay unchanged. The
105
+ * generated search_vector is not changed: making a field searchable needs a hand-written
106
+ * migration.
107
+ */
108
+ export declare function alterResourceTable(db: Knex, name: string, addition: ResourceAddition): Promise<void>;
8
109
  /** Record collaboration (phase 3): comments with mentions, followers, tags and field history. */
9
110
  export declare function createCollaborationSchema(db: Knex): Promise<void>;
10
111
  /** Work assigned to a user on a record; approval steps of workflows reuse it (phase 4). */
@@ -50,3 +151,55 @@ export declare function createUploadGrantsSchema(db: Knex): Promise<void>;
50
151
  * dispatched as domain events through the outbox.
51
152
  */
52
153
  export declare function createInboundWebhooksSchema(db: Knex): Promise<void>;
154
+ /**
155
+ * TOTP two-factor authentication (2.2): one row per user with the sealed secret and
156
+ * the last accepted time step (replay guard), and one row per recovery code so a
157
+ * code is consumed atomically. Codes are stored as SHA-256 over a per-code salt.
158
+ */
159
+ export declare function createTwoFactorSchema(db: Knex): Promise<void>;
160
+ /**
161
+ * Import modes: upsert by a unique field, dry-run validation and its per-row report.
162
+ * `updated` counts rows an upsert changed; `report` holds the dry run's row outcomes.
163
+ */
164
+ export declare function createImportModesSchema(db: Knex): Promise<void>;
165
+ /**
166
+ * Background synchronization runs (sync_jobs.ts): one row per queued, running or
167
+ * finished run. The partial unique index allows one open (queued or running) run per job.
168
+ */
169
+ export declare function createSyncJobsSchema(db: Knex): Promise<void>;
170
+ /**
171
+ * Notification channels (2.x): per-user channel preferences (e-mail opt-out, the
172
+ * address of an HTTP provider channel such as SMS or WhatsApp) and the delivery state
173
+ * of channels other than in-app and e-mail, which keeps its notifications.mail_state.
174
+ * Only error categories are stored, never provider response bodies.
175
+ */
176
+ export declare function createNotificationChannelsSchema(db: Knex): Promise<void>;
177
+ /**
178
+ * Confirmation of a notification channel address (2.x): a one-time code sent to the
179
+ * number before the channel can be enabled with it. One row per user and channel, the
180
+ * code stored as SHA-256 over a per-code salt and void after five wrong attempts; the
181
+ * row also counts codes sent in a 24-hour window. Preferences record when their number
182
+ * was confirmed; a number without confirmed_at never receives messages.
183
+ */
184
+ export declare function createChannelConfirmationsSchema(db: Knex): Promise<void>;
185
+ /**
186
+ * Import worker leases: a claimed batch belongs to one worker until lease_expires_at;
187
+ * every progress write names lease_id, so a worker whose lease was taken over writes nothing.
188
+ */
189
+ export declare function createImportLeasesSchema(db: Knex): Promise<void>;
190
+ /**
191
+ * Approval delegation and SLA deadlines (ADR 044). A delegation routes a user's new
192
+ * approvals to a delegate for a date range and lets the delegate act on the user's
193
+ * pending ones; overlap is refused by WorkflowDelegations under a row lock. Approval
194
+ * assignments gain a deadline, the delegation they were routed through and the SLA
195
+ * markers; workflow_escalations records each reminder and escalation once.
196
+ */
197
+ export declare function createWorkflowDelegationSlaSchema(db: Knex): Promise<void>;
198
+ /**
199
+ * Administrator print templates (ADR 048). A template row points to its current
200
+ * version; versions are immutable (a trigger refuses UPDATE and DELETE, except clearing
201
+ * created_by when the author is deleted), so a printed
202
+ * document's recorded version always resolves to the markup that produced it.
203
+ * Templates are deployment-wide, like message_templates.
204
+ */
205
+ export declare function createPrintTemplatesSchema(db: Knex): Promise<void>;