@tstdl/base 0.92.129 → 0.92.131

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 (72) hide show
  1. package/ai/ai.service.js +4 -4
  2. package/api/server/api-controller.js +1 -2
  3. package/document-management/api/document-management.api.d.ts +25 -55
  4. package/document-management/api/document-management.api.js +9 -18
  5. package/document-management/models/document-request-collection-assignment.model.d.ts +7 -0
  6. package/document-management/models/{document-request-collection.model.js → document-request-collection-assignment.model.js} +6 -6
  7. package/document-management/models/index.d.ts +1 -1
  8. package/document-management/models/index.js +1 -1
  9. package/document-management/server/api/document-management.api.d.ts +26 -0
  10. package/document-management/server/api/document-management.api.js +169 -0
  11. package/document-management/server/api/index.d.ts +1 -0
  12. package/document-management/server/api/index.js +1 -0
  13. package/document-management/server/drizzle/{0000_cool_victor_mancha.sql → 0000_magical_madame_hydra.sql} +128 -96
  14. package/document-management/server/drizzle/meta/0000_snapshot.json +768 -492
  15. package/document-management/server/drizzle/meta/_journal.json +2 -9
  16. package/document-management/server/index.d.ts +1 -0
  17. package/document-management/server/index.js +1 -0
  18. package/document-management/server/schemas.d.ts +3 -2
  19. package/document-management/server/schemas.js +3 -2
  20. package/document-management/server/services/document-category-type.service.d.ts +2 -0
  21. package/document-management/server/services/document-category-type.service.js +26 -15
  22. package/document-management/server/services/document-collection.service.js +13 -2
  23. package/document-management/server/services/document-file.service.js +15 -4
  24. package/document-management/server/services/document-management-ai.service.js +19 -8
  25. package/document-management/server/services/document-management-ancillary.service.d.ts +21 -40
  26. package/document-management/server/services/document-management-ancillary.service.js +25 -14
  27. package/document-management/server/services/document-management.service.d.ts +1 -1
  28. package/document-management/server/services/document-management.service.js +53 -34
  29. package/document-management/server/services/document-property.service.d.ts +2 -34
  30. package/document-management/server/services/document-property.service.js +20 -8
  31. package/document-management/server/services/document-request.service.js +11 -11
  32. package/document-management/server/services/document-validation.service.js +15 -4
  33. package/document-management/server/services/document-workflow.service.js +27 -16
  34. package/document-management/server/services/document.service.d.ts +10 -2
  35. package/document-management/server/services/document.service.js +61 -8
  36. package/document-management/server/services/index.d.ts +1 -0
  37. package/document-management/server/services/index.js +1 -0
  38. package/document-management/server/services/singleton.d.ts +4 -0
  39. package/document-management/server/services/singleton.js +12 -0
  40. package/document-management/service-models/document.service-model.d.ts +8 -9
  41. package/document-management/service-models/document.service-model.js +1 -1
  42. package/eslint.config.js +1 -0
  43. package/examples/document-management/categories-and-types.d.ts +324 -0
  44. package/examples/document-management/categories-and-types.js +363 -0
  45. package/examples/document-management/main.d.ts +7 -8
  46. package/examples/document-management/main.js +86 -27
  47. package/injector/decorators.d.ts +1 -0
  48. package/injector/decorators.js +41 -12
  49. package/injector/inject.d.ts +12 -2
  50. package/injector/injector.d.ts +3 -2
  51. package/injector/injector.js +87 -36
  52. package/injector/symbols.d.ts +1 -0
  53. package/injector/symbols.js +1 -0
  54. package/module/modules/web-server.module.js +4 -4
  55. package/orm/server/database.d.ts +0 -4
  56. package/orm/server/database.js +0 -4
  57. package/orm/server/drizzle/schema-converter.js +5 -4
  58. package/orm/server/module.d.ts +0 -4
  59. package/orm/server/module.js +0 -2
  60. package/orm/server/query-converter.js +11 -38
  61. package/orm/server/repository.d.ts +3 -2
  62. package/orm/server/repository.js +2 -2
  63. package/orm/server/transaction.d.ts +5 -4
  64. package/orm/server/transaction.js +8 -3
  65. package/orm/server/transactional.js +3 -3
  66. package/orm/sqls.d.ts +4 -1
  67. package/orm/sqls.js +4 -1
  68. package/package.json +4 -4
  69. package/reflection/registry.js +6 -6
  70. package/document-management/models/document-request-collection.model.d.ts +0 -7
  71. package/document-management/server/drizzle/0001_concerned_quentin_quire.sql +0 -2
  72. package/document-management/server/drizzle/meta/0001_snapshot.json +0 -1932
