@xylex-group/athena 1.7.0 → 1.9.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 +24 -11
- package/bin/athena-js.js +0 -0
- package/dist/cli/index.cjs +73 -35
- 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 +73 -35
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +139 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -41
- package/dist/index.d.ts +44 -41
- package/dist/index.js +137 -38
- package/dist/index.js.map +1 -1
- package/dist/model-form-Bm_kqCn2.d.ts +92 -0
- package/dist/model-form-DkS48fsh.d.cts +92 -0
- package/dist/pipeline-C-cN0ACi.d.cts +164 -0
- package/dist/pipeline-CQgV-Yfo.d.ts +164 -0
- package/dist/react.cjs +64 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +62 -1
- package/dist/react.js.map +1 -1
- package/dist/types-BnzoaNRC.d.cts +380 -0
- package/dist/types-BnzoaNRC.d.ts +380 -0
- package/package.json +15 -14
- package/dist/errors-BJGgjHcI.d.cts +0 -31
- package/dist/errors-Bcf5Sftv.d.ts +0 -31
- package/dist/pipeline-BsKuBqmE.d.cts +0 -343
- package/dist/pipeline-xQSjGbqF.d.ts +0 -343
- package/dist/types-wPA1Z4vQ.d.cts +0 -195
- package/dist/types-wPA1Z4vQ.d.ts +0 -195
package/dist/cli/index.d.cts
CHANGED
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1229,6 +1229,12 @@ function mergeOptions(...options) {
|
|
|
1229
1229
|
return { ...acc, ...next };
|
|
1230
1230
|
}, void 0);
|
|
1231
1231
|
}
|
|
1232
|
+
function asAthenaJsonObject(value) {
|
|
1233
|
+
return value;
|
|
1234
|
+
}
|
|
1235
|
+
function asAthenaJsonObjectArray(values) {
|
|
1236
|
+
return values;
|
|
1237
|
+
}
|
|
1232
1238
|
function createMutationQuery(executor, defaultColumns = DEFAULT_COLUMNS) {
|
|
1233
1239
|
let selectedColumns = defaultColumns === null ? void 0 : defaultColumns;
|
|
1234
1240
|
let selectedOptions;
|
|
@@ -1317,6 +1323,22 @@ function buildSelectColumnsClause(columns) {
|
|
|
1317
1323
|
}
|
|
1318
1324
|
return quoteSelectColumnsExpression(columns);
|
|
1319
1325
|
}
|
|
1326
|
+
function resolveTableNameForCall(tableName, schema) {
|
|
1327
|
+
if (!schema) return tableName;
|
|
1328
|
+
const normalizedSchema = schema.trim();
|
|
1329
|
+
if (!normalizedSchema) {
|
|
1330
|
+
throw new Error("schema option must be a non-empty string");
|
|
1331
|
+
}
|
|
1332
|
+
if (tableName.includes(".")) {
|
|
1333
|
+
if (tableName.startsWith(`${normalizedSchema}.`)) {
|
|
1334
|
+
return tableName;
|
|
1335
|
+
}
|
|
1336
|
+
throw new Error(
|
|
1337
|
+
`schema option "${normalizedSchema}" conflicts with schema-qualified table "${tableName}"`
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
return `${normalizedSchema}.${tableName}`;
|
|
1341
|
+
}
|
|
1320
1342
|
function conditionToSqlClause(condition) {
|
|
1321
1343
|
if (!condition.column) return null;
|
|
1322
1344
|
const column = withCast(quoteQualifiedIdentifier(condition.column), condition.column_cast);
|
|
@@ -1396,23 +1418,27 @@ function buildTypedSelectQuery(input) {
|
|
|
1396
1418
|
function createFilterMethods(state, addCondition, self) {
|
|
1397
1419
|
return {
|
|
1398
1420
|
eq(column, value) {
|
|
1399
|
-
|
|
1400
|
-
|
|
1421
|
+
const columnName = String(column);
|
|
1422
|
+
if (shouldUseUuidTextComparison(columnName, value)) {
|
|
1423
|
+
addCondition("eq", columnName, value, { columnCast: "text" });
|
|
1401
1424
|
} else {
|
|
1402
|
-
addCondition("eq",
|
|
1425
|
+
addCondition("eq", columnName, value);
|
|
1403
1426
|
}
|
|
1404
1427
|
return self;
|
|
1405
1428
|
},
|
|
1406
1429
|
eqCast(column, value, cast) {
|
|
1407
|
-
addCondition("eq", column, value, { valueCast: cast });
|
|
1430
|
+
addCondition("eq", String(column), value, { valueCast: cast });
|
|
1408
1431
|
return self;
|
|
1409
1432
|
},
|
|
1410
1433
|
eqUuid(column, value) {
|
|
1411
|
-
addCondition("eq", column, value, { valueCast: "uuid" });
|
|
1434
|
+
addCondition("eq", String(column), value, { valueCast: "uuid" });
|
|
1412
1435
|
return self;
|
|
1413
1436
|
},
|
|
1414
1437
|
match(filters) {
|
|
1415
1438
|
Object.entries(filters).forEach(([column, value]) => {
|
|
1439
|
+
if (value === void 0) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1416
1442
|
if (shouldUseUuidTextComparison(column, value)) {
|
|
1417
1443
|
addCondition("eq", column, value, { columnCast: "text" });
|
|
1418
1444
|
} else {
|
|
@@ -1448,60 +1474,61 @@ function createFilterMethods(state, addCondition, self) {
|
|
|
1448
1474
|
},
|
|
1449
1475
|
order(column, options) {
|
|
1450
1476
|
state.order = {
|
|
1451
|
-
field: column,
|
|
1477
|
+
field: String(column),
|
|
1452
1478
|
direction: options?.ascending === false ? "descending" : "ascending"
|
|
1453
1479
|
};
|
|
1454
1480
|
return self;
|
|
1455
1481
|
},
|
|
1456
1482
|
gt(column, value) {
|
|
1457
|
-
addCondition("gt", column, value);
|
|
1483
|
+
addCondition("gt", String(column), value);
|
|
1458
1484
|
return self;
|
|
1459
1485
|
},
|
|
1460
1486
|
gte(column, value) {
|
|
1461
|
-
addCondition("gte", column, value);
|
|
1487
|
+
addCondition("gte", String(column), value);
|
|
1462
1488
|
return self;
|
|
1463
1489
|
},
|
|
1464
1490
|
lt(column, value) {
|
|
1465
|
-
addCondition("lt", column, value);
|
|
1491
|
+
addCondition("lt", String(column), value);
|
|
1466
1492
|
return self;
|
|
1467
1493
|
},
|
|
1468
1494
|
lte(column, value) {
|
|
1469
|
-
addCondition("lte", column, value);
|
|
1495
|
+
addCondition("lte", String(column), value);
|
|
1470
1496
|
return self;
|
|
1471
1497
|
},
|
|
1472
1498
|
neq(column, value) {
|
|
1473
|
-
addCondition("neq", column, value);
|
|
1499
|
+
addCondition("neq", String(column), value);
|
|
1474
1500
|
return self;
|
|
1475
1501
|
},
|
|
1476
1502
|
like(column, value) {
|
|
1477
|
-
addCondition("like", column, value);
|
|
1503
|
+
addCondition("like", String(column), value);
|
|
1478
1504
|
return self;
|
|
1479
1505
|
},
|
|
1480
1506
|
ilike(column, value) {
|
|
1481
|
-
addCondition("ilike", column, value);
|
|
1507
|
+
addCondition("ilike", String(column), value);
|
|
1482
1508
|
return self;
|
|
1483
1509
|
},
|
|
1484
1510
|
is(column, value) {
|
|
1485
|
-
addCondition("is", column, value);
|
|
1511
|
+
addCondition("is", String(column), value);
|
|
1486
1512
|
return self;
|
|
1487
1513
|
},
|
|
1488
1514
|
in(column, values) {
|
|
1489
|
-
addCondition("in", column, values);
|
|
1515
|
+
addCondition("in", String(column), values);
|
|
1490
1516
|
return self;
|
|
1491
1517
|
},
|
|
1492
1518
|
contains(column, values) {
|
|
1493
|
-
addCondition("contains", column, values);
|
|
1519
|
+
addCondition("contains", String(column), values);
|
|
1494
1520
|
return self;
|
|
1495
1521
|
},
|
|
1496
1522
|
containedBy(column, values) {
|
|
1497
|
-
addCondition("containedBy", column, values);
|
|
1523
|
+
addCondition("containedBy", String(column), values);
|
|
1498
1524
|
return self;
|
|
1499
1525
|
},
|
|
1500
1526
|
not(columnOrExpression, operator, value) {
|
|
1527
|
+
const expression = String(columnOrExpression);
|
|
1501
1528
|
if (operator != null && value !== void 0) {
|
|
1502
|
-
addCondition("not", void 0, `${
|
|
1529
|
+
addCondition("not", void 0, `${expression}.${operator}.${stringifyFilterValue(value)}`);
|
|
1503
1530
|
} else {
|
|
1504
|
-
addCondition("not", void 0,
|
|
1531
|
+
addCondition("not", void 0, expression);
|
|
1505
1532
|
}
|
|
1506
1533
|
return self;
|
|
1507
1534
|
},
|
|
@@ -1671,15 +1698,20 @@ function createTableBuilder(tableName, client) {
|
|
|
1671
1698
|
state.conditions.push(condition);
|
|
1672
1699
|
};
|
|
1673
1700
|
const builder = {};
|
|
1674
|
-
const filterMethods = createFilterMethods(
|
|
1701
|
+
const filterMethods = createFilterMethods(
|
|
1702
|
+
state,
|
|
1703
|
+
addCondition,
|
|
1704
|
+
builder
|
|
1705
|
+
);
|
|
1675
1706
|
const runSelect = async (columns = DEFAULT_COLUMNS, options) => {
|
|
1707
|
+
const resolvedTableName = resolveTableNameForCall(tableName, options?.schema);
|
|
1676
1708
|
const conditions = state.conditions.length ? state.conditions.map((condition) => ({ ...condition })) : void 0;
|
|
1677
1709
|
const hasTypedEqualityComparison = conditions?.some(
|
|
1678
1710
|
(condition) => condition.operator === "eq" && (condition.value_cast !== void 0 || condition.column_cast !== void 0)
|
|
1679
1711
|
) ?? false;
|
|
1680
1712
|
if (hasTypedEqualityComparison && !options?.head && !options?.count && conditions) {
|
|
1681
1713
|
const query = buildTypedSelectQuery({
|
|
1682
|
-
tableName,
|
|
1714
|
+
tableName: resolvedTableName,
|
|
1683
1715
|
columns,
|
|
1684
1716
|
conditions,
|
|
1685
1717
|
limit: state.limit,
|
|
@@ -1694,7 +1726,7 @@ function createTableBuilder(tableName, client) {
|
|
|
1694
1726
|
}
|
|
1695
1727
|
}
|
|
1696
1728
|
const payload = {
|
|
1697
|
-
table_name:
|
|
1729
|
+
table_name: resolvedTableName,
|
|
1698
1730
|
columns,
|
|
1699
1731
|
conditions,
|
|
1700
1732
|
limit: state.limit,
|
|
@@ -1751,9 +1783,10 @@ function createTableBuilder(tableName, client) {
|
|
|
1751
1783
|
if (Array.isArray(values)) {
|
|
1752
1784
|
const executeInsertMany = async (columns, selectOptions) => {
|
|
1753
1785
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1786
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1754
1787
|
const payload = {
|
|
1755
|
-
table_name:
|
|
1756
|
-
insert_body: values
|
|
1788
|
+
table_name: resolvedTableName,
|
|
1789
|
+
insert_body: asAthenaJsonObjectArray(values)
|
|
1757
1790
|
};
|
|
1758
1791
|
if (columns) payload.columns = columns;
|
|
1759
1792
|
if (mergedOptions?.count) payload.count = mergedOptions.count;
|
|
@@ -1768,9 +1801,10 @@ function createTableBuilder(tableName, client) {
|
|
|
1768
1801
|
}
|
|
1769
1802
|
const executeInsertOne = async (columns, selectOptions) => {
|
|
1770
1803
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1804
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1771
1805
|
const payload = {
|
|
1772
|
-
table_name:
|
|
1773
|
-
insert_body: values
|
|
1806
|
+
table_name: resolvedTableName,
|
|
1807
|
+
insert_body: asAthenaJsonObject(values)
|
|
1774
1808
|
};
|
|
1775
1809
|
if (columns) payload.columns = columns;
|
|
1776
1810
|
if (mergedOptions?.count) payload.count = mergedOptions.count;
|
|
@@ -1787,10 +1821,11 @@ function createTableBuilder(tableName, client) {
|
|
|
1787
1821
|
if (Array.isArray(values)) {
|
|
1788
1822
|
const executeUpsertMany = async (columns, selectOptions) => {
|
|
1789
1823
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1824
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1790
1825
|
const payload = {
|
|
1791
|
-
table_name:
|
|
1792
|
-
insert_body: values,
|
|
1793
|
-
update_body: options?.updateBody ? options.updateBody : void 0
|
|
1826
|
+
table_name: resolvedTableName,
|
|
1827
|
+
insert_body: asAthenaJsonObjectArray(values),
|
|
1828
|
+
update_body: options?.updateBody ? asAthenaJsonObject(options.updateBody) : void 0
|
|
1794
1829
|
};
|
|
1795
1830
|
if (columns) payload.columns = columns;
|
|
1796
1831
|
if (options?.onConflict) payload.on_conflict = options.onConflict;
|
|
@@ -1806,10 +1841,11 @@ function createTableBuilder(tableName, client) {
|
|
|
1806
1841
|
}
|
|
1807
1842
|
const executeUpsertOne = async (columns, selectOptions) => {
|
|
1808
1843
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1844
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1809
1845
|
const payload = {
|
|
1810
|
-
table_name:
|
|
1811
|
-
insert_body: values,
|
|
1812
|
-
update_body: options?.updateBody ? options.updateBody : void 0
|
|
1846
|
+
table_name: resolvedTableName,
|
|
1847
|
+
insert_body: asAthenaJsonObject(values),
|
|
1848
|
+
update_body: options?.updateBody ? asAthenaJsonObject(options.updateBody) : void 0
|
|
1813
1849
|
};
|
|
1814
1850
|
if (columns) payload.columns = columns;
|
|
1815
1851
|
if (options?.onConflict) payload.on_conflict = options.onConflict;
|
|
@@ -1827,9 +1863,10 @@ function createTableBuilder(tableName, client) {
|
|
|
1827
1863
|
const executeUpdate = async (columns, selectOptions) => {
|
|
1828
1864
|
const filters = state.conditions.length ? [...state.conditions] : void 0;
|
|
1829
1865
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1866
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1830
1867
|
const payload = {
|
|
1831
|
-
table_name:
|
|
1832
|
-
set: values,
|
|
1868
|
+
table_name: resolvedTableName,
|
|
1869
|
+
set: asAthenaJsonObject(values),
|
|
1833
1870
|
conditions: filters,
|
|
1834
1871
|
strip_nulls: mergedOptions?.stripNulls ?? true
|
|
1835
1872
|
};
|
|
@@ -1855,8 +1892,9 @@ function createTableBuilder(tableName, client) {
|
|
|
1855
1892
|
}
|
|
1856
1893
|
const executeDelete = async (columns, selectOptions) => {
|
|
1857
1894
|
const mergedOptions = mergeOptions(options, selectOptions);
|
|
1895
|
+
const resolvedTableName = resolveTableNameForCall(tableName, mergedOptions?.schema);
|
|
1858
1896
|
const payload = {
|
|
1859
|
-
table_name:
|
|
1897
|
+
table_name: resolvedTableName,
|
|
1860
1898
|
resource_id: resourceId,
|
|
1861
1899
|
conditions: filters
|
|
1862
1900
|
};
|