@stewardhq/sdk 0.2.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { G as EntitlementSnapshot, f as EventType, q as SubscriptionStatus } from "./events.js";
1
+ import { I as AccountState, J as SubscriptionStatus, K as EntitlementSnapshot, f as EventType } from "./events.js";
2
2
  import { z } from "zod";
3
3
  //#region ../contract/src/common.d.ts
4
4
  declare const API_VERSION = "2026-10-01";
@@ -717,6 +717,11 @@ declare const AccountDetailSchema: z.ZodObject<{
717
717
  cancelAt: z.ZodNullable<z.ZodISODateTime>;
718
718
  }, z.core.$strip>>;
719
719
  }, z.core.$strip>;
720
+ notificationEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
721
+ locale: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
722
+ tr: "tr";
723
+ en: "en";
724
+ }>>>;
720
725
  profile: z.ZodOptional<z.ZodNullable<z.ZodObject<{
721
726
  kind: z.ZodEnum<{
722
727
  individual: "individual";
@@ -904,6 +909,11 @@ declare const AccountUpsertResponseSchema: z.ZodObject<{
904
909
  cancelAt: z.ZodNullable<z.ZodISODateTime>;
905
910
  }, z.core.$strip>>;
906
911
  }, z.core.$strip>;
912
+ notificationEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
913
+ locale: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
914
+ tr: "tr";
915
+ en: "en";
916
+ }>>>;
907
917
  account: z.ZodOptional<z.ZodObject<{
908
918
  version: z.ZodNumber;
909
919
  planCode: z.ZodString;
@@ -1863,6 +1873,184 @@ declare const ResyncResultSchema: z.ZodObject<{
1863
1873
  }, z.core.$strip>;
1864
1874
  type ResyncResult = z.infer<typeof ResyncResultSchema>;
1865
1875
  //#endregion
1876
+ //#region ../contract/src/emails.d.ts
1877
+ declare const EMAIL_TEMPLATES: readonly ["subscription_started", "payment_receipt", "payment_failed", "cancel_scheduled", "subscription_ended", "access_suspended", "subscription_terminated", "invoice_issued"];
1878
+ declare const EmailTemplateSchema: z.ZodEnum<{
1879
+ subscription_started: "subscription_started";
1880
+ payment_receipt: "payment_receipt";
1881
+ payment_failed: "payment_failed";
1882
+ cancel_scheduled: "cancel_scheduled";
1883
+ subscription_ended: "subscription_ended";
1884
+ access_suspended: "access_suspended";
1885
+ subscription_terminated: "subscription_terminated";
1886
+ invoice_issued: "invoice_issued";
1887
+ }>;
1888
+ type EmailTemplate = z.infer<typeof EmailTemplateSchema>;
1889
+ /** Which event triggers which template. Events not listed send no email. */
1890
+ declare const EMAIL_TEMPLATE_BY_EVENT: Readonly<Partial<Record<EventType, EmailTemplate>>>;
1891
+ declare function emailTemplateOf(type: string): EmailTemplate | null;
1892
+ declare const EMAIL_LOCALES: readonly ["tr", "en"];
1893
+ type EmailLocale = (typeof EMAIL_LOCALES)[number];
1894
+ /** Upper bound of product-provided recipients per account. */
1895
+ declare const MAX_NOTIFICATION_EMAILS = 10;
1896
+ declare const NotificationEmailsSchema: z.ZodPipe<z.ZodArray<z.ZodEmail>, z.ZodTransform<string[], string[]>>;
1897
+ /** Case-insensitive de-duplication; keeps the first spelling and the order. */
1898
+ declare function uniqueEmails(emails: readonly string[]): string[];
1899
+ /** Profile email first, then the account's notification emails. */
1900
+ declare function emailRecipients(profileEmail: string | null | undefined, notificationEmails: readonly string[]): string[];
1901
+ declare function emailLocaleOf(accountLocale: string | null | undefined, lastCheckoutLocale: string | null | undefined, defaultLocale: EmailLocale): EmailLocale;
1902
+ declare const EmailExtraTextSchema: z.ZodObject<{
1903
+ tr: z.ZodOptional<z.ZodString>;
1904
+ en: z.ZodOptional<z.ZodString>;
1905
+ }, z.core.$strip>;
1906
+ declare const EmailTemplateSettingsSchema: z.ZodObject<{
1907
+ enabled: z.ZodDefault<z.ZodBoolean>;
1908
+ extraText: z.ZodOptional<z.ZodObject<{
1909
+ tr: z.ZodOptional<z.ZodString>;
1910
+ en: z.ZodOptional<z.ZodString>;
1911
+ }, z.core.$strip>>;
1912
+ }, z.core.$strip>;
1913
+ type EmailTemplateSettings = z.output<typeof EmailTemplateSettingsSchema>;
1914
+ declare const EmailSenderSchema: z.ZodObject<{
1915
+ name: z.ZodOptional<z.ZodString>;
1916
+ address: z.ZodOptional<z.ZodEmail>;
1917
+ }, z.core.$strip>;
1918
+ /** Placeholders a billing path may use. */
1919
+ declare const BILLING_PATH_PLACEHOLDERS: readonly ["{LOCALE}", "{ACCOUNT_REF}"];
1920
+ declare const BillingPathSchema: z.ZodString;
1921
+ declare const EmailSettingsSchema: z.ZodObject<{
1922
+ from: z.ZodOptional<z.ZodObject<{
1923
+ name: z.ZodOptional<z.ZodString>;
1924
+ address: z.ZodOptional<z.ZodEmail>;
1925
+ }, z.core.$strip>>;
1926
+ replyTo: z.ZodOptional<z.ZodEmail>;
1927
+ billingPath: z.ZodOptional<z.ZodString>;
1928
+ templates: z.ZodDefault<z.ZodObject<{
1929
+ subscription_started: z.ZodOptional<z.ZodObject<{
1930
+ enabled: z.ZodDefault<z.ZodBoolean>;
1931
+ extraText: z.ZodOptional<z.ZodObject<{
1932
+ tr: z.ZodOptional<z.ZodString>;
1933
+ en: z.ZodOptional<z.ZodString>;
1934
+ }, z.core.$strip>>;
1935
+ }, z.core.$strip>>;
1936
+ payment_receipt: z.ZodOptional<z.ZodObject<{
1937
+ enabled: z.ZodDefault<z.ZodBoolean>;
1938
+ extraText: z.ZodOptional<z.ZodObject<{
1939
+ tr: z.ZodOptional<z.ZodString>;
1940
+ en: z.ZodOptional<z.ZodString>;
1941
+ }, z.core.$strip>>;
1942
+ }, z.core.$strip>>;
1943
+ payment_failed: z.ZodOptional<z.ZodObject<{
1944
+ enabled: z.ZodDefault<z.ZodBoolean>;
1945
+ extraText: z.ZodOptional<z.ZodObject<{
1946
+ tr: z.ZodOptional<z.ZodString>;
1947
+ en: z.ZodOptional<z.ZodString>;
1948
+ }, z.core.$strip>>;
1949
+ }, z.core.$strip>>;
1950
+ cancel_scheduled: z.ZodOptional<z.ZodObject<{
1951
+ enabled: z.ZodDefault<z.ZodBoolean>;
1952
+ extraText: z.ZodOptional<z.ZodObject<{
1953
+ tr: z.ZodOptional<z.ZodString>;
1954
+ en: z.ZodOptional<z.ZodString>;
1955
+ }, z.core.$strip>>;
1956
+ }, z.core.$strip>>;
1957
+ subscription_ended: z.ZodOptional<z.ZodObject<{
1958
+ enabled: z.ZodDefault<z.ZodBoolean>;
1959
+ extraText: z.ZodOptional<z.ZodObject<{
1960
+ tr: z.ZodOptional<z.ZodString>;
1961
+ en: z.ZodOptional<z.ZodString>;
1962
+ }, z.core.$strip>>;
1963
+ }, z.core.$strip>>;
1964
+ access_suspended: z.ZodOptional<z.ZodObject<{
1965
+ enabled: z.ZodDefault<z.ZodBoolean>;
1966
+ extraText: z.ZodOptional<z.ZodObject<{
1967
+ tr: z.ZodOptional<z.ZodString>;
1968
+ en: z.ZodOptional<z.ZodString>;
1969
+ }, z.core.$strip>>;
1970
+ }, z.core.$strip>>;
1971
+ subscription_terminated: z.ZodOptional<z.ZodObject<{
1972
+ enabled: z.ZodDefault<z.ZodBoolean>;
1973
+ extraText: z.ZodOptional<z.ZodObject<{
1974
+ tr: z.ZodOptional<z.ZodString>;
1975
+ en: z.ZodOptional<z.ZodString>;
1976
+ }, z.core.$strip>>;
1977
+ }, z.core.$strip>>;
1978
+ invoice_issued: z.ZodOptional<z.ZodObject<{
1979
+ enabled: z.ZodDefault<z.ZodBoolean>;
1980
+ extraText: z.ZodOptional<z.ZodObject<{
1981
+ tr: z.ZodOptional<z.ZodString>;
1982
+ en: z.ZodOptional<z.ZodString>;
1983
+ }, z.core.$strip>>;
1984
+ }, z.core.$strip>>;
1985
+ }, z.core.$strip>>;
1986
+ }, z.core.$strip>;
1987
+ type EmailSettings = z.output<typeof EmailSettingsSchema>;
1988
+ declare const EmailSettingsPatchSchema: z.ZodObject<{
1989
+ from: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1990
+ name: z.ZodOptional<z.ZodString>;
1991
+ address: z.ZodOptional<z.ZodEmail>;
1992
+ }, z.core.$strict>>>;
1993
+ replyTo: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
1994
+ billingPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1995
+ templates: z.ZodOptional<z.ZodObject<{
1996
+ subscription_started: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1997
+ enabled: z.ZodOptional<z.ZodBoolean>;
1998
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
1999
+ }, z.core.$strict>>>;
2000
+ payment_receipt: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2001
+ enabled: z.ZodOptional<z.ZodBoolean>;
2002
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2003
+ }, z.core.$strict>>>;
2004
+ payment_failed: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2005
+ enabled: z.ZodOptional<z.ZodBoolean>;
2006
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2007
+ }, z.core.$strict>>>;
2008
+ cancel_scheduled: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2009
+ enabled: z.ZodOptional<z.ZodBoolean>;
2010
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2011
+ }, z.core.$strict>>>;
2012
+ subscription_ended: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2013
+ enabled: z.ZodOptional<z.ZodBoolean>;
2014
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2015
+ }, z.core.$strict>>>;
2016
+ access_suspended: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2017
+ enabled: z.ZodOptional<z.ZodBoolean>;
2018
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2019
+ }, z.core.$strict>>>;
2020
+ subscription_terminated: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2021
+ enabled: z.ZodOptional<z.ZodBoolean>;
2022
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2023
+ }, z.core.$strict>>>;
2024
+ invoice_issued: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2025
+ enabled: z.ZodOptional<z.ZodBoolean>;
2026
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2027
+ }, z.core.$strict>>>;
2028
+ }, z.core.$strict>>;
2029
+ }, z.core.$strict>;
2030
+ type EmailSettingsPatch = z.output<typeof EmailSettingsPatchSchema>;
2031
+ /** Pure merge of a validated patch (see the patch rules above). */
2032
+ declare function applyEmailSettingsPatch(current: EmailSettings, patch: EmailSettingsPatch | null): EmailSettings;
2033
+ declare function emailTemplateSettings(settings: EmailSettings, template: EmailTemplate): EmailTemplateSettings;
2034
+ /**
2035
+ * Button target: `appUrl` + `billingPath` with placeholders filled (the ref is URL-encoded).
2036
+ * Null without `appUrl`, or when the result would leave the `appUrl` origin.
2037
+ */
2038
+ declare function billingPageUrl(appUrl: string | undefined, billingPath: string | undefined, locale: EmailLocale, accountRef: string): string | null;
2039
+ type EmailRelevanceFacts = {
2040
+ /** Current (stored) account state at send time. */
2041
+ state: AccountState;
2042
+ /** `detail.subscriptionId` of the triggering event, if any. */
2043
+ subscriptionId: string | null;
2044
+ /** Current status of the invoice (`invoice_issued`). */
2045
+ invoiceStatus?: string | null;
2046
+ };
2047
+ /**
2048
+ * Whether the email still describes the account at send time. Receipts, the welcome email
2049
+ * (legal confirmation) and the final termination notice always go; the others only while
2050
+ * the situation they describe still holds.
2051
+ */
2052
+ declare function isEmailRelevant(template: EmailTemplate, facts: EmailRelevanceFacts): boolean;
2053
+ //#endregion
1866
2054
  //#region ../contract/src/settings.d.ts
