@stewardhq/sdk 0.1.0-rc.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.
Files changed (48) hide show
  1. package/README.md +437 -0
  2. package/dist/_chunks/errors.js +73 -0
  3. package/dist/_chunks/events.d.ts +537 -0
  4. package/dist/_chunks/events.js +350 -0
  5. package/dist/_chunks/index.d.ts +6005 -0
  6. package/dist/_chunks/locale.d.ts +17 -0
  7. package/dist/_chunks/locale.js +17 -0
  8. package/dist/_chunks/src.js +1202 -0
  9. package/dist/_chunks/steward.d.ts +2588 -0
  10. package/dist/_chunks/steward.js +578 -0
  11. package/dist/_chunks/validators.d.ts +23 -0
  12. package/dist/_chunks/validators.js +106 -0
  13. package/dist/_chunks/webhook-core.d.ts +32 -0
  14. package/dist/_chunks/webhook-core.js +64 -0
  15. package/dist/_chunks/webhook.d.ts +22 -0
  16. package/dist/_chunks/webhook.js +53 -0
  17. package/dist/contract.d.ts +4 -0
  18. package/dist/contract.js +4 -0
  19. package/dist/index.d.ts +268 -0
  20. package/dist/index.js +784 -0
  21. package/dist/server.d.ts +236 -0
  22. package/dist/server.js +384 -0
  23. package/dist/testing/fixtures/events/LOCK.json +27 -0
  24. package/dist/testing/fixtures/events/account.deleted.json +36 -0
  25. package/dist/testing/fixtures/events/account.state_changed.json +53 -0
  26. package/dist/testing/fixtures/events/account.updated.json +37 -0
  27. package/dist/testing/fixtures/events/checkout.completed.json +36 -0
  28. package/dist/testing/fixtures/events/checkout.expired.json +26 -0
  29. package/dist/testing/fixtures/events/checkout.failed.json +27 -0
  30. package/dist/testing/fixtures/events/invoice.created.json +37 -0
  31. package/dist/testing/fixtures/events/invoice.issued.json +38 -0
  32. package/dist/testing/fixtures/events/invoice.voided.json +39 -0
  33. package/dist/testing/fixtures/events/subscription.activated.json +40 -0
  34. package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +38 -0
  35. package/dist/testing/fixtures/events/subscription.canceled.json +29 -0
  36. package/dist/testing/fixtures/events/subscription.expired.json +27 -0
  37. package/dist/testing/fixtures/events/subscription.payment_failed.json +38 -0
  38. package/dist/testing/fixtures/events/subscription.reactivated.json +36 -0
  39. package/dist/testing/fixtures/events/subscription.renewed.json +39 -0
  40. package/dist/testing/fixtures/events/subscription.suspended.json +36 -0
  41. package/dist/testing/fixtures/events/subscription.terminated.json +28 -0
  42. package/dist/testing.d.ts +629 -0
  43. package/dist/testing.js +3759 -0
  44. package/dist/webhook/web.d.ts +17 -0
  45. package/dist/webhook/web.js +66 -0
  46. package/dist/webhook.d.ts +3 -0
  47. package/dist/webhook.js +3 -0
  48. package/package.json +70 -0
@@ -0,0 +1,17 @@
1
+ //#region src/http-status.d.ts
2
+ type StewardLogger = {
3
+ warn(message: string, context: Record<string, unknown>): void;
4
+ error(message: string, context: Record<string, unknown>): void;
5
+ };
6
+ type HttpStatusResult = {
7
+ status: 404 | 409 | 422 | 500 | 502 | 503;
8
+ headers: Record<string, string>;
9
+ };
10
+ declare function httpStatusFor(err: unknown, options?: {
11
+ logger?: StewardLogger;
12
+ }): HttpStatusResult;
13
+ //#endregion
14
+ //#region src/locale.d.ts
15
+ type StewardLocale = "tr" | "en";
16
+ //#endregion
17
+ export { httpStatusFor as i, HttpStatusResult as n, StewardLogger as r, StewardLocale as t };
@@ -0,0 +1,17 @@
1
+ //#region src/locale.ts
2
+ /** `tr`, `tr-TR` → tr; diğer her dil → en. */
3
+ function localeOf(locale) {
4
+ return locale.toLowerCase().startsWith("tr") ? "tr" : "en";
5
+ }
6
+ /**
7
+ * Hosted sayfa dili (`Checkout`, `CustomerPortal`): BCP-47 benzeri etiketin birincil alt etiketi
8
+ * (`tr`, `tr-TR`, `EN_us` → tr/en). Desteklenmeyen dil ya da boş değer → `undefined`: çağıran
9
+ * dili göndermez, steward ürün ayarı `defaultLocale`'i kullanır (ürünün dil algısı sayfayı bozmasın).
10
+ */
11
+ function hostedLocaleOf(locale) {
12
+ if (typeof locale !== "string") return void 0;
13
+ const primary = locale.trim().toLowerCase().split(/[-_]/)[0];
14
+ return primary === "tr" || primary === "en" ? primary : void 0;
15
+ }
16
+ //#endregion
17
+ export { localeOf as n, hostedLocaleOf as t };