@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.
- package/LICENSE +201 -0
- package/README.md +229 -200
- package/dist/_chunks/events.d.ts +133 -122
- package/dist/_chunks/events.js +45 -7
- package/dist/_chunks/index.d.ts +970 -589
- package/dist/_chunks/locale.d.ts +3 -3
- package/dist/_chunks/src.js +130 -18
- package/dist/_chunks/validators.d.ts +2 -2
- package/dist/_chunks/webhook-core.d.ts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +3 -3
- package/dist/index.d.ts +24 -24
- package/dist/index.js +4 -4
- package/dist/server.d.ts +32 -20
- package/dist/server.js +7 -3
- package/package.json +14 -8
package/dist/_chunks/events.js
CHANGED
|
@@ -372,11 +372,11 @@ function meterFilterIssues(filter) {
|
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
374
|
if (depth + 1 > 3) return;
|
|
375
|
-
members.
|
|
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 {
|
|
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 };
|