@xylex-group/athena 1.4.1 → 1.6.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 +169 -18
- package/bin/athena-js.js +7 -8
- package/dist/cli/index.cjs +2472 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +6 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +2470 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +1524 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +484 -1
- package/dist/index.d.ts +484 -1
- package/dist/index.js +1506 -16
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +965 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +232 -1
- package/dist/react.d.ts +232 -1
- package/dist/react.js +960 -2
- package/dist/react.js.map +1 -1
- package/package.json +10 -3
package/dist/index.d.ts
CHANGED
|
@@ -133,6 +133,36 @@ declare class AthenaClient {
|
|
|
133
133
|
declare function createClient(url: string, apiKey: string, options?: Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'>): AthenaSdkClient;
|
|
134
134
|
|
|
135
135
|
type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
|
|
136
|
+
declare const AthenaErrorKind: {
|
|
137
|
+
readonly UniqueViolation: "unique_violation";
|
|
138
|
+
readonly NotFound: "not_found";
|
|
139
|
+
readonly Validation: "validation";
|
|
140
|
+
readonly Auth: "auth";
|
|
141
|
+
readonly RateLimit: "rate_limit";
|
|
142
|
+
readonly Transient: "transient";
|
|
143
|
+
readonly Unknown: "unknown";
|
|
144
|
+
};
|
|
145
|
+
type AthenaErrorCode = 'UNIQUE_VIOLATION' | 'NOT_FOUND' | 'VALIDATION_FAILED' | 'AUTH_UNAUTHORIZED' | 'AUTH_FORBIDDEN' | 'RATE_LIMITED' | 'NETWORK_UNAVAILABLE' | 'TRANSIENT_FAILURE' | 'HTTP_FAILURE' | 'UNKNOWN';
|
|
146
|
+
declare const AthenaErrorCode: {
|
|
147
|
+
readonly UniqueViolation: "UNIQUE_VIOLATION";
|
|
148
|
+
readonly NotFound: "NOT_FOUND";
|
|
149
|
+
readonly ValidationFailed: "VALIDATION_FAILED";
|
|
150
|
+
readonly AuthUnauthorized: "AUTH_UNAUTHORIZED";
|
|
151
|
+
readonly AuthForbidden: "AUTH_FORBIDDEN";
|
|
152
|
+
readonly RateLimited: "RATE_LIMITED";
|
|
153
|
+
readonly NetworkUnavailable: "NETWORK_UNAVAILABLE";
|
|
154
|
+
readonly TransientFailure: "TRANSIENT_FAILURE";
|
|
155
|
+
readonly HttpFailure: "HTTP_FAILURE";
|
|
156
|
+
readonly Unknown: "UNKNOWN";
|
|
157
|
+
};
|
|
158
|
+
type AthenaErrorCategory = 'transport' | 'client' | 'server' | 'database' | 'unknown';
|
|
159
|
+
declare const AthenaErrorCategory: {
|
|
160
|
+
readonly Transport: "transport";
|
|
161
|
+
readonly Client: "client";
|
|
162
|
+
readonly Server: "server";
|
|
163
|
+
readonly Database: "database";
|
|
164
|
+
readonly Unknown: "unknown";
|
|
165
|
+
};
|
|
136
166
|
interface AthenaOperationContext {
|
|
137
167
|
table?: string;
|
|
138
168
|
operation?: string;
|
|
@@ -140,6 +170,9 @@ interface AthenaOperationContext {
|
|
|
140
170
|
}
|
|
141
171
|
interface NormalizedAthenaError {
|
|
142
172
|
kind: AthenaErrorKind;
|
|
173
|
+
code: AthenaErrorCode;
|
|
174
|
+
category: AthenaErrorCategory;
|
|
175
|
+
retryable: boolean;
|
|
143
176
|
status?: number;
|
|
144
177
|
constraint?: string;
|
|
145
178
|
table?: string;
|
|
@@ -147,6 +180,17 @@ interface NormalizedAthenaError {
|
|
|
147
180
|
message: string;
|
|
148
181
|
raw: unknown;
|
|
149
182
|
}
|
|
183
|
+
interface AthenaErrorInput {
|
|
184
|
+
code: AthenaErrorCode;
|
|
185
|
+
kind: AthenaErrorKind;
|
|
186
|
+
category: AthenaErrorCategory;
|
|
187
|
+
message: string;
|
|
188
|
+
status?: number;
|
|
189
|
+
retryable?: boolean;
|
|
190
|
+
requestId?: string;
|
|
191
|
+
context?: AthenaOperationContext;
|
|
192
|
+
raw?: unknown;
|
|
193
|
+
}
|
|
150
194
|
interface UnwrapOptions {
|
|
151
195
|
allowNull?: boolean;
|
|
152
196
|
context?: AthenaOperationContext;
|
|
@@ -171,6 +215,17 @@ interface RetryConfig {
|
|
|
171
215
|
interface RequireAffectedOptions {
|
|
172
216
|
min?: number;
|
|
173
217
|
}
|
|
218
|
+
declare class AthenaError extends Error {
|
|
219
|
+
readonly code: AthenaErrorCode;
|
|
220
|
+
readonly kind: AthenaErrorKind;
|
|
221
|
+
readonly category: AthenaErrorCategory;
|
|
222
|
+
readonly status?: number;
|
|
223
|
+
readonly retryable: boolean;
|
|
224
|
+
readonly requestId?: string;
|
|
225
|
+
readonly context?: AthenaOperationContext;
|
|
226
|
+
readonly raw?: unknown;
|
|
227
|
+
constructor(input: AthenaErrorInput);
|
|
228
|
+
}
|
|
174
229
|
/**
|
|
175
230
|
* Returns `true` when a result is successful (`2xx` status and no `error`).
|
|
176
231
|
*/
|
|
@@ -246,4 +301,432 @@ declare function assertInt(value: unknown, label?: string, options?: IntCoercion
|
|
|
246
301
|
*/
|
|
247
302
|
declare function withRetry<T>(config: RetryConfig, fn: () => Promise<T>): Promise<T>;
|
|
248
303
|
|
|
249
|
-
|
|
304
|
+
/**
|
|
305
|
+
* Immutable identifier object with consistent SQL rendering.
|
|
306
|
+
*/
|
|
307
|
+
interface SqlIdentifier {
|
|
308
|
+
readonly segments: string[];
|
|
309
|
+
toSql(): string;
|
|
310
|
+
toString(): string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Creates a quoted identifier object from segment or dotted inputs.
|
|
314
|
+
*/
|
|
315
|
+
declare function identifier(...segments: string[]): SqlIdentifier;
|
|
316
|
+
|
|
317
|
+
type ModelKey = string;
|
|
318
|
+
type ColumnKey = string;
|
|
319
|
+
/**
|
|
320
|
+
* Runtime values that can safely be serialized into tenant-scoped headers.
|
|
321
|
+
*/
|
|
322
|
+
type TenantContextValue = string | number | boolean | null | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* Compile-time map of tenant context keys to outbound header names.
|
|
325
|
+
*/
|
|
326
|
+
type TenantKeyMap = Record<string, string>;
|
|
327
|
+
/**
|
|
328
|
+
* Partial tenant context keyed by `TenantKeyMap`.
|
|
329
|
+
*/
|
|
330
|
+
type TenantContext<TMap extends TenantKeyMap> = Partial<Record<keyof TMap, TenantContextValue>>;
|
|
331
|
+
/**
|
|
332
|
+
* Supported relationship cardinalities for model metadata and introspection snapshots.
|
|
333
|
+
*/
|
|
334
|
+
type ModelRelationKind = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
335
|
+
/**
|
|
336
|
+
* Base metadata shape shared by typed model definitions and introspection snapshots.
|
|
337
|
+
* This type is intentionally row-agnostic so it can be used for generic registries.
|
|
338
|
+
*/
|
|
339
|
+
interface ModelMetadataBase {
|
|
340
|
+
database?: string;
|
|
341
|
+
schema?: string;
|
|
342
|
+
model?: string;
|
|
343
|
+
tableName?: string;
|
|
344
|
+
primaryKey: string[];
|
|
345
|
+
nullable?: Partial<Record<string, boolean>>;
|
|
346
|
+
relations?: Record<string, ModelRelationMetadata>;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Strongly-typed model metadata linked to a row shape.
|
|
350
|
+
*/
|
|
351
|
+
type ModelMetadata<Row> = Omit<ModelMetadataBase, 'primaryKey' | 'nullable'> & {
|
|
352
|
+
primaryKey: Array<Extract<keyof Row, string>>;
|
|
353
|
+
nullable?: Partial<Record<Extract<keyof Row, string>, boolean>>;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Relation metadata for model contracts and introspection snapshots.
|
|
357
|
+
*/
|
|
358
|
+
interface ModelRelationMetadata {
|
|
359
|
+
kind: ModelRelationKind;
|
|
360
|
+
sourceColumns: ColumnKey[];
|
|
361
|
+
targetSchema: string;
|
|
362
|
+
targetModel: ModelKey;
|
|
363
|
+
targetColumns: ColumnKey[];
|
|
364
|
+
targetDatabase?: string;
|
|
365
|
+
through?: {
|
|
366
|
+
schema: string;
|
|
367
|
+
model: string;
|
|
368
|
+
sourceColumns: ColumnKey[];
|
|
369
|
+
targetColumns: ColumnKey[];
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Core model definition contract used by typed registries.
|
|
374
|
+
*/
|
|
375
|
+
interface ModelDef<Row, Insert = Partial<Row>, Update = Partial<Insert>, Meta extends ModelMetadataBase = ModelMetadata<Row>> {
|
|
376
|
+
readonly meta: Meta;
|
|
377
|
+
readonly __types?: {
|
|
378
|
+
row: Row;
|
|
379
|
+
insert: Insert;
|
|
380
|
+
update: Update;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Row-agnostic model definition used as a generic constraint.
|
|
385
|
+
*/
|
|
386
|
+
type AnyModelDef = ModelDef<unknown, unknown, unknown, ModelMetadataBase>;
|
|
387
|
+
/**
|
|
388
|
+
* Schema-level model registry.
|
|
389
|
+
*/
|
|
390
|
+
interface SchemaDef<Models extends Record<ModelKey, AnyModelDef>> {
|
|
391
|
+
readonly models: Models;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Database-level schema registry.
|
|
395
|
+
*/
|
|
396
|
+
interface DatabaseDef<Schemas extends Record<string, SchemaDef<Record<ModelKey, AnyModelDef>>>> {
|
|
397
|
+
readonly schemas: Schemas;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Top-level registry keyed by logical database names.
|
|
401
|
+
*/
|
|
402
|
+
type RegistryDef<Databases extends Record<string, DatabaseDef<Record<string, SchemaDef<Record<ModelKey, AnyModelDef>>>>>> = Databases;
|
|
403
|
+
/**
|
|
404
|
+
* Extracts row type from a model definition.
|
|
405
|
+
*/
|
|
406
|
+
type RowOf<TModel extends AnyModelDef> = TModel extends ModelDef<infer TRow, unknown, unknown, ModelMetadataBase> ? TRow : never;
|
|
407
|
+
/**
|
|
408
|
+
* Extracts insert type from a model definition.
|
|
409
|
+
*/
|
|
410
|
+
type InsertOf<TModel extends AnyModelDef> = TModel extends ModelDef<unknown, infer TInsert, unknown, ModelMetadataBase> ? TInsert : never;
|
|
411
|
+
/**
|
|
412
|
+
* Extracts update type from a model definition.
|
|
413
|
+
*/
|
|
414
|
+
type UpdateOf<TModel extends AnyModelDef> = TModel extends ModelDef<unknown, unknown, infer TUpdate, ModelMetadataBase> ? TUpdate : never;
|
|
415
|
+
/**
|
|
416
|
+
* Resolves a model definition from a registry path.
|
|
417
|
+
*/
|
|
418
|
+
type ModelAt<TRegistry extends RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<ModelKey, AnyModelDef>>>>>>, TDatabase extends keyof TRegistry & string, TSchema extends keyof TRegistry[TDatabase]['schemas'] & string, TModel extends keyof TRegistry[TDatabase]['schemas'][TSchema]['models'] & string> = TRegistry[TDatabase]['schemas'][TSchema]['models'][TModel];
|
|
419
|
+
/**
|
|
420
|
+
* Introspection-level column type families.
|
|
421
|
+
*/
|
|
422
|
+
type IntrospectionTypeKind = 'scalar' | 'enum' | 'domain' | 'range' | 'multirange' | 'composite';
|
|
423
|
+
/**
|
|
424
|
+
* Introspected column metadata.
|
|
425
|
+
*/
|
|
426
|
+
interface IntrospectionColumn {
|
|
427
|
+
name: string;
|
|
428
|
+
dataType: string;
|
|
429
|
+
udtName: string;
|
|
430
|
+
typeKind: IntrospectionTypeKind;
|
|
431
|
+
isNullable: boolean;
|
|
432
|
+
isPrimaryKey: boolean;
|
|
433
|
+
hasDefault: boolean;
|
|
434
|
+
isGenerated: boolean;
|
|
435
|
+
arrayDimensions: number;
|
|
436
|
+
enumValues?: string[];
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Introspected relationship metadata.
|
|
440
|
+
*/
|
|
441
|
+
interface IntrospectionRelation {
|
|
442
|
+
name: string;
|
|
443
|
+
kind: ModelRelationKind;
|
|
444
|
+
sourceColumns: string[];
|
|
445
|
+
targetSchema: string;
|
|
446
|
+
targetModel: string;
|
|
447
|
+
targetColumns: string[];
|
|
448
|
+
targetDatabase?: string;
|
|
449
|
+
through?: {
|
|
450
|
+
schema: string;
|
|
451
|
+
model: string;
|
|
452
|
+
sourceColumns: string[];
|
|
453
|
+
targetColumns: string[];
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Introspected table metadata.
|
|
458
|
+
*/
|
|
459
|
+
interface IntrospectionTable {
|
|
460
|
+
schema: string;
|
|
461
|
+
name: string;
|
|
462
|
+
columns: Record<string, IntrospectionColumn>;
|
|
463
|
+
primaryKey: string[];
|
|
464
|
+
relations: Record<string, IntrospectionRelation>;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Introspected schema metadata.
|
|
468
|
+
*/
|
|
469
|
+
interface IntrospectionSchema {
|
|
470
|
+
name: string;
|
|
471
|
+
tables: Record<string, IntrospectionTable>;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Normalized output of a schema introspection pass.
|
|
475
|
+
*/
|
|
476
|
+
interface IntrospectionSnapshot {
|
|
477
|
+
backend: BackendType;
|
|
478
|
+
database: string;
|
|
479
|
+
generatedAt: string;
|
|
480
|
+
schemas: Record<string, IntrospectionSchema>;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Options accepted by introspection providers.
|
|
484
|
+
*/
|
|
485
|
+
interface IntrospectionInspectOptions {
|
|
486
|
+
schemas?: string[];
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Provider contract implemented by backend-specific introspection adapters.
|
|
490
|
+
*/
|
|
491
|
+
interface SchemaIntrospectionProvider {
|
|
492
|
+
readonly backend: BackendType;
|
|
493
|
+
inspect(options?: IntrospectionInspectOptions): Promise<IntrospectionSnapshot>;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Declares a model contract with explicit metadata and typed row/insert/update shapes.
|
|
498
|
+
*/
|
|
499
|
+
declare function defineModel<Row, Insert = Partial<Row>, Update = Partial<Insert>, Meta extends ModelMetadata<Row> = ModelMetadata<Row>>(input: {
|
|
500
|
+
meta: Meta;
|
|
501
|
+
}): ModelDef<Row, Insert, Update, Meta>;
|
|
502
|
+
/**
|
|
503
|
+
* Declares a schema-level model map.
|
|
504
|
+
*/
|
|
505
|
+
declare function defineSchema<Models extends Record<string, AnyModelDef>>(models: Models): SchemaDef<Models>;
|
|
506
|
+
/**
|
|
507
|
+
* Declares a database-level schema map.
|
|
508
|
+
*/
|
|
509
|
+
declare function defineDatabase<Schemas extends Record<string, SchemaDef<Record<string, AnyModelDef>>>>(schemas: Schemas): DatabaseDef<Schemas>;
|
|
510
|
+
/**
|
|
511
|
+
* Declares a top-level multi-database registry.
|
|
512
|
+
*/
|
|
513
|
+
declare function defineRegistry<Databases extends Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>(databases: Databases): RegistryDef<Databases>;
|
|
514
|
+
|
|
515
|
+
type RegistryConstraint = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
|
|
516
|
+
/**
|
|
517
|
+
* Options for creating typed Athena clients.
|
|
518
|
+
*/
|
|
519
|
+
interface TypedClientOptions<TMap extends TenantKeyMap = TenantKeyMap> extends Pick<AthenaGatewayCallOptions, 'backend' | 'client' | 'headers'> {
|
|
520
|
+
tenantKeyMap?: TMap;
|
|
521
|
+
tenantContext?: TenantContext<TMap>;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Typed Athena client with registry-driven model resolution and tenant-context propagation.
|
|
525
|
+
*/
|
|
526
|
+
interface TypedAthenaClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>> extends AthenaSdkClient {
|
|
527
|
+
readonly registry: TRegistry;
|
|
528
|
+
readonly tenantKeyMap: Readonly<TTenantMap>;
|
|
529
|
+
readonly tenantContext: TenantContext<TTenantMap>;
|
|
530
|
+
withTenantContext(context: TenantContext<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
|
|
531
|
+
fromModel<TDatabase extends keyof TRegistry & string, TSchema extends keyof TRegistry[TDatabase]['schemas'] & string, TModel extends keyof TRegistry[TDatabase]['schemas'][TSchema]['models'] & string>(database: TDatabase, schema: TSchema, model: TModel): TableQueryBuilder<RowOf<ModelAt<TRegistry, TDatabase, TSchema, TModel>>>;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Creates a typed client bound to a registry contract and optional tenant header mapping.
|
|
535
|
+
*/
|
|
536
|
+
declare function createTypedClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>>(registry: TRegistry, url: string, apiKey: string, options?: TypedClientOptions<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Constructor options for the PostgreSQL introspection provider.
|
|
540
|
+
*/
|
|
541
|
+
interface PostgresIntrospectionProviderOptions {
|
|
542
|
+
connectionString: string;
|
|
543
|
+
database?: string;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Creates a PostgreSQL-backed schema introspection provider.
|
|
547
|
+
*/
|
|
548
|
+
declare function createPostgresIntrospectionProvider(options: PostgresIntrospectionProviderOptions): SchemaIntrospectionProvider;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Supported case transformations for generated symbols and path token variants.
|
|
552
|
+
*/
|
|
553
|
+
type NamingStyle = 'preserve' | 'camel' | 'pascal' | 'snake' | 'kebab';
|
|
554
|
+
/**
|
|
555
|
+
* Naming configuration for generated TypeScript identifiers.
|
|
556
|
+
*/
|
|
557
|
+
interface GeneratorNamingConfig {
|
|
558
|
+
modelType: NamingStyle;
|
|
559
|
+
modelConst: NamingStyle;
|
|
560
|
+
schemaConst: NamingStyle;
|
|
561
|
+
databaseConst: NamingStyle;
|
|
562
|
+
registryConst: NamingStyle;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Stable feature flags for generator output behavior.
|
|
566
|
+
*/
|
|
567
|
+
interface GeneratorFeatureFlags {
|
|
568
|
+
emitRelations: boolean;
|
|
569
|
+
emitRegistry: boolean;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Experimental toggles for optional/forward-compatible generator behavior.
|
|
573
|
+
*/
|
|
574
|
+
interface GeneratorExperimentalFlags {
|
|
575
|
+
/**
|
|
576
|
+
* Legacy compatibility toggle from the initial scaffold.
|
|
577
|
+
* Gateway introspection is now implemented; this flag is retained for additive config compatibility.
|
|
578
|
+
*/
|
|
579
|
+
postgresGatewayIntrospection: boolean;
|
|
580
|
+
/**
|
|
581
|
+
* Enables contract placeholders for future Scylla provider work.
|
|
582
|
+
*/
|
|
583
|
+
scyllaProviderContracts: boolean;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Path templates for each generated artifact category.
|
|
587
|
+
*/
|
|
588
|
+
interface GeneratorOutputTargets {
|
|
589
|
+
model: string;
|
|
590
|
+
schema: string;
|
|
591
|
+
database: string;
|
|
592
|
+
registry: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Output configuration including dynamic placeholder aliases.
|
|
596
|
+
*/
|
|
597
|
+
interface GeneratorOutputConfig {
|
|
598
|
+
targets: GeneratorOutputTargets;
|
|
599
|
+
placeholderMap: Record<string, string>;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Direct PostgreSQL introspection mode (implemented).
|
|
603
|
+
*/
|
|
604
|
+
interface PostgresDirectProviderConfig {
|
|
605
|
+
kind: 'postgres';
|
|
606
|
+
mode: 'direct';
|
|
607
|
+
connectionString: string;
|
|
608
|
+
database?: string;
|
|
609
|
+
schemas?: string[];
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Athena gateway-backed PostgreSQL introspection mode using `/gateway/query`.
|
|
613
|
+
*/
|
|
614
|
+
interface PostgresGatewayProviderConfig {
|
|
615
|
+
kind: 'postgres';
|
|
616
|
+
mode: 'gateway';
|
|
617
|
+
gatewayUrl: string;
|
|
618
|
+
apiKey: string;
|
|
619
|
+
database: string;
|
|
620
|
+
schemas?: string[];
|
|
621
|
+
backend?: BackendType;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Scylla introspection provider contract placeholder (phase-two scaffold).
|
|
625
|
+
*/
|
|
626
|
+
interface ScyllaDirectProviderConfig {
|
|
627
|
+
kind: 'scylla';
|
|
628
|
+
mode: 'direct';
|
|
629
|
+
contactPoints: string[];
|
|
630
|
+
keyspace: string;
|
|
631
|
+
datacenter?: string;
|
|
632
|
+
}
|
|
633
|
+
type GeneratorProviderConfig = PostgresDirectProviderConfig | PostgresGatewayProviderConfig | ScyllaDirectProviderConfig;
|
|
634
|
+
/**
|
|
635
|
+
* Root config contract loaded from `athena.config.ts`.
|
|
636
|
+
*/
|
|
637
|
+
interface AthenaGeneratorConfig {
|
|
638
|
+
provider: GeneratorProviderConfig;
|
|
639
|
+
output: GeneratorOutputConfig;
|
|
640
|
+
naming?: Partial<GeneratorNamingConfig>;
|
|
641
|
+
features?: Partial<GeneratorFeatureFlags>;
|
|
642
|
+
experimental?: Partial<GeneratorExperimentalFlags>;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Normalized generator config with defaults applied.
|
|
646
|
+
*/
|
|
647
|
+
interface NormalizedAthenaGeneratorConfig {
|
|
648
|
+
provider: GeneratorProviderConfig;
|
|
649
|
+
output: GeneratorOutputConfig;
|
|
650
|
+
naming: GeneratorNamingConfig;
|
|
651
|
+
features: GeneratorFeatureFlags;
|
|
652
|
+
experimental: GeneratorExperimentalFlags;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Config loader options for CLI/programmatic usage.
|
|
656
|
+
*/
|
|
657
|
+
interface LoadGeneratorConfigOptions {
|
|
658
|
+
cwd?: string;
|
|
659
|
+
configPath?: string;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Fully loaded config result including resolved file path.
|
|
663
|
+
*/
|
|
664
|
+
interface LoadedGeneratorConfig {
|
|
665
|
+
configPath: string;
|
|
666
|
+
config: NormalizedAthenaGeneratorConfig;
|
|
667
|
+
}
|
|
668
|
+
type GeneratorArtifactKind = 'model' | 'schema' | 'database' | 'registry';
|
|
669
|
+
/**
|
|
670
|
+
* One generated output file.
|
|
671
|
+
*/
|
|
672
|
+
interface GeneratedArtifact {
|
|
673
|
+
kind: GeneratorArtifactKind;
|
|
674
|
+
path: string;
|
|
675
|
+
content: string;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* In-memory generator output payload.
|
|
679
|
+
*/
|
|
680
|
+
interface GeneratedArtifacts {
|
|
681
|
+
snapshot: IntrospectionSnapshot;
|
|
682
|
+
files: GeneratedArtifact[];
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Runtime options for executing the generator pipeline.
|
|
686
|
+
*/
|
|
687
|
+
interface RunGeneratorOptions {
|
|
688
|
+
cwd?: string;
|
|
689
|
+
configPath?: string;
|
|
690
|
+
dryRun?: boolean;
|
|
691
|
+
provider?: SchemaIntrospectionProvider;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Generator execution result including files written to disk.
|
|
695
|
+
*/
|
|
696
|
+
interface RunGeneratorResult extends GeneratedArtifacts {
|
|
697
|
+
configPath: string;
|
|
698
|
+
writtenFiles: string[];
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
declare function normalizeGeneratorConfig(input: AthenaGeneratorConfig): NormalizedAthenaGeneratorConfig;
|
|
702
|
+
/**
|
|
703
|
+
* Typed identity helper for authoring generator configs.
|
|
704
|
+
*/
|
|
705
|
+
declare function defineGeneratorConfig<TConfig extends AthenaGeneratorConfig>(config: TConfig): TConfig;
|
|
706
|
+
/**
|
|
707
|
+
* Finds a supported generator config filename in the provided directory.
|
|
708
|
+
*/
|
|
709
|
+
declare function findGeneratorConfigPath(cwd?: string): string | undefined;
|
|
710
|
+
/**
|
|
711
|
+
* Loads and normalizes `athena.config.*` from disk.
|
|
712
|
+
*/
|
|
713
|
+
declare function loadGeneratorConfig(options?: LoadGeneratorConfigOptions): Promise<LoadedGeneratorConfig>;
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Generates model/schema/database/registry source artifacts from an introspection snapshot.
|
|
717
|
+
*/
|
|
718
|
+
declare function generateArtifactsFromSnapshot(snapshot: IntrospectionSnapshot, config: AthenaGeneratorConfig | NormalizedAthenaGeneratorConfig): GeneratedArtifacts;
|
|
719
|
+
|
|
720
|
+
declare function resolvePostgresColumnType(column: IntrospectionColumn): string;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Resolves a runtime introspection provider from generator config.
|
|
724
|
+
*/
|
|
725
|
+
declare function resolveGeneratorProvider(providerConfig: GeneratorProviderConfig, experimentalFlags: GeneratorExperimentalFlags): SchemaIntrospectionProvider;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* End-to-end generator execution: load config, introspect, render, and optionally write files.
|
|
729
|
+
*/
|
|
730
|
+
declare function runSchemaGenerator(options?: RunGeneratorOptions): Promise<RunGeneratorResult>;
|
|
731
|
+
|
|
732
|
+
export { AthenaClient, AthenaConditionCastType, AthenaError, AthenaErrorCategory, AthenaErrorCode, type AthenaErrorInput, AthenaErrorKind, AthenaGatewayCallOptions, AthenaGatewayErrorDetails, type AthenaGeneratorConfig, type AthenaOperationContext, type AthenaResult, AthenaRpcCallOptions, type AthenaSdkClient, BackendConfig, BackendType, type DatabaseDef, type GeneratedArtifact, type GeneratedArtifacts, type GeneratorArtifactKind, type GeneratorExperimentalFlags, type GeneratorFeatureFlags, type GeneratorNamingConfig, type GeneratorOutputConfig, type GeneratorOutputTargets, type GeneratorProviderConfig, type InsertOf, type IntCoercionOptions, type IntrospectionColumn, type IntrospectionInspectOptions, type IntrospectionRelation, type IntrospectionSchema, type IntrospectionSnapshot, type IntrospectionTable, type IntrospectionTypeKind, type LoadGeneratorConfigOptions, type LoadedGeneratorConfig, type ModelAt, type ModelDef, type ModelMetadata, type ModelRelationKind, type ModelRelationMetadata, type NamingStyle, type NormalizedAthenaError, type NormalizedAthenaGeneratorConfig, type PostgresIntrospectionProviderOptions, type RegistryDef, type RequireAffectedOptions, type RetryBackoffStrategy, type RetryConfig, type RowOf, type RpcOrderOptions, type RpcQueryBuilder, type RunGeneratorOptions, type RunGeneratorResult, type SchemaDef, type SchemaIntrospectionProvider, type TableQueryBuilder, type TenantContext, type TenantContextValue, type TenantKeyMap, type TypedAthenaClient, type TypedClientOptions, type UnwrapOneOptions, type UnwrapOptions, type UpdateOf, assertInt, coerceInt, createClient, createPostgresIntrospectionProvider, createTypedClient, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, findGeneratorConfigPath, generateArtifactsFromSnapshot, identifier, isOk, loadGeneratorConfig, normalizeAthenaError, normalizeGeneratorConfig, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, runSchemaGenerator, unwrap, unwrapOne, unwrapRows, withRetry };
|