@d19n/youfibre-odin-sdk 2.0.342 → 2.0.344

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 (98) hide show
  1. package/README.md +26 -2
  2. package/dist/EntityRegistry.d.ts +4 -0
  3. package/dist/EntityRegistry.js +4 -0
  4. package/dist/OdinApiClient.d.ts +8 -0
  5. package/dist/OdinApiClient.js +16 -0
  6. package/dist/OdinDbClient.d.ts +8 -0
  7. package/dist/OdinDbClient.js +16 -0
  8. package/dist/accessors-v2/DocumentAccessor.d.ts +112 -0
  9. package/dist/accessors-v2/DocumentAccessor.js +191 -0
  10. package/dist/accessors-v2/DocumentProcessingAccessor.d.ts +112 -0
  11. package/dist/accessors-v2/DocumentProcessingAccessor.js +191 -0
  12. package/dist/accessors-v2/index.d.ts +2 -0
  13. package/dist/accessors-v2/index.js +7 -3
  14. package/dist/actions-v2/CreateAiRouteRequestDto.d.ts +1 -1
  15. package/dist/actions-v2/CreateChurnRequestDto.d.ts +2 -0
  16. package/dist/actions-v2/CreateChurnRequestDto.js +2 -0
  17. package/dist/actions-v2/CreateDocumentDto.d.ts +235 -0
  18. package/dist/actions-v2/CreateDocumentDto.js +57 -0
  19. package/dist/actions-v2/CreateDocumentProcessingDto.d.ts +192 -0
  20. package/dist/actions-v2/CreateDocumentProcessingDto.js +57 -0
  21. package/dist/actions-v2/CreateLeadSalesAppDto.d.ts +9 -17
  22. package/dist/actions-v2/UpdateDocumentDto.d.ts +236 -0
  23. package/dist/actions-v2/UpdateDocumentDto.js +59 -0
  24. package/dist/actions-v2/UpdateMessageReadByCustomerDto.d.ts +72 -0
  25. package/dist/actions-v2/UpdateMessageReadByCustomerDto.js +56 -0
  26. package/dist/api-sdk-v2/CommitmentApi.d.ts +48 -0
  27. package/dist/api-sdk-v2/CommitmentApi.js +155 -0
  28. package/dist/api-sdk-v2/ContractBuyOutApi.d.ts +2 -0
  29. package/dist/api-sdk-v2/ContractBuyOutApi.js +6 -0
  30. package/dist/api-sdk-v2/DocumentApi.d.ts +52 -0
  31. package/dist/api-sdk-v2/DocumentApi.js +167 -0
  32. package/dist/api-sdk-v2/DocumentProcessingApi.d.ts +50 -0
  33. package/dist/api-sdk-v2/DocumentProcessingApi.js +161 -0
  34. package/dist/api-sdk-v2/EquipmentReturnApi.d.ts +45 -0
  35. package/dist/api-sdk-v2/EquipmentReturnApi.js +151 -0
  36. package/dist/api-sdk-v2/EquipmentReturnItemApi.d.ts +45 -0
  37. package/dist/api-sdk-v2/EquipmentReturnItemApi.js +151 -0
  38. package/dist/api-sdk-v2/FileApi.d.ts +4 -0
  39. package/dist/api-sdk-v2/FileApi.js +12 -0
  40. package/dist/api-sdk-v2/OrderApi.d.ts +2 -0
  41. package/dist/api-sdk-v2/OrderApi.js +6 -0
  42. package/dist/db-accessors-v2/DocumentDbAccessor.d.ts +180 -0
  43. package/dist/db-accessors-v2/DocumentDbAccessor.js +265 -0
  44. package/dist/db-accessors-v2/DocumentProcessingDbAccessor.d.ts +180 -0
  45. package/dist/db-accessors-v2/DocumentProcessingDbAccessor.js +265 -0
  46. package/dist/db-accessors-v2/index.d.ts +2 -0
  47. package/dist/db-accessors-v2/index.js +7 -3
  48. package/dist/db-sdk-v2/CommitmentDb.d.ts +120 -0
  49. package/dist/db-sdk-v2/CommitmentDb.js +204 -0
  50. package/dist/db-sdk-v2/ContractBuyOutDb.d.ts +2 -0
  51. package/dist/db-sdk-v2/ContractBuyOutDb.js +6 -0
  52. package/dist/db-sdk-v2/DocumentDb.d.ts +124 -0
  53. package/dist/db-sdk-v2/DocumentDb.js +216 -0
  54. package/dist/db-sdk-v2/DocumentProcessingDb.d.ts +122 -0
  55. package/dist/db-sdk-v2/DocumentProcessingDb.js +210 -0
  56. package/dist/db-sdk-v2/EquipmentReturnDb.d.ts +117 -0
  57. package/dist/db-sdk-v2/EquipmentReturnDb.js +200 -0
  58. package/dist/db-sdk-v2/EquipmentReturnItemDb.d.ts +117 -0
  59. package/dist/db-sdk-v2/EquipmentReturnItemDb.js +200 -0
  60. package/dist/db-sdk-v2/FileDb.d.ts +4 -0
  61. package/dist/db-sdk-v2/FileDb.js +12 -0
  62. package/dist/db-sdk-v2/OrderDb.d.ts +2 -0
  63. package/dist/db-sdk-v2/OrderDb.js +6 -0
  64. package/dist/entities-v2/AiRouteRequest.d.ts +23 -11
  65. package/dist/entities-v2/AiRouteRequest.js +15 -3
  66. package/dist/entities-v2/Commitment.d.ts +154 -0
  67. package/dist/entities-v2/Commitment.js +115 -0
  68. package/dist/entities-v2/ContractBuyOut.d.ts +7 -0
  69. package/dist/entities-v2/ContractBuyOut.js +5 -1
  70. package/dist/entities-v2/Document.d.ts +1145 -0
  71. package/dist/entities-v2/Document.js +220 -0
  72. package/dist/entities-v2/DocumentProcessing.d.ts +272 -0
  73. package/dist/entities-v2/DocumentProcessing.js +156 -0
  74. package/dist/entities-v2/EquipmentReturn.d.ts +66 -0
  75. package/dist/entities-v2/EquipmentReturn.js +64 -0
  76. package/dist/entities-v2/EquipmentReturnItem.d.ts +66 -0
  77. package/dist/entities-v2/EquipmentReturnItem.js +64 -0
  78. package/dist/entities-v2/File.d.ts +81 -1
  79. package/dist/entities-v2/File.js +9 -1
  80. package/dist/entities-v2/Message.d.ts +27 -1
  81. package/dist/entities-v2/Message.js +2 -0
  82. package/dist/entities-v2/Order.d.ts +49 -8
  83. package/dist/entities-v2/Order.js +24 -4
  84. package/dist/entities-v2/YfStockCount.d.ts +197 -1
  85. package/dist/entities-v2/YfStockCount.js +28 -0
  86. package/dist/records-v2/ContractBuyOutRecord.d.ts +20 -0
  87. package/dist/records-v2/ContractBuyOutRecord.js +33 -0
  88. package/dist/records-v2/DocumentProcessingRecord.d.ts +227 -0
  89. package/dist/records-v2/DocumentProcessingRecord.js +315 -0
  90. package/dist/records-v2/DocumentRecord.d.ts +355 -0
  91. package/dist/records-v2/DocumentRecord.js +468 -0
  92. package/dist/records-v2/FileRecord.d.ts +59 -3
  93. package/dist/records-v2/FileRecord.js +83 -1
  94. package/dist/records-v2/MessageRecord.d.ts +28 -0
  95. package/dist/records-v2/MessageRecord.js +37 -0
  96. package/dist/records-v2/index.d.ts +2 -0
  97. package/dist/records-v2/index.js +10 -4
  98. package/package.json +1 -1
