@xylex-group/athena 1.6.1 → 1.6.2
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 +31 -6
- package/bin/athena-js.js +74 -6
- package/dist/cli/index.cjs +158 -24
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +21 -2
- package/dist/cli/index.d.ts +21 -2
- package/dist/cli/index.js +157 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/errors-1b-LSTum.d.ts +31 -0
- package/dist/errors-BYRK5phv.d.cts +31 -0
- package/dist/index.cjs +68 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -338
- package/dist/index.d.ts +6 -338
- package/dist/index.js +68 -10
- package/dist/index.js.map +1 -1
- package/dist/pipeline-BQzpSLD3.d.ts +338 -0
- package/dist/pipeline-CA2aexDl.d.cts +338 -0
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/{errors-C4GJaFI_.d.cts → types-v6UyGg-x.d.cts} +1 -29
- package/dist/{errors-C4GJaFI_.d.ts → types-v6UyGg-x.d.ts} +1 -29
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { m as AthenaGatewayErrorCode, u as AthenaGatewayEndpointPath, v as AthenaGatewayMethod, e as AthenaGatewayErrorDetails, t as AthenaGatewayResponse } from './types-v6UyGg-x.js';
|
|
2
|
+
|
|
3
|
+
interface AthenaGatewayErrorInput {
|
|
4
|
+
code: AthenaGatewayErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
status?: number;
|
|
7
|
+
endpoint?: AthenaGatewayEndpointPath;
|
|
8
|
+
method?: AthenaGatewayMethod;
|
|
9
|
+
requestId?: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
cause?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Canonical error for gateway failures.
|
|
15
|
+
* Holds request context and machine-readable classification.
|
|
16
|
+
*/
|
|
17
|
+
declare class AthenaGatewayError extends Error {
|
|
18
|
+
readonly code: AthenaGatewayErrorCode;
|
|
19
|
+
readonly status: number;
|
|
20
|
+
readonly endpoint?: AthenaGatewayEndpointPath;
|
|
21
|
+
readonly method?: AthenaGatewayMethod;
|
|
22
|
+
readonly requestId?: string;
|
|
23
|
+
readonly hint?: string;
|
|
24
|
+
readonly causeDetail?: string;
|
|
25
|
+
constructor(input: AthenaGatewayErrorInput);
|
|
26
|
+
toDetails(): AthenaGatewayErrorDetails;
|
|
27
|
+
static fromResponse<T>(response: AthenaGatewayResponse<T>, fallback: Omit<AthenaGatewayErrorInput, 'code' | 'message' | 'status'>): AthenaGatewayError;
|
|
28
|
+
}
|
|
29
|
+
declare function isAthenaGatewayError(error: unknown): error is AthenaGatewayError;
|
|
30
|
+
|
|
31
|
+
export { AthenaGatewayError as A, isAthenaGatewayError as i };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { m as AthenaGatewayErrorCode, u as AthenaGatewayEndpointPath, v as AthenaGatewayMethod, e as AthenaGatewayErrorDetails, t as AthenaGatewayResponse } from './types-v6UyGg-x.cjs';
|
|
2
|
+
|
|
3
|
+
interface AthenaGatewayErrorInput {
|
|
4
|
+
code: AthenaGatewayErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
status?: number;
|
|
7
|
+
endpoint?: AthenaGatewayEndpointPath;
|
|
8
|
+
method?: AthenaGatewayMethod;
|
|
9
|
+
requestId?: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
cause?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Canonical error for gateway failures.
|
|
15
|
+
* Holds request context and machine-readable classification.
|
|
16
|
+
*/
|
|
17
|
+
declare class AthenaGatewayError extends Error {
|
|
18
|
+
readonly code: AthenaGatewayErrorCode;
|
|
19
|
+
readonly status: number;
|
|
20
|
+
readonly endpoint?: AthenaGatewayEndpointPath;
|
|
21
|
+
readonly method?: AthenaGatewayMethod;
|
|
22
|
+
readonly requestId?: string;
|
|
23
|
+
readonly hint?: string;
|
|
24
|
+
readonly causeDetail?: string;
|
|
25
|
+
constructor(input: AthenaGatewayErrorInput);
|
|
26
|
+
toDetails(): AthenaGatewayErrorDetails;
|
|
27
|
+
static fromResponse<T>(response: AthenaGatewayResponse<T>, fallback: Omit<AthenaGatewayErrorInput, 'code' | 'message' | 'status'>): AthenaGatewayError;
|
|
28
|
+
}
|
|
29
|
+
declare function isAthenaGatewayError(error: unknown): error is AthenaGatewayError;
|
|
30
|
+
|
|
31
|
+
export { AthenaGatewayError as A, isAthenaGatewayError as i };
|
package/dist/index.cjs
CHANGED
|
@@ -1968,6 +1968,58 @@ function toTypeKind(code) {
|
|
|
1968
1968
|
function escapeSqlLiteral(value) {
|
|
1969
1969
|
return value.replace(/'/g, "''");
|
|
1970
1970
|
}
|
|
1971
|
+
function parsePostgresArrayLiteral(text) {
|
|
1972
|
+
const body = text.slice(1, -1).trim();
|
|
1973
|
+
if (!body) return [];
|
|
1974
|
+
const values = [];
|
|
1975
|
+
let current = "";
|
|
1976
|
+
let inQuotes = false;
|
|
1977
|
+
let escaped = false;
|
|
1978
|
+
for (const char of body) {
|
|
1979
|
+
if (escaped) {
|
|
1980
|
+
current += char;
|
|
1981
|
+
escaped = false;
|
|
1982
|
+
continue;
|
|
1983
|
+
}
|
|
1984
|
+
if (char === "\\") {
|
|
1985
|
+
escaped = true;
|
|
1986
|
+
continue;
|
|
1987
|
+
}
|
|
1988
|
+
if (char === '"') {
|
|
1989
|
+
inQuotes = !inQuotes;
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
if (char === "," && !inQuotes) {
|
|
1993
|
+
values.push(current);
|
|
1994
|
+
current = "";
|
|
1995
|
+
continue;
|
|
1996
|
+
}
|
|
1997
|
+
current += char;
|
|
1998
|
+
}
|
|
1999
|
+
values.push(current);
|
|
2000
|
+
return values.map((value) => value.trim()).filter((value) => value.length > 0);
|
|
2001
|
+
}
|
|
2002
|
+
function coerceStringArray(value) {
|
|
2003
|
+
if (Array.isArray(value)) {
|
|
2004
|
+
return value.map((item) => typeof item === "string" ? item : String(item)).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
2005
|
+
}
|
|
2006
|
+
if (typeof value === "string") {
|
|
2007
|
+
const trimmed = value.trim();
|
|
2008
|
+
if (!trimmed) return [];
|
|
2009
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
2010
|
+
try {
|
|
2011
|
+
const parsed = JSON.parse(trimmed);
|
|
2012
|
+
return coerceStringArray(parsed);
|
|
2013
|
+
} catch {
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
2017
|
+
return parsePostgresArrayLiteral(trimmed);
|
|
2018
|
+
}
|
|
2019
|
+
return trimmed.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
2020
|
+
}
|
|
2021
|
+
return [];
|
|
2022
|
+
}
|
|
1971
2023
|
function buildSchemaArrayLiteral(schemas) {
|
|
1972
2024
|
const normalized = schemas.length > 0 ? schemas : ["public"];
|
|
1973
2025
|
const literals = normalized.map((schema) => `'${escapeSqlLiteral(schema)}'`).join(", ");
|
|
@@ -2007,8 +2059,10 @@ var PostgresCatalogSnapshotAssembler = class {
|
|
|
2007
2059
|
addPrimaryKeyRows(primaryKeyRows) {
|
|
2008
2060
|
for (const row of primaryKeyRows) {
|
|
2009
2061
|
const table = this.ensureTable(row.schema_name, row.table_name);
|
|
2010
|
-
|
|
2011
|
-
|
|
2062
|
+
const primaryKeyColumns = coerceStringArray(row.columns);
|
|
2063
|
+
row.columns = primaryKeyColumns;
|
|
2064
|
+
table.primaryKey = primaryKeyColumns;
|
|
2065
|
+
for (const columnName of primaryKeyColumns) {
|
|
2012
2066
|
const column = table.columns[columnName];
|
|
2013
2067
|
if (column) {
|
|
2014
2068
|
column.isPrimaryKey = true;
|
|
@@ -2020,23 +2074,27 @@ var PostgresCatalogSnapshotAssembler = class {
|
|
|
2020
2074
|
for (const row of foreignKeyRows) {
|
|
2021
2075
|
const sourceTable = this.ensureTable(row.source_schema, row.source_table);
|
|
2022
2076
|
const targetTable = this.ensureTable(row.target_schema, row.target_table);
|
|
2077
|
+
const sourceColumns = coerceStringArray(row.source_columns);
|
|
2078
|
+
const targetColumns = coerceStringArray(row.target_columns);
|
|
2079
|
+
row.source_columns = sourceColumns;
|
|
2080
|
+
row.target_columns = targetColumns;
|
|
2023
2081
|
const sourceRelationKind = row.source_is_unique ? "one-to-one" : "many-to-one";
|
|
2024
2082
|
this.upsertRelation(sourceTable, relationKey(row.constraint_name, row.target_table), {
|
|
2025
2083
|
name: row.constraint_name,
|
|
2026
2084
|
kind: sourceRelationKind,
|
|
2027
|
-
sourceColumns
|
|
2085
|
+
sourceColumns,
|
|
2028
2086
|
targetSchema: row.target_schema,
|
|
2029
2087
|
targetModel: row.target_table,
|
|
2030
|
-
targetColumns
|
|
2088
|
+
targetColumns
|
|
2031
2089
|
});
|
|
2032
2090
|
const targetRelationKind = row.source_is_unique ? "one-to-one" : "one-to-many";
|
|
2033
2091
|
this.upsertRelation(targetTable, relationKey(row.source_table), {
|
|
2034
2092
|
name: relationKey(row.source_table, row.constraint_name),
|
|
2035
2093
|
kind: targetRelationKind,
|
|
2036
|
-
sourceColumns:
|
|
2094
|
+
sourceColumns: targetColumns,
|
|
2037
2095
|
targetSchema: row.source_schema,
|
|
2038
2096
|
targetModel: row.source_table,
|
|
2039
|
-
targetColumns:
|
|
2097
|
+
targetColumns: sourceColumns
|
|
2040
2098
|
});
|
|
2041
2099
|
}
|
|
2042
2100
|
}
|
|
@@ -2209,10 +2267,10 @@ var DEFAULT_CONFIG_CANDIDATES = [
|
|
|
2209
2267
|
".athena.config.js"
|
|
2210
2268
|
];
|
|
2211
2269
|
var DEFAULT_TARGETS = {
|
|
2212
|
-
model: "
|
|
2213
|
-
schema: "
|
|
2214
|
-
database: "
|
|
2215
|
-
registry: "
|
|
2270
|
+
model: "athena/models/{model_kebab}.ts",
|
|
2271
|
+
schema: "athena/schema.ts",
|
|
2272
|
+
database: "athena/relations.ts",
|
|
2273
|
+
registry: "athena/config.ts"
|
|
2216
2274
|
};
|
|
2217
2275
|
var DEFAULT_NAMING = {
|
|
2218
2276
|
modelType: "pascal",
|