@delopay/sdk 0.111.0 → 0.112.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-3O5MU6FP.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,
@@ -3700,6 +3703,28 @@ var Analytics = class {
3700
3703
  */
3701
3704
  async deviceTransactions(params) {
3702
3705
  return this.request("GET", "/analytics/devices/transactions", {
3706
+ // A discriminated union carries no index signature, so the widening
3707
+ // goes via `unknown` — the union is the point.
3708
+ query: params
3709
+ });
3710
+ }
3711
+ /**
3712
+ * The payments behind one clicked element of the payments dashboard: a
3713
+ * processor-donut slice, a payment-method slice, an outcome segment of a
3714
+ * series bar, a series bucket, or a breakdown row — combinable, with
3715
+ * `target_bucket` narrowing every other target. The outcome mapping is the
3716
+ * one the series and donuts are folded with, expanded server-side, so the
3717
+ * list is what the clicked number was made of. Rows and the whole-match
3718
+ * `summary` carry USD figures converted with the dashboard's own rates.
3719
+ * Same window/scope/chip contract as `scope`; sorted per `sort_on` /
3720
+ * `sort_by`, `limit` rows (default 50) per page, `offset` for the next.
3721
+ * `GET /analytics/scope/transactions`
3722
+ */
3723
+ async scopeTransactions(params) {
3724
+ return this.request("GET", "/analytics/scope/transactions", {
3725
+ // A discriminated union carries no index signature, so the widening
3726
+ // goes via `unknown` — the union is the point, and the query builder
3727
+ // only ever reads own enumerable keys.
3703
3728
  query: params
3704
3729
  });
3705
3730
  }
@@ -5228,14 +5253,41 @@ var HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
5228
5253
  function isHexColor(value) {
5229
5254
  return HEX_RE.test(value.trim());
5230
5255
  }
5256
+ var CSS_HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5257
+ var LENIENT_HEX_RE = /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5258
+ function parseHexChannels(value, pattern) {
5259
+ const match = pattern.exec(value.trim());
5260
+ if (!match) return null;
5261
+ const digits = match[1];
5262
+ const full = digits.length === 3 ? digits.split("").map((c) => c + c).join("") : digits;
5263
+ return [
5264
+ parseInt(full.slice(0, 2), 16),
5265
+ parseInt(full.slice(2, 4), 16),
5266
+ parseInt(full.slice(4, 6), 16)
5267
+ ];
5268
+ }
5269
+ function relativeLuminance([r, g, b]) {
5270
+ const [lr, lg, lb] = [r, g, b].map((channel) => {
5271
+ const c = channel / 255;
5272
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
5273
+ });
5274
+ return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
5275
+ }
5276
+ var WCAG_AA_TEXT = 4.5;
5277
+ var WCAG_AA_UI = 3;
5278
+ function contrastRatio(a, b) {
5279
+ const first = parseHexChannels(a, CSS_HEX_RE);
5280
+ const second = parseHexChannels(b, CSS_HEX_RE);
5281
+ if (!first || !second) return null;
5282
+ const [x, y] = [relativeLuminance(first), relativeLuminance(second)];
5283
+ const lighter = Math.max(x, y);
5284
+ const darker = Math.min(x, y);
5285
+ return (lighter + 0.05) / (darker + 0.05);
5286
+ }
5231
5287
  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;
5288
+ const channels = parseHexChannels(color, LENIENT_HEX_RE);
5289
+ if (!channels) return false;
5290
+ const [r, g, b] = channels;
5239
5291
  const luma = (r * 299 + g * 587 + b * 114) / 1e3;
5240
5292
  return luma < 128;
5241
5293
  }
@@ -6979,6 +7031,19 @@ var AdminPortal = class {
6979
7031
  */
6980
7032
  async analyticsDeviceTransactions(params) {
6981
7033
  return this.request("GET", "/admin-portal/analytics/devices/transactions", {
7034
+ // A discriminated union carries no index signature, so the widening
7035
+ // goes via `unknown` — the union is the point.
7036
+ query: params
7037
+ });
7038
+ }
7039
+ /**
7040
+ * The payments behind one clicked element of the admin payments dashboard
7041
+ * (processor / method slice, outcome segment, series bucket or breakdown
7042
+ * row), rooted at all merchants. Same contract as the merchant surface's
7043
+ * `analytics.scopeTransactions`. `GET /admin-portal/analytics/scope/transactions`
7044
+ */
7045
+ async analyticsScopeTransactions(params) {
7046
+ return this.request("GET", "/admin-portal/analytics/scope/transactions", {
6982
7047
  query: params
6983
7048
  });
6984
7049
  }
@@ -7738,6 +7803,8 @@ var DelopayInternal = class extends Delopay {
7738
7803
  Search,
7739
7804
  Settlement,
7740
7805
  Subscriptions,
7806
+ WCAG_AA_TEXT,
7807
+ WCAG_AA_UI,
7741
7808
  Webhooks,
7742
7809
  allOf,
7743
7810
  anyOf,
@@ -7748,6 +7815,7 @@ var DelopayInternal = class extends Delopay {
7748
7815
  cloneCustomField,
7749
7816
  cloneNativePane,
7750
7817
  clonePane,
7818
+ contrastRatio,
7751
7819
  customFieldContextFromMetadata,
7752
7820
  customFieldIsTextLike,
7753
7821
  customFieldOperatorTakesValue,