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