@torrow/sdk-client 0.18.0 → 0.19.0

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.js CHANGED
@@ -52,8 +52,37 @@ var TorrowSdkErrorDomain = /* @__PURE__ */ ((TorrowSdkErrorDomain2) => {
52
52
  TorrowSdkErrorDomain2["BehaviorSettings"] = "BehaviorSettings";
53
53
  TorrowSdkErrorDomain2["Otp"] = "Otp";
54
54
  TorrowSdkErrorDomain2["AuthSession"] = "AuthSession";
55
+ TorrowSdkErrorDomain2["Profiles"] = "Profiles";
55
56
  return TorrowSdkErrorDomain2;
56
57
  })(TorrowSdkErrorDomain || {});
58
+ var ProfileErrorReason = /* @__PURE__ */ ((ProfileErrorReason2) => {
59
+ ProfileErrorReason2["TargetNotProfile"] = "TargetNotProfile";
60
+ ProfileErrorReason2["LastProfile"] = "LastProfile";
61
+ ProfileErrorReason2["SelectedDefault"] = "SelectedDefault";
62
+ ProfileErrorReason2["UnusableProfileList"] = "UnusableProfileList";
63
+ ProfileErrorReason2["UnusableDefault"] = "UnusableDefault";
64
+ return ProfileErrorReason2;
65
+ })(ProfileErrorReason || {});
66
+ var ProfileOperation = /* @__PURE__ */ ((ProfileOperation2) => {
67
+ ProfileOperation2["SetDefaultProfileByContactId"] = "setDefaultProfileByContactId";
68
+ ProfileOperation2["Remove"] = "remove";
69
+ return ProfileOperation2;
70
+ })(ProfileOperation || {});
71
+ var ProfileFailureAt = /* @__PURE__ */ ((ProfileFailureAt2) => {
72
+ ProfileFailureAt2["ValidateInput"] = "ValidateInput";
73
+ ProfileFailureAt2["ReadProfiles"] = "ReadProfiles";
74
+ ProfileFailureAt2["ValidateProfiles"] = "ValidateProfiles";
75
+ ProfileFailureAt2["ReadDefault"] = "ReadDefault";
76
+ ProfileFailureAt2["ValidateDefault"] = "ValidateDefault";
77
+ ProfileFailureAt2["Write"] = "Write";
78
+ ProfileFailureAt2["ValidateWriteResponse"] = "ValidateWriteResponse";
79
+ ProfileFailureAt2["ProjectResponse"] = "ProjectResponse";
80
+ return ProfileFailureAt2;
81
+ })(ProfileFailureAt || {});
82
+ var ProfileEffectStep = /* @__PURE__ */ ((ProfileEffectStep2) => {
83
+ ProfileEffectStep2["Write"] = "Write";
84
+ return ProfileEffectStep2;
85
+ })(ProfileEffectStep || {});
57
86
  var FileMetadataErrorReason = /* @__PURE__ */ ((FileMetadataErrorReason2) => {
58
87
  FileMetadataErrorReason2["ContentTypeUnavailable"] = "ContentTypeUnavailable";
59
88
  FileMetadataErrorReason2["SubscriptionIsNotValid"] = "SubscriptionIsNotValid";
@@ -15652,6 +15681,63 @@ function prepareUserProfileItemForAdd(body) {
15652
15681
  return payload;
15653
15682
  }
15654
15683
 
15684
+ // ../../src/resources/user-profiles/profile-list-response-error.ts
15685
+ var ProfileListResponseError = class extends Error {
15686
+ constructor(message, cause) {
15687
+ super(message, { cause });
15688
+ }
15689
+ };
15690
+
15691
+ // ../../src/resources/user-profiles/read-default-profile.ts
15692
+ async function readDefaultProfile(http, listProfiles, options) {
15693
+ const dto = await http.requestJson({
15694
+ method: "GET",
15695
+ path: "/api/v1/user/defaultprofile",
15696
+ signal: options?.signal
15697
+ });
15698
+ if (dto !== null && dto !== void 0) {
15699
+ return projectContactItem(dto);
15700
+ }
15701
+ return (await listProfiles())[0] ?? null;
15702
+ }
15703
+
15704
+ // ../../src/resources/user-profiles/profile-write-guard.ts
15705
+ function assertUsableProfileIds(profiles) {
15706
+ const ids = /* @__PURE__ */ new Set();
15707
+ if (!Array.isArray(profiles) || profiles.length === 0 || profiles.some((profile) => {
15708
+ const id = profile?.id;
15709
+ if (typeof id !== "string" || id.trim().length === 0 || ids.has(id)) {
15710
+ return true;
15711
+ }
15712
+ ids.add(id);
15713
+ return false;
15714
+ })) {
15715
+ throw new TorrowSdkError({
15716
+ category: "InsufficientData" /* InsufficientData */,
15717
+ detail: { domain: "Profiles" /* Profiles */, reason: "UnusableProfileList" /* UnusableProfileList */ }
15718
+ });
15719
+ }
15720
+ return ids;
15721
+ }
15722
+ function contextualizeProfileWriteError(cause, operation, failureAt, dispatched, effect) {
15723
+ const error = cause instanceof TorrowSdkError ? cause : new TorrowSdkError({
15724
+ category: cause instanceof ProfileListResponseError || failureAt === "ProjectResponse" /* ProjectResponse */ && cause instanceof Error ? "InvalidResponse" /* InvalidResponse */ : "Unknown" /* Unknown */,
15725
+ sensitive: { cause }
15726
+ });
15727
+ const detail = cause instanceof ProfileListResponseError ? {
15728
+ domain: "Profiles" /* Profiles */,
15729
+ reason: failureAt === "ReadProfiles" /* ReadProfiles */ ? "UnusableProfileList" /* UnusableProfileList */ : "UnusableDefault" /* UnusableDefault */
15730
+ } : error.detail?.domain === "Profiles" /* Profiles */ ? error.detail : { domain: "Profiles" /* Profiles */ };
15731
+ const writeState = effect === "Applied" /* Applied */ ? effect : dispatched ? "Unknown" /* Unknown */ : "NotApplied" /* NotApplied */;
15732
+ return error.withContext({
15733
+ detail,
15734
+ operation,
15735
+ failureAt,
15736
+ request: dispatched ? "Started" /* Started */ : "NotStarted" /* NotStarted */,
15737
+ effects: [{ area: "Remote" /* Remote */, step: "Write" /* Write */, state: writeState }]
15738
+ });
15739
+ }
15740
+
15655
15741
  // ../../src/resources/user-profiles/ProfilesFacade.ts
15656
15742
  var BASE11 = "/api/v1/user/profiles";
15657
15743
  var ProfilesFacade = class {
@@ -15671,16 +15757,20 @@ var ProfilesFacade = class {
15671
15757
  signal: options?.signal
15672
15758
  });
15673
15759
  if (resp === null || typeof resp !== "object") {
15674
- throw new Error("GET /api/v1/user/profiles: expected a JSON object body");
15760
+ throw new ProfileListResponseError("GET /api/v1/user/profiles: expected a JSON object body");
15675
15761
  }
15676
15762
  const pl = resp.profileList;
15677
15763
  if (pl === void 0 || pl === null) {
15678
15764
  return projectReadList([], (dto) => projectContactItem(dto));
15679
15765
  }
15680
15766
  if (!Array.isArray(pl)) {
15681
- throw new Error("GET /api/v1/user/profiles: profileList must be an array when present");
15767
+ throw new ProfileListResponseError("GET /api/v1/user/profiles: profileList must be an array when present");
15768
+ }
15769
+ try {
15770
+ return projectReadList(pl, (dto) => projectContactItem(dto));
15771
+ } catch (cause) {
15772
+ throw new ProfileListResponseError("GET /api/v1/user/profiles: invalid profile projection", cause);
15682
15773
  }
15683
- return projectReadList(pl, (dto) => projectContactItem(dto));
15684
15774
  }
15685
15775
  /**
15686
15776
  * `POST /api/v1/user/profiles` — создать Профиль по телу **`UserProfileItemForAdd`** (контакт для write + поля Профиля).
@@ -15724,14 +15814,65 @@ var ProfilesFacade = class {
15724
15814
  });
15725
15815
  return unwrapTorrowObjectFromProfilePropertiesUpdate(resp);
15726
15816
  }
15727
- /** `DELETE /api/v1/user/profiles/{profileId}` — удалить Профиль; возвращает актуальный **`personalContactList`**. */
15817
+ /**
15818
+ * `DELETE /api/v1/user/profiles/{profileId}` — снять связь Профиля, сохранив другой Профиль и выбранный SDK default.
15819
+ * Проверяет список и default до DELETE; fallback default может повторно прочитать список, но первый снимок остаётся условием.
15820
+ * Успех возвращает `personalContactList` как `ContactItem[]`; Contact не удаляется. GET→DELETE не атомарны.
15821
+ * @param profileId Точный ID привязанного Contact; на wire кодируется как сегмент пути.
15822
+ * @param options Общий signal предварительных чтений и целевого DELETE.
15823
+ */
15728
15824
  async remove(profileId, options) {
15729
- const resp = await this.http.requestJson({
15730
- method: "DELETE",
15731
- path: `${BASE11}/${encodePathSegment(profileId)}`,
15732
- signal: options?.signal
15733
- });
15734
- return projectReadList(unwrapRemoveProfileList(resp), (dto) => projectContactItem(dto));
15825
+ let failureAt = "ValidateInput" /* ValidateInput */;
15826
+ let dispatched = false;
15827
+ let effect = "NotApplied" /* NotApplied */;
15828
+ try {
15829
+ if (typeof profileId !== "string" || profileId.trim().length === 0) {
15830
+ throw new TorrowSdkError({ category: "InvalidInput" /* InvalidInput */ });
15831
+ }
15832
+ failureAt = "ReadProfiles" /* ReadProfiles */;
15833
+ const profiles = await this.list(options);
15834
+ failureAt = "ValidateProfiles" /* ValidateProfiles */;
15835
+ const ids = assertUsableProfileIds(profiles);
15836
+ if (!ids.has(profileId)) {
15837
+ throw new TorrowSdkError({
15838
+ category: "InvalidState" /* InvalidState */,
15839
+ detail: { domain: "Profiles" /* Profiles */, reason: "TargetNotProfile" /* TargetNotProfile */ }
15840
+ });
15841
+ }
15842
+ if (profiles.length === 1) {
15843
+ throw new TorrowSdkError({
15844
+ category: "InvalidState" /* InvalidState */,
15845
+ detail: { domain: "Profiles" /* Profiles */, reason: "LastProfile" /* LastProfile */ }
15846
+ });
15847
+ }
15848
+ failureAt = "ReadDefault" /* ReadDefault */;
15849
+ const selected = await readDefaultProfile(this.http, () => this.list(options), options);
15850
+ failureAt = "ValidateDefault" /* ValidateDefault */;
15851
+ if (typeof selected?.id !== "string" || selected.id.trim().length === 0 || !ids.has(selected.id)) {
15852
+ throw new TorrowSdkError({
15853
+ category: "InsufficientData" /* InsufficientData */,
15854
+ detail: { domain: "Profiles" /* Profiles */, reason: "UnusableDefault" /* UnusableDefault */ }
15855
+ });
15856
+ }
15857
+ if (selected.id === profileId) {
15858
+ throw new TorrowSdkError({
15859
+ category: "InvalidState" /* InvalidState */,
15860
+ detail: { domain: "Profiles" /* Profiles */, reason: "SelectedDefault" /* SelectedDefault */ }
15861
+ });
15862
+ }
15863
+ failureAt = "Write" /* Write */;
15864
+ const resp = await this.http.requestJson(
15865
+ { method: "DELETE", path: `${BASE11}/${encodePathSegment(profileId)}`, signal: options?.signal },
15866
+ () => {
15867
+ dispatched = true;
15868
+ }
15869
+ );
15870
+ effect = "Applied" /* Applied */;
15871
+ failureAt = "ProjectResponse" /* ProjectResponse */;
15872
+ return projectReadList(unwrapRemoveProfileList(resp), (dto) => projectContactItem(dto));
15873
+ } catch (cause) {
15874
+ throw contextualizeProfileWriteError(cause, "remove" /* Remove */, failureAt, dispatched, effect);
15875
+ }
15735
15876
  }
15736
15877
  };
