@stewardhq/sdk 0.5.0 → 0.6.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.
@@ -372,11 +372,11 @@ function meterFilterIssues(filter) {
372
372
  return;
373
373
  }
374
374
  if (depth + 1 > 3) return;
375
- members.forEach((member, i) => visit(member, [
375
+ for (const [i, member] of members.entries()) visit(member, [
376
376
  ...path,
377
377
  key,
378
378
  i
379
- ], depth + 1));
379
+ ], depth + 1);
380
380
  return;
381
381
  }
382
382
  conditions += 1;
@@ -839,7 +839,8 @@ const EMAIL_TEMPLATES = [
839
839
  "subscription_terminated",
840
840
  "invoice_issued",
841
841
  "invoice_payment_due",
842
- "price_change_notice"
842
+ "price_change_notice",
843
+ "bank_transfer_instructions"
843
844
  ];
844
845
  const EmailTemplateSchema = z.enum(EMAIL_TEMPLATES);
845
846
  /** `invoice_payment_due`: summary of an unpaid invoice, its due date and the hosted pay page link. */
@@ -899,8 +900,27 @@ const PriceChangeNoticeEmailSchema = z.object({
899
900
  effectiveAt: DateTimeSchema,
900
901
  meteredRates: z.array(PriceChangeNoticeMeteredRateSchema).optional()
901
902
  });
903
+ /**
904
+ * `bank_transfer_instructions` (bank transfer plan H12): how to pay a checkout by bank transfer —
905
+ * the deployment's bank account for the currency, the exact amount, the account's order code to
906
+ * write in the description and the deadline. `reminder`: sent the day before the deadline.
907
+ */
908
+ const BankTransferInstructionsEmailSchema = z.object({
909
+ checkoutSessionId: IdSchema,
910
+ planName: z.string(),
911
+ totalMinor: AmountMinorSchema,
912
+ currency: CurrencySchema,
913
+ beneficiary: z.string(),
914
+ bank: z.string().nullable(),
915
+ iban: z.string(),
916
+ /** The account's order code (`XXXX-XXXX-X`). */
917
+ code: z.string(),
918
+ deadline: DateTimeSchema,
919
+ reminder: z.boolean()
920
+ });
902
921
  /** Payload schema per billing core template. */
903
922
  const EMAIL_PAYLOAD_SCHEMAS = Object.freeze({
923
+ bank_transfer_instructions: BankTransferInstructionsEmailSchema,
904
924
  invoice_payment_due: InvoicePaymentDueEmailSchema,
905
925
  price_change_notice: PriceChangeNoticeEmailSchema
906
926
  });
@@ -1056,6 +1076,7 @@ function isEmailRelevant(template, facts) {
1056
1076
  case "subscription_terminated":
1057
1077
  case "price_change_notice": return true;
1058
1078
  case "invoice_payment_due": return facts.invoicePaymentStatus === "unpaid";
1079
+ case "bank_transfer_instructions": return facts.transferPending === true;
1059
1080
  case "payment_failed": return sub?.status === "past_due";
1060
1081
  case "cancel_scheduled": return sub?.cancelAtPeriodEnd === true;
1061
1082
  case "subscription_ended": return facts.state.subscriptions !== void 0 ? sub === null : facts.state.subscription === null;
@@ -1173,7 +1194,13 @@ const AccountOpenCheckoutSchema = z.object({
1173
1194
  intervalCount: z.number().int().min(1),
1174
1195
  currency: CurrencySchema,
1175
1196
  amountMinor: AmountMinorSchema,
1176
- expiresAt: DateTimeSchema
1197
+ expiresAt: DateTimeSchema,
1198
+ /**
1199
+ * Bank transfer plan (H6): `bank_transfer` when the session waits for the customer's transfer
1200
+ * until `expiresAt` (the product shows "payment pending" with `AccountState.bankTransferCode`).
1201
+ * Absent otherwise (a card checkout's state is unchanged).
1202
+ */
1203
+ paymentMethod: z.enum(["card", "bank_transfer"]).optional()
1177
1204
  });
1178
1205
  /**
1179
1206
  * An unpaid invoice of the account (billing core, M22/M34): renewal or final invoices written
@@ -1234,7 +1261,12 @@ const AccountStateSchema = EntitlementSnapshotSchema.extend({
1234
1261
  * for a product whose catalog defines meters (the state of other products, and so its version
1235
1262
  * and fingerprint, stays exactly as before).
1236
1263
  */
1237
- meters: AccountMetersStateSchema.optional()
1264
+ meters: AccountMetersStateSchema.optional(),
1265
+ /**
1266
+ * Bank transfer plan (H4, H6): the account's order code the customer writes in the transfer
1267
+ * description (`XXXX-XXXX-X`); present once the account chose bank transfer, then permanent.
1268
+ */
1269
+ bankTransferCode: z.string().optional()
1238
1270
  });