@@ -1,4 +1,12 @@
1
+ CREATE TYPE "document_management"."document_approval" AS ENUM('pending', 'approved', 'rejected');--> statement-breakpoint
2
+ CREATE TYPE "document_management"."document_assignment_target" AS ENUM('collection', 'request');--> statement-breakpoint
1
3
  CREATE TYPE "document_management"."document_property_data_type" AS ENUM('text', 'integer', 'decimal', 'boolean', 'date');--> statement-breakpoint
4
+ CREATE TYPE "document_management"."document_request_state" AS ENUM('open', 'fulfilled', 'closed');--> statement-breakpoint
5
+ CREATE TYPE "document_management"."document_validation_execution_state" AS ENUM('pending', 'running', 'completed', 'error');--> statement-breakpoint
6
+ CREATE TYPE "document_management"."document_validation_result_status" AS ENUM('passed', 'failed', 'warning');--> statement-breakpoint
7
+ CREATE TYPE "document_management"."document_workflow_fail_reason" AS ENUM('no-suitable-collection', 'no-suitable-request');--> statement-breakpoint
8
+ CREATE TYPE "document_management"."document_workflow_state" AS ENUM('pending', 'running', 'completed', 'error', 'failed');--> statement-breakpoint
9
+ CREATE TYPE "document_management"."document_workflow_step" AS ENUM('classification', 'extraction', 'assignment', 'validation');--> statement-breakpoint
2
10
  CREATE TABLE "document_management"."document" (
3
11
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4
12
  "file_id" uuid NOT NULL,
@@ -9,6 +17,9 @@ CREATE TABLE "document_management"."document" (
9
17
  "date" date,
10
18
  "summary" text,
11
19
  "tags" text[],
20
+ "approval" "document_management"."document_approval" NOT NULL,
21
+ "comment" text,
22
+ "create_user_id" uuid,
12
23
  "revision" integer NOT NULL,
13
24
  "revision_timestamp" timestamp with time zone NOT NULL,
14
25
  "create_timestamp" timestamp with time zone NOT NULL,
@@ -16,8 +27,33 @@ CREATE TABLE "document_management"."document" (
16
27
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
17
28
  );
18
29
  --> statement-breakpoint
30
+ CREATE TABLE "document_management"."document_assignment_scope" (
31
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
32
+ "task_id" uuid NOT NULL,
33
+ "collection_id" uuid NOT NULL,
34
+ "revision" integer NOT NULL,
35
+ "revision_timestamp" timestamp with time zone NOT NULL,
36
+ "create_timestamp" timestamp with time zone NOT NULL,
37
+ "delete_timestamp" timestamp with time zone,
38
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
39
+ CONSTRAINT "das_task_id_collection_id_unique" UNIQUE("task_id","collection_id")
40
+ );
41
+ --> statement-breakpoint
42
+ CREATE TABLE "document_management"."document_assignment_task" (
43
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
44
+ "document_id" uuid NOT NULL,
45
+ "target" "document_management"."document_assignment_target" NOT NULL,
46
+ "revision" integer NOT NULL,
47
+ "revision_timestamp" timestamp with time zone NOT NULL,
48
+ "create_timestamp" timestamp with time zone NOT NULL,
49
+ "delete_timestamp" timestamp with time zone,
50
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
51
+ CONSTRAINT "document_assignment_task_document_id_unique" UNIQUE("document_id")
52
+ );
53
+ --> statement-breakpoint
19
54
  CREATE TABLE "document_management"."document_category" (
20
55
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
56
+ "parent_id" uuid,
21
57
  "label" text NOT NULL,
22
58
  "revision" integer NOT NULL,
23
59
  "revision_timestamp" timestamp with time zone NOT NULL,
@@ -29,6 +65,7 @@ CREATE TABLE "document_management"."document_category" (
29
65
  --> statement-breakpoint
30
66
  CREATE TABLE "document_management"."document_collection" (
31
67
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
68
+ "parent_id" uuid,
32
69
  "revision" integer NOT NULL,
33
70
  "revision_timestamp" timestamp with time zone NOT NULL,
34
71
  "create_timestamp" timestamp with time zone NOT NULL,
@@ -36,7 +73,7 @@ CREATE TABLE "document_management"."document_collection" (
36
73
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
37
74
  );
38
75
  --> statement-breakpoint
39
- CREATE TABLE "document_management"."document_collection_document" (
76
+ CREATE TABLE "document_management"."document_collection_assignment" (
40
77
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
41
78
  "collection_id" uuid NOT NULL,
42
79
  "document_id" uuid NOT NULL,
@@ -46,7 +83,7 @@ CREATE TABLE "document_management"."document_collection_document" (
46
83
  "create_timestamp" timestamp with time zone NOT NULL,
47
84
  "delete_timestamp" timestamp with time zone,
48
85
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
49
- CONSTRAINT "document_collection_document_collection_id_document_id_unique" UNIQUE("collection_id","document_id")
86
+ CONSTRAINT "document_collection_assignment_collection_id_document_id_unique" UNIQUE("collection_id","document_id")
50
87
  );
51
88
  --> statement-breakpoint
52
89
  CREATE TABLE "document_management"."document_file" (
@@ -76,13 +113,13 @@ CREATE TABLE "document_management"."document_property" (
76
113
  --> statement-breakpoint
77
114
  CREATE TABLE "document_management"."document_property_value" (
78
115
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
116
+ "document_id" uuid NOT NULL,
79
117
  "property_id" uuid NOT NULL,
80
118
  "text" text,
81
119
  "integer" integer,
82
120
  "decimal" double precision,
83
121
  "boolean" boolean,
84
122
  "date" date,
85
- "document_id" uuid NOT NULL,
86
123
  "revision" integer NOT NULL,
87
124
  "revision_timestamp" timestamp with time zone NOT NULL,
88
125
  "create_timestamp" timestamp with time zone NOT NULL,
@@ -95,190 +132,185 @@ CREATE TABLE "document_management"."document_property_value" (
95
132
  CREATE TABLE "document_management"."document_request" (
96
133
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
97
134
  "type_id" uuid,
98
- "required_files_count" integer NOT NULL,
135
+ "document_id" uuid,
99
136
  "comment" text,
100
- "completed" boolean NOT NULL,
137
+ "state" "document_management"."document_request_state" NOT NULL,
101
138
  "revision" integer NOT NULL,
102
139
  "revision_timestamp" timestamp with time zone NOT NULL,
103
140
  "create_timestamp" timestamp with time zone NOT NULL,
104
141
  "delete_timestamp" timestamp with time zone,
105
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
142
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
143
+ CONSTRAINT "document_request_document_id_unique" UNIQUE("document_id")
106
144
  );
107
145
  --> statement-breakpoint
108
- CREATE TABLE "document_management"."document_request_assignment_task" (
146
+ CREATE TABLE "document_management"."document_request_collection_assignment" (
109
147
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
110
- "file_id" uuid NOT NULL,
111
- "assigned_request_file_id" uuid,
112
- "type_id" uuid,
113
- "title" text,
114
- "subtitle" text,
115
- "pages" integer,
116
- "date" date,
117
- "summary" text,
118
- "tags" text[],
119
- "assignment_tries" integer NOT NULL,
148
+ "request_id" uuid NOT NULL,
149
+ "collection_id" uuid NOT NULL,
120
150
  "revision" integer NOT NULL,
121
151
  "revision_timestamp" timestamp with time zone NOT NULL,
122
152
  "create_timestamp" timestamp with time zone NOT NULL,
123
153
  "delete_timestamp" timestamp with time zone,
124
154
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
125
- CONSTRAINT "drat_file_id_unique" UNIQUE("file_id")
155
+ CONSTRAINT "document_request_collection_assignment_request_id_collection_id_unique" UNIQUE("request_id","collection_id")
126
156
  );
127
157
  --> statement-breakpoint
128
- CREATE TABLE "document_management"."document_request_assignment_task_collection" (
158
+ CREATE TABLE "document_management"."document_request_submission" (
129
159
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
130
- "request_assignment_task_id" uuid NOT NULL,
131
- "collection_id" uuid NOT NULL,
160
+ "request_id" uuid NOT NULL,
161
+ "document_id" uuid NOT NULL,
132
162
  "revision" integer NOT NULL,
133
163
  "revision_timestamp" timestamp with time zone NOT NULL,
134
164
  "create_timestamp" timestamp with time zone NOT NULL,
135
165
  "delete_timestamp" timestamp with time zone,
136
166
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
137
- CONSTRAINT "dratc_request_assignment_task_id_collection_id_unique" UNIQUE("request_assignment_task_id","collection_id")
167
+ CONSTRAINT "document_request_submission_request_id_document_id_unique" UNIQUE("request_id","document_id")
138
168
  );
139
169
  --> statement-breakpoint
140
- CREATE TABLE "document_management"."document_request_assignment_task_property_value" (
170
+ CREATE TABLE "document_management"."document_request_template" (
141
171
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
142
- "property_id" uuid NOT NULL,
143
- "text" text,
144
- "integer" integer,
145
- "decimal" double precision,
146
- "boolean" boolean,
147
- "date" date,
148
- "request_assignment_task_id" uuid NOT NULL,
172
+ "requests_template_id" uuid NOT NULL,
173
+ "type_id" uuid NOT NULL,
174
+ "comment" text,
149
175
  "revision" integer NOT NULL,
150
176
  "revision_timestamp" timestamp with time zone NOT NULL,
151
177
  "create_timestamp" timestamp with time zone NOT NULL,
152
178
  "delete_timestamp" timestamp with time zone,
153
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
154
- CONSTRAINT "dratpv_request_assignment_task_id_property_id_unique" UNIQUE("request_assignment_task_id","property_id"),
155
- CONSTRAINT "only_one_value" CHECK (num_nonnulls("document_management"."document_request_assignment_task_property_value"."text", "document_management"."document_request_assignment_task_property_value"."integer", "document_management"."document_request_assignment_task_property_value"."decimal", "document_management"."document_request_assignment_task_property_value"."boolean", "document_management"."document_request_assignment_task_property_value"."date") = 1)
179
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
156
180
  );
157
181
  --> statement-breakpoint
158
- CREATE TABLE "document_management"."document_request_collection" (
182
+ CREATE TABLE "document_management"."document_requests_template" (
159
183
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
160
- "request_id" uuid NOT NULL,
161
- "collection_id" uuid NOT NULL,
184
+ "label" text NOT NULL,
185
+ "description" text,
162
186
  "revision" integer NOT NULL,
163
187
  "revision_timestamp" timestamp with time zone NOT NULL,
164
188
  "create_timestamp" timestamp with time zone NOT NULL,
165
189
  "delete_timestamp" timestamp with time zone,
166
190
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
167
- CONSTRAINT "document_request_collection_request_id_collection_id_unique" UNIQUE("request_id","collection_id")
191
+ CONSTRAINT "document_requests_template_label_unique" UNIQUE("label")
168
192
  );
169
193
  --> statement-breakpoint
170
- CREATE TABLE "document_management"."document_request_file" (
194
+ CREATE TABLE "document_management"."document_type" (
171
195
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
172
- "request_id" uuid NOT NULL,
173
- "file_id" uuid NOT NULL,
174
- "title" text,
175
- "subtitle" text,
176
- "pages" integer,
177
- "date" date,
178
- "summary" text,
179
- "tags" text[],
180
- "created_document_id" uuid,
181
- "approval" boolean,
182
- "approval_comment" text,
183
- "approval_timestamp" timestamp with time zone,
196
+ "category_id" uuid NOT NULL,
197
+ "label" text NOT NULL,
184
198
  "revision" integer NOT NULL,
185
199
  "revision_timestamp" timestamp with time zone NOT NULL,
186
200
  "create_timestamp" timestamp with time zone NOT NULL,
187
201
  "delete_timestamp" timestamp with time zone,
188
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
202
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
203
+ CONSTRAINT "document_type_category_id_label_unique" UNIQUE("category_id","label")
189
204
  );
190
205
  --> statement-breakpoint
191
- CREATE TABLE "document_management"."document_request_file_property_value" (
206
+ CREATE TABLE "document_management"."document_type_property" (
192
207
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
208
+ "type_id" uuid NOT NULL,
193
209
  "property_id" uuid NOT NULL,
194
- "text" text,
195
- "integer" integer,
196
- "decimal" double precision,
197
- "boolean" boolean,
198
- "date" date,
199
- "request_file_id" uuid NOT NULL,
200
210
  "revision" integer NOT NULL,
201
211
  "revision_timestamp" timestamp with time zone NOT NULL,
202
212
  "create_timestamp" timestamp with time zone NOT NULL,
203
213
  "delete_timestamp" timestamp with time zone,
204
214
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
205
- CONSTRAINT "drfpv_request_file_id_property_id_unique" UNIQUE("request_file_id","property_id"),
206
- CONSTRAINT "only_one_value" CHECK (num_nonnulls("document_management"."document_request_file_property_value"."text", "document_management"."document_request_file_property_value"."integer", "document_management"."document_request_file_property_value"."decimal", "document_management"."document_request_file_property_value"."boolean", "document_management"."document_request_file_property_value"."date") = 1)
215
+ CONSTRAINT "document_type_property_type_id_property_id_unique" UNIQUE("type_id","property_id")
207
216
  );
208
217
  --> statement-breakpoint
209
- CREATE TABLE "document_management"."document_request_template" (
218
+ CREATE TABLE "document_management"."document_type_validation" (
210
219
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
211
- "requests_template_id" uuid NOT NULL,
212
- "type_id" uuid,
213
- "required_files_count" integer NOT NULL,
214
- "comment" text,
220
+ "type_id" uuid NOT NULL,
221
+ "validation_id" uuid NOT NULL,
215
222
  "revision" integer NOT NULL,
216
223
  "revision_timestamp" timestamp with time zone NOT NULL,
217
224
  "create_timestamp" timestamp with time zone NOT NULL,
218
225
  "delete_timestamp" timestamp with time zone,
219
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
226
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
227
+ CONSTRAINT "document_type_validation_type_id_validation_id_unique" UNIQUE("type_id","validation_id")
220
228
  );
221
229
  --> statement-breakpoint
222
- CREATE TABLE "document_management"."document_requests_template" (
230
+ CREATE TABLE "document_management"."document_validation_definition" (
223
231
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
232
+ "identifier" text NOT NULL,
224
233
  "label" text NOT NULL,
225
234
  "description" text,
235
+ "configuration" jsonb NOT NULL,
226
236
  "revision" integer NOT NULL,
227
237
  "revision_timestamp" timestamp with time zone NOT NULL,
228
238
  "create_timestamp" timestamp with time zone NOT NULL,
229
239
  "delete_timestamp" timestamp with time zone,
230
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
231
- CONSTRAINT "document_requests_template_label_unique" UNIQUE("label")
240
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
232
241
  );
233
242
  --> statement-breakpoint
234
- CREATE TABLE "document_management"."document_type" (
243
+ CREATE TABLE "document_management"."document_validation_execution" (
235
244
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
236
- "category_id" uuid NOT NULL,
237
- "group" text,
238
- "label" text NOT NULL,
245
+ "workflow_id" uuid NOT NULL,
246
+ "definition_id" uuid NOT NULL,
247
+ "state" "document_management"."document_validation_execution_state" NOT NULL,
248
+ "result_status" "document_management"."document_validation_result_status",
249
+ "result_message" text,
250
+ "started_at" timestamp with time zone,
251
+ "completed_at" timestamp with time zone,
239
252
  "revision" integer NOT NULL,
240
253
  "revision_timestamp" timestamp with time zone NOT NULL,
241
254
  "create_timestamp" timestamp with time zone NOT NULL,
242
255
  "delete_timestamp" timestamp with time zone,
243
256
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
244
- CONSTRAINT "document_type_category_id_label_unique" UNIQUE("category_id","label")
257
+ CONSTRAINT "document_validation_execution_workflow_id_definition_id_unique" UNIQUE("workflow_id","definition_id")
245
258
  );
246
259
  --> statement-breakpoint
247
- CREATE TABLE "document_management"."document_type_property" (
260
+ CREATE TABLE "document_management"."document_validation_execution_related_document" (
248
261
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
249
- "type_id" uuid NOT NULL,
250
- "property_id" uuid NOT NULL,
262
+ "execution_id" uuid NOT NULL,
263
+ "document_id" uuid NOT NULL,
251
264
  "revision" integer NOT NULL,
252
265
  "revision_timestamp" timestamp with time zone NOT NULL,
253
266
  "create_timestamp" timestamp with time zone NOT NULL,
254
267
  "delete_timestamp" timestamp with time zone,
255
268
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
256
- CONSTRAINT "document_type_property_type_id_property_id_unique" UNIQUE("type_id","property_id")
269
+ CONSTRAINT "dverd_execution_id_document_id_unique" UNIQUE("execution_id","document_id")
270
+ );
271
+ --> statement-breakpoint
272
+ CREATE TABLE "document_management"."document_workflow" (
273
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
274
+ "document_id" uuid NOT NULL,
275
+ "step" "document_management"."document_workflow_step" NOT NULL,
276
+ "state" "document_management"."document_workflow_state" NOT NULL,
277
+ "fail_reason" "document_management"."document_workflow_fail_reason",
278
+ "complete_user_id" uuid,
279
+ "revision" integer NOT NULL,
280
+ "revision_timestamp" timestamp with time zone NOT NULL,
281
+ "create_timestamp" timestamp with time zone NOT NULL,
282
+ "delete_timestamp" timestamp with time zone,
283
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
257
284
  );
258
285
  --> statement-breakpoint
259
286
  ALTER TABLE "document_management"."document" ADD CONSTRAINT "document_file_id_document_file_id_fk" FOREIGN KEY ("file_id") REFERENCES "document_management"."document_file"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
260
287
  ALTER TABLE "document_management"."document" ADD CONSTRAINT "document_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
261
- ALTER TABLE "document_management"."document_collection_document" ADD CONSTRAINT "document_collection_document_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
262
- ALTER TABLE "document_management"."document_collection_document" ADD CONSTRAINT "document_collection_document_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
263
- ALTER TABLE "document_management"."document_property_value" ADD CONSTRAINT "document_property_value_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
288
+ ALTER TABLE "document_management"."document_assignment_scope" ADD CONSTRAINT "document_assignment_scope_task_id_document_assignment_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "document_management"."document_assignment_task"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
289
+ ALTER TABLE "document_management"."document_assignment_scope" ADD CONSTRAINT "document_assignment_scope_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
290
+ ALTER TABLE "document_management"."document_assignment_task" ADD CONSTRAINT "document_assignment_task_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
291
+ ALTER TABLE "document_management"."document_category" ADD CONSTRAINT "document_category_parent_id_document_category_id_fk" FOREIGN KEY ("parent_id") REFERENCES "document_management"."document_category"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
292
+ ALTER TABLE "document_management"."document_collection" ADD CONSTRAINT "document_collection_parent_id_document_collection_id_fk" FOREIGN KEY ("parent_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
293
+ ALTER TABLE "document_management"."document_collection_assignment" ADD CONSTRAINT "document_collection_assignment_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
294
+ ALTER TABLE "document_management"."document_collection_assignment" ADD CONSTRAINT "document_collection_assignment_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
264
295
  ALTER TABLE "document_management"."document_property_value" ADD CONSTRAINT "document_property_value_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
296
+ ALTER TABLE "document_management"."document_property_value" ADD CONSTRAINT "document_property_value_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
265
297
  ALTER TABLE "document_management"."document_request" ADD CONSTRAINT "document_request_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
266
- ALTER TABLE "document_management"."document_request_assignment_task" ADD CONSTRAINT "document_request_assignment_task_file_id_document_file_id_fk" FOREIGN KEY ("file_id") REFERENCES "document_management"."document_file"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
267
- ALTER TABLE "document_management"."document_request_assignment_task" ADD CONSTRAINT "document_request_assignment_task_assigned_request_file_id_document_request_file_id_fk" FOREIGN KEY ("assigned_request_file_id") REFERENCES "document_management"."document_request_file"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
268
- ALTER TABLE "document_management"."document_request_assignment_task" ADD CONSTRAINT "document_request_assignment_task_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
269
- ALTER TABLE "document_management"."document_request_assignment_task_collection" ADD CONSTRAINT "document_request_assignment_task_collection_request_assignment_task_id_document_request_assignment_task_id_fk" FOREIGN KEY ("request_assignment_task_id") REFERENCES "document_management"."document_request_assignment_task"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
270
- ALTER TABLE "document_management"."document_request_assignment_task_collection" ADD CONSTRAINT "document_request_assignment_task_collection_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
271
- ALTER TABLE "document_management"."document_request_assignment_task_property_value" ADD CONSTRAINT "document_request_assignment_task_property_value_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
272
- ALTER TABLE "document_management"."document_request_assignment_task_property_value" ADD CONSTRAINT "document_request_assignment_task_property_value_request_assignment_task_id_document_request_assignment_task_id_fk" FOREIGN KEY ("request_assignment_task_id") REFERENCES "document_management"."document_request_assignment_task"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
273
- ALTER TABLE "document_management"."document_request_collection" ADD CONSTRAINT "document_request_collection_request_id_document_request_id_fk" FOREIGN KEY ("request_id") REFERENCES "document_management"."document_request"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
274
- ALTER TABLE "document_management"."document_request_collection" ADD CONSTRAINT "document_request_collection_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
275
- ALTER TABLE "document_management"."document_request_file" ADD CONSTRAINT "document_request_file_request_id_document_request_id_fk" FOREIGN KEY ("request_id") REFERENCES "document_management"."document_request"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
276
- ALTER TABLE "document_management"."document_request_file" ADD CONSTRAINT "document_request_file_file_id_document_file_id_fk" FOREIGN KEY ("file_id") REFERENCES "document_management"."document_file"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
277
- ALTER TABLE "document_management"."document_request_file" ADD CONSTRAINT "document_request_file_created_document_id_document_id_fk" FOREIGN KEY ("created_document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
278
- ALTER TABLE "document_management"."document_request_file_property_value" ADD CONSTRAINT "document_request_file_property_value_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
279
- ALTER TABLE "document_management"."document_request_file_property_value" ADD CONSTRAINT "document_request_file_property_value_request_file_id_document_request_file_id_fk" FOREIGN KEY ("request_file_id") REFERENCES "document_management"."document_request_file"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
298
+ ALTER TABLE "document_management"."document_request" ADD CONSTRAINT "document_request_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
299
+ ALTER TABLE "document_management"."document_request_collection_assignment" ADD CONSTRAINT "document_request_collection_assignment_request_id_document_request_id_fk" FOREIGN KEY ("request_id") REFERENCES "document_management"."document_request"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
300
+ ALTER TABLE "document_management"."document_request_collection_assignment" ADD CONSTRAINT "document_request_collection_assignment_collection_id_document_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "document_management"."document_collection"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
301
+ ALTER TABLE "document_management"."document_request_submission" ADD CONSTRAINT "document_request_submission_request_id_document_request_id_fk" FOREIGN KEY ("request_id") REFERENCES "document_management"."document_request"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
302
+ ALTER TABLE "document_management"."document_request_submission" ADD CONSTRAINT "document_request_submission_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
280
303
  ALTER TABLE "document_management"."document_request_template" ADD CONSTRAINT "document_request_template_requests_template_id_document_requests_template_id_fk" FOREIGN KEY ("requests_template_id") REFERENCES "document_management"."document_requests_template"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
281
304
  ALTER TABLE "document_management"."document_request_template" ADD CONSTRAINT "document_request_template_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
282
305
  ALTER TABLE "document_management"."document_type" ADD CONSTRAINT "document_type_category_id_document_category_id_fk" FOREIGN KEY ("category_id") REFERENCES "document_management"."document_category"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
283
306
  ALTER TABLE "document_management"."document_type_property" ADD CONSTRAINT "document_type_property_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
284
- ALTER TABLE "document_management"."document_type_property" ADD CONSTRAINT "document_type_property_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;
307
+ ALTER TABLE "document_management"."document_type_property" ADD CONSTRAINT "document_type_property_property_id_document_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "document_management"."document_property"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
308
+ ALTER TABLE "document_management"."document_type_validation" ADD CONSTRAINT "document_type_validation_type_id_document_type_id_fk" FOREIGN KEY ("type_id") REFERENCES "document_management"."document_type"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
309
+ ALTER TABLE "document_management"."document_type_validation" ADD CONSTRAINT "document_type_validation_validation_id_document_validation_definition_id_fk" FOREIGN KEY ("validation_id") REFERENCES "document_management"."document_validation_definition"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
310
+ ALTER TABLE "document_management"."document_validation_execution" ADD CONSTRAINT "document_validation_execution_workflow_id_document_workflow_id_fk" FOREIGN KEY ("workflow_id") REFERENCES "document_management"."document_workflow"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
311
+ ALTER TABLE "document_management"."document_validation_execution" ADD CONSTRAINT "document_validation_execution_definition_id_document_validation_definition_id_fk" FOREIGN KEY ("definition_id") REFERENCES "document_management"."document_validation_definition"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
312
+ ALTER TABLE "document_management"."document_validation_execution_related_document" ADD CONSTRAINT "document_validation_execution_related_document_execution_id_document_validation_execution_id_fk" FOREIGN KEY ("execution_id") REFERENCES "document_management"."document_validation_execution"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
313
+ ALTER TABLE "document_management"."document_validation_execution_related_document" ADD CONSTRAINT "document_validation_execution_related_document_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
314
+ ALTER TABLE "document_management"."document_workflow" ADD CONSTRAINT "document_workflow_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "document_management"."document"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
315
+ CREATE INDEX "document_request_state_idx" ON "document_management"."document_request" USING btree ("state");--> statement-breakpoint
316
+ CREATE UNIQUE INDEX "document_workflow_document_id_idx" ON "document_management"."document_workflow" USING btree ("document_id") WHERE "document_management"."document_workflow"."state" <> 'completed';