@@ -0,0 +1,468 @@
1
+ "use strict";
2
+ /**
3
+ * Document Record Wrapper
4
+ *
5
+ * Provides typed action methods and link management.
6
+ * Works with both ApiProvider and DbProvider.
7
+ *
8
+ * All action methods return an ActionBuilder or FlowBuilder.
9
+ * Call .execute() to run or .dryRun() to get the payload for debugging.
10
+ *
11
+ * Can be instantiated with null record for create operations:
12
+ * ```typescript
13
+ * const record = odinClient.documents.new();
14
+ * await record.createDocument({ ... }).execute();
15
+ * ```
16
+ *
17
+ * Entity Types: CONTRACT_BUYOUT, DEFAULT, EMAIL_ATTACHMENT, INVOICE, OTHER, OUTCOME_FORM
18
+ *
19
+ * AUTO-GENERATED - DO NOT EDIT DIRECTLY
20
+ */
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.isDocumentRecord = exports.DocumentRecord = void 0;
32
+ const uuid_1 = require("uuid");
33
+ const core_1 = require("@d19n/odin-types/dist/core");
34
+ const record_link_manager_1 = require("@d19n/odin-sdk-generator/dist/record-link-manager");
35
+ const FileRecord_1 = require("./FileRecord");
36
+ const DocumentProcessingRecord_1 = require("./DocumentProcessingRecord");
37
+ const ContractBuyOutRecord_1 = require("./ContractBuyOutRecord");
38
+ /**
39
+ * Builder for action execution with dryRun support
40
+ *
41
+ * Provides a consistent API across all action types:
42
+ * - `.execute()` - Execute the action and return results
43
+ * - `.dryRun()` - Return the payload without executing (for debugging)
44
+ */
45
+ class ActionBuilder {
46
+ constructor(provider, moduleName, entityName, payload, clearPendingLinks) {
47
+ this._provider = provider;
48
+ this._moduleName = moduleName;
49
+ this._entityName = entityName;
50
+ this._payload = payload;
51
+ this._clearPendingLinks = clearPendingLinks;
52
+ }
53
+ /**
54
+ * Set an external system identifier for this record.
55
+ * Links the record to a corresponding entry in an external application.
56
+ *
57
+ * @param externalId - The ID in the external system
58
+ * @param externalAppId - The external application identifier
59
+ * @returns this (for chaining)
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * await record.createOrder({ ... }).withExternalId('SF-123', 'salesforce').execute();
64
+ * ```
65
+ */
66
+ withExternalId(externalId, externalAppId) {
67
+ this._payload.externalId = externalId;
68
+ this._payload.externalAppId = externalAppId;
69
+ return this;
70
+ }
71
+ /**
72
+ * Set security/access groups for this record.
73
+ * Controls which user groups can access the record.
74
+ *
75
+ * @param groups - Array of group names
76
+ * @returns this (for chaining)
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * await record.createOrder({ ... }).withGroups(['TenantA', 'BillingTeam']).execute();
81
+ * ```
82
+ */
83
+ withGroups(groups) {
84
+ this._payload.groups = groups;
85
+ return this;
86
+ }
87
+ /**
88
+ * Execute the action
89
+ * @returns The result from the API
90
+ */
91
+ execute() {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const result = yield this._provider._applyAction(this._moduleName, this._entityName, this._payload);
94
+ this._clearPendingLinks();
95
+ return result;
96
+ });
97
+ }
98
+ /**
99
+ * Returns the request payload without executing (for debugging)
100
+ * @returns The request payload that would be sent to the API
101
+ */
102
+ dryRun() {
103
+ return this._payload;
104
+ }
105
+ /**
106
+ * Prevents accidental `await actionBuilder` without .execute()
107
+ * Forces developers to explicitly call .execute()
108
+ * @throws Error always - use .execute() or .dryRun() instead
109
+ */
110
+ then() {
111
+ throw new Error('ActionBuilder cannot be awaited directly. Call .execute() to run the action or .dryRun() to get the payload.');
112
+ }
113
+ }
114
+ class DocumentRecord {
115
+ /**
116
+ * Create a record wrapper.
117
+ * @param record - The underlying record, or null for create operations
118
+ * @param provider - The API or DB provider
119
+ * @param preGeneratedId - Optional pre-generated ID for new records (auto-generated if not provided)
120
+ */
121
+ constructor(record, provider, preGeneratedId) {
122
+ this._pendingLinks = [];
123
+ this._record = record;
124
+ this._provider = provider;
125
+ this._preGeneratedId = preGeneratedId !== null && preGeneratedId !== void 0 ? preGeneratedId : (0, uuid_1.v4)();
126
+ }
127
+ // ============================================
128
+ // CORE PROPERTIES
129
+ // ============================================
130
+ /** Returns true if this is a new (unsaved) record */
131
+ get isNew() { var _a; return !((_a = this._record) === null || _a === void 0 ? void 0 : _a.id); }
132
+ /** Record ID - always available (pre-generated for new records) */
133
+ get id() { var _a, _b; return (_b = (_a = this._record) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this._preGeneratedId; }
134
+ get entity() { var _a, _b; return (_b = (_a = this._record) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : 'AiModule:Document'; }
135
+ get type() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.type; }
136
+ /** Record properties - empty object for new (unsaved) records */
137
+ get properties() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.properties) || {}; }
138
+ get title() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.title; }
139
+ get recordNumber() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.recordNumber; }
140
+ get stage() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.stage; }
141
+ get createdAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.createdAt; }
142
+ get updatedAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.updatedAt; }
143
+ get externalId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalId; }
144
+ get externalAppId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalAppId; }
145
+ get groups() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.groups) || []; }
146
+ /** Link metadata - populated only when the read passed withLinks (empty otherwise) */
147
+ get links() { var _a, _b; return (_b = (_a = this._record) === null || _a === void 0 ? void 0 : _a.links) !== null && _b !== void 0 ? _b : []; }
148
+ /** Access the underlying OdinRecord (null for new records) */
149
+ get record() { return this._record; }
150
+ // ============================================
151
+ // TYPE GUARDS (with TypeScript type predicates)
152
+ // ============================================
153
+ /**
154
+ * Type guard: check if this record is of type CONTRACT_BUYOUT
155
+ *
156
+ * When this returns true, TypeScript automatically narrows the type,
157
+ * giving you access to CONTRACT_BUYOUT-specific properties.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * if (record.isContractBuyout()) {
162
+ * // TypeScript knows record.properties is ContractBuyoutDocumentProperties
163
+ * console.log(record.properties.SomeTypeSpecificField);
164
+ * }
165
+ * ```
166
+ * @remarks A customer's previous-provider final bill sent for a contract buyout (YouFibre orders).
167
+ */
168
+ isContractBuyout() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'CONTRACT_BUYOUT'; }
169
+ /**
170
+ * Type guard: check if this record is of type DEFAULT
171
+ *
172
+ * When this returns true, TypeScript automatically narrows the type,
173
+ * giving you access to DEFAULT-specific properties.
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * if (record.isDefault()) {
178
+ * // TypeScript knows record.properties is DocumentProperties
179
+ * console.log(record.properties.SomeTypeSpecificField);
180
+ * }
181
+ * ```
182
+ * @remarks This is the default record type
183
+ */
184
+ isDefault() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'DEFAULT'; }
185
+ /**
186
+ * Type guard: check if this record is of type EMAIL_ATTACHMENT
187
+ *
188
+ * When this returns true, TypeScript automatically narrows the type,
189
+ * giving you access to EMAIL_ATTACHMENT-specific properties.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * if (record.isEmailAttachment()) {
194
+ * // TypeScript knows record.properties is EmailAttachmentDocumentProperties
195
+ * console.log(record.properties.SomeTypeSpecificField);
196
+ * }
197
+ * ```
198
+ * @remarks A file attached to an inbound or outbound email.
199
+ */
200
+ isEmailAttachment() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'EMAIL_ATTACHMENT'; }
201
+ /**
202
+ * Type guard: check if this record is of type INVOICE
203
+ *
204
+ * When this returns true, TypeScript automatically narrows the type,
205
+ * giving you access to INVOICE-specific properties.
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * if (record.isInvoice()) {
210
+ * // TypeScript knows record.properties is InvoiceDocumentProperties
211
+ * console.log(record.properties.SomeTypeSpecificField);
212
+ * }
213
+ * ```
214
+ * @remarks An invoice document produced by billing.
215
+ */
216
+ isInvoice() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'INVOICE'; }
217
+ /**
218
+ * Type guard: check if this record is of type OTHER
219
+ *
220
+ * When this returns true, TypeScript automatically narrows the type,
221
+ * giving you access to OTHER-specific properties.
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * if (record.isOther()) {
226
+ * // TypeScript knows record.properties is OtherDocumentProperties
227
+ * console.log(record.properties.SomeTypeSpecificField);
228
+ * }
229
+ * ```
230
+ * @remarks Any document class not listed yet. Prefer adding a kind.
231
+ */
232
+ isOther() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'OTHER'; }
233
+ /**
234
+ * Type guard: check if this record is of type OUTCOME_FORM
235
+ *
236
+ * When this returns true, TypeScript automatically narrows the type,
237
+ * giving you access to OUTCOME_FORM-specific properties.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * if (record.isOutcomeForm()) {
242
+ * // TypeScript knows record.properties is OutcomeFormDocumentProperties
243
+ * console.log(record.properties.SomeTypeSpecificField);
244
+ * }
245
+ * ```
246
+ * @remarks An engineer outcome form with its photos and signatures (Netomnia field service).
247
+ */
248
+ isOutcomeForm() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'OUTCOME_FORM'; }
249
+ /**
250
+ * Access linked File records
251
+ * @remarks Available labels: Document__File
252
+ * @throws Error if called on a new (unsaved) record
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * // Get all linked File records
257
+ * const items = await record.files.list();
258
+ * const first = await record.files.first();
259
+ *
260
+ * // Filter by label
261
+ * const specific = await record.files.first({ label: 'Document__File' });
262
+ * ```
263
+ */
264
+ get files() {
265
+ var _a;
266
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
267
+ throw new Error('Cannot access links on a new (unsaved) record');
268
+ if (!this._files) {
269
+ this._files = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
270
+ sourceEntity: 'AiModule:Document',
271
+ targetEntity: 'SchemaModule:File',
272
+ targetModuleName: 'SchemaModule',
273
+ targetEntityName: 'File',
274
+ labels: ['Document__File'],
275
+ }, FileRecord_1.FileRecord);
276
+ }
277
+ return this._files;
278
+ }
279
+ /**
280
+ * Access linked DocumentProcessing records
281
+ * @remarks Available labels: Document__DocumentProcessing
282
+ * @throws Error if called on a new (unsaved) record
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * // Get all linked DocumentProcessing records
287
+ * const items = await record.documentProcessings.list();
288
+ * const first = await record.documentProcessings.first();
289
+ *
290
+ * // Filter by label
291
+ * const specific = await record.documentProcessings.first({ label: 'Document__DocumentProcessing' });
292
+ * ```
293
+ */
294
+ get documentProcessings() {
295
+ var _a;
296
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
297
+ throw new Error('Cannot access links on a new (unsaved) record');
298
+ if (!this._documentProcessings) {
299
+ this._documentProcessings = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
300
+ sourceEntity: 'AiModule:Document',
301
+ targetEntity: 'AiModule:DocumentProcessing',
302
+ targetModuleName: 'AiModule',
303
+ targetEntityName: 'DocumentProcessing',
304
+ labels: ['Document__DocumentProcessing'],
305
+ }, DocumentProcessingRecord_1.DocumentProcessingRecord);
306
+ }
307
+ return this._documentProcessings;
308
+ }
309
+ /**
310
+ * Access linked ContractBuyOut records
311
+ * @remarks Available labels: ContractBuyOut__Document
312
+ * @throws Error if called on a new (unsaved) record
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * // Get all linked ContractBuyOut records
317
+ * const items = await record.contractBuyOuts.list();
318
+ * const first = await record.contractBuyOuts.first();
319
+ *
320
+ * // Filter by label
321
+ * const specific = await record.contractBuyOuts.first({ label: 'ContractBuyOut__Document' });
322
+ * ```
323
+ */
324
+ get contractBuyOuts() {
325
+ var _a;
326
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
327
+ throw new Error('Cannot access links on a new (unsaved) record');
328
+ if (!this._contractBuyOuts) {
329
+ this._contractBuyOuts = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
330
+ sourceEntity: 'AiModule:Document',
331
+ targetEntity: 'OrderModule:ContractBuyOut',
332
+ targetModuleName: 'OrderModule',
333
+ targetEntityName: 'ContractBuyOut',
334
+ labels: ['ContractBuyOut__Document'],
335
+ }, ContractBuyOutRecord_1.ContractBuyOutRecord);
336
+ }
337
+ return this._contractBuyOuts;
338
+ }
339
+ // ============================================
340
+ // LINK MANAGEMENT
341
+ // ============================================
342
+ /**
343
+ * Queue a link to be created with the next action.
344
+ * Works for both create and update actions.
345
+ * @returns this (for chaining)
346
+ */
347
+ link(target) {
348
+ this._pendingLinks.push(new core_1.OdinRecordLinkDto({ id: target.id, entity: target.entity }));
349
+ return this;
350
+ }
351
+ /** Get the currently queued links */
352
+ get pendingLinks() {
353
+ return [...this._pendingLinks];
354
+ }
355
+ /** Clear pending links without executing an action */
356
+ clearPendingLinks() {
357
+ this._pendingLinks = [];
358
+ return this;
359
+ }
360
+ /**
361
+ * Immediately unlink a record (API call).
362
+ * Unlike link(), this executes immediately.
363
+ * @throws Error if called on a new (unsaved) record
364
+ */
365
+ unlink(target) {
366
+ var _a;
367
+ return __awaiter(this, void 0, void 0, function* () {
368
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
369
+ throw new Error('Cannot unlink from a new (unsaved) record');
370
+ const targetId = typeof target === 'string' ? target : target.id;
371
+ yield this._provider._deleteLinks('AiModule', 'Document', this._record.id, targetId);
372
+ });
373
+ }
374
+ // ============================================
375
+ // CREATE ACTIONS (no existing record required)
376
+ // ============================================
377
+ /**
378
+ * CreateDocument
379
+ *
380
+ * Creates a new Document record with the specified properties.
381
+ * Returns an ActionBuilder - call .execute() to create or .dryRun() for debugging.
382
+ *
383
+ * @remarks Record type: DEFAULT
384
+ *
385
+ * @param properties - The properties for the new record
386
+ * @param options - Optional settings
387
+ * @param options.journeyId - Associate with a journey
388
+ * @param options.stageKey - Set initial pipeline stage
389
+ * @returns ActionBuilder - call .execute() to create or .dryRun() for payload
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * // Create with properties
394
+ * const record = odinClient.documents.new();
395
+ * await record.createDocument({ ... }).execute();
396
+ *
397
+ * // Dry run (for debugging)
398
+ * const payload = record.createDocument({ ... }).dryRun();
399
+ * ```
400
+ */
401
+ createDocument(properties, options) {
402
+ const payload = {
403
+ entity: 'AiModule:Document',
404
+ type: 'DEFAULT',
405
+ actionName: 'CreateDocument',
406
+ properties: properties || {},
407
+ associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined,
408
+ journeyId: options === null || options === void 0 ? void 0 : options.journeyId,
409
+ stageKey: options === null || options === void 0 ? void 0 : options.stageKey,
410
+ };
411
+ return new ActionBuilder(this._provider, 'AiModule', 'Document', payload, () => { this._pendingLinks = []; });
412
+ }
413
+ // ============================================
414
+ // UPDATE ACTIONS (require existing record)
415
+ // ============================================
416
+ /**
417
+ * UpdateDocument
418
+ *
419
+ * Updates this Document record.
420
+ * Returns an ActionBuilder - call .execute() to update or .dryRun() for debugging.
421
+ *
422
+ * @param propertiesOrOptions - Properties to update, or options object
423
+ * @param options - Optional settings (journeyId, stageKey)
424
+ * @returns ActionBuilder - call .execute() to update or .dryRun() for payload
425
+ * @throws Error if called on a new (unsaved) record
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * const record = await odinClient.documents.get(id);
430
+ * await record.updateDocument({ ... }).execute();
431
+ *
432
+ * // Dry run (for debugging)
433
+ * const payload = record.updateDocument({ ... }).dryRun();
434
+ * ```
435
+ */
436
+ updateDocument(propertiesOrOptions, options) {
437
+ var _a;
438
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
439
+ throw new Error('updateDocument requires an existing record. Use accessor.get() first.');
440
+ let properties = {};
441
+ let opts = options;
442
+ if (propertiesOrOptions) {
443
+ if ('journeyId' in propertiesOrOptions || 'stageKey' in propertiesOrOptions) {
444
+ opts = propertiesOrOptions;
445
+ }
446
+ else {
447
+ properties = propertiesOrOptions;
448
+ }
449
+ }
450
+ const payload = Object.assign({ id: this._record.id, entity: this._record.entity, type: this._record.type, actionName: 'UpdateDocument', properties, associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined }, opts);
451
+ return new ActionBuilder(this._provider, 'AiModule', 'Document', payload, () => { this._pendingLinks = []; });
452
+ }
453
+ }
454
+ exports.DocumentRecord = DocumentRecord;
455
+ // ============================================
456
+ // TYPED LINK ACCESSORS
457
+ // ============================================
458
+ /** Valid labels for File associations */
459
+ DocumentRecord.filesLabels = ['Document__File'];
460
+ /** Valid labels for DocumentProcessing associations */
461
+ DocumentRecord.documentProcessingsLabels = ['Document__DocumentProcessing'];
462
+ /** Valid labels for ContractBuyOut associations */
463
+ DocumentRecord.contractBuyOutsLabels = ['ContractBuyOut__Document'];
464
+ /** Type guard to check if an object is a DocumentRecord */
465
+ function isDocumentRecord(obj) {
466
+ return obj instanceof DocumentRecord;
467
+ }
468
+ exports.isDocumentRecord = isDocumentRecord;
@@ -13,7 +13,7 @@
13
13
  * await record.createFile({ ... }).execute();
