@tstdl/base 0.92.86 → 0.92.88

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 (112) hide show
  1. package/ai/ai-file.service.js +8 -13
  2. package/ai/ai.service.d.ts +3 -3
  3. package/ai/ai.service.js +24 -11
  4. package/ai/types.d.ts +4 -3
  5. package/api/server/gateway.js +1 -1
  6. package/authentication/server/authentication-ancillary.service.d.ts +6 -4
  7. package/authentication/server/authentication-ancillary.service.js +5 -5
  8. package/context/context.d.ts +1 -9
  9. package/context/context.js +8 -5
  10. package/document-management/api/document-management.api.d.ts +48 -16
  11. package/document-management/models/document-category.model.d.ts +1 -1
  12. package/document-management/models/document-category.model.js +2 -0
  13. package/document-management/models/document-collection-document.model.js +7 -3
  14. package/document-management/models/document-property-value.model.d.ts +13 -14
  15. package/document-management/models/document-property-value.model.js +60 -27
  16. package/document-management/models/document-property.model.d.ts +2 -0
  17. package/document-management/models/document-property.model.js +4 -1
  18. package/document-management/models/document-request-assignment-task-collection.model.d.ts +7 -0
  19. package/document-management/models/{document-index.model.js → document-request-assignment-task-collection.model.js} +16 -16
  20. package/document-management/models/document-request-assignment-task.model.d.ts +14 -0
  21. package/document-management/models/document-request-assignment-task.model.js +72 -0
  22. package/document-management/models/document-request-collection.model.d.ts +1 -0
  23. package/document-management/models/document-request-collection.model.js +7 -3
  24. package/document-management/models/document-request-file.model.d.ts +6 -1
  25. package/document-management/models/document-request-file.model.js +27 -2
  26. package/document-management/models/document-request.model.d.ts +1 -0
  27. package/document-management/models/document-requests-template.js +2 -0
  28. package/document-management/models/document-type-property.model.js +7 -3
  29. package/document-management/models/document-type.model.d.ts +1 -1
  30. package/document-management/models/document-type.model.js +7 -3
  31. package/document-management/models/document.model.d.ts +4 -1
  32. package/document-management/models/document.model.js +19 -4
  33. package/document-management/models/index.d.ts +2 -0
  34. package/document-management/models/index.js +2 -0
  35. package/document-management/models/service-models/document.service-model.d.ts +35 -16
  36. package/document-management/models/service-models/document.service-model.js +11 -6
  37. package/document-management/models/service-models/document.view-model.d.ts +1 -1
  38. package/document-management/models/service-models/document.view-model.js +2 -2
  39. package/document-management/server/drizzle/{0000_useful_overlord.sql → 0000_cool_victor_mancha.sql} +97 -41
  40. package/document-management/server/drizzle/meta/0000_snapshot.json +514 -126
  41. package/document-management/server/drizzle/meta/_journal.json +2 -2
  42. package/document-management/server/index.d.ts +1 -0
  43. package/document-management/server/index.js +1 -0
  44. package/document-management/server/module.d.ts +2 -1
  45. package/document-management/server/module.js +3 -1
  46. package/document-management/server/schemas.d.ts +14 -11
  47. package/document-management/server/schemas.js +13 -10
  48. package/document-management/server/services/document-management-ancillary.service.d.ts +4 -0
  49. package/document-management/server/services/document-management-ancillary.service.js +13 -0
  50. package/document-management/server/services/document-management.service.d.ts +63 -28
  51. package/document-management/server/services/document-management.service.js +507 -108
  52. package/document-management/server/services/index.d.ts +1 -0
  53. package/document-management/server/services/index.js +1 -0
  54. package/eslint.config.js +1 -0
  55. package/examples/document-management/main.d.ts +5 -0
  56. package/examples/document-management/main.js +20 -2
  57. package/file/index.d.ts +1 -0
  58. package/file/index.js +1 -0
  59. package/file/temporary-file.d.ts +18 -0
  60. package/file/temporary-file.js +53 -0
  61. package/http/server/http-server-response.d.ts +2 -0
  62. package/http/server/http-server-response.js +13 -0
  63. package/injector/index.d.ts +1 -0
  64. package/injector/index.js +1 -0
  65. package/injector/injector.js +19 -7
  66. package/injector/interfaces.d.ts +1 -1
  67. package/injector/interfaces.js +1 -1
  68. package/injector/resolution.d.ts +15 -0
  69. package/injector/resolution.js +6 -0
  70. package/logger/console/logger.d.ts +1 -1
  71. package/logger/logger.d.ts +1 -1
  72. package/object-storage/object-storage.d.ts +5 -7
  73. package/object-storage/s3/s3.object-storage.d.ts +0 -1
  74. package/object-storage/s3/s3.object-storage.js +0 -3
  75. package/orm/{server/data-types → data-types}/numeric-date.js +2 -3
  76. package/orm/decorators.d.ts +13 -4
  77. package/orm/decorators.js +13 -7
  78. package/orm/entity.js +3 -7
  79. package/orm/index.d.ts +1 -0
  80. package/orm/index.js +1 -0
  81. package/orm/server/drizzle/schema-converter.js +48 -19
  82. package/orm/server/repository.d.ts +5 -4
  83. package/orm/server/repository.js +33 -22
  84. package/orm/server/sqls.d.ts +9 -1
  85. package/orm/server/sqls.js +13 -0
  86. package/orm/types.d.ts +3 -3
  87. package/orm/utils.d.ts +3 -0
  88. package/orm/utils.js +6 -0
  89. package/package.json +13 -11
  90. package/pdf/pdf.service.d.ts +0 -1
  91. package/pdf/pdf.service.js +1 -95
  92. package/pdf/utils.d.ts +3 -1
  93. package/pdf/utils.js +129 -4
  94. package/promise/lazy-promise.d.ts +3 -3
  95. package/queue/postgres/module.d.ts +1 -1
  96. package/queue/postgres/queue.js +10 -12
  97. package/queue/queue.d.ts +14 -0
  98. package/queue/queue.js +43 -0
  99. package/utils/date-time.d.ts +4 -2
  100. package/utils/date-time.js +10 -3
  101. package/utils/format-error.js +0 -1
  102. package/utils/object/lazy-property.js +0 -1
  103. package/utils/try-ignore.d.ts +9 -2
  104. package/utils/try-ignore.js +30 -6
  105. package/document-management/models/document-index.model.d.ts +0 -7
  106. /package/orm/{server/data-types → data-types}/bytea.d.ts +0 -0
  107. /package/orm/{server/data-types → data-types}/bytea.js +0 -0
  108. /package/orm/{server/data-types → data-types}/index.d.ts +0 -0
  109. /package/orm/{server/data-types → data-types}/index.js +0 -0
  110. /package/orm/{server/data-types → data-types}/numeric-date.d.ts +0 -0
  111. /package/orm/{server/data-types → data-types}/timestamp.d.ts +0 -0
  112. /package/orm/{server/data-types → data-types}/timestamp.js +0 -0
