adula 0.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/LICENSE.md +10 -0
  2. package/README.md +38 -2
  3. package/build/agent/AGENTS.template.md +28 -0
  4. package/build/agent/capabilities.md +60 -0
  5. package/build/agent/skills/adula-frontend-design/SKILL.md +59 -0
  6. package/build/agent/skills/idea-review/SKILL.md +31 -0
  7. package/build/agent/skills/module-review/SKILL.md +22 -0
  8. package/build/agent/skills/perf-review/SKILL.md +24 -0
  9. package/build/agent/skills/schema-review/SKILL.md +22 -0
  10. package/build/agent/skills/security-review/SKILL.md +24 -0
  11. package/build/agent/skills/ui-review/SKILL.md +22 -0
  12. package/build/commands/capabilities.d.ts +10 -0
  13. package/build/commands/capabilities.js +40 -0
  14. package/build/commands/doctor.d.ts +9 -0
  15. package/build/commands/doctor.js +72 -0
  16. package/build/commands/gaps.d.ts +12 -0
  17. package/build/commands/gaps.js +62 -0
  18. package/build/commands/install.d.ts +9 -0
  19. package/build/commands/install.js +105 -0
  20. package/build/commands/main.d.ts +8 -0
  21. package/build/commands/main.js +33 -0
  22. package/build/commands/module_add.d.ts +8 -0
  23. package/build/commands/module_add.js +57 -0
  24. package/build/commands/module_remove.d.ts +10 -0
  25. package/build/commands/module_remove.js +94 -0
  26. package/build/commands/resource.d.ts +8 -0
  27. package/build/commands/resource.js +29 -0
  28. package/build/commands/resource_snapshot.d.ts +15 -0
  29. package/build/commands/resource_snapshot.js +61 -0
  30. package/build/commands/storage_migrate.d.ts +12 -0
  31. package/build/commands/storage_migrate.js +39 -0
  32. package/build/commands/ui.d.ts +11 -0
  33. package/build/commands/ui.js +210 -0
  34. package/build/commands/upgrade.d.ts +15 -0
  35. package/build/commands/upgrade.js +34 -0
  36. package/build/configure.d.ts +2 -0
  37. package/build/configure.js +79 -0
  38. package/build/database/migrations/1770000000000_core.d.ts +5 -0
  39. package/build/database/migrations/1770000000000_core.js +10 -0
  40. package/build/database/migrations/1770000000001_attachments.d.ts +5 -0
  41. package/build/database/migrations/1770000000001_attachments.js +10 -0
  42. package/build/database/migrations/1770000000002_saved_views.d.ts +5 -0
  43. package/build/database/migrations/1770000000002_saved_views.js +10 -0
  44. package/build/database/migrations/1770000000003_user_invitations.d.ts +5 -0
  45. package/build/database/migrations/1770000000003_user_invitations.js +18 -0
  46. package/build/database/migrations/1770000000004_collaboration.d.ts +5 -0
  47. package/build/database/migrations/1770000000004_collaboration.js +10 -0
  48. package/build/database/migrations/1770000000005_assignments.d.ts +5 -0
  49. package/build/database/migrations/1770000000005_assignments.js +10 -0
  50. package/build/database/migrations/1770000000006_messaging.d.ts +5 -0
  51. package/build/database/migrations/1770000000006_messaging.js +10 -0
  52. package/build/database/migrations/1770000000007_webhooks.d.ts +5 -0
  53. package/build/database/migrations/1770000000007_webhooks.js +10 -0
  54. package/build/database/migrations/1770000000008_imports.d.ts +5 -0
  55. package/build/database/migrations/1770000000008_imports.js +10 -0
  56. package/build/database/migrations/1770000000010_workflows.d.ts +5 -0
  57. package/build/database/migrations/1770000000010_workflows.js +10 -0
  58. package/build/database/migrations/1770000000011_managed_assignments.d.ts +5 -0
  59. package/build/database/migrations/1770000000011_managed_assignments.js +10 -0
  60. package/build/database/migrations/1770000000012_role_keys.d.ts +5 -0
  61. package/build/database/migrations/1770000000012_role_keys.js +10 -0
  62. package/build/database/migrations/1770000000013_notification_targets.d.ts +5 -0
  63. package/build/database/migrations/1770000000013_notification_targets.js +10 -0
  64. package/build/database/migrations/1770000000014_upload_grants.d.ts +5 -0
  65. package/build/database/migrations/1770000000014_upload_grants.js +10 -0
  66. package/build/database/migrations/1770000000015_inbound_webhooks.d.ts +5 -0
  67. package/build/database/migrations/1770000000015_inbound_webhooks.js +10 -0
  68. package/build/database/migrations/1770000000016_adulajs_names.d.ts +6 -0
  69. package/build/database/migrations/1770000000016_adulajs_names.js +11 -0
  70. package/build/index.d.ts +80 -0
  71. package/build/index.js +49 -0
  72. package/build/providers/adula_provider.d.ts +6 -0
  73. package/build/providers/adula_provider.js +10 -0
  74. package/build/src/admin/contracts.d.ts +19 -0
  75. package/build/src/admin/contracts.js +115 -0
  76. package/build/src/admin/controller.d.ts +32 -0
  77. package/build/src/admin/controller.js +167 -0
  78. package/build/src/admin/errors.d.ts +5 -0
  79. package/build/src/admin/errors.js +9 -0
  80. package/build/src/admin/presentation.d.ts +28 -0
  81. package/build/src/admin/presentation.js +1 -0
  82. package/build/src/admin/record_title.d.ts +14 -0
  83. package/build/src/admin/record_title.js +50 -0
  84. package/build/src/admin/resource_service.d.ts +376 -0
  85. package/build/src/admin/resource_service.js +1448 -0
  86. package/build/src/attachments/attachment_service.d.ts +100 -0
  87. package/build/src/attachments/attachment_service.js +270 -0
  88. package/build/src/attachments/doctor.d.ts +4 -0
  89. package/build/src/attachments/doctor.js +28 -0
  90. package/build/src/attachments/storage_migrate.d.ts +39 -0
  91. package/build/src/attachments/storage_migrate.js +64 -0
  92. package/build/src/attachments/upload_grants.d.ts +44 -0
  93. package/build/src/attachments/upload_grants.js +105 -0
  94. package/build/src/auth/ability.d.ts +24 -0
  95. package/build/src/auth/ability.js +34 -0
  96. package/build/src/auth/actor_store.d.ts +14 -0
  97. package/build/src/auth/actor_store.js +70 -0
  98. package/build/src/auth/conditions.d.ts +26 -0
  99. package/build/src/auth/conditions.js +117 -0
  100. package/build/src/auth/packed_rules.d.ts +4 -0
  101. package/build/src/auth/packed_rules.js +13 -0
  102. package/build/src/auth/sql.d.ts +11 -0
  103. package/build/src/auth/sql.js +118 -0
  104. package/build/src/collaboration/assignments.d.ts +129 -0
  105. package/build/src/collaboration/assignments.js +333 -0
  106. package/build/src/collaboration/record_collaboration.d.ts +86 -0
  107. package/build/src/collaboration/record_collaboration.js +348 -0
  108. package/build/src/commands/agent_assets.d.ts +7 -0
  109. package/build/src/commands/agent_assets.js +66 -0
  110. package/build/src/commands/capabilities.d.ts +19 -0
  111. package/build/src/commands/capabilities.js +179 -0
  112. package/build/src/commands/doctor.d.ts +42 -0
  113. package/build/src/commands/doctor.js +375 -0
  114. package/build/src/commands/gap_report.d.ts +56 -0
  115. package/build/src/commands/gap_report.js +110 -0
  116. package/build/src/commands/generator.d.ts +1 -0
  117. package/build/src/commands/generator.js +70 -0
  118. package/build/src/commands/snapshot.d.ts +28 -0
  119. package/build/src/commands/snapshot.js +48 -0
  120. package/build/src/commands/source_markers.d.ts +11 -0
  121. package/build/src/commands/source_markers.js +41 -0
  122. package/build/src/core/activity.d.ts +43 -0
  123. package/build/src/core/activity.js +77 -0
  124. package/build/src/core/administration_guard.d.ts +3 -0
  125. package/build/src/core/administration_guard.js +39 -0
  126. package/build/src/core/health.d.ts +42 -0
  127. package/build/src/core/health.js +44 -0
  128. package/build/src/core/mail_test.d.ts +18 -0
  129. package/build/src/core/mail_test.js +88 -0
  130. package/build/src/core/message_templates.d.ts +83 -0
  131. package/build/src/core/message_templates.js +293 -0
  132. package/build/src/core/module_seed.d.ts +15 -0
  133. package/build/src/core/module_seed.js +31 -0
  134. package/build/src/core/notifications.d.ts +42 -0
  135. package/build/src/core/notifications.js +91 -0
  136. package/build/src/core/org_units.d.ts +30 -0
  137. package/build/src/core/org_units.js +123 -0
  138. package/build/src/core/roles.d.ts +98 -0
  139. package/build/src/core/roles.js +447 -0
  140. package/build/src/core/saved_views.d.ts +37 -0
  141. package/build/src/core/saved_views.js +164 -0
  142. package/build/src/core/settings.d.ts +29 -0
  143. package/build/src/core/settings.js +113 -0
  144. package/build/src/core/setup.d.ts +14 -0
  145. package/build/src/core/setup.js +89 -0
  146. package/build/src/core/ui_preferences.d.ts +12 -0
  147. package/build/src/core/ui_preferences.js +30 -0
  148. package/build/src/core/user_invitations.d.ts +23 -0
  149. package/build/src/core/user_invitations.js +144 -0
  150. package/build/src/core/users.d.ts +44 -0
  151. package/build/src/core/users.js +182 -0
  152. package/build/src/database/configure.d.ts +3 -0
  153. package/build/src/database/configure.js +41 -0
  154. package/build/src/database/schema.d.ts +52 -0
  155. package/build/src/database/schema.js +538 -0
  156. package/build/src/eslint/index.d.ts +3 -0
  157. package/build/src/eslint/index.js +90 -0
  158. package/build/src/events/adonis_jobs.d.ts +9 -0
  159. package/build/src/events/adonis_jobs.js +13 -0
  160. package/build/src/events/outbox.d.ts +19 -0
  161. package/build/src/events/outbox.js +33 -0
  162. package/build/src/events/record_mutation.d.ts +24 -0
  163. package/build/src/events/record_mutation.js +62 -0
  164. package/build/src/integrations/imports.d.ts +74 -0
  165. package/build/src/integrations/imports.js +333 -0
  166. package/build/src/integrations/inbound_webhooks.d.ts +94 -0
  167. package/build/src/integrations/inbound_webhooks.js +276 -0
  168. package/build/src/integrations/openapi.d.ts +39 -0
  169. package/build/src/integrations/openapi.js +323 -0
  170. package/build/src/integrations/print.d.ts +37 -0
  171. package/build/src/integrations/print.js +124 -0
  172. package/build/src/integrations/webhooks.d.ts +98 -0
  173. package/build/src/integrations/webhooks.js +298 -0
  174. package/build/src/mcp/tools.d.ts +8 -0
  175. package/build/src/mcp/tools.js +156 -0
  176. package/build/src/org/org_service.d.ts +2 -0
  177. package/build/src/org/org_service.js +16 -0
  178. package/build/src/resource/define_resource.d.ts +5 -0
  179. package/build/src/resource/define_resource.js +68 -0
  180. package/build/src/resource/registry.d.ts +12 -0
  181. package/build/src/resource/registry.js +101 -0
  182. package/build/src/resource/types.d.ts +155 -0
  183. package/build/src/resource/types.js +1 -0
  184. package/build/src/resource/values.d.ts +5 -0
  185. package/build/src/resource/values.js +88 -0
  186. package/build/src/services/backup.d.ts +14 -0
  187. package/build/src/services/backup.js +59 -0
  188. package/build/src/services/settings.d.ts +21 -0
  189. package/build/src/services/settings.js +30 -0
  190. package/build/src/upgrade/legacy.d.ts +27 -0
  191. package/build/src/upgrade/legacy.js +58 -0
  192. package/build/src/upgrade/rename.d.ts +17 -0
  193. package/build/src/upgrade/rename.js +94 -0
  194. package/build/src/version.d.ts +1 -0
  195. package/build/src/version.js +2 -0
  196. package/build/src/workflows/define_workflow.d.ts +124 -0
  197. package/build/src/workflows/define_workflow.js +123 -0
  198. package/build/src/workflows/engine.d.ts +141 -0
  199. package/build/src/workflows/engine.js +752 -0
  200. package/build/stubs/README.md +6 -0
  201. package/build/stubs/controller.stub +8 -0
  202. package/build/stubs/main.d.ts +5 -0
  203. package/build/stubs/main.js +5 -0
  204. package/build/stubs/main.ts +5 -0
  205. package/build/stubs/modules.stub +6 -0
  206. package/build/stubs/resource_contract.stub +1 -0
  207. package/build/stubs/resource_contract.txt +452 -0
  208. package/build/stubs/routes.stub +16 -0
  209. package/build/stubs/service.stub +9 -0
  210. package/package.json +95 -6