15737
15878
 
@@ -16575,6 +16716,113 @@ var LoyaltySystemsFacade = class extends TorrowItemCoreFacade {
16575
16716
  }
16576
16717
  };
16577
16718
 
16719
+ // ../../src/resources/loyalty-cards/types.ts
16720
+ var LoyaltyCardStateValues = /* @__PURE__ */ ((LoyaltyCardStateValues2) => {
16721
+ LoyaltyCardStateValues2["Unknown"] = "UnknownLoyaltyCardState";
16722
+ LoyaltyCardStateValues2["Issued"] = "Issued";
16723
+ LoyaltyCardStateValues2["Actived"] = "Actived";
16724
+ LoyaltyCardStateValues2["Blocked"] = "Blocked";
16725
+ LoyaltyCardStateValues2["Closed"] = "Closed";
16726
+ return LoyaltyCardStateValues2;
16727
+ })(LoyaltyCardStateValues || {});
16728
+
16729
+ // ../../src/resources/loyalty-cards/loyalty-card-patch.ts
16730
+ function omitLoyaltyCardNumber(body) {
16731
+ const payload = { ...body };
16732
+ Reflect.deleteProperty(payload, "cardNumber");
16733
+ return payload;
16734
+ }
16735
+ function contactInformation(value) {
16736
+ return isItemPatchDtoObject(value) && Array.isArray(value.fields) && value.fields.length > 0 && value.fields.every(isItemPatchDtoObject);
16737
+ }
16738
+ function subscriptions(value) {
16739
+ if (!Array.isArray(value)) {
16740
+ return false;
16741
+ }
16742
+ const ids = /* @__PURE__ */ new Set();
16743
+ return value.every((item) => {
16744
+ if (!isItemPatchDtoObject(item) || typeof item.subscriptionId !== "string" || !isItemPatchReferenceId(item.subscriptionId) || ids.has(item.subscriptionId)) {
16745
+ return false;
16746
+ }
16747
+ ids.add(item.subscriptionId);
16748
+ for (const key of ["createDate", "beginDate", "endDate"]) {
16749
+ const date2 = item[key];
16750
+ if (date2 != null && (!(date2 instanceof Date) || !Number.isFinite(date2.getTime()))) {
16751
+ return false;
16752
+ }
16753
+ }
16754
+ if (item.image == null) {
16755
+ return true;
16756
+ }
16757
+ return isItemPatchDtoObject(item.image) && Object.keys(item.image).length === 1 && isItemPatchReferenceId(item.image.id);
16758
+ });
16759
+ }
16760
+ function createLoyaltyCardPatchAdapter() {
16761
+ let selectedSubscriptionIds;
16762
+ return {
16763
+ operation: "LoyaltyCardsFacade.patch",
16764
+ basePath: "/api/v1/loyaltycards",
16765
+ objectType: TorrowObjectTypeCode.LoyaltyCard,
16766
+ discriminator: "LoyaltyCardItem" /* LoyaltyCardItem */,
16767
+ fields: {
16768
+ contactId: { kind: "String" /* String */, nullable: true, validate: isItemPatchReferenceId },
16769
+ state: {
16770
+ kind: "String" /* String */,
16771
+ validate: (value) => value !== "UnknownLoyaltyCardState" /* Unknown */ && Object.values(LoyaltyCardStateValues).some((state) => state === value)
16772
+ },
16773
+ issueDate: { kind: "Date" /* Date */, nullable: true },
16774
+ expiredDate: { kind: "Date" /* Date */, nullable: true },
16775
+ contactInformation: { kind: "Object" /* Object */, validate: contactInformation },
16776
+ cardIssueInformation: { kind: "Object" /* Object */, nullable: true },
16777
+ allowedReferralProgramIds: {
16778
+ kind: "Array" /* Array */,
16779
+ validate: (value) => Array.isArray(value) && value.every(isItemPatchReferenceId)
16780
+ },
16781
+ subscriptions: { kind: "Array" /* Array */, validate: subscriptions }
16782
+ },
16783
+ validateFields: (fields) => {
16784
+ if (Array.isArray(fields.subscriptions)) {
16785
+ selectedSubscriptionIds = fields.subscriptions.map((item) => item.subscriptionId);
16786
+ }
16787
+ },
16788
+ assertSnapshot: (item) => {
16789
+ if (item.name == null || item.loyaltySystemId == null || item.contactInformation == null) {
16790
+ throw itemPatchError("InsufficientData" /* InsufficientData */);
16791
+ }
16792
+ if (typeof item.name !== "string" || !item.name.length || !isItemPatchReferenceId(item.loyaltySystemId) || !contactInformation(item.contactInformation)) {
16793
+ throw itemPatchError("InvalidResponse" /* InvalidResponse */);
16794
+ }
16795
+ const storedIds = /* @__PURE__ */ new Set();
16796
+ if (item.subscriptions != null) {
16797
+ if (!Array.isArray(item.subscriptions)) {
16798
+ throw itemPatchError("InvalidResponse" /* InvalidResponse */);
16799
+ }
16800
+ for (const subscription of item.subscriptions) {
16801
+ if (!isItemPatchDtoObject(subscription) || typeof subscription.subscriptionId !== "string" || !isItemPatchReferenceId(subscription.subscriptionId) || storedIds.has(subscription.subscriptionId)) {
16802
+ throw itemPatchError("InvalidResponse" /* InvalidResponse */);
16803
+ }
16804
+ storedIds.add(subscription.subscriptionId);
16805
+ }
16806
+ }
16807
+ if (selectedSubscriptionIds?.some((id) => !storedIds.has(id))) {
16808
+ throw itemPatchError("InvalidInput" /* InvalidInput */);
16809
+ }
16810
+ },
16811
+ prepare: (body) => omitLoyaltyCardNumber(body),
16812
+ project: (item) => projectLoyaltyCardItem(item),
16813
+ equalField: (key, before, after) => {
16814
+ if (key !== "subscriptions" || !Array.isArray(before)) {
16815
+ return void 0;
16816
+ }
16817
+ const comparable2 = before.map(
16818
+ (item) => isItemPatchDtoObject(item) && isItemPatchDtoObject(item.image) && isItemPatchReferenceId(item.image.id) ? { ...item, image: { id: item.image.id } } : item
16819
+ );
16820
+ return equalItemPatchValue(comparable2, after);
16821
+ },
16822
+ casRefusal: isItemPatchCasRefusal
16823
+ };
16824
+ }
16825
+
16578
16826
  // ../../src/resources/loyalty-cards/LoyaltyCardsFacade.ts