14
14
  * ```
15
15
  *
16
- * Entity Types: AFP_INVOICE, CBO_FINAL_BILL, CSV, DEFAULT, EMAIL, INVOICE, NA_PROBLEM_EVIDENCE, NA_SOLUTION_EVIDENCE, OPENREACH_A55, OTDR
16
+ * Entity Types: AFP_INVOICE, CBO_FINAL_BILL, CSV, DEFAULT, EMAIL, INVOICE, NA_PROBLEM_EVIDENCE, NA_SOLUTION_EVIDENCE, OPENREACH_A55, OTDR, PROCESSING_OUTPUT
17
17
  *
18
18
  * AUTO-GENERATED - DO NOT EDIT DIRECTLY
19
19
  */
@@ -22,7 +22,7 @@ import { PipelineStageEntity } from '@d19n/odin-types/dist/core';
22
22
  import { IDbRecordCreateUpdateRes } from '@d19n/odin-types/dist/core/interfaces/v1.db.interfaces';
23
23
  import { IOdinProvider } from '@d19n/odin-sdk-generator/dist/odin-sdk-types';
24
24
  import { RecordLinkManager } from '@d19n/odin-sdk-generator/dist/record-link-manager';
25
- import { FileProperties, AfpInvoiceFileProperties, CboFinalBillFileProperties, CsvFileProperties, EmailFileProperties, InvoiceFileProperties, NaProblemEvidenceFileProperties, NaSolutionEvidenceFileProperties, OpenreachA55FileProperties, OtdrFileProperties } from '../entities-v2/File';
25
+ import { FileProperties, AfpInvoiceFileProperties, CboFinalBillFileProperties, CsvFileProperties, EmailFileProperties, InvoiceFileProperties, NaProblemEvidenceFileProperties, NaSolutionEvidenceFileProperties, OpenreachA55FileProperties, OtdrFileProperties, ProcessingOutputFileProperties } from '../entities-v2/File';
26
26
  import { CreateFileProperties } from '../actions-v2/CreateFileDto';
27
27
  import { OverlayRealA55Record } from './OverlayRealA55Record';
28
28
  import { AppointmentRecord } from './AppointmentRecord';
@@ -64,8 +64,10 @@ import { EmailRecord } from './EmailRecord';
64
64
  import { PgDirectDebitFileRecord } from './PgDirectDebitFileRecord';
65
65
  import { YfWifiSurveyRecord } from './YfWifiSurveyRecord';
66
66
  import { YfFieldVisitOutcomeFormRecord } from './YfFieldVisitOutcomeFormRecord';
67
+ import { DocumentRecord } from './DocumentRecord';
68
+ import { DocumentProcessingRecord } from './DocumentProcessingRecord';
67
69
  /** Valid entity types for File */
68
- export declare type FileType = 'AFP_INVOICE' | 'CBO_FINAL_BILL' | 'CSV' | 'DEFAULT' | 'EMAIL' | 'INVOICE' | 'NA_PROBLEM_EVIDENCE' | 'NA_SOLUTION_EVIDENCE' | 'OPENREACH_A55' | 'OTDR';
70
+ export declare type FileType = 'AFP_INVOICE' | 'CBO_FINAL_BILL' | 'CSV' | 'DEFAULT' | 'EMAIL' | 'INVOICE' | 'NA_PROBLEM_EVIDENCE' | 'NA_SOLUTION_EVIDENCE' | 'OPENREACH_A55' | 'OTDR' | 'PROCESSING_OUTPUT';
69
71
  /**
70
72
  * Builder for action execution with dryRun support
71
73
  *
@@ -169,6 +171,8 @@ export declare class FileRecord<TProps = FileProperties> {
169
171
  private _pgDirectDebitFiles?;
170
172
  private _yfWifiSurveys?;
171
173
  private _yfFieldVisitOutcomeForms?;
174
+ private _documents?;
175
+ private _documentProcessings?;
172
176
  /**
173
177
  * Create a record wrapper.
174
178
  * @param record - The underlying record, or null for create operations
@@ -356,6 +360,22 @@ export declare class FileRecord<TProps = FileProperties> {
356
360
  * @remarks OTDR evidence for L1 and L2 closures
357
361
  */
358
362
  isOtdr(): this is FileRecord<OtdrFileProperties>;
363
+ /**
364
+ * Type guard: check if this record is of type PROCESSING_OUTPUT
365
+ *
366
+ * When this returns true, TypeScript automatically narrows the type,
367
+ * giving you access to PROCESSING_OUTPUT-specific properties.
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * if (record.isProcessingOutput()) {
372
+ * // TypeScript knows record.properties is ProcessingOutputFileProperties
373
+ * console.log(record.properties.SomeTypeSpecificField);
374
+ * }
375
+ * ```
376
+ * @remarks JSON detail of a document pipeline run, linked to its AiModule:DocumentProcessing row (e.g. per-question verdicts and reasons).
377
+ */
378
+ isProcessingOutput(): this is FileRecord<ProcessingOutputFileProperties>;
359
379
  /** Valid labels for OverlayRealA55 associations */
