feat(_mock): add typed attributes to document mocks and extend Attribute types

This commit is contained in:
tekh 2025-07-14 14:59:11 +02:00
parent d5d82a5a1e
commit 9a03c3ef85
2 changed files with 67 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import { Doc } from 'src/services/document-service'; import { Doc } from 'src/services/document-service';
import { Product } from 'src/services/product-service'; import { Product } from 'src/services/product-service';
import { Attribute } from 'src/services/attribute-service'; import { Attribute, Type } from 'src/services/attribute-service';
import { import {
_id, _id,
@ -267,7 +267,60 @@ export const _documents: Doc[] = [
name: "example1.pdf", name: "example1.pdf",
data: base64ToUint8Array(_base64.example1_pdf), data: base64ToUint8Array(_base64.example1_pdf),
addedWhen: new Date("2024-01-12T10:00:00Z"), addedWhen: new Date("2024-01-12T10:00:00Z"),
addedWho: "TekH" addedWho: "TekH",
attributes: [
{
name: "invoiceNumber",
serilizedValue: "INV-20250714-001",
type: 'VARCHAR'
},
{
name: "customerName",
serilizedValue: "John Doe",
type: 'VARCHAR'
},
{
name: "startDate",
serilizedValue: "2025-07-01",
type: 'DATE'
},
{
name: "endDate",
serilizedValue: "2025-07-14",
type: 'DATE'
},
{
name: "minAmount",
serilizedValue: "100.50",
type: 'DECIMAL'
},
{
name: "maxAmount",
serilizedValue: "1000.00",
type: 'DECIMAL'
},
{
name: "taxIncluded",
serilizedValue: "true",
type: 'BOOLEAN'
},
{
name: "createdAt",
serilizedValue: "2025-07-10",
type: 'DATE'
},
{
name: "deliveryTime",
serilizedValue: "15:30:00",
type: 'TIME'
},
{
name: "lastUpdated",
serilizedValue: "2025-07-14T10:45:00",
type: 'DATETIME'
}
]
}, },
{ {
id: 2, id: 2,
@ -301,4 +354,12 @@ export const _documents: Doc[] = [
addedWhen: new Date("2024-04-17T11:25:00Z"), addedWhen: new Date("2024-04-17T11:25:00Z"),
addedWho: "SchreiberM" addedWho: "SchreiberM"
} }
].map(doc => Doc.map(doc)); ]
.map(doc => ({
...doc,
attributes: doc.attributes?.map(attr => ({
...attr,
type: attr.type as Type
}))
}))
.map(doc => Doc.map(doc));

View File

@ -1,5 +1,7 @@
import { _documents } from "src/_mock" import { _documents } from "src/_mock"
import { Type } from "./attribute-service";
export type FileFormat = export type FileFormat =
| 'pdf' | 'pdf'
| 'docx' | 'docx'
@ -25,6 +27,7 @@ const validExtensions: FileFormat[] = [
type DocAttribute = { type DocAttribute = {
name: string; name: string;
serilizedValue: string; serilizedValue: string;
type: Type;
} }
export class Doc { export class Doc {