@stewardhq/sdk 0.2.0 → 0.5.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 +123 -88
- package/dist/_chunks/errors.js +1 -1
- package/dist/_chunks/events.d.ts +315 -4
- package/dist/_chunks/events.js +1155 -9
- package/dist/_chunks/index.d.ts +3473 -90
- package/dist/_chunks/locale.d.ts +269 -1
- package/dist/_chunks/src.js +842 -24
- package/dist/_chunks/validators.d.ts +45 -1
- package/dist/_chunks/validators.js +128 -27
- package/dist/contract.d.ts +4 -4
- package/dist/contract.js +4 -4
- package/dist/index.d.ts +436 -22
- package/dist/index.js +1659 -26
- package/dist/server.d.ts +44 -6
- package/dist/server.js +29 -2
- package/package.json +4 -10
- package/dist/_chunks/steward.d.ts +0 -189
- package/dist/_chunks/steward.js +0 -560
- package/dist/testing/fixtures/events/LOCK.json +0 -27
- package/dist/testing/fixtures/events/account.deleted.json +0 -36
- package/dist/testing/fixtures/events/account.state_changed.json +0 -53
- package/dist/testing/fixtures/events/account.updated.json +0 -37
- package/dist/testing/fixtures/events/checkout.completed.json +0 -36
- package/dist/testing/fixtures/events/checkout.expired.json +0 -26
- package/dist/testing/fixtures/events/checkout.failed.json +0 -27
- package/dist/testing/fixtures/events/invoice.created.json +0 -37
- package/dist/testing/fixtures/events/invoice.issued.json +0 -38
- package/dist/testing/fixtures/events/invoice.voided.json +0 -39
- package/dist/testing/fixtures/events/subscription.activated.json +0 -40
- package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +0 -38
- package/dist/testing/fixtures/events/subscription.canceled.json +0 -29
- package/dist/testing/fixtures/events/subscription.expired.json +0 -27
- package/dist/testing/fixtures/events/subscription.payment_failed.json +0 -38
- package/dist/testing/fixtures/events/subscription.reactivated.json +0 -36
- package/dist/testing/fixtures/events/subscription.renewed.json +0 -39
- package/dist/testing/fixtures/events/subscription.suspended.json +0 -36
- package/dist/testing/fixtures/events/subscription.terminated.json +0 -28
- package/dist/testing.d.ts +0 -626
- package/dist/testing.js +0 -3638
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r as MutationOptions } from "./_chunks/
|
|
4
|
-
import { r as StewardLogger, t as StewardLocale } from "./_chunks/locale.js";
|
|
1
|
+
import { Ba as CheckoutStatus, La as CheckoutSessionCreated, Pa as CheckoutSessionCreateInput, ba as PortalSession, di as CheckoutSessionResponse, ka as CheckoutPrefill, xa as PortalSessionCreateInput, xc as Interval, yo as AccountBenefit } from "./_chunks/index.js";
|
|
2
|
+
import { O as AccountInclude, U as AccountState, Y as BillingProfile, a as BillingEvent, f as EventType, n as AnyBillingEvent, o as BillingEventOf, u as EventDetail } from "./_chunks/events.js";
|
|
3
|
+
import { r as StewardLogger, s as MutationOptions, t as StewardLocale } from "./_chunks/locale.js";
|
|
5
4
|
import { a as HeaderSource, s as VerifyRawFailure } from "./_chunks/webhook-core.js";
|
|
6
5
|
import "./_chunks/webhook.js";
|
|
7
6
|
//#region src/server/checkout.d.ts
|
|
@@ -148,6 +147,35 @@ type NotificationHookArgs<T extends CauseEventType, S extends HookState = HookSt
|
|
|
148
147
|
/** `includeProfile: true` ise steward'dan okunan fatura profili (e-posta; K15). */
|
|
149
148
|
profile?: BillingProfile | null;
|
|
150
149
|
};
|
|
150
|
+
/** Benefit grant types with a dedicated hook (`onBenefitGranted` / `onBenefitRevoked` / `onBenefitCycled`). */
|
|
151
|
+
type BenefitHookEventType = "benefit_grant.created" | "benefit_grant.revoked" | "benefit_grant.cycled";
|
|
152
|
+
type BenefitHookArgs<T extends BenefitHookEventType, S extends HookState = HookState> = {
|
|
153
|
+
ref: string;
|
|
154
|
+
cause: T;
|
|
155
|
+
/** The benefit grant event itself (the hook does not run for an `account.state_changed`, which carries no benefit). */
|
|
156
|
+
event: BillingEventOf<T>;
|
|
157
|
+
/** `event.data.detail.benefit`: the benefit as granted or revoked at the time of the event. */
|
|
158
|
+
benefit: AccountBenefit;
|
|
159
|
+
/** Grant log row id (`event.data.detail.grantId`). */
|
|
160
|
+
grantId: string;
|
|
161
|
+
/** The delivery's full state (live with refetch): `state.benefits` is the current set. */
|
|
162
|
+
state: S;
|
|
163
|
+
};
|
|
164
|
+
/** `onBenefitCycled` (`benefit_grant.cycled`): the renewed `meter_credit` grant and its new meter period. */
|
|
165
|
+
type BenefitCycledHookArgs<S extends HookState = HookState> = BenefitHookArgs<"benefit_grant.cycled", S> & {
|
|
166
|
+
periodStart: string;
|
|
167
|
+
periodEnd: string;
|
|
168
|
+
};
|
|
169
|
+
/** `onMeterThreshold` (`meter.threshold_crossed`, cause hook). */
|
|
170
|
+
type MeterThresholdHookArgs<S extends HookState = HookState> = CauseHookArgs<"meter.threshold_crossed", S> & {
|
|
171
|
+
/** The event's detail when the event itself was delivered; `null` for an `account.state_changed` caused by it. */
|
|
172
|
+
threshold: EventDetail<"meter.threshold_crossed"> | null;
|
|
173
|
+
};
|
|
174
|
+
/** `onMeterPeriodClosed` (`meter.period_closed`, cause hook). */
|
|
175
|
+
type MeterPeriodClosedHookArgs<S extends HookState = HookState> = CauseHookArgs<"meter.period_closed", S> & {
|
|
176
|
+
/** The event's detail when the event itself was delivered; `null` for an `account.state_changed` caused by it. */
|
|
177
|
+
period: EventDetail<"meter.period_closed"> | null;
|
|
178
|
+
};
|
|
151
179
|
type UnknownEventArgs<S extends HookState = HookState> = {
|
|
152
180
|
ref: string;
|
|
153
181
|
cause: string;
|
|
@@ -187,7 +215,13 @@ type WebhooksCache = {
|
|
|
187
215
|
invalidate?(ref: string): unknown;
|
|
188
216
|
};
|
|
189
217
|
type CauseHooks<S extends HookState> = { [T in CauseEventType as EventHookName<T>]?: Hook<CauseHookArgs<T, S>>; };
|
|
190
|
-
type WebhooksOptions<S extends HookState = HookState> = CauseHooks<S> & {
|
|
218
|
+
type WebhooksOptions<S extends HookState = HookState> = Omit<CauseHooks<S>, "onMeterPeriodClosed"> & {
|
|
219
|
+
/** `meter.period_closed` (cause hook); `period` is the event's detail when the event itself was delivered. */
|
|
220
|
+
onMeterPeriodClosed?: Hook<MeterPeriodClosedHookArgs<S>>;
|
|
221
|
+
/** A meter's standing changed (`meter.threshold_crossed`, cause hook); after `onMeterThresholdCrossed`. */
|
|
222
|
+
onMeterThreshold?: Hook<MeterThresholdHookArgs<S>>;
|
|
223
|
+
/** A `meter_credit` grant was renewed (`benefit_grant.cycled`; the endpoint must list the type). After `onBenefitGrantCycled`. */
|
|
224
|
+
onBenefitCycled?: Hook<BenefitCycledHookArgs<S>>;
|
|
191
225
|
/** İmza sırları; metinse virgülle "yeni,eski". Verilmezse her teslimatta `STEWARD_WEBHOOK_SECRET`. */
|
|
192
226
|
secrets?: string | readonly string[];
|
|
193
227
|
/** Zaman damgası penceresi, saniye (varsayılan 300). */
|
|
@@ -207,6 +241,10 @@ type WebhooksOptions<S extends HookState = HookState> = CauseHooks<S> & {
|
|
|
207
241
|
onPaymentFailed?: Hook<NotificationHookArgs<"subscription.payment_failed", S>>;
|
|
208
242
|
onSuspended?: Hook<NotificationHookArgs<"subscription.suspended", S>>;
|
|
209
243
|
onTerminated?: Hook<NotificationHookArgs<"subscription.terminated", S>>;
|
|
244
|
+
/** A benefit was granted (`benefit_grant.created`; the endpoint must list the type). After `onBenefitGrantCreated`. */
|
|
245
|
+
onBenefitGranted?: Hook<BenefitHookArgs<"benefit_grant.created", S>>;
|
|
246
|
+
/** A benefit was revoked (`benefit_grant.revoked`; the endpoint must list the type). After `onBenefitGrantRevoked`. */
|
|
247
|
+
onBenefitRevoked?: Hook<BenefitHookArgs<"benefit_grant.revoked", S>>;
|
|
210
248
|
onUnknownEvent?: Hook<UnknownEventArgs<S>>;
|
|
211
249
|
/** Diğer hook'lardan sonra, her teslimatta (tekrar dahil; `"ignore"` hariç); ör. ağlara yayılma. */
|
|
212
250
|
after?: Hook<AfterArgs<S>>;
|
|
@@ -233,4 +271,4 @@ export declare function Webhooks<const R extends boolean | undefined = undefined
|
|
|
233
271
|
steward?: St;
|
|
234
272
|
}): WebhooksHandler;
|
|
235
273
|
//#endregion
|
|
236
|
-
export type { AfterArgs, CauseEventType, CauseHookArgs, CheckoutCache, CheckoutCreateInput, CheckoutCreated, CheckoutHandler, CheckoutOptions, CheckoutResult, CheckoutSteward, ConsentDoc, CustomerPortalClient, CustomerPortalCreateArgs, CustomerPortalOptions, CustomerPortalSteward, EventHookName, HookState, NotificationHookArgs, StateChangedArgs, UnknownEventArgs, WebhookErrorCode, WebhookHandled, WebhookRequest, WebhookResult, WebhooksCache, WebhooksHandler, WebhooksHookState, WebhooksOptions, WebhooksSteward };
|
|
274
|
+
export type { AfterArgs, BenefitCycledHookArgs, BenefitHookArgs, BenefitHookEventType, CauseEventType, CauseHookArgs, CheckoutCache, CheckoutCreateInput, CheckoutCreated, CheckoutHandler, CheckoutOptions, CheckoutResult, CheckoutSteward, ConsentDoc, CustomerPortalClient, CustomerPortalCreateArgs, CustomerPortalOptions, CustomerPortalSteward, EventHookName, HookState, MeterPeriodClosedHookArgs, MeterThresholdHookArgs, NotificationHookArgs, StateChangedArgs, UnknownEventArgs, WebhookErrorCode, WebhookHandled, WebhookRequest, WebhookResult, WebhooksCache, WebhooksHandler, WebhooksHookState, WebhooksOptions, WebhooksSteward };
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Gn as IdSchema, Hn as ExternalRefSchema, Mn as ActorRefSchema, a as EVENT_TYPES, l as PING_EVENT_TYPE, r as BillingEventSchema, t as AnyBillingEventSchema, u as PingSchema, w as AccountStateSchema } from "./_chunks/events.js";
|
|
2
2
|
import "./_chunks/src.js";
|
|
3
3
|
import { n as StewardConfigError, r as StewardContractError, t as StewardApiError } from "./_chunks/errors.js";
|
|
4
4
|
import { i as verifyWebhookRaw } from "./_chunks/webhook.js";
|
|
@@ -126,6 +126,12 @@ const NOTIFICATION_HOOKS = {
|
|
|
126
126
|
"subscription.suspended": "onSuspended",
|
|
127
127
|
"subscription.terminated": "onTerminated"
|
|
128
128
|
};
|
|
129
|
+
const BENEFIT_HOOKS = {
|
|
130
|
+
"benefit_grant.created": "onBenefitGranted",
|
|
131
|
+
"benefit_grant.revoked": "onBenefitRevoked",
|
|
132
|
+
"benefit_grant.cycled": "onBenefitCycled"
|
|
133
|
+
};
|
|
134
|
+
const isBenefitHookEvent = (event) => Object.hasOwn(BENEFIT_HOOKS, event.type);
|
|
129
135
|
const CAUSE_TYPES = new Set(EVENT_TYPES.filter((t) => t !== "account.state_changed"));
|
|
130
136
|
const KNOWN_TYPES = new Set(EVENT_TYPES);
|
|
131
137
|
const isCauseType = (value) => CAUSE_TYPES.has(value);
|
|
@@ -282,12 +288,33 @@ function Webhooks(input) {
|
|
|
282
288
|
event: d.event,
|
|
283
289
|
state: d.state
|
|
284
290
|
};
|
|
285
|
-
|
|
291
|
+
const causeArgs = d.causeType === "meter.period_closed" ? {
|
|
292
|
+
...args,
|
|
293
|
+
period: d.event.type === "meter.period_closed" ? d.event.data.detail : null
|
|
294
|
+
} : args;
|
|
295
|
+
await hooks[eventHookName(d.causeType)]?.(causeArgs);
|
|
286
296
|
const notification = NOTIFICATION_HOOKS[d.causeType];
|
|
287
297
|
if (notification) await hooks[notification]?.(profile === void 0 ? args : {
|
|
288
298
|
...args,
|
|
289
299
|
profile
|
|
290
300
|
});
|
|
301
|
+
if (isBenefitHookEvent(d.event)) {
|
|
302
|
+
const { benefit, grantId } = d.event.data.detail;
|
|
303
|
+
const period = d.event.type === "benefit_grant.cycled" ? {
|
|
304
|
+
periodStart: d.event.data.detail.periodStart,
|
|
305
|
+
periodEnd: d.event.data.detail.periodEnd
|
|
306
|
+
} : {};
|
|
307
|
+
await hooks[BENEFIT_HOOKS[d.event.type]]?.({
|
|
308
|
+
...args,
|
|
309
|
+
benefit,
|
|
310
|
+
grantId,
|
|
311
|
+
...period
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (d.causeType === "meter.threshold_crossed") await hooks.onMeterThreshold?.({
|
|
315
|
+
...args,
|
|
316
|
+
threshold: d.event.type === "meter.threshold_crossed" ? d.event.data.detail : null
|
|
317
|
+
});
|
|
291
318
|
}
|
|
292
319
|
const handled = d.state ? "received" : "no_state";
|
|
293
320
|
await options.after?.({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stewardhq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Steward SDK: contract schemas, typed API client and webhook signing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,6 @@
|
|
|
33
33
|
"types": "./dist/webhook/web.d.ts",
|
|
34
34
|
"default": "./dist/webhook/web.js"
|
|
35
35
|
},
|
|
36
|
-
"./testing": {
|
|
37
|
-
"types": "./dist/testing.d.ts",
|
|
38
|
-
"default": "./dist/testing.js"
|
|
39
|
-
},
|
|
40
|
-
"./testing/fixtures/events/*": "./dist/testing/fixtures/events/*",
|
|
41
36
|
"./package.json": "./package.json"
|
|
42
37
|
},
|
|
43
38
|
"files": [
|
|
@@ -45,8 +40,7 @@
|
|
|
45
40
|
],
|
|
46
41
|
"publishConfig": {
|
|
47
42
|
"access": "public",
|
|
48
|
-
"registry": "https://registry.npmjs.org"
|
|
49
|
-
"provenance": true
|
|
43
|
+
"registry": "https://registry.npmjs.org"
|
|
50
44
|
},
|
|
51
45
|
"dependencies": {
|
|
52
46
|
"zod": "^4.0.0"
|
|
@@ -55,9 +49,9 @@
|
|
|
55
49
|
"@types/node": "^24.13.3",
|
|
56
50
|
"tsdown": "^0.23.0",
|
|
57
51
|
"typescript": "^5.9.0",
|
|
58
|
-
"vitest": "^
|
|
52
|
+
"vitest": "^5.0.1",
|
|
59
53
|
"workerd": "^1.20260916.1",
|
|
60
|
-
"@steward/contract": "0.
|
|
54
|
+
"@steward/contract": "0.4.0"
|
|
61
55
|
},
|
|
62
56
|
"scripts": {
|
|
63
57
|
"build": "tsdown && node scripts/check-dist.mjs",
|
|
@@ -1,189 +0,0 @@
|
|
|
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";
|
|
3
|
-
//#region ../contract/src/client.d.ts
|
|
4
|
-
type CallOptions = {
|
|
5
|
-
idempotencyKey?: string;
|
|
6
|
-
actorRef?: string;
|
|
7
|
-
};
|
|
8
|
-
/** `getAccountState` sonucu: 304'te gövde yok, elindeki durum güncel. */
|
|
9
|
-
type AccountStateRead = {
|
|
10
|
-
notModified: false;
|
|
11
|
-
etag: string | null;
|
|
12
|
-
state: AccountState;
|
|
13
|
-
} | {
|
|
14
|
-
notModified: true;
|
|
15
|
-
etag: string;
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/retry.d.ts
|
|
19
|
-
type RetryClass = "network" | "5xx" | "429";
|
|
20
|
-
type RetryOptions = {
|
|
21
|
-
/** İlk istekten sonraki en çok tekrar sayısı; 0 kapatır. Varsayılan 2. */
|
|
22
|
-
attempts?: number;
|
|
23
|
-
/** Tekrar denenen hata sınıfları. Varsayılan hepsi. */
|
|
24
|
-
on?: readonly RetryClass[];
|
|
25
|
-
/** Tek bir beklemenin üst sınırı (Retry-After dahil), ms. Varsayılan 5000. */
|
|
26
|
-
maxDelayMs?: number;
|
|
27
|
-
/** Test için: bekleme. Varsayılan `setTimeout`. */
|
|
28
|
-
sleep?: (ms: number) => Promise<void>;
|
|
29
|
-
/** Test için: jitter kaynağı, [0, 1). Varsayılan `Math.random`. */
|
|
30
|
-
random?: () => number;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/steward.d.ts
|
|
34
|
-
type StewardEnv = Readonly<Record<string, string | undefined>>;
|
|
35
|
-
type StewardOptions = {
|
|
36
|
-
/** Varsayılan `STEWARD_URL`. Ürün adresi ve anahtarı ikisi de yoksa ve admin ayarları tamsa istemci yalnızca `admin.*` içindir. */
|
|
37
|
-
baseUrl?: string;
|
|
38
|
-
/** Varsayılan `STEWARD_API_KEY`. */
|
|
39
|
-
apiKey?: string;
|
|
40
|
-
/** Ayarların okunduğu ortam; varsayılan `process.env` (varsa). */
|
|
41
|
-
env?: StewardEnv;
|
|
42
|
-
fetch?: typeof fetch;
|
|
43
|
-
/** Deneme başına zaman aşımı, ms. Varsayılan 10 sn. */
|
|
44
|
-
timeoutMs?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Mutasyonlarda varsayılan `X-Actor-Ref` (ör. `system`); çağrıdaki `actorRef` ezer. İkisi de
|
|
47
|
-
* yoksa mutasyon istek göndermeden `StewardConfigError` (`actor_ref_required`) fırlatır.
|
|
48
|
-
*/
|
|
49
|
-
actorRef?: string;
|
|
50
|
-
/** Varsayılan `STEWARD_ADMIN_URL`; yalnızca `admin.*` için. */
|
|
51
|
-
adminBaseUrl?: string;
|
|
52
|
-
/** Varsayılan `STEWARD_ADMIN_API_KEY`; yalnızca `admin.*` için. */
|
|
53
|
-
adminApiKey?: string;
|
|
54
|
-
retries?: RetryOptions;
|
|
55
|
-
};
|
|
56
|
-
/** Mutasyon çağrısı seçenekleri: `Idempotency-Key` ve `X-Actor-Ref`. */
|
|
57
|
-
type MutationOptions = CallOptions;
|
|
58
|
-
/** Koşullu katalog okuması: 304'te gövde yok, elindeki katalog güncel. */
|
|
59
|
-
type CatalogRead = {
|
|
60
|
-
notModified: false;
|
|
61
|
-
etag: string | null;
|
|
62
|
-
catalog: Catalog;
|
|
63
|
-
} | {
|
|
64
|
-
notModified: true;
|
|
65
|
-
etag: string;
|
|
66
|
-
};
|
|
67
|
-
type InvoiceDocument = {
|
|
68
|
-
contentType: string;
|
|
69
|
-
bytes: Uint8Array;
|
|
70
|
-
};
|
|
71
|
-
/** `GET /v1/me`: anahtarın ürünü ve kapsamı (kurulum doğrulaması). */
|
|
72
|
-
type StewardMe = {
|
|
73
|
-
product: string;
|
|
74
|
-
keyName: string;
|
|
75
|
-
scope: "product" | "admin";
|
|
76
|
-
};
|
|
77
|
-
type Steward = {
|
|
78
|
-
accounts: {
|
|
79
|
-
/** `PUT /v1/accounts/{ref}` — hesabı oluşturur ya da günceller. */
|
|
80
|
-
upsert(ref: string, input: AccountUpsertInput, options?: MutationOptions): Promise<AccountUpsertResponse>;
|
|
81
|
-
get(ref: string, options?: {
|
|
82
|
-
include?: readonly AccountInclude[];
|
|
83
|
-
}): Promise<AccountDetail>;
|
|
84
|
-
/** `GET /v1/accounts/{ref}/state`. */
|
|
85
|
-
state(ref: string): Promise<AccountState>;
|
|
86
|
-
/** Koşullu durum okuması (önbellekler için): `etag` verilir ve durum değişmediyse `{notModified: true}`. */
|
|
87
|
-
readState(ref: string, options?: {
|
|
88
|
-
etag?: string;
|
|
89
|
-
}): Promise<AccountStateRead>;
|
|
90
|
-
/**
|
|
91
|
-
* `PUT /v1/accounts/{ref}/plan` — atomik plan (K6): aktif plan grant'leri tek plan
|
|
92
|
-
* grant'iyle değişir, `planCode: null` kaldırır. Canlı abonelik planı hedefi
|
|
93
|
-
* geçiyorsa `mode: "ensure"` (varsayılan) sonuç + `warnings`, `"strict"`
|
|
94
|
-
* `StewardApiError` `subscription_plan_higher` (409). Yanıttaki `account` önbelleğe `prime` edilebilir.
|
|
95
|
-
*/
|
|
96
|
-
setPlan(ref: string, input: PlanSetInput, options?: MutationOptions): Promise<PlanSetResponse>;
|
|
97
|
-
/** `POST /v1/accounts/{ref}/resync` — saklı durumu `account.state_changed` (`cause: "resync"`) olarak yeniden yayınlar; version değişmez. */
|
|
98
|
-
resync(ref: string, options?: MutationOptions): Promise<ResyncResult>;
|
|
99
|
-
/**
|
|
100
|
-
* `DELETE /v1/accounts/{ref}` — KVKK anonimleştirme (F4e): profil ve kişisel veri silinir,
|
|
101
|
-
* faturalar kalır → `{ref, deletedAt}`. Sonra hesabın her ucu `account_deleted` (410; aynı
|
|
102
|
-
* ref'le `upsert` dahil). Canlı abonelikte `subscription_active` (409; önce `immediate`
|
|
103
|
-
* iptal), formu açık checkout'ta `checkout_in_progress` (409; süresi dolunca tekrar);
|
|
104
|
-
* zaten silinmişse `account_deleted` — iş tekrarında başarı sayılabilir.
|
|
105
|
-
*/
|
|
106
|
-
delete(ref: string, options?: MutationOptions): Promise<AccountDeleteResponse>;
|
|
107
|
-
};
|
|
108
|
-
checkoutSessions: {
|
|
109
|
-
create(ref: string, input: CheckoutSessionCreateInput, options?: MutationOptions): Promise<CheckoutSessionCreated>;
|
|
110
|
-
get(id: string): Promise<CheckoutSessionResponse>;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Hosted müşteri portalı (F3a): `POST /v1/accounts/{ref}/portal-sessions` → `{id, url, expiresAt}`.
|
|
114
|
-
* Tarayıcı `url`e yönlendirilir (iptal, ödemeyi yeniden dene, fatura, profil steward'da).
|
|
115
|
-
* Yetki üründe; `actorRef` portalı açan kullanıcı. Durum değişmez, event yok.
|
|
116
|
-
*/
|
|
117
|
-
portalSessions: {
|
|
118
|
-
create(ref: string, input?: PortalSessionCreateInput, options?: MutationOptions): Promise<PortalSession>;
|
|
119
|
-
};
|
|
120
|
-
subscriptions: {
|
|
121
|
-
cancel(id: string, input: CancelSubscriptionInput, options?: MutationOptions): Promise<CancelSubscriptionResponse>;
|
|
122
|
-
};
|
|
123
|
-
grants: {
|
|
124
|
-
create(ref: string, input: GrantCreateInput, options?: MutationOptions): Promise<GrantCreateResponse>;
|
|
125
|
-
revoke(id: string, options?: MutationOptions): Promise<void>;
|
|
126
|
-
};
|
|
127
|
-
invoices: {
|
|
128
|
-
issue(id: string, input: InvoiceIssueInput, options?: MutationOptions): Promise<InvoiceIssueResponse>;
|
|
129
|
-
document(id: string): Promise<InvoiceDocument>;
|
|
130
|
-
/**
|
|
131
|
-
* `POST /v1/accounts/{ref}/invoices` (F4f) — manuel taslak fatura (Enterprise satışı); `issue` ile kesilir.
|
|
132
|
-
* Hesabın fatura profili gerekir (422 `billing_profile_required`). `invoice.created` yayınlanır, durum değişmez.
|
|
133
|
-
*/
|
|
134
|
-
createManual(ref: string, input: ManualInvoiceInput, options?: MutationOptions): Promise<ManualInvoiceResponse>;
|
|
135
|
-
/**
|
|
136
|
-
* `POST /v1/invoices/{id}/void` (F4f) — yalnızca manuel fatura (taslak ya da kesilmiş; numara ve belge kalır).
|
|
137
|
-
* Ödemeli fatura 409 `invoice_has_payment`, zaten void 409 `invoice_not_voidable`. `invoice.voided` yayınlanır.
|
|
138
|
-
*/
|
|
139
|
-
void(id: string, input: InvoiceVoidInput, options?: MutationOptions): Promise<InvoiceVoidResponse>;
|
|
140
|
-
};
|
|
141
|
-
catalog: {
|
|
142
|
-
get(): Promise<Catalog>;
|
|
143
|
-
/** Conditional read (`If-None-Match`); used by `steward catalog push` to report the current version. */
|
|
144
|
-
read(options?: {
|
|
145
|
-
etag?: string;
|
|
146
|
-
}): Promise<CatalogRead>;
|
|
147
|
-
};
|
|
148
|
-
stats(): Promise<Stats>;
|
|
149
|
-
me(): Promise<StewardMe>;
|
|
150
|
-
/**
|
|
151
|
-
* `GET /v1/doctor` — kurulum teşhisi (K11): katalog senkronu, sağlayıcı, ayarlar, hosted
|
|
152
|
-
* sayfa hazırlığı, endpoint teslimat teşhisi (`wrong_secret` = son teslimat 401),
|
|
153
|
-
* dunning ve `warnings[{code, severity, message}]`; `ok` = `error` önemde uyarı yok.
|
|
154
|
-
* Ürün anahtarıyla çalışır (yalnızca admin ayarlı istemcide admin anahtarıyla). Sağlayıcı
|
|
155
|
-
* sağlığı yanıtı veren pod'un gözlemidir.
|
|
156
|
-
*/
|
|
157
|
-
doctor(): Promise<DoctorReport>;
|
|
158
|
-
/** Admin kapsamlı uçlar: `adminBaseUrl`/`adminApiKey` (ya da `STEWARD_ADMIN_*`) gerekir. */
|
|
159
|
-
admin: {
|
|
160
|
-
catalog: {
|
|
161
|
-
sync(input: CatalogSyncInput, options?: MutationOptions): Promise<CatalogSyncResult>;
|
|
162
|
-
};
|
|
163
|
-
accounts: {
|
|
164
|
-
refresh(options?: MutationOptions): Promise<AccountsRefreshResult>;
|
|
165
|
-
};
|
|
166
|
-
settings: {
|
|
167
|
-
/** `GET /v1/admin/settings`. */
|
|
168
|
-
get(): Promise<ProductSettings>;
|
|
169
|
-
/** `PATCH /v1/admin/settings`: verilmeyen alan değişmez, `null` temizler, `branding` sığ birleşir. */
|
|
170
|
-
update(patch: ProductSettingsPatch, options?: MutationOptions): Promise<ProductSettings>;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Webhook endpoint'leri. Sırrı çağıran üretir (`generateWebhookSecret()`) ve
|
|
174
|
-
* saklar; steward hiçbir yanıtta geri vermez.
|
|
175
|
-
*/
|
|
176
|
-
endpoints: {
|
|
177
|
-
list(): Promise<WebhookEndpointList>;
|
|
178
|
-
/** `eventTypes` verilmezse yalnızca `account.state_changed`. */
|
|
179
|
-
create(input: WebhookEndpointCreateInput, options?: MutationOptions): Promise<WebhookEndpoint>;
|
|
180
|
-
/** Yeni sır; eskisi ürün geçişi bitene kadar ikinci imza olarak kalır. */
|
|
181
|
-
rotate(id: string, input: WebhookEndpointRotateInput, options?: MutationOptions): Promise<WebhookEndpoint>;
|
|
182
|
-
/** `status: inactive`; geri alınmaz (yeni endpoint açılır). */
|
|
183
|
-
deactivate(id: string, options?: MutationOptions): Promise<WebhookEndpoint>;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
declare function createSteward(options?: StewardOptions): Steward;
|
|
188
|
-
//#endregion
|
|
189
|
-
export { StewardEnv as a, createSteward as c, AccountStateRead as d, Steward as i, RetryClass as l, InvoiceDocument as n, StewardMe as o, MutationOptions as r, StewardOptions as s, CatalogRead as t, RetryOptions as u };
|