@d19n/youfibre-odin-sdk 2.0.1 → 2.0.2

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 (67) hide show
  1. package/README.md +14 -3
  2. package/dist/EntityRegistry.d.ts +2 -0
  3. package/dist/EntityRegistry.js +2 -0
  4. package/dist/OdinApiClient.d.ts +4 -0
  5. package/dist/OdinApiClient.js +8 -0
  6. package/dist/OdinDbClient.d.ts +4 -0
  7. package/dist/OdinDbClient.js +8 -0
  8. package/dist/accessors-v2/BrskEntityMigrationErrorAccessor.d.ts +111 -0
  9. package/dist/accessors-v2/BrskEntityMigrationErrorAccessor.js +190 -0
  10. package/dist/accessors-v2/index.d.ts +1 -0
  11. package/dist/accessors-v2/index.js +5 -3
  12. package/dist/actions-v2/AssignCaseDto.d.ts +5 -13
  13. package/dist/actions-v2/AssignCaseWithNoteFlowDto.d.ts +5 -13
  14. package/dist/actions-v2/CreateAuddisPgSubmissionAllocationDto.d.ts +8 -1
  15. package/dist/actions-v2/CreateBacsPgSubmissionAllocationDto.d.ts +11 -4
  16. package/dist/actions-v2/CreateBrskMigrationErrorDto.d.ts +100 -0
  17. package/dist/actions-v2/CreateBrskMigrationErrorDto.js +52 -0
  18. package/dist/actions-v2/CreateCaseFromContactDto.d.ts +5 -13
  19. package/dist/actions-v2/CreateCashbackRewardForOrderReferralDto.d.ts +208 -0
  20. package/dist/actions-v2/CreateCashbackRewardForOrderReferralDto.js +179 -0
  21. package/dist/actions-v2/MoveCollectionWorkOrderToCompleteDto.d.ts +72 -20
  22. package/dist/actions-v2/MoveCollectionWorkOrderToCompleteDto.js +42 -21
  23. package/dist/actions-v2/UpdatePgFileAllocationDto.d.ts +91 -0
  24. package/dist/actions-v2/UpdatePgFileAllocationDto.js +61 -0
  25. package/dist/actions-v2/UpdateTeamDto.d.ts +15 -1
  26. package/dist/api-sdk-v2/BrskEntityMigrationErrorApi.d.ts +45 -0
  27. package/dist/api-sdk-v2/BrskEntityMigrationErrorApi.js +151 -0
  28. package/dist/api-sdk-v2/ReferralApi.d.ts +2 -0
  29. package/dist/api-sdk-v2/ReferralApi.js +6 -0
  30. package/dist/api-sdk-v2/RewardApi.d.ts +2 -0
  31. package/dist/api-sdk-v2/RewardApi.js +6 -0
  32. package/dist/db-accessors-v2/BrskEntityMigrationErrorDbAccessor.d.ts +146 -0
  33. package/dist/db-accessors-v2/BrskEntityMigrationErrorDbAccessor.js +224 -0
  34. package/dist/db-accessors-v2/index.d.ts +1 -0
  35. package/dist/db-accessors-v2/index.js +5 -3
  36. package/dist/db-sdk-v2/BrskEntityMigrationErrorDb.d.ts +117 -0
  37. package/dist/db-sdk-v2/BrskEntityMigrationErrorDb.js +200 -0
  38. package/dist/db-sdk-v2/ReferralDb.d.ts +2 -0
  39. package/dist/db-sdk-v2/ReferralDb.js +6 -0
  40. package/dist/db-sdk-v2/RewardDb.d.ts +2 -0
  41. package/dist/db-sdk-v2/RewardDb.js +6 -0
  42. package/dist/entities-v2/AccountCredit.d.ts +90 -7
  43. package/dist/entities-v2/AccountCredit.js +86 -3
  44. package/dist/entities-v2/BrskEntityMigrationError.d.ts +107 -0
  45. package/dist/entities-v2/BrskEntityMigrationError.js +75 -0
  46. package/dist/entities-v2/Config.d.ts +8 -8
  47. package/dist/entities-v2/Config.js +4 -4
  48. package/dist/entities-v2/Referral.d.ts +7 -0
  49. package/dist/entities-v2/Referral.js +5 -1
  50. package/dist/entities-v2/Reward.d.ts +3 -12
  51. package/dist/entities-v2/Reward.js +0 -2
  52. package/dist/entities-v2/Team.d.ts +21 -0
  53. package/dist/entities-v2/Team.js +17 -1
  54. package/dist/records-v2/BrskEntityMigrationErrorRecord.d.ts +184 -0
  55. package/dist/records-v2/BrskEntityMigrationErrorRecord.js +243 -0
  56. package/dist/records-v2/ContactRecord.js +2 -0
  57. package/dist/records-v2/PgFileAllocationRecord.d.ts +28 -0
  58. package/dist/records-v2/PgFileAllocationRecord.js +37 -0
  59. package/dist/records-v2/ReferralRecord.d.ts +20 -0
  60. package/dist/records-v2/ReferralRecord.js +33 -0
  61. package/dist/records-v2/RewardRecord.d.ts +49 -0
  62. package/dist/records-v2/RewardRecord.js +60 -0
  63. package/dist/records-v2/WorkOrderRecord.d.ts +25 -29
  64. package/dist/records-v2/WorkOrderRecord.js +29 -36
  65. package/dist/records-v2/index.d.ts +1 -0
  66. package/dist/records-v2/index.js +7 -4
  67. package/package.json +1 -1
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ /**
3
+ * BrskEntityMigrationError 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.brskEntityMigrationErrors.new();
14
+ * await record.createBrskEntityMigrationError({ ... }).execute();
15
+ * ```
16
+ *
17
+ * Entity Types: DEFAULT
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.isBrskEntityMigrationErrorRecord = exports.BrskEntityMigrationErrorRecord = void 0;
32
+ const uuid_1 = require("uuid");
33
+ const core_1 = require("@d19n/odin-types/dist/core");
34
+ /**
35
+ * Builder for action execution with dryRun support
36
+ *
37
+ * Provides a consistent API across all action types:
38
+ * - `.execute()` - Execute the action and return results
39
+ * - `.dryRun()` - Return the payload without executing (for debugging)
40
+ */
41
+ class ActionBuilder {
42
+ constructor(provider, moduleName, entityName, payload, clearPendingLinks) {
43
+ this._provider = provider;
44
+ this._moduleName = moduleName;
45
+ this._entityName = entityName;
46
+ this._payload = payload;
47
+ this._clearPendingLinks = clearPendingLinks;
48
+ }
49
+ /**
50
+ * Set an external system identifier for this record.
51
+ * Links the record to a corresponding entry in an external application.
52
+ *
53
+ * @param externalId - The ID in the external system
54
+ * @param externalAppId - The external application identifier
55
+ * @returns this (for chaining)
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * await record.createOrder({ ... }).withExternalId('SF-123', 'salesforce').execute();
60
+ * ```
61
+ */
62
+ withExternalId(externalId, externalAppId) {
63
+ this._payload.externalId = externalId;
64
+ this._payload.externalAppId = externalAppId;
65
+ return this;
66
+ }
67
+ /**
68
+ * Set security/access groups for this record.
69
+ * Controls which user groups can access the record.
70
+ *
71
+ * @param groups - Array of group names
72
+ * @returns this (for chaining)
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * await record.createOrder({ ... }).withGroups(['TenantA', 'BillingTeam']).execute();
77
+ * ```
78
+ */
79
+ withGroups(groups) {
80
+ this._payload.groups = groups;
81
+ return this;
82
+ }
83
+ /**
84
+ * Execute the action
85
+ * @returns The result from the API
86
+ */
87
+ execute() {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const result = yield this._provider._applyAction(this._moduleName, this._entityName, this._payload);
90
+ this._clearPendingLinks();
91
+ return result;
92
+ });
93
+ }
94
+ /**
95
+ * Returns the request payload without executing (for debugging)
96
+ * @returns The request payload that would be sent to the API
97
+ */
98
+ dryRun() {
99
+ return this._payload;
100
+ }
101
+ /**
102
+ * Prevents accidental `await actionBuilder` without .execute()
103
+ * Forces developers to explicitly call .execute()
104
+ * @throws Error always - use .execute() or .dryRun() instead
105
+ */
106
+ then() {
107
+ throw new Error('ActionBuilder cannot be awaited directly. Call .execute() to run the action or .dryRun() to get the payload.');
108
+ }
109
+ }
110
+ class BrskEntityMigrationErrorRecord {
111
+ /**
112
+ * Create a record wrapper.
113
+ * @param record - The underlying record, or null for create operations
114
+ * @param provider - The API or DB provider
115
+ * @param preGeneratedId - Optional pre-generated ID for new records (auto-generated if not provided)
116
+ */
117
+ constructor(record, provider, preGeneratedId) {
118
+ this._pendingLinks = [];
119
+ this._record = record;
120
+ this._provider = provider;
121
+ this._preGeneratedId = preGeneratedId !== null && preGeneratedId !== void 0 ? preGeneratedId : (0, uuid_1.v4)();
122
+ }
123
+ // ============================================
124
+ // CORE PROPERTIES
125
+ // ============================================
126
+ /** Returns true if this is a new (unsaved) record */
127
+ get isNew() { var _a; return !((_a = this._record) === null || _a === void 0 ? void 0 : _a.id); }
128
+ /** Record ID - always available (pre-generated for new records) */
129
+ 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; }
130
+ get entity() { var _a, _b; return (_b = (_a = this._record) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : 'AuditModule:BrskEntityMigrationError'; }
131
+ get type() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.type; }
132
+ /** Record properties - empty object for new (unsaved) records */
133
+ get properties() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.properties) || {}; }
134
+ get title() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.title; }
135
+ get recordNumber() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.recordNumber; }
136
+ get stage() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.stage; }
137
+ get createdAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.createdAt; }
138
+ get updatedAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.updatedAt; }
139
+ get externalId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalId; }
140
+ get externalAppId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalAppId; }
141
+ get groups() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.groups) || []; }
142
+ /** Access the underlying OdinRecord (null for new records) */
143
+ get record() { return this._record; }
144
+ // ============================================
145
+ // TYPE GUARDS (with TypeScript type predicates)
146
+ // ============================================
147
+ /**
148
+ * Type guard: check if this record is of type DEFAULT
149
+ *
150
+ * When this returns true, TypeScript automatically narrows the type,
151
+ * giving you access to DEFAULT-specific properties.
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * if (record.isDefault()) {
156
+ * // TypeScript knows record.properties is BrskEntityMigrationErrorProperties
157
+ * console.log(record.properties.SomeTypeSpecificField);
158
+ * }
159
+ * ```
160
+ * @remarks This is the default record type
161
+ */
162
+ isDefault() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.type) === 'DEFAULT'; }
163
+ // ============================================
164
+ // LINK MANAGEMENT
165
+ // ============================================
166
+ /**
167
+ * Queue a link to be created with the next action.
168
+ * Works for both create and update actions.
169
+ * @returns this (for chaining)
170
+ */
171
+ link(target) {
172
+ this._pendingLinks.push(new core_1.OdinRecordLinkDto({ id: target.id, entity: target.entity }));
173
+ return this;
174
+ }
175
+ /** Get the currently queued links */
176
+ get pendingLinks() {
177
+ return [...this._pendingLinks];
178
+ }
179
+ /** Clear pending links without executing an action */
180
+ clearPendingLinks() {
181
+ this._pendingLinks = [];
182
+ return this;
183
+ }
184
+ /**
185
+ * Immediately unlink a record (API call).
186
+ * Unlike link(), this executes immediately.
187
+ * @throws Error if called on a new (unsaved) record
188
+ */
189
+ unlink(target) {
190
+ var _a;
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
193
+ throw new Error('Cannot unlink from a new (unsaved) record');
194
+ const targetId = typeof target === 'string' ? target : target.id;
195
+ yield this._provider._deleteLinks('AuditModule', 'BrskEntityMigrationError', this._record.id, targetId);
196
+ });
197
+ }
198
+ // ============================================
199
+ // CREATE ACTIONS (no existing record required)
200
+ // ============================================
201
+ /**
202
+ * CreateBrskMigrationError
203
+ *
204
+ * Creates a new BrskEntityMigrationError record with the specified properties.
205
+ * Returns an ActionBuilder - call .execute() to create or .dryRun() for debugging.
206
+ *
207
+ * @param properties - The properties for the new record
208
+ * @param options - Optional settings
209
+ * @param options.type - Override the record type
210
+ * @param options.journeyId - Associate with a journey
211
+ * @param options.stageKey - Set initial pipeline stage
212
+ * @returns ActionBuilder - call .execute() to create or .dryRun() for payload
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * // Create with properties
217
+ * const record = odinClient.brskEntityMigrationErrors.new();
218
+ * await record.createBrskMigrationError({ ... }).execute();
219
+ *
220
+ * // Dry run (for debugging)
221
+ * const payload = record.createBrskMigrationError({ ... }).dryRun();
222
+ * ```
223
+ */
224
+ createBrskMigrationError(properties, options) {
225
+ var _a, _b;
226
+ const payload = {
227
+ entity: 'AuditModule:BrskEntityMigrationError',
228
+ type: (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : (_b = this._record) === null || _b === void 0 ? void 0 : _b.type,
229
+ actionName: 'CreateBrskMigrationError',
230
+ properties: properties || {},
231
+ associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined,
232
+ journeyId: options === null || options === void 0 ? void 0 : options.journeyId,
233
+ stageKey: options === null || options === void 0 ? void 0 : options.stageKey,
234
+ };
235
+ return new ActionBuilder(this._provider, 'AuditModule', 'BrskEntityMigrationError', payload, () => { this._pendingLinks = []; });
236
+ }
237
+ }
238
+ exports.BrskEntityMigrationErrorRecord = BrskEntityMigrationErrorRecord;
239
+ /** Type guard to check if an object is a BrskEntityMigrationErrorRecord */
240
+ function isBrskEntityMigrationErrorRecord(obj) {
241
+ return obj instanceof BrskEntityMigrationErrorRecord;
242
+ }
243
+ exports.isBrskEntityMigrationErrorRecord = isBrskEntityMigrationErrorRecord;
@@ -171,6 +171,8 @@ class CreateCaseFromContactFlowBuilder {
171
171
  entity: 'SupportModule:Case',
172
172
  schemaId: 'be8173eb-269b-4a67-be0c-11ce6af5d561',
173
173
  schemaActionId: '4fd9f78b-0d8f-414e-96cf-aedf37b36d23',
174
+ schemaTypeId: '2d18d4c3-b4f8-4633-bfb0-ff0d62fbaecf',
175
+ type: 'DEFAULT',
174
176
  autoLinkParent: true,
175
177
  associations: (_a = options === null || options === void 0 ? void 0 : options.associations) === null || _a === void 0 ? void 0 : _a.map(a => (Object.assign(Object.assign({}, a), { linkType: null, relationType: undefined }))),
176
178
  groups: options === null || options === void 0 ? void 0 : options.groups,
@@ -28,6 +28,7 @@ import { CreateBacsPgSubmissionAllocationProperties } from '../actions-v2/Create
28
28
  import { UpdatePgAllocationWithAcknowledgementOneProperties } from '../actions-v2/UpdatePgAllocationWithAcknowledgementOneDto';
29
29
  import { UpdatePgAllocationWithAcknowledgementTwoProperties } from '../actions-v2/UpdatePgAllocationWithAcknowledgementTwoDto';
30
30
  import { UpdatePgAllocationWithBacsReportProperties } from '../actions-v2/UpdatePgAllocationWithBacsReportDto';
31
+ import { UpdatePgFileAllocationProperties } from '../actions-v2/UpdatePgFileAllocationDto';
31
32
  import { PgDirectDebitFileRecord } from './PgDirectDebitFileRecord';
32
33
  import { PgPaymentMethodRecord } from './PgPaymentMethodRecord';
33
34
  import { PgTransactionRecord } from './PgTransactionRecord';
@@ -381,6 +382,33 @@ export declare class PgFileAllocationRecord<TProps = PgFileAllocationProperties>
381
382
  journeyId?: string;
382
383
  stageKey?: string;
383
384
  }): ActionBuilder;