360
380
  static readonly overlayRealA55sLabels: readonly ["OverlayRealA55_File"];
361
381
  /**
@@ -1076,6 +1096,42 @@ export declare class FileRecord<TProps = FileProperties> {
1076
1096
  * ```
1077
1097
  */
1078
1098
  get yfFieldVisitOutcomeForms(): RecordLinkManager<YfFieldVisitOutcomeFormRecord, typeof FileRecord['yfFieldVisitOutcomeFormsLabels'][number]>;
1099
+ /** Valid labels for Document associations */
1100
+ static readonly documentsLabels: readonly ["Document__File"];
1101
+ /**
1102
+ * Access linked Document records
1103
+ * @remarks Available labels: Document__File
1104
+ * @throws Error if called on a new (unsaved) record
1105
+ *
1106
+ * @example
1107
+ * ```typescript
1108
+ * // Get all linked Document records
1109
+ * const items = await record.documents.list();
1110
+ * const first = await record.documents.first();
1111
+ *
1112
+ * // Filter by label
1113
+ * const specific = await record.documents.first({ label: 'Document__File' });
1114
+ * ```
1115
+ */
1116
+ get documents(): RecordLinkManager<DocumentRecord, typeof FileRecord['documentsLabels'][number]>;
1117
+ /** Valid labels for DocumentProcessing associations */
1118
+ static readonly documentProcessingsLabels: readonly ["DocumentProcessing__File"];
1119
+ /**
1120
+ * Access linked DocumentProcessing records
1121
+ * @remarks Available labels: DocumentProcessing__File
1122
+ * @throws Error if called on a new (unsaved) record
1123
+ *
1124
+ * @example
1125
+ * ```typescript
1126
+ * // Get all linked DocumentProcessing records
1127
+ * const items = await record.documentProcessings.list();
1128
+ * const first = await record.documentProcessings.first();
1129
+ *
1130
+ * // Filter by label
1131
+ * const specific = await record.documentProcessings.first({ label: 'DocumentProcessing__File' });
1132
+ * ```
1133
+ */
1134
+ get documentProcessings(): RecordLinkManager<DocumentProcessingRecord, typeof FileRecord['documentProcessingsLabels'][number]>;
1079
1135
  /**
1080
1136
  * Queue a link to be created with the next action.
1081
1137
  * Works for both create and update actions.