@delopay/sdk 0.75.0 → 0.77.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.
@@ -1169,6 +1169,17 @@ var Payments = class {
1169
1169
  * { headers: { 'Idempotency-Key': 'order_1001' } },
1170
1170
  * );
1171
1171
  * ```
1172
+ *
1173
+ * @example Send `test_mode` to pick the environment per payment, so a staging
1174
+ * deploy cannot charge real cards and a forgotten processor toggle cannot
1175
+ * swallow production traffic:
1176
+ * ```typescript
1177
+ * const payment = await delopay.payments.create({
1178
+ * amount: 5000,
1179
+ * currency: 'EUR',
1180
+ * test_mode: process.env.NODE_ENV !== 'production',
1181
+ * });
1182
+ * ```
1172
1183
  */
1173
1184
  async create(params, options) {
1174
1185
  return this.request("POST", "/payments", { body: params, ...options });
@@ -4001,8 +4012,17 @@ var ALL_CUSTOM_FIELD_TYPES = [
4001
4012
  "textarea",
4002
4013
  "password",
4003
4014
  "email",
4004
- "select"
4015
+ "select",
4016
+ "checkbox"
4005
4017
  ];
4018
+ var CHECKBOX_CHECKED = "true";
4019
+ var CHECKBOX_UNCHECKED = "false";
4020
+ function isCheckboxChecked(value) {
4021
+ return typeof value === "string" && value.trim().toLowerCase() === CHECKBOX_CHECKED;
4022
+ }
4023
+ function customFieldIsTextLike(type) {
4024
+ return type !== "select" && type !== "checkbox";
4025
+ }
4006
4026
  var CUSTOM_FIELD_CONDITIONS_MAX = 10;
4007
4027
  var ALL_CUSTOM_FIELD_CONDITION_SOURCES = [
4008
4028
  "metadata",
@@ -4105,8 +4125,11 @@ function normalizeCustomField(raw, index) {
4105
4125
  labelTranslations: parseTranslations(o["labelTranslations"])
4106
4126
  };
4107
4127
  }).filter((o) => o.value.length > 0) : [];
4108
- const minLength = parseBoundedInt(f["minLength"]);
4109
- const maxLength = parseBoundedInt(f["maxLength"]);
4128
+ const textLike = customFieldIsTextLike(type);
4129
+ const minLength = textLike ? parseBoundedInt(f["minLength"]) : null;
4130
+ const maxLength = textLike ? parseBoundedInt(f["maxLength"]) : null;
4131
+ const rawDefault = typeof f["defaultValue"] === "string" ? f["defaultValue"] : "";
4132
+ const defaultValue = type === "checkbox" ? isCheckboxChecked(rawDefault) ? CHECKBOX_CHECKED : CHECKBOX_UNCHECKED : rawDefault;
4110
4133
  return {
4111
4134
  id: typeof f["id"] === "string" && f["id"] ? f["id"] : `field-${index}`,
4112
4135
  key,
@@ -4122,7 +4145,7 @@ function normalizeCustomField(raw, index) {
4122
4145
  minLength,
4123
4146
  // Guard inverted bounds at decode so consumers never see min > max.
4124
4147
  maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
4125
- defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
4148
+ defaultValue,
4126
4149
  options,
4127
4150
  visibility: normalizeVisibility(f["visibility"])
4128
4151
  };
@@ -4165,9 +4188,13 @@ function encodeCustomFields(fields) {
4165
4188
  ...nonEmpty(f.helpTextTranslations) ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) } : {},
4166
4189
  ...f.required ? { required: true } : {},
4167
4190
  ...f.enabled ? {} : { enabled: false },
4168
- ...f.minLength !== null ? { minLength: f.minLength } : {},
4169
- ...f.maxLength !== null ? { maxLength: f.maxLength } : {},
4170
- ...f.defaultValue ? { defaultValue: f.defaultValue } : {},
4191
+ // Length bounds only exist for free-text types; a choice control that
4192
+ // still carries them is stale state the decoder would drop anyway.
4193
+ ...customFieldIsTextLike(f.type) && f.minLength !== null ? { minLength: f.minLength } : {},
4194
+ ...customFieldIsTextLike(f.type) && f.maxLength !== null ? { maxLength: f.maxLength } : {},
4195
+ // A checkbox persists only "starts ticked"; unticked is the decoder's
4196
+ // default, so writing 'false' would be noise on every such field.
4197
+ ...f.type === "checkbox" ? isCheckboxChecked(f.defaultValue) ? { defaultValue: CHECKBOX_CHECKED } : {} : f.defaultValue ? { defaultValue: f.defaultValue } : {},
4171
4198
  ...f.type === "select" ? { options: f.options } : {},
4172
4199
  // Omitted for unconditional fields so the stored blob (and every
4173
4200
  // pre-feature payload) stays byte-identical to what it was.
@@ -4703,6 +4730,10 @@ export {
4703
4730
  CUSTOM_FIELDS_MAX,
4704
4731
  CUSTOM_FIELD_KEY_PATTERN,
4705
4732
  ALL_CUSTOM_FIELD_TYPES,
4733
+ CHECKBOX_CHECKED,
4734
+ CHECKBOX_UNCHECKED,
4735
+ isCheckboxChecked,
4736
+ customFieldIsTextLike,
4706
4737
  CUSTOM_FIELD_CONDITIONS_MAX,
4707
4738
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
4708
4739
  ALL_CUSTOM_FIELD_OPERATORS,
@@ -4729,4 +4760,4 @@ export {
4729
4760
  applyBrandingVariables,
4730
4761
  shadowFor
4731
4762
  };
4732
- //# sourceMappingURL=chunk-5J763YMV.js.map
4763
+ //# sourceMappingURL=chunk-RODMYISN.js.map