@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,106 @@
|
|
|
1
|
+
//#region ../contract/src/rules.ts
|
|
2
|
+
/** Hesap başına en fazla bir abonelik bu durumlardan birindedir. */
|
|
3
|
+
const LIVE_SUBSCRIPTION_STATUSES = [
|
|
4
|
+
"active",
|
|
5
|
+
"past_due",
|
|
6
|
+
"suspended"
|
|
7
|
+
];
|
|
8
|
+
function isLiveSubscriptionStatus(status) {
|
|
9
|
+
return LIVE_SUBSCRIPTION_STATUSES.includes(status);
|
|
10
|
+
}
|
|
11
|
+
const toMs = (value) => value instanceof Date ? value.getTime() : Date.parse(value);
|
|
12
|
+
/** İptal edilmemiş ve (`at` verildiyse) penceresi içinde olan grant. */
|
|
13
|
+
function isGrantActive(grant, at) {
|
|
14
|
+
if (grant.revokedAt !== void 0 && grant.revokedAt !== null) return false;
|
|
15
|
+
if (at === void 0) return true;
|
|
16
|
+
const now = toMs(at);
|
|
17
|
+
if (grant.startsAt !== void 0 && toMs(grant.startsAt) > now) return false;
|
|
18
|
+
if (grant.endsAt !== void 0 && grant.endsAt !== null && toMs(grant.endsAt) <= now) return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
function creationOrder(grants) {
|
|
22
|
+
if (!grants.every((g) => g.createdAt !== void 0)) return grants;
|
|
23
|
+
return [...grants].sort((a, b) => {
|
|
24
|
+
const diff = toMs(a.createdAt) - toMs(b.createdAt);
|
|
25
|
+
if (diff !== 0) return diff;
|
|
26
|
+
if (a.id === void 0 || b.id === void 0 || a.id === b.id) return 0;
|
|
27
|
+
return a.id < b.id ? -1 : 1;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Hesabın etkin planı, hakları ve erişim durumu. Adaylardan biri katalogda
|
|
32
|
+
* yoksa fırlatır (tutarsız veri; servis bunu FK ile garanti eder).
|
|
33
|
+
*/
|
|
34
|
+
function resolveEntitlements(input) {
|
|
35
|
+
const { catalog } = input;
|
|
36
|
+
const plans = new Map(catalog.plans.map((p) => [p.code, p]));
|
|
37
|
+
const planOf = (code) => {
|
|
38
|
+
const plan = plans.get(code);
|
|
39
|
+
if (!plan) throw new Error(`plan katalogda yok: ${code}`);
|
|
40
|
+
return plan;
|
|
41
|
+
};
|
|
42
|
+
const live = input.subscription && isLiveSubscriptionStatus(input.subscription.status) ? input.subscription : null;
|
|
43
|
+
const grants = creationOrder((input.grants ?? []).filter((g) => isGrantActive(g, input.at)));
|
|
44
|
+
const candidates = [
|
|
45
|
+
catalog.defaultPlanCode,
|
|
46
|
+
...live ? [live.planCode] : [],
|
|
47
|
+
...grants.flatMap((g) => g.planCode ? [g.planCode] : [])
|
|
48
|
+
];
|
|
49
|
+
let plan = planOf(candidates[0]);
|
|
50
|
+
for (const code of candidates.slice(1)) {
|
|
51
|
+
const candidate = planOf(code);
|
|
52
|
+
if (candidate.rank >= plan.rank) plan = candidate;
|
|
53
|
+
}
|
|
54
|
+
const entitlements = new Map(catalog.features.map((f) => [f.key, Object.hasOwn(plan.entitlements, f.key) ? plan.entitlements[f.key] ?? null : null]));
|
|
55
|
+
for (const g of grants) for (const [key, value] of Object.entries(g.overrides ?? {})) if (entitlements.has(key)) entitlements.set(key, value);
|
|
56
|
+
const accessState = live?.status === "suspended" ? "suspended" : "active";
|
|
57
|
+
return {
|
|
58
|
+
planCode: plan.code,
|
|
59
|
+
accessState,
|
|
60
|
+
entitlements: Object.fromEntries(entitlements)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../contract/src/validators.ts
|
|
65
|
+
const digitsOf = (value) => Array.from(value, Number);
|
|
66
|
+
/**
|
|
67
|
+
* T.C. kimlik numarası: 11 hane, ilk hane 0 değil;
|
|
68
|
+
* 10. hane = ((1.+3.+5.+7.+9.) × 7 − (2.+4.+6.+8.)) mod 10,
|
|
69
|
+
* 11. hane = (ilk 10 hanenin toplamı) mod 10.
|
|
70
|
+
*/
|
|
71
|
+
function isValidTckn(value) {
|
|
72
|
+
if (typeof value !== "string" || !/^[1-9]\d{10}$/.test(value)) return false;
|
|
73
|
+
const d = digitsOf(value);
|
|
74
|
+
const odd = d[0] + d[2] + d[4] + d[6] + d[8];
|
|
75
|
+
const even = d[1] + d[3] + d[5] + d[7];
|
|
76
|
+
const tenth = ((odd * 7 - even) % 10 + 10) % 10;
|
|
77
|
+
const eleventh = (odd + even + tenth) % 10;
|
|
78
|
+
return d[9] === tenth && d[10] === eleventh;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Vergi kimlik numarası (GİB): 10 hane; i = 0…8 için
|
|
82
|
+
* t = (hane + 9 − i) mod 10, p = t × 2^(9 − i) mod 9 (t ≠ 0 ve p = 0 ise 9),
|
|
83
|
+
* son hane = (10 − Σp mod 10) mod 10.
|
|
84
|
+
*/
|
|
85
|
+
function isValidVkn(value) {
|
|
86
|
+
if (typeof value !== "string" || !/^\d{10}$/.test(value)) return false;
|
|
87
|
+
const d = digitsOf(value);
|
|
88
|
+
let sum = 0;
|
|
89
|
+
for (let i = 0; i < 9; i++) {
|
|
90
|
+
const t = (d[i] + 9 - i) % 10;
|
|
91
|
+
const p = t * 2 ** (9 - i) % 9;
|
|
92
|
+
sum += t !== 0 && p === 0 ? 9 : p;
|
|
93
|
+
}
|
|
94
|
+
return d[9] === (10 - sum % 10) % 10;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* E.164 telefon: `+`, sıfırla başlamayan ülke kodu, toplam 8–15 hane
|
|
98
|
+
* (steward fatura profili şemasıyla aynı). `{country: "TR"}`: `+90` ve 10 hane
|
|
99
|
+
* (iyzico'nun istediği biçim).
|
|
100
|
+
*/
|
|
101
|
+
function isE164(value, options = {}) {
|
|
102
|
+
if (typeof value !== "string") return false;
|
|
103
|
+
return options.country === "TR" ? /^\+90\d{10}$/.test(value) : /^\+[1-9]\d{7,14}$/.test(value);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { isGrantActive as a, LIVE_SUBSCRIPTION_STATUSES as i, isValidTckn as n, isLiveSubscriptionStatus as o, isValidVkn as r, resolveEntitlements as s, isE164 as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { a as BillingEvent } from "./events.js";
|
|
2
|
+
//#region ../contract/src/webhook-core.d.ts
|
|
3
|
+
declare const HEADER_EVENT_ID = "steward-event-id";
|
|
4
|
+
declare const HEADER_TIMESTAMP = "steward-timestamp";
|
|
5
|
+
declare const HEADER_SIGNATURE = "steward-signature";
|
|
6
|
+
declare const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
7
|
+
type HeaderSource = Headers | Record<string, string | string[] | undefined>;
|
|
8
|
+
type VerifyFailure = "missing_headers" | "timestamp_out_of_tolerance" | "bad_signature" | "invalid_payload" | "id_mismatch";
|
|
9
|
+
type VerifyResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
event: BillingEvent;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
reason: VerifyFailure;
|
|
15
|
+
};
|
|
16
|
+
/** Gövdeyi parse etmeden yapılan doğrulamanın başarısızlık nedenleri. */
|
|
17
|
+
type VerifyRawFailure = "missing_headers" | "timestamp_out_of_tolerance" | "bad_signature";
|
|
18
|
+
type VerifyRawResult = {
|
|
19
|
+
ok: true;
|
|
20
|
+
eventId: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
reason: VerifyRawFailure;
|
|
25
|
+
};
|
|
26
|
+
type VerifyRawOptions = {
|
|
27
|
+
toleranceSeconds?: number;
|
|
28
|
+
/** Karşılaştırma anı: `Date` ya da unix SANİYE (`Steward-Timestamp` ile aynı birim). */
|
|
29
|
+
now?: Date | number;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { HeaderSource as a, VerifyRawOptions as c, HEADER_TIMESTAMP as i, VerifyRawResult as l, HEADER_EVENT_ID as n, VerifyFailure as o, HEADER_SIGNATURE as r, VerifyRawFailure as s, DEFAULT_TOLERANCE_SECONDS as t, VerifyResult as u };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { r as BillingEventSchema } from "./events.js";
|
|
2
|
+
//#region ../contract/src/webhook-core.ts
|
|
3
|
+
const HEADER_EVENT_ID = "steward-event-id";
|
|
4
|
+
const HEADER_TIMESTAMP = "steward-timestamp";
|
|
5
|
+
const HEADER_SIGNATURE = "steward-signature";
|
|
6
|
+
const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
7
|
+
function header(headers, name) {
|
|
8
|
+
if (typeof headers.get === "function") return headers.get(name);
|
|
9
|
+
const record = headers;
|
|
10
|
+
const key = Object.keys(record).find((k) => k.toLowerCase() === name);
|
|
11
|
+
const value = key === void 0 ? void 0 : record[key];
|
|
12
|
+
return Array.isArray(value) ? value[0] ?? null : value ?? null;
|
|
13
|
+
}
|
|
14
|
+
const signedPayload = (eventId, timestamp, rawBody) => `${eventId}.${timestamp}.${rawBody}`;
|
|
15
|
+
/** Başlıklar ve pencere; imza karşılaştırması çağırandadır. `signatures` küçük harfli hex adayları. */
|
|
16
|
+
function checkHeaders(secrets, headers, options) {
|
|
17
|
+
const id = header(headers, HEADER_EVENT_ID);
|
|
18
|
+
const ts = header(headers, HEADER_TIMESTAMP);
|
|
19
|
+
const sig = header(headers, HEADER_SIGNATURE);
|
|
20
|
+
if (!id || !ts || !sig || secrets.length === 0) return {
|
|
21
|
+
ok: false,
|
|
22
|
+
reason: "missing_headers"
|
|
23
|
+
};
|
|
24
|
+
const timestamp = Number(ts);
|
|
25
|
+
const now = options.now === void 0 ? Math.floor(Date.now() / 1e3) : options.now instanceof Date ? Math.floor(options.now.getTime() / 1e3) : options.now;
|
|
26
|
+
const tolerance = options.toleranceSeconds ?? 300;
|
|
27
|
+
if (!/^\d+$/.test(ts) || Math.abs(now - timestamp) > tolerance) return {
|
|
28
|
+
ok: false,
|
|
29
|
+
reason: "timestamp_out_of_tolerance"
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
ok: true,
|
|
33
|
+
eventId: id,
|
|
34
|
+
timestamp,
|
|
35
|
+
signatures: sig.split(",").map((part) => part.trim()).filter((part) => part.startsWith("v1=")).map((part) => part.slice(3).toLowerCase())
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** İmzası doğrulanmış gövdeyi sözleşmeyle parse eder; başlıktaki id gövdedekiyle aynı olmalı. */
|
|
39
|
+
function parseVerified(eventId, rawBody) {
|
|
40
|
+
let json;
|
|
41
|
+
try {
|
|
42
|
+
json = JSON.parse(rawBody);
|
|
43
|
+
} catch {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
reason: "invalid_payload"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const parsed = BillingEventSchema.safeParse(json);
|
|
50
|
+
if (!parsed.success) return {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: "invalid_payload"
|
|
53
|
+
};
|
|
54
|
+
if (parsed.data.id !== eventId) return {
|
|
55
|
+
ok: false,
|
|
56
|
+
reason: "id_mismatch"
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
event: parsed.data
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { checkHeaders as a, HEADER_TIMESTAMP as i, HEADER_EVENT_ID as n, parseVerified as o, HEADER_SIGNATURE as r, signedPayload as s, DEFAULT_TOLERANCE_SECONDS as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as HeaderSource, c as VerifyRawOptions, l as VerifyRawResult, u as VerifyResult } from "./webhook-core.js";
|
|
2
|
+
//#region ../contract/src/webhook.d.ts
|
|
3
|
+
declare function computeSignature(secret: string, eventId: string, timestamp: number, rawBody: string): string;
|
|
4
|
+
/** Gönderen tarafı: teslimat başlıkları. `secrets[0]` güncel sır. */
|
|
5
|
+
declare function signWebhook(secrets: readonly string[], eventId: string, rawBody: string, timestamp?: number): Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Alıcı tarafı, şemasız: başlıkları, zaman penceresini ve imzayı ham gövde
|
|
8
|
+
* üzerinde doğrular; gövdeyi PARSE ETMEZ. Şemayı çağıran seçer
|
|
9
|
+
* (`BillingEventSchema`, tanınmayan tip için `AnyBillingEventSchema`,
|
|
10
|
+
* `PingSchema`); gövdedeki `id`'nin `eventId` ile aynı olduğunu da çağıran denetler.
|
|
11
|
+
*/
|
|
12
|
+
declare function verifyWebhookRaw(secrets: readonly string[], headers: HeaderSource, rawBody: string, options?: VerifyRawOptions): VerifyRawResult;
|
|
13
|
+
/** Alıcı tarafı: imzayı ham gövde üzerinde doğrular, SONRA sözleşmeyle parse eder. */
|
|
14
|
+
declare function verifyWebhook(input: {
|
|
15
|
+
secrets: readonly string[];
|
|
16
|
+
headers: HeaderSource;
|
|
17
|
+
rawBody: string;
|
|
18
|
+
nowSeconds?: number;
|
|
19
|
+
toleranceSeconds?: number;
|
|
20
|
+
}): VerifyResult;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { verifyWebhookRaw as i, signWebhook as n, verifyWebhook as r, computeSignature as t };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { a as checkHeaders, i as HEADER_TIMESTAMP, n as HEADER_EVENT_ID, o as parseVerified, r as HEADER_SIGNATURE, s as signedPayload } from "./webhook-core.js";
|
|
2
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
|
+
//#region ../contract/src/webhook.ts
|
|
4
|
+
function computeSignature(secret, eventId, timestamp, rawBody) {
|
|
5
|
+
return createHmac("sha256", secret).update(signedPayload(eventId, timestamp, rawBody)).digest("hex");
|
|
6
|
+
}
|
|
7
|
+
/** Gönderen tarafı: teslimat başlıkları. `secrets[0]` güncel sır. */
|
|
8
|
+
function signWebhook(secrets, eventId, rawBody, timestamp = Math.floor(Date.now() / 1e3)) {
|
|
9
|
+
if (secrets.length === 0) throw new Error("en az bir imza sırrı gerekli");
|
|
10
|
+
const signature = secrets.map((s) => `v1=${computeSignature(s, eventId, timestamp, rawBody)}`).join(",");
|
|
11
|
+
return {
|
|
12
|
+
[HEADER_EVENT_ID]: eventId,
|
|
13
|
+
[HEADER_TIMESTAMP]: String(timestamp),
|
|
14
|
+
[HEADER_SIGNATURE]: signature
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function safeEqualHex(a, b) {
|
|
18
|
+
const ab = Buffer.from(a, "utf8");
|
|
19
|
+
const bb = Buffer.from(b, "utf8");
|
|
20
|
+
return ab.length === bb.length && timingSafeEqual(ab, bb);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Alıcı tarafı, şemasız: başlıkları, zaman penceresini ve imzayı ham gövde
|
|
24
|
+
* üzerinde doğrular; gövdeyi PARSE ETMEZ. Şemayı çağıran seçer
|
|
25
|
+
* (`BillingEventSchema`, tanınmayan tip için `AnyBillingEventSchema`,
|
|
26
|
+
* `PingSchema`); gövdedeki `id`'nin `eventId` ile aynı olduğunu da çağıran denetler.
|
|
27
|
+
*/
|
|
28
|
+
function verifyWebhookRaw(secrets, headers, rawBody, options = {}) {
|
|
29
|
+
const checked = checkHeaders(secrets, headers, options);
|
|
30
|
+
if (!checked.ok) return checked;
|
|
31
|
+
const { eventId, timestamp, signatures } = checked;
|
|
32
|
+
return secrets.some((secret) => {
|
|
33
|
+
const expected = computeSignature(secret, eventId, timestamp, rawBody);
|
|
34
|
+
return signatures.some((given) => safeEqualHex(expected, given));
|
|
35
|
+
}) ? {
|
|
36
|
+
ok: true,
|
|
37
|
+
eventId,
|
|
38
|
+
timestamp
|
|
39
|
+
} : {
|
|
40
|
+
ok: false,
|
|
41
|
+
reason: "bad_signature"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Alıcı tarafı: imzayı ham gövde üzerinde doğrular, SONRA sözleşmeyle parse eder. */
|
|
45
|
+
function verifyWebhook(input) {
|
|
46
|
+
const verified = verifyWebhookRaw(input.secrets, input.headers, input.rawBody, {
|
|
47
|
+
...input.nowSeconds !== void 0 ? { now: input.nowSeconds } : {},
|
|
48
|
+
...input.toleranceSeconds !== void 0 ? { toleranceSeconds: input.toleranceSeconds } : {}
|
|
49
|
+
});
|
|
50
|
+
return verified.ok ? parseVerified(verified.eventId, input.rawBody) : verified;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { verifyWebhookRaw as i, signWebhook as n, verifyWebhook as r, computeSignature as t };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { $ as DEFAULT_CHECKOUT_TTL_MINUTES, $n as CheckoutPrefillSchema, $r as IdSchema, $t as EventRecord, A as hostedReadinessOf, An as CancelSubscriptionInput, Ar as PlanDef, At as ResolvedEntitlements, B as WebhookEndpointRotateInput, Bn as Subscription, Br as Currency, Bt as AccountDetailSchema, C as DoctorUnsellablePriceSchema, Cn as MANUAL_INVOICE_MAX_AMOUNT_MINOR, Cr as CatalogSyncInput, Ct as PlanSetWarningSchema, D as DoctorWarningSchema, Dn as ManualInvoiceLineInputSchema, Dr as FeatureDef, Dt as EntitlementRulesGrant, E as DoctorWarningCode, En as ManualInvoiceLineInput, Er as CatalogSyncResultSchema, Et as EntitlementRulesCatalog, F as WebhookEndpoint, Fn as GrantSchema, Fr as PriceSchema, Ft as ErrorCode, G as WebhookLastDelivery, Gn as PortalSessionCreateInputSchema, Gr as EntitlementValueSchema, Gt as CancelSubscriptionResponse, H as WebhookEndpointSchema, Hn as PORTAL_SESSION_ERRORS, Hr as DateTimeSchema, Ht as AccountUpsertResponseSchema, I as WebhookEndpointCreateInput, In as Payment, Ir as API_VERSION, It as ErrorCodeSpec, J as generateWebhookSecret, Jn as CHECKOUT_ERRORS, Jr as ErrorCategory, Jt as CheckoutSessionResponseSchema, K as WebhookLastDeliverySchema, Kn as PortalSessionError, Kr as Entitlements, Kt as CancelSubscriptionResponseSchema, L as WebhookEndpointCreateInputSchema, Ln as PaymentSchema, Lr as ActorRefSchema, Lt as errorCodeSpec, M as EventTypeSchema, Mn as Grant, Mr as Price, Mt as isLiveSubscriptionStatus, N as WEBHOOK_ENDPOINT_STATUSES, Nn as GrantCreateInput, Nr as PriceDef, Nt as resolveEntitlements, O as buildDoctorReport, On as manualInvoiceTotals, Or as FeatureDefSchema, Ot as LIVE_SUBSCRIPTION_STATUSES, P as WEBHOOK_SECRET_PREFIX, Pn as GrantCreateInputSchema, Pr as PriceDefSchema, Pt as ERROR_CODES, Q as BrandingSchema, Qn as CheckoutPrefill, Qr as ExternalRefSchema, Qt as EventListSchema, R as WebhookEndpointList, Rn as Stats, Rr as AmountMinorSchema, Rt as isKnownErrorCode, S as DoctorUnsellablePrice, Sn as InvoiceVoidInputSchema, Sr as CatalogSchema, St as PlanSetWarningCode, T as DoctorWarning, Tn as ManualInvoiceInputSchema, Tr as CatalogSyncResult, Tt as ResyncResultSchema, U as WebhookEndpointStatus, Un as PortalSession, Ur as ERROR_CATEGORIES, Ut as BillingProfileResponse, V as WebhookEndpointRotateInputSchema, Vn as SubscriptionSchema, Vr as CurrencySchema, Vt as AccountUpsertResponse, W as WebhookEndpointStatusSchema, Wn as PortalSessionCreateInput, Wr as EntitlementValue, Wt as BillingProfileResponseSchema, X as Branding, Xn as CheckoutConsentInputSchema, Xr as ErrorResponse, Xt as DeliverySchema, Y as webhookEndpointUrlProblem, Yn as CheckoutConsentInput, Yr as ErrorCategorySchema, Yt as Delivery, Z as BrandingPatchSchema, Zn as CheckoutError, Zr as ErrorResponseSchema, Zt as EventList, _ as DoctorReportSchema, _n as InvoiceLine, _r as checkoutRedirectUrl, _t as PlanSetMode, a as DOCTOR_SEVERITIES, an as HEADER_IDEMPOTENCY_KEY, ar as CheckoutSessionCreateParsed, at as ReturnOriginSchema, b as DoctorSeverity, bn as InvoiceStatusSchema, br as AccountsRefreshResultSchema, bt as PlanSetResponseSchema, c as DoctorEndpoint, cn as InvoiceIssueResponse, cr as CheckoutSessionSchema, ct as SettingsLocaleSchema, d as DoctorFacts, dn as InvoiceVoidResponseSchema, dr as Consent, dt as applySettingsPatch, ei as Interval, en as EventRecordSchema, er as CheckoutRedirectTarget, et as DEFAULT_PORTAL_TTL_MINUTES, f as DoctorHosted, fn as ManualInvoiceResponse, fr as ConsentSchema, ft as isReturnUrlAllowed, g as DoctorReport, gn as InvoiceIssueInputSchema, gr as ProviderPayloadSchema, gt as PlanSetInputSchema, h as DoctorProviderSchema, hn as InvoiceIssueInput, hr as ProviderPayload, ht as PlanSetInput, i as DOCTOR_REQUIRED_LEGAL_LINKS, in as HEADER_API_VERSION, ir as CheckoutSessionCreateInputSchema, it as ProductSettingsSchema, j as DEFAULT_ENDPOINT_EVENT_TYPES, jn as CancelSubscriptionInputSchema, jr as PlanDefSchema, jt as isGrantActive, k as endpointDiagnosisOf, kn as splitInclusiveTax, kr as FeatureTypeSchema, kt as ResolveEntitlementsInput, l as DoctorEndpointDiagnosis, ln as InvoiceIssueResponseSchema, lr as CheckoutStatus, lt as TtlMinutesSchema, m as DoctorProvider, mn as Invoice, mr as MAX_CHECKOUT_CONSENT_DOCS, mt as PLAN_SET_MODES, n as DOCTOR_PROVIDER_ENVIRONMENTS, ni as MetadataSchema, nn as GrantCreateResponseSchema, nr as CheckoutSession, nt as ProductSettingsPatch, o as DoctorCatalog, on as HEADER_REQUEST_ID, or as CheckoutSessionCreated, ot as SETTINGS_LOCALES, p as DoctorHostedSchema, pn as ManualInvoiceResponseSchema, pr as LegacyCheckoutSessionCreateParsed, pt as returnOriginsOf, q as WebhookSecretSchema, qn as PortalSessionSchema, qr as EntitlementsSchema, qt as CheckoutSessionResponse, r as DOCTOR_REQUIRED_BRANDING, rn as HEADER_ACTOR_REF, rr as CheckoutSessionCreateInput, rt as ProductSettingsPatchSchema, s as DoctorCatalogSchema, sn as HEADER_SDK, sr as CheckoutSessionCreatedSchema, st as SettingsLocale, t as DOCTOR_PENDING_BACKLOG_MS, ti as IntervalSchema, tn as GrantCreateResponse, tr as CheckoutReturnStatus, tt as ProductSettings, u as DoctorEndpointSchema, un as InvoiceVoidResponse, ur as CheckoutStatusSchema, ut as WebUrlSchema, v as DoctorSettings, vn as InvoiceLineSchema, vr as isLegacyCheckoutInput, vt as PlanSetModeSchema, w as DoctorUnsellableReason, wn as ManualInvoiceInput, wr as CatalogSyncInputSchema, wt as ResyncResult, x as DoctorSeveritySchema, xn as InvoiceVoidInput, xr as Catalog, xt as PlanSetWarning, y as DoctorSettingsSchema, yn as InvoiceSchema, yr as AccountsRefreshResult, yt as PlanSetResponse, z as WebhookEndpointListSchema, zn as StatsSchema, zr as CodeSchema, zt as AccountDetail } from "./_chunks/index.js";
|
|
2
|
+
import { A as AccountProfileState, B as AccountUpsertInputSchema, C as AccountDeleteResponse, D as AccountInclude, E as AccountDunningStateSchema, F as AccountState, G as EntitlementSnapshot, H as BillingProfileInput, I as AccountStateSchema, J as SubscriptionStatusSchema, K as EntitlementSnapshotSchema, L as AccountSubscriptionState, M as AccountScheduledChange, N as AccountScheduledChangeSchema, O as AccountOpenCheckout, P as AccountSchema, R as AccountSubscriptionStateSchema, S as Account, T as AccountDunningState, U as BillingProfileKindSchema, V as BillingProfile, W as BillingProfileSchema, X as SubscriptionSummarySchema, Y as SubscriptionSummary, _ as PingSchema, a as BillingEvent, b as AccessState, c as EVENT_DETAIL_SCHEMAS, d as EventIdSchema, f as EventType, g as Ping, h as PING_EVENT_TYPE, i as ApiVersionSchema, j as AccountProfileStateSchema, k as AccountOpenCheckoutSchema, l as EVENT_TYPES, m as LegacyEventType, n as AnyBillingEvent, o as BillingEventOf, p as LEGACY_EVENT_TYPES, q as SubscriptionStatus, r as AnyBillingEventSchema, s as BillingEventSchema, t as AccountStateChangeCause, u as EventDetail, v as isEventType, w as AccountDeleteResponseSchema, x as AccessStateSchema, y as ACCOUNT_INCLUDES, z as AccountUpsertInput } from "./_chunks/events.js";
|
|
3
|
+
import { n as isValidTckn, r as isValidVkn, t as isE164 } from "./_chunks/validators.js";
|
|
4
|
+
export { ACCOUNT_INCLUDES, API_VERSION, AccessState, AccessStateSchema, Account, AccountDeleteResponse, AccountDeleteResponseSchema, AccountDetail, AccountDetailSchema, AccountDunningState, AccountDunningStateSchema, AccountInclude, AccountOpenCheckout, AccountOpenCheckoutSchema, AccountProfileState, AccountProfileStateSchema, AccountScheduledChange, AccountScheduledChangeSchema, AccountSchema, AccountState, AccountStateChangeCause, AccountStateSchema, AccountSubscriptionState, AccountSubscriptionStateSchema, AccountUpsertInput, AccountUpsertInputSchema, AccountUpsertResponse, AccountUpsertResponseSchema, AccountsRefreshResult, AccountsRefreshResultSchema, ActorRefSchema, AmountMinorSchema, AnyBillingEvent, AnyBillingEventSchema, ApiVersionSchema, BillingEvent, BillingEventOf, BillingEventSchema, BillingProfile, BillingProfileInput, BillingProfileKindSchema, BillingProfileResponse, BillingProfileResponseSchema, BillingProfileSchema, Branding, BrandingPatchSchema, BrandingSchema, CHECKOUT_ERRORS, CancelSubscriptionInput, CancelSubscriptionInputSchema, CancelSubscriptionResponse, CancelSubscriptionResponseSchema, Catalog, CatalogSchema, CatalogSyncInput, CatalogSyncInputSchema, CatalogSyncResult, CatalogSyncResultSchema, CheckoutConsentInput, CheckoutConsentInputSchema, CheckoutError, CheckoutPrefill, CheckoutPrefillSchema, CheckoutRedirectTarget, CheckoutReturnStatus, CheckoutSession, CheckoutSessionCreateInput, CheckoutSessionCreateInputSchema, CheckoutSessionCreateParsed, CheckoutSessionCreated, CheckoutSessionCreatedSchema, CheckoutSessionResponse, CheckoutSessionResponseSchema, CheckoutSessionSchema, CheckoutStatus, CheckoutStatusSchema, CodeSchema, Consent, ConsentSchema, Currency, CurrencySchema, DEFAULT_CHECKOUT_TTL_MINUTES, DEFAULT_ENDPOINT_EVENT_TYPES, DEFAULT_PORTAL_TTL_MINUTES, DOCTOR_PENDING_BACKLOG_MS, DOCTOR_PROVIDER_ENVIRONMENTS, DOCTOR_REQUIRED_BRANDING, DOCTOR_REQUIRED_LEGAL_LINKS, DOCTOR_SEVERITIES, DateTimeSchema, Delivery, DeliverySchema, DoctorCatalog, DoctorCatalogSchema, DoctorEndpoint, DoctorEndpointDiagnosis, DoctorEndpointSchema, DoctorFacts, DoctorHosted, DoctorHostedSchema, DoctorProvider, DoctorProviderSchema, DoctorReport, DoctorReportSchema, DoctorSettings, DoctorSettingsSchema, DoctorSeverity, DoctorSeveritySchema, DoctorUnsellablePrice, DoctorUnsellablePriceSchema, DoctorUnsellableReason, DoctorWarning, DoctorWarningCode, DoctorWarningSchema, ERROR_CATEGORIES, ERROR_CODES, EVENT_DETAIL_SCHEMAS, EVENT_TYPES, EntitlementRulesCatalog, EntitlementRulesGrant, EntitlementSnapshot, EntitlementSnapshotSchema, EntitlementValue, EntitlementValueSchema, Entitlements, EntitlementsSchema, ErrorCategory, ErrorCategorySchema, ErrorCode, ErrorCodeSpec, ErrorResponse, ErrorResponseSchema, EventDetail, EventIdSchema, EventList, EventListSchema, EventRecord, EventRecordSchema, EventType, EventTypeSchema, ExternalRefSchema, FeatureDef, FeatureDefSchema, FeatureTypeSchema, Grant, GrantCreateInput, GrantCreateInputSchema, GrantCreateResponse, GrantCreateResponseSchema, GrantSchema, HEADER_ACTOR_REF, HEADER_API_VERSION, HEADER_IDEMPOTENCY_KEY, HEADER_REQUEST_ID, HEADER_SDK, IdSchema, Interval, IntervalSchema, Invoice, InvoiceIssueInput, InvoiceIssueInputSchema, InvoiceIssueResponse, InvoiceIssueResponseSchema, InvoiceLine, InvoiceLineSchema, InvoiceSchema, InvoiceStatusSchema, InvoiceVoidInput, InvoiceVoidInputSchema, InvoiceVoidResponse, InvoiceVoidResponseSchema, LEGACY_EVENT_TYPES, LIVE_SUBSCRIPTION_STATUSES, LegacyCheckoutSessionCreateParsed, LegacyEventType, MANUAL_INVOICE_MAX_AMOUNT_MINOR, MAX_CHECKOUT_CONSENT_DOCS, ManualInvoiceInput, ManualInvoiceInputSchema, ManualInvoiceLineInput, ManualInvoiceLineInputSchema, ManualInvoiceResponse, ManualInvoiceResponseSchema, MetadataSchema, PING_EVENT_TYPE, PLAN_SET_MODES, PORTAL_SESSION_ERRORS, Payment, PaymentSchema, Ping, PingSchema, PlanDef, PlanDefSchema, PlanSetInput, PlanSetInputSchema, PlanSetMode, PlanSetModeSchema, PlanSetResponse, PlanSetResponseSchema, PlanSetWarning, PlanSetWarningCode, PlanSetWarningSchema, PortalSession, PortalSessionCreateInput, PortalSessionCreateInputSchema, PortalSessionError, PortalSessionSchema, Price, PriceDef, PriceDefSchema, PriceSchema, ProductSettings, ProductSettingsPatch, ProductSettingsPatchSchema, ProductSettingsSchema, ProviderPayload, ProviderPayloadSchema, ResolveEntitlementsInput, ResolvedEntitlements, ResyncResult, ResyncResultSchema, ReturnOriginSchema, SETTINGS_LOCALES, SettingsLocale, SettingsLocaleSchema, Stats, StatsSchema, Subscription, SubscriptionSchema, SubscriptionStatus, SubscriptionStatusSchema, SubscriptionSummary, SubscriptionSummarySchema, TtlMinutesSchema, WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_SECRET_PREFIX, WebUrlSchema, WebhookEndpoint, WebhookEndpointCreateInput, WebhookEndpointCreateInputSchema, WebhookEndpointList, WebhookEndpointListSchema, WebhookEndpointRotateInput, WebhookEndpointRotateInputSchema, WebhookEndpointSchema, WebhookEndpointStatus, WebhookEndpointStatusSchema, WebhookLastDelivery, WebhookLastDeliverySchema, WebhookSecretSchema, applySettingsPatch, buildDoctorReport, checkoutRedirectUrl, endpointDiagnosisOf, errorCodeSpec, generateWebhookSecret, hostedReadinessOf, isE164, isEventType, isGrantActive, isKnownErrorCode, isLegacyCheckoutInput, isLiveSubscriptionStatus, isReturnUrlAllowed, isValidTckn, isValidVkn, manualInvoiceTotals, resolveEntitlements, returnOriginsOf, splitInclusiveTax, webhookEndpointUrlProblem };
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { A as CodeSchema, B as IntervalSchema, C as BillingProfileSchema, D as API_VERSION, E as SubscriptionSummarySchema, F as EntitlementsSchema, I as ErrorCategorySchema, L as ErrorResponseSchema, M as DateTimeSchema, N as ERROR_CATEGORIES, O as ActorRefSchema, P as EntitlementValueSchema, R as ExternalRefSchema, S as BillingProfileKindSchema, T as SubscriptionStatusSchema, V as MetadataSchema, _ as AccountScheduledChangeSchema, a as EVENT_TYPES, b as AccountSubscriptionStateSchema, c as PING_EVENT_TYPE, d as ACCOUNT_INCLUDES, f as AccessStateSchema, g as AccountProfileStateSchema, h as AccountOpenCheckoutSchema, i as EVENT_DETAIL_SCHEMAS, j as CurrencySchema, k as AmountMinorSchema, l as PingSchema, m as AccountDunningStateSchema, n as ApiVersionSchema, o as EventIdSchema, p as AccountDeleteResponseSchema, r as BillingEventSchema, s as LEGACY_EVENT_TYPES, t as AnyBillingEventSchema, u as isEventType, v as AccountSchema, w as EntitlementSnapshotSchema, x as AccountUpsertInputSchema, y as AccountStateSchema, z as IdSchema } from "./_chunks/events.js";
|
|
2
|
+
import { $ as HEADER_SDK, $t as FeatureTypeSchema, A as webhookEndpointUrlProblem, At as MAX_CHECKOUT_CONSENT_DOCS, B as AccountDetailSchema, Bt as ReturnOriginSchema, C as WebhookEndpointListSchema, Ct as CheckoutConsentInputSchema, D as WebhookLastDeliverySchema, Dt as CheckoutSessionSchema, E as WebhookEndpointStatusSchema, Et as CheckoutSessionCreatedSchema, F as PlanSetWarningSchema, Ft as BrandingSchema, G as DeliverySchema, Gt as applySettingsPatch, H as BillingProfileResponseSchema, Ht as SettingsLocaleSchema, I as ResyncResultSchema, It as DEFAULT_CHECKOUT_TTL_MINUTES, J as GrantCreateResponseSchema, Jt as AccountsRefreshResultSchema, K as EventListSchema, Kt as isReturnUrlAllowed, L as ERROR_CODES, Lt as DEFAULT_PORTAL_TTL_MINUTES, M as PlanSetInputSchema, Mt as checkoutRedirectUrl, N as PlanSetModeSchema, Nt as isLegacyCheckoutInput, O as WebhookSecretSchema, Ot as CheckoutStatusSchema, P as PlanSetResponseSchema, Pt as BrandingPatchSchema, Q as HEADER_REQUEST_ID, Qt as FeatureDefSchema, R as errorCodeSpec, Rt as ProductSettingsPatchSchema, S as WebhookEndpointCreateInputSchema, St as CHECKOUT_ERRORS, T as WebhookEndpointSchema, Tt as CheckoutSessionCreateInputSchema, U as CancelSubscriptionResponseSchema, Ut as TtlMinutesSchema, V as AccountUpsertResponseSchema, Vt as SETTINGS_LOCALES, W as CheckoutSessionResponseSchema, Wt as WebUrlSchema, X as HEADER_API_VERSION, Xt as CatalogSyncInputSchema, Y as HEADER_ACTOR_REF, Yt as CatalogSchema, Z as HEADER_IDEMPOTENCY_KEY, Zt as CatalogSyncResultSchema, _ as hostedReadinessOf, _t as StatsSchema, a as DOCTOR_SEVERITIES, at as InvoiceSchema, b as WEBHOOK_ENDPOINT_STATUSES, bt as PortalSessionCreateInputSchema, c as DoctorHostedSchema, ct as MANUAL_INVOICE_MAX_AMOUNT_MINOR, d as DoctorSettingsSchema, dt as manualInvoiceTotals, en as PlanDefSchema, et as InvoiceIssueResponseSchema, f as DoctorSeveritySchema, ft as splitInclusiveTax, g as endpointDiagnosisOf, gt as PaymentSchema, h as buildDoctorReport, ht as GrantSchema, i as DOCTOR_REQUIRED_LEGAL_LINKS, it as InvoiceLineSchema, j as PLAN_SET_MODES, jt as ProviderPayloadSchema, k as generateWebhookSecret, kt as ConsentSchema, l as DoctorProviderSchema, lt as ManualInvoiceInputSchema, m as DoctorWarningSchema, mt as GrantCreateInputSchema, n as DOCTOR_PROVIDER_ENVIRONMENTS, nn as PriceSchema, nt as ManualInvoiceResponseSchema, o as DoctorCatalogSchema, ot as InvoiceStatusSchema, p as DoctorUnsellablePriceSchema, pt as CancelSubscriptionInputSchema, q as EventRecordSchema, qt as returnOriginsOf, r as DOCTOR_REQUIRED_BRANDING, rt as InvoiceIssueInputSchema, s as DoctorEndpointSchema, st as InvoiceVoidInputSchema, t as DOCTOR_PENDING_BACKLOG_MS, tn as PriceDefSchema, tt as InvoiceVoidResponseSchema, u as DoctorReportSchema, ut as ManualInvoiceLineInputSchema, v as DEFAULT_ENDPOINT_EVENT_TYPES, vt as SubscriptionSchema, w as WebhookEndpointRotateInputSchema, wt as CheckoutPrefillSchema, x as WEBHOOK_SECRET_PREFIX, xt as PortalSessionSchema, y as EventTypeSchema, yt as PORTAL_SESSION_ERRORS, z as isKnownErrorCode, zt as ProductSettingsSchema } from "./_chunks/src.js";
|
|
3
|
+
import { a as isGrantActive, i as LIVE_SUBSCRIPTION_STATUSES, n as isValidTckn, o as isLiveSubscriptionStatus, r as isValidVkn, s as resolveEntitlements, t as isE164 } from "./_chunks/validators.js";
|
|
4
|
+
export { ACCOUNT_INCLUDES, API_VERSION, AccessStateSchema, AccountDeleteResponseSchema, AccountDetailSchema, AccountDunningStateSchema, AccountOpenCheckoutSchema, AccountProfileStateSchema, AccountScheduledChangeSchema, AccountSchema, AccountStateSchema, AccountSubscriptionStateSchema, AccountUpsertInputSchema, AccountUpsertResponseSchema, AccountsRefreshResultSchema, ActorRefSchema, AmountMinorSchema, AnyBillingEventSchema, ApiVersionSchema, BillingEventSchema, BillingProfileKindSchema, BillingProfileResponseSchema, BillingProfileSchema, BrandingPatchSchema, BrandingSchema, CHECKOUT_ERRORS, CancelSubscriptionInputSchema, CancelSubscriptionResponseSchema, CatalogSchema, CatalogSyncInputSchema, CatalogSyncResultSchema, CheckoutConsentInputSchema, CheckoutPrefillSchema, CheckoutSessionCreateInputSchema, CheckoutSessionCreatedSchema, CheckoutSessionResponseSchema, CheckoutSessionSchema, CheckoutStatusSchema, CodeSchema, ConsentSchema, CurrencySchema, DEFAULT_CHECKOUT_TTL_MINUTES, DEFAULT_ENDPOINT_EVENT_TYPES, DEFAULT_PORTAL_TTL_MINUTES, DOCTOR_PENDING_BACKLOG_MS, DOCTOR_PROVIDER_ENVIRONMENTS, DOCTOR_REQUIRED_BRANDING, DOCTOR_REQUIRED_LEGAL_LINKS, DOCTOR_SEVERITIES, DateTimeSchema, DeliverySchema, DoctorCatalogSchema, DoctorEndpointSchema, DoctorHostedSchema, DoctorProviderSchema, DoctorReportSchema, DoctorSettingsSchema, DoctorSeveritySchema, DoctorUnsellablePriceSchema, DoctorWarningSchema, ERROR_CATEGORIES, ERROR_CODES, EVENT_DETAIL_SCHEMAS, EVENT_TYPES, EntitlementSnapshotSchema, EntitlementValueSchema, EntitlementsSchema, ErrorCategorySchema, ErrorResponseSchema, EventIdSchema, EventListSchema, EventRecordSchema, EventTypeSchema, ExternalRefSchema, FeatureDefSchema, FeatureTypeSchema, GrantCreateInputSchema, GrantCreateResponseSchema, GrantSchema, HEADER_ACTOR_REF, HEADER_API_VERSION, HEADER_IDEMPOTENCY_KEY, HEADER_REQUEST_ID, HEADER_SDK, IdSchema, IntervalSchema, InvoiceIssueInputSchema, InvoiceIssueResponseSchema, InvoiceLineSchema, InvoiceSchema, InvoiceStatusSchema, InvoiceVoidInputSchema, InvoiceVoidResponseSchema, LEGACY_EVENT_TYPES, LIVE_SUBSCRIPTION_STATUSES, MANUAL_INVOICE_MAX_AMOUNT_MINOR, MAX_CHECKOUT_CONSENT_DOCS, ManualInvoiceInputSchema, ManualInvoiceLineInputSchema, ManualInvoiceResponseSchema, MetadataSchema, PING_EVENT_TYPE, PLAN_SET_MODES, PORTAL_SESSION_ERRORS, PaymentSchema, PingSchema, PlanDefSchema, PlanSetInputSchema, PlanSetModeSchema, PlanSetResponseSchema, PlanSetWarningSchema, PortalSessionCreateInputSchema, PortalSessionSchema, PriceDefSchema, PriceSchema, ProductSettingsPatchSchema, ProductSettingsSchema, ProviderPayloadSchema, ResyncResultSchema, ReturnOriginSchema, SETTINGS_LOCALES, SettingsLocaleSchema, StatsSchema, SubscriptionSchema, SubscriptionStatusSchema, SubscriptionSummarySchema, TtlMinutesSchema, WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_SECRET_PREFIX, WebUrlSchema, WebhookEndpointCreateInputSchema, WebhookEndpointListSchema, WebhookEndpointRotateInputSchema, WebhookEndpointSchema, WebhookEndpointStatusSchema, WebhookLastDeliverySchema, WebhookSecretSchema, applySettingsPatch, buildDoctorReport, checkoutRedirectUrl, endpointDiagnosisOf, errorCodeSpec, generateWebhookSecret, hostedReadinessOf, isE164, isEventType, isGrantActive, isKnownErrorCode, isLegacyCheckoutInput, isLiveSubscriptionStatus, isReturnUrlAllowed, isValidTckn, isValidVkn, manualInvoiceTotals, resolveEntitlements, returnOriginsOf, splitInclusiveTax, webhookEndpointUrlProblem };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { $ as DEFAULT_CHECKOUT_TTL_MINUTES, $n as CheckoutPrefillSchema, $r as IdSchema, $t as EventRecord, A as hostedReadinessOf, An as CancelSubscriptionInput, Ar as PlanDef, At as ResolvedEntitlements, B as WebhookEndpointRotateInput, Bn as Subscription, Br as Currency, Bt as AccountDetailSchema, C as DoctorUnsellablePriceSchema, Cn as MANUAL_INVOICE_MAX_AMOUNT_MINOR, Cr as CatalogSyncInput, Ct as PlanSetWarningSchema, D as DoctorWarningSchema, Dn as ManualInvoiceLineInputSchema, Dr as FeatureDef, Dt as EntitlementRulesGrant, E as DoctorWarningCode, En as ManualInvoiceLineInput, Er as CatalogSyncResultSchema, Et as EntitlementRulesCatalog, F as WebhookEndpoint, Fn as GrantSchema, Fr as PriceSchema, Ft as ErrorCode, G as WebhookLastDelivery, Gn as PortalSessionCreateInputSchema, Gr as EntitlementValueSchema, Gt as CancelSubscriptionResponse, H as WebhookEndpointSchema, Hn as PORTAL_SESSION_ERRORS, Hr as DateTimeSchema, Ht as AccountUpsertResponseSchema, I as WebhookEndpointCreateInput, In as Payment, Ir as API_VERSION, It as ErrorCodeSpec, J as generateWebhookSecret, Jn as CHECKOUT_ERRORS, Jr as ErrorCategory, Jt as CheckoutSessionResponseSchema, K as WebhookLastDeliverySchema, Kn as PortalSessionError, Kr as Entitlements, Kt as CancelSubscriptionResponseSchema, L as WebhookEndpointCreateInputSchema, Ln as PaymentSchema, Lr as ActorRefSchema, Lt as errorCodeSpec, M as EventTypeSchema, Mn as Grant, Mr as Price, Mt as isLiveSubscriptionStatus, N as WEBHOOK_ENDPOINT_STATUSES, Nn as GrantCreateInput, Nr as PriceDef, Nt as resolveEntitlements, O as buildDoctorReport, On as manualInvoiceTotals, Or as FeatureDefSchema, Ot as LIVE_SUBSCRIPTION_STATUSES, P as WEBHOOK_SECRET_PREFIX, Pn as GrantCreateInputSchema, Pr as PriceDefSchema, Pt as ERROR_CODES, Q as BrandingSchema, Qn as CheckoutPrefill, Qr as ExternalRefSchema, Qt as EventListSchema, R as WebhookEndpointList, Rn as Stats, Rr as AmountMinorSchema, Rt as isKnownErrorCode, S as DoctorUnsellablePrice, Sn as InvoiceVoidInputSchema, Sr as CatalogSchema, St as PlanSetWarningCode, T as DoctorWarning, Tn as ManualInvoiceInputSchema, Tr as CatalogSyncResult, Tt as ResyncResultSchema, U as WebhookEndpointStatus, Un as PortalSession, Ur as ERROR_CATEGORIES, Ut as BillingProfileResponse, V as WebhookEndpointRotateInputSchema, Vn as SubscriptionSchema, Vr as CurrencySchema, Vt as AccountUpsertResponse, W as WebhookEndpointStatusSchema, Wn as PortalSessionCreateInput, Wr as EntitlementValue, Wt as BillingProfileResponseSchema, X as Branding, Xn as CheckoutConsentInputSchema, Xr as ErrorResponse, Xt as DeliverySchema, Y as webhookEndpointUrlProblem, Yn as CheckoutConsentInput, Yr as ErrorCategorySchema, Yt as Delivery, Z as BrandingPatchSchema, Zn as CheckoutError, Zr as ErrorResponseSchema, Zt as EventList, _ as DoctorReportSchema, _n as InvoiceLine, _r as checkoutRedirectUrl, _t as PlanSetMode, a as DOCTOR_SEVERITIES, an as HEADER_IDEMPOTENCY_KEY, ar as CheckoutSessionCreateParsed, at as ReturnOriginSchema, b as DoctorSeverity, bn as InvoiceStatusSchema, br as AccountsRefreshResultSchema, bt as PlanSetResponseSchema, c as DoctorEndpoint, cn as InvoiceIssueResponse, cr as CheckoutSessionSchema, ct as SettingsLocaleSchema, d as DoctorFacts, dn as InvoiceVoidResponseSchema, dr as Consent, dt as applySettingsPatch, ei as Interval, en as EventRecordSchema, er as CheckoutRedirectTarget, et as DEFAULT_PORTAL_TTL_MINUTES, f as DoctorHosted, fn as ManualInvoiceResponse, fr as ConsentSchema, ft as isReturnUrlAllowed, g as DoctorReport, gn as InvoiceIssueInputSchema, gr as ProviderPayloadSchema, gt as PlanSetInputSchema, h as DoctorProviderSchema, hn as InvoiceIssueInput, hr as ProviderPayload, ht as PlanSetInput, i as DOCTOR_REQUIRED_LEGAL_LINKS, in as HEADER_API_VERSION, ir as CheckoutSessionCreateInputSchema, it as ProductSettingsSchema, j as DEFAULT_ENDPOINT_EVENT_TYPES, jn as CancelSubscriptionInputSchema, jr as PlanDefSchema, jt as isGrantActive, k as endpointDiagnosisOf, kn as splitInclusiveTax, kr as FeatureTypeSchema, kt as ResolveEntitlementsInput, l as DoctorEndpointDiagnosis, ln as InvoiceIssueResponseSchema, lr as CheckoutStatus, lt as TtlMinutesSchema, m as DoctorProvider, mn as Invoice, mr as MAX_CHECKOUT_CONSENT_DOCS, mt as PLAN_SET_MODES, n as DOCTOR_PROVIDER_ENVIRONMENTS, ni as MetadataSchema, nn as GrantCreateResponseSchema, nr as CheckoutSession, nt as ProductSettingsPatch, o as DoctorCatalog, on as HEADER_REQUEST_ID, or as CheckoutSessionCreated, ot as SETTINGS_LOCALES, p as DoctorHostedSchema, pn as ManualInvoiceResponseSchema, pr as LegacyCheckoutSessionCreateParsed, pt as returnOriginsOf, q as WebhookSecretSchema, qn as PortalSessionSchema, qr as EntitlementsSchema, qt as CheckoutSessionResponse, r as DOCTOR_REQUIRED_BRANDING, rn as HEADER_ACTOR_REF, rr as CheckoutSessionCreateInput, rt as ProductSettingsPatchSchema, s as DoctorCatalogSchema, sn as HEADER_SDK, sr as CheckoutSessionCreatedSchema, st as SettingsLocale, t as DOCTOR_PENDING_BACKLOG_MS, ti as IntervalSchema, tn as GrantCreateResponse, tr as CheckoutReturnStatus, tt as ProductSettings, u as DoctorEndpointSchema, un as InvoiceVoidResponse, ur as CheckoutStatusSchema, ut as WebUrlSchema, v as DoctorSettings, vn as InvoiceLineSchema, vr as isLegacyCheckoutInput, vt as PlanSetModeSchema, w as DoctorUnsellableReason, wn as ManualInvoiceInput, wr as CatalogSyncInputSchema, wt as ResyncResult, x as DoctorSeveritySchema, xn as InvoiceVoidInput, xr as Catalog, xt as PlanSetWarning, y as DoctorSettingsSchema, yn as InvoiceSchema, yr as AccountsRefreshResult, yt as PlanSetResponse, z as WebhookEndpointListSchema, zn as StatsSchema, zr as CodeSchema, zt as AccountDetail } from "./_chunks/index.js";
|
|
2
|
+
import { A as AccountProfileState, B as AccountUpsertInputSchema, C as AccountDeleteResponse, D as AccountInclude, E as AccountDunningStateSchema, F as AccountState, G as EntitlementSnapshot, H as BillingProfileInput, I as AccountStateSchema, J as SubscriptionStatusSchema, K as EntitlementSnapshotSchema, L as AccountSubscriptionState, M as AccountScheduledChange, N as AccountScheduledChangeSchema, O as AccountOpenCheckout, P as AccountSchema, R as AccountSubscriptionStateSchema, S as Account, T as AccountDunningState, U as BillingProfileKindSchema, V as BillingProfile, W as BillingProfileSchema, X as SubscriptionSummarySchema, Y as SubscriptionSummary, _ as PingSchema, a as BillingEvent, b as AccessState, c as EVENT_DETAIL_SCHEMAS, d as EventIdSchema, f as EventType, g as Ping, h as PING_EVENT_TYPE, i as ApiVersionSchema, j as AccountProfileStateSchema, k as AccountOpenCheckoutSchema, l as EVENT_TYPES, m as LegacyEventType, n as AnyBillingEvent, o as BillingEventOf, p as LEGACY_EVENT_TYPES, q as SubscriptionStatus, r as AnyBillingEventSchema, s as BillingEventSchema, t as AccountStateChangeCause, u as EventDetail, v as isEventType, w as AccountDeleteResponseSchema, x as AccessStateSchema, y as ACCOUNT_INCLUDES, z as AccountUpsertInput } from "./_chunks/events.js";
|
|
3
|
+
import { n as isValidTckn, r as isValidVkn, t as isE164 } from "./_chunks/validators.js";
|
|
4
|
+
import { _ as createBillingClient, a as Steward, c as StewardOptions, d as RetryOptions, f as AccountStateRead, g as ClientResult, h as CallOptions, i as MutationOptions, l as createSteward, m as BillingClientOptions, n as EventListQuery, o as StewardEnv, p as BillingClient, r as InvoiceDocument, s as StewardMe, t as CatalogRead, u as RetryClass, v as parseRetryAfter } from "./_chunks/steward.js";
|
|
5
|
+
import { i as httpStatusFor, n as HttpStatusResult, r as StewardLogger, t as StewardLocale } from "./_chunks/locale.js";
|
|
6
|
+
//#region src/catalog-cache.d.ts
|
|
7
|
+
export type CatalogCacheOptions = {
|
|
8
|
+
/** Varsayılan 60 sn. */
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
/** Bayat değer uyarısı; varsayılan `console`. */
|
|
11
|
+
logger?: Pick<StewardLogger, "warn">;
|
|
12
|
+
};
|
|
13
|
+
export type CatalogCache = {
|
|
14
|
+
get(): Promise<Catalog>;
|
|
15
|
+
/** Sonraki `get()` süreyi beklemeden (ETag'le) tazeler. */
|
|
16
|
+
invalidate(): void;
|
|
17
|
+
};
|
|
18
|
+
export declare function createCatalogCache(steward: Pick<Steward, "catalog">, options?: CatalogCacheOptions): CatalogCache;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/catalog.d.ts
|
|
21
|
+
type FeatureType = "limit" | "boolean" | "string";
|
|
22
|
+
export type FeatureSpec<T extends FeatureType = FeatureType> = {
|
|
23
|
+
readonly type: T;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
};
|
|
26
|
+
type FeatureOptions = {
|
|
27
|
+
description?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Sayısal limit: negatif olmayan tam sayı ya da `null` (sınırsız). */
|
|
30
|
+
export declare const limit: (options?: FeatureOptions) => FeatureSpec<"limit">;
|
|
31
|
+
/** Açık/kapalı özellik. */
|
|
32
|
+
export declare const flag: (options?: FeatureOptions) => FeatureSpec<"boolean">;
|
|
33
|
+
/** Serbest metin ayarı. */
|
|
34
|
+
export declare const text: (options?: FeatureOptions) => FeatureSpec<"string">;
|
|
35
|
+
export type FeatureValue<F extends FeatureSpec> = F["type"] extends "limit" ? number | null : F["type"] extends "boolean" ? boolean : string;
|
|
36
|
+
export type FeatureSpecs = Record<string, FeatureSpec>;
|
|
37
|
+
/** Feature listesinin tam, tipli hak nesnesi. */
|
|
38
|
+
export type EntitlementsFor<F extends FeatureSpecs> = { [K in keyof F]: FeatureValue<F[K]>; };
|
|
39
|
+
export type PlanSpec<F extends FeatureSpecs> = {
|
|
40
|
+
name: string;
|
|
41
|
+
/** Yükseltme/düşürme sırası: büyük olan üst plan. */
|
|
42
|
+
rank: number;
|
|
43
|
+
/** Self-servis satın alınabilir mi (false: yalnızca grant ile). */
|
|
44
|
+
sellable: boolean;
|
|
45
|
+
entitlements: EntitlementsFor<F>;
|
|
46
|
+
};
|
|
47
|
+
export type PriceSpec<P extends string> = {
|
|
48
|
+
plan: P;
|
|
49
|
+
interval: Interval;
|
|
50
|
+
intervalCount?: number;
|
|
51
|
+
currency: string;
|
|
52
|
+
amountMinor: number;
|
|
53
|
+
taxInclusive: boolean;
|
|
54
|
+
/** Baz puan: %20 = 2000. */
|
|
55
|
+
taxRateBps: number;
|
|
56
|
+
};
|
|
57
|
+
export type CatalogDefinition<F extends FeatureSpecs, P extends string> = {
|
|
58
|
+
defaultPlan: NoInfer<P>;
|
|
59
|
+
features: F;
|
|
60
|
+
plans: { [K in P]: PlanSpec<NoInfer<F>>; };
|
|
61
|
+
prices: readonly PriceSpec<NoInfer<P>>[];
|
|
62
|
+
};
|
|
63
|
+
/** `resolve` girdisi: `AccountState`/`EntitlementSnapshot` ya da projeksiyon satırı. */
|
|
64
|
+
export type EntitlementSource = {
|
|
65
|
+
planCode?: string | null;
|
|
66
|
+
entitlements?: Readonly<Record<string, unknown>> | null;
|
|
67
|
+
};
|
|
68
|
+
/** `stateOf` seçenekleri: ürünün bildiği (kendi tablosundaki) alanlar. */
|
|
69
|
+
export type CatalogStateOptions = {
|
|
70
|
+
/** Varsayılan `active` (ör. ürün organizasyonu askıdaysa `suspended`). */
|
|
71
|
+
accessState?: AccessState;
|
|
72
|
+
/** Varsayılan `ref`. */
|
|
73
|
+
displayName?: string;
|
|
74
|
+
};
|
|
75
|
+
export type CatalogResolveOptions = {
|
|
76
|
+
/** Snapshot'ta eksik ya da tipi uymayan anahtarlar (yedek değer kullanıldı); ALARM için. */
|
|
77
|
+
onFallback?: (keys: string[]) => void;
|
|
78
|
+
};
|
|
79
|
+
export type DefinedCatalog<F extends FeatureSpecs, P extends string> = {
|
|
80
|
+
readonly defaultPlan: P;
|
|
81
|
+
readonly features: Readonly<F>;
|
|
82
|
+
readonly plans: { readonly [K in P]: Readonly<PlanSpec<F>>; };
|
|
83
|
+
readonly prices: readonly Readonly<PriceSpec<P>>[];
|
|
84
|
+
/** Yalnızca tip (`typeof catalog.$plan`); çalışma zamanında `undefined`. */
|
|
85
|
+
readonly $plan: P;
|
|
86
|
+
/** Yalnızca tip (`typeof catalog.$entitlements`); çalışma zamanında `undefined`. */
|
|
87
|
+
readonly $entitlements: EntitlementsFor<F>;
|
|
88
|
+
/** `PUT /v1/admin/catalog` gövdesi. */
|
|
89
|
+
toSyncInput(): CatalogSyncInput;
|
|
90
|
+
/** Planın katalogdaki hakları (kopya). */
|
|
91
|
+
entitlementsOf(plan: P): EntitlementsFor<F>;
|
|
92
|
+
/**
|
|
93
|
+
* Snapshot → tipli haklar. K4 sonrası tam snapshot her anahtarı taşır; anahtar
|
|
94
|
+
* eksikse ya da tipi uymuyorsa (eski katalog, sürüm kayması) değer snapshot'ın
|
|
95
|
+
* planından, plan bu katalogda yoksa varsayılan plandan alınır. Yedek asla
|
|
96
|
+
* "sınırsız" üretmez: bozuk snapshot limiti kaldıramaz. Snapshot yoksa
|
|
97
|
+
* (`null`) varsayılan planın hakları. Katalogda olmayan anahtarlar yok sayılır.
|
|
98
|
+
*/
|
|
99
|
+
resolve(state: EntitlementSource | null | undefined, options?: CatalogResolveOptions): EntitlementsFor<F>;
|
|
100
|
+
isPlan(code: unknown): code is P;
|
|
101
|
+
/**
|
|
102
|
+
* Katalogdan kurulan tam `AccountState` — steward'dan gelmeyen yer tutucu, `stateCache`
|
|
103
|
+
* `fallback`'i için: `version` 0, `updatedAt` 1970-01-01, `catalogVersion` null, haklar
|
|
104
|
+
* planın katalogdaki değerleri, abonelik ve açık checkout yok, profil yok. `plan`
|
|
105
|
+
* verilmezse varsayılan plan; katalogda olmayan plan `StewardConfigError` (`unknown_plan`).
|
|
106
|
+
*/
|
|
107
|
+
stateOf(ref: string, plan?: P, options?: CatalogStateOptions): AccountState;
|
|
108
|
+
};
|
|
109
|
+
export declare function defineCatalog<F extends FeatureSpecs, P extends string>(definition: CatalogDefinition<F, P>): DefinedCatalog<F, P>;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/state-cache.d.ts
|
|
112
|
+
export type StateReadOptions = {
|
|
113
|
+
/** TTL'i ve hata sonrası bekleme aralığını atla (steward'a sor). */
|
|
114
|
+
fresh?: boolean;
|
|
115
|
+
};
|
|
116
|
+
export type StateFallbackEvent = {
|
|
117
|
+
ref: string;
|
|
118
|
+
/** Steward hatasının kodu: `network_error`, `timeout`, `database_unavailable`… ya da (`missing: "fallback"`) `account_not_found`. */
|
|
119
|
+
reason: string;
|
|
120
|
+
};
|
|
121
|
+
/** 404 `account_not_found`: `throw` hata (varsayılan), `fallback` ürünün `fallback(ref)`'i (kesinti sayılmaz). */
|
|
122
|
+
export type StateMissingPolicy = "throw" | "fallback";
|
|
123
|
+
export type StateCacheOptions = {
|
|
124
|
+
/** Varsayılan 30 sn. */
|
|
125
|
+
ttlMs?: number;
|
|
126
|
+
/** Süre dolduktan sonra kesintide bayat değerin kullanılabileceği süre. Varsayılan 10 dk. */
|
|
127
|
+
staleIfErrorMs?: number;
|
|
128
|
+
/** Steward'a ulaşılamaz ve bayat değer yoksa (ör. katalog × ürünün plan alanı). `null`: yok, hata fırlatılır. */
|
|
129
|
+
fallback?: (ref: string) => AccountState | null | Promise<AccountState | null>;
|
|
130
|
+
/** Fallback her kullanıldığında; ürünün metriğine bağlanır. */
|
|
131
|
+
onFallback?: (event: StateFallbackEvent) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Steward hesabı bilmiyorsa (404 `account_not_found`): `"throw"` (varsayılan) hatayı fırlatır;
|
|
134
|
+
* `"fallback"` `fallback(ref)`'i döner (`fallback` zorunlu; WARN yok, `onFallback` nedeni
|
|
135
|
+
* `account_not_found`). Hesabı ilk checkout'ta açan ürün için.
|
|
136
|
+
*/
|
|
137
|
+
missing?: StateMissingPolicy;
|
|
138
|
+
/** Önbellekteki en çok hesap (LRU). Varsayılan 10 000. */
|
|
139
|
+
maxEntries?: number;
|
|
140
|
+
/** Bayat değer/fallback uyarıları; varsayılan `console`. */
|
|
141
|
+
logger?: Pick<StewardLogger, "warn">;
|
|
142
|
+
/** Saat, ms (test için). Varsayılan `Date.now`. */
|
|
143
|
+
now?: () => number;
|
|
144
|
+
};
|
|
145
|
+
export type StateCache<E = Entitlements> = {
|
|
146
|
+
state(ref: string, options?: StateReadOptions): Promise<AccountState>;
|
|
147
|
+
/** `catalog` verildiyse tipli ve tam (`catalog.resolve`), yoksa durumdaki haklar. */
|
|
148
|
+
entitlements(ref: string, options?: StateReadOptions): Promise<E>;
|
|
149
|
+
many(refs: Iterable<string>): Promise<Map<string, AccountState>>;
|
|
150
|
+
invalidate(ref: string): void;
|
|
151
|
+
/** Daha yeni ya da aynı version'daki durumu yazar; `null`/`undefined` yok sayılır (eski steward `account` dönmeyebilir). */
|
|
152
|
+
prime(account: AccountState | null | undefined): void;
|
|
153
|
+
};
|
|
154
|
+
/** Önbelleğin kullandığı istemci kısmı (`createSteward()` karşılar). */
|
|
155
|
+
export type StateCacheSteward = {
|
|
156
|
+
accounts: {
|
|
157
|
+
readState(ref: string, options?: {
|
|
158
|
+
etag?: string;
|
|
159
|
+
}): Promise<AccountStateRead>;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
export declare function stateCache<F extends FeatureSpecs, P extends string>(steward: StateCacheSteward, options: StateCacheOptions & {
|
|
163
|
+
catalog: DefinedCatalog<F, P>;
|
|
164
|
+
}): StateCache<EntitlementsFor<F>>;
|
|
165
|
+
export declare function stateCache(steward: StateCacheSteward, options?: StateCacheOptions & {
|
|
166
|
+
catalog?: undefined;
|
|
167
|
+
}): StateCache<Entitlements>;
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/errors.d.ts
|
|
170
|
+
export type StewardErrorOptions = {
|
|
171
|
+
code: string;
|
|
172
|
+
message?: string;
|
|
173
|
+
httpStatus?: number;
|
|
174
|
+
category?: ErrorCategory;
|
|
175
|
+
retryable?: boolean;
|
|
176
|
+
/** Steward yanıtındaki `X-Request-Id`; destek ve log eşleştirmesi için. */
|
|
177
|
+
requestId?: string;
|
|
178
|
+
/** 429/503 yanıtındaki `Retry-After`, milisaniye. */
|
|
179
|
+
retryAfterMs?: number;
|
|
180
|
+
cause?: unknown;
|
|
181
|
+
};
|
|
182
|
+
export declare class StewardError extends Error {
|
|
183
|
+
readonly code: string;
|
|
184
|
+
readonly httpStatus: number;
|
|
185
|
+
readonly retryable: boolean;
|
|
186
|
+
readonly category?: ErrorCategory;
|
|
187
|
+
readonly requestId?: string;
|
|
188
|
+
readonly retryAfterMs?: number;
|
|
189
|
+
constructor(options: StewardErrorOptions);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Steward 2xx dışı yanıt döndü (`{error, message?}`). Yanıt `category` /
|
|
193
|
+
* `retryable` taşımıyorsa sözleşmenin `ERROR_CODES` kaydı kullanılır; kod orada
|
|
194
|
+
* da yoksa 429 ve 5xx tekrar denenebilir sayılır.
|
|
195
|
+
*/
|
|
196
|
+
export declare class StewardApiError extends StewardError {
|
|
197
|
+
constructor(options: StewardErrorOptions & {
|
|
198
|
+
httpStatus: number;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/** Steward'a ulaşılamadı ya da zaman aşımı; yanıt yok (`httpStatus` 0), tekrar denenebilir. */
|
|
202
|
+
export declare class StewardNetworkError extends StewardError {
|
|
203
|
+
constructor(options?: Omit<StewardErrorOptions, "code" | "httpStatus" | "category"> & {
|
|
204
|
+
code?: "network_error" | "timeout";
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/** Yanıt sözleşme şemasına uymadı (sürüm kayması); aynı istek aynı sonucu verir. */
|
|
208
|
+
export declare class StewardContractError extends StewardError {
|
|
209
|
+
constructor(options?: Omit<StewardErrorOptions, "code" | "category"> & {
|
|
210
|
+
code?: string;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/** SDK yanlış yapılandırıldı (eksik `STEWARD_URL`, geçersiz katalog…); istek hiç gönderilmedi. */
|
|
214
|
+
export declare class StewardConfigError extends StewardError {
|
|
215
|
+
constructor(options?: Omit<StewardErrorOptions, "code" | "httpStatus" | "category" | "retryable"> & {
|
|
216
|
+
code?: string;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/messages.d.ts
|
|
221
|
+
/** SDK'nın kendisinin ürettiği kodlar (yanıt yok ya da istek hiç gönderilmedi). */
|
|
222
|
+
declare const CLIENT_ERROR_CODES: readonly ["network_error", "timeout", "invalid_response", "config_error"];
|
|
223
|
+
export type StewardErrorCode = ErrorCode | (typeof CLIENT_ERROR_CODES)[number];
|
|
224
|
+
export declare const STEWARD_ERROR_CODES: readonly StewardErrorCode[];
|
|
225
|
+
export type ErrorMessages = Record<StewardErrorCode, string> & {
|
|
226
|
+
fallback: string;
|
|
227
|
+
};
|
|
228
|
+
export declare const errorMessages: {
|
|
229
|
+
readonly tr: ErrorMessages;
|
|
230
|
+
readonly en: ErrorMessages;
|
|
231
|
+
};
|
|
232
|
+
/** Kullanıcıya gösterilecek metin (`tr`, `tr-TR` → tr; diğer diller → en); tanınmayan kodda genel metin. */
|
|
233
|
+
export declare function messageFor(code: string, locale: string): string;
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/money.d.ts
|
|
236
|
+
/** `Price`, `PriceDef` ve `defineCatalog` fiyatlarıyla uyumlu en küçük şekil. */
|
|
237
|
+
export type PriceAmount = {
|
|
238
|
+
amountMinor: number;
|
|
239
|
+
currency: string;
|
|
240
|
+
taxInclusive: boolean;
|
|
241
|
+
/** Baz puan: %20 = 2000. */
|
|
242
|
+
taxRateBps: number;
|
|
243
|
+
};
|
|
244
|
+
export type TaxBreakdown = {
|
|
245
|
+
/** Matrah (vergi hariç). */
|
|
246
|
+
subtotalMinor: number;
|
|
247
|
+
taxMinor: number;
|
|
248
|
+
/** Ödenecek toplam = matrah + vergi. */
|
|
249
|
+
totalMinor: number;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Vergi dahil fiyatta toplam korunur, matrah kuruşa yuvarlanır ve vergi kalandır;
|
|
253
|
+
* vergi hariç fiyatta vergi kuruşa yuvarlanıp üstüne eklenir.
|
|
254
|
+
*/
|
|
255
|
+
export declare function taxBreakdown(price: Pick<PriceAmount, "amountMinor" | "taxInclusive" | "taxRateBps">): TaxBreakdown;
|
|
256
|
+
/**
|
|
257
|
+
* Tutar, para biriminin ondalık hanesiyle (TRY/USD 2, JPY 0): `₺1.250,00`
|
|
258
|
+
* (tr), `₺1,250.00` (en). Sembol dar biçimde (`TRY 1,250.00` değil).
|
|
259
|
+
*/
|
|
260
|
+
export declare function formatMoney(amountMinor: number, currency: string, locale: string): string;
|
|
261
|
+
/**
|
|
262
|
+
* Fiyat etiketi: `₺1.250,00 · KDV dahil` (tr), `₺1,250.00 · VAT included` (en).
|
|
263
|
+
* Vergi oranı 0 ise vergi ibaresi yazılmaz. Sayı biçimi `locale`'in kendisiyle,
|
|
264
|
+
* ibare `tr*` → Türkçe, diğerleri İngilizce.
|
|
265
|
+
*/
|
|
266
|
+
export declare function formatPrice(price: PriceAmount, locale: string): string;
|
|
267
|
+
//#endregion
|
|
268
|
+
export { ACCOUNT_INCLUDES, API_VERSION, AccessState, AccessStateSchema, Account, AccountDeleteResponse, AccountDeleteResponseSchema, AccountDetail, AccountDetailSchema, AccountDunningState, AccountDunningStateSchema, AccountInclude, AccountOpenCheckout, AccountOpenCheckoutSchema, AccountProfileState, AccountProfileStateSchema, AccountScheduledChange, AccountScheduledChangeSchema, AccountSchema, AccountState, AccountStateChangeCause, AccountStateRead, AccountStateSchema, AccountSubscriptionState, AccountSubscriptionStateSchema, AccountUpsertInput, AccountUpsertInputSchema, AccountUpsertResponse, AccountUpsertResponseSchema, AccountsRefreshResult, AccountsRefreshResultSchema, ActorRefSchema, AmountMinorSchema, AnyBillingEvent, AnyBillingEventSchema, ApiVersionSchema, BillingClient, BillingClientOptions, BillingEvent, BillingEventOf, BillingEventSchema, BillingProfile, BillingProfileInput, BillingProfileKindSchema, BillingProfileResponse, BillingProfileResponseSchema, BillingProfileSchema, Branding, BrandingPatchSchema, BrandingSchema, CHECKOUT_ERRORS, CallOptions, CancelSubscriptionInput, CancelSubscriptionInputSchema, CancelSubscriptionResponse, CancelSubscriptionResponseSchema, Catalog, CatalogRead, CatalogSchema, CatalogSyncInput, CatalogSyncInputSchema, CatalogSyncResult, CatalogSyncResultSchema, CheckoutConsentInput, CheckoutConsentInputSchema, CheckoutError, CheckoutPrefill, CheckoutPrefillSchema, CheckoutRedirectTarget, CheckoutReturnStatus, CheckoutSession, CheckoutSessionCreateInput, CheckoutSessionCreateInputSchema, CheckoutSessionCreateParsed, CheckoutSessionCreated, CheckoutSessionCreatedSchema, CheckoutSessionResponse, CheckoutSessionResponseSchema, CheckoutSessionSchema, CheckoutStatus, CheckoutStatusSchema, ClientResult, CodeSchema, Consent, ConsentSchema, Currency, CurrencySchema, DEFAULT_CHECKOUT_TTL_MINUTES, DEFAULT_ENDPOINT_EVENT_TYPES, DEFAULT_PORTAL_TTL_MINUTES, DOCTOR_PENDING_BACKLOG_MS, DOCTOR_PROVIDER_ENVIRONMENTS, DOCTOR_REQUIRED_BRANDING, DOCTOR_REQUIRED_LEGAL_LINKS, DOCTOR_SEVERITIES, DateTimeSchema, Delivery, DeliverySchema, DoctorCatalog, DoctorCatalogSchema, DoctorEndpoint, DoctorEndpointDiagnosis, DoctorEndpointSchema, DoctorFacts, DoctorHosted, DoctorHostedSchema, DoctorProvider, DoctorProviderSchema, DoctorReport, DoctorReportSchema, DoctorSettings, DoctorSettingsSchema, DoctorSeverity, DoctorSeveritySchema, DoctorUnsellablePrice, DoctorUnsellablePriceSchema, DoctorUnsellableReason, DoctorWarning, DoctorWarningCode, DoctorWarningSchema, ERROR_CATEGORIES, ERROR_CODES, EVENT_DETAIL_SCHEMAS, EVENT_TYPES, EntitlementRulesCatalog, EntitlementRulesGrant, EntitlementSnapshot, EntitlementSnapshotSchema, EntitlementValue, EntitlementValueSchema, Entitlements, EntitlementsSchema, ErrorCategory, ErrorCategorySchema, ErrorCode, ErrorCodeSpec, ErrorResponse, ErrorResponseSchema, EventDetail, EventIdSchema, EventList, EventListQuery, EventListSchema, EventRecord, EventRecordSchema, EventType, EventTypeSchema, ExternalRefSchema, FeatureDef, FeatureDefSchema, FeatureTypeSchema, Grant, GrantCreateInput, GrantCreateInputSchema, GrantCreateResponse, GrantCreateResponseSchema, GrantSchema, HEADER_ACTOR_REF, HEADER_API_VERSION, HEADER_IDEMPOTENCY_KEY, HEADER_REQUEST_ID, HEADER_SDK, HttpStatusResult, IdSchema, Interval, IntervalSchema, Invoice, InvoiceDocument, InvoiceIssueInput, InvoiceIssueInputSchema, InvoiceIssueResponse, InvoiceIssueResponseSchema, InvoiceLine, InvoiceLineSchema, InvoiceSchema, InvoiceStatusSchema, InvoiceVoidInput, InvoiceVoidInputSchema, InvoiceVoidResponse, InvoiceVoidResponseSchema, LEGACY_EVENT_TYPES, LIVE_SUBSCRIPTION_STATUSES, LegacyCheckoutSessionCreateParsed, LegacyEventType, MANUAL_INVOICE_MAX_AMOUNT_MINOR, MAX_CHECKOUT_CONSENT_DOCS, ManualInvoiceInput, ManualInvoiceInputSchema, ManualInvoiceLineInput, ManualInvoiceLineInputSchema, ManualInvoiceResponse, ManualInvoiceResponseSchema, MetadataSchema, MutationOptions, PING_EVENT_TYPE, PLAN_SET_MODES, PORTAL_SESSION_ERRORS, Payment, PaymentSchema, Ping, PingSchema, PlanDef, PlanDefSchema, PlanSetInput, PlanSetInputSchema, PlanSetMode, PlanSetModeSchema, PlanSetResponse, PlanSetResponseSchema, PlanSetWarning, PlanSetWarningCode, PlanSetWarningSchema, PortalSession, PortalSessionCreateInput, PortalSessionCreateInputSchema, PortalSessionError, PortalSessionSchema, Price, PriceDef, PriceDefSchema, PriceSchema, ProductSettings, ProductSettingsPatch, ProductSettingsPatchSchema, ProductSettingsSchema, ProviderPayload, ProviderPayloadSchema, ResolveEntitlementsInput, ResolvedEntitlements, ResyncResult, ResyncResultSchema, type RetryClass, type RetryOptions, ReturnOriginSchema, SETTINGS_LOCALES, SettingsLocale, SettingsLocaleSchema, Stats, StatsSchema, Steward, StewardEnv, type StewardLocale, StewardLogger, StewardMe, StewardOptions, Subscription, SubscriptionSchema, SubscriptionStatus, SubscriptionStatusSchema, SubscriptionSummary, SubscriptionSummarySchema, TtlMinutesSchema, WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_SECRET_PREFIX, WebUrlSchema, WebhookEndpoint, WebhookEndpointCreateInput, WebhookEndpointCreateInputSchema, WebhookEndpointList, WebhookEndpointListSchema, WebhookEndpointRotateInput, WebhookEndpointRotateInputSchema, WebhookEndpointSchema, WebhookEndpointStatus, WebhookEndpointStatusSchema, WebhookLastDelivery, WebhookLastDeliverySchema, WebhookSecretSchema, applySettingsPatch, buildDoctorReport, checkoutRedirectUrl, createBillingClient, createSteward, endpointDiagnosisOf, errorCodeSpec, generateWebhookSecret, hostedReadinessOf, httpStatusFor, isE164, isEventType, isGrantActive, isKnownErrorCode, isLegacyCheckoutInput, isLiveSubscriptionStatus, isReturnUrlAllowed, isValidTckn, isValidVkn, manualInvoiceTotals, parseRetryAfter, resolveEntitlements, returnOriginsOf, splitInclusiveTax, webhookEndpointUrlProblem };
|