385
+ /**
386
+ * UpdatePgFileAllocation
387
+ *
388
+ * Updates this PgFileAllocation record.
389
+ * Returns an ActionBuilder - call .execute() to update or .dryRun() for debugging.
390
+ *
391
+ * @param propertiesOrOptions - Properties to update, or options object
392
+ * @param options - Optional settings (journeyId, stageKey)
393
+ * @returns ActionBuilder - call .execute() to update or .dryRun() for payload
394
+ * @throws Error if called on a new (unsaved) record
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const record = await odinClient.pgFileAllocations.get(id);
399
+ * await record.updatePgFileAllocation({ ... }).execute();
400
+ *
401
+ * // Dry run (for debugging)
402
+ * const payload = record.updatePgFileAllocation({ ... }).dryRun();
403
+ * ```
404
+ */
405
+ updatePgFileAllocation(propertiesOrOptions?: UpdatePgFileAllocationProperties | {
406
+ journeyId?: string;
407
+ stageKey?: string;
408
+ }, options?: {
409
+ journeyId?: string;
410
+ stageKey?: string;
411
+ }): ActionBuilder;
384
412
  }
385
413
  /** Type guard to check if an object is a PgFileAllocationRecord */
386
414
  export declare function isPgFileAllocationRecord(obj: any): obj is PgFileAllocationRecord;