@@ -8,7 +8,6 @@ export declare const metadataParameterObjectSchema: import("../../../schema/inde
8
8
  }> | undefined;
9
9
  }>;
10
10
  export declare const setDocumentPropertyParametersSchema: import("../../../schema/index.js").ObjectSchema<{
11
- documentId: import("../../../orm/schemas/uuid.js").Uuid;
12
11
  propertyId: import("../../../orm/schemas/uuid.js").Uuid;
13
12
  value: unknown;
14
13
  metadata?: Partial<{
@@ -17,17 +16,20 @@ export declare const setDocumentPropertyParametersSchema: import("../../../schem
17
16
  }>;
18
17
  export declare const createDocumentParametersSchema: import("../../../schema/index.js").ObjectSchema<{
19
18
  date: import("../../../orm/schemas/numeric-date.js").NumericDate | null;
19
+ summary: string | null;
20
20
  title: string | null;
21
- expiration: import("../../../orm/schemas/numeric-date.js").NumericDate | null;
21
+ tags: string[] | null;
22
22
  typeId: import("../../../orm/schemas/uuid.js").Uuid | null;
23
+ subtitle: string | null;
24
+ pages: number | null;
23
25
  originalFileName: string | null;
24
26
  collectionIds: string | string[];
25
27
  properties?: {
28
+ propertyId: import("../../../orm/schemas/uuid.js").Uuid;
26
29
  value: unknown;
27
30
  metadata?: Partial<{
28
31
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
29
32
  }> | undefined;
30
- propertyId: import("../../../orm/schemas/uuid.js").Uuid;
31
33
  }[] | undefined;
32
34
  metadata?: Partial<{
33
35
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -36,16 +38,19 @@ export declare const createDocumentParametersSchema: import("../../../schema/ind
36
38
  export declare const updateDocumentParametersSchema: import("../../../schema/index.js").ObjectSchema<{
37
39
  id: import("../../../orm/types.js").IsPrimaryKey<import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/uuid.js").Uuid>>;
38
40
  date?: import("../../../orm/types.js").NumericDate | null | undefined;
41
+ summary?: string | null | undefined;
39
42
  title?: string | null | undefined;
40
- expiration?: import("../../../orm/types.js").NumericDate | null | undefined;
43
+ tags?: string[] | null | undefined;
41
44
  fileId?: import("../../../orm/types.js").Uuid | undefined;
42
45
  typeId?: import("../../../orm/types.js").Uuid | null | undefined;
46
+ subtitle?: string | null | undefined;
47
+ pages?: number | null | undefined;
43
48
  properties?: {
49
+ propertyId: import("../../../orm/schemas/uuid.js").Uuid;
44
50
  value: unknown;
45
51
  metadata?: Partial<{
46
52
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
47
53
  }> | undefined;
48
- propertyId: import("../../../orm/schemas/uuid.js").Uuid;
49
54
  }[] | undefined;
50
55
  metadata?: Partial<{
51
56
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -80,9 +85,9 @@ export declare const deleteDocumentRequestsTemplateParametersSchema: import("../
80
85
  }> | undefined;
81
86
  }>;
82
87
  export declare const createDocumentRequestTemplateParametersSchema: import("../../../schema/index.js").ObjectSchema<{
83
- comment: string | null;
84
88
  typeId: import("../../../orm/schemas/uuid.js").Uuid | null;
85
89
  requiredFilesCount: number;
90
+ comment: string | null;
86
91
  requestsTemplateId: import("../../../orm/schemas/uuid.js").Uuid;
87
92
  metadata?: Partial<{
88
93
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -90,9 +95,9 @@ export declare const createDocumentRequestTemplateParametersSchema: import("../.
90
95
  }>;
91
96
  export declare const updateDocumentRequestTemplateParametersSchema: import("../../../schema/index.js").ObjectSchema<{
92
97
  id: import("../../../orm/types.js").IsPrimaryKey<import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/uuid.js").Uuid>>;
93
- comment?: string | null | undefined;
94
98
  typeId?: import("../../../orm/types.js").Uuid | null | undefined;
95
99
  requiredFilesCount?: number | undefined;
100
+ comment?: string | null | undefined;
96
101
  metadata?: Partial<{
97
102
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
98
103
  }> | undefined;
@@ -104,9 +109,9 @@ export declare const deleteDocumentRequestTemplateParametersSchema: import("../.
104
109
  }> | undefined;
105
110
  }>;
106
111
  export declare const createDocumentRequestParametersSchema: import("../../../schema/index.js").ObjectSchema<{
107
- comment: string | null;
108
112
  typeId: import("../../../orm/schemas/uuid.js").Uuid | null;
109
113
  requiredFilesCount: number;
114
+ comment: string | null;
110
115
  collectionIds: string[];
111
116
  metadata?: Partial<{
112
117
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -114,9 +119,9 @@ export declare const createDocumentRequestParametersSchema: import("../../../sch
114
119
  }>;
115
120
  export declare const updateDocumentRequestParametersSchema: import("../../../schema/index.js").ObjectSchema<{
116
121
  id: import("../../../orm/types.js").IsPrimaryKey<import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/uuid.js").Uuid>>;
117
- comment?: string | null | undefined;
118
122
  typeId?: import("../../../orm/types.js").Uuid | null | undefined;
119
123
  requiredFilesCount?: number | undefined;
124
+ comment?: string | null | undefined;
120
125
  completed?: boolean | undefined;
121
126
  metadata?: Partial<{
122
127
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -130,7 +135,12 @@ export declare const deleteDocumentRequestParametersSchema: import("../../../sch
130
135
  }>;
131
136
  export declare const updateDocumentRequestFileParametersSchema: import("../../../schema/index.js").ObjectSchema<{
132
137
  id: import("../../../orm/types.js").IsPrimaryKey<import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/uuid.js").Uuid>>;
138
+ date?: import("../../../orm/types.js").NumericDate | null | undefined;
139
+ summary?: string | null | undefined;
133
140
  title?: string | null | undefined;
141
+ tags?: string[] | null | undefined;
142
+ subtitle?: string | null | undefined;
143
+ pages?: number | null | undefined;
134
144
  approvalComment?: string | null | undefined;
135
145
  approvalTimestamp?: import("../../../orm/types.js").Timestamp | null | undefined;
136
146
  metadata?: Partial<{
@@ -163,13 +173,17 @@ export declare const createCollectionParametersSchema: import("../../../schema/i
163
173
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
164
174
  }> | undefined;
165
175
  }>;
166
- export declare const setDocumentPropertiesParametersSchema: import("../../../schema/index.js").ArraySchema<{
167
- documentId: import("../../../orm/schemas/uuid.js").Uuid;
168
- propertyId: import("../../../orm/schemas/uuid.js").Uuid;
169
- value: unknown;
170
- metadata?: Partial<{
171
- attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
172
- }> | undefined;
176
+ export declare const setDocumentPropertiesParametersSchema: import("../../../schema/index.js").ObjectSchema<{
177
+ properties: {
178
+ propertyId: import("../../../orm/schemas/uuid.js").Uuid;
179
+ value: unknown;
180
+ metadata?: Partial<{
181
+ attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
182
+ }> | undefined;
183
+ }[];
184
+ documentId?: string | undefined;
185
+ requestFileId?: string | undefined;
186
+ requestAssignmentTaskId?: string | undefined;
173
187
  }>;
174
188
  export declare const createDocumentCategoryParametersSchema: import("../../../schema/index.js").ObjectSchema<{
175
189
  label: string;
@@ -187,7 +201,12 @@ export declare const createDocumentTypeParametersSchema: import("../../../schema
187
201
  }>;
188
202
  export declare const createDocumentRequestFileParametersSchema: import("../../../schema/index.js").ObjectSchema<{
189
203
  requestId: string;
204
+ date: import("../../../orm/schemas/numeric-date.js").NumericDate | null;
205
+ summary: string | null;
190
206
  title: string | null;
207
+ tags: string[] | null;
208
+ subtitle: string | null;
209
+ pages: number | null;
191
210
  originalFileName: string | null;
192
211
  metadata?: Partial<{
193
212
  attributes: import("../../../orm/types.js").HasDefault<import("../../../orm/schemas/json.js").Json<import("../../../orm/entity.js").EntityMetadataAttributes>>;
@@ -14,12 +14,12 @@ import { DocumentType } from '../document-type.model.js';
14
14
  import { Document } from '../document.model.js';
15
15
  export const metadataParameterSchema = optional(partial(pick(EntityMetadata, 'attributes')));
16
16
  export const metadataParameterObjectSchema = object({ metadata: metadataParameterSchema });
17
- export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValueBase, ['documentId', 'propertyId']), object({ value: unknown() }), metadataParameterObjectSchema);
18
- export const createDocumentParametersSchema = assign(pick(Document, ['typeId', 'title', 'date', 'expiration']), pick(DocumentFile, ['originalFileName']), object({
17
+ export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValueBase, ['propertyId']), object({ value: unknown() }), metadataParameterObjectSchema);
18
+ export const createDocumentParametersSchema = assign(pick(Document, ['typeId', 'title', 'subtitle', 'pages', 'date', 'summary', 'tags']), pick(DocumentFile, ['originalFileName']), object({
19
19
  collectionIds: oneOrMany(string()),
20
- properties: optional(array(omit(setDocumentPropertyParametersSchema, ['documentId'])))
20
+ properties: optional(array(setDocumentPropertyParametersSchema))
21
21
  }), metadataParameterObjectSchema);
22
- export const updateDocumentParametersSchema = assign(pick(Document, ['id']), partial(omit(Document, ['id', 'metadata'])), object({ properties: optional(array(omit(setDocumentPropertyParametersSchema, ['documentId']))) }), metadataParameterObjectSchema);
22
+ export const updateDocumentParametersSchema = assign(pick(Document, ['id']), partial(omit(Document, ['id', 'metadata'])), object({ properties: optional(array(setDocumentPropertyParametersSchema)) }), metadataParameterObjectSchema);
23
23
  export const createDocumentRequestsTemplateParametersSchema = assign(pick(DocumentRequestsTemplate, ['label', 'description']), metadataParameterObjectSchema);
24
24
  export const updateDocumentRequestsTemplateParametersSchema = assign(pick(DocumentRequestsTemplate, ['id']), partial(omit(DocumentRequestsTemplate, ['id', 'metadata'])), metadataParameterObjectSchema);
25
25
  export const applyDocumentRequestsTemplateParametersSchema = assign(pick(DocumentRequestsTemplate, ['id']), object({ collectionIds: array(string()) }), metadataParameterObjectSchema);
@@ -36,10 +36,15 @@ export const loadDataCollectionMetadataParametersSchema = object({ name: optiona
36
36
  export const loadDataCollectionsMetadataParametersSchema = record(string(), loadDataCollectionMetadataParametersSchema);
37
37
  export const loadDataParametersSchema = object({ collectionIds: oneOrMany(string()), collectionsMetadata: loadDataCollectionsMetadataParametersSchema });
38
38
  export const createCollectionParametersSchema = metadataParameterObjectSchema;
39
- export const setDocumentPropertiesParametersSchema = array(setDocumentPropertyParametersSchema);
39
+ export const setDocumentPropertiesParametersSchema = object({
40
+ documentId: optional(string()),
41
+ requestFileId: optional(string()),
42
+ requestAssignmentTaskId: optional(string()),
43
+ properties: array(setDocumentPropertyParametersSchema)
44
+ });
40
45
  export const createDocumentCategoryParametersSchema = assign(pick(DocumentCategory, ['label']), metadataParameterObjectSchema);
41
46
  export const createDocumentTypeParametersSchema = assign(pick(DocumentType, ['categoryId', 'group', 'label']), metadataParameterObjectSchema);
42
- export const createDocumentRequestFileParametersSchema = assign(object({ requestId: string() }), pick(DocumentRequestFile, ['title']), pick(DocumentFile, ['originalFileName']), metadataParameterObjectSchema);
47
+ export const createDocumentRequestFileParametersSchema = assign(object({ requestId: string() }), pick(DocumentRequestFile, ['title', 'subtitle', 'pages', 'date', 'summary', 'tags']), pick(DocumentFile, ['originalFileName']), metadataParameterObjectSchema);
43
48
  export const approveDocumentRequestFileParametersSchema = assign(pick(DocumentRequestFile, ['id', 'approvalComment']), object({
44
49
  documentMetadata: metadataParameterSchema,
45
50
  requestFileMetadata: metadataParameterSchema
@@ -2,7 +2,7 @@ import { Timestamp } from '../../../orm/types.js';
2
2
  import { DocumentCategory } from '../document-category.model.js';
3
3
  import { DocumentCollection } from '../document-collection.model.js';
4
4
  import { DocumentFile } from '../document-file.model.js';
5
- import { type DocumentPropertyValue } from '../document-property-value.model.js';
5
+ import { DocumentPropertyValue } from '../document-property-value.model.js';
6
6
  import { DocumentRequestFile } from '../document-request-file.model.js';
7
7
  import { DocumentRequest } from '../document-request.model.js';
8
8
  import { DocumentType } from '../document-type.model.js';
@@ -12,7 +12,7 @@ import { Array, StringProperty } from '../../../schema/index.js';
12
12
  import { DocumentCategory } from '../document-category.model.js';
13
13
  import { DocumentCollection } from '../document-collection.model.js';
14
14
  import { DocumentFile } from '../document-file.model.js';
15
- import { documentPropertyValueSchema } from '../document-property-value.model.js';
15
+ import { DocumentPropertyValue } from '../document-property-value.model.js';
16
16
  import { DocumentRequestFile } from '../document-request-file.model.js';
17
17
  import { DocumentRequest } from '../document-request.model.js';
18
18
  import { DocumentType } from '../document-type.model.js';
@@ -50,7 +50,7 @@ __decorate([
50
50
  __metadata("design:type", Array)
51
51
  ], DocumentView.prototype, "collectionAssignments", void 0);
52
52
  __decorate([
53
- Array(documentPropertyValueSchema),
53
+ Array(DocumentPropertyValue),
54
54
  __metadata("design:type", Array)
55
55
  ], DocumentView.prototype, "properties", void 0);
56
56
  export class DocumentRequestView extends DocumentRequest {
@@ -1,11 +1,14 @@
1
- CREATE TYPE "document_management"."document_property_data_type" AS ENUM('text', 'integer', 'decimal', 'boolean');--> statement-breakpoint
1
+ CREATE TYPE "document_management"."document_property_data_type" AS ENUM('text', 'integer', 'decimal', 'boolean', 'date');--> statement-breakpoint
2
2
  CREATE TABLE "document_management"."document" (
3
3
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4
4
  "file_id" uuid NOT NULL,
5
5
  "type_id" uuid,
6
6
  "title" text,
7
+ "subtitle" text,
8
+ "pages" integer,
7
9
  "date" date,
8
- "expiration" date,
10
+ "summary" text,
11
+ "tags" text[],
9
12
  "revision" integer NOT NULL,
10
13
  "revision_timestamp" timestamp with time zone NOT NULL,
11
14
  "create_timestamp" timestamp with time zone NOT NULL,
@@ -20,7 +23,8 @@ CREATE TABLE "document_management"."document_category" (
20
23
  "revision_timestamp" timestamp with time zone NOT NULL,
21
24
  "create_timestamp" timestamp with time zone NOT NULL,
22
25
  "delete_timestamp" timestamp with time zone,
23
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
26
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
27
+ CONSTRAINT "document_category_label_unique" UNIQUE("label")
24
28
  );
25
29
  --> statement-breakpoint
26
30
  CREATE TABLE "document_management"."document_collection" (
@@ -41,7 +45,8 @@ CREATE TABLE "document_management"."document_collection_document" (
41
45
  "revision_timestamp" timestamp with time zone NOT NULL,
42
46
  "create_timestamp" timestamp with time zone NOT NULL,
43
47
  "delete_timestamp" timestamp with time zone,
44
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
48
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
49
+ CONSTRAINT "document_collection_document_collection_id_document_id_unique" UNIQUE("collection_id","document_id")
45
50
  );
46
51
  --> statement-breakpoint
47
52
  CREATE TABLE "document_management"."document_file" (
@@ -65,26 +70,34 @@ CREATE TABLE "document_management"."document_property" (
65
70
  "revision_timestamp" timestamp with time zone NOT NULL,
66
71
  "create_timestamp" timestamp with time zone NOT NULL,
67
72
  "delete_timestamp" timestamp with time zone,
68
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
73
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
74
+ CONSTRAINT "document_property_label_unique" UNIQUE("label")
69
75
  );
70
76
  --> statement-breakpoint
71
- CREATE TABLE "document_management"."document_property_boolean_value" (
77
+ CREATE TABLE "document_management"."document_property_value" (
72
78
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
73
- "document_id" uuid NOT NULL,
74
79
  "property_id" uuid NOT NULL,
75
- "value" boolean,
80
+ "text" text,
81
+ "integer" integer,
82
+ "decimal" double precision,
83
+ "boolean" boolean,
84
+ "date" date,
85
+ "document_id" uuid NOT NULL,
76
86
  "revision" integer NOT NULL,
77
87
  "revision_timestamp" timestamp with time zone NOT NULL,
78
88
  "create_timestamp" timestamp with time zone NOT NULL,
79
89
  "delete_timestamp" timestamp with time zone,
80
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
90
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
91
+ CONSTRAINT "document_property_value_document_id_property_id_unique" UNIQUE("document_id","property_id"),
92
+ CONSTRAINT "only_one_value" CHECK (num_nonnulls("document_management"."document_property_value"."text", "document_management"."document_property_value"."integer", "document_management"."document_property_value"."decimal", "document_management"."document_property_value"."boolean", "document_management"."document_property_value"."date") = 1)
81
93
  );
82
94
  --> statement-breakpoint
83
- CREATE TABLE "document_management"."document_property_decimal_value" (
95
+ CREATE TABLE "document_management"."document_request" (
84
96
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
85
- "document_id" uuid NOT NULL,
86
- "property_id" uuid NOT NULL,
87
- "value" double precision,
97
+ "type_id" uuid,
98
+ "required_files_count" integer NOT NULL,
99
+ "comment" text,
100
+ "completed" boolean NOT NULL,
88
101
  "revision" integer NOT NULL,
89
102
  "revision_timestamp" timestamp with time zone NOT NULL,
90
103
  "create_timestamp" timestamp with time zone NOT NULL,
@@ -92,41 +105,54 @@ CREATE TABLE "document_management"."document_property_decimal_value" (
92
105
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
93
106
  );
94
107
  --> statement-breakpoint
95
- CREATE TABLE "document_management"."document_property_integer_value" (
108
+ CREATE TABLE "document_management"."document_request_assignment_task" (
96
109
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
97
- "document_id" uuid NOT NULL,
98
- "property_id" uuid NOT NULL,
99
- "value" integer,
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,
100
120
  "revision" integer NOT NULL,
101
121
  "revision_timestamp" timestamp with time zone NOT NULL,
102
122
  "create_timestamp" timestamp with time zone NOT NULL,
103
123
  "delete_timestamp" timestamp with time zone,
104
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
124
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
125
+ CONSTRAINT "drat_file_id_unique" UNIQUE("file_id")
105
126
  );
106
127
  --> statement-breakpoint
107
- CREATE TABLE "document_management"."document_property_text_value" (
128
+ CREATE TABLE "document_management"."document_request_assignment_task_collection" (
108
129
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
109
- "document_id" uuid NOT NULL,
110
- "property_id" uuid NOT NULL,
111
- "value" text,
130
+ "request_assignment_task_id" uuid NOT NULL,
131
+ "collection_id" uuid NOT NULL,
112
132
  "revision" integer NOT NULL,
113
133
  "revision_timestamp" timestamp with time zone NOT NULL,
114
134
  "create_timestamp" timestamp with time zone NOT NULL,
115
135
  "delete_timestamp" timestamp with time zone,
116
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
136
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
137
+ CONSTRAINT "dratc_request_assignment_task_id_collection_id_unique" UNIQUE("request_assignment_task_id","collection_id")
117
138
  );
118
139
  --> statement-breakpoint
119
- CREATE TABLE "document_management"."document_request" (
140
+ CREATE TABLE "document_management"."document_request_assignment_task_property_value" (
120
141
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
121
- "type_id" uuid,
122
- "required_files_count" integer NOT NULL,
123
- "comment" text,
124
- "completed" boolean 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,
125
149
  "revision" integer NOT NULL,
126
150
  "revision_timestamp" timestamp with time zone NOT NULL,
127
151
  "create_timestamp" timestamp with time zone NOT NULL,
128
152
  "delete_timestamp" timestamp with time zone,
129
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
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)
130
156
  );
131
157
  --> statement-breakpoint
132
158
  CREATE TABLE "document_management"."document_request_collection" (
@@ -137,7 +163,8 @@ CREATE TABLE "document_management"."document_request_collection" (
137
163
  "revision_timestamp" timestamp with time zone NOT NULL,
138
164
  "create_timestamp" timestamp with time zone NOT NULL,
139
165
  "delete_timestamp" timestamp with time zone,
140
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
166
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
167
+ CONSTRAINT "document_request_collection_request_id_collection_id_unique" UNIQUE("request_id","collection_id")
141
168
  );
142
169
  --> statement-breakpoint
143
170
  CREATE TABLE "document_management"."document_request_file" (
@@ -145,6 +172,11 @@ CREATE TABLE "document_management"."document_request_file" (
145
172
  "request_id" uuid NOT NULL,
146
173
  "file_id" uuid NOT NULL,
147
174
  "title" text,
175
+ "subtitle" text,
176
+ "pages" integer,
177
+ "date" date,
178
+ "summary" text,
179
+ "tags" text[],
148
180
  "created_document_id" uuid,
149
181
  "approval" boolean,
150
182
  "approval_comment" text,
@@ -156,6 +188,24 @@ CREATE TABLE "document_management"."document_request_file" (
156
188
  "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
157
189
  );
158
190
  --> statement-breakpoint
191
+ CREATE TABLE "document_management"."document_request_file_property_value" (
192
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
193
+ "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
+ "revision" integer NOT NULL,
201
+ "revision_timestamp" timestamp with time zone NOT NULL,
202
+ "create_timestamp" timestamp with time zone NOT NULL,
203
+ "delete_timestamp" timestamp with time zone,
204
+ "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)
207
+ );
208
+ --> statement-breakpoint
159
209
  CREATE TABLE "document_management"."document_request_template" (
160
210
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
161
211
  "requests_template_id" uuid NOT NULL,
@@ -177,7 +227,8 @@ CREATE TABLE "document_management"."document_requests_template" (
177
227
  "revision_timestamp" timestamp with time zone NOT NULL,
178
228
  "create_timestamp" timestamp with time zone NOT NULL,
179
229
  "delete_timestamp" timestamp with time zone,
180
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
230
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
231
+ CONSTRAINT "document_requests_template_label_unique" UNIQUE("label")
181
232
  );
182
233
  --> statement-breakpoint
183
234
  CREATE TABLE "document_management"."document_type" (
@@ -189,7 +240,8 @@ CREATE TABLE "document_management"."document_type" (
189
240
  "revision_timestamp" timestamp with time zone NOT NULL,
190
241
  "create_timestamp" timestamp with time zone NOT NULL,
191
242
  "delete_timestamp" timestamp with time zone,
192
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
243
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
244
+ CONSTRAINT "document_type_category_id_label_unique" UNIQUE("category_id","label")
193
245
  );
194
246
  --> statement-breakpoint
195
247
  CREATE TABLE "document_management"."document_type_property" (
@@ -200,27 +252,31 @@ CREATE TABLE "document_management"."document_type_property" (
200
252
  "revision_timestamp" timestamp with time zone NOT NULL,
201
253
  "create_timestamp" timestamp with time zone NOT NULL,
202
254
  "delete_timestamp" timestamp with time zone,
203
- "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL
255
+ "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
256
+ CONSTRAINT "document_type_property_type_id_property_id_unique" UNIQUE("type_id","property_id")
204
257
  );
205
258
  --> statement-breakpoint
206
259
  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
207
260
  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
208
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
209
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
210
- ALTER TABLE "document_management"."document_property_boolean_value" ADD CONSTRAINT "document_property_boolean_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
211
- ALTER TABLE "document_management"."document_property_boolean_value" ADD CONSTRAINT "document_property_boolean_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
212
- ALTER TABLE "document_management"."document_property_decimal_value" ADD CONSTRAINT "document_property_decimal_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
213
- ALTER TABLE "document_management"."document_property_decimal_value" ADD CONSTRAINT "document_property_decimal_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
214
- ALTER TABLE "document_management"."document_property_integer_value" ADD CONSTRAINT "document_property_integer_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
215
- ALTER TABLE "document_management"."document_property_integer_value" ADD CONSTRAINT "document_property_integer_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
216
- ALTER TABLE "document_management"."document_property_text_value" ADD CONSTRAINT "document_property_text_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
217
- ALTER TABLE "document_management"."document_property_text_value" ADD CONSTRAINT "document_property_text_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
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
264
+ 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
218
265
  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
219
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
220
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
221
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
222
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
223
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
224
280
  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
225
281
  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
226
282
  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