@@ -0,0 +1,182 @@
1
+ import { AdulaError } from '../admin/errors.js';
2
+ import { logActivity, pageLimit } from './activity.js';
3
+ import { administrationGuard } from './administration_guard.js';
4
+ const RESOURCE = 'core.users';
5
+ const escapeLike = (value) => value.replace(/[\\%_]/g, '\\$&');
6
+ /** Host applications own the users table; AdulaJS expects id, email, full_name and disabled_at. */
7
+ export class UsersAdmin {
8
+ db;
9
+ constructor(db) {
10
+ this.db = db;
11
+ }
12
+ async list(options = {}) {
13
+ const limit = pageLimit(options.limit);
14
+ const query = this.db('users')
15
+ .select('id', 'email', 'full_name', 'disabled_at')
16
+ .orderBy('id')
17
+ .limit(limit + 1);
18
+ const search = options.search?.trim();
19
+ if (search) {
20
+ const pattern = `%${escapeLike(search)}%`;
21
+ query.where((where) => where.whereILike('email', pattern).orWhereILike('full_name', pattern));
22
+ }
23
+ if (options.cursor)
24
+ query.where('id', '>', options.cursor);
25
+ const rows = await query;
26
+ const page = rows.slice(0, limit);
27
+ const data = await this.hydrate(page);
28
+ return { data, nextCursor: rows.length > limit ? page[page.length - 1].id : null };
29
+ }
30
+ async get(id) {
31
+ const [user] = await this.hydrate([await this.find(this.db, id)]);
32
+ return user;
33
+ }
34
+ async assignRole(actorId, userId, roleId, orgUnitId = null) {
35
+ return this.db.transaction(async (trx) => {
36
+ const verifyAccess = await administrationGuard(trx, actorId);
37
+ await this.find(trx, userId);
38
+ const role = await trx('roles').where('id', roleId).first();
39
+ if (!role)
40
+ throw new AdulaError(404, 'E_ROLE_NOT_FOUND', 'الدور غير موجود');
41
+ if (orgUnitId !== null && !(await trx('org_units').where('id', orgUnitId).first()))
42
+ throw new AdulaError(404, 'E_ORG_NOT_FOUND', 'الوحدة التنظيمية غير موجودة');
43
+ const duplicate = await trx('user_roles')
44
+ .where({ user_id: userId, role_id: roleId })
45
+ .andWhere((where) => orgUnitId === null
46
+ ? where.whereNull('org_unit_id')
47
+ : where.where('org_unit_id', orgUnitId))
48
+ .first();
49
+ if (duplicate)
50
+ throw new AdulaError(409, 'E_ROLE_ASSIGNED', 'هذا الدور مسند بالفعل');
51
+ const [row] = await trx('user_roles')
52
+ .insert({ user_id: userId, role_id: roleId, org_unit_id: orgUnitId })
53
+ .returning('id');
54
+ await verifyAccess();
55
+ await logActivity(trx, {
56
+ resource: RESOURCE,
57
+ recordId: userId,
58
+ actorId,
59
+ action: 'assign_role',
60
+ changes: { roleId, role: role.name, orgUnitId },
61
+ });
62
+ return row.id;
63
+ });
64
+ }
65
+ async removeRole(actorId, userId, assignmentId) {
66
+ return this.db.transaction(async (trx) => {
67
+ const verifyAccess = await administrationGuard(trx, actorId);
68
+ const [row] = await trx('user_roles')
69
+ .where({ id: assignmentId, user_id: userId })
70
+ .delete()
71
+ .returning('*');
72
+ if (!row)
73
+ throw new AdulaError(404, 'E_ROLE_NOT_ASSIGNED', 'الإسناد غير موجود');
74
+ await verifyAccess();
75
+ await logActivity(trx, {
76
+ resource: RESOURCE,
77
+ recordId: userId,
78
+ actorId,
79
+ action: 'remove_role',
80
+ changes: { roleId: row.role_id, orgUnitId: row.org_unit_id },
81
+ });
82
+ });
83
+ }
84
+ async assignOrgUnit(actorId, userId, orgUnitId) {
85
+ return this.db.transaction(async (trx) => {
86
+ await this.find(trx, userId);
87
+ const unit = await trx('org_units').where('id', orgUnitId).first();
88
+ if (!unit)
89
+ throw new AdulaError(404, 'E_ORG_NOT_FOUND', 'الوحدة التنظيمية غير موجودة');
90
+ if (await trx('user_org_units').where({ user_id: userId, org_unit_id: orgUnitId }).first())
91
+ throw new AdulaError(409, 'E_MEMBERSHIP_EXISTS', 'المستخدم عضو في هذه الوحدة بالفعل');
92
+ await trx('user_org_units').insert({ user_id: userId, org_unit_id: orgUnitId });
93
+ await logActivity(trx, {
94
+ resource: RESOURCE,
95
+ recordId: userId,
96
+ actorId,
97
+ action: 'assign_org_unit',
98
+ changes: { orgUnitId, orgUnit: unit.name },
99
+ });
100
+ });
101
+ }
102
+ async removeOrgUnit(actorId, userId, orgUnitId) {
103
+ return this.db.transaction(async (trx) => {
104
+ const removed = await trx('user_org_units')
105
+ .where({ user_id: userId, org_unit_id: orgUnitId })
106
+ .delete();
107
+ if (!removed)
108
+ throw new AdulaError(404, 'E_MEMBERSHIP_NOT_FOUND', 'العضوية غير موجودة');
109
+ await logActivity(trx, {
110
+ resource: RESOURCE,
111
+ recordId: userId,
112
+ actorId,
113
+ action: 'remove_org_unit',
114
+ changes: { orgUnitId },
115
+ });
116
+ });
117
+ }
118
+ async disable(actorId, userId) {
119
+ if (actorId === userId)
120
+ throw new AdulaError(422, 'E_SELF_DISABLE', 'لا يمكنك تعطيل حسابك الحالي');
121
+ return this.db.transaction(async (trx) => {
122
+ const verifyAccess = await administrationGuard(trx, actorId);
123
+ await this.find(trx, userId);
124
+ await trx('users')
125
+ .where('id', userId)
126
+ .whereNull('disabled_at')
127
+ .update({ disabled_at: trx.fn.now() });
128
+ await verifyAccess();
129
+ await logActivity(trx, { resource: RESOURCE, recordId: userId, actorId, action: 'disable' });
130
+ });
131
+ }
132
+ async enable(actorId, userId) {
133
+ return this.db.transaction(async (trx) => {
134
+ await this.find(trx, userId);
135
+ await trx('users').where('id', userId).update({ disabled_at: null });
136
+ await logActivity(trx, { resource: RESOURCE, recordId: userId, actorId, action: 'enable' });
137
+ });
138
+ }
139
+ async find(db, id) {
140
+ const user = await db('users')
141
+ .select('id', 'email', 'full_name', 'disabled_at')
142
+ .where('id', id)
143
+ .first();
144
+ if (!user)
145
+ throw new AdulaError(404, 'E_USER_NOT_FOUND', 'المستخدم غير موجود');
146
+ return user;
147
+ }
148
+ async hydrate(rows) {
149
+ if (!rows.length)
150
+ return [];
151
+ const ids = rows.map((row) => row.id);
152
+ const roles = await this.db('user_roles as ur')
153
+ .join('roles as r', 'r.id', 'ur.role_id')
154
+ .leftJoin('org_units as o', 'o.id', 'ur.org_unit_id')
155
+ .whereIn('ur.user_id', ids)
156
+ .select('ur.id', 'ur.user_id', 'ur.role_id', 'r.name as role', 'ur.org_unit_id', 'o.name as org_unit')
157
+ .orderBy(['r.name', 'ur.id']);
158
+ const units = await this.db('user_org_units as m')
159
+ .join('org_units as o', 'o.id', 'm.org_unit_id')
160
+ .whereIn('m.user_id', ids)
161
+ .select('m.user_id', 'o.id', 'o.name', 'o.path')
162
+ .orderBy('o.path');
163
+ return rows.map((row) => ({
164
+ id: row.id,
165
+ fullName: row.full_name ?? null,
166
+ email: row.email,
167
+ disabledAt: row.disabled_at ? new Date(row.disabled_at).toISOString() : null,
168
+ roles: roles
169
+ .filter((role) => role.user_id === row.id)
170
+ .map((role) => ({
171
+ id: role.id,
172
+ roleId: role.role_id,
173
+ role: role.role,
174
+ orgUnitId: role.org_unit_id ?? null,
175
+ orgUnit: role.org_unit ?? null,
176
+ })),
177
+ orgUnits: units
178
+ .filter((unit) => unit.user_id === row.id)
179
+ .map((unit) => ({ id: unit.id, name: unit.name, path: String(unit.path) })),
180
+ }));
181
+ }
182
+ }
@@ -0,0 +1,3 @@
1
+ import type { DatabaseConfig } from '@adonisjs/lucid/types/database';
2
+ /** Migration names stay relative across source, packed and production installs. */
3
+ export declare function withAdulaDatabase<T extends DatabaseConfig>(config: T, root: string): T;
@@ -0,0 +1,41 @@
1
+ import { readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ /** Migration names stay relative across source, packed and production installs. */
4
+ export function withAdulaDatabase(config, root) {
5
+ const name = config.connection;
6
+ const connection = name ? config.connections[name] : undefined;
7
+ if (!connection || connection.client !== 'pg')
8
+ throw new Error('AdulaJS requires a configured PostgreSQL connection');
9
+ let modules = [];
10
+ try {
11
+ modules = readdirSync(join(root, 'app/modules'), { withFileTypes: true })
12
+ .filter((entry) => entry.isDirectory() && /^[a-z][a-z0-9_]*$/.test(entry.name))
13
+ .map((entry) => `app/modules/${entry.name}/migrations`)
14
+ .sort();
15
+ }
16
+ catch (error) {
17
+ if (error.code !== 'ENOENT')
18
+ throw error;
19
+ }
20
+ const migrations = connection.migrations ?? {};
21
+ return {
22
+ ...config,
23
+ connections: {
24
+ ...config.connections,
25
+ [name]: {
26
+ ...connection,
27
+ migrations: {
28
+ ...migrations,
29
+ naturalSort: true,
30
+ paths: [
31
+ ...new Set([
32
+ ...(migrations.paths ?? ['database/migrations']),
33
+ 'node_modules/adula/build/database/migrations',
34
+ ...modules,
35
+ ]),
36
+ ],
37
+ },
38
+ },
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,52 @@
1
+ import type { Knex } from 'knex';
2
+ import type { Resource } from '../resource/types.js';
3
+ export declare function createCoreSchema(db: Knex): Promise<void>;
4
+ /** Attachment metadata lives in one table so ownership, restore drills and disk moves see every file. */
5
+ export declare function createAttachmentsSchema(db: Knex): Promise<void>;
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>;
8
+ /** Record collaboration (phase 3): comments with mentions, followers, tags and field history. */
9
+ export declare function createCollaborationSchema(db: Knex): Promise<void>;
10
+ /** Work assigned to a user on a record; approval steps of workflows reuse it (phase 4). */
11
+ export declare function createAssignmentsSchema(db: Knex): Promise<void>;
12
+ /**
13
+ * Managed assignments (1.1): opened and closed by module code with the record's state,
14
+ * never completed by hand. The close reason is shown with the closed task.
15
+ */
16
+ export declare function createManagedAssignmentsSchema(db: Knex): Promise<void>;
17
+ /**
18
+ * Message templates, notification e-mail delivery state and the realtime signal.
19
+ * The trigger's NOTIFY is delivered only when the inserting transaction commits.
20
+ */
21
+ export declare function createMessagingSchema(db: Knex): Promise<void>;
22
+ /** Outgoing webhooks and their delivery log (exactly one row per webhook and event). */
23
+ export declare function createWebhooksSchema(db: Knex): Promise<void>;
24
+ /** CSV import batches: parsed rows, column mapping, progress and per-row errors. */
25
+ export declare function createImportsSchema(db: Knex): Promise<void>;
26
+ /**
27
+ * Workflow engine state (phase 4): the submission envelope rows gain execution
28
+ * columns, and every transition is appended to workflow_events.
29
+ */
30
+ export declare function createWorkflowSchema(db: Knex): Promise<void>;
31
+ /**
32
+ * Roles gain a stable key (1.1) that workflows and module defaults address, so an
33
+ * administrator can rename the display name freely. Existing identifier-like names
34
+ * (such as the bootstrap "administrator") become their key.
35
+ */
36
+ export declare function createRoleKeysSchema(db: Knex): Promise<void>;
37
+ /**
38
+ * Notifications may name the record they are about (1.1). Links are authorized when
39
+ * opened, by the record page itself, never when the notification is written.
40
+ */
41
+ export declare function createNotificationTargetsSchema(db: Knex): Promise<void>;
42
+ /**
43
+ * Short-lived upload grants (1.1): module code lets one user upload to one attachment field
44
+ * of one record without a role rule. Only the SHA-256 hash of the token is stored.
45
+ */
46
+ export declare function createUploadGrantsSchema(db: Knex): Promise<void>;
47
+ /**
48
+ * Signed inbound webhooks (1.2): administrator-managed sources with sealed secrets,
49
+ * and a delivery log deduplicated by the sender's delivery id. Accepted deliveries are
50
+ * dispatched as domain events through the outbox.
51
+ */
52
+ export declare function createInboundWebhooksSchema(db: Knex): Promise<void>;