@xylex-group/athena 2.10.0 → 2.12.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 +112 -28
- package/dist/browser.cjs +333 -240
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +9 -8
- package/dist/browser.d.ts +9 -8
- package/dist/browser.js +333 -240
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +306 -240
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -3
- package/dist/cli/index.d.ts +4 -3
- package/dist/cli/index.js +306 -240
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-BYii6dU9.d.ts → client-C3x75Zgn.d.cts} +22 -9
- package/dist/{client-B7EQ_hPV.d.cts → client-QUbAs7E8.d.ts} +22 -9
- package/dist/index.cjs +333 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +333 -240
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DACdBLYG.d.cts → model-form-CD1uhWSh.d.cts} +2 -1
- package/dist/{model-form-ByvyyvxB.d.ts → model-form-Dm69I-oO.d.ts} +2 -1
- package/dist/{module-DbHlxpeR.d.ts → module-CW3tWJ10.d.ts} +5 -4
- package/dist/{module-DC96HJa3.d.cts → module-Cxcurfes.d.cts} +5 -4
- package/dist/next/client.cjs +333 -240
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -3
- package/dist/next/client.d.ts +4 -3
- package/dist/next/client.js +333 -240
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +333 -240
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +4 -3
- package/dist/next/server.d.ts +4 -3
- package/dist/next/server.js +333 -240
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-CmUZsXsi.d.cts → pipeline-B14jVK7J.d.cts} +1 -1
- package/dist/{pipeline-DZMsPxUg.d.ts → pipeline-BAwb6Vzm.d.ts} +1 -1
- package/dist/react.cjs +234 -98
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -4
- package/dist/react.d.ts +5 -4
- package/dist/react.js +234 -98
- package/dist/react.js.map +1 -1
- package/dist/{shared-DRptGBWP.d.ts → shared-0Kdc74lu.d.ts} +2 -2
- package/dist/{shared-BMVGMnti.d.cts → shared-C0wVICRv.d.cts} +2 -2
- package/dist/{types-C-YvfgYh.d.cts → types-BcVmPBP-.d.ts} +2 -1
- package/dist/types-Cq4-NoB4.d.ts +204 -0
- package/dist/types-CwJCPpLD.d.cts +236 -0
- package/dist/types-CwJCPpLD.d.ts +236 -0
- package/dist/{types-CRjDwmtJ.d.ts → types-DMOoYnPS.d.cts} +2 -1
- package/dist/types-Dr849HD6.d.cts +204 -0
- package/dist/utils.cjs +276 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +58 -1
- package/dist/utils.d.ts +58 -1
- package/dist/utils.js +269 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/types-BeZIHduP.d.cts +0 -428
- package/dist/types-BeZIHduP.d.ts +0 -428
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* athena gateway types
|
|
3
|
+
*
|
|
4
|
+
* type definitions for the athena gateway api client and react hook
|
|
5
|
+
*/
|
|
6
|
+
type AthenaGatewayMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
7
|
+
type AthenaGatewayEndpointPath = '/gateway/fetch' | '/gateway/insert' | '/gateway/update' | '/gateway/delete' | '/gateway/rpc' | '/gateway/query' | `/rpc/${string}` | `/storage/${string}`;
|
|
8
|
+
type AthenaCountOption = 'exact' | 'planned' | 'estimated';
|
|
9
|
+
type AthenaJsonPrimitive = string | number | boolean | null;
|
|
10
|
+
type AthenaJsonValue = AthenaJsonPrimitive | AthenaJsonObject | AthenaJsonArray;
|
|
11
|
+
interface AthenaJsonObject {
|
|
12
|
+
[key: string]: AthenaJsonValue;
|
|
13
|
+
}
|
|
14
|
+
type AthenaJsonArray = AthenaJsonValue[];
|
|
15
|
+
type AthenaConditionValue = AthenaJsonPrimitive;
|
|
16
|
+
type AthenaConditionArrayValue = Array<AthenaConditionValue>;
|
|
17
|
+
type AthenaConditionCastType = string;
|
|
18
|
+
type AthenaConditionOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'contains' | 'containedBy' | 'not' | 'or';
|
|
19
|
+
interface AthenaGatewayCondition {
|
|
20
|
+
column?: string;
|
|
21
|
+
operator: AthenaConditionOperator;
|
|
22
|
+
value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional explicit cast for `value` (for example `"uuid"`).
|
|
25
|
+
* Older gateways ignore unknown fields; newer gateways may use this hint.
|
|
26
|
+
*/
|
|
27
|
+
value_cast?: AthenaConditionCastType;
|
|
28
|
+
/**
|
|
29
|
+
* Optional explicit cast for `column` (for example `"text"`).
|
|
30
|
+
* Used by SDK SQL fallback for typed comparisons.
|
|
31
|
+
*/
|
|
32
|
+
column_cast?: AthenaConditionCastType;
|
|
33
|
+
/** Back-compat shape expected by older gateway implementations */
|
|
34
|
+
eq_column?: string;
|
|
35
|
+
eq_value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
36
|
+
/** Optional cast hint aligned with legacy eq_* fields */
|
|
37
|
+
eq_value_cast?: AthenaConditionCastType;
|
|
38
|
+
/** Optional cast hint aligned with legacy eq_* fields */
|
|
39
|
+
eq_column_cast?: AthenaConditionCastType;
|
|
40
|
+
}
|
|
41
|
+
type AthenaSortDirection = 'ascending' | 'descending';
|
|
42
|
+
interface AthenaSortBy {
|
|
43
|
+
field: string;
|
|
44
|
+
direction: AthenaSortDirection;
|
|
45
|
+
}
|
|
46
|
+
interface AthenaFetchPayload {
|
|
47
|
+
select?: string | AthenaJsonObject;
|
|
48
|
+
view_name?: string;
|
|
49
|
+
table_name?: string;
|
|
50
|
+
columns?: string[] | string;
|
|
51
|
+
where?: AthenaJsonObject;
|
|
52
|
+
orderBy?: AthenaJsonObject | AthenaJsonArray;
|
|
53
|
+
conditions?: AthenaGatewayCondition[];
|
|
54
|
+
limit?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
current_page?: number;
|
|
57
|
+
page_size?: number;
|
|
58
|
+
total_pages?: number;
|
|
59
|
+
strip_nulls?: boolean;
|
|
60
|
+
count?: AthenaCountOption;
|
|
61
|
+
head?: boolean;
|
|
62
|
+
group_by?: string;
|
|
63
|
+
time_granularity?: 'day' | 'hour' | 'minute';
|
|
64
|
+
aggregation_column?: string;
|
|
65
|
+
aggregation_strategy?: 'cumulative_sum';
|
|
66
|
+
aggregation_dedup?: boolean;
|
|
67
|
+
sort_by?: AthenaSortBy;
|
|
68
|
+
}
|
|
69
|
+
interface AthenaInsertPayload<TInsertBody = AthenaJsonObject, TUpdateBody = AthenaJsonObject> {
|
|
70
|
+
table_name: string;
|
|
71
|
+
insert_body: TInsertBody | TInsertBody[];
|
|
72
|
+
update_body?: TUpdateBody;
|
|
73
|
+
columns?: string[] | string;
|
|
74
|
+
count?: AthenaCountOption;
|
|
75
|
+
head?: boolean;
|
|
76
|
+
default_to_null?: boolean;
|
|
77
|
+
on_conflict?: string | string[];
|
|
78
|
+
}
|
|
79
|
+
interface AthenaDeletePayload {
|
|
80
|
+
table_name: string;
|
|
81
|
+
resource_id?: string;
|
|
82
|
+
columns?: string[] | string;
|
|
83
|
+
conditions?: AthenaGatewayCondition[];
|
|
84
|
+
sort_by?: AthenaSortBy;
|
|
85
|
+
current_page?: number;
|
|
86
|
+
page_size?: number;
|
|
87
|
+
total_pages?: number;
|
|
88
|
+
}
|
|
89
|
+
interface AthenaUpdatePayload<TUpdateBody = AthenaJsonObject> extends AthenaFetchPayload {
|
|
90
|
+
set?: TUpdateBody;
|
|
91
|
+
data?: TUpdateBody;
|
|
92
|
+
}
|
|
93
|
+
type AthenaRpcFilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in';
|
|
94
|
+
interface AthenaRpcFilter {
|
|
95
|
+
column: string;
|
|
96
|
+
operator: AthenaRpcFilterOperator;
|
|
97
|
+
value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
98
|
+
}
|
|
99
|
+
interface AthenaRpcOrder {
|
|
100
|
+
column: string;
|
|
101
|
+
ascending?: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface AthenaRpcPayload<TArgs = AthenaJsonObject> {
|
|
104
|
+
function: string;
|
|
105
|
+
function_name?: string;
|
|
106
|
+
schema?: string;
|
|
107
|
+
args?: TArgs;
|
|
108
|
+
select?: string;
|
|
109
|
+
filters?: AthenaRpcFilter[];
|
|
110
|
+
count?: AthenaCountOption;
|
|
111
|
+
head?: boolean;
|
|
112
|
+
limit?: number;
|
|
113
|
+
offset?: number;
|
|
114
|
+
order?: AthenaRpcOrder;
|
|
115
|
+
}
|
|
116
|
+
interface AthenaQueryPayload {
|
|
117
|
+
query: string;
|
|
118
|
+
}
|
|
119
|
+
/** Backend type for Athena client (aligns with athena-rs) */
|
|
120
|
+
type BackendType = 'athena' | 'postgrest' | 'postgresql' | 'scylladb';
|
|
121
|
+
/** Backend config: type from SDK + backend-scoped options */
|
|
122
|
+
interface BackendConfig {
|
|
123
|
+
type: BackendType;
|
|
124
|
+
options?: AthenaJsonObject;
|
|
125
|
+
}
|
|
126
|
+
/** Pre-defined backends for lean usage: backend: Backend.Athena */
|
|
127
|
+
declare const Backend: {
|
|
128
|
+
readonly Athena: {
|
|
129
|
+
readonly type: "athena";
|
|
130
|
+
};
|
|
131
|
+
readonly Postgrest: {
|
|
132
|
+
readonly type: "postgrest";
|
|
133
|
+
};
|
|
134
|
+
readonly PostgreSQL: {
|
|
135
|
+
readonly type: "postgresql";
|
|
136
|
+
};
|
|
137
|
+
readonly ScyllaDB: {
|
|
138
|
+
readonly type: "scylladb";
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
type BackendOption = BackendConfig | BackendType;
|
|
142
|
+
interface AthenaGatewayBaseOptions {
|
|
143
|
+
baseUrl?: string;
|
|
144
|
+
apiKey?: string;
|
|
145
|
+
/** Overrides `X-Athena-Key` while leaving `apikey` / `x-api-key` on `apiKey`. */
|
|
146
|
+
athenaKey?: string | null;
|
|
147
|
+
client?: string;
|
|
148
|
+
backend?: BackendOption;
|
|
149
|
+
publishEvent?: string;
|
|
150
|
+
forceNoCache?: boolean;
|
|
151
|
+
headers?: Record<string, string>;
|
|
152
|
+
userId?: string | null;
|
|
153
|
+
organizationId?: string | null;
|
|
154
|
+
/** Direct PostgreSQL URI forwarded as `x-pg-uri` (OpenAPI preferred routing header). */
|
|
155
|
+
pgUri?: string | null;
|
|
156
|
+
/** JDBC/PostgreSQL URI mirrored to `x-athena-jdbc-url` and `x-jdbc-url` compatibility headers. */
|
|
157
|
+
jdbcUrl?: string | null;
|
|
158
|
+
bearerToken?: string | null;
|
|
159
|
+
cookie?: string | null;
|
|
160
|
+
sessionToken?: string | null;
|
|
161
|
+
}
|
|
162
|
+
type AthenaGatewayHookConfig = AthenaGatewayBaseOptions;
|
|
163
|
+
interface AthenaGatewayCallOptions extends AthenaGatewayBaseOptions {
|
|
164
|
+
schema?: string;
|
|
165
|
+
count?: AthenaCountOption;
|
|
166
|
+
head?: boolean;
|
|
167
|
+
defaultToNull?: boolean;
|
|
168
|
+
stripNulls?: boolean;
|
|
169
|
+
onConflict?: string | string[];
|
|
170
|
+
updateBody?: AthenaJsonObject;
|
|
171
|
+
}
|
|
172
|
+
interface AthenaRpcCallOptions extends AthenaGatewayCallOptions {
|
|
173
|
+
count?: AthenaCountOption;
|
|
174
|
+
get?: boolean;
|
|
175
|
+
}
|
|
176
|
+
interface AthenaGatewayResponse<T = unknown> {
|
|
177
|
+
ok: boolean;
|
|
178
|
+
status: number;
|
|
179
|
+
statusText?: string | null;
|
|
180
|
+
data: T | null;
|
|
181
|
+
count?: number | null;
|
|
182
|
+
error?: string;
|
|
183
|
+
errorDetails?: AthenaGatewayErrorDetails | null;
|
|
184
|
+
raw: unknown;
|
|
185
|
+
}
|
|
186
|
+
type AthenaGatewayErrorCode = 'NETWORK_ERROR' | 'INVALID_URL' | 'HTTP_ERROR' | 'INVALID_JSON' | 'UNKNOWN_ERROR';
|
|
187
|
+
interface AthenaGatewayErrorDetails {
|
|
188
|
+
code: AthenaGatewayErrorCode;
|
|
189
|
+
message: string;
|
|
190
|
+
status: number;
|
|
191
|
+
endpoint?: AthenaGatewayEndpointPath;
|
|
192
|
+
method?: AthenaGatewayMethod;
|
|
193
|
+
requestId?: string;
|
|
194
|
+
hint?: string;
|
|
195
|
+
cause?: string;
|
|
196
|
+
}
|
|
197
|
+
interface AthenaGatewayConnectionOptions {
|
|
198
|
+
path?: `/${string}`;
|
|
199
|
+
headers?: Record<string, string>;
|
|
200
|
+
signal?: AbortSignal;
|
|
201
|
+
}
|
|
202
|
+
interface AthenaGatewayConnectionResult {
|
|
203
|
+
ok: boolean;
|
|
204
|
+
reachable: boolean;
|
|
205
|
+
status: number;
|
|
206
|
+
statusText?: string | null;
|
|
207
|
+
baseUrl: string;
|
|
208
|
+
url: string;
|
|
209
|
+
error?: string;
|
|
210
|
+
errorDetails?: AthenaGatewayErrorDetails | null;
|
|
211
|
+
raw: unknown;
|
|
212
|
+
}
|
|
213
|
+
interface AthenaGatewayResponseLog extends AthenaGatewayResponse {
|
|
214
|
+
timestamp: string;
|
|
215
|
+
}
|
|
216
|
+
interface AthenaGatewayCallLog {
|
|
217
|
+
endpoint: AthenaGatewayEndpointPath;
|
|
218
|
+
method: AthenaGatewayMethod;
|
|
219
|
+
payload: unknown;
|
|
220
|
+
headers: Record<string, string>;
|
|
221
|
+
timestamp: string;
|
|
222
|
+
}
|
|
223
|
+
interface AthenaGatewayHookResult {
|
|
224
|
+
fetchGateway: <T = unknown>(payload: AthenaFetchPayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
|
|
225
|
+
insertGateway: <T = unknown>(payload: AthenaInsertPayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
|
|
226
|
+
updateGateway: <T = unknown>(payload: AthenaUpdatePayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
|
|
227
|
+
deleteGateway: <T = unknown>(payload: AthenaDeletePayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
|
|
228
|
+
rpcGateway: <T = unknown>(payload: AthenaRpcPayload, options?: AthenaRpcCallOptions) => Promise<AthenaGatewayResponse<T>>;
|
|
229
|
+
isLoading: boolean;
|
|
230
|
+
error: string | null;
|
|
231
|
+
lastRequest: AthenaGatewayCallLog | null;
|
|
232
|
+
lastResponse: AthenaGatewayResponseLog | null;
|
|
233
|
+
baseUrl: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { type AthenaConditionCastType as A, Backend as B, type AthenaGatewayBaseOptions as C, type AthenaConditionValue as D, type AthenaConditionArrayValue as E, type AthenaGatewayCondition as F, type AthenaSortBy as G, type AthenaConditionOperator as H, type BackendOption as I, type AthenaGatewayCallOptions as a, type AthenaGatewayConnectionOptions as b, type AthenaGatewayConnectionResult as c, type AthenaGatewayErrorCode as d, type AthenaGatewayErrorDetails as e, type AthenaJsonArray as f, type AthenaJsonObject as g, type AthenaJsonPrimitive as h, type AthenaJsonValue as i, type AthenaRpcCallOptions as j, type AthenaRpcFilter as k, type AthenaRpcFilterOperator as l, type AthenaRpcOrder as m, type AthenaRpcPayload as n, type BackendConfig as o, type BackendType as p, type AthenaGatewayHookConfig as q, type AthenaGatewayHookResult as r, type AthenaDeletePayload as s, type AthenaFetchPayload as t, type AthenaGatewayResponse as u, type AthenaInsertPayload as v, type AthenaUpdatePayload as w, type AthenaGatewayEndpointPath as x, type AthenaGatewayMethod as y, type AthenaQueryPayload as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as BackendType } from './types-CwJCPpLD.cjs';
|
|
2
|
+
import { I as IntrospectionSnapshot, S as SchemaIntrospectionProvider } from './types-Dr849HD6.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Supported case transformations for generated symbols and path token variants.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { p as BackendType } from './types-CwJCPpLD.cjs';
|
|
2
|
+
|
|
3
|
+
type ModelKey = string;
|
|
4
|
+
type ColumnKey = string;
|
|
5
|
+
/**
|
|
6
|
+
* Supported column helper families for table-builder definitions.
|
|
7
|
+
*/
|
|
8
|
+
type ModelColumnKind = 'boolean' | 'number' | 'string' | 'json' | 'enumeration';
|
|
9
|
+
/**
|
|
10
|
+
* Optional per-column metadata carried by model contracts.
|
|
11
|
+
*/
|
|
12
|
+
interface ModelColumnMetadata {
|
|
13
|
+
kind: ModelColumnKind;
|
|
14
|
+
columnName?: string;
|
|
15
|
+
nullable?: boolean;
|
|
16
|
+
hasDefault?: boolean;
|
|
17
|
+
isGenerated?: boolean;
|
|
18
|
+
enumValues?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Runtime values that can safely be serialized into tenant-scoped headers.
|
|
22
|
+
*/
|
|
23
|
+
type TenantContextValue = string | number | boolean | null | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Compile-time map of tenant context keys to outbound header names.
|
|
26
|
+
*/
|
|
27
|
+
type TenantKeyMap = Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Partial tenant context keyed by `TenantKeyMap`.
|
|
30
|
+
*/
|
|
31
|
+
type TenantContext<TMap extends TenantKeyMap> = Partial<Record<keyof TMap, TenantContextValue>>;
|
|
32
|
+
/**
|
|
33
|
+
* Supported relationship cardinalities for model metadata and introspection snapshots.
|
|
34
|
+
*/
|
|
35
|
+
type ModelRelationKind = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
36
|
+
/**
|
|
37
|
+
* Base metadata shape shared by typed model definitions and introspection snapshots.
|
|
38
|
+
* This type is intentionally row-agnostic so it can be used for generic registries.
|
|
39
|
+
*/
|
|
40
|
+
interface ModelMetadataBase {
|
|
41
|
+
database?: string;
|
|
42
|
+
schema?: string;
|
|
43
|
+
model?: string;
|
|
44
|
+
tableName?: string;
|
|
45
|
+
primaryKey: string[];
|
|
46
|
+
nullable?: Partial<Record<string, boolean>>;
|
|
47
|
+
columns?: Partial<Record<string, ModelColumnMetadata>>;
|
|
48
|
+
relations?: Record<string, ModelRelationMetadata>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Strongly-typed model metadata linked to a row shape.
|
|
52
|
+
*/
|
|
53
|
+
type ModelMetadata<Row> = Omit<ModelMetadataBase, 'primaryKey' | 'nullable'> & {
|
|
54
|
+
primaryKey: Array<Extract<keyof Row, string>>;
|
|
55
|
+
nullable?: Partial<Record<Extract<keyof Row, string>, boolean>>;
|
|
56
|
+
columns?: Partial<Record<Extract<keyof Row, string>, ModelColumnMetadata>>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Relation metadata for model contracts and introspection snapshots.
|
|
60
|
+
*/
|
|
61
|
+
interface ModelRelationMetadata {
|
|
62
|
+
kind: ModelRelationKind;
|
|
63
|
+
sourceColumns: ColumnKey[];
|
|
64
|
+
targetSchema: string;
|
|
65
|
+
targetModel: ModelKey;
|
|
66
|
+
targetColumns: ColumnKey[];
|
|
67
|
+
targetDatabase?: string;
|
|
68
|
+
through?: {
|
|
69
|
+
schema: string;
|
|
70
|
+
model: string;
|
|
71
|
+
sourceColumns: ColumnKey[];
|
|
72
|
+
targetColumns: ColumnKey[];
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Core model definition contract used by typed registries.
|
|
77
|
+
*/
|
|
78
|
+
interface ModelDef<Row, Insert = Partial<Row>, Update = Partial<Insert>, Meta extends ModelMetadataBase = ModelMetadata<Row>> {
|
|
79
|
+
readonly meta: Meta;
|
|
80
|
+
readonly __types?: {
|
|
81
|
+
row: Row;
|
|
82
|
+
insert: Insert;
|
|
83
|
+
update: Update;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Row-agnostic model definition used as a generic constraint.
|
|
88
|
+
*/
|
|
89
|
+
type AnyModelDef = ModelDef<unknown, unknown, unknown, ModelMetadataBase>;
|
|
90
|
+
/**
|
|
91
|
+
* Public model/table value that carries Athena target metadata plus row/write typings.
|
|
92
|
+
* This can be passed directly to `client.from(...)` for opt-in target inference.
|
|
93
|
+
*/
|
|
94
|
+
type AthenaModelTarget<Row = unknown, Insert = unknown, Update = unknown> = ModelDef<Row, Insert, Update, ModelMetadataBase>;
|
|
95
|
+
/**
|
|
96
|
+
* Schema-level model registry.
|
|
97
|
+
*/
|
|
98
|
+
interface SchemaDef<Models extends Record<ModelKey, AnyModelDef>> {
|
|
99
|
+
readonly models: Models;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Database-level schema registry.
|
|
103
|
+
*/
|
|
104
|
+
interface DatabaseDef<Schemas extends Record<string, SchemaDef<Record<ModelKey, AnyModelDef>>>> {
|
|
105
|
+
readonly schemas: Schemas;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Top-level registry keyed by logical database names.
|
|
109
|
+
*/
|
|
110
|
+
type RegistryDef<Databases extends Record<string, DatabaseDef<Record<string, SchemaDef<Record<ModelKey, AnyModelDef>>>>>> = Databases;
|
|
111
|
+
/**
|
|
112
|
+
* Extracts row type from a model definition.
|
|
113
|
+
*/
|
|
114
|
+
type RowOf<TModel extends AnyModelDef> = TModel extends ModelDef<infer TRow, unknown, unknown, ModelMetadataBase> ? TRow : never;
|
|
115
|
+
/**
|
|
116
|
+
* Extracts insert type from a model definition.
|
|
117
|
+
*/
|
|
118
|
+
type InsertOf<TModel extends AnyModelDef> = TModel extends ModelDef<unknown, infer TInsert, unknown, ModelMetadataBase> ? TInsert : never;
|
|
119
|
+
/**
|
|
120
|
+
* Extracts update type from a model definition.
|
|
121
|
+
*/
|
|
122
|
+
type UpdateOf<TModel extends AnyModelDef> = TModel extends ModelDef<unknown, unknown, infer TUpdate, ModelMetadataBase> ? TUpdate : never;
|
|
123
|
+
/**
|
|
124
|
+
* Resolves a model definition from a registry path.
|
|
125
|
+
*/
|
|
126
|
+
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];
|
|
127
|
+
/**
|
|
128
|
+
* Introspection-level column type families.
|
|
129
|
+
*/
|
|
130
|
+
type IntrospectionTypeKind = 'scalar' | 'enum' | 'domain' | 'range' | 'multirange' | 'composite';
|
|
131
|
+
/**
|
|
132
|
+
* Introspected column metadata.
|
|
133
|
+
*/
|
|
134
|
+
interface IntrospectionColumn {
|
|
135
|
+
name: string;
|
|
136
|
+
dataType: string;
|
|
137
|
+
udtName: string;
|
|
138
|
+
typeKind: IntrospectionTypeKind;
|
|
139
|
+
isNullable: boolean;
|
|
140
|
+
isPrimaryKey: boolean;
|
|
141
|
+
hasDefault: boolean;
|
|
142
|
+
isGenerated: boolean;
|
|
143
|
+
arrayDimensions: number;
|
|
144
|
+
enumValues?: string[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Introspected relationship metadata.
|
|
148
|
+
*/
|
|
149
|
+
interface IntrospectionRelation {
|
|
150
|
+
name: string;
|
|
151
|
+
kind: ModelRelationKind;
|
|
152
|
+
sourceColumns: string[];
|
|
153
|
+
targetSchema: string;
|
|
154
|
+
targetModel: string;
|
|
155
|
+
targetColumns: string[];
|
|
156
|
+
targetDatabase?: string;
|
|
157
|
+
through?: {
|
|
158
|
+
schema: string;
|
|
159
|
+
model: string;
|
|
160
|
+
sourceColumns: string[];
|
|
161
|
+
targetColumns: string[];
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Introspected table metadata.
|
|
166
|
+
*/
|
|
167
|
+
interface IntrospectionTable {
|
|
168
|
+
schema: string;
|
|
169
|
+
name: string;
|
|
170
|
+
columns: Record<string, IntrospectionColumn>;
|
|
171
|
+
primaryKey: string[];
|
|
172
|
+
relations: Record<string, IntrospectionRelation>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Introspected schema metadata.
|
|
176
|
+
*/
|
|
177
|
+
interface IntrospectionSchema {
|
|
178
|
+
name: string;
|
|
179
|
+
tables: Record<string, IntrospectionTable>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Normalized output of a schema introspection pass.
|
|
183
|
+
*/
|
|
184
|
+
interface IntrospectionSnapshot {
|
|
185
|
+
backend: BackendType;
|
|
186
|
+
database: string;
|
|
187
|
+
generatedAt: string;
|
|
188
|
+
schemas: Record<string, IntrospectionSchema>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Options accepted by introspection providers.
|
|
192
|
+
*/
|
|
193
|
+
interface IntrospectionInspectOptions {
|
|
194
|
+
schemas?: string[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Provider contract implemented by backend-specific introspection adapters.
|
|
198
|
+
*/
|
|
199
|
+
interface SchemaIntrospectionProvider {
|
|
200
|
+
readonly backend: BackendType;
|
|
201
|
+
inspect(options?: IntrospectionInspectOptions): Promise<IntrospectionSnapshot>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type { AthenaModelTarget as A, DatabaseDef as D, IntrospectionSnapshot as I, ModelAt as M, RegistryDef as R, SchemaIntrospectionProvider as S, TenantContext as T, UpdateOf as U, InsertOf as a, IntrospectionColumn as b, IntrospectionInspectOptions as c, IntrospectionRelation as d, IntrospectionSchema as e, IntrospectionTable as f, IntrospectionTypeKind as g, ModelColumnKind as h, ModelColumnMetadata as i, ModelDef as j, ModelMetadata as k, ModelRelationKind as l, ModelRelationMetadata as m, RowOf as n, SchemaDef as o, TenantContextValue as p, TenantKeyMap as q, AnyModelDef as r };
|