📄 src/models/test/fixtures.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 *
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 *
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15import { BookMethod, CopyrightStatus, QualityScore } from '@the_library/db_schemas/enums';
16import type { BookInput } from '../generated-src/Book.ts';
17import type { TagInput } from '../generated-src/Tag.ts';
18import type { PersonInput } from '../generated-src/Person.ts';
19import type { InstanceData } from '../interfaces.ts';
20
21export const createInstancesFixture = (): InstanceData[] => [
22 {
23 downloadTxId: 'tx-default-eng',
24 method: BookMethod.Scan,
25 isAiTranslation: false,
26 aiEngine: null,
27 addedAt: 1700000000,
28 nbPages: 300,
29 sizeBytes: 1500000,
30 isbn: '978-0-123456-47-2',
31 publisher: 'Default Press',
32 publicationDate: '2020-01-01',
33 publishedAt: null,
34 qualityScore: QualityScore.Good,
35 isDefault: true,
36 language: 'eng'
37 },
38 {
39 downloadTxId: 'tx-alt-eng',
40 method: BookMethod.OCR,
41 isAiTranslation: false,
42 aiEngine: null,
43 addedAt: 1700000100,
44 nbPages: 300,
45 sizeBytes: 800000,
46 isbn: '978-0-123456-47-3',
47 publisher: 'Alt Press',
48 publicationDate: '2020-01-01',
49 publishedAt: null,
50 qualityScore: QualityScore.Fair,
51 isDefault: false,
52 language: 'eng'
53 },
54 {
55 downloadTxId: 'tx-default-fra',
56 method: BookMethod.AiTranslation,
57 isAiTranslation: true,
58 aiEngine: 'GPT-4',
59 addedAt: 1700000200,
60 nbPages: 310,
61 sizeBytes: 1600000,
62 isbn: '978-0-123456-47-4',
63 publisher: 'French Press',
64 publicationDate: '2021-01-01',
65 publishedAt: null,
66 qualityScore: QualityScore.Good,
67 isDefault: true,
68 language: 'fra'
69 }
70];
71
72export const createBookFixture = (id: number): BookInput => {
73 const instances = createInstancesFixture();
74 const defaultInst = instances.find(i => i.isDefault && i.language === 'eng') || instances[0];
75
76 return {
77 id,
78 title: `Book Title ${id}`,
79 description: `Description for book ${id}`,
80 originalLang: 'eng',
81 previewTxId: `prev-${id}`,
82 ageGradeBand: 4,
83 safe: true,
84 deleted: false,
85 prerequisites: 'Basic Knowledge',
86 deweyDecimal: '500',
87 locCallNumber: 'Q1',
88 copyrightStatus: CopyrightStatus.PublicDomain,
89 textQuality: QualityScore.Excellent,
90 illustrations: QualityScore.Good,
91 educationQuality: QualityScore.VeryGood,
92 practicality: QualityScore.Excellent,
93 accessibilityLevel: QualityScore.Fair,
94 teacherMaterials: true,
95 pedagogicalScaffolding: QualityScore.Good,
96 clarityOfExplanation: QualityScore.Excellent,
97 workedExamples: QualityScore.Excellent,
98 exercisesAndAssessment: QualityScore.VeryGood,
99 selfStudyReadiness: QualityScore.Excellent,
100 referenceApparatus: QualityScore.Good,
101 safetyGuidance: QualityScore.None,
102 contentCurrency: QualityScore.Excellent,
103 ecoRegeneration: QualityScore.None,
104 communityLiving: QualityScore.None,
105 promotesPeace: QualityScore.None,
106 businessDevelopment: QualityScore.Good,
107 authorIds: [100, 101],
108 defaultLanguage: (defaultInst.language as string | null) ?? null,
109 defaultDownloadTxId: defaultInst.downloadTxId as string,
110 defaultMethod: defaultInst.method as number,
111 defaultIsAiTranslation: defaultInst.isAiTranslation as boolean,
112 defaultAiEngine: defaultInst.aiEngine as string | null,
113 defaultAddedAt: defaultInst.addedAt as number,
114 defaultNbPages: defaultInst.nbPages as number,
115 defaultSizeBytes: defaultInst.sizeBytes as number,
116 defaultPublisher: defaultInst.publisher as string | null,
117 defaultPublicationDate: defaultInst.publicationDate as string | null,
118 defaultPublishedAt: defaultInst.publishedAt as string | null,
119 defaultQualityScore: defaultInst.qualityScore as number,
120 defaultIsbn: defaultInst.isbn as string | null,
121 instances: instances
122 };
123};
124
125export const createTagFixture = (id: number): TagInput => ({
126 id,
127 title: `Tag ${id}`,
128 description: `Description for Tag ${id}`,
129 originalLang: 'eng',
130 previewTxId: `tag-prev-${id}`,
131 ageGradeBand: 0,
132 safe: true,
133 deleted: false,
134 lccNotation: null,
135 ddcNotation: `50${id}`,
136 udcNotation: null,
137 clcNotation: null,
138 bbkNotation: null,
139 tlcNotation: null,
140 ccNotation: null,
141 tags: [200, 201],
142 books: [300, 301]
143});
144
145export const createPersonFixture = (id: number): PersonInput => ({
146 id,
147 title: `Person ${id}`,
148 description: `Biography for Person ${id}`,
149 originalLang: 'eng',
150 previewTxId: `person-prev-${id}`,
151 ageGradeBand: 0,
152 safe: true,
153 deleted: false,
154 birthDate: '1970-01-01',
155 deathDate: null,
156 nationality: 'UK',
157 wikiUrl: `https://en.wikipedia.org/wiki/Person_${id}`,
158 isniId: `00000000000000${id}`,
159 orcidId: `0000-0000-0000-000${id}`
160});
161