1867
2055
  /** https; http yalnızca localhost / 127.0.0.1 / [::1]. */
1868
2056
  declare const WebUrlSchema: z.ZodURL;
@@ -1903,6 +2091,72 @@ declare const ProductSettingsSchema: z.ZodObject<{
1903
2091
  }, z.core.$strip>>;
1904
2092
  checkoutTtlMinutes: z.ZodDefault<z.ZodNumber>;
1905
2093
  portalTtlMinutes: z.ZodDefault<z.ZodNumber>;
2094
+ emails: z.ZodDefault<z.ZodObject<{
2095
+ from: z.ZodOptional<z.ZodObject<{
2096
+ name: z.ZodOptional<z.ZodString>;
2097
+ address: z.ZodOptional<z.ZodEmail>;
2098
+ }, z.core.$strip>>;
2099
+ replyTo: z.ZodOptional<z.ZodEmail>;
2100
+ billingPath: z.ZodOptional<z.ZodString>;
2101
+ templates: z.ZodDefault<z.ZodObject<{
2102
+ subscription_started: z.ZodOptional<z.ZodObject<{
2103
+ enabled: z.ZodDefault<z.ZodBoolean>;
2104
+ extraText: z.ZodOptional<z.ZodObject<{
2105
+ tr: z.ZodOptional<z.ZodString>;
2106
+ en: z.ZodOptional<z.ZodString>;
2107
+ }, z.core.$strip>>;
2108
+ }, z.core.$strip>>;
2109
+ payment_receipt: z.ZodOptional<z.ZodObject<{
2110
+ enabled: z.ZodDefault<z.ZodBoolean>;
2111
+ extraText: z.ZodOptional<z.ZodObject<{
2112
+ tr: z.ZodOptional<z.ZodString>;
2113
+ en: z.ZodOptional<z.ZodString>;
2114
+ }, z.core.$strip>>;
2115
+ }, z.core.$strip>>;
2116
+ payment_failed: z.ZodOptional<z.ZodObject<{
2117
+ enabled: z.ZodDefault<z.ZodBoolean>;
2118
+ extraText: z.ZodOptional<z.ZodObject<{
2119
+ tr: z.ZodOptional<z.ZodString>;
2120
+ en: z.ZodOptional<z.ZodString>;
2121
+ }, z.core.$strip>>;
2122
+ }, z.core.$strip>>;
2123
+ cancel_scheduled: z.ZodOptional<z.ZodObject<{
2124
+ enabled: z.ZodDefault<z.ZodBoolean>;
2125
+ extraText: z.ZodOptional<z.ZodObject<{
2126
+ tr: z.ZodOptional<z.ZodString>;
2127
+ en: z.ZodOptional<z.ZodString>;
2128
+ }, z.core.$strip>>;
2129
+ }, z.core.$strip>>;
2130
+ subscription_ended: z.ZodOptional<z.ZodObject<{
2131
+ enabled: z.ZodDefault<z.ZodBoolean>;
2132
+ extraText: z.ZodOptional<z.ZodObject<{
2133
+ tr: z.ZodOptional<z.ZodString>;
2134
+ en: z.ZodOptional<z.ZodString>;
2135
+ }, z.core.$strip>>;
2136
+ }, z.core.$strip>>;
2137
+ access_suspended: z.ZodOptional<z.ZodObject<{
2138
+ enabled: z.ZodDefault<z.ZodBoolean>;
2139
+ extraText: z.ZodOptional<z.ZodObject<{
2140
+ tr: z.ZodOptional<z.ZodString>;
2141
+ en: z.ZodOptional<z.ZodString>;
2142
+ }, z.core.$strip>>;
2143
+ }, z.core.$strip>>;
2144
+ subscription_terminated: z.ZodOptional<z.ZodObject<{
2145
+ enabled: z.ZodDefault<z.ZodBoolean>;
2146
+ extraText: z.ZodOptional<z.ZodObject<{
2147
+ tr: z.ZodOptional<z.ZodString>;
2148
+ en: z.ZodOptional<z.ZodString>;
2149
+ }, z.core.$strip>>;
2150
+ }, z.core.$strip>>;
2151
+ invoice_issued: z.ZodOptional<z.ZodObject<{
2152
+ enabled: z.ZodDefault<z.ZodBoolean>;
2153
+ extraText: z.ZodOptional<z.ZodObject<{
2154
+ tr: z.ZodOptional<z.ZodString>;
2155
+ en: z.ZodOptional<z.ZodString>;
2156
+ }, z.core.$strip>>;
2157
+ }, z.core.$strip>>;
2158
+ }, z.core.$strip>>;
2159
+ }, z.core.$strip>>;
1906
2160
  }, z.core.$strip>;
