@tstdl/base 0.92.128 → 0.92.130

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.
@@ -89,15 +89,14 @@ export declare const documentManagementApiDefinition: {
89
89
  resource: string;
90
90
  method: "POST";
91
91
  parameters: import("../../schema/index.js").ObjectSchema<{
92
- date: import("../../orm/schemas/numeric-date.js").NumericDate | null;
93
- summary: string | null;
94
- title: string | null;
95
- typeId: import("../../orm/schemas/uuid.js").Uuid | null;
96
- subtitle: string | null;
97
- tags: string[] | null;
98
- comment: string | null;
99
- approval: import("../models/document.model.js").DocumentApproval;
100
- createUserId: import("../../orm/schemas/uuid.js").Uuid | null;
92
+ date?: import("../../orm/types.js").NumericDate | null | undefined;
93
+ summary?: string | null | undefined;
94
+ title?: string | null | undefined;
95
+ typeId?: import("../../orm/types.js").Uuid | null | undefined;
96
+ subtitle?: string | null | undefined;
97
+ tags?: string[] | null | undefined;
98
+ comment?: string | null | undefined;
99
+ approval?: import("../models/document.model.js").DocumentApproval | undefined;
101
100
  originalFileName: string | null;
102
101
  assignment: {
103
102
  collections: string | string[];
@@ -403,15 +402,14 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
403
402
  resource: string;
404
403
  method: "POST";
405
404
  parameters: import("../../schema/index.js").ObjectSchema<{
406
- date: import("../../orm/schemas/numeric-date.js").NumericDate | null;
407
- summary: string | null;
408
- title: string | null;
409
- typeId: import("../../orm/schemas/uuid.js").Uuid | null;
410
- subtitle: string | null;
411
- tags: string[] | null;
412
- comment: string | null;
413
- approval: import("../models/document.model.js").DocumentApproval;
414
- createUserId: import("../../orm/schemas/uuid.js").Uuid | null;
405
+ date?: import("../../orm/types.js").NumericDate | null | undefined;
406
+ summary?: string | null | undefined;
407
+ title?: string | null | undefined;
408
+ typeId?: import("../../orm/types.js").Uuid | null | undefined;
409
+ subtitle?: string | null | undefined;
410
+ tags?: string[] | null | undefined;
411
+ comment?: string | null | undefined;
412
+ approval?: import("../models/document.model.js").DocumentApproval | undefined;
415
413
  originalFileName: string | null;
416
414
  assignment: {
417
415
  collections: string | string[];
@@ -5,7 +5,9 @@ import { Document } from '../../models/index.js';
5
5
  export declare class DocumentService extends Transactional {
6
6
  #private;
7
7
  readonly repository: import("../../../orm/server/repository.js").EntityRepository<Document>;
8
- createDocument({ typeId, title, subtitle, date, summary, tags, approval, comment, createUserId, originalFileName, assignment, properties, metadata }: CreateDocumentParameters, content: Uint8Array | ReadableStream<Uint8Array>): Promise<Document>;
8
+ createDocument({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: CreateDocumentParameters, content: Uint8Array | ReadableStream<Uint8Array>, { createUserId }: {
9
+ createUserId?: string;
10
+ }): Promise<Document>;
9
11
  updateDocument(id: string, update: Partial<Pick<Document, UpdatableDocumentProperties>> & {
10
12
  properties?: SetDocumentPropertyParameters[];
11
13
  }): Promise<void>;
@@ -27,11 +27,24 @@ export class DocumentService extends Transactional {
27
27
  #documentAssignmentScopeRepository = injectRepository(DocumentAssignmentScope);
28
28
  #logger = inject(Logger, _a.name);
29
29
  repository = injectRepository(Document).withSession(this.session);
30
- async createDocument({ typeId, title, subtitle, date, summary, tags, approval, comment, createUserId, originalFileName, assignment, properties, metadata }, content) {
30
+ async createDocument({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }, content, { createUserId }) {
31
31
  const document = await this.transaction(async (tx) => {
32
32
  const documentFile = await this.#documentFileService.withTransaction(tx).create(content, originalFileName);
33
33
  const pages = documentFile.mimeType.includes('pdf') ? await tryIgnoreLogAsync(this.#logger, async () => getPdfPageCount(content), null) : null;
34
- const document = await this.repository.withTransaction(tx).insert({ fileId: documentFile.id, typeId, title, subtitle, pages, date, summary, tags, metadata, approval, comment, createUserId });
34
+ const document = await this.repository.withTransaction(tx).insert({
35
+ fileId: documentFile.id,
36
+ typeId: typeId ?? null,
37
+ title: title ?? null,
38
+ subtitle: subtitle ?? null,
39
+ pages,
40
+ date: date ?? null,
41
+ summary: summary ?? null,
42
+ tags: tags ?? null,
43
+ approval: approval ?? DocumentApproval.Pending,
44
+ comment: comment ?? null,
45
+ createUserId: createUserId ?? null,
46
+ metadata,
47
+ });
35
48
  if (isDefined(properties)) {
36
49
  await this.#documentPropertyService.withTransaction(tx).setPropertyValues(document.id, properties);
37
50
  }
@@ -7,14 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { Array } from '../../schema/index.js';
10
+ import { Array, deferred } from '../../schema/index.js';
11
11
  import { DocumentCategory, DocumentType } from '../models/index.js';
12
12
  export class DocumentCategoryView extends DocumentCategory {
13
13
  children;
14
14
  types;
15
15
  }
16
16
  __decorate([
17
- Array(DocumentCategoryView),
17
+ Array(deferred(() => DocumentCategoryView)),
18
18
  __metadata("design:type", Array)
19
19
  ], DocumentCategoryView.prototype, "children", void 0);
20
20
  __decorate([
@@ -15,15 +15,14 @@ export declare const setDocumentPropertyParametersSchema: import("../../schema/i
15
15
  }> | undefined;
16
16
  }>;
17
17
  export declare const createDocumentParametersSchema: import("../../schema/index.js").ObjectSchema<{
18
- date: import("../../orm/schemas/numeric-date.js").NumericDate | null;
19
- summary: string | null;
20
- title: string | null;
21
- typeId: import("../../orm/schemas/uuid.js").Uuid | null;
22
- subtitle: string | null;
23
- tags: string[] | null;
24
- comment: string | null;
25
- approval: import("../models/document.model.js").DocumentApproval;
26
- createUserId: import("../../orm/schemas/uuid.js").Uuid | null;
18
+ date?: import("../../orm/types.js").NumericDate | null | undefined;
19
+ summary?: string | null | undefined;
20
+ title?: string | null | undefined;
21
+ typeId?: import("../../orm/types.js").Uuid | null | undefined;
22
+ subtitle?: string | null | undefined;
23
+ tags?: string[] | null | undefined;
24
+ comment?: string | null | undefined;
25
+ approval?: import("../models/document.model.js").DocumentApproval | undefined;
27
26
  originalFileName: string | null;
28
27
  assignment: {
29
28
  collections: string | string[];
@@ -4,7 +4,7 @@ import { Document, DocumentAssignmentTarget, DocumentCategory, DocumentCollectio
4
4
  export const metadataParameterSchema = optional(partial(pick(EntityMetadata, 'attributes')));
5
5
  export const metadataParameterObjectSchema = object({ metadata: metadataParameterSchema });
6
6
  export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValue, ['propertyId']), object({ value: union(string(), number(), boolean(), nullable(never())) }), metadataParameterObjectSchema);
7
- export const createDocumentParametersSchema = assign(pick(Document, ['typeId', 'title', 'subtitle', 'date', 'summary', 'tags', 'approval', 'comment', 'createUserId']), pick(DocumentFile, ['originalFileName']), object({
7
+ export const createDocumentParametersSchema = assign(partial(pick(Document, ['typeId', 'title', 'subtitle', 'date', 'summary', 'tags', 'approval', 'comment'])), pick(DocumentFile, ['originalFileName']), object({
8
8
  assignment: union(object({ collections: oneOrMany(string(), { minimum: 1 }) }), object({ request: string() }), object({
9
9
  automatic: object({
10
10
  /** collection ids to assign in */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.128",
3
+ "version": "0.92.130",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"