@@ -486,6 +486,43 @@ class PgFileAllocationRecord {
486
486
  const payload = Object.assign({ id: this._record.id, entity: this._record.entity, type: this._record.type, actionName: 'UpdatePgAllocationWithBacsReport', properties, associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined }, options);
487
487
  return new ActionBuilder(this._provider, 'BillingModule', 'PgFileAllocation', payload, () => { this._pendingLinks = []; });
488
488
  }
489
+ /**
490
+ * UpdatePgFileAllocation
491
+ *
492
+ * Updates this PgFileAllocation record.
493
+ * Returns an ActionBuilder - call .execute() to update or .dryRun() for debugging.
494
+ *
495
+ * @param propertiesOrOptions - Properties to update, or options object
496
+ * @param options - Optional settings (journeyId, stageKey)
497
+ * @returns ActionBuilder - call .execute() to update or .dryRun() for payload
498
+ * @throws Error if called on a new (unsaved) record
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * const record = await odinClient.pgFileAllocations.get(id);
503
+ * await record.updatePgFileAllocation({ ... }).execute();
504
+ *
505
+ * // Dry run (for debugging)
506
+ * const payload = record.updatePgFileAllocation({ ... }).dryRun();
507
+ * ```
508
+ */
509
+ updatePgFileAllocation(propertiesOrOptions, options) {
510
+ var _a;
511
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
512
+ throw new Error('updatePgFileAllocation requires an existing record. Use accessor.get() first.');
513
+ let properties = {};
514
+ let opts = options;
515
+ if (propertiesOrOptions) {
516
+ if ('journeyId' in propertiesOrOptions || 'stageKey' in propertiesOrOptions) {
517
+ opts = propertiesOrOptions;
518
+ }
519
+ else {
520
+ properties = propertiesOrOptions;
521
+ }
522
+ }
523
+ const payload = Object.assign({ id: this._record.id, entity: this._record.entity, type: this._record.type, actionName: 'UpdatePgFileAllocation', properties, associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined }, opts);
524
+ return new ActionBuilder(this._provider, 'BillingModule', 'PgFileAllocation', payload, () => { this._pendingLinks = []; });
525
+ }
489
526
  }