1907
2161
  type ProductSettings = z.output<typeof ProductSettingsSchema>;
1908
2162
  declare const BrandingPatchSchema: z.ZodObject<{
@@ -1930,6 +2184,48 @@ declare const ProductSettingsPatchSchema: z.ZodObject<{
1930
2184
  }, z.core.$strict>>>;
1931
2185
  checkoutTtlMinutes: z.ZodOptional<z.ZodNumber>;
1932
2186
  portalTtlMinutes: z.ZodOptional<z.ZodNumber>;
2187
+ emails: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2188
+ from: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2189
+ name: z.ZodOptional<z.ZodString>;
2190
+ address: z.ZodOptional<z.ZodEmail>;
2191
+ }, z.core.$strict>>>;
2192
+ replyTo: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
2193
+ billingPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2194
+ templates: z.ZodOptional<z.ZodObject<{
2195
+ subscription_started: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2196
+ enabled: z.ZodOptional<z.ZodBoolean>;
2197
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2198
+ }, z.core.$strict>>>;
2199
+ payment_receipt: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2200
+ enabled: z.ZodOptional<z.ZodBoolean>;
2201
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2202
+ }, z.core.$strict>>>;
2203
+ payment_failed: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2204
+ enabled: z.ZodOptional<z.ZodBoolean>;
2205
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2206
+ }, z.core.$strict>>>;
2207
+ cancel_scheduled: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2208
+ enabled: z.ZodOptional<z.ZodBoolean>;
2209
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2210
+ }, z.core.$strict>>>;
2211
+ subscription_ended: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2212
+ enabled: z.ZodOptional<z.ZodBoolean>;
2213
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2214
+ }, z.core.$strict>>>;
2215
+ access_suspended: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2216
+ enabled: z.ZodOptional<z.ZodBoolean>;
2217
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2218
+ }, z.core.$strict>>>;
2219
+ subscription_terminated: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2220
+ enabled: z.ZodOptional<z.ZodBoolean>;
2221
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2222
+ }, z.core.$strict>>>;
2223
+ invoice_issued: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2224
+ enabled: z.ZodOptional<z.ZodBoolean>;
2225
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2226
+ }, z.core.$strict>>>;
2227
+ }, z.core.$strict>>;
2228
+ }, z.core.$strict>>>;
1933
2229
  }, z.core.$strict>;
1934
2230
  type ProductSettingsPatch = z.input<typeof ProductSettingsPatchSchema>;
1935
2231
  /**
@@ -2141,7 +2437,7 @@ declare const DoctorSeveritySchema: z.ZodEnum<{
2141
2437
  }>;
2142
2438
  type DoctorSeverity = z.infer<typeof DoctorSeveritySchema>;
2143
2439
  /** `warnings[].code` — bu sürümün ürettiği kodlar; küme açık. */
