@torrow/sdk-client 0.17.2 → 0.18.1
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/dist/index.d.ts +395 -13
- package/dist/index.js +256 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9959,10 +9959,10 @@ function validateOperationNoteTypes(body, method, path) {
|
|
|
9959
9959
|
if (Array.isArray(current) && node.items !== void 0) {
|
|
9960
9960
|
current.forEach((entry, i) => merge(invalidPaths(entry, node.items, `${path2}/${i}`, /* @__PURE__ */ new Set())));
|
|
9961
9961
|
} else if (typeof current === "object" && !Array.isArray(current)) {
|
|
9962
|
-
const
|
|
9962
|
+
const record8 = current;
|
|
9963
9963
|
for (const [key, child] of Object.entries(node.properties ?? {})) {
|
|
9964
|
-
if (Object.hasOwn(
|
|
9965
|
-
merge(invalidPaths(
|
|
9964
|
+
if (Object.hasOwn(record8, key)) {
|
|
9965
|
+
merge(invalidPaths(record8[key], child, `${path2}/${key}`, /* @__PURE__ */ new Set()));
|
|
9966
9966
|
}
|
|
9967
9967
|
}
|
|
9968
9968
|
}
|
|
@@ -11800,7 +11800,7 @@ function copyValue(value, active = /* @__PURE__ */ new Set(), path = [], ridPath
|
|
|
11800
11800
|
if (Array.isArray(value)) {
|
|
11801
11801
|
result = Array.from(value, (child, index) => copyValue(child, active, [...path, index], ridPaths));
|
|
11802
11802
|
} else {
|
|
11803
|
-
const
|
|
11803
|
+
const record8 = {};
|
|
11804
11804
|
for (const key of Reflect.ownKeys(value)) {
|
|
11805
11805
|
if (typeof key !== "string") {
|
|
11806
11806
|
throw itemPatchError("InvalidInput" /* InvalidInput */);
|
|
@@ -11813,14 +11813,14 @@ function copyValue(value, active = /* @__PURE__ */ new Set(), path = [], ridPath
|
|
|
11813
11813
|
if (descriptor.value === void 0 && isPatchRidPath(childPath, ridPaths)) {
|
|
11814
11814
|
continue;
|
|
11815
11815
|
}
|
|
11816
|
-
Object.defineProperty(
|
|
11816
|
+
Object.defineProperty(record8, key, {
|
|
11817
11817
|
value: copyValue(descriptor.value, active, childPath, ridPaths),
|
|
11818
11818
|
enumerable: true,
|
|
11819
11819
|
writable: true,
|
|
11820
11820
|
configurable: true
|
|
11821
11821
|
});
|
|
11822
11822
|
}
|
|
11823
|
-
result =
|
|
11823
|
+
result = record8;
|
|
11824
11824
|
}
|
|
11825
11825
|
active.delete(value);
|
|
11826
11826
|
return result;
|
|
@@ -16575,6 +16575,113 @@ var LoyaltySystemsFacade = class extends TorrowItemCoreFacade {
|
|
|
16575
16575
|
}
|
|
16576
16576
|
};
|
|
16577
16577
|
|
|
16578
|
+
// ../../src/resources/loyalty-cards/types.ts
|
|
16579
|
+
var LoyaltyCardStateValues = /* @__PURE__ */ ((LoyaltyCardStateValues2) => {
|
|
16580
|
+
LoyaltyCardStateValues2["Unknown"] = "UnknownLoyaltyCardState";
|
|
16581
|
+
LoyaltyCardStateValues2["Issued"] = "Issued";
|
|
16582
|
+
LoyaltyCardStateValues2["Actived"] = "Actived";
|
|
16583
|
+
LoyaltyCardStateValues2["Blocked"] = "Blocked";
|
|
16584
|
+
LoyaltyCardStateValues2["Closed"] = "Closed";
|
|
16585
|
+
return LoyaltyCardStateValues2;
|
|
16586
|
+
})(LoyaltyCardStateValues || {});
|
|
16587
|
+
|
|
16588
|
+
// ../../src/resources/loyalty-cards/loyalty-card-patch.ts
|
|
16589
|
+
function omitLoyaltyCardNumber(body) {
|
|
16590
|
+
const payload = { ...body };
|
|
16591
|
+
Reflect.deleteProperty(payload, "cardNumber");
|
|
16592
|
+
return payload;
|
|
16593
|
+
}
|
|
16594
|
+
function contactInformation(value) {
|
|
16595
|
+
return isItemPatchDtoObject(value) && Array.isArray(value.fields) && value.fields.length > 0 && value.fields.every(isItemPatchDtoObject);
|
|
16596
|
+
}
|
|
16597
|
+
function subscriptions(value) {
|
|
16598
|
+
if (!Array.isArray(value)) {
|
|
16599
|
+
return false;
|
|
16600
|
+
}
|
|
16601
|
+
const ids = /* @__PURE__ */ new Set();
|
|
16602
|
+
return value.every((item) => {
|
|
16603
|
+
if (!isItemPatchDtoObject(item) || typeof item.subscriptionId !== "string" || !isItemPatchReferenceId(item.subscriptionId) || ids.has(item.subscriptionId)) {
|
|
16604
|
+
return false;
|
|
16605
|
+
}
|
|
16606
|
+
ids.add(item.subscriptionId);
|
|
16607
|
+
for (const key of ["createDate", "beginDate", "endDate"]) {
|
|
16608
|
+
const date2 = item[key];
|
|
16609
|
+
if (date2 != null && (!(date2 instanceof Date) || !Number.isFinite(date2.getTime()))) {
|
|
16610
|
+
return false;
|
|
16611
|
+
}
|
|
16612
|
+
}
|
|
16613
|
+
if (item.image == null) {
|
|
16614
|
+
return true;
|
|
16615
|
+
}
|
|
16616
|
+
return isItemPatchDtoObject(item.image) && Object.keys(item.image).length === 1 && isItemPatchReferenceId(item.image.id);
|
|
16617
|
+
});
|
|
16618
|
+
}
|
|
16619
|
+
function createLoyaltyCardPatchAdapter() {
|
|
16620
|
+
let selectedSubscriptionIds;
|
|
16621
|
+
return {
|
|
16622
|
+
operation: "LoyaltyCardsFacade.patch",
|
|
16623
|
+
basePath: "/api/v1/loyaltycards",
|
|
16624
|
+
objectType: TorrowObjectTypeCode.LoyaltyCard,
|
|
16625
|
+
discriminator: "LoyaltyCardItem" /* LoyaltyCardItem */,
|
|
16626
|
+
fields: {
|
|
16627
|
+
contactId: { kind: "String" /* String */, nullable: true, validate: isItemPatchReferenceId },
|
|
16628
|
+
state: {
|
|
16629
|
+
kind: "String" /* String */,
|
|
16630
|
+
validate: (value) => value !== "UnknownLoyaltyCardState" /* Unknown */ && Object.values(LoyaltyCardStateValues).some((state) => state === value)
|
|
16631
|
+
},
|
|
16632
|
+
issueDate: { kind: "Date" /* Date */, nullable: true },
|
|
16633
|
+
expiredDate: { kind: "Date" /* Date */, nullable: true },
|
|
16634
|
+
contactInformation: { kind: "Object" /* Object */, validate: contactInformation },
|
|
16635
|
+
cardIssueInformation: { kind: "Object" /* Object */, nullable: true },
|
|
16636
|
+
allowedReferralProgramIds: {
|
|
16637
|
+
kind: "Array" /* Array */,
|
|
16638
|
+
validate: (value) => Array.isArray(value) && value.every(isItemPatchReferenceId)
|
|
16639
|
+
},
|
|
16640
|
+
subscriptions: { kind: "Array" /* Array */, validate: subscriptions }
|
|
16641
|
+
},
|
|
16642
|
+
validateFields: (fields) => {
|
|
16643
|
+
if (Array.isArray(fields.subscriptions)) {
|
|
16644
|
+
selectedSubscriptionIds = fields.subscriptions.map((item) => item.subscriptionId);
|
|
16645
|
+
}
|
|
16646
|
+
},
|
|
16647
|
+
assertSnapshot: (item) => {
|
|
16648
|
+
if (item.name == null || item.loyaltySystemId == null || item.contactInformation == null) {
|
|
16649
|
+
throw itemPatchError("InsufficientData" /* InsufficientData */);
|
|
16650
|
+
}
|
|
16651
|
+
if (typeof item.name !== "string" || !item.name.length || !isItemPatchReferenceId(item.loyaltySystemId) || !contactInformation(item.contactInformation)) {
|
|
16652
|
+
throw itemPatchError("InvalidResponse" /* InvalidResponse */);
|
|
16653
|
+
}
|
|
16654
|
+
const storedIds = /* @__PURE__ */ new Set();
|
|
16655
|
+
if (item.subscriptions != null) {
|
|
16656
|
+
if (!Array.isArray(item.subscriptions)) {
|
|
16657
|
+
throw itemPatchError("InvalidResponse" /* InvalidResponse */);
|
|
16658
|
+
}
|
|
16659
|
+
for (const subscription of item.subscriptions) {
|
|
16660
|
+
if (!isItemPatchDtoObject(subscription) || typeof subscription.subscriptionId !== "string" || !isItemPatchReferenceId(subscription.subscriptionId) || storedIds.has(subscription.subscriptionId)) {
|
|
16661
|
+
throw itemPatchError("InvalidResponse" /* InvalidResponse */);
|
|
16662
|
+
}
|
|
16663
|
+
storedIds.add(subscription.subscriptionId);
|
|
16664
|
+
}
|
|
16665
|
+
}
|
|
16666
|
+
if (selectedSubscriptionIds?.some((id) => !storedIds.has(id))) {
|
|
16667
|
+
throw itemPatchError("InvalidInput" /* InvalidInput */);
|
|
16668
|
+
}
|
|
16669
|
+
},
|
|
16670
|
+
prepare: (body) => omitLoyaltyCardNumber(body),
|
|
16671
|
+
project: (item) => projectLoyaltyCardItem(item),
|
|
16672
|
+
equalField: (key, before, after) => {
|
|
16673
|
+
if (key !== "subscriptions" || !Array.isArray(before)) {
|
|
16674
|
+
return void 0;
|
|
16675
|
+
}
|
|
16676
|
+
const comparable2 = before.map(
|
|
16677
|
+
(item) => isItemPatchDtoObject(item) && isItemPatchDtoObject(item.image) && isItemPatchReferenceId(item.image.id) ? { ...item, image: { id: item.image.id } } : item
|
|
16678
|
+
);
|
|
16679
|
+
return equalItemPatchValue(comparable2, after);
|
|
16680
|
+
},
|
|
16681
|
+
casRefusal: isItemPatchCasRefusal
|
|
16682
|
+
};
|
|
16683
|
+
}
|
|
16684
|
+
|
|
16578
16685
|
// ../../src/resources/loyalty-cards/LoyaltyCardsFacade.ts
|
|
16579
16686
|
var BASE18 = "/api/v1/loyaltycards";
|
|
16580
16687
|
var LOYALTY_CARD_SOCIAL_OPTS = { withGroupListEndpoint: false };
|
|
@@ -16587,6 +16694,15 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
|
|
|
16587
16694
|
constructor(http) {
|
|
16588
16695
|
super(http, BASE18, LOYALTY_CARD_SOCIAL_OPTS);
|
|
16589
16696
|
}
|
|
16697
|
+
/**
|
|
16698
|
+
* Изменяет выбранные поля карты через Full GET и максимум один CAS PUT.
|
|
16699
|
+
* Пропуск сохраняет поле; вложенные значения заменяются целиком. Name/image производные.
|
|
16700
|
+
* Номер карты доступен только для чтения. Draft: backend cleanup общего файла шаблона требует live-приёмки. Нет retry/readback.
|
|
16701
|
+
* Effects описывают root write, а не транзакцию файлов, очередей и финансов.
|
|
16702
|
+
*/
|
|
16703
|
+
patch(itemId, fields, options) {
|
|
16704
|
+
return patchItem(this.http, itemId, fields, options, createLoyaltyCardPatchAdapter());
|
|
16705
|
+
}
|
|
16590
16706
|
/**
|
|
16591
16707
|
* Отображаемый аватар из свежей Full-карточки за один GET; отсутствие → null.
|
|
16592
16708
|
* Сервер уже применил наследование изображения программы. image/info читает собственный файл карты,
|
|
@@ -16618,15 +16734,15 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
|
|
|
16618
16734
|
validateInput: () => validateFileMetadataId(subscriptionId),
|
|
16619
16735
|
readItem: (id, readSignal) => this.readFileMetadataItem(id, readSignal),
|
|
16620
16736
|
selectFile: (item) => {
|
|
16621
|
-
const
|
|
16622
|
-
if (
|
|
16737
|
+
const subscriptions2 = item.subscriptions;
|
|
16738
|
+
if (subscriptions2 == null) {
|
|
16623
16739
|
return null;
|
|
16624
16740
|
}
|
|
16625
|
-
if (!Array.isArray(
|
|
16741
|
+
if (!Array.isArray(subscriptions2)) {
|
|
16626
16742
|
throw fileMetadataError("InvalidResponse" /* InvalidResponse */);
|
|
16627
16743
|
}
|
|
16628
16744
|
const ids = /* @__PURE__ */ new Set();
|
|
16629
|
-
for (const subscription of
|
|
16745
|
+
for (const subscription of subscriptions2) {
|
|
16630
16746
|
if (subscription === null || typeof subscription !== "object" || Array.isArray(subscription)) {
|
|
16631
16747
|
throw fileMetadataError("InvalidResponse" /* InvalidResponse */);
|
|
16632
16748
|
}
|
|
@@ -16642,7 +16758,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
|
|
|
16642
16758
|
}
|
|
16643
16759
|
ids.add(id);
|
|
16644
16760
|
}
|
|
16645
|
-
return
|
|
16761
|
+
return subscriptions2.find((subscription) => subscription.subscriptionId === subscriptionId)?.image;
|
|
16646
16762
|
}
|
|
16647
16763
|
});
|
|
16648
16764
|
}
|
|
@@ -16710,7 +16826,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
|
|
|
16710
16826
|
signal: options?.signal
|
|
16711
16827
|
}).then((items) => projectReadList(items, (dto) => projectAccountingTransaction(dto)));
|
|
16712
16828
|
}
|
|
16713
|
-
/** `PUT /api/v1/loyaltycards/{body.id}
|
|
16829
|
+
/** `PUT /api/v1/loyaltycards/{body.id}`; server-owned cardNumber исключается из копии тела. */
|
|
16714
16830
|
update(body, options) {
|
|
16715
16831
|
const itemId = requireItemUpdateId(body, "Loyalty card");
|
|
16716
16832
|
return this.http.requestJson({
|
|
@@ -16720,7 +16836,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
|
|
|
16720
16836
|
checkVersion: options?.checkVersion,
|
|
16721
16837
|
isNeedAnnouncement: options?.isNeedAnnouncement
|
|
16722
16838
|
},
|
|
16723
|
-
body,
|
|
16839
|
+
body: omitLoyaltyCardNumber(body),
|
|
16724
16840
|
signal: options?.signal
|
|
16725
16841
|
}).then((dto) => projectLoyaltyCardItem(dto));
|
|
16726
16842
|
}
|
|
@@ -17250,30 +17366,147 @@ var IdGeneratorFacade = class {
|
|
|
17250
17366
|
}
|
|
17251
17367
|
};
|
|
17252
17368
|
|
|
17369
|
+
// ../../src/resources/integrations/types.ts
|
|
17370
|
+
var IntegrationTypeValues = /* @__PURE__ */ ((IntegrationTypeValues2) => {
|
|
17371
|
+
IntegrationTypeValues2["UnknownInegrationActionType"] = "UnknownInegrationActionType";
|
|
17372
|
+
IntegrationTypeValues2["WebHook"] = "WebHook";
|
|
17373
|
+
IntegrationTypeValues2["ExternalCalendar"] = "ExternalCalendar";
|
|
17374
|
+
IntegrationTypeValues2["VideoTelephony"] = "VideoTelephony";
|
|
17375
|
+
return IntegrationTypeValues2;
|
|
17376
|
+
})(IntegrationTypeValues || {});
|
|
17377
|
+
var IntegrationEventTypeValues = /* @__PURE__ */ ((IntegrationEventTypeValues2) => {
|
|
17378
|
+
IntegrationEventTypeValues2["CreateItem"] = "CreateItem";
|
|
17379
|
+
IntegrationEventTypeValues2["CheckIn"] = "CheckIn";
|
|
17380
|
+
IntegrationEventTypeValues2["CancelCaseParticipation"] = "CancelCaseParticipation";
|
|
17381
|
+
IntegrationEventTypeValues2["GetTimetable"] = "GetTimetable";
|
|
17382
|
+
IntegrationEventTypeValues2["CaseReject"] = "CaseReject";
|
|
17383
|
+
IntegrationEventTypeValues2["CaseDeclineWork"] = "CaseDeclineWork";
|
|
17384
|
+
IntegrationEventTypeValues2["CasePlan"] = "CasePlan";
|
|
17385
|
+
IntegrationEventTypeValues2["CaseCancel"] = "CaseCancel";
|
|
17386
|
+
IntegrationEventTypeValues2["CaseTakeInWork"] = "CaseTakeInWork";
|
|
17387
|
+
IntegrationEventTypeValues2["CaseComplete"] = "CaseComplete";
|
|
17388
|
+
IntegrationEventTypeValues2["CaseAccept"] = "CaseAccept";
|
|
17389
|
+
IntegrationEventTypeValues2["UpdateCase"] = "UpdateCase";
|
|
17390
|
+
IntegrationEventTypeValues2["UpdateCaseTime"] = "UpdateCaseTime";
|
|
17391
|
+
IntegrationEventTypeValues2["UpdateCasePlace"] = "UpdateCasePlace";
|
|
17392
|
+
IntegrationEventTypeValues2["ApproveCaseParticipation"] = "ApproveCaseParticipation";
|
|
17393
|
+
IntegrationEventTypeValues2["ConfirmCaseParticipation"] = "ConfirmCaseParticipation";
|
|
17394
|
+
IntegrationEventTypeValues2["ApproveMoneyReceive"] = "ApproveMoneyReceive";
|
|
17395
|
+
IntegrationEventTypeValues2["RejectMoneyReceive"] = "RejectMoneyReceive";
|
|
17396
|
+
IntegrationEventTypeValues2["CaseReturnToVerification"] = "CaseReturnToVerification";
|
|
17397
|
+
IntegrationEventTypeValues2["CaseActionEvent"] = "CaseActionEvent";
|
|
17398
|
+
IntegrationEventTypeValues2["CreateOrder"] = "CreateOrder";
|
|
17399
|
+
IntegrationEventTypeValues2["UpdateOrder"] = "UpdateOrder";
|
|
17400
|
+
return IntegrationEventTypeValues2;
|
|
17401
|
+
})(IntegrationEventTypeValues || {});
|
|
17402
|
+
function record7(value) {
|
|
17403
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17404
|
+
}
|
|
17405
|
+
function hasReadEnvelope(value, type, discriminator) {
|
|
17406
|
+
return record7(value) && typeof value.name === "string" && value.integrationType === type && value.discriminator === discriminator && record7(value.integrationParameters) && Array.isArray(value.integrationEvents) && Array.from(value.integrationEvents).every(
|
|
17407
|
+
(event) => record7(event) && typeof event.rid === "string" && typeof event.eventType === "string" && Object.values(IntegrationEventTypeValues).some((known) => known === event.eventType)
|
|
17408
|
+
);
|
|
17409
|
+
}
|
|
17410
|
+
function isExternalCalendarIntegration(value) {
|
|
17411
|
+
if (!hasReadEnvelope(value, "ExternalCalendar" /* ExternalCalendar */, "ExternalCalendarIntegration" /* ExternalCalendarIntegration */)) {
|
|
17412
|
+
return false;
|
|
17413
|
+
}
|
|
17414
|
+
const parameters = value.integrationParameters;
|
|
17415
|
+
return record7(parameters) && Array.isArray(parameters.externalCalendars) && Array.from(parameters.externalCalendars).every(
|
|
17416
|
+
(calendar) => record7(calendar) && typeof calendar.externalAuthId === "string"
|
|
17417
|
+
);
|
|
17418
|
+
}
|
|
17419
|
+
function isVideoTelephonyIntegration(value) {
|
|
17420
|
+
if (!hasReadEnvelope(value, "VideoTelephony" /* VideoTelephony */, "VideoTelephonyIntegration" /* VideoTelephonyIntegration */)) {
|
|
17421
|
+
return false;
|
|
17422
|
+
}
|
|
17423
|
+
const parameters = value.integrationParameters;
|
|
17424
|
+
return record7(parameters) && record7(parameters.videoTelephony) && typeof parameters.videoTelephony.externalAuthId === "string";
|
|
17425
|
+
}
|
|
17426
|
+
function isWebHookIntegration(integration) {
|
|
17427
|
+
return typeof integration === "object" && integration !== null && "name" in integration && typeof integration.name === "string" && "integrationType" in integration && integration.integrationType === "WebHook" /* WebHook */ && "discriminator" in integration && integration.discriminator === "WebHookIntegration" /* WebHookIntegration */ && "integrationParameters" in integration && typeof integration.integrationParameters === "object" && integration.integrationParameters !== null && "url" in integration.integrationParameters && typeof integration.integrationParameters.url === "string" && "integrationEvents" in integration && Array.isArray(integration.integrationEvents) && Array.from(integration.integrationEvents).every(
|
|
17428
|
+
(event) => typeof event === "object" && event !== null && "rid" in event && typeof event.rid === "string" && "eventType" in event && typeof event.eventType === "string" && Object.values(IntegrationEventTypeValues).some((value) => value === event.eventType)
|
|
17429
|
+
);
|
|
17430
|
+
}
|
|
17431
|
+
|
|
17253
17432
|
// ../../src/resources/integrations/IntegrationsFacade.ts
|
|
17433
|
+
var shapes = [
|
|
17434
|
+
{
|
|
17435
|
+
parameterKey: "url",
|
|
17436
|
+
integrationType: "WebHook" /* WebHook */,
|
|
17437
|
+
discriminator: "WebHookIntegration" /* WebHookIntegration */,
|
|
17438
|
+
matches: isWebHookIntegration
|
|
17439
|
+
},
|
|
17440
|
+
{
|
|
17441
|
+
parameterKey: "externalCalendars",
|
|
17442
|
+
integrationType: "ExternalCalendar" /* ExternalCalendar */,
|
|
17443
|
+
discriminator: "ExternalCalendarIntegration" /* ExternalCalendarIntegration */,
|
|
17444
|
+
matches: isExternalCalendarIntegration
|
|
17445
|
+
},
|
|
17446
|
+
{
|
|
17447
|
+
parameterKey: "videoTelephony",
|
|
17448
|
+
integrationType: "VideoTelephony" /* VideoTelephony */,
|
|
17449
|
+
discriminator: "VideoTelephonyIntegration" /* VideoTelephonyIntegration */,
|
|
17450
|
+
matches: isVideoTelephonyIntegration
|
|
17451
|
+
}
|
|
17452
|
+
];
|
|
17453
|
+
function invalidIntegration() {
|
|
17454
|
+
return new TorrowSdkError({
|
|
17455
|
+
category: "InvalidInput" /* InvalidInput */,
|
|
17456
|
+
request: "NotStarted" /* NotStarted */
|
|
17457
|
+
});
|
|
17458
|
+
}
|
|
17254
17459
|
var BASE25 = "/api/v1/integrations";
|
|
17255
17460
|
var IntegrationsFacade = class {
|
|
17256
17461
|
constructor(http) {
|
|
17257
17462
|
this.http = http;
|
|
17258
17463
|
}
|
|
17259
17464
|
http;
|
|
17260
|
-
/**
|
|
17465
|
+
/** Определяет одну полную ветвь по parameters и формирует независимую верхнеуровневую копию DTO. */
|
|
17466
|
+
toApiIntegration(body) {
|
|
17467
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
17468
|
+
throw invalidIntegration();
|
|
17469
|
+
}
|
|
17470
|
+
const parameters = body.integrationParameters;
|
|
17471
|
+
if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
|
|
17472
|
+
throw invalidIntegration();
|
|
17473
|
+
}
|
|
17474
|
+
const candidates = shapes.filter((shape3) => Object.hasOwn(parameters, shape3.parameterKey));
|
|
17475
|
+
const shape2 = candidates[0];
|
|
17476
|
+
if (candidates.length !== 1 || !shape2) {
|
|
17477
|
+
throw invalidIntegration();
|
|
17478
|
+
}
|
|
17479
|
+
const payload = { ...body, integrationType: shape2.integrationType, discriminator: shape2.discriminator };
|
|
17480
|
+
if (!shape2.matches(payload) || !payload.name.trim() || payload.integrationEvents.length === 0 || payload.integrationEvents.some((event) => !event.rid.trim())) {
|
|
17481
|
+
throw invalidIntegration();
|
|
17482
|
+
}
|
|
17483
|
+
if (isWebHookIntegration(payload) && !payload.integrationParameters.url.trim()) {
|
|
17484
|
+
throw invalidIntegration();
|
|
17485
|
+
}
|
|
17486
|
+
if (isExternalCalendarIntegration(payload) && (payload.integrationParameters.externalCalendars.length === 0 || payload.integrationParameters.externalCalendars.some((calendar) => !calendar.externalAuthId.trim()))) {
|
|
17487
|
+
throw invalidIntegration();
|
|
17488
|
+
}
|
|
17489
|
+
if (isVideoTelephonyIntegration(payload) && !payload.integrationParameters.videoTelephony.externalAuthId.trim()) {
|
|
17490
|
+
throw invalidIntegration();
|
|
17491
|
+
}
|
|
17492
|
+
return payload;
|
|
17493
|
+
}
|
|
17261
17494
|
create(body, options) {
|
|
17262
17495
|
return this.http.requestJson({
|
|
17263
17496
|
method: "POST",
|
|
17264
17497
|
path: BASE25,
|
|
17265
|
-
body,
|
|
17498
|
+
body: this.toApiIntegration(body),
|
|
17266
17499
|
signal: options?.signal
|
|
17267
17500
|
});
|
|
17268
17501
|
}
|
|
17269
|
-
/** `PUT /api/v1/integrations/{body.id}` */
|
|
17270
17502
|
update(body, options) {
|
|
17503
|
+
const payload = this.toApiIntegration(body);
|
|
17271
17504
|
const itemId = requireItemUpdateId(body, "Integration");
|
|
17272
17505
|
return this.http.requestJson({
|
|
17273
17506
|
method: "PUT",
|
|
17274
17507
|
path: `${BASE25}/${encodePathSegment(itemId)}`,
|
|
17275
17508
|
query: { checkVersion: options?.checkVersion },
|
|
17276
|
-
body,
|
|
17509
|
+
body: payload,
|
|
17277
17510
|
signal: options?.signal
|
|
17278
17511
|
});
|
|
17279
17512
|
}
|
|
@@ -18857,6 +19090,8 @@ export {
|
|
|
18857
19090
|
HttpClient,
|
|
18858
19091
|
IdGeneratorFacade,
|
|
18859
19092
|
ImagePreviewSizeValues,
|
|
19093
|
+
IntegrationEventTypeValues,
|
|
19094
|
+
IntegrationTypeValues,
|
|
18860
19095
|
IntegrationsFacade,
|
|
18861
19096
|
ItemFacade,
|
|
18862
19097
|
ItemPatchEffectStep,
|
|
@@ -18865,6 +19100,7 @@ export {
|
|
|
18865
19100
|
LayoutTypeValues,
|
|
18866
19101
|
LoyaltyCardIssueTypeValues,
|
|
18867
19102
|
LoyaltyCardSortConditionValues,
|
|
19103
|
+
LoyaltyCardStateValues,
|
|
18868
19104
|
LoyaltyCardUpdateKeyInformationValues,
|
|
18869
19105
|
LoyaltyCardUpdateNonKeyInformationValues,
|
|
18870
19106
|
LoyaltyCardsFacade,
|
|
@@ -18959,6 +19195,7 @@ export {
|
|
|
18959
19195
|
isAuthScope,
|
|
18960
19196
|
isContextIconPreset,
|
|
18961
19197
|
isDeviceType,
|
|
19198
|
+
isExternalCalendarIntegration,
|
|
18962
19199
|
isFreeCheckInSlot,
|
|
18963
19200
|
isItemViewSortCondition,
|
|
18964
19201
|
isSendCodeAccountType,
|
|
@@ -18968,6 +19205,8 @@ export {
|
|
|
18968
19205
|
isTokenStatus,
|
|
18969
19206
|
isTorrowItemType,
|
|
18970
19207
|
isVerificationMethod,
|
|
19208
|
+
isVideoTelephonyIntegration,
|
|
19209
|
+
isWebHookIntegration,
|
|
18971
19210
|
normalizePaymentUrl,
|
|
18972
19211
|
packTorrowId,
|
|
18973
19212
|
parseAccountType,
|