@delopay/sdk 0.46.0 → 0.48.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/{chunk-25GERHCM.js → chunk-SX46W7E4.js} +122 -2
- package/dist/chunk-SX46W7E4.js.map +1 -0
- package/dist/index.cjs +126 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -1
- package/dist/index.d.ts +121 -1
- package/dist/index.js +11 -1
- package/dist/internal.cjs +137 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +9 -3
- package/dist/internal.d.ts +9 -3
- package/dist/internal.js +22 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-25GERHCM.js.map +0 -1
|
@@ -727,6 +727,20 @@ var FeeRulesManager = class {
|
|
|
727
727
|
query: { merchant_id: merchantId, profile_id: profileId }
|
|
728
728
|
});
|
|
729
729
|
}
|
|
730
|
+
/**
|
|
731
|
+
* Dry-run a candidate fee-rule program against a sample transaction.
|
|
732
|
+
* Returns the matched rule name, whether it fell through, and the computed fee.
|
|
733
|
+
* Does not persist anything.
|
|
734
|
+
*
|
|
735
|
+
* @param input - Candidate program + sample transaction fields.
|
|
736
|
+
* @param merchantId - The merchant account ID.
|
|
737
|
+
*/
|
|
738
|
+
async preview(input, merchantId) {
|
|
739
|
+
return this.request("POST", "/merchant-fees/rules/preview", {
|
|
740
|
+
body: input,
|
|
741
|
+
query: { merchant_id: merchantId }
|
|
742
|
+
});
|
|
743
|
+
}
|
|
730
744
|
};
|
|
731
745
|
|
|
732
746
|
// src/resources/mandates.ts
|
|
@@ -2659,6 +2673,21 @@ var AvailabilityOverrides = class {
|
|
|
2659
2673
|
async delete(id) {
|
|
2660
2674
|
return this.request("DELETE", `/availability-overrides/${encodeURIComponent(id)}`);
|
|
2661
2675
|
}
|
|
2676
|
+
/**
|
|
2677
|
+
* Preview the methods a customer in `country` would be shown for a shop —
|
|
2678
|
+
* the connector ceiling narrowed by the smart country defaults and the
|
|
2679
|
+
* merchant overrides, without an active payment.
|
|
2680
|
+
* `GET /availability-overrides/preview`
|
|
2681
|
+
*/
|
|
2682
|
+
async preview(params) {
|
|
2683
|
+
return this.request("GET", "/availability-overrides/preview", {
|
|
2684
|
+
query: {
|
|
2685
|
+
merchant_id: params.merchant_id,
|
|
2686
|
+
profile_id: params.profile_id,
|
|
2687
|
+
...params.country ? { country: params.country } : {}
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2662
2691
|
};
|
|
2663
2692
|
|
|
2664
2693
|
// src/resources/subscriptions.ts
|
|
@@ -3158,6 +3187,16 @@ var Delopay = class {
|
|
|
3158
3187
|
Delopay.webhooks = Webhooks;
|
|
3159
3188
|
|
|
3160
3189
|
// src/feeProgram.ts
|
|
3190
|
+
function leaf(lhs, comparison, value) {
|
|
3191
|
+
const tagged = typeof value === "number" ? { type: "number", value } : { type: "enum_variant", value };
|
|
3192
|
+
return { kind: "leaf", lhs, comparison, value: tagged };
|
|
3193
|
+
}
|
|
3194
|
+
function allOf(...children) {
|
|
3195
|
+
return { kind: "all", children };
|
|
3196
|
+
}
|
|
3197
|
+
function anyOf(...children) {
|
|
3198
|
+
return { kind: "any", children };
|
|
3199
|
+
}
|
|
3161
3200
|
function toFeeOutput(spec) {
|
|
3162
3201
|
const hasPct = spec.percentage != null;
|
|
3163
3202
|
const hasFlat = spec.flat != null;
|
|
@@ -3190,9 +3229,83 @@ function buildConditions(when = {}, raw = []) {
|
|
|
3190
3229
|
if (when.amountLessThan != null) {
|
|
3191
3230
|
out.push(numberCondition("amount", "less_than", when.amountLessThan));
|
|
3192
3231
|
}
|
|
3232
|
+
if (when.merchantVolumeEquals != null) {
|
|
3233
|
+
out.push(numberCondition("merchant_volume", "equal", when.merchantVolumeEquals));
|
|
3234
|
+
}
|
|
3235
|
+
if (when.merchantVolumeGreaterThan != null) {
|
|
3236
|
+
out.push(numberCondition("merchant_volume", "greater_than", when.merchantVolumeGreaterThan));
|
|
3237
|
+
}
|
|
3238
|
+
if (when.merchantVolumeLessThan != null) {
|
|
3239
|
+
out.push(numberCondition("merchant_volume", "less_than", when.merchantVolumeLessThan));
|
|
3240
|
+
}
|
|
3193
3241
|
out.push(...raw);
|
|
3194
3242
|
return out;
|
|
3195
3243
|
}
|
|
3244
|
+
function leafToComparison(node) {
|
|
3245
|
+
return { lhs: node.lhs, comparison: node.comparison, value: node.value, metadata: {} };
|
|
3246
|
+
}
|
|
3247
|
+
function normalizeNode(node) {
|
|
3248
|
+
if (node.kind === "leaf") return node;
|
|
3249
|
+
const children = node.children.map(normalizeNode);
|
|
3250
|
+
const flat = [];
|
|
3251
|
+
for (const c of children) {
|
|
3252
|
+
if (c.kind === node.kind) flat.push(...c.children);
|
|
3253
|
+
else flat.push(c);
|
|
3254
|
+
}
|
|
3255
|
+
if (flat.length === 1) return flat[0];
|
|
3256
|
+
return { kind: node.kind, children: flat };
|
|
3257
|
+
}
|
|
3258
|
+
function toStatement(node) {
|
|
3259
|
+
if (node.kind === "leaf") return { condition: [leafToComparison(node)], nested: null };
|
|
3260
|
+
if (node.kind === "any") {
|
|
3261
|
+
return { condition: [], nested: node.children.map(toStatement) };
|
|
3262
|
+
}
|
|
3263
|
+
const leaves = node.children.filter((c) => c.kind === "leaf");
|
|
3264
|
+
const groups = node.children.filter((c) => c.kind !== "leaf");
|
|
3265
|
+
const condition = leaves.map(leafToComparison);
|
|
3266
|
+
if (groups.length === 0) return { condition, nested: null };
|
|
3267
|
+
const [first, ...rest] = groups;
|
|
3268
|
+
const nested = first.children.map((branch) => toStatement(normalizeNode(allOf(branch, ...rest))));
|
|
3269
|
+
return { condition, nested };
|
|
3270
|
+
}
|
|
3271
|
+
function assertNoEmptyAnyOf(node) {
|
|
3272
|
+
if (node.kind === "leaf") return;
|
|
3273
|
+
if (node.kind === "any" && node.children.length === 0) {
|
|
3274
|
+
throw new Error("feeProgram: an anyOf() group must have at least one condition");
|
|
3275
|
+
}
|
|
3276
|
+
node.children.forEach(assertNoEmptyAnyOf);
|
|
3277
|
+
}
|
|
3278
|
+
function encodeStatements(match) {
|
|
3279
|
+
const m = normalizeNode(match);
|
|
3280
|
+
if (m.kind === "any") return m.children.map(toStatement);
|
|
3281
|
+
return [toStatement(m)];
|
|
3282
|
+
}
|
|
3283
|
+
function comparisonToLeaf(c) {
|
|
3284
|
+
return { kind: "leaf", lhs: c.lhs, comparison: c.comparison, value: c.value };
|
|
3285
|
+
}
|
|
3286
|
+
function statementToNode(stmt) {
|
|
3287
|
+
const leaves = stmt.condition.map(comparisonToLeaf);
|
|
3288
|
+
if (stmt.nested && stmt.nested.length > 0) {
|
|
3289
|
+
const orNode = anyOf(...stmt.nested.map(statementToNode));
|
|
3290
|
+
if (leaves.length === 0) return orNode;
|
|
3291
|
+
return allOf(...leaves, orNode);
|
|
3292
|
+
}
|
|
3293
|
+
return leaves.length === 1 ? leaves[0] : allOf(...leaves);
|
|
3294
|
+
}
|
|
3295
|
+
function ruleMatchToTree(statements) {
|
|
3296
|
+
if (statements.length === 1) return normalizeNode(statementToNode(statements[0]));
|
|
3297
|
+
return normalizeNode(anyOf(...statements.map(statementToNode)));
|
|
3298
|
+
}
|
|
3299
|
+
function programToTree(program) {
|
|
3300
|
+
return {
|
|
3301
|
+
rules: program.rules.map((r) => ({
|
|
3302
|
+
name: r.name,
|
|
3303
|
+
match: ruleMatchToTree(r.statements),
|
|
3304
|
+
fee: r.connectorSelection.fee ?? null
|
|
3305
|
+
})),
|
|
3306
|
+
otherwise: program.defaultSelection.fee ?? null
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3196
3309
|
var FeeProgramBuilder = class {
|
|
3197
3310
|
constructor() {
|
|
3198
3311
|
this.rules = [];
|
|
@@ -3200,10 +3313,12 @@ var FeeProgramBuilder = class {
|
|
|
3200
3313
|
}
|
|
3201
3314
|
/** Append a rule. Provided `when`/`rawConditions` are ANDed. */
|
|
3202
3315
|
rule(input) {
|
|
3316
|
+
if (input.match) assertNoEmptyAnyOf(input.match);
|
|
3317
|
+
const statements = input.match ? encodeStatements(input.match) : [{ condition: buildConditions(input.when, input.rawConditions) }];
|
|
3203
3318
|
this.rules.push({
|
|
3204
3319
|
name: input.name,
|
|
3205
3320
|
connectorSelection: { fee: toFeeOutput(input.fee) },
|
|
3206
|
-
statements
|
|
3321
|
+
statements
|
|
3207
3322
|
});
|
|
3208
3323
|
return this;
|
|
3209
3324
|
}
|
|
@@ -3872,6 +3987,11 @@ export {
|
|
|
3872
3987
|
AvailabilityOverrides,
|
|
3873
3988
|
Subscriptions,
|
|
3874
3989
|
Delopay,
|
|
3990
|
+
leaf,
|
|
3991
|
+
allOf,
|
|
3992
|
+
anyOf,
|
|
3993
|
+
ruleMatchToTree,
|
|
3994
|
+
programToTree,
|
|
3875
3995
|
FeeProgramBuilder,
|
|
3876
3996
|
feeProgram,
|
|
3877
3997
|
fontStack,
|
|
@@ -3903,4 +4023,4 @@ export {
|
|
|
3903
4023
|
applyBrandingVariables,
|
|
3904
4024
|
shadowFor
|
|
3905
4025
|
};
|
|
3906
|
-
//# sourceMappingURL=chunk-
|
|
4026
|
+
//# sourceMappingURL=chunk-SX46W7E4.js.map
|