@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.cjs CHANGED
@@ -67,6 +67,8 @@ __export(index_exports, {
67
67
  Search: () => Search,
68
68
  Settlement: () => Settlement,
69
69
  Subscriptions: () => Subscriptions,
70
+ WCAG_AA_TEXT: () => WCAG_AA_TEXT,
71
+ WCAG_AA_UI: () => WCAG_AA_UI,
70
72
  Webhooks: () => Webhooks,
71
73
  allOf: () => allOf,
72
74
  anyOf: () => anyOf,
@@ -77,6 +79,7 @@ __export(index_exports, {
77
79
  cloneCustomField: () => cloneCustomField,
78
80
  cloneNativePane: () => cloneNativePane,
79
81
  clonePane: () => clonePane,
82
+ contrastRatio: () => contrastRatio,
80
83
  customFieldContextFromMetadata: () => customFieldContextFromMetadata,
81
84
  customFieldIsTextLike: () => customFieldIsTextLike,
82
85
  customFieldOperatorTakesValue: () => customFieldOperatorTakesValue,
@@ -3688,6 +3691,28 @@ var Analytics = class {
3688
3691
  */
3689
3692
  async deviceTransactions(params) {
3690
3693
  return this.request("GET", "/analytics/devices/transactions", {
3694
+ // A discriminated union carries no index signature, so the widening
3695
+ // goes via `unknown` — the union is the point.
3696
+ query: params
3697
+ });
3698
+ }
3699
+ /**
3700
+ * The payments behind one clicked element of the payments dashboard: a
3701
+ * processor-donut slice, a payment-method slice, an outcome segment of a
3702
+ * series bar, a series bucket, or a breakdown row — combinable, with
3703
+ * `target_bucket` narrowing every other target. The outcome mapping is the
3704
+ * one the series and donuts are folded with, expanded server-side, so the
3705
+ * list is what the clicked number was made of. Rows and the whole-match
3706
+ * `summary` carry USD figures converted with the dashboard's own rates.
3707
+ * Same window/scope/chip contract as `scope`; sorted per `sort_on` /
3708
+ * `sort_by`, `limit` rows (default 50) per page, `offset` for the next.
3709
+ * `GET /analytics/scope/transactions`
3710
+ */
3711
+ async scopeTransactions(params) {
3712
+ return this.request("GET", "/analytics/scope/transactions", {
3713
+ // A discriminated union carries no index signature, so the widening
3714
+ // goes via `unknown` — the union is the point, and the query builder
3715
+ // only ever reads own enumerable keys.
3691
3716
  query: params
3692
3717
  });
3693
3718
  }
@@ -5216,14 +5241,41 @@ var HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
5216
5241
  function isHexColor(value) {
5217
5242
  return HEX_RE.test(value.trim());
5218
5243
  }
5244
+ var CSS_HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5245
+ var LENIENT_HEX_RE = /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5246
+ function parseHexChannels(value, pattern) {
5247
+ const match = pattern.exec(value.trim());
5248
+ if (!match) return null;
5249
+ const digits = match[1];
5250
+ const full = digits.length === 3 ? digits.split("").map((c) => c + c).join("") : digits;
5251
+ return [
5252
+ parseInt(full.slice(0, 2), 16),
5253
+ parseInt(full.slice(2, 4), 16),
5254
+ parseInt(full.slice(4, 6), 16)
5255
+ ];
5256
+ }
5257
+ function relativeLuminance([r, g, b]) {
5258
+ const [lr, lg, lb] = [r, g, b].map((channel) => {
5259
+ const c = channel / 255;
5260
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
5261
+ });
5262
+ return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
5263
+ }
5264
+ var WCAG_AA_TEXT = 4.5;
5265
+ var WCAG_AA_UI = 3;
5266
+ function contrastRatio(a, b) {
5267
+ const first = parseHexChannels(a, CSS_HEX_RE);
5268
+ const second = parseHexChannels(b, CSS_HEX_RE);
5269
+ if (!first || !second) return null;
5270
+ const [x, y] = [relativeLuminance(first), relativeLuminance(second)];
5271
+ const lighter = Math.max(x, y);
5272
+ const darker = Math.min(x, y);
5273
+ return (lighter + 0.05) / (darker + 0.05);
5274
+ }
5219
5275
  function isDarkSurface(color) {
5220
- const m = color.replace("#", "").trim();
5221
- if (m.length !== 3 && m.length !== 6) return false;
5222
- const full = m.length === 3 ? m.split("").map((c) => c + c).join("") : m;
5223
- const r = parseInt(full.slice(0, 2), 16);
5224
- const g = parseInt(full.slice(2, 4), 16);
5225
- const b = parseInt(full.slice(4, 6), 16);
5226
- if ([r, g, b].some(Number.isNaN)) return false;
5276
+ const channels = parseHexChannels(color, LENIENT_HEX_RE);
5277
+ if (!channels) return false;
5278
+ const [r, g, b] = channels;
5227
5279
  const luma = (r * 299 + g * 587 + b * 114) / 1e3;
5228
5280
  return luma < 128;
5229
5281
  }
@@ -6855,6 +6907,8 @@ var encodeNativePanes = encodePanes;
6855
6907
  Search,
6856
6908
  Settlement,
6857
6909
  Subscriptions,
6910
+ WCAG_AA_TEXT,
6911
+ WCAG_AA_UI,
6858
6912
  Webhooks,
6859
6913
  allOf,
6860
6914
  anyOf,
@@ -6865,6 +6919,7 @@ var encodeNativePanes = encodePanes;
6865
6919
  cloneCustomField,
6866
6920
  cloneNativePane,
6867
6921
  clonePane,
6922
+ contrastRatio,
6868
6923
  customFieldContextFromMetadata,
6869
6924
  customFieldIsTextLike,
6870
6925
  customFieldOperatorTakesValue,