@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.
- package/README.md +437 -0
- package/dist/_chunks/errors.js +73 -0
- package/dist/_chunks/events.d.ts +537 -0
- package/dist/_chunks/events.js +350 -0
- package/dist/_chunks/index.d.ts +6005 -0
- package/dist/_chunks/locale.d.ts +17 -0
- package/dist/_chunks/locale.js +17 -0
- package/dist/_chunks/src.js +1202 -0
- package/dist/_chunks/steward.d.ts +2588 -0
- package/dist/_chunks/steward.js +578 -0
- package/dist/_chunks/validators.d.ts +23 -0
- package/dist/_chunks/validators.js +106 -0
- package/dist/_chunks/webhook-core.d.ts +32 -0
- package/dist/_chunks/webhook-core.js +64 -0
- package/dist/_chunks/webhook.d.ts +22 -0
- package/dist/_chunks/webhook.js +53 -0
- package/dist/contract.d.ts +4 -0
- package/dist/contract.js +4 -0
- package/dist/index.d.ts +268 -0
- package/dist/index.js +784 -0
- package/dist/server.d.ts +236 -0
- package/dist/server.js +384 -0
- package/dist/testing/fixtures/events/LOCK.json +27 -0
- package/dist/testing/fixtures/events/account.deleted.json +36 -0
- package/dist/testing/fixtures/events/account.state_changed.json +53 -0
- package/dist/testing/fixtures/events/account.updated.json +37 -0
- package/dist/testing/fixtures/events/checkout.completed.json +36 -0
- package/dist/testing/fixtures/events/checkout.expired.json +26 -0
- package/dist/testing/fixtures/events/checkout.failed.json +27 -0
- package/dist/testing/fixtures/events/invoice.created.json +37 -0
- package/dist/testing/fixtures/events/invoice.issued.json +38 -0
- package/dist/testing/fixtures/events/invoice.voided.json +39 -0
- package/dist/testing/fixtures/events/subscription.activated.json +40 -0
- package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +38 -0
- package/dist/testing/fixtures/events/subscription.canceled.json +29 -0
- package/dist/testing/fixtures/events/subscription.expired.json +27 -0
- package/dist/testing/fixtures/events/subscription.payment_failed.json +38 -0
- package/dist/testing/fixtures/events/subscription.reactivated.json +36 -0
- package/dist/testing/fixtures/events/subscription.renewed.json +39 -0
- package/dist/testing/fixtures/events/subscription.suspended.json +36 -0
- package/dist/testing/fixtures/events/subscription.terminated.json +28 -0
- package/dist/testing.d.ts +629 -0
- package/dist/testing.js +3759 -0
- package/dist/webhook/web.d.ts +17 -0
- package/dist/webhook/web.js +66 -0
- package/dist/webhook.d.ts +3 -0
- package/dist/webhook.js +3 -0
- 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 };
|