@xylex-group/athena 1.6.2 → 1.7.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 +47 -1
- package/dist/cli/index.cjs +77 -18
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +77 -18
- package/dist/cli/index.js.map +1 -1
- package/dist/{errors-BYRK5phv.d.cts → errors-BJGgjHcI.d.cts} +1 -1
- package/dist/{errors-1b-LSTum.d.ts → errors-Bcf5Sftv.d.ts} +1 -1
- package/dist/index.cjs +572 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +269 -6
- package/dist/index.d.ts +269 -6
- package/dist/index.js +569 -19
- package/dist/index.js.map +1 -1
- package/dist/{pipeline-CA2aexDl.d.cts → pipeline-BsKuBqmE.d.cts} +9 -4
- package/dist/{pipeline-BQzpSLD3.d.ts → pipeline-xQSjGbqF.d.ts} +9 -4
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/{types-v6UyGg-x.d.cts → types-wPA1Z4vQ.d.cts} +1 -1
- package/dist/{types-v6UyGg-x.d.ts → types-wPA1Z4vQ.d.ts} +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2020,8 +2020,21 @@ function coerceStringArray(value) {
|
|
|
2020
2020
|
}
|
|
2021
2021
|
return [];
|
|
2022
2022
|
}
|
|
2023
|
+
function normalizePostgresCatalogSchemas(schemas) {
|
|
2024
|
+
const normalized = [];
|
|
2025
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2026
|
+
for (const value of schemas ?? []) {
|
|
2027
|
+
const schema = value.trim();
|
|
2028
|
+
if (!schema || seen.has(schema)) {
|
|
2029
|
+
continue;
|
|
2030
|
+
}
|
|
2031
|
+
seen.add(schema);
|
|
2032
|
+
normalized.push(schema);
|
|
2033
|
+
}
|
|
2034
|
+
return normalized.length > 0 ? normalized : ["public"];
|
|
2035
|
+
}
|
|
2023
2036
|
function buildSchemaArrayLiteral(schemas) {
|
|
2024
|
-
const normalized = schemas
|
|
2037
|
+
const normalized = normalizePostgresCatalogSchemas(schemas);
|
|
2025
2038
|
const literals = normalized.map((schema) => `'${escapeSqlLiteral(schema)}'`).join(", ");
|
|
2026
2039
|
return `ARRAY[${literals}]`;
|
|
2027
2040
|
}
|
|
@@ -2222,12 +2235,14 @@ var PostgresIntrospectionProvider = class {
|
|
|
2222
2235
|
backend = "postgresql";
|
|
2223
2236
|
connectionString;
|
|
2224
2237
|
database;
|
|
2238
|
+
schemas;
|
|
2225
2239
|
constructor(options) {
|
|
2226
2240
|
this.connectionString = options.connectionString;
|
|
2227
2241
|
this.database = options.database ?? "postgres";
|
|
2242
|
+
this.schemas = normalizePostgresCatalogSchemas(options.schemas);
|
|
2228
2243
|
}
|
|
2229
2244
|
async inspect(options) {
|
|
2230
|
-
const schemas = options?.schemas && options.schemas.length > 0 ? options.schemas :
|
|
2245
|
+
const schemas = options?.schemas && options.schemas.length > 0 ? normalizePostgresCatalogSchemas(options.schemas) : this.schemas;
|
|
2231
2246
|
const pool = new pg.Pool({
|
|
2232
2247
|
connectionString: this.connectionString
|
|
2233
2248
|
});
|
|
@@ -2258,6 +2273,37 @@ var PostgresIntrospectionProvider = class {
|
|
|
2258
2273
|
function createPostgresIntrospectionProvider(options) {
|
|
2259
2274
|
return new PostgresIntrospectionProvider(options);
|
|
2260
2275
|
}
|
|
2276
|
+
|
|
2277
|
+
// src/generator/schema-selection.ts
|
|
2278
|
+
var DEFAULT_POSTGRES_SCHEMAS = ["public"];
|
|
2279
|
+
function collectSchemaNames(input) {
|
|
2280
|
+
if (!input) {
|
|
2281
|
+
return [];
|
|
2282
|
+
}
|
|
2283
|
+
const values = typeof input === "string" ? [input] : input;
|
|
2284
|
+
return values.flatMap((value) => String(value).split(","));
|
|
2285
|
+
}
|
|
2286
|
+
function normalizeSchemaSelection(input) {
|
|
2287
|
+
const schemas = [];
|
|
2288
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2289
|
+
for (const value of collectSchemaNames(input)) {
|
|
2290
|
+
const schema = value.trim();
|
|
2291
|
+
if (!schema || seen.has(schema)) {
|
|
2292
|
+
continue;
|
|
2293
|
+
}
|
|
2294
|
+
seen.add(schema);
|
|
2295
|
+
schemas.push(schema);
|
|
2296
|
+
}
|
|
2297
|
+
return schemas.length > 0 ? schemas : [...DEFAULT_POSTGRES_SCHEMAS];
|
|
2298
|
+
}
|
|
2299
|
+
function resolveProviderSchemas(providerConfig) {
|
|
2300
|
+
if (providerConfig.kind === "postgres") {
|
|
2301
|
+
return normalizeSchemaSelection(providerConfig.schemas);
|
|
2302
|
+
}
|
|
2303
|
+
return [...DEFAULT_POSTGRES_SCHEMAS];
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// src/generator/config.ts
|
|
2261
2307
|
var DEFAULT_CONFIG_CANDIDATES = [
|
|
2262
2308
|
"athena.config.ts",
|
|
2263
2309
|
"athena.config.js",
|
|
@@ -2267,8 +2313,8 @@ var DEFAULT_CONFIG_CANDIDATES = [
|
|
|
2267
2313
|
".athena.config.js"
|
|
2268
2314
|
];
|
|
2269
2315
|
var DEFAULT_TARGETS = {
|
|
2270
|
-
model: "athena/models/{model_kebab}.ts",
|
|
2271
|
-
schema: "athena/
|
|
2316
|
+
model: "athena/models/{schema_kebab}/{model_kebab}.ts",
|
|
2317
|
+
schema: "athena/schemas/{schema_kebab}.ts",
|
|
2272
2318
|
database: "athena/relations.ts",
|
|
2273
2319
|
registry: "athena/config.ts"
|
|
2274
2320
|
};
|
|
@@ -2298,6 +2344,15 @@ function normalizeOutputConfig(output) {
|
|
|
2298
2344
|
}
|
|
2299
2345
|
};
|
|
2300
2346
|
}
|
|
2347
|
+
function normalizeProviderConfig(provider) {
|
|
2348
|
+
if (provider.kind === "postgres") {
|
|
2349
|
+
return {
|
|
2350
|
+
...provider,
|
|
2351
|
+
schemas: normalizeSchemaSelection(provider.schemas)
|
|
2352
|
+
};
|
|
2353
|
+
}
|
|
2354
|
+
return provider;
|
|
2355
|
+
}
|
|
2301
2356
|
function isAthenaGeneratorConfig(value) {
|
|
2302
2357
|
if (!value || typeof value !== "object") {
|
|
2303
2358
|
return false;
|
|
@@ -2307,7 +2362,7 @@ function isAthenaGeneratorConfig(value) {
|
|
|
2307
2362
|
}
|
|
2308
2363
|
function normalizeGeneratorConfig(input) {
|
|
2309
2364
|
return {
|
|
2310
|
-
provider: input.provider,
|
|
2365
|
+
provider: normalizeProviderConfig(input.provider),
|
|
2311
2366
|
output: normalizeOutputConfig(input.output),
|
|
2312
2367
|
naming: {
|
|
2313
2368
|
...DEFAULT_NAMING,
|
|
@@ -2804,12 +2859,19 @@ export const ${registryConstName} = defineRegistry({
|
|
|
2804
2859
|
};
|
|
2805
2860
|
}
|
|
2806
2861
|
function assertNoDuplicatePaths(files) {
|
|
2807
|
-
const seen = /* @__PURE__ */ new
|
|
2862
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2808
2863
|
for (const file of files) {
|
|
2809
|
-
|
|
2810
|
-
|
|
2864
|
+
const existing = seen.get(file.path);
|
|
2865
|
+
if (existing) {
|
|
2866
|
+
throw new Error(
|
|
2867
|
+
[
|
|
2868
|
+
`Generator output collision detected for path: ${file.path}`,
|
|
2869
|
+
`Collision: ${existing.kind} and ${file.kind}.`,
|
|
2870
|
+
"When syncing multiple schemas, include a schema placeholder such as {schema} or {schema_kebab} in model/schema output targets."
|
|
2871
|
+
].join(" ")
|
|
2872
|
+
);
|
|
2811
2873
|
}
|
|
2812
|
-
seen.
|
|
2874
|
+
seen.set(file.path, file);
|
|
2813
2875
|
}
|
|
2814
2876
|
}
|
|
2815
2877
|
var ArtifactComposer = class {
|
|
@@ -2969,11 +3031,13 @@ var AthenaGatewayPostgresIntrospectionProvider = class {
|
|
|
2969
3031
|
type: this.config.backend ?? "postgresql"
|
|
2970
3032
|
}
|
|
2971
3033
|
});
|
|
3034
|
+
this.schemas = normalizeSchemaSelection(this.config.schemas);
|
|
2972
3035
|
}
|
|
2973
3036
|
backend = "postgresql";
|
|
2974
3037
|
client;
|
|
3038
|
+
schemas;
|
|
2975
3039
|
async inspect(options) {
|
|
2976
|
-
const schemas = options?.schemas && options.schemas.length > 0 ? options.schemas : this.
|
|
3040
|
+
const schemas = options?.schemas && options.schemas.length > 0 ? normalizeSchemaSelection(options.schemas) : this.schemas;
|
|
2977
3041
|
const catalogClient = new AthenaGatewayCatalogClient(this.client);
|
|
2978
3042
|
const queries = buildGatewayCatalogQueries(schemas);
|
|
2979
3043
|
const [columnRows, enumMap, primaryKeyRows, foreignKeyRows] = await Promise.all([
|
|
@@ -3009,7 +3073,8 @@ var ScyllaIntrospectionProvider = class {
|
|
|
3009
3073
|
function createPostgresProvider(config) {
|
|
3010
3074
|
return createPostgresIntrospectionProvider({
|
|
3011
3075
|
connectionString: config.connectionString,
|
|
3012
|
-
database: config.database
|
|
3076
|
+
database: config.database,
|
|
3077
|
+
schemas: normalizeSchemaSelection(config.schemas)
|
|
3013
3078
|
});
|
|
3014
3079
|
}
|
|
3015
3080
|
function resolveGeneratorProvider(providerConfig, experimentalFlags) {
|
|
@@ -3029,12 +3094,6 @@ function resolveGeneratorProvider(providerConfig, experimentalFlags) {
|
|
|
3029
3094
|
}
|
|
3030
3095
|
throw new Error(`Unsupported generator provider kind: ${providerConfig.kind ?? "unknown"}`);
|
|
3031
3096
|
}
|
|
3032
|
-
function extractProviderSchemas(providerConfig) {
|
|
3033
|
-
if (!("schemas" in providerConfig) || !providerConfig.schemas || providerConfig.schemas.length === 0) {
|
|
3034
|
-
return void 0;
|
|
3035
|
-
}
|
|
3036
|
-
return providerConfig.schemas;
|
|
3037
|
-
}
|
|
3038
3097
|
async function writeArtifacts(files, cwd) {
|
|
3039
3098
|
const writtenFiles = [];
|
|
3040
3099
|
for (const file of files) {
|
|
@@ -3054,7 +3113,7 @@ async function runSchemaGenerator(options = {}) {
|
|
|
3054
3113
|
const { configPath, config } = await loadGeneratorConfig(configOptions);
|
|
3055
3114
|
const provider = options.provider ?? resolveGeneratorProvider(config.provider, config.experimental);
|
|
3056
3115
|
const snapshot = await provider.inspect({
|
|
3057
|
-
schemas:
|
|
3116
|
+
schemas: resolveProviderSchemas(config.provider)
|
|
3058
3117
|
});
|
|
3059
3118
|
const generated = generateArtifactsFromSnapshot(snapshot, config);
|
|
3060
3119
|
const writtenFiles = options.dryRun ? [] : await writeArtifacts(generated.files, cwd);
|
|
@@ -3065,6 +3124,497 @@ async function runSchemaGenerator(options = {}) {
|
|
|
3065
3124
|
};
|
|
3066
3125
|
}
|
|
3067
3126
|
|
|
3127
|
+
// src/auth/client.ts
|
|
3128
|
+
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
3129
|
+
var FALLBACK_SDK_VERSION2 = "1.0.0";
|
|
3130
|
+
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
3131
|
+
var SDK_VERSION2 = typeof process !== "undefined" && process?.env?.npm_package_version ? process.env.npm_package_version : FALLBACK_SDK_VERSION2;
|
|
3132
|
+
var SDK_HEADER_VALUE2 = `${SDK_NAME2} ${SDK_VERSION2}`;
|
|
3133
|
+
function normalizeBaseUrl(baseUrl) {
|
|
3134
|
+
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
3135
|
+
}
|
|
3136
|
+
function isRecord3(value) {
|
|
3137
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3138
|
+
}
|
|
3139
|
+
function normalizeHeaderValue2(value) {
|
|
3140
|
+
return value ? value : void 0;
|
|
3141
|
+
}
|
|
3142
|
+
function parseResponseBody2(rawText, contentType) {
|
|
3143
|
+
if (!rawText) {
|
|
3144
|
+
return { parsed: null, parseFailed: false };
|
|
3145
|
+
}
|
|
3146
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
3147
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
3148
|
+
if (!looksJson) {
|
|
3149
|
+
return { parsed: rawText, parseFailed: false };
|
|
3150
|
+
}
|
|
3151
|
+
try {
|
|
3152
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
3153
|
+
} catch {
|
|
3154
|
+
return { parsed: rawText, parseFailed: true };
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
function resolveRequestId2(headers) {
|
|
3158
|
+
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
3159
|
+
}
|
|
3160
|
+
function resolveErrorMessage2(payload, fallback) {
|
|
3161
|
+
if (isRecord3(payload)) {
|
|
3162
|
+
const messageCandidates = [payload.error, payload.message, payload.details];
|
|
3163
|
+
for (const candidate of messageCandidates) {
|
|
3164
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
3165
|
+
return candidate.trim();
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
if (typeof payload === "string" && payload.trim().length > 0) {
|
|
3170
|
+
return payload.trim();
|
|
3171
|
+
}
|
|
3172
|
+
return fallback;
|
|
3173
|
+
}
|
|
3174
|
+
function toErrorDetails(input) {
|
|
3175
|
+
return {
|
|
3176
|
+
code: input.code,
|
|
3177
|
+
message: input.message,
|
|
3178
|
+
status: input.status,
|
|
3179
|
+
endpoint: input.endpoint,
|
|
3180
|
+
method: input.method,
|
|
3181
|
+
requestId: input.requestId,
|
|
3182
|
+
hint: input.hint,
|
|
3183
|
+
cause: input.cause
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
function mergeCallOptions(base, override) {
|
|
3187
|
+
if (!base && !override) return void 0;
|
|
3188
|
+
return {
|
|
3189
|
+
...base,
|
|
3190
|
+
...override,
|
|
3191
|
+
headers: {
|
|
3192
|
+
...base?.headers ?? {},
|
|
3193
|
+
...override?.headers ?? {}
|
|
3194
|
+
}
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
function extractFetchOptions(input) {
|
|
3198
|
+
if (!input) {
|
|
3199
|
+
return {
|
|
3200
|
+
payload: void 0,
|
|
3201
|
+
fetchOptions: void 0
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
const { fetchOptions, ...rest } = input;
|
|
3205
|
+
const hasPayloadKeys = Object.keys(rest).length > 0;
|
|
3206
|
+
return {
|
|
3207
|
+
payload: hasPayloadKeys ? rest : void 0,
|
|
3208
|
+
fetchOptions
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
function buildHeaders2(config, options) {
|
|
3212
|
+
const headers = {
|
|
3213
|
+
"Content-Type": "application/json",
|
|
3214
|
+
"X-Athena-Sdk": SDK_HEADER_VALUE2
|
|
3215
|
+
};
|
|
3216
|
+
const apiKey = options?.apiKey ?? config.apiKey;
|
|
3217
|
+
if (apiKey) {
|
|
3218
|
+
headers.apikey = apiKey;
|
|
3219
|
+
headers["x-api-key"] = apiKey;
|
|
3220
|
+
}
|
|
3221
|
+
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
3222
|
+
if (bearerToken) {
|
|
3223
|
+
headers.Authorization = `Bearer ${bearerToken}`;
|
|
3224
|
+
}
|
|
3225
|
+
const mergedExtraHeaders = {
|
|
3226
|
+
...config.headers ?? {},
|
|
3227
|
+
...options?.headers ?? {}
|
|
3228
|
+
};
|
|
3229
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
3230
|
+
const normalized = normalizeHeaderValue2(value);
|
|
3231
|
+
if (normalized) {
|
|
3232
|
+
headers[key] = normalized;
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
return headers;
|
|
3236
|
+
}
|
|
3237
|
+
function appendQueryParam(searchParams, key, value) {
|
|
3238
|
+
if (value === void 0 || value === null) return;
|
|
3239
|
+
if (Array.isArray(value)) {
|
|
3240
|
+
value.forEach((item) => {
|
|
3241
|
+
searchParams.append(key, String(item));
|
|
3242
|
+
});
|
|
3243
|
+
return;
|
|
3244
|
+
}
|
|
3245
|
+
searchParams.append(key, String(value));
|
|
3246
|
+
}
|
|
3247
|
+
function buildRequestUrl(baseUrl, endpoint, query) {
|
|
3248
|
+
const url = `${baseUrl}${endpoint}`;
|
|
3249
|
+
if (!query || Object.keys(query).length === 0) return url;
|
|
3250
|
+
const searchParams = new URLSearchParams();
|
|
3251
|
+
Object.entries(query).forEach(([key, value]) => appendQueryParam(searchParams, key, value));
|
|
3252
|
+
const queryText = searchParams.toString();
|
|
3253
|
+
return queryText ? `${url}?${queryText}` : url;
|
|
3254
|
+
}
|
|
3255
|
+
function inferDefaultMethod(endpoint) {
|
|
3256
|
+
if (endpoint.startsWith("/reset-password/")) {
|
|
3257
|
+
return "GET";
|
|
3258
|
+
}
|
|
3259
|
+
switch (endpoint) {
|
|
3260
|
+
case "/get-session":
|
|
3261
|
+
case "/list-sessions":
|
|
3262
|
+
case "/verify-email":
|
|
3263
|
+
case "/delete-user/callback":
|
|
3264
|
+
case "/list-accounts":
|
|
3265
|
+
case "/ok":
|
|
3266
|
+
case "/error":
|
|
3267
|
+
return "GET";
|
|
3268
|
+
default:
|
|
3269
|
+
return "POST";
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
async function callAuthEndpoint(config, context, body, query, options) {
|
|
3273
|
+
const baseUrl = normalizeBaseUrl(options?.baseUrl ?? config.baseUrl);
|
|
3274
|
+
const url = buildRequestUrl(baseUrl, context.endpoint, query);
|
|
3275
|
+
const headers = buildHeaders2(config, options);
|
|
3276
|
+
const credentials = options?.credentials ?? config.credentials ?? "include";
|
|
3277
|
+
const requestInit = {
|
|
3278
|
+
method: context.method,
|
|
3279
|
+
headers,
|
|
3280
|
+
credentials,
|
|
3281
|
+
signal: options?.signal
|
|
3282
|
+
};
|
|
3283
|
+
if (context.method !== "GET") {
|
|
3284
|
+
requestInit.body = JSON.stringify(body ?? {});
|
|
3285
|
+
}
|
|
3286
|
+
const fetcher = config.fetch ?? globalThis.fetch;
|
|
3287
|
+
if (!fetcher) {
|
|
3288
|
+
const details = toErrorDetails({
|
|
3289
|
+
code: "UNKNOWN_ERROR",
|
|
3290
|
+
message: "No fetch implementation available for auth client",
|
|
3291
|
+
status: 0,
|
|
3292
|
+
endpoint: context.endpoint,
|
|
3293
|
+
method: context.method,
|
|
3294
|
+
hint: "Use Node 18+ or provide `fetch` in createAuthClient({ fetch })"
|
|
3295
|
+
});
|
|
3296
|
+
return {
|
|
3297
|
+
ok: false,
|
|
3298
|
+
status: 0,
|
|
3299
|
+
data: null,
|
|
3300
|
+
error: details.message,
|
|
3301
|
+
errorDetails: details,
|
|
3302
|
+
raw: null
|
|
3303
|
+
};
|
|
3304
|
+
}
|
|
3305
|
+
try {
|
|
3306
|
+
const response = await fetcher(url, requestInit);
|
|
3307
|
+
const rawText = await response.text();
|
|
3308
|
+
const requestId = resolveRequestId2(response.headers);
|
|
3309
|
+
const parsedBody = parseResponseBody2(rawText ?? "", response.headers.get("content-type"));
|
|
3310
|
+
if (parsedBody.parseFailed) {
|
|
3311
|
+
const details = toErrorDetails({
|
|
3312
|
+
code: "INVALID_JSON",
|
|
3313
|
+
message: "Auth server returned malformed JSON",
|
|
3314
|
+
status: response.status,
|
|
3315
|
+
endpoint: context.endpoint,
|
|
3316
|
+
method: context.method,
|
|
3317
|
+
requestId,
|
|
3318
|
+
hint: "Verify the auth endpoint response body is valid JSON.",
|
|
3319
|
+
cause: rawText.slice(0, 300)
|
|
3320
|
+
});
|
|
3321
|
+
return {
|
|
3322
|
+
ok: false,
|
|
3323
|
+
status: response.status,
|
|
3324
|
+
data: null,
|
|
3325
|
+
error: details.message,
|
|
3326
|
+
errorDetails: details,
|
|
3327
|
+
raw: parsedBody.parsed
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
const parsed = parsedBody.parsed;
|
|
3331
|
+
if (!response.ok) {
|
|
3332
|
+
const details = toErrorDetails({
|
|
3333
|
+
code: "HTTP_ERROR",
|
|
3334
|
+
message: resolveErrorMessage2(
|
|
3335
|
+
parsed,
|
|
3336
|
+
`Auth endpoint ${context.method} ${context.endpoint} failed with status ${response.status}`
|
|
3337
|
+
),
|
|
3338
|
+
status: response.status,
|
|
3339
|
+
endpoint: context.endpoint,
|
|
3340
|
+
method: context.method,
|
|
3341
|
+
requestId
|
|
3342
|
+
});
|
|
3343
|
+
return {
|
|
3344
|
+
ok: false,
|
|
3345
|
+
status: response.status,
|
|
3346
|
+
data: null,
|
|
3347
|
+
error: details.message,
|
|
3348
|
+
errorDetails: details,
|
|
3349
|
+
raw: parsed
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
return {
|
|
3353
|
+
ok: true,
|
|
3354
|
+
status: response.status,
|
|
3355
|
+
data: parsed ?? null,
|
|
3356
|
+
error: null,
|
|
3357
|
+
errorDetails: null,
|
|
3358
|
+
raw: parsed
|
|
3359
|
+
};
|
|
3360
|
+
} catch (callError) {
|
|
3361
|
+
const message = callError instanceof Error ? callError.message : String(callError);
|
|
3362
|
+
const details = toErrorDetails({
|
|
3363
|
+
code: "NETWORK_ERROR",
|
|
3364
|
+
message: `Network error while calling ${context.method} ${context.endpoint}: ${message}`,
|
|
3365
|
+
status: 0,
|
|
3366
|
+
endpoint: context.endpoint,
|
|
3367
|
+
method: context.method,
|
|
3368
|
+
cause: message,
|
|
3369
|
+
hint: "Check auth server URL, DNS, and network reachability."
|
|
3370
|
+
});
|
|
3371
|
+
return {
|
|
3372
|
+
ok: false,
|
|
3373
|
+
status: 0,
|
|
3374
|
+
data: null,
|
|
3375
|
+
error: details.message,
|
|
3376
|
+
errorDetails: details,
|
|
3377
|
+
raw: null
|
|
3378
|
+
};
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
function executePostWithCompatibleInput(config, context, input, options) {
|
|
3382
|
+
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
3383
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3384
|
+
return callAuthEndpoint(config, context, payload ?? {}, void 0, mergedOptions);
|
|
3385
|
+
}
|
|
3386
|
+
function executePostWithOptionalInput(config, context, input, options) {
|
|
3387
|
+
const { fetchOptions } = extractFetchOptions(input);
|
|
3388
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3389
|
+
return callAuthEndpoint(config, context, {}, void 0, mergedOptions);
|
|
3390
|
+
}
|
|
3391
|
+
function executeGetWithCompatibleInput(config, context, input, options) {
|
|
3392
|
+
const { fetchOptions } = extractFetchOptions(input);
|
|
3393
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3394
|
+
return callAuthEndpoint(config, context, void 0, void 0, mergedOptions);
|
|
3395
|
+
}
|
|
3396
|
+
function createAuthClient(config = {}) {
|
|
3397
|
+
const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
|
|
3398
|
+
const resolvedConfig = {
|
|
3399
|
+
...config,
|
|
3400
|
+
baseUrl: normalizedBaseUrl
|
|
3401
|
+
};
|
|
3402
|
+
const request = (input, options) => {
|
|
3403
|
+
const method = input.method ?? (input.body !== void 0 ? "POST" : inferDefaultMethod(input.endpoint));
|
|
3404
|
+
const mergedOptions = mergeCallOptions(input.fetchOptions, options);
|
|
3405
|
+
return callAuthEndpoint(
|
|
3406
|
+
resolvedConfig,
|
|
3407
|
+
{ endpoint: input.endpoint, method },
|
|
3408
|
+
input.body,
|
|
3409
|
+
input.query,
|
|
3410
|
+
mergedOptions
|
|
3411
|
+
);
|
|
3412
|
+
};
|
|
3413
|
+
const signOut = (input, options) => executePostWithOptionalInput(
|
|
3414
|
+
resolvedConfig,
|
|
3415
|
+
{ endpoint: "/sign-out", method: "POST" },
|
|
3416
|
+
input,
|
|
3417
|
+
options
|
|
3418
|
+
);
|
|
3419
|
+
const revokeSessions = (input, options) => executePostWithOptionalInput(
|
|
3420
|
+
resolvedConfig,
|
|
3421
|
+
{ endpoint: "/revoke-sessions", method: "POST" },
|
|
3422
|
+
input,
|
|
3423
|
+
options
|
|
3424
|
+
);
|
|
3425
|
+
const revokeOtherSessions = (input, options) => executePostWithOptionalInput(
|
|
3426
|
+
resolvedConfig,
|
|
3427
|
+
{ endpoint: "/revoke-other-sessions", method: "POST" },
|
|
3428
|
+
input,
|
|
3429
|
+
options
|
|
3430
|
+
);
|
|
3431
|
+
const revokeSession = (input, options) => executePostWithCompatibleInput(
|
|
3432
|
+
resolvedConfig,
|
|
3433
|
+
{ endpoint: "/revoke-session", method: "POST" },
|
|
3434
|
+
input,
|
|
3435
|
+
options
|
|
3436
|
+
);
|
|
3437
|
+
const deleteUser = (input, options) => {
|
|
3438
|
+
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
3439
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3440
|
+
return callAuthEndpoint(
|
|
3441
|
+
resolvedConfig,
|
|
3442
|
+
{ endpoint: "/delete-user", method: "POST" },
|
|
3443
|
+
payload ?? {},
|
|
3444
|
+
void 0,
|
|
3445
|
+
mergedOptions
|
|
3446
|
+
);
|
|
3447
|
+
};
|
|
3448
|
+
const deleteUserCallback = (input, options) => {
|
|
3449
|
+
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
3450
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3451
|
+
const query = payload ?? {};
|
|
3452
|
+
return callAuthEndpoint(
|
|
3453
|
+
resolvedConfig,
|
|
3454
|
+
{ endpoint: "/delete-user/callback", method: "GET" },
|
|
3455
|
+
void 0,
|
|
3456
|
+
{
|
|
3457
|
+
token: query.token,
|
|
3458
|
+
callbackURL: query.callbackURL
|
|
3459
|
+
},
|
|
3460
|
+
mergedOptions
|
|
3461
|
+
);
|
|
3462
|
+
};
|
|
3463
|
+
const resolveResetPasswordToken = (input, options) => {
|
|
3464
|
+
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
3465
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3466
|
+
const query = payload;
|
|
3467
|
+
const token = query?.token?.trim();
|
|
3468
|
+
if (!token) {
|
|
3469
|
+
throw new Error("resolveResetPasswordToken requires a non-empty token");
|
|
3470
|
+
}
|
|
3471
|
+
const endpoint = `/reset-password/${encodeURIComponent(token)}`;
|
|
3472
|
+
return callAuthEndpoint(
|
|
3473
|
+
resolvedConfig,
|
|
3474
|
+
{ endpoint, method: "GET" },
|
|
3475
|
+
void 0,
|
|
3476
|
+
query?.callbackURL ? { callbackURL: query.callbackURL } : void 0,
|
|
3477
|
+
mergedOptions
|
|
3478
|
+
);
|
|
3479
|
+
};
|
|
3480
|
+
return {
|
|
3481
|
+
baseUrl: normalizedBaseUrl,
|
|
3482
|
+
request,
|
|
3483
|
+
signIn: {
|
|
3484
|
+
email: (input, options) => executePostWithCompatibleInput(
|
|
3485
|
+
resolvedConfig,
|
|
3486
|
+
{ endpoint: "/sign-in/email", method: "POST" },
|
|
3487
|
+
input,
|
|
3488
|
+
options
|
|
3489
|
+
),
|
|
3490
|
+
username: (input, options) => executePostWithCompatibleInput(
|
|
3491
|
+
resolvedConfig,
|
|
3492
|
+
{ endpoint: "/sign-in/username", method: "POST" },
|
|
3493
|
+
input,
|
|
3494
|
+
options
|
|
3495
|
+
),
|
|
3496
|
+
social: (input, options) => executePostWithCompatibleInput(
|
|
3497
|
+
resolvedConfig,
|
|
3498
|
+
{ endpoint: "/sign-in/social", method: "POST" },
|
|
3499
|
+
input,
|
|
3500
|
+
options
|
|
3501
|
+
)
|
|
3502
|
+
},
|
|
3503
|
+
signUp: {
|
|
3504
|
+
email: (input, options) => executePostWithCompatibleInput(
|
|
3505
|
+
resolvedConfig,
|
|
3506
|
+
{ endpoint: "/sign-up/email", method: "POST" },
|
|
3507
|
+
input,
|
|
3508
|
+
options
|
|
3509
|
+
)
|
|
3510
|
+
},
|
|
3511
|
+
signOut,
|
|
3512
|
+
logout: signOut,
|
|
3513
|
+
getSession: (input, options) => executeGetWithCompatibleInput(
|
|
3514
|
+
resolvedConfig,
|
|
3515
|
+
{ endpoint: "/get-session", method: "GET" },
|
|
3516
|
+
input,
|
|
3517
|
+
options
|
|
3518
|
+
),
|
|
3519
|
+
listSessions: (input, options) => executeGetWithCompatibleInput(
|
|
3520
|
+
resolvedConfig,
|
|
3521
|
+
{ endpoint: "/list-sessions", method: "GET" },
|
|
3522
|
+
input,
|
|
3523
|
+
options
|
|
3524
|
+
),
|
|
3525
|
+
revokeSession,
|
|
3526
|
+
clearSession: revokeSession,
|
|
3527
|
+
revokeSessions,
|
|
3528
|
+
clearSessions: revokeSessions,
|
|
3529
|
+
revokeOtherSessions,
|
|
3530
|
+
clearOtherSessions: revokeOtherSessions,
|
|
3531
|
+
forgetPassword: (input, options) => executePostWithCompatibleInput(
|
|
3532
|
+
resolvedConfig,
|
|
3533
|
+
{ endpoint: "/forget-password", method: "POST" },
|
|
3534
|
+
input,
|
|
3535
|
+
options
|
|
3536
|
+
),
|
|
3537
|
+
resetPassword: (input, options) => executePostWithCompatibleInput(
|
|
3538
|
+
resolvedConfig,
|
|
3539
|
+
{ endpoint: "/reset-password", method: "POST" },
|
|
3540
|
+
input,
|
|
3541
|
+
options
|
|
3542
|
+
),
|
|
3543
|
+
resolveResetPasswordToken,
|
|
3544
|
+
verifyEmail: (input, options) => {
|
|
3545
|
+
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
3546
|
+
const mergedOptions = mergeCallOptions(fetchOptions, options);
|
|
3547
|
+
const query = payload;
|
|
3548
|
+
return callAuthEndpoint(
|
|
3549
|
+
resolvedConfig,
|
|
3550
|
+
{ endpoint: "/verify-email", method: "GET" },
|
|
3551
|
+
void 0,
|
|
3552
|
+
query ? {
|
|
3553
|
+
token: query.token,
|
|
3554
|
+
callbackURL: query.callbackURL
|
|
3555
|
+
} : void 0,
|
|
3556
|
+
mergedOptions
|
|
3557
|
+
);
|
|
3558
|
+
},
|
|
3559
|
+
sendVerificationEmail: (input, options) => executePostWithCompatibleInput(
|
|
3560
|
+
resolvedConfig,
|
|
3561
|
+
{ endpoint: "/send-verification-email", method: "POST" },
|
|
3562
|
+
input,
|
|
3563
|
+
options
|
|
3564
|
+
),
|
|
3565
|
+
changeEmail: (input, options) => executePostWithCompatibleInput(
|
|
3566
|
+
resolvedConfig,
|
|
3567
|
+
{ endpoint: "/change-email", method: "POST" },
|
|
3568
|
+
input,
|
|
3569
|
+
options
|
|
3570
|
+
),
|
|
3571
|
+
changePassword: (input, options) => executePostWithCompatibleInput(
|
|
3572
|
+
resolvedConfig,
|
|
3573
|
+
{ endpoint: "/change-password", method: "POST" },
|
|
3574
|
+
input,
|
|
3575
|
+
options
|
|
3576
|
+
),
|
|
3577
|
+
updateUser: (input, options) => executePostWithCompatibleInput(
|
|
3578
|
+
resolvedConfig,
|
|
3579
|
+
{ endpoint: "/update-user", method: "POST" },
|
|
3580
|
+
input,
|
|
3581
|
+
options
|
|
3582
|
+
),
|
|
3583
|
+
deleteUser,
|
|
3584
|
+
deleteUserCallback,
|
|
3585
|
+
linkSocial: (input, options) => executePostWithCompatibleInput(
|
|
3586
|
+
resolvedConfig,
|
|
3587
|
+
{ endpoint: "/link-social", method: "POST" },
|
|
3588
|
+
input,
|
|
3589
|
+
options
|
|
3590
|
+
),
|
|
3591
|
+
listAccounts: (input, options) => executeGetWithCompatibleInput(
|
|
3592
|
+
resolvedConfig,
|
|
3593
|
+
{ endpoint: "/list-accounts", method: "GET" },
|
|
3594
|
+
input,
|
|
3595
|
+
options
|
|
3596
|
+
),
|
|
3597
|
+
unlinkAccount: (input, options) => executePostWithCompatibleInput(
|
|
3598
|
+
resolvedConfig,
|
|
3599
|
+
{ endpoint: "/unlink-account", method: "POST" },
|
|
3600
|
+
input,
|
|
3601
|
+
options
|
|
3602
|
+
),
|
|
3603
|
+
refreshToken: (input, options) => executePostWithCompatibleInput(
|
|
3604
|
+
resolvedConfig,
|
|
3605
|
+
{ endpoint: "/refresh-token", method: "POST" },
|
|
3606
|
+
input,
|
|
3607
|
+
options
|
|
3608
|
+
),
|
|
3609
|
+
getAccessToken: (input, options) => executePostWithCompatibleInput(
|
|
3610
|
+
resolvedConfig,
|
|
3611
|
+
{ endpoint: "/get-access-token", method: "POST" },
|
|
3612
|
+
input,
|
|
3613
|
+
options
|
|
3614
|
+
)
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3068
3618
|
exports.AthenaClient = AthenaClient;
|
|
3069
3619
|
exports.AthenaError = AthenaError;
|
|
3070
3620
|
exports.AthenaErrorCategory = AthenaErrorCategory;
|
|
@@ -3072,8 +3622,10 @@ exports.AthenaErrorCode = AthenaErrorCode;
|
|
|
3072
3622
|
exports.AthenaErrorKind = AthenaErrorKind;
|
|
3073
3623
|
exports.AthenaGatewayError = AthenaGatewayError;
|
|
3074
3624
|
exports.Backend = Backend;
|
|
3625
|
+
exports.DEFAULT_POSTGRES_SCHEMAS = DEFAULT_POSTGRES_SCHEMAS;
|
|
3075
3626
|
exports.assertInt = assertInt;
|
|
3076
3627
|
exports.coerceInt = coerceInt;
|
|
3628
|
+
exports.createAuthClient = createAuthClient;
|
|
3077
3629
|
exports.createClient = createClient;
|
|
3078
3630
|
exports.createPostgresIntrospectionProvider = createPostgresIntrospectionProvider;
|
|
3079
3631
|
exports.createTypedClient = createTypedClient;
|
|
@@ -3090,10 +3642,12 @@ exports.isOk = isOk;
|
|
|
3090
3642
|
exports.loadGeneratorConfig = loadGeneratorConfig;
|
|
3091
3643
|
exports.normalizeAthenaError = normalizeAthenaError;
|
|
3092
3644
|
exports.normalizeGeneratorConfig = normalizeGeneratorConfig;
|
|
3645
|
+
exports.normalizeSchemaSelection = normalizeSchemaSelection;
|
|
3093
3646
|
exports.requireAffected = requireAffected;
|
|
3094
3647
|
exports.requireSuccess = requireSuccess;
|
|
3095
3648
|
exports.resolveGeneratorProvider = resolveGeneratorProvider;
|
|
3096
3649
|
exports.resolvePostgresColumnType = resolvePostgresColumnType;
|
|
3650
|
+
exports.resolveProviderSchemas = resolveProviderSchemas;
|
|
3097
3651
|
exports.runSchemaGenerator = runSchemaGenerator;
|
|
3098
3652
|
exports.unwrap = unwrap;
|
|
3099
3653
|
exports.unwrapOne = unwrapOne;
|