490
527
  exports.PgFileAllocationRecord = PgFileAllocationRecord;
491
528
  // ============================================
@@ -28,6 +28,7 @@ import { ContactRecord } from './ContactRecord';
28
28
  import { AffiliateCodeRecord } from './AffiliateCodeRecord';
29
29
  import { CampaignRecord } from './CampaignRecord';
30
30
  import { OrderRecord } from './OrderRecord';
31
+ import { RewardRecord } from './RewardRecord';
31
32
  /** Valid entity types for Referral */
32
33
  export declare type ReferralType = 'ORDER';
33
34
  /**
@@ -97,6 +98,7 @@ export declare class ReferralRecord<TProps = ReferralProperties> {
97
98
  private _affiliateCodes?;
98
99
  private _campaigns?;
99
100
  private _orders?;
101
+ private _rewards?;
100
102
  /**
101
103
  * Create a record wrapper.
102
104
  * @param record - The underlying record, or null for create operations
@@ -210,6 +212,24 @@ export declare class ReferralRecord<TProps = ReferralProperties> {
210
212
  * ```
211
213
  */
212
214
  get orders(): RecordLinkManager<OrderRecord, typeof ReferralRecord['ordersLabels'][number]>;
215
+ /** Valid labels for Reward associations */
216
+ static readonly rewardsLabels: readonly ["OrderReferralCashbackReward"];
217
+ /**
218
+ * Access linked Reward records
219
+ * @remarks Available labels: OrderReferralCashbackReward
220
+ * @throws Error if called on a new (unsaved) record
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * // Get all linked Reward records
225
+ * const items = await record.rewards.list();
226
+ * const first = await record.rewards.first();
227
+ *
228
+ * // Filter by label
229
+ * const specific = await record.rewards.first({ label: 'OrderReferralCashbackReward' });
230
+ * ```
231
+ */
232
+ get rewards(): RecordLinkManager<RewardRecord, typeof ReferralRecord['rewardsLabels'][number]>;
213
233
  /**
214
234
  * Queue a link to be created with the next action.
215
235
  * Works for both create and update actions.
@@ -36,6 +36,7 @@ const ContactRecord_1 = require("./ContactRecord");
36
36
  const AffiliateCodeRecord_1 = require("./AffiliateCodeRecord");
37
37
  const CampaignRecord_1 = require("./CampaignRecord");
38
38
  const OrderRecord_1 = require("./OrderRecord");
39
+ const RewardRecord_1 = require("./RewardRecord");
39
40
  /**
40
41
  * Builder for action execution with dryRun support
41
42
  *
@@ -285,6 +286,36 @@ class ReferralRecord {
285
286
  }
286
287
  return this._orders;
287
288
  }
289
+ /**
290
+ * Access linked Reward records
291
+ * @remarks Available labels: OrderReferralCashbackReward
292
+ * @throws Error if called on a new (unsaved) record
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * // Get all linked Reward records
297
+ * const items = await record.rewards.list();
298
+ * const first = await record.rewards.first();
299
+ *
300
+ * // Filter by label
301
+ * const specific = await record.rewards.first({ label: 'OrderReferralCashbackReward' });
302
+ * ```
303
+ */
304
+ get rewards() {
305
+ var _a;
306
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
307
+ throw new Error('Cannot access links on a new (unsaved) record');
308
+ if (!this._rewards) {
309
+ this._rewards = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
310
+ sourceEntity: 'CrmModule:Referral',
311
+ targetEntity: 'CrmModule:Reward',
312
+ targetModuleName: 'CrmModule',
313
+ targetEntityName: 'Reward',
314
+ labels: ['OrderReferralCashbackReward'],
315
+ }, RewardRecord_1.RewardRecord);
316
+ }
317
+ return this._rewards;
318
+ }
288
319
  // ============================================
