@d19n/youfibre-odin-sdk 2.0.39 → 2.0.41
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.
- package/README.md +11 -28
- package/dist/EntityRegistry.d.ts +0 -2
- package/dist/EntityRegistry.js +0 -2
- package/dist/OdinApiClient.d.ts +0 -4
- package/dist/OdinApiClient.js +0 -8
- package/dist/OdinDbClient.d.ts +0 -4
- package/dist/OdinDbClient.js +0 -8
- package/dist/accessors-v2/index.d.ts +0 -1
- package/dist/accessors-v2/index.js +2 -4
- package/dist/actions-v2/AssignCaseDto.d.ts +4 -4
- package/dist/actions-v2/AssignCaseWithNoteFlowDto.d.ts +4 -4
- package/dist/actions-v2/CreateAddressCrmDatasetDto.d.ts +116 -0
- package/dist/actions-v2/CreateAddressCrmDatasetDto.js +59 -0
- package/dist/actions-v2/CreateCaseFromContactDto.d.ts +4 -4
- package/dist/db-accessors-v2/index.d.ts +0 -1
- package/dist/db-accessors-v2/index.js +2 -4
- package/dist/entities-v2/Config.d.ts +8 -8
- package/dist/entities-v2/Config.js +4 -4
- package/dist/entities-v2/CrmDataset.d.ts +23 -1
- package/dist/entities-v2/CrmDataset.js +2 -0
- package/dist/entities-v2/Lead.d.ts +0 -7
- package/dist/entities-v2/Lead.js +0 -2
- package/dist/entities-v2/ServiceAppointmentConfig.d.ts +6 -3
- package/dist/entities-v2/ServiceAppointmentConfig.js +6 -3
- package/dist/entities-v2/WorkOrder.d.ts +3 -1
- package/dist/entities-v2/WorkOrder.js +2 -0
- package/dist/records-v2/AccountRecord.d.ts +0 -29
- package/dist/records-v2/AccountRecord.js +0 -36
- package/dist/records-v2/AddressRecord.d.ts +0 -28
- package/dist/records-v2/AddressRecord.js +1 -45
- package/dist/records-v2/CaseRecord.js +8 -62
- package/dist/records-v2/ChurnRequestRecord.js +1 -7
- package/dist/records-v2/ContactRecord.d.ts +0 -49
- package/dist/records-v2/ContactRecord.js +1 -79
- package/dist/records-v2/ContractBuyOutRecord.js +2 -14
- package/dist/records-v2/CrmDatasetRecord.d.ts +29 -0
- package/dist/records-v2/CrmDatasetRecord.js +36 -0
- package/dist/records-v2/CustomerDeviceOntRecord.js +1 -7
- package/dist/records-v2/LeadRecord.d.ts +0 -29
- package/dist/records-v2/LeadRecord.js +0 -36
- package/dist/records-v2/OrderItemRecord.d.ts +0 -29
- package/dist/records-v2/OrderItemRecord.js +0 -36
- package/dist/records-v2/OrderRecord.d.ts +0 -99
- package/dist/records-v2/OrderRecord.js +8 -182
- package/dist/records-v2/PICRequestRecord.js +1 -7
- package/dist/records-v2/PaymentMethodRefundRecord.js +1 -6
- package/dist/records-v2/TestEntityForVisualBuilderRecord.js +1 -6
- package/dist/records-v2/WorkOrderRecord.js +41 -364
- package/dist/records-v2/index.d.ts +1 -2
- package/dist/records-v2/index.js +6 -9
- package/package.json +2 -2
- package/dist/accessors-v2/PhoneNumberAccessor.d.ts +0 -111
- package/dist/accessors-v2/PhoneNumberAccessor.js +0 -190
- package/dist/actions-v2/CreateAccountFromBrskDto.d.ts +0 -102
- package/dist/actions-v2/CreateAccountFromBrskDto.js +0 -54
- package/dist/actions-v2/CreateContactFromBrskDto.d.ts +0 -107
- package/dist/actions-v2/CreateContactFromBrskDto.js +0 -52
- package/dist/actions-v2/CreateLeadFromBrskDto.d.ts +0 -118
- package/dist/actions-v2/CreateLeadFromBrskDto.js +0 -52
- package/dist/actions-v2/CreateOrderFromBrskDto.d.ts +0 -138
- package/dist/actions-v2/CreateOrderFromBrskDto.js +0 -52
- package/dist/actions-v2/CreateOrderItemFromBrskDto.d.ts +0 -198
- package/dist/actions-v2/CreateOrderItemFromBrskDto.js +0 -52
- package/dist/actions-v2/CreatePhoneNumberFromBrskDto.d.ts +0 -67
- package/dist/actions-v2/CreatePhoneNumberFromBrskDto.js +0 -54
- package/dist/actions-v2/MoveOrderFromSupplyToActiveDto.d.ts +0 -112
- package/dist/actions-v2/MoveOrderFromSupplyToActiveDto.js +0 -77
- package/dist/actions-v2/MoveOrderFromSupplyToCancelledDto.d.ts +0 -112
- package/dist/actions-v2/MoveOrderFromSupplyToCancelledDto.js +0 -77
- package/dist/actions-v2/UpdateAddressFromBrskDto.d.ts +0 -61
- package/dist/actions-v2/UpdateAddressFromBrskDto.js +0 -54
- package/dist/db-accessors-v2/PhoneNumberDbAccessor.d.ts +0 -149
- package/dist/db-accessors-v2/PhoneNumberDbAccessor.js +0 -227
- package/dist/records-v2/PhoneNumberRecord.d.ts +0 -205
- package/dist/records-v2/PhoneNumberRecord.js +0 -292
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* PhoneNumber 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.phoneNumbers.new();
|
|
14
|
-
* await record.createPhoneNumber({ ... }).execute();
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* AUTO-GENERATED - DO NOT EDIT DIRECTLY
|
|
18
|
-
*/
|
|
19
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.isPhoneNumberRecord = exports.PhoneNumberRecord = void 0;
|
|
30
|
-
const uuid_1 = require("uuid");
|
|
31
|
-
const core_1 = require("@d19n/odin-types/dist/core");
|
|
32
|
-
const record_link_manager_1 = require("@d19n/odin-sdk-generator/dist/record-link-manager");
|
|
33
|
-
const OrderRecord_1 = require("./OrderRecord");
|
|
34
|
-
const ContactRecord_1 = require("./ContactRecord");
|
|
35
|
-
/**
|
|
36
|
-
* Builder for action execution with dryRun support
|
|
37
|
-
*
|
|
38
|
-
* Provides a consistent API across all action types:
|
|
39
|
-
* - `.execute()` - Execute the action and return results
|
|
40
|
-
* - `.dryRun()` - Return the payload without executing (for debugging)
|
|
41
|
-
*/
|
|
42
|
-
class ActionBuilder {
|
|
43
|
-
constructor(provider, moduleName, entityName, payload, clearPendingLinks) {
|
|
44
|
-
this._provider = provider;
|
|
45
|
-
this._moduleName = moduleName;
|
|
46
|
-
this._entityName = entityName;
|
|
47
|
-
this._payload = payload;
|
|
48
|
-
this._clearPendingLinks = clearPendingLinks;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Set an external system identifier for this record.
|
|
52
|
-
* Links the record to a corresponding entry in an external application.
|
|
53
|
-
*
|
|
54
|
-
* @param externalId - The ID in the external system
|
|
55
|
-
* @param externalAppId - The external application identifier
|
|
56
|
-
* @returns this (for chaining)
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* await record.createOrder({ ... }).withExternalId('SF-123', 'salesforce').execute();
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
withExternalId(externalId, externalAppId) {
|
|
64
|
-
this._payload.externalId = externalId;
|
|
65
|
-
this._payload.externalAppId = externalAppId;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Set security/access groups for this record.
|
|
70
|
-
* Controls which user groups can access the record.
|
|
71
|
-
*
|
|
72
|
-
* @param groups - Array of group names
|
|
73
|
-
* @returns this (for chaining)
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* await record.createOrder({ ... }).withGroups(['TenantA', 'BillingTeam']).execute();
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
withGroups(groups) {
|
|
81
|
-
this._payload.groups = groups;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Execute the action
|
|
86
|
-
* @returns The result from the API
|
|
87
|
-
*/
|
|
88
|
-
execute() {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const result = yield this._provider._applyAction(this._moduleName, this._entityName, this._payload);
|
|
91
|
-
this._clearPendingLinks();
|
|
92
|
-
return result;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Returns the request payload without executing (for debugging)
|
|
97
|
-
* @returns The request payload that would be sent to the API
|
|
98
|
-
*/
|
|
99
|
-
dryRun() {
|
|
100
|
-
return this._payload;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Prevents accidental `await actionBuilder` without .execute()
|
|
104
|
-
* Forces developers to explicitly call .execute()
|
|
105
|
-
* @throws Error always - use .execute() or .dryRun() instead
|
|
106
|
-
*/
|
|
107
|
-
then() {
|
|
108
|
-
throw new Error('ActionBuilder cannot be awaited directly. Call .execute() to run the action or .dryRun() to get the payload.');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
class PhoneNumberRecord {
|
|
112
|
-
/**
|
|
113
|
-
* Create a record wrapper.
|
|
114
|
-
* @param record - The underlying record, or null for create operations
|
|
115
|
-
* @param provider - The API or DB provider
|
|
116
|
-
* @param preGeneratedId - Optional pre-generated ID for new records (auto-generated if not provided)
|
|
117
|
-
*/
|
|
118
|
-
constructor(record, provider, preGeneratedId) {
|
|
119
|
-
this._pendingLinks = [];
|
|
120
|
-
this._record = record;
|
|
121
|
-
this._provider = provider;
|
|
122
|
-
this._preGeneratedId = preGeneratedId !== null && preGeneratedId !== void 0 ? preGeneratedId : (0, uuid_1.v4)();
|
|
123
|
-
}
|
|
124
|
-
// ============================================
|
|
125
|
-
// CORE PROPERTIES
|
|
126
|
-
// ============================================
|
|
127
|
-
/** Returns true if this is a new (unsaved) record */
|
|
128
|
-
get isNew() { var _a; return !((_a = this._record) === null || _a === void 0 ? void 0 : _a.id); }
|
|
129
|
-
/** Record ID - always available (pre-generated for new records) */
|
|
130
|
-
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; }
|
|
131
|
-
get entity() { var _a, _b; return (_b = (_a = this._record) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : 'CrmModule:PhoneNumber'; }
|
|
132
|
-
get type() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.type; }
|
|
133
|
-
/** Record properties - empty object for new (unsaved) records */
|
|
134
|
-
get properties() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.properties) || {}; }
|
|
135
|
-
get title() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.title; }
|
|
136
|
-
get recordNumber() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.recordNumber; }
|
|
137
|
-
get stage() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.stage; }
|
|
138
|
-
get createdAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.createdAt; }
|
|
139
|
-
get updatedAt() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.updatedAt; }
|
|
140
|
-
get externalId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalId; }
|
|
141
|
-
get externalAppId() { var _a; return (_a = this._record) === null || _a === void 0 ? void 0 : _a.externalAppId; }
|
|
142
|
-
get groups() { var _a; return ((_a = this._record) === null || _a === void 0 ? void 0 : _a.groups) || []; }
|
|
143
|
-
/** Access the underlying OdinRecord (null for new records) */
|
|
144
|
-
get record() { return this._record; }
|
|
145
|
-
/**
|
|
146
|
-
* Access linked Order records
|
|
147
|
-
* @remarks Available labels: Order__PhoneNumber
|
|
148
|
-
* @throws Error if called on a new (unsaved) record
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* // Get all linked Order records
|
|
153
|
-
* const items = await record.orders.list();
|
|
154
|
-
* const first = await record.orders.first();
|
|
155
|
-
*
|
|
156
|
-
* // Filter by label
|
|
157
|
-
* const specific = await record.orders.first({ label: 'Order__PhoneNumber' });
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
get orders() {
|
|
161
|
-
var _a;
|
|
162
|
-
if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
|
|
163
|
-
throw new Error('Cannot access links on a new (unsaved) record');
|
|
164
|
-
if (!this._orders) {
|
|
165
|
-
this._orders = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
|
|
166
|
-
sourceEntity: 'CrmModule:PhoneNumber',
|
|
167
|
-
targetEntity: 'OrderModule:Order',
|
|
168
|
-
targetModuleName: 'OrderModule',
|
|
169
|
-
targetEntityName: 'Order',
|
|
170
|
-
labels: ['Order__PhoneNumber'],
|
|
171
|
-
}, OrderRecord_1.OrderRecord);
|
|
172
|
-
}
|
|
173
|
-
return this._orders;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Access linked Contact records
|
|
177
|
-
* @remarks Available labels: Contact__PhoneNumber
|
|
178
|
-
* @throws Error if called on a new (unsaved) record
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```typescript
|
|
182
|
-
* // Get all linked Contact records
|
|
183
|
-
* const items = await record.contacts.list();
|
|
184
|
-
* const first = await record.contacts.first();
|
|
185
|
-
*
|
|
186
|
-
* // Filter by label
|
|
187
|
-
* const specific = await record.contacts.first({ label: 'Contact__PhoneNumber' });
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
get contacts() {
|
|
191
|
-
var _a;
|
|
192
|
-
if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
|
|
193
|
-
throw new Error('Cannot access links on a new (unsaved) record');
|
|
194
|
-
if (!this._contacts) {
|
|
195
|
-
this._contacts = new record_link_manager_1.RecordLinkManager(this._provider, this._record, {
|
|
196
|
-
sourceEntity: 'CrmModule:PhoneNumber',
|
|
197
|
-
targetEntity: 'CrmModule:Contact',
|
|
198
|
-
targetModuleName: 'CrmModule',
|
|
199
|
-
targetEntityName: 'Contact',
|
|
200
|
-
labels: ['Contact__PhoneNumber'],
|
|
201
|
-
}, ContactRecord_1.ContactRecord);
|
|
202
|
-
}
|
|
203
|
-
return this._contacts;
|
|
204
|
-
}
|
|
205
|
-
// ============================================
|
|
206
|
-
// LINK MANAGEMENT
|
|
207
|
-
// ============================================
|
|
208
|
-
/**
|
|
209
|
-
* Queue a link to be created with the next action.
|
|
210
|
-
* Works for both create and update actions.
|
|
211
|
-
* @returns this (for chaining)
|
|
212
|
-
*/
|
|
213
|
-
link(target) {
|
|
214
|
-
this._pendingLinks.push(new core_1.OdinRecordLinkDto({ id: target.id, entity: target.entity }));
|
|
215
|
-
return this;
|
|
216
|
-
}
|
|
217
|
-
/** Get the currently queued links */
|
|
218
|
-
get pendingLinks() {
|
|
219
|
-
return [...this._pendingLinks];
|
|
220
|
-
}
|
|
221
|
-
/** Clear pending links without executing an action */
|
|
222
|
-
clearPendingLinks() {
|
|
223
|
-
this._pendingLinks = [];
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Immediately unlink a record (API call).
|
|
228
|
-
* Unlike link(), this executes immediately.
|
|
229
|
-
* @throws Error if called on a new (unsaved) record
|
|
230
|
-
*/
|
|
231
|
-
unlink(target) {
|
|
232
|
-
var _a;
|
|
233
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
if (!((_a = this._record) === null || _a === void 0 ? void 0 : _a.id))
|
|
235
|
-
throw new Error('Cannot unlink from a new (unsaved) record');
|
|
236
|
-
const targetId = typeof target === 'string' ? target : target.id;
|
|
237
|
-
yield this._provider._deleteLinks('CrmModule', 'PhoneNumber', this._record.id, targetId);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
// ============================================
|
|
241
|
-
// CREATE ACTIONS (no existing record required)
|
|
242
|
-
// ============================================
|
|
243
|
-
/**
|
|
244
|
-
* CreatePhoneNumberFromBrsk
|
|
245
|
-
*
|
|
246
|
-
* Creates a new PhoneNumber record with the specified properties.
|
|
247
|
-
* Returns an ActionBuilder - call .execute() to create or .dryRun() for debugging.
|
|
248
|
-
*
|
|
249
|
-
* @param properties - The properties for the new record
|
|
250
|
-
* @param options - Optional settings
|
|
251
|
-
* @param options.type - Override the record type
|
|
252
|
-
* @param options.journeyId - Associate with a journey
|
|
253
|
-
* @param options.stageKey - Set initial pipeline stage
|
|
254
|
-
* @returns ActionBuilder - call .execute() to create or .dryRun() for payload
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```typescript
|
|
258
|
-
* // Create with properties
|
|
259
|
-
* const record = odinClient.phoneNumbers.new();
|
|
260
|
-
* await record.createPhoneNumberFromBrsk({ ... }).execute();
|
|
261
|
-
*
|
|
262
|
-
* // Dry run (for debugging)
|
|
263
|
-
* const payload = record.createPhoneNumberFromBrsk({ ... }).dryRun();
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
createPhoneNumberFromBrsk(properties, options) {
|
|
267
|
-
var _a, _b;
|
|
268
|
-
const payload = {
|
|
269
|
-
entity: 'CrmModule:PhoneNumber',
|
|
270
|
-
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,
|
|
271
|
-
actionName: 'CreatePhoneNumberFromBrsk',
|
|
272
|
-
properties: properties || {},
|
|
273
|
-
associations: this._pendingLinks.length > 0 ? this._pendingLinks : undefined,
|
|
274
|
-
journeyId: options === null || options === void 0 ? void 0 : options.journeyId,
|
|
275
|
-
stageKey: options === null || options === void 0 ? void 0 : options.stageKey,
|
|
276
|
-
};
|
|
277
|
-
return new ActionBuilder(this._provider, 'CrmModule', 'PhoneNumber', payload, () => { this._pendingLinks = []; });
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
exports.PhoneNumberRecord = PhoneNumberRecord;
|
|
281
|
-
// ============================================
|
|
282
|
-
// TYPED LINK ACCESSORS
|
|
283
|
-
// ============================================
|
|
284
|
-
/** Valid labels for Order associations */
|
|
285
|
-
PhoneNumberRecord.ordersLabels = ['Order__PhoneNumber'];
|
|
286
|
-
/** Valid labels for Contact associations */
|
|
287
|
-
PhoneNumberRecord.contactsLabels = ['Contact__PhoneNumber'];
|
|
288
|
-
/** Type guard to check if an object is a PhoneNumberRecord */
|
|
289
|
-
function isPhoneNumberRecord(obj) {
|
|
290
|
-
return obj instanceof PhoneNumberRecord;
|
|
291
|
-
}
|
|
292
|
-
exports.isPhoneNumberRecord = isPhoneNumberRecord;
|