kaafil-js 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/client-entry.cjs +1782 -0
- package/dist/client-entry.cjs.map +1 -0
- package/dist/client-entry.d.cts +187 -0
- package/dist/client-entry.d.ts +187 -0
- package/dist/client-entry.js +1739 -0
- package/dist/client-entry.js.map +1 -0
- package/dist/index.cjs +3541 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2311 -0
- package/dist/index.d.ts +2311 -0
- package/dist/index.js +3458 -0
- package/dist/index.js.map +1 -0
- package/dist/paginator-CE9JhsLi.d.cts +24009 -0
- package/dist/paginator-CE9JhsLi.d.ts +24009 -0
- package/package.json +75 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { E as Environment, R as Resolvable, M as ManagerRefreshResult, A as AgencyAdminRefreshResult, V as VendorsResource, J as JourneyResource } from './paginator-CE9JhsLi.cjs';
|
|
2
|
+
export { B as BookingStatus, C as ClaimStatusIngest, a as CursorPageMeta, b as ERROR_CODE_TABLE, c as ErrorCodeTableEntry, d as EventType, F as FetchPage, G as Gender, K as KaafilAbortError, e as KaafilApiError, f as KaafilCapabilityUnavailableError, g as KaafilEntitlementError, h as KaafilError, i as KaafilErrorCode, j as KaafilErrorKind, k as KaafilInvalidRequestError, l as KaafilLockedError, m as KaafilNetworkError, n as KaafilNotFoundError, o as KaafilNotImplementedError, p as KaafilPagedResponse, q as KaafilPaginationError, r as KaafilPaginationExhaustedError, s as KaafilPaginationInFlightError, t as KaafilPaginator, u as KaafilRateLimitedError, v as KaafilReadOnlyRoleError, w as KaafilResponse, x as KaafilShareTokenExpiredError, y as KaafilShareTokenRevokedError, z as KaafilTimeoutError, D as KaafilTransportError, H as KaafilUnauthenticatedError, I as KaafilValidationError, L as KaafilVersionConflictError, N as ManagerRole, O as ManifestMode, P as OutboxClass, Q as PagedResponseMeta, S as PaginatorPage, T as PartyKind, U as PlanRefusalReason, W as ResponseMeta, X as Retryability, Y as TriggerAnchor, Z as TripMode, _ as TripStatus, $ as UnsatisfiableSchemeError, a0 as WaitUntilJourneyReadyOptions, a1 as isKaafilError, a2 as isRetryable } from './paginator-CE9JhsLi.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `KaafilClient` — the browser entry (`kaafil-js/client`).
|
|
6
|
+
* `architecture/08-sdk.md §2, §3.2, §3.3`.
|
|
7
|
+
*
|
|
8
|
+
* Kept as a separate module graph from `./client.ts`/`./index.ts` so it
|
|
9
|
+
* structurally CANNOT reach the API-key credential path — not by
|
|
10
|
+
* convention, by the shape of the import graph:
|
|
11
|
+
*
|
|
12
|
+
* - This file never imports `./client.ts` (the only place a
|
|
13
|
+
* `{ kind: 'apiKey', apiKey }` config is ever assembled) or `./index.ts`.
|
|
14
|
+
* - It never imports `./config.ts`'s API-key-specific exports —
|
|
15
|
+
* `assertApiKeyMatchesEnvironment`, `guardApiKeyEnvironment`,
|
|
16
|
+
* `ApiKeyEnvironmentMismatchError` — only `resolveBaseUrl`/
|
|
17
|
+
* `assertValidTimeout`/`assertValidMaxAttempts`, which every client needs,
|
|
18
|
+
* API key or not.
|
|
19
|
+
* - It builds `ManagerSessionCredentialConfig`/`ShareTokenCredentialConfig`/
|
|
20
|
+
* `AgencyAdminCredentialConfig` objects using the literal string kinds
|
|
21
|
+
* (`'managerSession'`/`'shareToken'`/`'agencyAdmin'`) rather than
|
|
22
|
+
* importing the shared `CredentialKind` value export from
|
|
23
|
+
* `./auth/credentials.ts` — that constant's own object literal carries the
|
|
24
|
+
* `'apiKey'` kind alongside the other three (one generated-adjacent table,
|
|
25
|
+
* not four separable ones), so importing it at all would pull that value
|
|
26
|
+
* into this bundle for no reason this file has.
|
|
27
|
+
*
|
|
28
|
+
* A bundler following only this file's import graph has no path to the code
|
|
29
|
+
* that turns an API-key string into a working credential. (`./auth/credentials.ts`'s
|
|
30
|
+
* `SECURITY_SCHEME_CARRIERS` table — shared infrastructure `CredentialResolver`
|
|
31
|
+
* needs to resolve a `managerAuth`/`shareAuth`/`agencyAdminAuth` *bearer*
|
|
32
|
+
* header just as much as an `apiKeyAuth` one — still carries the literal
|
|
33
|
+
* header name `X-API-Key` as inert data for the scheme this file never
|
|
34
|
+
* selects; that table is generated, single, and un-split, so its presence in
|
|
35
|
+
* this bundle is not evidence of a reachable API-key path. What this file
|
|
36
|
+
* cannot do, from its own code or anything it imports, is construct or
|
|
37
|
+
* validate an API-key credential, or reach the `Kaafil` class.)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface KaafilClientOptions {
|
|
41
|
+
readonly environment: Environment;
|
|
42
|
+
/** Overrides the environment's default base URL outright — see
|
|
43
|
+
* `./config.ts`'s `resolveBaseUrl` for why the two are never merged. */
|
|
44
|
+
readonly baseUrl?: string;
|
|
45
|
+
readonly timeoutMs?: number;
|
|
46
|
+
readonly maxAttempts?: number;
|
|
47
|
+
readonly userAgent?: string;
|
|
48
|
+
readonly random?: () => number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `session.open(...)`'s options — just the tokens a manager-token mint (or a
|
|
52
|
+
* prior refresh) already handed the host; never a URL, never a header.
|
|
53
|
+
* Rotation from here on is automatic (`./auth/credentials.ts`'s
|
|
54
|
+
* `CredentialResolver`, exchanging directly with the engine).
|
|
55
|
+
*/
|
|
56
|
+
interface OpenManagerSessionOptions {
|
|
57
|
+
readonly accessToken: Resolvable<string>;
|
|
58
|
+
readonly refreshToken: Resolvable<string>;
|
|
59
|
+
readonly expiresAt?: Resolvable<string>;
|
|
60
|
+
/** Persists the rotated pair after a successful refresh — the SDK keeps
|
|
61
|
+
* no state across a reload, so this is the host's one hook to survive one. */
|
|
62
|
+
readonly onRefresh?: (result: ManagerRefreshResult) => void | Promise<void>;
|
|
63
|
+
/** Overrides the direct engine exchange with an integrator-supplied one —
|
|
64
|
+
* see `./auth/credentials.ts`'s `ManagerSessionCredentialConfig.refresh`. */
|
|
65
|
+
readonly refresh?: (refreshToken: string) => Promise<ManagerRefreshResult>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `admin.open(...)`'s options — the agency-admin analogue of
|
|
69
|
+
* `OpenManagerSessionOptions` above: the access/refresh pair a server-side
|
|
70
|
+
* `kaafil.auth.mintAgencyAdminToken(...)` call (or a prior refresh) already
|
|
71
|
+
* handed the host. Rotation from here on is automatic, the same way a
|
|
72
|
+
* manager session's is (`./auth/credentials.ts`'s `CredentialResolver`,
|
|
73
|
+
* exchanging directly with the engine).
|
|
74
|
+
*/
|
|
75
|
+
interface OpenAgencyAdminSessionOptions {
|
|
76
|
+
readonly accessToken: Resolvable<string>;
|
|
77
|
+
readonly refreshToken: Resolvable<string>;
|
|
78
|
+
readonly expiresAt?: Resolvable<string>;
|
|
79
|
+
readonly onRefresh?: (result: AgencyAdminRefreshResult) => void | Promise<void>;
|
|
80
|
+
/** Overrides the direct engine exchange with an integrator-supplied one —
|
|
81
|
+
* see `./auth/credentials.ts`'s `AgencyAdminCredentialConfig.refresh`. */
|
|
82
|
+
readonly refresh?: (refreshToken: string) => Promise<AgencyAdminRefreshResult>;
|
|
83
|
+
}
|
|
84
|
+
/** `share.open(...)`'s options. */
|
|
85
|
+
interface OpenShareTokenOptions {
|
|
86
|
+
readonly token: Resolvable<string>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Thrown by `.vendors`/`.journey` before `session.open()`/`share.open()` has
|
|
90
|
+
* run, or after `close()`. There is no resource surface without a credential
|
|
91
|
+
* to resolve headers with, so this fails at the point of use rather than
|
|
92
|
+
* letting a call fall through to an unauthenticated request.
|
|
93
|
+
*/
|
|
94
|
+
declare class KaafilClientNotOpenError extends Error {
|
|
95
|
+
constructor();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown by `session.open()`/`share.open()` while a session is already open.
|
|
99
|
+
* `close()` first — silently replacing a live session out from under
|
|
100
|
+
* whatever the caller thought was still open is exactly the kind of
|
|
101
|
+
* ambiguity this SDK does not leave implicit.
|
|
102
|
+
*/
|
|
103
|
+
declare class KaafilClientAlreadyOpenError extends Error {
|
|
104
|
+
constructor();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The browser client. Constructed with only an `environment` — no
|
|
108
|
+
* credential yet, because none exists until a manager session, an
|
|
109
|
+
* agency-admin session, or a share token is minted server-side and handed
|
|
110
|
+
* to `session.open`/`admin.open`/`share.open`.
|
|
111
|
+
*
|
|
112
|
+
* Only `vendors` and `journey` are reachable from here: every other
|
|
113
|
+
* resource group built in this wave (`trips`, `auth`, `shareTokens`,
|
|
114
|
+
* `webhooks`, `events`) declares `apiKeyAuth` as its only accepted scheme in
|
|
115
|
+
* the vendored spec (`../generated/security.ts`'s `OPERATION_SECURITY`) —
|
|
116
|
+
* a scheme none of a manager session, an agency-admin session, or a share
|
|
117
|
+
* token can ever satisfy — so exposing them here would just be a way to
|
|
118
|
+
* reach `UnsatisfiableSchemeError` a resource-group at a time. `vendors`
|
|
119
|
+
* (`listTripVendors`) and `journey` (`readJourney`/`readJourneyCapabilities`/
|
|
120
|
+
* `listJourneyTriggers`/`patchJourneyTrigger`) both accept `apiKeyAuth` OR
|
|
121
|
+
* `managerAuth` OR `agencyAdminAuth` — genuinely reachable from either
|
|
122
|
+
* rotating session this file can open. Both are exposed uniformly for a
|
|
123
|
+
* `shareToken`-opened client too, rather than hand-branching per credential
|
|
124
|
+
* kind here: no operation in the current spec accepts `shareAuth` at all
|
|
125
|
+
* (verified — `grep shareAuth src/generated/security.ts` matches only the
|
|
126
|
+
* scheme's own declaration, never an operation's accepted-schemes list), so
|
|
127
|
+
* a share-opened client calling either today gets `UnsatisfiableSchemeError`
|
|
128
|
+
* from `CredentialResolver` itself; the moment a future spec revision adds a
|
|
129
|
+
* `shareAuth`-accepting operation to either group, it becomes reachable here
|
|
130
|
+
* with no change to this file, which is the entire point of leaving that
|
|
131
|
+
* decision to the resolver rather than duplicating the spec's scheme table
|
|
132
|
+
* as a second, hand-maintained gate here.
|
|
133
|
+
*/
|
|
134
|
+
declare class KaafilClient {
|
|
135
|
+
#private;
|
|
136
|
+
constructor(options: KaafilClientOptions);
|
|
137
|
+
readonly session: {
|
|
138
|
+
/**
|
|
139
|
+
* Opens a manager session with the access/refresh pair a server-side
|
|
140
|
+
* `kaafil.auth.mintManagerToken(...)` call already minted. Rotation
|
|
141
|
+
* after this point — pre-emptive, and on a `401` — is entirely
|
|
142
|
+
* automatic: `CredentialResolver` exchanges directly with the engine
|
|
143
|
+
* (`../auth/credentials.ts`, `../http/client.ts`'s
|
|
144
|
+
* `createManagerSessionRefreshExchange`). Nothing else is required —
|
|
145
|
+
* `refresh`/`onRefresh` above are optional hooks, not obligations.
|
|
146
|
+
*/
|
|
147
|
+
open: (options: OpenManagerSessionOptions) => void;
|
|
148
|
+
};
|
|
149
|
+
readonly admin: {
|
|
150
|
+
/**
|
|
151
|
+
* Opens an agency-admin session with the access/refresh pair a
|
|
152
|
+
* server-side `kaafil.auth.mintAgencyAdminToken(...)` call already
|
|
153
|
+
* minted. Rotation after this point — pre-emptive, and on a `401` — is
|
|
154
|
+
* entirely automatic, the same way `session.open`'s is:
|
|
155
|
+
* `CredentialResolver` exchanges directly with the engine
|
|
156
|
+
* (`../auth/credentials.ts`, `../http/client.ts`'s
|
|
157
|
+
* `createAgencyAdminSessionRefreshExchange`). Nothing else is required
|
|
158
|
+
* — `refresh`/`onRefresh` above are optional hooks, not obligations.
|
|
159
|
+
*/
|
|
160
|
+
open: (options: OpenAgencyAdminSessionOptions) => void;
|
|
161
|
+
};
|
|
162
|
+
readonly share: {
|
|
163
|
+
/** Opens a read-only session with a share token minted server-side by
|
|
164
|
+
* `kaafil.shareTokens.create(...)`. */
|
|
165
|
+
open: (options: OpenShareTokenOptions) => void;
|
|
166
|
+
};
|
|
167
|
+
get vendors(): VendorsResource;
|
|
168
|
+
get journey(): JourneyResource;
|
|
169
|
+
/**
|
|
170
|
+
* Total teardown. One assignment, no field to forget — see
|
|
171
|
+
* `KaafilClientState` above. Safe to call whether or not a session is
|
|
172
|
+
* open; calling any resource method afterward throws
|
|
173
|
+
* `KaafilClientNotOpenError`, and `session.open`/`share.open` can be
|
|
174
|
+
* called again immediately after.
|
|
175
|
+
*/
|
|
176
|
+
close(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Mints an idempotency key outside the normal per-call flow. Every
|
|
179
|
+
* mutating method already mints and reuses one automatically
|
|
180
|
+
* (`../http/client.ts`) — this exists for the rare case of pinning a key
|
|
181
|
+
* ahead of time, to replay the exact same logical operation across a
|
|
182
|
+
* process restart.
|
|
183
|
+
*/
|
|
184
|
+
static newIdempotencyKey(): string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { AgencyAdminRefreshResult, Environment, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, ManagerRefreshResult, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenShareTokenOptions, Resolvable, VendorsResource };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { E as Environment, R as Resolvable, M as ManagerRefreshResult, A as AgencyAdminRefreshResult, V as VendorsResource, J as JourneyResource } from './paginator-CE9JhsLi.js';
|
|
2
|
+
export { B as BookingStatus, C as ClaimStatusIngest, a as CursorPageMeta, b as ERROR_CODE_TABLE, c as ErrorCodeTableEntry, d as EventType, F as FetchPage, G as Gender, K as KaafilAbortError, e as KaafilApiError, f as KaafilCapabilityUnavailableError, g as KaafilEntitlementError, h as KaafilError, i as KaafilErrorCode, j as KaafilErrorKind, k as KaafilInvalidRequestError, l as KaafilLockedError, m as KaafilNetworkError, n as KaafilNotFoundError, o as KaafilNotImplementedError, p as KaafilPagedResponse, q as KaafilPaginationError, r as KaafilPaginationExhaustedError, s as KaafilPaginationInFlightError, t as KaafilPaginator, u as KaafilRateLimitedError, v as KaafilReadOnlyRoleError, w as KaafilResponse, x as KaafilShareTokenExpiredError, y as KaafilShareTokenRevokedError, z as KaafilTimeoutError, D as KaafilTransportError, H as KaafilUnauthenticatedError, I as KaafilValidationError, L as KaafilVersionConflictError, N as ManagerRole, O as ManifestMode, P as OutboxClass, Q as PagedResponseMeta, S as PaginatorPage, T as PartyKind, U as PlanRefusalReason, W as ResponseMeta, X as Retryability, Y as TriggerAnchor, Z as TripMode, _ as TripStatus, $ as UnsatisfiableSchemeError, a0 as WaitUntilJourneyReadyOptions, a1 as isKaafilError, a2 as isRetryable } from './paginator-CE9JhsLi.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `KaafilClient` — the browser entry (`kaafil-js/client`).
|
|
6
|
+
* `architecture/08-sdk.md §2, §3.2, §3.3`.
|
|
7
|
+
*
|
|
8
|
+
* Kept as a separate module graph from `./client.ts`/`./index.ts` so it
|
|
9
|
+
* structurally CANNOT reach the API-key credential path — not by
|
|
10
|
+
* convention, by the shape of the import graph:
|
|
11
|
+
*
|
|
12
|
+
* - This file never imports `./client.ts` (the only place a
|
|
13
|
+
* `{ kind: 'apiKey', apiKey }` config is ever assembled) or `./index.ts`.
|
|
14
|
+
* - It never imports `./config.ts`'s API-key-specific exports —
|
|
15
|
+
* `assertApiKeyMatchesEnvironment`, `guardApiKeyEnvironment`,
|
|
16
|
+
* `ApiKeyEnvironmentMismatchError` — only `resolveBaseUrl`/
|
|
17
|
+
* `assertValidTimeout`/`assertValidMaxAttempts`, which every client needs,
|
|
18
|
+
* API key or not.
|
|
19
|
+
* - It builds `ManagerSessionCredentialConfig`/`ShareTokenCredentialConfig`/
|
|
20
|
+
* `AgencyAdminCredentialConfig` objects using the literal string kinds
|
|
21
|
+
* (`'managerSession'`/`'shareToken'`/`'agencyAdmin'`) rather than
|
|
22
|
+
* importing the shared `CredentialKind` value export from
|
|
23
|
+
* `./auth/credentials.ts` — that constant's own object literal carries the
|
|
24
|
+
* `'apiKey'` kind alongside the other three (one generated-adjacent table,
|
|
25
|
+
* not four separable ones), so importing it at all would pull that value
|
|
26
|
+
* into this bundle for no reason this file has.
|
|
27
|
+
*
|
|
28
|
+
* A bundler following only this file's import graph has no path to the code
|
|
29
|
+
* that turns an API-key string into a working credential. (`./auth/credentials.ts`'s
|
|
30
|
+
* `SECURITY_SCHEME_CARRIERS` table — shared infrastructure `CredentialResolver`
|
|
31
|
+
* needs to resolve a `managerAuth`/`shareAuth`/`agencyAdminAuth` *bearer*
|
|
32
|
+
* header just as much as an `apiKeyAuth` one — still carries the literal
|
|
33
|
+
* header name `X-API-Key` as inert data for the scheme this file never
|
|
34
|
+
* selects; that table is generated, single, and un-split, so its presence in
|
|
35
|
+
* this bundle is not evidence of a reachable API-key path. What this file
|
|
36
|
+
* cannot do, from its own code or anything it imports, is construct or
|
|
37
|
+
* validate an API-key credential, or reach the `Kaafil` class.)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface KaafilClientOptions {
|
|
41
|
+
readonly environment: Environment;
|
|
42
|
+
/** Overrides the environment's default base URL outright — see
|
|
43
|
+
* `./config.ts`'s `resolveBaseUrl` for why the two are never merged. */
|
|
44
|
+
readonly baseUrl?: string;
|
|
45
|
+
readonly timeoutMs?: number;
|
|
46
|
+
readonly maxAttempts?: number;
|
|
47
|
+
readonly userAgent?: string;
|
|
48
|
+
readonly random?: () => number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `session.open(...)`'s options — just the tokens a manager-token mint (or a
|
|
52
|
+
* prior refresh) already handed the host; never a URL, never a header.
|
|
53
|
+
* Rotation from here on is automatic (`./auth/credentials.ts`'s
|
|
54
|
+
* `CredentialResolver`, exchanging directly with the engine).
|
|
55
|
+
*/
|
|
56
|
+
interface OpenManagerSessionOptions {
|
|
57
|
+
readonly accessToken: Resolvable<string>;
|
|
58
|
+
readonly refreshToken: Resolvable<string>;
|
|
59
|
+
readonly expiresAt?: Resolvable<string>;
|
|
60
|
+
/** Persists the rotated pair after a successful refresh — the SDK keeps
|
|
61
|
+
* no state across a reload, so this is the host's one hook to survive one. */
|
|
62
|
+
readonly onRefresh?: (result: ManagerRefreshResult) => void | Promise<void>;
|
|
63
|
+
/** Overrides the direct engine exchange with an integrator-supplied one —
|
|
64
|
+
* see `./auth/credentials.ts`'s `ManagerSessionCredentialConfig.refresh`. */
|
|
65
|
+
readonly refresh?: (refreshToken: string) => Promise<ManagerRefreshResult>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `admin.open(...)`'s options — the agency-admin analogue of
|
|
69
|
+
* `OpenManagerSessionOptions` above: the access/refresh pair a server-side
|
|
70
|
+
* `kaafil.auth.mintAgencyAdminToken(...)` call (or a prior refresh) already
|
|
71
|
+
* handed the host. Rotation from here on is automatic, the same way a
|
|
72
|
+
* manager session's is (`./auth/credentials.ts`'s `CredentialResolver`,
|
|
73
|
+
* exchanging directly with the engine).
|
|
74
|
+
*/
|
|
75
|
+
interface OpenAgencyAdminSessionOptions {
|
|
76
|
+
readonly accessToken: Resolvable<string>;
|
|
77
|
+
readonly refreshToken: Resolvable<string>;
|
|
78
|
+
readonly expiresAt?: Resolvable<string>;
|
|
79
|
+
readonly onRefresh?: (result: AgencyAdminRefreshResult) => void | Promise<void>;
|
|
80
|
+
/** Overrides the direct engine exchange with an integrator-supplied one —
|
|
81
|
+
* see `./auth/credentials.ts`'s `AgencyAdminCredentialConfig.refresh`. */
|
|
82
|
+
readonly refresh?: (refreshToken: string) => Promise<AgencyAdminRefreshResult>;
|
|
83
|
+
}
|
|
84
|
+
/** `share.open(...)`'s options. */
|
|
85
|
+
interface OpenShareTokenOptions {
|
|
86
|
+
readonly token: Resolvable<string>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Thrown by `.vendors`/`.journey` before `session.open()`/`share.open()` has
|
|
90
|
+
* run, or after `close()`. There is no resource surface without a credential
|
|
91
|
+
* to resolve headers with, so this fails at the point of use rather than
|
|
92
|
+
* letting a call fall through to an unauthenticated request.
|
|
93
|
+
*/
|
|
94
|
+
declare class KaafilClientNotOpenError extends Error {
|
|
95
|
+
constructor();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown by `session.open()`/`share.open()` while a session is already open.
|
|
99
|
+
* `close()` first — silently replacing a live session out from under
|
|
100
|
+
* whatever the caller thought was still open is exactly the kind of
|
|
101
|
+
* ambiguity this SDK does not leave implicit.
|
|
102
|
+
*/
|
|
103
|
+
declare class KaafilClientAlreadyOpenError extends Error {
|
|
104
|
+
constructor();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The browser client. Constructed with only an `environment` — no
|
|
108
|
+
* credential yet, because none exists until a manager session, an
|
|
109
|
+
* agency-admin session, or a share token is minted server-side and handed
|
|
110
|
+
* to `session.open`/`admin.open`/`share.open`.
|
|
111
|
+
*
|
|
112
|
+
* Only `vendors` and `journey` are reachable from here: every other
|
|
113
|
+
* resource group built in this wave (`trips`, `auth`, `shareTokens`,
|
|
114
|
+
* `webhooks`, `events`) declares `apiKeyAuth` as its only accepted scheme in
|
|
115
|
+
* the vendored spec (`../generated/security.ts`'s `OPERATION_SECURITY`) —
|
|
116
|
+
* a scheme none of a manager session, an agency-admin session, or a share
|
|
117
|
+
* token can ever satisfy — so exposing them here would just be a way to
|
|
118
|
+
* reach `UnsatisfiableSchemeError` a resource-group at a time. `vendors`
|
|
119
|
+
* (`listTripVendors`) and `journey` (`readJourney`/`readJourneyCapabilities`/
|
|
120
|
+
* `listJourneyTriggers`/`patchJourneyTrigger`) both accept `apiKeyAuth` OR
|
|
121
|
+
* `managerAuth` OR `agencyAdminAuth` — genuinely reachable from either
|
|
122
|
+
* rotating session this file can open. Both are exposed uniformly for a
|
|
123
|
+
* `shareToken`-opened client too, rather than hand-branching per credential
|
|
124
|
+
* kind here: no operation in the current spec accepts `shareAuth` at all
|
|
125
|
+
* (verified — `grep shareAuth src/generated/security.ts` matches only the
|
|
126
|
+
* scheme's own declaration, never an operation's accepted-schemes list), so
|
|
127
|
+
* a share-opened client calling either today gets `UnsatisfiableSchemeError`
|
|
128
|
+
* from `CredentialResolver` itself; the moment a future spec revision adds a
|
|
129
|
+
* `shareAuth`-accepting operation to either group, it becomes reachable here
|
|
130
|
+
* with no change to this file, which is the entire point of leaving that
|
|
131
|
+
* decision to the resolver rather than duplicating the spec's scheme table
|
|
132
|
+
* as a second, hand-maintained gate here.
|
|
133
|
+
*/
|
|
134
|
+
declare class KaafilClient {
|
|
135
|
+
#private;
|
|
136
|
+
constructor(options: KaafilClientOptions);
|
|
137
|
+
readonly session: {
|
|
138
|
+
/**
|
|
139
|
+
* Opens a manager session with the access/refresh pair a server-side
|
|
140
|
+
* `kaafil.auth.mintManagerToken(...)` call already minted. Rotation
|
|
141
|
+
* after this point — pre-emptive, and on a `401` — is entirely
|
|
142
|
+
* automatic: `CredentialResolver` exchanges directly with the engine
|
|
143
|
+
* (`../auth/credentials.ts`, `../http/client.ts`'s
|
|
144
|
+
* `createManagerSessionRefreshExchange`). Nothing else is required —
|
|
145
|
+
* `refresh`/`onRefresh` above are optional hooks, not obligations.
|
|
146
|
+
*/
|
|
147
|
+
open: (options: OpenManagerSessionOptions) => void;
|
|
148
|
+
};
|
|
149
|
+
readonly admin: {
|
|
150
|
+
/**
|
|
151
|
+
* Opens an agency-admin session with the access/refresh pair a
|
|
152
|
+
* server-side `kaafil.auth.mintAgencyAdminToken(...)` call already
|
|
153
|
+
* minted. Rotation after this point — pre-emptive, and on a `401` — is
|
|
154
|
+
* entirely automatic, the same way `session.open`'s is:
|
|
155
|
+
* `CredentialResolver` exchanges directly with the engine
|
|
156
|
+
* (`../auth/credentials.ts`, `../http/client.ts`'s
|
|
157
|
+
* `createAgencyAdminSessionRefreshExchange`). Nothing else is required
|
|
158
|
+
* — `refresh`/`onRefresh` above are optional hooks, not obligations.
|
|
159
|
+
*/
|
|
160
|
+
open: (options: OpenAgencyAdminSessionOptions) => void;
|
|
161
|
+
};
|
|
162
|
+
readonly share: {
|
|
163
|
+
/** Opens a read-only session with a share token minted server-side by
|
|
164
|
+
* `kaafil.shareTokens.create(...)`. */
|
|
165
|
+
open: (options: OpenShareTokenOptions) => void;
|
|
166
|
+
};
|
|
167
|
+
get vendors(): VendorsResource;
|
|
168
|
+
get journey(): JourneyResource;
|
|
169
|
+
/**
|
|
170
|
+
* Total teardown. One assignment, no field to forget — see
|
|
171
|
+
* `KaafilClientState` above. Safe to call whether or not a session is
|
|
172
|
+
* open; calling any resource method afterward throws
|
|
173
|
+
* `KaafilClientNotOpenError`, and `session.open`/`share.open` can be
|
|
174
|
+
* called again immediately after.
|
|
175
|
+
*/
|
|
176
|
+
close(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Mints an idempotency key outside the normal per-call flow. Every
|
|
179
|
+
* mutating method already mints and reuses one automatically
|
|
180
|
+
* (`../http/client.ts`) — this exists for the rare case of pinning a key
|
|
181
|
+
* ahead of time, to replay the exact same logical operation across a
|
|
182
|
+
* process restart.
|
|
183
|
+
*/
|
|
184
|
+
static newIdempotencyKey(): string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { AgencyAdminRefreshResult, Environment, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, ManagerRefreshResult, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenShareTokenOptions, Resolvable, VendorsResource };
|