16579
16827
  var BASE18 = "/api/v1/loyaltycards";
16580
16828
  var LOYALTY_CARD_SOCIAL_OPTS = { withGroupListEndpoint: false };
@@ -16587,6 +16835,15 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
16587
16835
  constructor(http) {
16588
16836
  super(http, BASE18, LOYALTY_CARD_SOCIAL_OPTS);
16589
16837
  }
16838
+ /**
16839
+ * Изменяет выбранные поля карты через Full GET и максимум один CAS PUT.
16840
+ * Пропуск сохраняет поле; вложенные значения заменяются целиком. Name/image производные.
16841
+ * Номер карты доступен только для чтения. Draft: backend cleanup общего файла шаблона требует live-приёмки. Нет retry/readback.
16842
+ * Effects описывают root write, а не транзакцию файлов, очередей и финансов.
16843
+ */
16844
+ patch(itemId, fields, options) {
16845
+ return patchItem(this.http, itemId, fields, options, createLoyaltyCardPatchAdapter());
16846
+ }
16590
16847
  /**
16591
16848
  * Отображаемый аватар из свежей Full-карточки за один GET; отсутствие → null.
16592
16849
  * Сервер уже применил наследование изображения программы. image/info читает собственный файл карты,
@@ -16618,15 +16875,15 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
16618
16875
  validateInput: () => validateFileMetadataId(subscriptionId),
16619
16876
  readItem: (id, readSignal) => this.readFileMetadataItem(id, readSignal),
16620
16877
  selectFile: (item) => {
16621
- const subscriptions = item.subscriptions;
16622
- if (subscriptions == null) {
16878
+ const subscriptions2 = item.subscriptions;
16879
+ if (subscriptions2 == null) {
16623
16880
  return null;
16624
16881
  }
16625
- if (!Array.isArray(subscriptions)) {
16882
+ if (!Array.isArray(subscriptions2)) {
16626
16883
  throw fileMetadataError("InvalidResponse" /* InvalidResponse */);