2144
- type DoctorWarningCode = "catalog_not_synced" | "price_not_synced_with_provider" | "price_unsellable" | "provider_not_configured" | "provider_unhealthy" | "no_return_origin" | "app_url_missing" | "branding_incomplete" | "legal_links_missing" | "no_active_endpoint" | "no_state_changed_endpoint" | "endpoint_wrong_secret" | "endpoint_old_contract" | "endpoint_unreachable" | "endpoint_failing" | "endpoint_dead_deliveries" | "endpoint_pending_backlog" | "dunning_dry_run" | (string & Record<never, never>);
2440
+ type DoctorWarningCode = "catalog_not_synced" | "price_not_synced_with_provider" | "price_unsellable" | "provider_not_configured" | "provider_unhealthy" | "no_return_origin" | "app_url_missing" | "branding_incomplete" | "legal_links_missing" | "no_active_endpoint" | "no_state_changed_endpoint" | "endpoint_wrong_secret" | "endpoint_old_contract" | "endpoint_unreachable" | "endpoint_failing" | "endpoint_dead_deliveries" | "endpoint_pending_backlog" | "dunning_dry_run" | "email_not_configured" | "email_sender_missing" | "email_billing_link_missing" | (string & Record<never, never>);
2145
2441
  declare const DoctorWarningSchema: z.ZodObject<{
2146
2442
  code: z.ZodString;
2147
2443
  severity: z.ZodEnum<{
@@ -2280,6 +2576,14 @@ declare const DoctorEndpointSchema: z.ZodObject<{
2280
2576
  diagnosis: z.ZodString;
2281
2577
  }, z.core.$strip>;
2282
2578
  type DoctorEndpoint = z.infer<typeof DoctorEndpointSchema>;
2579
+ /** Billing emails (issue #15). */
2580
+ declare const DoctorEmailsSchema: z.ZodObject<{
2581
+ transportConfigured: z.ZodBoolean;
2582
+ senderConfigured: z.ZodBoolean;
2583
+ disabledTemplates: z.ZodArray<z.ZodString>;
2584
+ ready: z.ZodBoolean;
2585
+ }, z.core.$strip>;
2586
+ type DoctorEmails = z.infer<typeof DoctorEmailsSchema>;
2283
2587
  declare const DoctorReportSchema: z.ZodObject<{
2284
2588
  ok: z.ZodBoolean;
2285
2589
  checkedAt: z.ZodISODateTime;
@@ -2380,6 +2684,12 @@ declare const DoctorReportSchema: z.ZodObject<{
2380
2684
  dunning: z.ZodObject<{
2381
2685
  dryRun: z.ZodBoolean;
2382
2686
  }, z.core.$strip>;
2687
+ emails: z.ZodOptional<z.ZodObject<{
2688
+ transportConfigured: z.ZodBoolean;
2689
+ senderConfigured: z.ZodBoolean;
2690
+ disabledTemplates: z.ZodArray<z.ZodString>;
2691
+ ready: z.ZodBoolean;
2692
+ }, z.core.$strip>>;
2383
2693
  warnings: z.ZodArray<z.ZodObject<{
2384
2694
  code: z.ZodString;
2385
2695
  severity: z.ZodEnum<{
@@ -2398,10 +2708,17 @@ type DoctorFacts = {
2398
2708
  product: DoctorReport["product"];
2399
2709
  catalog: DoctorCatalog;
2400
2710
  provider: DoctorProvider;
2401
- settings: Pick<ProductSettings, "appUrl" | "extraReturnOrigins" | "privacyUrl" | "termsUrl" | "branding">;
2711
+ settings: Pick<ProductSettings, "appUrl" | "extraReturnOrigins" | "privacyUrl" | "termsUrl" | "branding"> & Partial<Pick<ProductSettings, "emails">>;
2402
2712
  endpoints: Omit<DoctorEndpoint, "diagnosis">[];
2403
2713
  dunning: DoctorReport["dunning"];
2714
+ /** Deployment email transport facts; omitted: no email section in the report. */
2715
+ emailTransport?: {
2716
+ configured: boolean;
2717
+ defaultFromConfigured: boolean;
2718
+ };
2404
2719
  };
2720
+ /** Email readiness from settings and the deployment's transport (pure). */
2721
+ declare function emailReadinessOf(settings: DoctorFacts["settings"], transport: NonNullable<DoctorFacts["emailTransport"]>): DoctorEmails;
2405
2722
  /** Bekleyen en eski teslimat bundan eskiyse `endpoint_pending_backlog` (K23 alarmıyla aynı eşik). */
2406
2723
  declare const DOCTOR_PENDING_BACKLOG_MS: number;
2407
2724
  /** Son denenmiş teslimattan endpoint teşhisi (saf). */
@@ -2411,4 +2728,4 @@ declare function hostedReadinessOf(settings: DoctorFacts["settings"]): DoctorHos
2411
2728
  /** Olgulardan raporu türetir (saf): endpoint teşhisleri, hosted hazırlığı, uyarılar ve `ok`. */
2412
2729
  declare function buildDoctorReport(facts: DoctorFacts): DoctorReport;
2413
2730
  //#endregion
2414
- export { DEFAULT_CHECKOUT_TTL_MINUTES as $, CheckoutSessionCreatedSchema as $n, HEADER_SDK as $t, hostedReadinessOf as A, Stats as An, Currency as Ar, ResolvedEntitlements as At, WebhookEndpointRotateInput as B, CHECKOUT_ERRORS as Bn, ErrorResponse as Br, AccountDetailSchema as Bt, DoctorUnsellablePriceSchema as C, CancelSubscriptionInputSchema as Cn, PriceDef as Cr, PlanSetWarningSchema as Ct, DoctorWarningSchema as D, GrantSchema as Dn, ActorRefSchema as Dr, EntitlementRulesGrant as Dt, DoctorWarningCode as E, GrantCreateInputSchema as En, API_VERSION as Er, EntitlementRulesCatalog as Et, WebhookEndpoint as F, PortalSession as Fn, EntitlementValueSchema as Fr, ErrorCode as Ft, WebhookLastDelivery as G, CheckoutPrefillSchema as Gn, IntervalSchema as Gr, CheckoutSessionResponse as Gt, WebhookEndpointSchema as H, CheckoutConsentInputSchema as Hn, ExternalRefSchema as Hr, AccountUpsertResponseSchema as Ht, WebhookEndpointCreateInput as I, PortalSessionCreateInput as In, Entitlements as Ir, ErrorCodeSpec as It, generateWebhookSecret as J, CheckoutSession as Jn, GrantCreateResponseSchema as Jt, WebhookLastDeliverySchema as K, CheckoutRedirectTarget as Kn, MetadataSchema as Kr, CheckoutSessionResponseSchema as Kt, WebhookEndpointCreateInputSchema as L, PortalSessionCreateInputSchema as Ln, EntitlementsSchema as Lr, errorCodeSpec as Lt, EventTypeSchema as M, Subscription as Mn, DateTimeSchema as Mr, isLiveSubscriptionStatus as Mt, WEBHOOK_ENDPOINT_STATUSES as N, SubscriptionSchema as Nn, ERROR_CATEGORIES as Nr, resolveEntitlements as Nt, buildDoctorReport as O, Payment as On, AmountMinorSchema as Or, LIVE_SUBSCRIPTION_STATUSES as Ot, WEBHOOK_SECRET_PREFIX as P, PORTAL_SESSION_ERRORS as Pn, EntitlementValue as Pr, ERROR_CODES as Pt, BrandingSchema as Q, CheckoutSessionCreated as Qn, HEADER_REQUEST_ID as Qt, WebhookEndpointList as R, PortalSessionError as Rn, ErrorCategory as Rr, isKnownErrorCode as Rt, DoctorUnsellablePrice as S, CancelSubscriptionInput as Sn, Price as Sr, PlanSetWarningCode as St, DoctorWarning as T, GrantCreateInput as Tn, PriceSchema as Tr, ResyncResultSchema as Tt, WebhookEndpointStatus as U, CheckoutError as Un, IdSchema as Ur, CancelSubscriptionResponse as Ut, WebhookEndpointRotateInputSchema as V, CheckoutConsentInput as Vn, ErrorResponseSchema as Vr, AccountUpsertResponse as Vt, WebhookEndpointStatusSchema as W, CheckoutPrefill as Wn, Interval as Wr, CancelSubscriptionResponseSchema as Wt, Branding as X, CheckoutSessionCreateInputSchema as Xn, HEADER_API_VERSION as Xt, webhookEndpointUrlProblem as Y, CheckoutSessionCreateInput as Yn, HEADER_ACTOR_REF as Yt, BrandingPatchSchema as Z, CheckoutSessionCreateParsed as Zn, HEADER_IDEMPOTENCY_KEY as Zt, DoctorReportSchema as _, ManualInvoiceInputSchema as _n, FeatureDef as _r, PlanSetMode as _t, DOCTOR_SEVERITIES as a, ManualInvoiceResponseSchema as an, MAX_CHECKOUT_CONSENT_DOCS as ar, ReturnOriginSchema as at, DoctorSeverity as b, manualInvoiceTotals as bn, PlanDef as br, PlanSetResponseSchema as bt, DoctorEndpoint as c, InvoiceIssueInputSchema as cn, checkoutRedirectUrl as cr, SettingsLocaleSchema as ct, DoctorFacts as d, InvoiceSchema as dn, Catalog as dr, applySettingsPatch as dt, InvoiceIssueResponse as en, CheckoutSessionSchema as er, DEFAULT_PORTAL_TTL_MINUTES as et, DoctorHosted as f, InvoiceStatusSchema as fn, CatalogSchema as fr, isReturnUrlAllowed as ft, DoctorReport as g, ManualInvoiceInput as gn, CatalogSyncResultSchema as gr, PlanSetInputSchema as gt, DoctorProviderSchema as h, MANUAL_INVOICE_MAX_AMOUNT_MINOR as hn, CatalogSyncResult as hr, PlanSetInput as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, ManualInvoiceResponse as in, ConsentSchema as ir, ProductSettingsSchema as it, DEFAULT_ENDPOINT_EVENT_TYPES as j, StatsSchema as jn, CurrencySchema as jr, isGrantActive as jt, endpointDiagnosisOf as k, PaymentSchema as kn, CodeSchema as kr, ResolveEntitlementsInput as kt, DoctorEndpointDiagnosis as l, InvoiceLine as ln, AccountsRefreshResult as lr, TtlMinutesSchema as lt, DoctorProvider as m, InvoiceVoidInputSchema as mn, CatalogSyncInputSchema as mr, PLAN_SET_MODES as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, InvoiceVoidResponse as nn, CheckoutStatusSchema as nr, ProductSettingsPatch as nt, DoctorCatalog as o, Invoice as on, ProviderPayload as or, SETTINGS_LOCALES as ot, DoctorHostedSchema as p, InvoiceVoidInput as pn, CatalogSyncInput as pr, returnOriginsOf as pt, WebhookSecretSchema as q, CheckoutReturnStatus as qn, GrantCreateResponse as qt, DOCTOR_REQUIRED_BRANDING as r, InvoiceVoidResponseSchema as rn, Consent as rr, ProductSettingsPatchSchema as rt, DoctorCatalogSchema as s, InvoiceIssueInput as sn, ProviderPayloadSchema as sr, SettingsLocale as st, DOCTOR_PENDING_BACKLOG_MS as t, InvoiceIssueResponseSchema as tn, CheckoutStatus as tr, ProductSettings as tt, DoctorEndpointSchema as u, InvoiceLineSchema as un, AccountsRefreshResultSchema as ur, WebUrlSchema as ut, DoctorSettings as v, ManualInvoiceLineInput as vn, FeatureDefSchema as vr, PlanSetModeSchema as vt, DoctorUnsellableReason as w, Grant as wn, PriceDefSchema as wr, ResyncResult as wt, DoctorSeveritySchema as x, splitInclusiveTax as xn, PlanDefSchema as xr, PlanSetWarning as xt, DoctorSettingsSchema as y, ManualInvoiceLineInputSchema as yn, FeatureTypeSchema as yr, PlanSetResponse as yt, WebhookEndpointListSchema as z, PortalSessionSchema as zn, ErrorCategorySchema as zr, AccountDetail as zt };
2731
+ export { Branding as $, CancelSubscriptionInputSchema as $n, PriceDef as $r, PlanSetWarningSchema as $t, buildDoctorReport as A, InvoiceIssueResponse as An, CheckoutSessionSchema as Ar, EmailTemplate as At, WebhookEndpointCreateInputSchema as B, InvoiceLineSchema as Bn, AccountsRefreshResultSchema as Br, emailTemplateOf as Bt, DoctorSeveritySchema as C, GrantCreateResponse as Cn, CheckoutReturnStatus as Cr, EmailLocale as Ct, DoctorWarning as D, HEADER_IDEMPOTENCY_KEY as Dn, CheckoutSessionCreateParsed as Dr, EmailSettingsPatch as Dt, DoctorUnsellableReason as E, HEADER_API_VERSION as En, CheckoutSessionCreateInputSchema as Er, EmailSettings as Et, EventTypeSchema as F, ManualInvoiceResponseSchema as Fn, MAX_CHECKOUT_CONSENT_DOCS as Fr, NotificationEmailsSchema as Ft, WebhookEndpointSchema as G, MANUAL_INVOICE_MAX_AMOUNT_MINOR as Gn, CatalogSyncResult as Gr, PlanSetInput as Gt, WebhookEndpointListSchema as H, InvoiceStatusSchema as Hn, CatalogSchema as Hr, isEmailRelevant as Ht, WEBHOOK_ENDPOINT_STATUSES as I, Invoice as In, ProviderPayload as Ir, applyEmailSettingsPatch as It, WebhookLastDelivery as J, ManualInvoiceLineInput as Jn, FeatureDefSchema as Jr, PlanSetModeSchema as Jt, WebhookEndpointStatus as K, ManualInvoiceInput as Kn, CatalogSyncResultSchema as Kr, PlanSetInputSchema as Kt, WEBHOOK_SECRET_PREFIX as L, InvoiceIssueInput as Ln, ProviderPayloadSchema as Lr, billingPageUrl as Lt, endpointDiagnosisOf as M, InvoiceVoidResponse as Mn, CheckoutStatusSchema as Mr, EmailTemplateSettings as Mt, hostedReadinessOf as N, InvoiceVoidResponseSchema as Nn, Consent as Nr, EmailTemplateSettingsSchema as Nt, DoctorWarningCode as O, HEADER_REQUEST_ID as On, CheckoutSessionCreated as Or, EmailSettingsPatchSchema as Ot, DEFAULT_ENDPOINT_EVENT_TYPES as P, ManualInvoiceResponse as Pn, ConsentSchema as Pr, MAX_NOTIFICATION_EMAILS as Pt, webhookEndpointUrlProblem as Q, CancelSubscriptionInput as Qn, Price as Qr, PlanSetWarningCode as Qt, WebhookEndpoint as R, InvoiceIssueInputSchema as Rn, checkoutRedirectUrl as Rr, emailLocaleOf as Rt, DoctorSeverity as S, MetadataSchema as Si, CheckoutSessionResponseSchema as Sn, CheckoutRedirectTarget as Sr, EmailExtraTextSchema as St, DoctorUnsellablePriceSchema as T, HEADER_ACTOR_REF as Tn, CheckoutSessionCreateInput as Tr, EmailSenderSchema as Tt, WebhookEndpointRotateInput as U, InvoiceVoidInput as Un, CatalogSyncInput as Ur, uniqueEmails as Ut, WebhookEndpointList as V, InvoiceSchema as Vn, Catalog as Vr, emailTemplateSettings as Vt, WebhookEndpointRotateInputSchema as W, InvoiceVoidInputSchema as Wn, CatalogSyncInputSchema as Wr, PLAN_SET_MODES as Wt, WebhookSecretSchema as X, manualInvoiceTotals as Xn, PlanDef as Xr, PlanSetResponseSchema as Xt, WebhookLastDeliverySchema as Y, ManualInvoiceLineInputSchema as Yn, FeatureTypeSchema as Yr, PlanSetResponse as Yt, generateWebhookSecret as Z, splitInclusiveTax as Zn, PlanDefSchema as Zr, PlanSetWarning as Zt, DoctorProviderSchema as _, ErrorResponseSchema as _i, AccountUpsertResponse as _n, CheckoutConsentInput as _r, BILLING_PATH_PLACEHOLDERS as _t, DOCTOR_SEVERITIES as a, CodeSchema as ai, ResolveEntitlementsInput as an, PaymentSchema as ar, ProductSettingsPatch as at, DoctorSettings as b, Interval as bi, CancelSubscriptionResponseSchema as bn, CheckoutPrefill as br, EMAIL_TEMPLATES as bt, DoctorEmails as c, DateTimeSchema as ci, isLiveSubscriptionStatus as cn, Subscription as cr, ReturnOriginSchema as ct, DoctorEndpointDiagnosis as d, EntitlementValueSchema as di, ErrorCode as dn, PortalSession as dr, SettingsLocaleSchema as dt, PriceDefSchema as ei, ResyncResult as en, Grant as er, BrandingPatchSchema as et, DoctorEndpointSchema as f, Entitlements as fi, ErrorCodeSpec as fn, PortalSessionCreateInput as fr, TtlMinutesSchema as ft, DoctorProvider as g, ErrorResponse as gi, AccountDetailSchema as gn, CHECKOUT_ERRORS as gr, returnOriginsOf as gt, DoctorHostedSchema as h, ErrorCategorySchema as hi, AccountDetail as hn, PortalSessionSchema as hr, isReturnUrlAllowed as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, AmountMinorSchema as ii, LIVE_SUBSCRIPTION_STATUSES as in, Payment as ir, ProductSettings as it, emailReadinessOf as j, InvoiceIssueResponseSchema as jn, CheckoutStatus as jr, EmailTemplateSchema as jt, DoctorWarningSchema as k, HEADER_SDK as kn, CheckoutSessionCreatedSchema as kr, EmailSettingsSchema as kt, DoctorEmailsSchema as l, ERROR_CATEGORIES as li, resolveEntitlements as ln, SubscriptionSchema as lr, SETTINGS_LOCALES as lt, DoctorHosted as m, ErrorCategory as mi, isKnownErrorCode as mn, PortalSessionError as mr, applySettingsPatch as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, API_VERSION as ni, EntitlementRulesCatalog as nn, GrantCreateInputSchema as nr, DEFAULT_CHECKOUT_TTL_MINUTES as nt, DoctorCatalog as o, Currency as oi, ResolvedEntitlements as on, Stats as or, ProductSettingsPatchSchema as ot, DoctorFacts as p, EntitlementsSchema as pi, errorCodeSpec as pn, PortalSessionCreateInputSchema as pr, WebUrlSchema as pt, WebhookEndpointStatusSchema as q, ManualInvoiceInputSchema as qn, FeatureDef as qr, PlanSetMode as qt, DOCTOR_REQUIRED_BRANDING as r, ActorRefSchema as ri, EntitlementRulesGrant as rn, GrantSchema as rr, DEFAULT_PORTAL_TTL_MINUTES as rt, DoctorCatalogSchema as s, CurrencySchema as si, isGrantActive as sn, StatsSchema as sr, ProductSettingsSchema as st, DOCTOR_PENDING_BACKLOG_MS as t, PriceSchema as ti, ResyncResultSchema as tn, GrantCreateInput as tr, BrandingSchema as tt, DoctorEndpoint as u, EntitlementValue as ui, ERROR_CODES as un, PORTAL_SESSION_ERRORS as ur, SettingsLocale as ut, DoctorReport as v, ExternalRefSchema as vi, AccountUpsertResponseSchema as vn, CheckoutConsentInputSchema as vr, BillingPathSchema as vt, DoctorUnsellablePrice as w, GrantCreateResponseSchema as wn, CheckoutSession as wr, EmailRelevanceFacts as wt, DoctorSettingsSchema as x, IntervalSchema as xi, CheckoutSessionResponse as xn, CheckoutPrefillSchema as xr, EMAIL_TEMPLATE_BY_EVENT as xt, DoctorReportSchema as y, IdSchema as yi, CancelSubscriptionResponse as yn, CheckoutError as yr, EMAIL_LOCALES as yt, WebhookEndpointCreateInput as z, InvoiceLine as zn, AccountsRefreshResult as zr, emailRecipients as zt };
@@ -1,4 +1,4 @@
1
- import { A as CodeSchema, B as IntervalSchema, C as BillingProfileSchema, F as EntitlementsSchema, M as DateTimeSchema, O as ActorRefSchema, R as ExternalRefSchema, S as BillingProfileKindSchema, T as SubscriptionStatusSchema, a as EVENT_TYPES, j as CurrencySchema, k as AmountMinorSchema, o as EventIdSchema, v as AccountSchema, y as AccountStateSchema, z as IdSchema } from "./events.js";
1
+ import { $ as CurrencySchema, C as BillingProfileKindSchema, E as SubscriptionStatusSchema, F as EmailSettingsPatchSchema, I as EmailSettingsSchema, Q as CodeSchema, V as applyEmailSettingsPatch, X as ActorRefSchema, Z as AmountMinorSchema, a as EVENT_TYPES, b as AccountStateSchema, ct as IntervalSchema, et as DateTimeSchema, j as EMAIL_TEMPLATES, o as EventIdSchema, ot as ExternalRefSchema, rt as EntitlementsSchema, st as IdSchema, w as BillingProfileSchema, y as AccountSchema } from "./events.js";
2
2
  import { z } from "zod";
3
3
  //#region ../contract/src/catalog.ts
4
4
  const FeatureTypeSchema = z.enum([
@@ -175,7 +175,9 @@ const ProductSettingsSchema = z.object({
175
175
  branding: BrandingSchema.default({}),
176
176
  /** Açık checkout oturumunun ömrü (sağlayıcının form ömrü daha kısaysa o geçerli). */
177
177
  checkoutTtlMinutes: TtlMinutesSchema.default(30),
178
- portalTtlMinutes: TtlMinutesSchema.default(30)
178
+ portalTtlMinutes: TtlMinutesSchema.default(30),
179
+ /** Billing emails sent by steward (`emails.ts`). */
180
+ emails: EmailSettingsSchema.default({ templates: {} })
179
181
  });
180
182
  const BrandingPatchSchema = z.object({
181
183
  name: BrandingNameSchema.nullable().optional(),
@@ -193,7 +195,8 @@ const ProductSettingsPatchSchema = z.object({
193
195
  termsUrl: WebUrlSchema.nullable().optional(),
194
196
  branding: BrandingPatchSchema.nullable().optional(),
195
197
  checkoutTtlMinutes: TtlMinutesSchema.optional(),
196
- portalTtlMinutes: TtlMinutesSchema.optional()
198
+ portalTtlMinutes: TtlMinutesSchema.optional(),
199
+ emails: EmailSettingsPatchSchema.nullable().optional()
197
200
  }).strict();
198
201
  /**
199
202
  * Doğrulanmış yamayı ayarlara uygular (saf). Sonuç şemadan geçer; alan kuralları
@@ -210,7 +213,8 @@ function applySettingsPatch(current, patch) {
210
213
  else if (fieldValue !== void 0) branding[field] = fieldValue;
211
214
  }
212
215
  next.branding = branding;
213
- } else if (value === null) delete next[key];
216
+ } else if (key === "emails") next.emails = applyEmailSettingsPatch(current.emails, value);
217
+ else if (value === null) delete next[key];
214
218
  else next[key] = value;
215
219
  }
216
220
  return ProductSettingsSchema.parse(next);
@@ -967,6 +971,17 @@ const DoctorEndpointSchema = z.object({
967
971
  lastDelivery: WebhookLastDeliverySchema.nullable(),
968
972
  diagnosis: z.string()
969
973
  });
974
+ /** Billing emails (issue #15). */
975
+ const DoctorEmailsSchema = z.object({
976
+ /** The deployment has a mail transport (`STEWARD_SMTP_URL`). */
977
+ transportConfigured: z.boolean(),
978
+ /** A sender address is known (`settings.emails.from.address` or the deployment default). */
979
+ senderConfigured: z.boolean(),
980
+ /** Templates the product turned off. */
981
+ disabledTemplates: z.array(z.string()),
982
+ /** Emails are sent: transport and sender configured, at least one template on. */
983
+ ready: z.boolean()
984
+ });
970
985
  const DoctorReportSchema = z.object({
971
986
  /** `error` önemde uyarı yok. */
972
987
  ok: z.boolean(),
@@ -984,8 +999,22 @@ const DoctorReportSchema = z.object({
984
999
  dunning: z.object({
985
1000
  /** true: dunning adımları yalnızca iz yazar (askı/sonlandırma yok). */
986
1001
  dryRun: z.boolean() }),
1002
+ /** Absent in reports of steward versions without billing emails. */
1003
+ emails: DoctorEmailsSchema.optional(),
987
1004
  warnings: z.array(DoctorWarningSchema)
988
1005
  });
1006
+ /** Email readiness from settings and the deployment's transport (pure). */
1007
+ function emailReadinessOf(settings, transport) {
1008
+ const templates = settings.emails?.templates ?? {};
1009
+ const disabledTemplates = EMAIL_TEMPLATES.filter((t) => templates[t]?.enabled === false);
1010
+ const senderConfigured = settings.emails?.from?.address !== void 0 || transport.defaultFromConfigured;
1011
+ return {
1012
+ transportConfigured: transport.configured,
1013
+ senderConfigured,
1014
+ disabledTemplates: [...disabledTemplates],
1015
+ ready: transport.configured && senderConfigured && disabledTemplates.length < EMAIL_TEMPLATES.length
1016
+ };
1017
+ }
989
1018
  /** Bekleyen en eski teslimat bundan eskiyse `endpoint_pending_backlog` (K23 alarmıyla aynı eşik). */
990
1019
  const DOCTOR_PENDING_BACKLOG_MS = 36e5;
991
1020
  /** Son denenmiş teslimattan endpoint teşhisi (saf). */
@@ -1073,6 +1102,12 @@ function buildDoctorReport(facts) {
1073
1102
  if (endpoint.dead > 0) warn("warning", "endpoint_dead_deliveries", `${endpoint.dead} teslimattan vazgeçildi (dead): etkilenen hesaplar için resync`, endpoint.id);
1074
1103
  if (endpoint.oldestPendingAt !== null && facts.checkedAt.getTime() - Date.parse(endpoint.oldestPendingAt) > 36e5) warn("warning", "endpoint_pending_backlog", `${endpoint.pending} teslimat bekliyor; en eskisi bir saatten eski`, endpoint.id);
1075
1104
  }
1105
+ const emails = facts.emailTransport ? emailReadinessOf(settings, facts.emailTransport) : void 0;
1106
+ if (emails && emails.disabledTemplates.length < EMAIL_TEMPLATES.length) {
1107
+ if (!emails.transportConfigured) warn("warning", "email_not_configured", "email is not configured: steward sends no billing emails (STEWARD_SMTP_URL)");
1108
+ else if (!emails.senderConfigured) warn("warning", "email_sender_missing", "no email sender: set `settings.emails.from.address` or STEWARD_EMAIL_FROM");
1109
+ if (settings.emails?.billingPath === void 0) warn("info", "email_billing_link_missing", "`settings.emails.billingPath` is not set: email buttons open `appUrl`");
1110
+ }
1076
1111
  if (dunning.dryRun) warn("info", "dunning_dry_run", "dunning dry-run: adımlar yalnızca iz yazar, askı ve sonlandırma uygulanmaz");
1077
1112
  return {
1078
1113
  ok: !warnings.some((w) => w.severity === "error"),
@@ -1087,8 +1122,9 @@ function buildDoctorReport(facts) {
1087
1122
  hosted,
1088
1123
  endpoints,
1089
1124
  dunning,
1125
+ ...emails ? { emails } : {},
1090
1126
  warnings
1091
1127
  };
1092
1128
  }
1093
1129
  //#endregion
1094
- export { InvoiceIssueInputSchema as $, webhookEndpointUrlProblem as A, BrandingSchema as At, AccountDetailSchema as B, applySettingsPatch as Bt, WebhookEndpointListSchema as C, CheckoutSessionSchema as Ct, WebhookLastDeliverySchema as D, ProviderPayloadSchema as Dt, WebhookEndpointStatusSchema as E, MAX_CHECKOUT_CONSENT_DOCS as Et, PlanSetWarningSchema as F, ReturnOriginSchema as Ft, HEADER_ACTOR_REF as G, CatalogSyncInputSchema as Gt, CancelSubscriptionResponseSchema as H, returnOriginsOf as Ht, ResyncResultSchema as I, SETTINGS_LOCALES as It, HEADER_REQUEST_ID as J, FeatureTypeSchema as Jt, HEADER_API_VERSION as K, CatalogSyncResultSchema as Kt, ERROR_CODES as L, SettingsLocaleSchema as Lt, PlanSetInputSchema as M, DEFAULT_PORTAL_TTL_MINUTES as Mt, PlanSetModeSchema as N, ProductSettingsPatchSchema as Nt, WebhookSecretSchema as O, checkoutRedirectUrl as Ot, PlanSetResponseSchema as P, ProductSettingsSchema as Pt, ManualInvoiceResponseSchema as Q, errorCodeSpec as R, TtlMinutesSchema as Rt, WebhookEndpointCreateInputSchema as S, CheckoutSessionCreatedSchema as St, WebhookEndpointSchema as T, ConsentSchema as Tt, CheckoutSessionResponseSchema as U, AccountsRefreshResultSchema as Ut, AccountUpsertResponseSchema as V, isReturnUrlAllowed as Vt, GrantCreateResponseSchema as W, CatalogSchema as Wt, InvoiceIssueResponseSchema as X, PriceDefSchema as Xt, HEADER_SDK as Y, PlanDefSchema as Yt, InvoiceVoidResponseSchema as Z, PriceSchema as Zt, hostedReadinessOf as _, PortalSessionSchema as _t, DOCTOR_SEVERITIES as a, ManualInvoiceInputSchema as at, WEBHOOK_ENDPOINT_STATUSES as b, CheckoutPrefillSchema as bt, DoctorHostedSchema as c, splitInclusiveTax as ct, DoctorSettingsSchema as d, GrantSchema as dt, InvoiceLineSchema as et, DoctorSeveritySchema as f, PaymentSchema as ft, endpointDiagnosisOf as g, PortalSessionCreateInputSchema as gt, buildDoctorReport as h, PORTAL_SESSION_ERRORS as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, MANUAL_INVOICE_MAX_AMOUNT_MINOR as it, PLAN_SET_MODES as j, DEFAULT_CHECKOUT_TTL_MINUTES as jt, generateWebhookSecret as k, BrandingPatchSchema as kt, DoctorProviderSchema as l, CancelSubscriptionInputSchema as lt, DoctorWarningSchema as m, SubscriptionSchema as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, InvoiceStatusSchema as nt, DoctorCatalogSchema as o, ManualInvoiceLineInputSchema as ot, DoctorUnsellablePriceSchema as p, StatsSchema as pt, HEADER_IDEMPOTENCY_KEY as q, FeatureDefSchema as qt, DOCTOR_REQUIRED_BRANDING as r, InvoiceVoidInputSchema as rt, DoctorEndpointSchema as s, manualInvoiceTotals as st, DOCTOR_PENDING_BACKLOG_MS as t, InvoiceSchema as tt, DoctorReportSchema as u, GrantCreateInputSchema as ut, DEFAULT_ENDPOINT_EVENT_TYPES as v, CHECKOUT_ERRORS as vt, WebhookEndpointRotateInputSchema as w, CheckoutStatusSchema as wt, WEBHOOK_SECRET_PREFIX as x, CheckoutSessionCreateInputSchema as xt, EventTypeSchema as y, CheckoutConsentInputSchema as yt, isKnownErrorCode as z, WebUrlSchema as zt };
1130
+ export { InvoiceVoidResponseSchema as $, PriceSchema as $t, WebhookSecretSchema as A, checkoutRedirectUrl as At, errorCodeSpec as B, TtlMinutesSchema as Bt, WEBHOOK_SECRET_PREFIX as C, CheckoutSessionCreateInputSchema as Ct, WebhookEndpointSchema as D, ConsentSchema as Dt, WebhookEndpointRotateInputSchema as E, CheckoutStatusSchema as Et, PlanSetModeSchema as F, ProductSettingsPatchSchema as Ft, CheckoutSessionResponseSchema as G, AccountsRefreshResultSchema as Gt, AccountDetailSchema as H, applySettingsPatch as Ht, PlanSetResponseSchema as I, ProductSettingsSchema as It, HEADER_API_VERSION as J, CatalogSyncResultSchema as Jt, GrantCreateResponseSchema as K, CatalogSchema as Kt, PlanSetWarningSchema as L, ReturnOriginSchema as Lt, webhookEndpointUrlProblem as M, BrandingSchema as Mt, PLAN_SET_MODES as N, DEFAULT_CHECKOUT_TTL_MINUTES as Nt, WebhookEndpointStatusSchema as O, MAX_CHECKOUT_CONSENT_DOCS as Ot, PlanSetInputSchema as P, DEFAULT_PORTAL_TTL_MINUTES as Pt, InvoiceIssueResponseSchema as Q, PriceDefSchema as Qt, ResyncResultSchema as R, SETTINGS_LOCALES as Rt, WEBHOOK_ENDPOINT_STATUSES as S, CheckoutPrefillSchema as St, WebhookEndpointListSchema as T, CheckoutSessionSchema as Tt, AccountUpsertResponseSchema as U, isReturnUrlAllowed as Ut, isKnownErrorCode as V, WebUrlSchema as Vt, CancelSubscriptionResponseSchema as W, returnOriginsOf as Wt, HEADER_REQUEST_ID as X, FeatureTypeSchema as Xt, HEADER_IDEMPOTENCY_KEY as Y, FeatureDefSchema as Yt, HEADER_SDK as Z, PlanDefSchema as Zt, emailReadinessOf as _, PORTAL_SESSION_ERRORS as _t, DOCTOR_SEVERITIES as a, InvoiceVoidInputSchema as at, DEFAULT_ENDPOINT_EVENT_TYPES as b, CHECKOUT_ERRORS as bt, DoctorEndpointSchema as c, ManualInvoiceLineInputSchema as ct, DoctorReportSchema as d, CancelSubscriptionInputSchema as dt, ManualInvoiceResponseSchema as et, DoctorSettingsSchema as f, GrantCreateInputSchema as ft, buildDoctorReport as g, SubscriptionSchema as gt, DoctorWarningSchema as h, StatsSchema as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, InvoiceStatusSchema as it, generateWebhookSecret as j, BrandingPatchSchema as jt, WebhookLastDeliverySchema as k, ProviderPayloadSchema as kt, DoctorHostedSchema as l, manualInvoiceTotals as lt, DoctorUnsellablePriceSchema as m, PaymentSchema as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, InvoiceLineSchema as nt, DoctorCatalogSchema as o, MANUAL_INVOICE_MAX_AMOUNT_MINOR as ot, DoctorSeveritySchema as p, GrantSchema as pt, HEADER_ACTOR_REF as q, CatalogSyncInputSchema as qt, DOCTOR_REQUIRED_BRANDING as r, InvoiceSchema as rt, DoctorEmailsSchema as s, ManualInvoiceInputSchema as st, DOCTOR_PENDING_BACKLOG_MS as t, InvoiceIssueInputSchema as tt, DoctorProviderSchema as u, splitInclusiveTax as ut, endpointDiagnosisOf as v, PortalSessionCreateInputSchema as vt, WebhookEndpointCreateInputSchema as w, CheckoutSessionCreatedSchema as wt, EventTypeSchema as x, CheckoutConsentInputSchema as xt, hostedReadinessOf as y, PortalSessionSchema as yt, ERROR_CODES as z, SettingsLocaleSchema as zt };
@@ -1,5 +1,5 @@
1
- import { An as Stats, B as WebhookEndpointRotateInput, F as WebhookEndpoint, Fn as PortalSession, Gt as CheckoutSessionResponse, I as WebhookEndpointCreateInput, In as PortalSessionCreateInput, Qn as CheckoutSessionCreated, R as WebhookEndpointList, Sn as CancelSubscriptionInput, Tn as GrantCreateInput, Ut as CancelSubscriptionResponse, Vt as AccountUpsertResponse, Yn as CheckoutSessionCreateInput, dr as Catalog, en as InvoiceIssueResponse, g as DoctorReport, gn as ManualInvoiceInput, hr as CatalogSyncResult, ht as PlanSetInput, in as ManualInvoiceResponse, lr as AccountsRefreshResult, nn as InvoiceVoidResponse, nt as ProductSettingsPatch, pn as InvoiceVoidInput, pr as CatalogSyncInput, qt as GrantCreateResponse, sn as InvoiceIssueInput, tt as ProductSettings, wt as ResyncResult, yt as PlanSetResponse, zt as AccountDetail } from "./index.js";
2
- import { C as AccountDeleteResponse, D as AccountInclude, F as AccountState, z as AccountUpsertInput } from "./events.js";
1
+ import { An as InvoiceIssueResponse, Cn as GrantCreateResponse, Gr as CatalogSyncResult, Gt as PlanSetInput, Kn as ManualInvoiceInput, Ln as InvoiceIssueInput, Mn as InvoiceVoidResponse, Or as CheckoutSessionCreated, Pn as ManualInvoiceResponse, Qn as CancelSubscriptionInput, R as WebhookEndpoint, Tr as CheckoutSessionCreateInput, U as WebhookEndpointRotateInput, Un as InvoiceVoidInput, Ur as CatalogSyncInput, V as WebhookEndpointList, Vr as Catalog, Yt as PlanSetResponse, _n as AccountUpsertResponse, at as ProductSettingsPatch, dr as PortalSession, en as ResyncResult, fr as PortalSessionCreateInput, hn as AccountDetail, it as ProductSettings, or as Stats, tr as GrantCreateInput, v as DoctorReport, xn as CheckoutSessionResponse, yn as CancelSubscriptionResponse, z as WebhookEndpointCreateInput, zr as AccountsRefreshResult } from "./index.js";
2
+ import { B as AccountUpsertInput, C as AccountDeleteResponse, D as AccountInclude, I as AccountState } from "./events.js";
3
3
  //#region ../contract/src/client.d.ts
4
4
  type CallOptions = {
5
5
  idempotencyKey?: string;
@@ -72,7 +72,7 @@ type InvoiceDocument = {
72
72
  type StewardMe = {
73
73
  product: string;
74
74
  keyName: string;
75
- scope: "product" | "admin";
75
+ scope: "product" | "admin" | "checkout";
76
76
  };
77
77
  type Steward = {
78
78
  accounts: {
@@ -1,5 +1,5 @@
1
- import { D as API_VERSION, L as ErrorResponseSchema, O as ActorRefSchema, p as AccountDeleteResponseSchema, y as AccountStateSchema } from "./events.js";
2
- import { B as AccountDetailSchema, C as WebhookEndpointListSchema, G as HEADER_ACTOR_REF, H as CancelSubscriptionResponseSchema, I as ResyncResultSchema, J as HEADER_REQUEST_ID, K as HEADER_API_VERSION, Kt as CatalogSyncResultSchema, P as PlanSetResponseSchema, Pt as ProductSettingsSchema, Q as ManualInvoiceResponseSchema, R as errorCodeSpec, St as CheckoutSessionCreatedSchema, T as WebhookEndpointSchema, U as CheckoutSessionResponseSchema, Ut as AccountsRefreshResultSchema, V as AccountUpsertResponseSchema, W as GrantCreateResponseSchema, Wt as CatalogSchema, X as InvoiceIssueResponseSchema, Y as HEADER_SDK, Z as InvoiceVoidResponseSchema, _t as PortalSessionSchema, pt as StatsSchema, q as HEADER_IDEMPOTENCY_KEY, u as DoctorReportSchema } from "./src.js";
1
+ import { X as ActorRefSchema, Y as API_VERSION, at as ErrorResponseSchema, b as AccountStateSchema, p as AccountDeleteResponseSchema } from "./events.js";
2
+ import { $ as InvoiceVoidResponseSchema, B as errorCodeSpec, D as WebhookEndpointSchema, G as CheckoutSessionResponseSchema, Gt as AccountsRefreshResultSchema, H as AccountDetailSchema, I as PlanSetResponseSchema, It as ProductSettingsSchema, J as HEADER_API_VERSION, Jt as CatalogSyncResultSchema, K as GrantCreateResponseSchema, Kt as CatalogSchema, Q as InvoiceIssueResponseSchema, R as ResyncResultSchema, T as WebhookEndpointListSchema, U as AccountUpsertResponseSchema, W as CancelSubscriptionResponseSchema, X as HEADER_REQUEST_ID, Y as HEADER_IDEMPOTENCY_KEY, Z as HEADER_SDK, d as DoctorReportSchema, et as ManualInvoiceResponseSchema, ht as StatsSchema, q as HEADER_ACTOR_REF, wt as CheckoutSessionCreatedSchema, yt as PortalSessionSchema } from "./src.js";
3
3
  import { a as StewardNetworkError, n as StewardConfigError, r as StewardContractError, t as StewardApiError } from "./errors.js";
4
4
  import { z } from "zod";
5
5
  //#region ../contract/src/client.ts
@@ -245,11 +245,15 @@ async function withRetries(request, policy, send) {
245
245
  }
246
246
  //#endregion
247
247
  //#region src/steward.ts
248
- const SDK_HEADER = `@stewardhq/sdk/0.2.0`;
248
+ const SDK_HEADER = `@stewardhq/sdk/0.3.0`;
249
249
  const MeSchema = z.object({
250
250
  product: z.string(),
251
251
  keyName: z.string(),
252
- scope: z.enum(["product", "admin"])
252
+ scope: z.enum([
253
+ "product",
254
+ "admin",
255
+ "checkout"
256
+ ])
253
257
  });
254
258
  const defaultEnv = () => globalThis.process?.env ?? {};
255
259
  function isHttpUrl(value) {