@xylex-group/athena 2.13.0 → 3.0.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 +91 -1398
- package/bin/athena-js.js +0 -0
- package/dist/admin.d.cts +1 -1
- package/dist/admin.d.ts +1 -1
- package/dist/billing.cjs +1199 -0
- package/dist/billing.cjs.map +1 -0
- package/dist/billing.d.cts +230 -0
- package/dist/billing.d.ts +230 -0
- package/dist/billing.js +1194 -0
- package/dist/billing.js.map +1 -0
- package/dist/browser.cjs +8934 -8075
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +11 -10
- package/dist/browser.d.ts +11 -10
- package/dist/browser.js +8931 -8073
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +8328 -7062
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -4
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +8328 -7062
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +9391 -8526
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +9384 -8524
- package/dist/index.js.map +1 -1
- package/dist/{model-form-Dw4zEL5a.d.cts → model-form-BEfCGB5b.d.cts} +2 -2
- package/dist/{model-form-yRg71q3H.d.ts → model-form-BKetpu6Q.d.ts} +2 -2
- package/dist/module-8dSMcy0K.d.cts +326 -0
- package/dist/module-8dSMcy0K.d.ts +326 -0
- package/dist/{module-DBteUIob.d.ts → module-Bef_MAPO.d.ts} +6 -52
- package/dist/{module-yoX49uQC.d.cts → module-CrrSmpML.d.cts} +6 -52
- package/dist/next/client.cjs +2 -8668
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +1 -27
- package/dist/next/client.d.ts +1 -27
- package/dist/next/client.js +3 -8668
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +79 -8779
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +30 -46
- package/dist/next/server.d.ts +30 -46
- package/dist/next/server.js +79 -8779
- package/dist/next/server.js.map +1 -1
- package/dist/{payload-DEOWN_oo.d.ts → payload-DWI1rw-e.d.cts} +1 -35
- package/dist/{payload-BzVbUgY_.d.cts → payload-DWI1rw-e.d.ts} +1 -35
- package/dist/{pipeline-Bj6RWt1A.d.ts → pipeline-BXFQbsUW.d.ts} +1 -1
- package/dist/{pipeline-Dwck-wZO.d.cts → pipeline-Dfsed4VD.d.cts} +1 -1
- package/dist/react.cjs +114 -13
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +46 -16
- package/dist/react.d.ts +46 -16
- package/dist/react.js +113 -14
- package/dist/react.js.map +1 -1
- package/dist/social-providers.cjs +33 -24
- package/dist/social-providers.cjs.map +1 -1
- package/dist/social-providers.d.cts +79 -82
- package/dist/social-providers.d.ts +79 -82
- package/dist/social-providers.js +33 -24
- package/dist/social-providers.js.map +1 -1
- package/dist/{types-eAKAh71s.d.cts → types-AOY-GLu8.d.cts} +27 -54
- package/dist/{types-eAKAh71s.d.ts → types-AOY-GLu8.d.ts} +27 -54
- package/dist/{types-CH78O90i.d.cts → types-Bltx6iL6.d.cts} +4 -6
- package/dist/{types-CH78O90i.d.ts → types-Bltx6iL6.d.ts} +4 -6
- package/dist/{types-DPgejxYC.d.ts → types-CK7cBQbC.d.ts} +2 -2
- package/dist/{types-CjC9_5ZQ.d.cts → types-Z3-rsiM3.d.cts} +2 -2
- package/dist/{types-BRP7sfSF.d.ts → types-jClgDy1J.d.ts} +2 -2
- package/dist/{types-BU8uJH_b.d.cts → types-kO_Ut5wU.d.cts} +2 -2
- package/dist/utils.cjs +7 -8
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -5
- package/dist/utils.d.ts +2 -5
- package/dist/utils.js +7 -8
- package/dist/utils.js.map +1 -1
- package/dist/{client-DVOKSYDI.d.ts → v3-client-CuCNy-JJ.d.ts} +532 -470
- package/dist/{client-BJjUwDSg.d.cts → v3-client-G8JMOilK.d.cts} +532 -470
- package/package.json +31 -21
package/dist/billing.cjs
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// package.json
|
|
4
|
+
var package_default = {
|
|
5
|
+
version: "3.0.0"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/sdk-version.ts
|
|
9
|
+
var PACKAGE_VERSION = package_default.version;
|
|
10
|
+
function buildSdkHeaderValue(sdkName) {
|
|
11
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/cookies/cookie-utils.ts
|
|
15
|
+
var SECURE_COOKIE_PREFIX = "__Secure-";
|
|
16
|
+
function parseCookies(cookieHeader) {
|
|
17
|
+
const cookies = cookieHeader.split("; ");
|
|
18
|
+
const cookieMap = /* @__PURE__ */ new Map();
|
|
19
|
+
cookies.forEach((cookie) => {
|
|
20
|
+
const [name, value] = cookie.split(/=(.*)/s);
|
|
21
|
+
cookieMap.set(name, value);
|
|
22
|
+
});
|
|
23
|
+
return cookieMap;
|
|
24
|
+
}
|
|
25
|
+
var getSessionCookie = (request, config) => {
|
|
26
|
+
const cookies = (request instanceof Headers || !("headers" in request) ? request : request.headers).get("cookie");
|
|
27
|
+
if (!cookies) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const { cookieName = "session_token", cookiePrefix = "athena-auth" } = {};
|
|
31
|
+
const parsedCookie = parseCookies(cookies);
|
|
32
|
+
const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
|
|
33
|
+
const candidateCookieNames = Array.from(/* @__PURE__ */ new Set([
|
|
34
|
+
cookieName,
|
|
35
|
+
cookieName.replace(/_/g, "-"),
|
|
36
|
+
cookieName.replace(/-/g, "_")
|
|
37
|
+
])).filter(Boolean);
|
|
38
|
+
for (const candidateName of candidateCookieNames) {
|
|
39
|
+
const sessionToken = getCookie(`${cookiePrefix}.${candidateName}`) || getCookie(`${cookiePrefix}-${candidateName}`);
|
|
40
|
+
if (sessionToken) {
|
|
41
|
+
return sessionToken;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/utils/athena-request-headers.ts
|
|
48
|
+
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
49
|
+
var API_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key", "X-Api-Key", "x-api-key", "apikey"];
|
|
50
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
51
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
52
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
53
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
54
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
55
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
56
|
+
var PROFILE_RULES = {
|
|
57
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
58
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
59
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
60
|
+
auth: { apiKeys: true, routing: true, authMirror: false, authBearer: true, contentType: true },
|
|
61
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
62
|
+
};
|
|
63
|
+
function normalizeHeaderValue(value) {
|
|
64
|
+
return value ? value : void 0;
|
|
65
|
+
}
|
|
66
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
67
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
68
|
+
}
|
|
69
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
70
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
71
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
72
|
+
}
|
|
73
|
+
function resolveHeaderValue(headers, candidates) {
|
|
74
|
+
for (const candidate of candidates) {
|
|
75
|
+
const direct = normalizeHeaderValue(headers[candidate]);
|
|
76
|
+
if (direct) return direct;
|
|
77
|
+
}
|
|
78
|
+
const loweredCandidates = new Set(candidates.map((candidate) => candidate.toLowerCase()));
|
|
79
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
80
|
+
if (!loweredCandidates.has(key.toLowerCase())) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const normalized = normalizeHeaderValue(value);
|
|
84
|
+
if (normalized) return normalized;
|
|
85
|
+
}
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
function isCacheControlHeaderName(name) {
|
|
89
|
+
return name.toLowerCase() === "cache-control";
|
|
90
|
+
}
|
|
91
|
+
function normalizeBearerToken(value) {
|
|
92
|
+
const trimmed = value.trim();
|
|
93
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
94
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
95
|
+
}
|
|
96
|
+
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
97
|
+
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
98
|
+
if (!authorization) {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
const token = normalizeBearerToken(authorization);
|
|
102
|
+
return token ? token : void 0;
|
|
103
|
+
}
|
|
104
|
+
function resolveSessionTokenFromCookieHeader(headers) {
|
|
105
|
+
const cookie = resolveHeaderValue(headers, ["Cookie"]);
|
|
106
|
+
if (!cookie) {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
110
|
+
}
|
|
111
|
+
function resolveBackendType(backend) {
|
|
112
|
+
if (!backend) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
116
|
+
}
|
|
117
|
+
function applyAthenaApiKeyHeaders(headers, apiKey) {
|
|
118
|
+
const resolvedApiKey = normalizeHeaderValue(apiKey);
|
|
119
|
+
if (resolvedApiKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
120
|
+
headers["X-Athena-Key"] = resolvedApiKey;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
124
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
125
|
+
const rules = PROFILE_RULES[input.profile];
|
|
126
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
127
|
+
if (explicitCookie) {
|
|
128
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
129
|
+
}
|
|
130
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
131
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
132
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
133
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
134
|
+
headers.Cookie = explicitCookie;
|
|
135
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
136
|
+
headers.Cookie = cookieFromHeaders;
|
|
137
|
+
}
|
|
138
|
+
const explicitBearerToken = (() => {
|
|
139
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
140
|
+
if (configured) {
|
|
141
|
+
return normalizeBearerToken(configured);
|
|
142
|
+
}
|
|
143
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
144
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
145
|
+
})();
|
|
146
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
147
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
148
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
149
|
+
}
|
|
150
|
+
if (rules.authMirror) {
|
|
151
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
152
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
153
|
+
}
|
|
154
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
155
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
156
|
+
}
|
|
157
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
158
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
162
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
163
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
164
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
165
|
+
headers["x-pg-uri"] = pgUri;
|
|
166
|
+
}
|
|
167
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
168
|
+
if (jdbcUrl) {
|
|
169
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
170
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
171
|
+
}
|
|
172
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
173
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function buildAthenaRequestHeaders(input) {
|
|
178
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
179
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
180
|
+
const rules = PROFILE_RULES[input.profile];
|
|
181
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
182
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
183
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
184
|
+
const finalAthenaKey = resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
185
|
+
const headers = {
|
|
186
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
187
|
+
};
|
|
188
|
+
if (rules.contentType) {
|
|
189
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
190
|
+
}
|
|
191
|
+
if (input.accept ?? rules.accept) {
|
|
192
|
+
headers.Accept = input.accept ?? "application/json";
|
|
193
|
+
}
|
|
194
|
+
if (rules.routing) {
|
|
195
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
196
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
197
|
+
}
|
|
198
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
199
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
200
|
+
}
|
|
201
|
+
if (finalClient) {
|
|
202
|
+
headers["X-Athena-Client"] = finalClient;
|
|
203
|
+
}
|
|
204
|
+
const backendType = resolveBackendType(input.backend);
|
|
205
|
+
if (backendType) {
|
|
206
|
+
headers["X-Backend-Type"] = backendType;
|
|
207
|
+
}
|
|
208
|
+
if (typeof input.stripNulls === "boolean") {
|
|
209
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
210
|
+
} else if (rules.stripNullsDefault) {
|
|
211
|
+
headers["X-Strip-Nulls"] = "true";
|
|
212
|
+
}
|
|
213
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
214
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
218
|
+
applyAthenaApiKeyHeaders(headers, finalAthenaKey);
|
|
219
|
+
}
|
|
220
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
221
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
222
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
223
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
224
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const normalized = normalizeHeaderValue(value);
|
|
231
|
+
if (normalized) {
|
|
232
|
+
headers[key] = normalized;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
if (forceNoCache) {
|
|
236
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
237
|
+
}
|
|
238
|
+
return headers;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/gateway/errors.ts
|
|
242
|
+
var AthenaGatewayError = class _AthenaGatewayError extends Error {
|
|
243
|
+
code;
|
|
244
|
+
status;
|
|
245
|
+
endpoint;
|
|
246
|
+
method;
|
|
247
|
+
requestId;
|
|
248
|
+
hint;
|
|
249
|
+
causeDetail;
|
|
250
|
+
constructor(input) {
|
|
251
|
+
super(input.message);
|
|
252
|
+
this.name = "AthenaGatewayError";
|
|
253
|
+
this.code = input.code;
|
|
254
|
+
this.status = input.status ?? 0;
|
|
255
|
+
this.endpoint = input.endpoint;
|
|
256
|
+
this.method = input.method;
|
|
257
|
+
this.requestId = input.requestId;
|
|
258
|
+
this.hint = input.hint;
|
|
259
|
+
this.causeDetail = input.cause;
|
|
260
|
+
}
|
|
261
|
+
toDetails() {
|
|
262
|
+
return {
|
|
263
|
+
code: this.code,
|
|
264
|
+
message: this.message,
|
|
265
|
+
status: this.status,
|
|
266
|
+
endpoint: this.endpoint,
|
|
267
|
+
method: this.method,
|
|
268
|
+
requestId: this.requestId,
|
|
269
|
+
hint: this.hint,
|
|
270
|
+
cause: this.causeDetail
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
static fromResponse(response, fallback) {
|
|
274
|
+
const details = response.errorDetails;
|
|
275
|
+
if (details) {
|
|
276
|
+
return new _AthenaGatewayError({
|
|
277
|
+
code: details.code,
|
|
278
|
+
message: details.message,
|
|
279
|
+
status: details.status,
|
|
280
|
+
endpoint: details.endpoint ?? fallback.endpoint,
|
|
281
|
+
method: details.method ?? fallback.method,
|
|
282
|
+
requestId: details.requestId ?? fallback.requestId,
|
|
283
|
+
hint: details.hint,
|
|
284
|
+
cause: details.cause
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return new _AthenaGatewayError({
|
|
288
|
+
code: "HTTP_ERROR",
|
|
289
|
+
message: response.error ?? "Gateway request failed",
|
|
290
|
+
status: response.status,
|
|
291
|
+
endpoint: fallback.endpoint,
|
|
292
|
+
method: fallback.method,
|
|
293
|
+
requestId: fallback.requestId
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// src/gateway/url.ts
|
|
299
|
+
function describeReceivedValue(value) {
|
|
300
|
+
if (value === void 0) return "undefined";
|
|
301
|
+
if (value === null) return "null";
|
|
302
|
+
if (typeof value === "string") {
|
|
303
|
+
return value.trim().length > 0 ? JSON.stringify(value) : "an empty string";
|
|
304
|
+
}
|
|
305
|
+
return `${typeof value} ${JSON.stringify(value)}`;
|
|
306
|
+
}
|
|
307
|
+
function invalidBaseUrlError(message, hint) {
|
|
308
|
+
return new AthenaGatewayError({
|
|
309
|
+
code: "INVALID_URL",
|
|
310
|
+
message,
|
|
311
|
+
status: 0,
|
|
312
|
+
hint
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function normalizeAthenaGatewayBaseUrl(input, options = {}) {
|
|
316
|
+
const label = options.label ?? "Athena gateway base URL";
|
|
317
|
+
const candidate = input ?? options.defaultBaseUrl;
|
|
318
|
+
if (candidate === void 0 || candidate === null) {
|
|
319
|
+
throw invalidBaseUrlError(
|
|
320
|
+
`${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(input)}.`,
|
|
321
|
+
'Set ATHENA_URL in the explicit env object (or pass createClient({ url, key })) to a full URL such as "https://mirror3.athena-db.com".'
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
const trimmed = candidate.trim();
|
|
325
|
+
if (!trimmed) {
|
|
326
|
+
throw invalidBaseUrlError(
|
|
327
|
+
`${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
|
|
328
|
+
'Set ATHENA_URL in the explicit env object (or pass createClient({ url, key })) to a full URL such as "https://mirror3.athena-db.com".'
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
let parsed;
|
|
332
|
+
try {
|
|
333
|
+
parsed = new URL(trimmed);
|
|
334
|
+
} catch {
|
|
335
|
+
throw invalidBaseUrlError(
|
|
336
|
+
`${label} must be a valid absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
|
|
337
|
+
'Use a full URL including the protocol, for example "https://mirror3.athena-db.com".'
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
341
|
+
throw invalidBaseUrlError(
|
|
342
|
+
`${label} must use http or https. Received ${JSON.stringify(trimmed)}.`,
|
|
343
|
+
'Use an Athena gateway URL such as "https://mirror3.athena-db.com".'
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
if (parsed.search || parsed.hash) {
|
|
347
|
+
throw invalidBaseUrlError(
|
|
348
|
+
`${label} must not include query parameters or hash fragments. Received ${JSON.stringify(trimmed)}.`,
|
|
349
|
+
'Pass only the base URL. Endpoint paths such as "/gateway/fetch" are appended by the SDK.'
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/billing/module.ts
|
|
356
|
+
var SDK_NAME = "xylex-group/athena-billing";
|
|
357
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
358
|
+
var AthenaBillingError = class extends Error {
|
|
359
|
+
status;
|
|
360
|
+
endpoint;
|
|
361
|
+
method;
|
|
362
|
+
body;
|
|
363
|
+
constructor(input) {
|
|
364
|
+
super(input.message);
|
|
365
|
+
this.name = "AthenaBillingError";
|
|
366
|
+
this.status = input.status;
|
|
367
|
+
this.endpoint = input.endpoint;
|
|
368
|
+
this.method = input.method;
|
|
369
|
+
this.body = input.body;
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
var billingSdkManifest = {
|
|
373
|
+
namespace: "billing",
|
|
374
|
+
envelopeKind: "athena",
|
|
375
|
+
methods: [
|
|
376
|
+
{ name: "getCapabilities", method: "GET", path: "/billing/v1/capabilities" },
|
|
377
|
+
{ name: "createCheckout", method: "POST", path: "/billing/v1/checkouts" },
|
|
378
|
+
{ name: "listCustomers", method: "GET", path: "/billing/v1/customers" },
|
|
379
|
+
{ name: "createCustomer", method: "POST", path: "/billing/v1/customers" },
|
|
380
|
+
{ name: "getCustomer", method: "GET", path: "/billing/v1/customers/{id}" },
|
|
381
|
+
{ name: "updateCustomer", method: "PATCH", path: "/billing/v1/customers/{id}" },
|
|
382
|
+
{ name: "deleteCustomer", method: "DELETE", path: "/billing/v1/customers/{id}" },
|
|
383
|
+
{ name: "listPayments", method: "GET", path: "/billing/v1/payments" },
|
|
384
|
+
{ name: "createPayment", method: "POST", path: "/billing/v1/payments" },
|
|
385
|
+
{ name: "getPayment", method: "GET", path: "/billing/v1/payments/{id}" },
|
|
386
|
+
{ name: "cancelPayment", method: "POST", path: "/billing/v1/payments/{id}/cancel" },
|
|
387
|
+
{ name: "listPaymentLinks", method: "GET", path: "/billing/v1/payment-links" },
|
|
388
|
+
{ name: "createPaymentLink", method: "POST", path: "/billing/v1/payment-links" },
|
|
389
|
+
{ name: "getPaymentLink", method: "GET", path: "/billing/v1/payment-links/{id}" },
|
|
390
|
+
{ name: "updatePaymentLink", method: "PATCH", path: "/billing/v1/payment-links/{id}" },
|
|
391
|
+
{ name: "deletePaymentLink", method: "DELETE", path: "/billing/v1/payment-links/{id}" },
|
|
392
|
+
{ name: "listRefunds", method: "GET", path: "/billing/v1/refunds" },
|
|
393
|
+
{ name: "createRefund", method: "POST", path: "/billing/v1/refunds" },
|
|
394
|
+
{ name: "getRefund", method: "GET", path: "/billing/v1/refunds/{id}" },
|
|
395
|
+
{ name: "cancelRefund", method: "POST", path: "/billing/v1/refunds/{id}/cancel" },
|
|
396
|
+
{ name: "listSubscriptions", method: "GET", path: "/billing/v1/subscriptions" },
|
|
397
|
+
{ name: "createSubscription", method: "POST", path: "/billing/v1/subscriptions" },
|
|
398
|
+
{ name: "getSubscription", method: "GET", path: "/billing/v1/subscriptions/{id}" },
|
|
399
|
+
{ name: "updateSubscription", method: "PATCH", path: "/billing/v1/subscriptions/{id}" },
|
|
400
|
+
{ name: "cancelSubscription", method: "POST", path: "/billing/v1/subscriptions/{id}/cancel" },
|
|
401
|
+
{ name: "listInvoices", method: "GET", path: "/billing/v1/invoices" },
|
|
402
|
+
{ name: "getInvoice", method: "GET", path: "/billing/v1/invoices/{id}" },
|
|
403
|
+
{
|
|
404
|
+
name: "listConnections",
|
|
405
|
+
method: "GET",
|
|
406
|
+
path: "/admin/billing/clients/{client_name}/connections"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: "createConnection",
|
|
410
|
+
method: "POST",
|
|
411
|
+
path: "/admin/billing/clients/{client_name}/connections"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
name: "getConnection",
|
|
415
|
+
method: "GET",
|
|
416
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "updateConnection",
|
|
420
|
+
method: "PATCH",
|
|
421
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}"
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "deleteConnection",
|
|
425
|
+
method: "DELETE",
|
|
426
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "reconcileDocument",
|
|
430
|
+
method: "POST",
|
|
431
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}/reconcile"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: "listWebhookEvents",
|
|
435
|
+
method: "GET",
|
|
436
|
+
path: "/admin/billing/clients/{client_name}/webhook-events"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: "provisionWebhookSinks",
|
|
440
|
+
method: "POST",
|
|
441
|
+
path: "/admin/billing/clients/{client_name}/webhook-sinks/provision"
|
|
442
|
+
},
|
|
443
|
+
{ name: "listGrants", method: "GET", path: "/admin/billing/grants" },
|
|
444
|
+
{ name: "listProviders", method: "GET", path: "/admin/billing/providers" },
|
|
445
|
+
{
|
|
446
|
+
name: "listSinkHelpers",
|
|
447
|
+
method: "GET",
|
|
448
|
+
path: "/admin/webhook-sinks/helpers/billing"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "ingestProviderWebhook",
|
|
452
|
+
method: "POST",
|
|
453
|
+
path: "/billing/providers/{provider}/clients/{client_name}/connections/{connection_id}/webhook"
|
|
454
|
+
},
|
|
455
|
+
{ name: "getDebugBilling", method: "GET", path: "/debug/billing" }
|
|
456
|
+
]
|
|
457
|
+
};
|
|
458
|
+
function withPathParam(path, name, value) {
|
|
459
|
+
return path.replace(`{${name}}`, encodeURIComponent(value));
|
|
460
|
+
}
|
|
461
|
+
function appendQuery(path, query) {
|
|
462
|
+
if (!query) return path;
|
|
463
|
+
const params = new URLSearchParams();
|
|
464
|
+
for (const [key, value] of Object.entries(query)) {
|
|
465
|
+
if (value === void 0 || value === null) continue;
|
|
466
|
+
params.set(key, String(value));
|
|
467
|
+
}
|
|
468
|
+
const serialized = params.toString();
|
|
469
|
+
return serialized ? `${path}?${serialized}` : path;
|
|
470
|
+
}
|
|
471
|
+
function connectionQuery(input) {
|
|
472
|
+
const query = {
|
|
473
|
+
connectionId: input.connectionId
|
|
474
|
+
};
|
|
475
|
+
if (input.clientName) query.clientName = input.clientName;
|
|
476
|
+
if ("cursor" in input && input.cursor) query.cursor = input.cursor;
|
|
477
|
+
if ("source" in input && input.source) query.source = input.source;
|
|
478
|
+
if ("limit" in input && input.limit !== void 0) query.limit = String(input.limit);
|
|
479
|
+
if ("offset" in input && input.offset !== void 0) query.offset = String(input.offset);
|
|
480
|
+
return query;
|
|
481
|
+
}
|
|
482
|
+
function parseEnvelopeData(body) {
|
|
483
|
+
if (body && typeof body === "object" && "data" in body) {
|
|
484
|
+
return body.data;
|
|
485
|
+
}
|
|
486
|
+
return body;
|
|
487
|
+
}
|
|
488
|
+
function createBillingModule(config) {
|
|
489
|
+
const baseUrl = normalizeAthenaGatewayBaseUrl(config.baseUrl, {
|
|
490
|
+
label: "Athena billing base URL"
|
|
491
|
+
});
|
|
492
|
+
const fetchImpl = config.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
493
|
+
async function call(method, path, body, options, responseType = "json") {
|
|
494
|
+
const headers = buildAthenaRequestHeaders({
|
|
495
|
+
profile: "gateway",
|
|
496
|
+
sdkHeaderValue: SDK_HEADER_VALUE,
|
|
497
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
498
|
+
client: config.client,
|
|
499
|
+
configHeaders: {
|
|
500
|
+
...config.headers ?? {}
|
|
501
|
+
},
|
|
502
|
+
callHeaders: options?.headers,
|
|
503
|
+
contentType: "application/json"
|
|
504
|
+
});
|
|
505
|
+
let requestBody;
|
|
506
|
+
if (body !== void 0 && body !== null) {
|
|
507
|
+
if (typeof body === "string" || body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof FormData || body instanceof URLSearchParams) {
|
|
508
|
+
requestBody = body;
|
|
509
|
+
} else {
|
|
510
|
+
requestBody = JSON.stringify(body);
|
|
511
|
+
if (!hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
512
|
+
headers["Content-Type"] = "application/json";
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
const targetUrl = `${baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
|
|
517
|
+
const response = await fetchImpl(targetUrl, {
|
|
518
|
+
method,
|
|
519
|
+
headers,
|
|
520
|
+
body: requestBody,
|
|
521
|
+
signal: options?.signal
|
|
522
|
+
});
|
|
523
|
+
if (responseType === "text") {
|
|
524
|
+
const text = await response.text();
|
|
525
|
+
if (!response.ok) {
|
|
526
|
+
throw new AthenaBillingError({
|
|
527
|
+
message: `Billing request failed (${response.status})`,
|
|
528
|
+
status: response.status,
|
|
529
|
+
endpoint: path,
|
|
530
|
+
method,
|
|
531
|
+
body: text
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
return text;
|
|
535
|
+
}
|
|
536
|
+
const rawText = await response.text();
|
|
537
|
+
let parsed = rawText;
|
|
538
|
+
if (rawText) {
|
|
539
|
+
try {
|
|
540
|
+
parsed = JSON.parse(rawText);
|
|
541
|
+
} catch {
|
|
542
|
+
parsed = rawText;
|
|
543
|
+
}
|
|
544
|
+
} else {
|
|
545
|
+
parsed = null;
|
|
546
|
+
}
|
|
547
|
+
if (!response.ok) {
|
|
548
|
+
const message = parsed && typeof parsed === "object" && "message" in parsed && typeof parsed.message === "string" ? parsed.message : `Billing request failed (${response.status})`;
|
|
549
|
+
throw new AthenaBillingError({
|
|
550
|
+
message,
|
|
551
|
+
status: response.status,
|
|
552
|
+
endpoint: path,
|
|
553
|
+
method,
|
|
554
|
+
body: parsed
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
return parseEnvelopeData(parsed);
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
getCapabilities(input, options) {
|
|
561
|
+
return call(
|
|
562
|
+
"GET",
|
|
563
|
+
appendQuery("/billing/v1/capabilities", connectionQuery(input)),
|
|
564
|
+
void 0,
|
|
565
|
+
options
|
|
566
|
+
);
|
|
567
|
+
},
|
|
568
|
+
createCheckout(body, options) {
|
|
569
|
+
return call("POST", "/billing/v1/checkouts", body, options);
|
|
570
|
+
},
|
|
571
|
+
listCustomers(input, options) {
|
|
572
|
+
return call(
|
|
573
|
+
"GET",
|
|
574
|
+
appendQuery("/billing/v1/customers", connectionQuery(input)),
|
|
575
|
+
void 0,
|
|
576
|
+
options
|
|
577
|
+
);
|
|
578
|
+
},
|
|
579
|
+
createCustomer(input, options) {
|
|
580
|
+
return call(
|
|
581
|
+
"POST",
|
|
582
|
+
"/billing/v1/customers",
|
|
583
|
+
{
|
|
584
|
+
connectionId: input.connectionId,
|
|
585
|
+
clientName: input.clientName,
|
|
586
|
+
email: input.email,
|
|
587
|
+
name: input.name,
|
|
588
|
+
metadata: input.metadata ?? {},
|
|
589
|
+
idempotencyKey: input.idempotencyKey
|
|
590
|
+
},
|
|
591
|
+
options
|
|
592
|
+
);
|
|
593
|
+
},
|
|
594
|
+
getCustomer(id, input, options) {
|
|
595
|
+
return call(
|
|
596
|
+
"GET",
|
|
597
|
+
appendQuery(
|
|
598
|
+
withPathParam("/billing/v1/customers/{id}", "id", id),
|
|
599
|
+
connectionQuery(input)
|
|
600
|
+
),
|
|
601
|
+
void 0,
|
|
602
|
+
options
|
|
603
|
+
);
|
|
604
|
+
},
|
|
605
|
+
updateCustomer(id, input, options) {
|
|
606
|
+
return call(
|
|
607
|
+
"PATCH",
|
|
608
|
+
withPathParam("/billing/v1/customers/{id}", "id", id),
|
|
609
|
+
{
|
|
610
|
+
connectionId: input.connectionId,
|
|
611
|
+
clientName: input.clientName,
|
|
612
|
+
email: input.email,
|
|
613
|
+
name: input.name
|
|
614
|
+
},
|
|
615
|
+
options
|
|
616
|
+
);
|
|
617
|
+
},
|
|
618
|
+
deleteCustomer(id, input, options) {
|
|
619
|
+
return call(
|
|
620
|
+
"DELETE",
|
|
621
|
+
appendQuery(
|
|
622
|
+
withPathParam("/billing/v1/customers/{id}", "id", id),
|
|
623
|
+
connectionQuery(input)
|
|
624
|
+
),
|
|
625
|
+
void 0,
|
|
626
|
+
options
|
|
627
|
+
);
|
|
628
|
+
},
|
|
629
|
+
listPayments(input, options) {
|
|
630
|
+
return call(
|
|
631
|
+
"GET",
|
|
632
|
+
appendQuery("/billing/v1/payments", connectionQuery(input)),
|
|
633
|
+
void 0,
|
|
634
|
+
options
|
|
635
|
+
);
|
|
636
|
+
},
|
|
637
|
+
createPayment(body, options) {
|
|
638
|
+
return call("POST", "/billing/v1/payments", body, options);
|
|
639
|
+
},
|
|
640
|
+
getPayment(id, input, options) {
|
|
641
|
+
return call(
|
|
642
|
+
"GET",
|
|
643
|
+
appendQuery(
|
|
644
|
+
withPathParam("/billing/v1/payments/{id}", "id", id),
|
|
645
|
+
connectionQuery(input)
|
|
646
|
+
),
|
|
647
|
+
void 0,
|
|
648
|
+
options
|
|
649
|
+
);
|
|
650
|
+
},
|
|
651
|
+
cancelPayment(id, input, options) {
|
|
652
|
+
return call(
|
|
653
|
+
"POST",
|
|
654
|
+
appendQuery(
|
|
655
|
+
withPathParam("/billing/v1/payments/{id}/cancel", "id", id),
|
|
656
|
+
connectionQuery(input)
|
|
657
|
+
),
|
|
658
|
+
{},
|
|
659
|
+
options
|
|
660
|
+
);
|
|
661
|
+
},
|
|
662
|
+
listPaymentLinks(input, options) {
|
|
663
|
+
return call(
|
|
664
|
+
"GET",
|
|
665
|
+
appendQuery("/billing/v1/payment-links", connectionQuery(input)),
|
|
666
|
+
void 0,
|
|
667
|
+
options
|
|
668
|
+
);
|
|
669
|
+
},
|
|
670
|
+
createPaymentLink(body, options) {
|
|
671
|
+
return call("POST", "/billing/v1/payment-links", body, options);
|
|
672
|
+
},
|
|
673
|
+
getPaymentLink(id, input, options) {
|
|
674
|
+
return call(
|
|
675
|
+
"GET",
|
|
676
|
+
appendQuery(
|
|
677
|
+
withPathParam("/billing/v1/payment-links/{id}", "id", id),
|
|
678
|
+
connectionQuery(input)
|
|
679
|
+
),
|
|
680
|
+
void 0,
|
|
681
|
+
options
|
|
682
|
+
);
|
|
683
|
+
},
|
|
684
|
+
updatePaymentLink(id, body, options) {
|
|
685
|
+
return call(
|
|
686
|
+
"PATCH",
|
|
687
|
+
withPathParam("/billing/v1/payment-links/{id}", "id", id),
|
|
688
|
+
body,
|
|
689
|
+
options
|
|
690
|
+
);
|
|
691
|
+
},
|
|
692
|
+
deletePaymentLink(id, input, options) {
|
|
693
|
+
return call(
|
|
694
|
+
"DELETE",
|
|
695
|
+
appendQuery(
|
|
696
|
+
withPathParam("/billing/v1/payment-links/{id}", "id", id),
|
|
697
|
+
connectionQuery(input)
|
|
698
|
+
),
|
|
699
|
+
void 0,
|
|
700
|
+
options
|
|
701
|
+
);
|
|
702
|
+
},
|
|
703
|
+
listRefunds(input, options) {
|
|
704
|
+
return call(
|
|
705
|
+
"GET",
|
|
706
|
+
appendQuery("/billing/v1/refunds", connectionQuery(input)),
|
|
707
|
+
void 0,
|
|
708
|
+
options
|
|
709
|
+
);
|
|
710
|
+
},
|
|
711
|
+
createRefund(body, options) {
|
|
712
|
+
return call("POST", "/billing/v1/refunds", body, options);
|
|
713
|
+
},
|
|
714
|
+
getRefund(id, input, options) {
|
|
715
|
+
return call(
|
|
716
|
+
"GET",
|
|
717
|
+
appendQuery(withPathParam("/billing/v1/refunds/{id}", "id", id), {
|
|
718
|
+
...connectionQuery(input),
|
|
719
|
+
...input.paymentId ? { paymentId: input.paymentId } : {}
|
|
720
|
+
}),
|
|
721
|
+
void 0,
|
|
722
|
+
options
|
|
723
|
+
);
|
|
724
|
+
},
|
|
725
|
+
cancelRefund(id, input, options) {
|
|
726
|
+
return call(
|
|
727
|
+
"POST",
|
|
728
|
+
appendQuery(withPathParam("/billing/v1/refunds/{id}/cancel", "id", id), {
|
|
729
|
+
...connectionQuery(input),
|
|
730
|
+
...input.paymentId ? { paymentId: input.paymentId } : {}
|
|
731
|
+
}),
|
|
732
|
+
{},
|
|
733
|
+
options
|
|
734
|
+
);
|
|
735
|
+
},
|
|
736
|
+
listSubscriptions(input, options) {
|
|
737
|
+
return call(
|
|
738
|
+
"GET",
|
|
739
|
+
appendQuery("/billing/v1/subscriptions", connectionQuery(input)),
|
|
740
|
+
void 0,
|
|
741
|
+
options
|
|
742
|
+
);
|
|
743
|
+
},
|
|
744
|
+
createSubscription(body, options) {
|
|
745
|
+
return call("POST", "/billing/v1/subscriptions", body, options);
|
|
746
|
+
},
|
|
747
|
+
getSubscription(id, input, options) {
|
|
748
|
+
return call(
|
|
749
|
+
"GET",
|
|
750
|
+
appendQuery(withPathParam("/billing/v1/subscriptions/{id}", "id", id), {
|
|
751
|
+
...connectionQuery(input),
|
|
752
|
+
...input.customerId ? { customerId: input.customerId } : {}
|
|
753
|
+
}),
|
|
754
|
+
void 0,
|
|
755
|
+
options
|
|
756
|
+
);
|
|
757
|
+
},
|
|
758
|
+
updateSubscription(id, body, options) {
|
|
759
|
+
return call(
|
|
760
|
+
"PATCH",
|
|
761
|
+
withPathParam("/billing/v1/subscriptions/{id}", "id", id),
|
|
762
|
+
body,
|
|
763
|
+
options
|
|
764
|
+
);
|
|
765
|
+
},
|
|
766
|
+
cancelSubscription(id, input, options) {
|
|
767
|
+
return call(
|
|
768
|
+
"POST",
|
|
769
|
+
appendQuery(withPathParam("/billing/v1/subscriptions/{id}/cancel", "id", id), {
|
|
770
|
+
...connectionQuery(input),
|
|
771
|
+
customerId: input.customerId
|
|
772
|
+
}),
|
|
773
|
+
{},
|
|
774
|
+
options
|
|
775
|
+
);
|
|
776
|
+
},
|
|
777
|
+
listInvoices(input, options) {
|
|
778
|
+
return call(
|
|
779
|
+
"GET",
|
|
780
|
+
appendQuery("/billing/v1/invoices", connectionQuery(input)),
|
|
781
|
+
void 0,
|
|
782
|
+
options
|
|
783
|
+
);
|
|
784
|
+
},
|
|
785
|
+
getInvoice(id, input, options) {
|
|
786
|
+
return call(
|
|
787
|
+
"GET",
|
|
788
|
+
appendQuery(
|
|
789
|
+
withPathParam("/billing/v1/invoices/{id}", "id", id),
|
|
790
|
+
connectionQuery(input)
|
|
791
|
+
),
|
|
792
|
+
void 0,
|
|
793
|
+
options
|
|
794
|
+
);
|
|
795
|
+
},
|
|
796
|
+
listConnections(clientName, options) {
|
|
797
|
+
return call(
|
|
798
|
+
"GET",
|
|
799
|
+
withPathParam("/admin/billing/clients/{client_name}/connections", "client_name", clientName),
|
|
800
|
+
void 0,
|
|
801
|
+
options
|
|
802
|
+
);
|
|
803
|
+
},
|
|
804
|
+
createConnection(clientName, input, options) {
|
|
805
|
+
return call(
|
|
806
|
+
"POST",
|
|
807
|
+
withPathParam("/admin/billing/clients/{client_name}/connections", "client_name", clientName),
|
|
808
|
+
{
|
|
809
|
+
ownerKind: input.ownerKind,
|
|
810
|
+
ownerId: input.ownerId,
|
|
811
|
+
provider: input.provider,
|
|
812
|
+
mode: input.mode,
|
|
813
|
+
status: input.status,
|
|
814
|
+
credentialKind: input.credentialKind,
|
|
815
|
+
providerAccountId: input.providerAccountId,
|
|
816
|
+
providerProfileId: input.providerProfileId,
|
|
817
|
+
scopes: input.scopes,
|
|
818
|
+
config: input.config,
|
|
819
|
+
metadata: input.metadata
|
|
820
|
+
},
|
|
821
|
+
options
|
|
822
|
+
);
|
|
823
|
+
},
|
|
824
|
+
getConnection(clientName, connectionId, options) {
|
|
825
|
+
return call(
|
|
826
|
+
"GET",
|
|
827
|
+
withPathParam(
|
|
828
|
+
withPathParam(
|
|
829
|
+
"/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
830
|
+
"client_name",
|
|
831
|
+
clientName
|
|
832
|
+
),
|
|
833
|
+
"connection_id",
|
|
834
|
+
connectionId
|
|
835
|
+
),
|
|
836
|
+
void 0,
|
|
837
|
+
options
|
|
838
|
+
);
|
|
839
|
+
},
|
|
840
|
+
updateConnection(clientName, connectionId, input, options) {
|
|
841
|
+
return call(
|
|
842
|
+
"PATCH",
|
|
843
|
+
withPathParam(
|
|
844
|
+
withPathParam(
|
|
845
|
+
"/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
846
|
+
"client_name",
|
|
847
|
+
clientName
|
|
848
|
+
),
|
|
849
|
+
"connection_id",
|
|
850
|
+
connectionId
|
|
851
|
+
),
|
|
852
|
+
input,
|
|
853
|
+
options
|
|
854
|
+
);
|
|
855
|
+
},
|
|
856
|
+
deleteConnection(clientName, connectionId, options) {
|
|
857
|
+
return call(
|
|
858
|
+
"DELETE",
|
|
859
|
+
withPathParam(
|
|
860
|
+
withPathParam(
|
|
861
|
+
"/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
862
|
+
"client_name",
|
|
863
|
+
clientName
|
|
864
|
+
),
|
|
865
|
+
"connection_id",
|
|
866
|
+
connectionId
|
|
867
|
+
),
|
|
868
|
+
void 0,
|
|
869
|
+
options
|
|
870
|
+
);
|
|
871
|
+
},
|
|
872
|
+
reconcileDocument(clientName, connectionId, input, options) {
|
|
873
|
+
return call(
|
|
874
|
+
"POST",
|
|
875
|
+
withPathParam(
|
|
876
|
+
withPathParam(
|
|
877
|
+
"/admin/billing/clients/{client_name}/connections/{connection_id}/reconcile",
|
|
878
|
+
"client_name",
|
|
879
|
+
clientName
|
|
880
|
+
),
|
|
881
|
+
"connection_id",
|
|
882
|
+
connectionId
|
|
883
|
+
),
|
|
884
|
+
{
|
|
885
|
+
resourceKind: input.resourceKind,
|
|
886
|
+
resourceId: input.resourceId,
|
|
887
|
+
customerId: input.customerId
|
|
888
|
+
},
|
|
889
|
+
options
|
|
890
|
+
);
|
|
891
|
+
},
|
|
892
|
+
listWebhookEvents(clientName, options) {
|
|
893
|
+
return call(
|
|
894
|
+
"GET",
|
|
895
|
+
withPathParam(
|
|
896
|
+
"/admin/billing/clients/{client_name}/webhook-events",
|
|
897
|
+
"client_name",
|
|
898
|
+
clientName
|
|
899
|
+
),
|
|
900
|
+
void 0,
|
|
901
|
+
options
|
|
902
|
+
);
|
|
903
|
+
},
|
|
904
|
+
provisionWebhookSinks(clientName, input, options) {
|
|
905
|
+
return call(
|
|
906
|
+
"POST",
|
|
907
|
+
appendQuery(
|
|
908
|
+
withPathParam(
|
|
909
|
+
"/admin/billing/clients/{client_name}/webhook-sinks/provision",
|
|
910
|
+
"client_name",
|
|
911
|
+
clientName
|
|
912
|
+
),
|
|
913
|
+
{
|
|
914
|
+
targetSchema: input?.targetSchema,
|
|
915
|
+
instance: input?.instance
|
|
916
|
+
}
|
|
917
|
+
),
|
|
918
|
+
{},
|
|
919
|
+
options
|
|
920
|
+
);
|
|
921
|
+
},
|
|
922
|
+
listGrants(options) {
|
|
923
|
+
return call("GET", "/admin/billing/grants", void 0, options);
|
|
924
|
+
},
|
|
925
|
+
listProviders(options) {
|
|
926
|
+
return call("GET", "/admin/billing/providers", void 0, options);
|
|
927
|
+
},
|
|
928
|
+
listSinkHelpers(query, options) {
|
|
929
|
+
return call(
|
|
930
|
+
"GET",
|
|
931
|
+
appendQuery("/admin/webhook-sinks/helpers/billing", {
|
|
932
|
+
targetSchema: query?.targetSchema,
|
|
933
|
+
instance: query?.instance
|
|
934
|
+
}),
|
|
935
|
+
void 0,
|
|
936
|
+
options
|
|
937
|
+
);
|
|
938
|
+
},
|
|
939
|
+
ingestProviderWebhook(input, options) {
|
|
940
|
+
const path = withPathParam(
|
|
941
|
+
withPathParam(
|
|
942
|
+
withPathParam(
|
|
943
|
+
"/billing/providers/{provider}/clients/{client_name}/connections/{connection_id}/webhook",
|
|
944
|
+
"provider",
|
|
945
|
+
input.provider
|
|
946
|
+
),
|
|
947
|
+
"client_name",
|
|
948
|
+
input.clientName
|
|
949
|
+
),
|
|
950
|
+
"connection_id",
|
|
951
|
+
input.connectionId
|
|
952
|
+
);
|
|
953
|
+
return call("POST", path, input.body, {
|
|
954
|
+
...options,
|
|
955
|
+
headers: {
|
|
956
|
+
...options?.headers ?? {},
|
|
957
|
+
...input.signatureHeaders ?? {}
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
},
|
|
961
|
+
getDebugBilling(jwtSecret, options) {
|
|
962
|
+
return call(
|
|
963
|
+
"GET",
|
|
964
|
+
appendQuery("/debug/billing", { jwt_secret: jwtSecret }),
|
|
965
|
+
void 0,
|
|
966
|
+
options,
|
|
967
|
+
"text"
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// src/billing/live-http-routes.json
|
|
974
|
+
var live_http_routes_default = {
|
|
975
|
+
consumers: [
|
|
976
|
+
"openapi.yaml",
|
|
977
|
+
"openapi.json",
|
|
978
|
+
"packages/athena-js billingSdkManifest",
|
|
979
|
+
"tests/billing_contract_spine.rs"
|
|
980
|
+
],
|
|
981
|
+
description: "Live Athena billing HTTP surface. Owned by athena_billing::live_http_routes (Rust). Export with: cargo run -p athena-billing --bin billing-contract-spine -- --write",
|
|
982
|
+
domain: "billing",
|
|
983
|
+
routes: [
|
|
984
|
+
{
|
|
985
|
+
method: "GET",
|
|
986
|
+
path: "/admin/billing/clients/{client_name}/connections",
|
|
987
|
+
surface: "admin"
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
method: "POST",
|
|
991
|
+
path: "/admin/billing/clients/{client_name}/connections",
|
|
992
|
+
surface: "admin"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
method: "DELETE",
|
|
996
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
997
|
+
surface: "admin"
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
method: "GET",
|
|
1001
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
1002
|
+
surface: "admin"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
method: "PATCH",
|
|
1006
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}",
|
|
1007
|
+
surface: "admin"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
method: "POST",
|
|
1011
|
+
path: "/admin/billing/clients/{client_name}/connections/{connection_id}/reconcile",
|
|
1012
|
+
surface: "admin"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
method: "GET",
|
|
1016
|
+
path: "/admin/billing/clients/{client_name}/webhook-events",
|
|
1017
|
+
surface: "admin"
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
method: "POST",
|
|
1021
|
+
path: "/admin/billing/clients/{client_name}/webhook-sinks/provision",
|
|
1022
|
+
surface: "admin"
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
method: "GET",
|
|
1026
|
+
path: "/admin/billing/grants",
|
|
1027
|
+
surface: "admin"
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
method: "GET",
|
|
1031
|
+
path: "/admin/billing/providers",
|
|
1032
|
+
surface: "admin"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
method: "GET",
|
|
1036
|
+
path: "/admin/webhook-sinks/helpers/billing",
|
|
1037
|
+
surface: "admin"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
method: "POST",
|
|
1041
|
+
path: "/billing/providers/{provider}/clients/{client_name}/connections/{connection_id}/webhook",
|
|
1042
|
+
surface: "providerWebhook"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
method: "GET",
|
|
1046
|
+
path: "/billing/v1/capabilities",
|
|
1047
|
+
surface: "billingV1"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
method: "POST",
|
|
1051
|
+
path: "/billing/v1/checkouts",
|
|
1052
|
+
surface: "billingV1"
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
method: "GET",
|
|
1056
|
+
path: "/billing/v1/customers",
|
|
1057
|
+
surface: "billingV1"
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
method: "POST",
|
|
1061
|
+
path: "/billing/v1/customers",
|
|
1062
|
+
surface: "billingV1"
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
method: "DELETE",
|
|
1066
|
+
path: "/billing/v1/customers/{id}",
|
|
1067
|
+
surface: "billingV1"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
method: "GET",
|
|
1071
|
+
path: "/billing/v1/customers/{id}",
|
|
1072
|
+
surface: "billingV1"
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
method: "PATCH",
|
|
1076
|
+
path: "/billing/v1/customers/{id}",
|
|
1077
|
+
surface: "billingV1"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
method: "GET",
|
|
1081
|
+
path: "/billing/v1/invoices",
|
|
1082
|
+
surface: "billingV1"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
method: "GET",
|
|
1086
|
+
path: "/billing/v1/invoices/{id}",
|
|
1087
|
+
surface: "billingV1"
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
method: "GET",
|
|
1091
|
+
path: "/billing/v1/payment-links",
|
|
1092
|
+
surface: "billingV1"
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
method: "POST",
|
|
1096
|
+
path: "/billing/v1/payment-links",
|
|
1097
|
+
surface: "billingV1"
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
method: "DELETE",
|
|
1101
|
+
path: "/billing/v1/payment-links/{id}",
|
|
1102
|
+
surface: "billingV1"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
method: "GET",
|
|
1106
|
+
path: "/billing/v1/payment-links/{id}",
|
|
1107
|
+
surface: "billingV1"
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
method: "PATCH",
|
|
1111
|
+
path: "/billing/v1/payment-links/{id}",
|
|
1112
|
+
surface: "billingV1"
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
method: "GET",
|
|
1116
|
+
path: "/billing/v1/payments",
|
|
1117
|
+
surface: "billingV1"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
method: "POST",
|
|
1121
|
+
path: "/billing/v1/payments",
|
|
1122
|
+
surface: "billingV1"
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
method: "GET",
|
|
1126
|
+
path: "/billing/v1/payments/{id}",
|
|
1127
|
+
surface: "billingV1"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
method: "POST",
|
|
1131
|
+
path: "/billing/v1/payments/{id}/cancel",
|
|
1132
|
+
surface: "billingV1"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
method: "GET",
|
|
1136
|
+
path: "/billing/v1/refunds",
|
|
1137
|
+
surface: "billingV1"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
method: "POST",
|
|
1141
|
+
path: "/billing/v1/refunds",
|
|
1142
|
+
surface: "billingV1"
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
method: "GET",
|
|
1146
|
+
path: "/billing/v1/refunds/{id}",
|
|
1147
|
+
surface: "billingV1"
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
method: "POST",
|
|
1151
|
+
path: "/billing/v1/refunds/{id}/cancel",
|
|
1152
|
+
surface: "billingV1"
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
method: "GET",
|
|
1156
|
+
path: "/billing/v1/subscriptions",
|
|
1157
|
+
surface: "billingV1"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
method: "POST",
|
|
1161
|
+
path: "/billing/v1/subscriptions",
|
|
1162
|
+
surface: "billingV1"
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
method: "GET",
|
|
1166
|
+
path: "/billing/v1/subscriptions/{id}",
|
|
1167
|
+
surface: "billingV1"
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
method: "PATCH",
|
|
1171
|
+
path: "/billing/v1/subscriptions/{id}",
|
|
1172
|
+
surface: "billingV1"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
method: "POST",
|
|
1176
|
+
path: "/billing/v1/subscriptions/{id}/cancel",
|
|
1177
|
+
surface: "billingV1"
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
method: "GET",
|
|
1181
|
+
path: "/debug/billing",
|
|
1182
|
+
surface: "debug"
|
|
1183
|
+
}
|
|
1184
|
+
],
|
|
1185
|
+
schemaVersion: 1,
|
|
1186
|
+
sourceOfTruth: "crates/athena-billing/src/live_http_routes.rs",
|
|
1187
|
+
sources: [
|
|
1188
|
+
"src/api/billing.rs",
|
|
1189
|
+
"src/api/billing_v1/**",
|
|
1190
|
+
"src/api/debug/billing.rs"
|
|
1191
|
+
]
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
exports.AthenaBillingError = AthenaBillingError;
|
|
1195
|
+
exports.billingLiveHttpRoutes = live_http_routes_default;
|
|
1196
|
+
exports.billingSdkManifest = billingSdkManifest;
|
|
1197
|
+
exports.createBillingModule = createBillingModule;
|
|
1198
|
+
//# sourceMappingURL=billing.cjs.map
|
|
1199
|
+
//# sourceMappingURL=billing.cjs.map
|