16627
16884
  }
16628
16885
  const ids = /* @__PURE__ */ new Set();
16629
- for (const subscription of subscriptions) {
16886
+ for (const subscription of subscriptions2) {
16630
16887
  if (subscription === null || typeof subscription !== "object" || Array.isArray(subscription)) {
16631
16888
  throw fileMetadataError("InvalidResponse" /* InvalidResponse */);
16632
16889
  }
@@ -16642,7 +16899,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
16642
16899
  }
16643
16900
  ids.add(id);
16644
16901
  }
16645
- return subscriptions.find((subscription) => subscription.subscriptionId === subscriptionId)?.image;
16902
+ return subscriptions2.find((subscription) => subscription.subscriptionId === subscriptionId)?.image;
16646
16903
  }
16647
16904
  });
16648
16905
  }
@@ -16710,7 +16967,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
16710
16967
  signal: options?.signal
16711
16968
  }).then((items) => projectReadList(items, (dto) => projectAccountingTransaction(dto)));
16712
16969
  }
16713
- /** `PUT /api/v1/loyaltycards/{body.id}` */
16970
+ /** `PUT /api/v1/loyaltycards/{body.id}`; server-owned cardNumber исключается из копии тела. */
16714
16971
  update(body, options) {
16715
16972
  const itemId = requireItemUpdateId(body, "Loyalty card");
16716
16973
  return this.http.requestJson({
@@ -16720,7 +16977,7 @@ var LoyaltyCardsFacade = class extends TorrowItemCoreFacade {
16720
16977
  checkVersion: options?.checkVersion,
16721
16978
  isNeedAnnouncement: options?.isNeedAnnouncement
16722
16979
  },
16723
- body,
16980
+ body: omitLoyaltyCardNumber(body),
16724
16981
  signal: options?.signal
16725
16982
  }).then((dto) => projectLoyaltyCardItem(dto));
16726
16983
  }