289
320
  // LINK MANAGEMENT
290
321
  // ============================================
@@ -549,6 +580,8 @@ ReferralRecord.affiliateCodesLabels = ['AffiliateCodeReferrals'];
549
580
  ReferralRecord.campaignsLabels = ['CampaignReferrals'];
550
581
  /** Valid labels for Order associations */
551
582
  ReferralRecord.ordersLabels = ['OrderReferral'];
583
+ /** Valid labels for Reward associations */
584
+ ReferralRecord.rewardsLabels = ['OrderReferralCashbackReward'];
552
585
  /** Type guard to check if an object is a ReferralRecord */
553
586
  function isReferralRecord(obj) {
554
587
  return obj instanceof ReferralRecord;
@@ -24,10 +24,13 @@ 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
25
  import { RewardProperties, CashbackRewardProperties } from '../entities-v2/Reward';
26
26
  import { CreateCashbackRewardProperties } from '../actions-v2/CreateCashbackRewardDto';
27
+ import { CreateCashbackRewardForOrderReferralProperties } from '../actions-v2/CreateCashbackRewardForOrderReferralDto';
28
+ import { CreateCashbackRewardForOrderReferralBuilder } from '../actions-v2/CreateCashbackRewardForOrderReferralDto';
27
29
  import { CampaignRecord } from './CampaignRecord';
28
30
  import { ContactRecord } from './ContactRecord';
29
31
  import { AffiliateCodeRecord } from './AffiliateCodeRecord';
30
32
  import { PaymentMethodRefundRecord } from './PaymentMethodRefundRecord';
33
+ import { ReferralRecord } from './ReferralRecord';
31
34
  /** Valid entity types for Reward */
32
35
  export declare type RewardType = 'CASHBACK';
33
36
  /**
@@ -97,6 +100,7 @@ export declare class RewardRecord<TProps = RewardProperties> {
97
100
  private _contacts?;
98
101
  private _affiliateCodes?;
99
102
  private _paymentMethodRefunds?;
103
+ private _referrals?;
100
104
  /**
101
105
  * Create a record wrapper.
102
106
  * @param record - The underlying record, or null for create operations
@@ -210,6 +214,24 @@ export declare class RewardRecord<TProps = RewardProperties> {
210
214
  * ```
211
215
  */
212
216
  get paymentMethodRefunds(): RecordLinkManager<PaymentMethodRefundRecord, typeof RewardRecord['paymentMethodRefundsLabels'][number]>;
217
+ /** Valid labels for Referral associations */
218
+ static readonly referralsLabels: readonly ["OrderReferralCashbackReward"];
219
+ /**
220
+ * Access linked Referral records
221
+ * @remarks Available labels: OrderReferralCashbackReward
222
+ * @throws Error if called on a new (unsaved) record
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * // Get all linked Referral records
227
+ * const items = await record.referrals.list();
228
+ * const first = await record.referrals.first();
229
+ *
230
+ * // Filter by label
231
+ * const specific = await record.referrals.first({ label: 'OrderReferralCashbackReward' });
232
+ * ```
233
+ */
234
+ get referrals(): RecordLinkManager<ReferralRecord, typeof RewardRecord['referralsLabels'][number]>;
213
235
  /**
214
236
  * Queue a link to be created with the next action.
215
237
  * Works for both create and update actions.
@@ -259,6 +281,33 @@ export declare class RewardRecord<TProps = RewardProperties> {
259
281
  journeyId?: string;
260
282
  stageKey?: string;
261
283
  }): ActionBuilder;
284
+ /**
285
+ * CreateCashbackRewardForOrderReferral
286
+ *
287
+ * Creates a new Reward record with the specified properties.
288
+ * Returns a builder with fluent .link*() methods for associations.
289
+ * Call .execute() to create or .dryRun() for debugging.
290
+ *
291
+ * @remarks Record type: CASHBACK
292
+ *
293
+ * @param properties - The properties for the new record
294
+ * @param options - Optional settings
295
+ * @param options.journeyId - Associate with a journey
296
+ * @param options.stageKey - Set initial pipeline stage
297
+ * @returns CreateCashbackRewardForOrderReferralBuilder - chain .link*() then .execute()
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const record = odinClient.rewards.new();
302
+ * await record.createCashbackRewardForOrderReferral({ ... })
303
+ * .linkAssociation_xxx(target)
304
+ * .execute();
305
+ * ```
306
+ */
307
+ createCashbackRewardForOrderReferral(properties: CreateCashbackRewardForOrderReferralProperties, options?: {
308
+ journeyId?: string;
309
+ stageKey?: string;
310
+ }): CreateCashbackRewardForOrderReferralBuilder;
262
311
  /**
263
312
  * MoveCashbackRewardToAwarded
264
313
  *
@@ -32,10 +32,12 @@ exports.isRewardRecord = exports.RewardRecord = void 0;
32
32
  const uuid_1 = require("uuid");
33
33
  const core_1 = require("@d19n/odin-types/dist/core");
34
34
  const record_link_manager_1 = require("@d19n/odin-sdk-generator/dist/record-link-manager");
35
+ const CreateCashbackRewardForOrderReferralDto_1 = require("../actions-v2/CreateCashbackRewardForOrderReferralDto");
35
36
  const CampaignRecord_1 = require("./CampaignRecord");
36
37
  const ContactRecord_1 = require("./ContactRecord");
37
38
  const AffiliateCodeRecord_1 = require("./AffiliateCodeRecord");
38
39
  const PaymentMethodRefundRecord_1 = require("./PaymentMethodRefundRecord");
40
+ const ReferralRecord_1 = require("./ReferralRecord");
39
41
  /**
40
42
  * Builder for action execution with dryRun support
41
43
  *
@@ -285,6 +287,36 @@ class RewardRecord {
285
287
  }
286
288
  return this._paymentMethodRefunds;
287
289
  }
290
+ /**
291
+ * Access linked Referral records
292
+ * @remarks Available labels: OrderReferralCashbackReward
293
+ * @throws Error if called on a new (unsaved) record
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * // Get all linked Referral records
298
+ * const items = await record.referrals.list();
299
+ * const first = await record.referrals.first();
300
+ *
301
+ * // Filter by label
302
+ * const specific = await record.referrals.first({ label: 'OrderReferralCashbackReward' });
303
+ * ```
304
+ */
305
+ get referrals() {
306
+ var _a;
307
+ if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
308
+ throw new Error('Cannot access links on a new (unsaved) record');
309
+ if (!this._referrals) {
310
+ this._referrals = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
311
+ sourceEntity: 'CrmModule:Reward',
312
+ targetEntity: 'CrmModule:Referral',
313
+ targetModuleName: 'CrmModule',
314
+ targetEntityName: 'Referral',
315
+ labels: ['OrderReferralCashbackReward'],
316
+ }, ReferralRecord_1.ReferralRecord);
317
+ }
318
+ return this._referrals;
319
+ }
288
320
  // ============================================
