@delopay/sdk 0.111.0 → 0.113.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
@@ -46,6 +46,8 @@ import {
46
46
  Search,
47
47
  Settlement,
48
48
  Subscriptions,
49
+ WCAG_AA_TEXT,
50
+ WCAG_AA_UI,
49
51
  Webhooks,
50
52
  allOf,
51
53
  anyOf,
@@ -56,6 +58,7 @@ import {
56
58
  cloneCustomField,
57
59
  cloneNativePane,
58
60
  clonePane,
61
+ contrastRatio,
59
62
  customFieldContextFromMetadata,
60
63
  customFieldIsTextLike,
61
64
  customFieldOperatorTakesValue,
@@ -107,7 +110,7 @@ import {
107
110
  validatePanes,
108
111
  verticalGapValue,
109
112
  visibleCustomFields
110
- } from "./chunk-TS422PA3.js";
113
+ } from "./chunk-NY5O6S5X.js";
111
114
  export {
112
115
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
113
116
  ALL_CUSTOM_FIELD_OPERATORS,
@@ -156,6 +159,8 @@ export {
156
159
  Search,
157
160
  Settlement,
158
161
  Subscriptions,
162
+ WCAG_AA_TEXT,
163
+ WCAG_AA_UI,
159
164
  Webhooks,
160
165
  allOf,
161
166
  anyOf,
@@ -166,6 +171,7 @@ export {
166
171
  cloneCustomField,
167
172
  cloneNativePane,
168
173
  clonePane,
174
+ contrastRatio,
169
175
  customFieldContextFromMetadata,
170
176
  customFieldIsTextLike,
171
177
  customFieldOperatorTakesValue,
package/dist/internal.cjs CHANGED
@@ -79,6 +79,8 @@ __export(internal_exports, {
79
79
  Search: () => Search,
80
80
  Settlement: () => Settlement,
81
81
  Subscriptions: () => Subscriptions,
82
+ WCAG_AA_TEXT: () => WCAG_AA_TEXT,
83
+ WCAG_AA_UI: () => WCAG_AA_UI,
82
84
  Webhooks: () => Webhooks,
83
85
  allOf: () => allOf,
84
86
  anyOf: () => anyOf,
@@ -89,6 +91,7 @@ __export(internal_exports, {
89
91
  cloneCustomField: () => cloneCustomField,
90
92
  cloneNativePane: () => cloneNativePane,
91
93
  clonePane: () => clonePane,
94
+ contrastRatio: () => contrastRatio,
92
95
  customFieldContextFromMetadata: () => customFieldContextFromMetadata,
93
96
  customFieldIsTextLike: () => customFieldIsTextLike,
94
97
  customFieldOperatorTakesValue: () => customFieldOperatorTakesValue,
@@ -2975,7 +2978,10 @@ var Shops = class {
2975
2978
  * @param merchantId - The merchant account ID.
2976
2979
  * @param shopId - The shop (business profile) ID to restyle.
2977
2980
  * @param params - The new `payment_link_config` blob (full replacement).
2978
- * @returns The updated business profile.
2981
+ * @returns The saved branding — the same shape `retrieveCheckoutBranding`
2982
+ * returns, not the whole shop. A role whose only power is restyling a
2983
+ * checkout must not receive the webhook signing key or the card-vault
2984
+ * configuration back from a save.
2979
2985
  */
2980
2986
  async updateCheckoutBranding(merchantId, shopId, params, options) {
2981
2987
  return this.request(
@@ -3700,6 +3706,28 @@ var Analytics = class {
3700
3706
  */
3701
3707
  async deviceTransactions(params) {
3702
3708
  return this.request("GET", "/analytics/devices/transactions", {
3709
+ // A discriminated union carries no index signature, so the widening
3710
+ // goes via `unknown` — the union is the point.
3711
+ query: params
3712
+ });
3713
+ }
3714
+ /**
3715
+ * The payments behind one clicked element of the payments dashboard: a
3716
+ * processor-donut slice, a payment-method slice, an outcome segment of a
3717
+ * series bar, a series bucket, or a breakdown row — combinable, with
3718
+ * `target_bucket` narrowing every other target. The outcome mapping is the
3719
+ * one the series and donuts are folded with, expanded server-side, so the
3720
+ * list is what the clicked number was made of. Rows and the whole-match
3721
+ * `summary` carry USD figures converted with the dashboard's own rates.
3722
+ * Same window/scope/chip contract as `scope`; sorted per `sort_on` /
3723
+ * `sort_by`, `limit` rows (default 50) per page, `offset` for the next.
3724
+ * `GET /analytics/scope/transactions`
3725
+ */
3726
+ async scopeTransactions(params) {
3727
+ return this.request("GET", "/analytics/scope/transactions", {
3728
+ // A discriminated union carries no index signature, so the widening
3729
+ // goes via `unknown` — the union is the point, and the query builder
3730
+ // only ever reads own enumerable keys.
3703
3731
  query: params
3704
3732
  });
3705
3733
  }
@@ -5228,14 +5256,41 @@ var HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
5228
5256
  function isHexColor(value) {
5229
5257
  return HEX_RE.test(value.trim());
5230
5258
  }
5259
+ var CSS_HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5260
+ var LENIENT_HEX_RE = /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5261
+ function parseHexChannels(value, pattern) {
5262
+ const match = pattern.exec(value.trim());
5263
+ if (!match) return null;
5264
+ const digits = match[1];
5265
+ const full = digits.length === 3 ? digits.split("").map((c) => c + c).join("") : digits;
5266
+ return [
5267
+ parseInt(full.slice(0, 2), 16),
5268
+ parseInt(full.slice(2, 4), 16),
5269
+ parseInt(full.slice(4, 6), 16)
5270
+ ];
5271
+ }
5272
+ function relativeLuminance([r, g, b]) {
5273
+ const [lr, lg, lb] = [r, g, b].map((channel) => {
5274
+ const c = channel / 255;
5275
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
5276
+ });
5277
+ return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
5278
+ }
5279
+ var WCAG_AA_TEXT = 4.5;
5280
+ var WCAG_AA_UI = 3;
5281
+ function contrastRatio(a, b) {
5282
+ const first = parseHexChannels(a, CSS_HEX_RE);
5283
+ const second = parseHexChannels(b, CSS_HEX_RE);
5284
+ if (!first || !second) return null;
5285
+ const [x, y] = [relativeLuminance(first), relativeLuminance(second)];
5286
+ const lighter = Math.max(x, y);
5287
+ const darker = Math.min(x, y);
5288
+ return (lighter + 0.05) / (darker + 0.05);
5289
+ }
5231
5290
  function isDarkSurface(color) {
5232
- const m = color.replace("#", "").trim();
5233
- if (m.length !== 3 && m.length !== 6) return false;
5234
- const full = m.length === 3 ? m.split("").map((c) => c + c).join("") : m;
5235
- const r = parseInt(full.slice(0, 2), 16);
5236
- const g = parseInt(full.slice(2, 4), 16);
5237
- const b = parseInt(full.slice(4, 6), 16);
5238
- if ([r, g, b].some(Number.isNaN)) return false;
5291
+ const channels = parseHexChannels(color, LENIENT_HEX_RE);
5292
+ if (!channels) return false;
5293
+ const [r, g, b] = channels;
5239
5294
  const luma = (r * 299 + g * 587 + b * 114) / 1e3;
5240
5295
  return luma < 128;
5241
5296
  }
@@ -6979,6 +7034,19 @@ var AdminPortal = class {
6979
7034
  */
6980
7035
  async analyticsDeviceTransactions(params) {
6981
7036
  return this.request("GET", "/admin-portal/analytics/devices/transactions", {
7037
+ // A discriminated union carries no index signature, so the widening
7038
+ // goes via `unknown` — the union is the point.
7039
+ query: params
7040
+ });
7041
+ }
7042
+ /**
7043
+ * The payments behind one clicked element of the admin payments dashboard
7044
+ * (processor / method slice, outcome segment, series bucket or breakdown
7045
+ * row), rooted at all merchants. Same contract as the merchant surface's
7046
+ * `analytics.scopeTransactions`. `GET /admin-portal/analytics/scope/transactions`
7047
+ */
7048
+ async analyticsScopeTransactions(params) {
7049
+ return this.request("GET", "/admin-portal/analytics/scope/transactions", {
6982
7050
  query: params
6983
7051
  });
6984
7052
  }
@@ -7067,6 +7135,13 @@ var AdminPortal = class {
7067
7135
  * against signup policy + JWT blacklist). `reset_2fa` clears TOTP state
7068
7136
  * so the user re-enrolls on next login. `is_active` supports both
7069
7137
  * directions: false soft-disables, true reactivates a soft-disabled user.
7138
+ *
7139
+ * Throws a `400` with `code === 'UR_66'` when the change would leave a
7140
+ * merchant with no administrator — `is_active: false` or `is_verified:
7141
+ * false` on, or a `role_id` demoting, the only active user whose role can
7142
+ * manage that merchant's users. Nothing is written. `error.data` carries a
7143
+ * {@link LastAdministratorRefusal} naming the merchant and which change was
7144
+ * refused; render that rather than the generic message.
7070
7145
  */
7071
7146
  async updateUser(userId, body) {
7072
7147
  return this.request("PATCH", `/admin-portal/users/${encodeURIComponent(userId)}`, { body });
@@ -7075,6 +7150,9 @@ var AdminPortal = class {
7075
7150
  * Soft-delete a user globally: deactivates the row, blacklists existing
7076
7151
  * JWTs, and wipes credentials. Distinct from `deleteUserRole`, which
7077
7152
  * removes a single role binding while leaving the user signed-in elsewhere.
7153
+ *
7154
+ * Throws the same `UR_66` as {@link updateUser} when the user is the last
7155
+ * administrator of any merchant they belong to, with `route: 'delete'`.
7078
7156
  */
7079
7157
  async deleteUser(userId) {
7080
7158
  return this.request("DELETE", `/admin-portal/users/${encodeURIComponent(userId)}`);
@@ -7738,6 +7816,8 @@ var DelopayInternal = class extends Delopay {
7738
7816
  Search,
7739
7817
  Settlement,
7740
7818
  Subscriptions,
7819
+ WCAG_AA_TEXT,
7820
+ WCAG_AA_UI,
7741
7821
  Webhooks,
7742
7822
  allOf,
7743
7823
  anyOf,
@@ -7748,6 +7828,7 @@ var DelopayInternal = class extends Delopay {
7748
7828
  cloneCustomField,
7749
7829
  cloneNativePane,
7750
7830
  clonePane,
7831
+ contrastRatio,
7751
7832
  customFieldContextFromMetadata,
7752
7833
  customFieldIsTextLike,
7753
7834
  customFieldOperatorTakesValue,