@@ -16972,25 +17229,61 @@ var UserFacade = class {
16972
17229
  * @param options Параметры чтения: signal — отмена всей цепочки запросов.
16973
17230
  */
16974
17231
  async getDefaultProfile(options) {
16975
- const dto = await this.http.requestJson({
16976
- method: "GET",
16977
- path: `${BASE20}/defaultprofile`,
16978
- signal: options?.signal
16979
- });
16980
- if (dto !== null && dto !== void 0) {
16981
- return projectContactItem(dto);
16982
- }
16983
- return (await this.profiles.list(options))[0] ?? null;
17232
+ return readDefaultProfile(this.http, () => this.profiles.list(options), options);
16984
17233
  }
16985
- /** `PUT /api/v1/user/defaultprofile` */
17234
+ /**
17235
+ * `PUT /api/v1/user/defaultprofile` — назначает только Contact, доказанно входящий в Профили учётной записи.
17236
+ * Предварительный список и целевой PUT используют один signal; между ними возможна серверная гонка.
17237
+ * При отказе `TorrowSdkError.effects` описывает только целевой PUT, а не предварительный GET.
17238
+ * @param contactId Точный ID Contact из `profiles.list`; не нормализуется.
17239
+ * @param options Параметры всей цепочки, включая общий signal отмены.
17240
+ */
16986
17241
  async setDefaultProfileByContactId(contactId, options) {
16987
- const resp = await this.http.requestJson({
16988
- method: "PUT",
16989
- path: `${BASE20}/defaultprofile`,
16990
- body: contactId,
16991
- signal: options?.signal
16992
- });
16993
- return projectContactItem(unwrapAddProfileContact(resp));
17242
+ let failureAt = "ValidateInput" /* ValidateInput */;
17243
+ let dispatched = false;
17244
+ let effect = "NotApplied" /* NotApplied */;
17245
+ try {
17246
+ if (typeof contactId !== "string" || contactId.trim().length === 0) {
17247
+ throw new TorrowSdkError({ category: "InvalidInput" /* InvalidInput */ });
17248
+ }
17249
+ failureAt = "ReadProfiles" /* ReadProfiles */;
17250
+ const profiles = await this.profiles.list(options);
17251
+ failureAt = "ValidateProfiles" /* ValidateProfiles */;
17252
+ const ids = assertUsableProfileIds(profiles);
17253
+ if (!ids.has(contactId)) {
17254
+ throw new TorrowSdkError({
17255
+ category: "InvalidState" /* InvalidState */,
17256
+ detail: { domain: "Profiles" /* Profiles */, reason: "TargetNotProfile" /* TargetNotProfile */ }
17257
+ });
17258
+ }
17259
+ failureAt = "Write" /* Write */;
17260
+ const resp = await this.http.requestJson(
17261
+ { method: "PUT", path: `${BASE20}/defaultprofile`, body: contactId, signal: options?.signal },
17262
+ () => {
17263
+ dispatched = true;
17264
+ }
17265
+ );
17266
+ effect = "Unknown" /* Unknown */;
17267
+ failureAt = "ValidateWriteResponse" /* ValidateWriteResponse */;
17268
+ const profile = resp?.profile;
17269
+ if (!profile || typeof profile !== "object" || Array.isArray(profile) || profile.id !== contactId) {
17270
+ throw new TorrowSdkError({
17271
+ category: "InvalidResponse" /* InvalidResponse */,
17272
+ sensitive: { body: resp }
17273
+ });
17274
+ }
17275
+ effect = "Applied" /* Applied */;
17276
+ failureAt = "ProjectResponse" /* ProjectResponse */;
17277
+ return projectContactItem(profile);
17278
+ } catch (cause) {
17279
+ throw contextualizeProfileWriteError(
17280
+ cause,
17281
+ "setDefaultProfileByContactId" /* SetDefaultProfileByContactId */,
17282
+ failureAt,
17283
+ dispatched,
17284
+ effect
17285
+ );
17286
+ }
16994
17287
  }
16995
17288
  /**
16996
17289
  * `POST /api/v1/user/defaultprofile` — создать и назначить дефолтный профиль.
@@ -18984,6 +19277,7 @@ export {
18984
19277
  LayoutTypeValues,
18985
19278
  LoyaltyCardIssueTypeValues,
18986
19279
  LoyaltyCardSortConditionValues,
19280
+ LoyaltyCardStateValues,
18987
19281
  LoyaltyCardUpdateKeyInformationValues,
18988
19282
  LoyaltyCardUpdateNonKeyInformationValues,
18989
19283
  LoyaltyCardsFacade,
@@ -18995,6 +19289,10 @@ export {
18995
19289
  ParticipationFieldTypeValues,
18996
19290
  PaymentProviderTypeValues,
18997
19291
  PinnedViewsFacade,
19292
+ ProfileEffectStep,
19293
+ ProfileErrorReason,
19294
+ ProfileFailureAt,
19295
+ ProfileOperation,
18998
19296
  ProfileTypeValues,
18999
19297
  ProfilesFacade,
19000
19298
  RawClient,