289
321
  // LINK MANAGEMENT
290
322
  // ============================================
@@ -359,6 +391,32 @@ class RewardRecord {
359
391
  };
360
392
  return new ActionBuilder(this._provider, 'CrmModule', 'Reward', payload, () => { this._pendingLinks = []; });
361
393
  }
394
+ /**
395
+ * CreateCashbackRewardForOrderReferral
396
+ *
397
+ * Creates a new Reward record with the specified properties.
398
+ * Returns a builder with fluent .link*() methods for associations.
399
+ * Call .execute() to create or .dryRun() for debugging.
400
+ *
401
+ * @remarks Record type: CASHBACK
402
+ *
403
+ * @param properties - The properties for the new record
404
+ * @param options - Optional settings
405
+ * @param options.journeyId - Associate with a journey
406
+ * @param options.stageKey - Set initial pipeline stage
407
+ * @returns CreateCashbackRewardForOrderReferralBuilder - chain .link*() then .execute()
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * const record = odinClient.rewards.new();
412
+ * await record.createCashbackRewardForOrderReferral({ ... })
413
+ * .linkAssociation_xxx(target)
414
+ * .execute();
415
+ * ```
416
+ */
417
+ createCashbackRewardForOrderReferral(properties, options) {
418
+ return new CreateCashbackRewardForOrderReferralDto_1.CreateCashbackRewardForOrderReferralBuilder(properties || {}, [...this._pendingLinks], options).withProvider(this._provider, 'CrmModule', 'Reward', () => { this._pendingLinks = []; });
419
+ }
362
420
  // ============================================
363
421
  // UPDATE ACTIONS (require existing record)
364
422
  // ============================================
@@ -433,6 +491,8 @@ RewardRecord.contactsLabels = ['ContactReward'];
433
491
  RewardRecord.affiliateCodesLabels = ['AffiliateCodeRewards'];
434
492
  /** Valid labels for PaymentMethodRefund associations */
435
493
  RewardRecord.paymentMethodRefundsLabels = ['RewardPaymentMethodRefund'];
494
+ /** Valid labels for Referral associations */
495
+ RewardRecord.referralsLabels = ['OrderReferralCashbackReward'];
436
496
  /** Type guard to check if an object is a RewardRecord */
437
497
  function isRewardRecord(obj) {
438
498
  return obj instanceof RewardRecord;