1239
1271
  const AccountSchema = z.object({
1240
1272
  ref: ExternalRefSchema,
@@ -1288,7 +1320,13 @@ changed: z.array(z.string()) }),
1288
1320
  interval: IntervalSchema,
1289
1321
  amountMinor: AmountMinorSchema,
1290
1322
  currency: CurrencySchema,
1291
- actorRef: z.string().nullable()
1323
+ actorRef: z.string().nullable(),
1324
+ /**
1325
+ * Upgrade (bank transfer plan H16): the subscription this one replaced — canceled immediately in
1326
+ * the same transaction (`cancelReason` `replaced_by_checkout`, no `subscription.canceled` of its
1327
+ * own). Absent when the checkout replaced nothing.
1328
+ */
1329
+ replacedSubscriptionId: IdSchema.optional()
1292
1330
  }),
1293
1331
  "subscription.renewed": z.object({
1294
1332
  ...sub,
@@ -1493,4 +1531,4 @@ const PingSchema = z.object({
1493
1531
  endpointId: IdSchema
1494
1532
  });
1495
1533
  //#endregion
1496
- export { emailRecipients as $, canonicalMeterFilter as $t, SubscriptionStatusSchema as A, isEventTimestampInRange as An, METER_FILTER_MAX_DEPTH as At, EmailSettingsPatchSchema as B, ErrorCategorySchema as Bn, MeterCreditEntrySchema as Bt, AccountSchema as C, EventsIngestInputSchema as Cn, DecimalUnitsStringSchema as Ct, BillingProfileKindSchema as D, IngestRejectCodeSchema as Dn, METER_CHARGE_STATUSES as Dt, AccountUpsertInputSchema as E, IngestEventSchema as En, METER_AGGREGATION_KINDS as Et, EMAIL_PAYLOAD_SCHEMAS as F, CurrencySchema as Fn, MeterChargeLineSchema as Ft, MAX_NOTIFICATION_EMAILS as G, IdSchema as Gn, MeterLowAtSchema as Gt, EmailTemplateSchema as H, ExternalRefSchema as Hn, MeterDefSchema as Ht, EMAIL_TEMPLATES as I, DateTimeSchema as In, MeterChargeListSchema as It, PriceChangeNoticeEmailSchema as J, InvoicePaymentStatusSchema as Jn, MeterPeriodStatusSchema as Jt, NoticedMeteredRateSchema as K, IntervalSchema as Kn, MeterPeriodListSchema as Kt, EMAIL_TEMPLATE_BY_EVENT as L, ERROR_CATEGORIES as Ln, MeterChargeSchema as Lt, BILLING_PATH_PLACEHOLDERS as M, ActorRefSchema as Mn, METER_PERIOD_STATUSES as Mt, BillingPathSchema as N, AmountMinorSchema as Nn, METER_STANDINGS as Nt, BillingProfileSchema as O, IngestRejectionSchema as On, METER_CREDIT_ENTRY_KINDS as Ot, EMAIL_LOCALES as P, CodeSchema as Pn, MeterAggregationSchema as Pt, emailLocaleOf as Q, MeteredPriceSchema as Qt, EmailExtraTextSchema as R, EntitlementValueSchema as Rn, MeterChargeStatusSchema as Rt, AccountScheduledChangeSchema as S, EventNameSchema as Sn, DEFAULT_METER_LOW_AT as St, AccountSubscriptionStateSchema as T, INGEST_REJECT_CODES as Tn, MAX_METER_UNITS as Tt, EmailTemplateSettingsSchema as U, INVOICE_BILLING_REASONS as Un, MeterFilterSchema as Ut, EmailSettingsSchema as V, ErrorResponseSchema as Vn, MeterCreditPropertiesSchema as Vt, InvoicePaymentDueEmailSchema as W, INVOICE_PAYMENT_STATUSES as Wn, MeterLabelSchema as Wt, applyEmailSettingsPatch as X, MeterUnitsSchema as Xt, PriceChangeNoticeMeteredRateSchema as Y, MetadataSchema as Yn, MeterStandingSchema as Yt, billingPageUrl as Z, MeteredPriceDefSchema as Zt, AccountMeterStateSchema as _, EVENT_TIMESTAMP_MAX_SKEW_MINUTES as _n, isMeterCreditBenefit as _t, EVENT_TYPES as a, isMicroPrecise as an, AccountBenefitSchema as at, AccountOpenInvoiceSchema as b, EventMetadataSchema as bn, CatalogMeterSchema as bt, LEGACY_EVENT_TYPES as c, plainDecimalOf as cn, BenefitDescriptionSchema as ct, isEventType as d, EVENTS_INGEST_MAX_EVENTS as dn, CatalogBenefitSchema as dt, meterFilterClauseOf as en, emailTemplateOf as et, ACCOUNT_INCLUDES as f, EVENT_METADATA_KEY_MAX_LENGTH as fn, FeatureFlagBenefitDefSchema as ft, AccountLocaleSchema as g, EVENT_TIMESTAMP_MAX_AGE_DAYS as gn, isFeatureFlagBenefit as gt, AccountDunningStateSchema as h, EVENT_NAME_MAX_LENGTH as hn, featureValueMatchesType as ht, EVENT_DETAIL_SCHEMAS as i, fromMicroUnits as in, uniqueEmails as it, SubscriptionSummarySchema as j, API_VERSION as jn, METER_FILTER_OPERATORS as jt, EntitlementSnapshotSchema as k, hasControlCharacters as kn, METER_FILTER_MAX_CONDITIONS as kt, PING_EVENT_TYPE as l, toMicroUnits as ln, BenefitSourceSchema as lt, AccountDeleteResponseSchema as m, EVENT_METADATA_STRING_MAX_LENGTH as mn, MeterCreditBenefitDefSchema as mt, ApiVersionSchema as n, MICRO_UNITS_PER_UNIT as nn, isEmailRelevant as nt, EventIdSchema as o, microToDecimalString as on, BENEFIT_TYPES as ot, AccessStateSchema as p, EVENT_METADATA_MAX_PAIRS as pn, FeatureFlagPropertiesSchema as pt, NotificationEmailsSchema as q, InvoiceBillingReasonSchema as qn, MeterPeriodSchema as qt, BillingEventSchema as r, UNIT_DECIMALS as rn, liveSubscriptionOf as rt, FULL_STATE_EVENT_TYPES as s, parseMicroUnits as sn, BenefitDefSchema as st, AnyBillingEventSchema as t, InvalidUnitValueError as tn, emailTemplateSettings as tt, PingSchema as u, EVENTS_INGEST_MAX_BYTES as un, BenefitTypeSchema as ut, AccountMetersStateSchema as v, EventExternalIdSchema as vn, AccountMeterSchema as vt, AccountStateSchema as w, EventsIngestResultSchema as wn, MAX_METERED_PRICE_PER_UNITS as wt, AccountProfileStateSchema as x, EventMetadataValueSchema as xn, CreditGrantInputSchema as xt, AccountOpenCheckoutSchema as y, EventMetadataKeySchema as yn, AccountMetersSchema as yt, EmailSenderSchema as z, EntitlementsSchema as zn, MeterCreditEntryKindSchema as zt };
1534
+ export { emailLocaleOf as $, MeteredPriceSchema as $t, SubscriptionStatusSchema as A, hasControlCharacters as An, METER_FILTER_MAX_CONDITIONS as At, EmailSenderSchema as B, EntitlementsSchema as Bn, MeterCreditEntryKindSchema as Bt, AccountSchema as C, EventNameSchema as Cn, DEFAULT_METER_LOW_AT as Ct, BillingProfileKindSchema as D, IngestEventSchema as Dn, METER_AGGREGATION_KINDS as Dt, AccountUpsertInputSchema as E, INGEST_REJECT_CODES as En, MAX_METER_UNITS as Et, EMAIL_LOCALES as F, CodeSchema as Fn, MeterAggregationSchema as Ft, InvoicePaymentDueEmailSchema as G, INVOICE_PAYMENT_STATUSES as Gn, MeterLabelSchema as Gt, EmailSettingsSchema as H, ErrorResponseSchema as Hn, MeterCreditPropertiesSchema as Ht, EMAIL_PAYLOAD_SCHEMAS as I, CurrencySchema as In, MeterChargeLineSchema as It, NotificationEmailsSchema as J, InvoiceBillingReasonSchema as Jn, MeterPeriodSchema as Jt, MAX_NOTIFICATION_EMAILS as K, IdSchema as Kn, MeterLowAtSchema as Kt, EMAIL_TEMPLATES as L, DateTimeSchema as Ln, MeterChargeListSchema as Lt, BILLING_PATH_PLACEHOLDERS as M, API_VERSION as Mn, METER_FILTER_OPERATORS as Mt, BankTransferInstructionsEmailSchema as N, ActorRefSchema as Nn, METER_PERIOD_STATUSES as Nt, BillingProfileSchema as O, IngestRejectCodeSchema as On, METER_CHARGE_STATUSES as Ot, BillingPathSchema as P, AmountMinorSchema as Pn, METER_STANDINGS as Pt, billingPageUrl as Q, MeteredPriceDefSchema as Qt, EMAIL_TEMPLATE_BY_EVENT as R, ERROR_CATEGORIES as Rn, MeterChargeSchema as Rt, AccountScheduledChangeSchema as S, EventMetadataValueSchema as Sn, CreditGrantInputSchema as St, AccountSubscriptionStateSchema as T, EventsIngestResultSchema as Tn, MAX_METERED_PRICE_PER_UNITS as Tt, EmailTemplateSchema as U, ExternalRefSchema as Un, MeterDefSchema as Ut, EmailSettingsPatchSchema as V, ErrorCategorySchema as Vn, MeterCreditEntrySchema as Vt, EmailTemplateSettingsSchema as W, INVOICE_BILLING_REASONS as Wn, MeterFilterSchema as Wt, PriceChangeNoticeMeteredRateSchema as X, MetadataSchema as Xn, MeterStandingSchema as Xt, PriceChangeNoticeEmailSchema as Y, InvoicePaymentStatusSchema as Yn, MeterPeriodStatusSchema as Yt, applyEmailSettingsPatch as Z, MeterUnitsSchema as Zt, AccountMeterStateSchema as _, EVENT_TIMESTAMP_MAX_AGE_DAYS as _n, isFeatureFlagBenefit as _t, EVENT_TYPES as a, fromMicroUnits as an, uniqueEmails as at, AccountOpenInvoiceSchema as b, EventMetadataKeySchema as bn, AccountMetersSchema as bt, LEGACY_EVENT_TYPES as c, parseMicroUnits as cn, BenefitDefSchema as ct, isEventType as d, EVENTS_INGEST_MAX_BYTES as dn, BenefitTypeSchema as dt, canonicalMeterFilter as en, emailRecipients as et, ACCOUNT_INCLUDES as f, EVENTS_INGEST_MAX_EVENTS as fn, CatalogBenefitSchema as ft, AccountLocaleSchema as g, EVENT_NAME_MAX_LENGTH as gn, featureValueMatchesType as gt, AccountDunningStateSchema as h, EVENT_METADATA_STRING_MAX_LENGTH as hn, MeterCreditBenefitDefSchema as ht, EVENT_DETAIL_SCHEMAS as i, UNIT_DECIMALS as in, liveSubscriptionOf as it, SubscriptionSummarySchema as j, isEventTimestampInRange as jn, METER_FILTER_MAX_DEPTH as jt, EntitlementSnapshotSchema as k, IngestRejectionSchema as kn, METER_CREDIT_ENTRY_KINDS as kt, PING_EVENT_TYPE as l, plainDecimalOf as ln, BenefitDescriptionSchema as lt, AccountDeleteResponseSchema as m, EVENT_METADATA_MAX_PAIRS as mn, FeatureFlagPropertiesSchema as mt, ApiVersionSchema as n, InvalidUnitValueError as nn, emailTemplateSettings as nt, EventIdSchema as o, isMicroPrecise as on, AccountBenefitSchema as ot, AccessStateSchema as p, EVENT_METADATA_KEY_MAX_LENGTH as pn, FeatureFlagBenefitDefSchema as pt, NoticedMeteredRateSchema as q, IntervalSchema as qn, MeterPeriodListSchema as qt, BillingEventSchema as r, MICRO_UNITS_PER_UNIT as rn, isEmailRelevant as rt, FULL_STATE_EVENT_TYPES as s, microToDecimalString as sn, BENEFIT_TYPES as st, AnyBillingEventSchema as t, meterFilterClauseOf as tn, emailTemplateOf as tt, PingSchema as u, toMicroUnits as un, BenefitSourceSchema as ut, AccountMetersStateSchema as v, EVENT_TIMESTAMP_MAX_SKEW_MINUTES as vn, isMeterCreditBenefit as vt, AccountStateSchema as w, EventsIngestInputSchema as wn, DecimalUnitsStringSchema as wt, AccountProfileStateSchema as x, EventMetadataSchema as xn, CatalogMeterSchema as xt, AccountOpenCheckoutSchema as y, EventExternalIdSchema as yn, AccountMeterSchema as yt, EmailExtraTextSchema as z, EntitlementValueSchema as zn, MeterChargeStatusSchema as zt };