arkormx 2.0.0-next.5 → 2.0.0-next.7
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/cli.mjs +98 -10
- package/dist/index.cjs +165 -22
- package/dist/index.d.cts +44 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.mjs +164 -24
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
4
|
import { dirname, extname, join, resolve } from "node:path";
|
|
4
5
|
import { spawnSync } from "node:child_process";
|
|
5
6
|
import { str } from "@h3ravel/support";
|
|
6
7
|
import path, { dirname as dirname$1, extname as extname$1, join as join$1, relative } from "path";
|
|
7
8
|
import { copyFileSync, existsSync as existsSync$1, mkdirSync as mkdirSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "fs";
|
|
8
9
|
import { AsyncLocalStorage } from "async_hooks";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
10
|
import { createJiti } from "@rexxars/jiti";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
import { createRequire } from "module";
|
|
@@ -55,6 +55,23 @@ var ArkormException = class extends Error {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/helpers/PrimaryKeyGenerationPlanner.ts
|
|
60
|
+
var PrimaryKeyGenerationPlanner = class {
|
|
61
|
+
static plan(column) {
|
|
62
|
+
if (!column.primary || column.default !== void 0) return void 0;
|
|
63
|
+
if (column.type === "uuid" || column.type === "string") return {
|
|
64
|
+
strategy: "uuid",
|
|
65
|
+
prismaDefault: "@default(uuid())",
|
|
66
|
+
databaseDefault: column.type === "uuid" ? "gen_random_uuid()" : "gen_random_uuid()::text",
|
|
67
|
+
runtimeFactory: "uuid"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
static generate(generation) {
|
|
71
|
+
if (generation?.runtimeFactory === "uuid") return randomUUID();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
58
75
|
//#endregion
|
|
59
76
|
//#region src/database/ForeignKeyBuilder.ts
|
|
60
77
|
/**
|
|
@@ -248,6 +265,7 @@ var TableBuilder = class {
|
|
|
248
265
|
column.primary = true;
|
|
249
266
|
if (typeof config.autoIncrement === "boolean") column.autoIncrement = config.autoIncrement;
|
|
250
267
|
if (Object.prototype.hasOwnProperty.call(config, "default")) column.default = config.default;
|
|
268
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
251
269
|
return this;
|
|
252
270
|
}
|
|
253
271
|
/**
|
|
@@ -611,8 +629,11 @@ var TableBuilder = class {
|
|
|
611
629
|
autoIncrement: options.autoIncrement,
|
|
612
630
|
after: options.after,
|
|
613
631
|
default: options.default,
|
|
614
|
-
updatedAt: options.updatedAt
|
|
632
|
+
updatedAt: options.updatedAt,
|
|
633
|
+
primaryKeyGeneration: options.primaryKeyGeneration
|
|
615
634
|
});
|
|
635
|
+
const column = this.columns[this.columns.length - 1];
|
|
636
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
616
637
|
this.latestColumnName = name;
|
|
617
638
|
return this;
|
|
618
639
|
}
|
|
@@ -867,7 +888,7 @@ const buildFieldLine = (column) => {
|
|
|
867
888
|
const primary = column.primary ? " @id" : "";
|
|
868
889
|
const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
|
|
869
890
|
const updatedAt = column.updatedAt ? " @updatedAt" : "";
|
|
870
|
-
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) :
|
|
891
|
+
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) : column.primaryKeyGeneration?.prismaDefault ?? formatDefaultValue(column.default);
|
|
871
892
|
const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
|
|
872
893
|
return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
|
|
873
894
|
};
|
|
@@ -1592,7 +1613,7 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
1592
1613
|
enums: {}
|
|
1593
1614
|
};
|
|
1594
1615
|
const candidate = table;
|
|
1595
|
-
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums"))) return {
|
|
1616
|
+
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums") || Object.prototype.hasOwnProperty.call(candidate, "primaryKeyGeneration") || Object.prototype.hasOwnProperty.call(candidate, "timestampColumns"))) return {
|
|
1596
1617
|
columns: normalizeLegacyTableColumns(candidate),
|
|
1597
1618
|
enums: {}
|
|
1598
1619
|
};
|
|
@@ -1603,16 +1624,45 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
1603
1624
|
const normalizedValues = normalizePersistedEnumValues(values);
|
|
1604
1625
|
if (normalizedValues.length > 0) all[columnName] = normalizedValues;
|
|
1605
1626
|
return all;
|
|
1606
|
-
}, {})
|
|
1627
|
+
}, {}),
|
|
1628
|
+
primaryKeyGeneration: normalizePersistedPrimaryKeyGeneration(candidate.primaryKeyGeneration),
|
|
1629
|
+
timestampColumns: normalizePersistedTimestampColumns(candidate.timestampColumns)
|
|
1630
|
+
};
|
|
1631
|
+
};
|
|
1632
|
+
const normalizePersistedPrimaryKeyGeneration = (value) => {
|
|
1633
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1634
|
+
const candidate = value;
|
|
1635
|
+
if (candidate.strategy !== "uuid" || typeof candidate.column !== "string" || candidate.column.trim().length === 0) return void 0;
|
|
1636
|
+
return {
|
|
1637
|
+
column: candidate.column,
|
|
1638
|
+
strategy: "uuid",
|
|
1639
|
+
prismaDefault: typeof candidate.prismaDefault === "string" && candidate.prismaDefault.trim().length > 0 ? candidate.prismaDefault : void 0,
|
|
1640
|
+
databaseDefault: typeof candidate.databaseDefault === "string" && candidate.databaseDefault.trim().length > 0 ? candidate.databaseDefault : void 0,
|
|
1641
|
+
runtimeFactory: candidate.runtimeFactory === "uuid" ? "uuid" : void 0
|
|
1607
1642
|
};
|
|
1608
1643
|
};
|
|
1644
|
+
const normalizePersistedTimestampColumns = (value) => {
|
|
1645
|
+
if (!Array.isArray(value)) return void 0;
|
|
1646
|
+
const columns = value.reduce((all, entry) => {
|
|
1647
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return all;
|
|
1648
|
+
const candidate = entry;
|
|
1649
|
+
if (typeof candidate.column !== "string" || candidate.column.trim().length === 0) return all;
|
|
1650
|
+
const normalized = { column: candidate.column };
|
|
1651
|
+
if (candidate.default === "now()") normalized.default = "now()";
|
|
1652
|
+
if (candidate.updatedAt === true) normalized.updatedAt = true;
|
|
1653
|
+
if (!normalized.default && !normalized.updatedAt) return all;
|
|
1654
|
+
all.push(normalized);
|
|
1655
|
+
return all;
|
|
1656
|
+
}, []);
|
|
1657
|
+
return columns.length > 0 ? columns : void 0;
|
|
1658
|
+
};
|
|
1609
1659
|
const normalizePersistedColumnMappingsState = (state) => {
|
|
1610
1660
|
return {
|
|
1611
1661
|
version: 1,
|
|
1612
1662
|
tables: Object.entries(state?.tables ?? {}).reduce((all, [tableName, tableMetadata]) => {
|
|
1613
1663
|
if (tableName.trim().length === 0) return all;
|
|
1614
1664
|
const normalized = normalizePersistedTableMetadata(tableMetadata);
|
|
1615
|
-
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0) all[tableName] = normalized;
|
|
1665
|
+
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0 || normalized.primaryKeyGeneration || normalized.timestampColumns?.length) all[tableName] = normalized;
|
|
1616
1666
|
return all;
|
|
1617
1667
|
}, {})
|
|
1618
1668
|
};
|
|
@@ -1683,7 +1733,9 @@ const getPersistedTableMetadata = (table, options = {}) => {
|
|
|
1683
1733
|
enums: Object.entries(metadata.enums).reduce((all, [columnName, values]) => {
|
|
1684
1734
|
all[columnName] = [...values];
|
|
1685
1735
|
return all;
|
|
1686
|
-
}, {})
|
|
1736
|
+
}, {}),
|
|
1737
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
1738
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
1687
1739
|
};
|
|
1688
1740
|
};
|
|
1689
1741
|
const applyMappedColumn = (tableColumns, column, features, table) => {
|
|
@@ -1709,6 +1761,36 @@ const removePersistedColumnMetadata = (tableMetadata, columnName) => {
|
|
|
1709
1761
|
Object.entries(tableMetadata.columns).forEach(([attribute, mappedColumn]) => {
|
|
1710
1762
|
if (mappedColumn === columnName) delete tableMetadata.columns[attribute];
|
|
1711
1763
|
});
|
|
1764
|
+
if (tableMetadata.primaryKeyGeneration?.column === columnName) delete tableMetadata.primaryKeyGeneration;
|
|
1765
|
+
if (tableMetadata.timestampColumns) {
|
|
1766
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((column) => column.column !== columnName);
|
|
1767
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
1768
|
+
}
|
|
1769
|
+
};
|
|
1770
|
+
const applyPrimaryKeyGeneration = (tableMetadata, column) => {
|
|
1771
|
+
if (!column.primary || !column.primaryKeyGeneration) {
|
|
1772
|
+
if (tableMetadata.primaryKeyGeneration?.column === column.name) delete tableMetadata.primaryKeyGeneration;
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
tableMetadata.primaryKeyGeneration = {
|
|
1776
|
+
column: column.name,
|
|
1777
|
+
...column.primaryKeyGeneration
|
|
1778
|
+
};
|
|
1779
|
+
};
|
|
1780
|
+
const applyTimestampColumn = (tableMetadata, column) => {
|
|
1781
|
+
if (column.type !== "timestamp" || column.default !== "now()" && column.updatedAt !== true) {
|
|
1782
|
+
if (tableMetadata.timestampColumns) {
|
|
1783
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((entry) => entry.column !== column.name);
|
|
1784
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
1785
|
+
}
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
const nextColumn = {
|
|
1789
|
+
column: column.name,
|
|
1790
|
+
...column.default === "now()" ? { default: "now()" } : {},
|
|
1791
|
+
...column.updatedAt ? { updatedAt: true } : {}
|
|
1792
|
+
};
|
|
1793
|
+
tableMetadata.timestampColumns = [...(tableMetadata.timestampColumns ?? []).filter((entry) => entry.column !== column.name), nextColumn];
|
|
1712
1794
|
};
|
|
1713
1795
|
const applyOperationsToPersistedColumnMappingsState = (state, operations, features = resolvePersistedMetadataFeatures()) => {
|
|
1714
1796
|
const nextTables = Object.entries(state.tables).reduce((all, [table, metadata]) => {
|
|
@@ -1717,7 +1799,9 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
1717
1799
|
enums: Object.entries(metadata.enums).reduce((nextEnums, [columnName, values]) => {
|
|
1718
1800
|
nextEnums[columnName] = [...values];
|
|
1719
1801
|
return nextEnums;
|
|
1720
|
-
}, {})
|
|
1802
|
+
}, {}),
|
|
1803
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
1804
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
1721
1805
|
};
|
|
1722
1806
|
return all;
|
|
1723
1807
|
}, {});
|
|
@@ -1730,8 +1814,10 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
1730
1814
|
operation.columns.forEach((column) => {
|
|
1731
1815
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
1732
1816
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
1817
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
1818
|
+
applyTimestampColumn(tableMetadata, column);
|
|
1733
1819
|
});
|
|
1734
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
1820
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
1735
1821
|
else delete nextTables[operation.table];
|
|
1736
1822
|
return;
|
|
1737
1823
|
}
|
|
@@ -1743,11 +1829,13 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
1743
1829
|
operation.addColumns.forEach((column) => {
|
|
1744
1830
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
1745
1831
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
1832
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
1833
|
+
applyTimestampColumn(tableMetadata, column);
|
|
1746
1834
|
});
|
|
1747
1835
|
operation.dropColumns.forEach((columnName) => {
|
|
1748
1836
|
removePersistedColumnMetadata(tableMetadata, columnName);
|
|
1749
1837
|
});
|
|
1750
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
1838
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
1751
1839
|
else delete nextTables[operation.table];
|
|
1752
1840
|
return;
|
|
1753
1841
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -164,6 +164,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
164
164
|
return "timestamptz";
|
|
165
165
|
}
|
|
166
166
|
resolveSchemaColumnDefault(column) {
|
|
167
|
+
if (column.primaryKeyGeneration?.databaseDefault) return column.primaryKeyGeneration.databaseDefault;
|
|
167
168
|
const value = column.default ?? (column.updatedAt ? "now()" : void 0);
|
|
168
169
|
if (value === void 0) return null;
|
|
169
170
|
if (value === "now()") return "now()";
|
|
@@ -1147,6 +1148,23 @@ const getLatestAppliedMigrations = (state, steps) => {
|
|
|
1147
1148
|
}).slice(0, Math.max(0, steps)).map((entry) => entry.migration);
|
|
1148
1149
|
};
|
|
1149
1150
|
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/helpers/PrimaryKeyGenerationPlanner.ts
|
|
1153
|
+
var PrimaryKeyGenerationPlanner = class {
|
|
1154
|
+
static plan(column) {
|
|
1155
|
+
if (!column.primary || column.default !== void 0) return void 0;
|
|
1156
|
+
if (column.type === "uuid" || column.type === "string") return {
|
|
1157
|
+
strategy: "uuid",
|
|
1158
|
+
prismaDefault: "@default(uuid())",
|
|
1159
|
+
databaseDefault: column.type === "uuid" ? "gen_random_uuid()" : "gen_random_uuid()::text",
|
|
1160
|
+
runtimeFactory: "uuid"
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
static generate(generation) {
|
|
1164
|
+
if (generation?.runtimeFactory === "uuid") return (0, node_crypto.randomUUID)();
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1150
1168
|
//#endregion
|
|
1151
1169
|
//#region src/database/ForeignKeyBuilder.ts
|
|
1152
1170
|
/**
|
|
@@ -1340,6 +1358,7 @@ var TableBuilder = class {
|
|
|
1340
1358
|
column.primary = true;
|
|
1341
1359
|
if (typeof config.autoIncrement === "boolean") column.autoIncrement = config.autoIncrement;
|
|
1342
1360
|
if (Object.prototype.hasOwnProperty.call(config, "default")) column.default = config.default;
|
|
1361
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
1343
1362
|
return this;
|
|
1344
1363
|
}
|
|
1345
1364
|
/**
|
|
@@ -1703,8 +1722,11 @@ var TableBuilder = class {
|
|
|
1703
1722
|
autoIncrement: options.autoIncrement,
|
|
1704
1723
|
after: options.after,
|
|
1705
1724
|
default: options.default,
|
|
1706
|
-
updatedAt: options.updatedAt
|
|
1725
|
+
updatedAt: options.updatedAt,
|
|
1726
|
+
primaryKeyGeneration: options.primaryKeyGeneration
|
|
1707
1727
|
});
|
|
1728
|
+
const column = this.columns[this.columns.length - 1];
|
|
1729
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
1708
1730
|
this.latestColumnName = name;
|
|
1709
1731
|
return this;
|
|
1710
1732
|
}
|
|
@@ -1959,7 +1981,7 @@ const buildFieldLine = (column) => {
|
|
|
1959
1981
|
const primary = column.primary ? " @id" : "";
|
|
1960
1982
|
const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
|
|
1961
1983
|
const updatedAt = column.updatedAt ? " @updatedAt" : "";
|
|
1962
|
-
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) :
|
|
1984
|
+
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) : column.primaryKeyGeneration?.prismaDefault ?? formatDefaultValue(column.default);
|
|
1963
1985
|
const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
|
|
1964
1986
|
return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
|
|
1965
1987
|
};
|
|
@@ -2596,7 +2618,7 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
2596
2618
|
enums: {}
|
|
2597
2619
|
};
|
|
2598
2620
|
const candidate = table;
|
|
2599
|
-
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums"))) return {
|
|
2621
|
+
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums") || Object.prototype.hasOwnProperty.call(candidate, "primaryKeyGeneration") || Object.prototype.hasOwnProperty.call(candidate, "timestampColumns"))) return {
|
|
2600
2622
|
columns: normalizeLegacyTableColumns(candidate),
|
|
2601
2623
|
enums: {}
|
|
2602
2624
|
};
|
|
@@ -2607,16 +2629,45 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
2607
2629
|
const normalizedValues = normalizePersistedEnumValues(values);
|
|
2608
2630
|
if (normalizedValues.length > 0) all[columnName] = normalizedValues;
|
|
2609
2631
|
return all;
|
|
2610
|
-
}, {})
|
|
2632
|
+
}, {}),
|
|
2633
|
+
primaryKeyGeneration: normalizePersistedPrimaryKeyGeneration(candidate.primaryKeyGeneration),
|
|
2634
|
+
timestampColumns: normalizePersistedTimestampColumns(candidate.timestampColumns)
|
|
2635
|
+
};
|
|
2636
|
+
};
|
|
2637
|
+
const normalizePersistedPrimaryKeyGeneration = (value) => {
|
|
2638
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
2639
|
+
const candidate = value;
|
|
2640
|
+
if (candidate.strategy !== "uuid" || typeof candidate.column !== "string" || candidate.column.trim().length === 0) return void 0;
|
|
2641
|
+
return {
|
|
2642
|
+
column: candidate.column,
|
|
2643
|
+
strategy: "uuid",
|
|
2644
|
+
prismaDefault: typeof candidate.prismaDefault === "string" && candidate.prismaDefault.trim().length > 0 ? candidate.prismaDefault : void 0,
|
|
2645
|
+
databaseDefault: typeof candidate.databaseDefault === "string" && candidate.databaseDefault.trim().length > 0 ? candidate.databaseDefault : void 0,
|
|
2646
|
+
runtimeFactory: candidate.runtimeFactory === "uuid" ? "uuid" : void 0
|
|
2611
2647
|
};
|
|
2612
2648
|
};
|
|
2649
|
+
const normalizePersistedTimestampColumns = (value) => {
|
|
2650
|
+
if (!Array.isArray(value)) return void 0;
|
|
2651
|
+
const columns = value.reduce((all, entry) => {
|
|
2652
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return all;
|
|
2653
|
+
const candidate = entry;
|
|
2654
|
+
if (typeof candidate.column !== "string" || candidate.column.trim().length === 0) return all;
|
|
2655
|
+
const normalized = { column: candidate.column };
|
|
2656
|
+
if (candidate.default === "now()") normalized.default = "now()";
|
|
2657
|
+
if (candidate.updatedAt === true) normalized.updatedAt = true;
|
|
2658
|
+
if (!normalized.default && !normalized.updatedAt) return all;
|
|
2659
|
+
all.push(normalized);
|
|
2660
|
+
return all;
|
|
2661
|
+
}, []);
|
|
2662
|
+
return columns.length > 0 ? columns : void 0;
|
|
2663
|
+
};
|
|
2613
2664
|
const normalizePersistedColumnMappingsState = (state) => {
|
|
2614
2665
|
return {
|
|
2615
2666
|
version: 1,
|
|
2616
2667
|
tables: Object.entries(state?.tables ?? {}).reduce((all, [tableName, tableMetadata]) => {
|
|
2617
2668
|
if (tableName.trim().length === 0) return all;
|
|
2618
2669
|
const normalized = normalizePersistedTableMetadata(tableMetadata);
|
|
2619
|
-
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0) all[tableName] = normalized;
|
|
2670
|
+
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0 || normalized.primaryKeyGeneration || normalized.timestampColumns?.length) all[tableName] = normalized;
|
|
2620
2671
|
return all;
|
|
2621
2672
|
}, {})
|
|
2622
2673
|
};
|
|
@@ -2687,7 +2738,9 @@ const getPersistedTableMetadata = (table, options = {}) => {
|
|
|
2687
2738
|
enums: Object.entries(metadata.enums).reduce((all, [columnName, values]) => {
|
|
2688
2739
|
all[columnName] = [...values];
|
|
2689
2740
|
return all;
|
|
2690
|
-
}, {})
|
|
2741
|
+
}, {}),
|
|
2742
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
2743
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
2691
2744
|
};
|
|
2692
2745
|
};
|
|
2693
2746
|
const getPersistedColumnMap = (table, options = {}) => {
|
|
@@ -2696,6 +2749,12 @@ const getPersistedColumnMap = (table, options = {}) => {
|
|
|
2696
2749
|
const getPersistedEnumMap = (table, options = {}) => {
|
|
2697
2750
|
return getPersistedTableMetadata(table, options).enums;
|
|
2698
2751
|
};
|
|
2752
|
+
const getPersistedPrimaryKeyGeneration = (table, options = {}) => {
|
|
2753
|
+
return getPersistedTableMetadata(table, options).primaryKeyGeneration;
|
|
2754
|
+
};
|
|
2755
|
+
const getPersistedTimestampColumns = (table, options = {}) => {
|
|
2756
|
+
return getPersistedTableMetadata(table, options).timestampColumns ?? [];
|
|
2757
|
+
};
|
|
2699
2758
|
const applyMappedColumn = (tableColumns, column, features, table) => {
|
|
2700
2759
|
if (typeof column.map === "string" && column.map.trim().length > 0 && column.map !== column.name) {
|
|
2701
2760
|
if (!features.persistedColumnMappings) throw buildPersistedFeatureDisabledError("persistedColumnMappings", table);
|
|
@@ -2719,6 +2778,36 @@ const removePersistedColumnMetadata = (tableMetadata, columnName) => {
|
|
|
2719
2778
|
Object.entries(tableMetadata.columns).forEach(([attribute, mappedColumn]) => {
|
|
2720
2779
|
if (mappedColumn === columnName) delete tableMetadata.columns[attribute];
|
|
2721
2780
|
});
|
|
2781
|
+
if (tableMetadata.primaryKeyGeneration?.column === columnName) delete tableMetadata.primaryKeyGeneration;
|
|
2782
|
+
if (tableMetadata.timestampColumns) {
|
|
2783
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((column) => column.column !== columnName);
|
|
2784
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
2785
|
+
}
|
|
2786
|
+
};
|
|
2787
|
+
const applyPrimaryKeyGeneration = (tableMetadata, column) => {
|
|
2788
|
+
if (!column.primary || !column.primaryKeyGeneration) {
|
|
2789
|
+
if (tableMetadata.primaryKeyGeneration?.column === column.name) delete tableMetadata.primaryKeyGeneration;
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
tableMetadata.primaryKeyGeneration = {
|
|
2793
|
+
column: column.name,
|
|
2794
|
+
...column.primaryKeyGeneration
|
|
2795
|
+
};
|
|
2796
|
+
};
|
|
2797
|
+
const applyTimestampColumn = (tableMetadata, column) => {
|
|
2798
|
+
if (column.type !== "timestamp" || column.default !== "now()" && column.updatedAt !== true) {
|
|
2799
|
+
if (tableMetadata.timestampColumns) {
|
|
2800
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((entry) => entry.column !== column.name);
|
|
2801
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
2802
|
+
}
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
const nextColumn = {
|
|
2806
|
+
column: column.name,
|
|
2807
|
+
...column.default === "now()" ? { default: "now()" } : {},
|
|
2808
|
+
...column.updatedAt ? { updatedAt: true } : {}
|
|
2809
|
+
};
|
|
2810
|
+
tableMetadata.timestampColumns = [...(tableMetadata.timestampColumns ?? []).filter((entry) => entry.column !== column.name), nextColumn];
|
|
2722
2811
|
};
|
|
2723
2812
|
const applyOperationsToPersistedColumnMappingsState = (state, operations, features = resolvePersistedMetadataFeatures()) => {
|
|
2724
2813
|
const nextTables = Object.entries(state.tables).reduce((all, [table, metadata]) => {
|
|
@@ -2727,7 +2816,9 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2727
2816
|
enums: Object.entries(metadata.enums).reduce((nextEnums, [columnName, values]) => {
|
|
2728
2817
|
nextEnums[columnName] = [...values];
|
|
2729
2818
|
return nextEnums;
|
|
2730
|
-
}, {})
|
|
2819
|
+
}, {}),
|
|
2820
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
2821
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
2731
2822
|
};
|
|
2732
2823
|
return all;
|
|
2733
2824
|
}, {});
|
|
@@ -2740,8 +2831,10 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2740
2831
|
operation.columns.forEach((column) => {
|
|
2741
2832
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
2742
2833
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
2834
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
2835
|
+
applyTimestampColumn(tableMetadata, column);
|
|
2743
2836
|
});
|
|
2744
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
2837
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
2745
2838
|
else delete nextTables[operation.table];
|
|
2746
2839
|
return;
|
|
2747
2840
|
}
|
|
@@ -2753,11 +2846,13 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2753
2846
|
operation.addColumns.forEach((column) => {
|
|
2754
2847
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
2755
2848
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
2849
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
2850
|
+
applyTimestampColumn(tableMetadata, column);
|
|
2756
2851
|
});
|
|
2757
2852
|
operation.dropColumns.forEach((columnName) => {
|
|
2758
2853
|
removePersistedColumnMetadata(tableMetadata, columnName);
|
|
2759
2854
|
});
|
|
2760
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
2855
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
2761
2856
|
else delete nextTables[operation.table];
|
|
2762
2857
|
return;
|
|
2763
2858
|
}
|
|
@@ -7941,8 +8036,29 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7941
8036
|
return !await this.exists();
|
|
7942
8037
|
}
|
|
7943
8038
|
normalizeInsertPayloads(values) {
|
|
7944
|
-
|
|
7945
|
-
|
|
8039
|
+
const payloads = Array.isArray(values) ? values : [values];
|
|
8040
|
+
const metadata = this.model.getModelMetadata();
|
|
8041
|
+
return payloads.map((payload) => {
|
|
8042
|
+
const nextPayload = { ...payload };
|
|
8043
|
+
const now = /* @__PURE__ */ new Date();
|
|
8044
|
+
const primaryKeyValue = nextPayload[metadata.primaryKey];
|
|
8045
|
+
if (primaryKeyValue === void 0 || primaryKeyValue === null) {
|
|
8046
|
+
const generated = PrimaryKeyGenerationPlanner.generate(metadata.primaryKeyGeneration);
|
|
8047
|
+
if (generated !== void 0) nextPayload[metadata.primaryKey] = generated;
|
|
8048
|
+
}
|
|
8049
|
+
for (const column of metadata.timestampColumns ?? []) {
|
|
8050
|
+
if (nextPayload[column.column] !== void 0 && nextPayload[column.column] !== null) continue;
|
|
8051
|
+
if (column.default === "now()" || column.updatedAt) nextPayload[column.column] = now;
|
|
8052
|
+
}
|
|
8053
|
+
return nextPayload;
|
|
8054
|
+
});
|
|
8055
|
+
}
|
|
8056
|
+
normalizeUpdatePayload(values) {
|
|
8057
|
+
const metadata = this.model.getModelMetadata();
|
|
8058
|
+
const nextPayload = { ...values };
|
|
8059
|
+
const now = /* @__PURE__ */ new Date();
|
|
8060
|
+
for (const column of metadata.timestampColumns ?? []) if (column.updatedAt) nextPayload[column.column] = now;
|
|
8061
|
+
return nextPayload;
|
|
7946
8062
|
}
|
|
7947
8063
|
resolveAffectedCount(result, fallback) {
|
|
7948
8064
|
if (typeof result === "number") return result;
|
|
@@ -8185,6 +8301,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8185
8301
|
modelName: this.model.name,
|
|
8186
8302
|
table: metadata.table,
|
|
8187
8303
|
primaryKey: metadata.primaryKey,
|
|
8304
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration,
|
|
8305
|
+
timestampColumns: metadata.timestampColumns,
|
|
8188
8306
|
columns: metadata.columns,
|
|
8189
8307
|
softDelete: metadata.softDelete
|
|
8190
8308
|
};
|
|
@@ -8549,13 +8667,15 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8549
8667
|
}) != null;
|
|
8550
8668
|
}
|
|
8551
8669
|
async executeInsertRow(values) {
|
|
8552
|
-
|
|
8670
|
+
const [payload] = this.normalizeInsertPayloads(values);
|
|
8671
|
+
return await this.requireAdapter().insert(this.tryBuildInsertSpec(payload));
|
|
8553
8672
|
}
|
|
8554
8673
|
async executeInsertManyRows(values, ignoreDuplicates = false) {
|
|
8555
8674
|
const adapter = this.requireAdapter();
|
|
8556
|
-
|
|
8675
|
+
const payloads = this.normalizeInsertPayloads(values);
|
|
8676
|
+
if (typeof adapter.insertMany === "function") return await adapter.insertMany(ignoreDuplicates ? this.tryBuildInsertOrIgnoreManySpec(payloads) : this.tryBuildInsertManySpec(payloads));
|
|
8557
8677
|
let inserted = 0;
|
|
8558
|
-
for (const value of
|
|
8678
|
+
for (const value of payloads) try {
|
|
8559
8679
|
await adapter.insert(this.tryBuildInsertSpec(value));
|
|
8560
8680
|
inserted += 1;
|
|
8561
8681
|
} catch (error) {
|
|
@@ -8565,15 +8685,18 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8565
8685
|
}
|
|
8566
8686
|
async executeUpsertRows(values, uniqueBy, updateColumns) {
|
|
8567
8687
|
const adapter = this.requireAdapter();
|
|
8688
|
+
const payloads = this.normalizeInsertPayloads(values);
|
|
8689
|
+
const timestampUpdateColumns = (this.model.getModelMetadata().timestampColumns ?? []).filter((column) => column.updatedAt).map((column) => column.column);
|
|
8690
|
+
const normalizedUpdateColumns = updateColumns ? Array.from(new Set([...updateColumns, ...timestampUpdateColumns])) : updateColumns;
|
|
8568
8691
|
if (typeof adapter.upsert !== "function") throw new UnsupportedAdapterFeatureException("Upsert is not supported by the current adapter.", {
|
|
8569
8692
|
operation: "query.upsert",
|
|
8570
8693
|
model: this.model.name
|
|
8571
8694
|
});
|
|
8572
|
-
return await adapter.upsert(this.tryBuildUpsertSpec(
|
|
8695
|
+
return await adapter.upsert(this.tryBuildUpsertSpec(payloads, uniqueBy, normalizedUpdateColumns));
|
|
8573
8696
|
}
|
|
8574
8697
|
async executeUpdateRow(where, values) {
|
|
8575
8698
|
const adapter = this.requireAdapter();
|
|
8576
|
-
const spec = this.tryBuildUpdateSpec(where, values);
|
|
8699
|
+
const spec = this.tryBuildUpdateSpec(where, this.normalizeUpdatePayload(values));
|
|
8577
8700
|
if (!spec) throw new UnsupportedAdapterFeatureException("Update could not be compiled into an Arkorm update specification.", {
|
|
8578
8701
|
operation: "query.update",
|
|
8579
8702
|
model: this.model.name
|
|
@@ -8584,7 +8707,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8584
8707
|
}
|
|
8585
8708
|
async executeUpdateManyRows(where, values) {
|
|
8586
8709
|
const adapter = this.requireAdapter();
|
|
8587
|
-
const
|
|
8710
|
+
const normalizedValues = this.normalizeUpdatePayload(values);
|
|
8711
|
+
const spec = this.tryBuildUpdateManySpec(where, normalizedValues);
|
|
8588
8712
|
if (!spec) throw new UnsupportedAdapterFeatureException("Update-many could not be compiled into an Arkorm update specification.", {
|
|
8589
8713
|
operation: "query.updateMany",
|
|
8590
8714
|
model: this.model.name
|
|
@@ -8601,7 +8725,7 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8601
8725
|
if (await adapter.update({
|
|
8602
8726
|
target: spec.target,
|
|
8603
8727
|
where: rowWhere,
|
|
8604
|
-
values:
|
|
8728
|
+
values: normalizedValues
|
|
8605
8729
|
})) updated += 1;
|
|
8606
8730
|
}
|
|
8607
8731
|
return updated;
|
|
@@ -8997,10 +9121,10 @@ var Model = class Model {
|
|
|
8997
9121
|
const adapter = this.getAdapter();
|
|
8998
9122
|
const shouldStrictlyValidatePersistedMappings = Boolean(adapter) && !(adapter instanceof PrismaDatabaseAdapter);
|
|
8999
9123
|
return {
|
|
9000
|
-
...
|
|
9124
|
+
...getPersistedTableMetadata(this.getTable(), {
|
|
9001
9125
|
features: resolvePersistedMetadataFeatures(getUserConfig("features")),
|
|
9002
9126
|
strict: shouldStrictlyValidatePersistedMappings
|
|
9003
|
-
}),
|
|
9127
|
+
}).columns,
|
|
9004
9128
|
...this.columns
|
|
9005
9129
|
};
|
|
9006
9130
|
}
|
|
@@ -9008,11 +9132,27 @@ var Model = class Model {
|
|
|
9008
9132
|
return this.getColumnMap()[attribute] ?? attribute;
|
|
9009
9133
|
}
|
|
9010
9134
|
static getModelMetadata() {
|
|
9135
|
+
const adapter = this.getAdapter();
|
|
9136
|
+
const shouldStrictlyValidatePersistedMappings = Boolean(adapter) && !(adapter instanceof PrismaDatabaseAdapter);
|
|
9137
|
+
const persistedMetadata = getPersistedTableMetadata(this.getTable(), {
|
|
9138
|
+
features: resolvePersistedMetadataFeatures(getUserConfig("features")),
|
|
9139
|
+
strict: shouldStrictlyValidatePersistedMappings
|
|
9140
|
+
});
|
|
9011
9141
|
return {
|
|
9012
9142
|
table: this.getTable(),
|
|
9013
9143
|
primaryKey: this.getPrimaryKey(),
|
|
9014
|
-
columns:
|
|
9015
|
-
|
|
9144
|
+
columns: {
|
|
9145
|
+
...persistedMetadata.columns,
|
|
9146
|
+
...this.columns
|
|
9147
|
+
},
|
|
9148
|
+
softDelete: this.getSoftDeleteConfig(),
|
|
9149
|
+
primaryKeyGeneration: persistedMetadata.primaryKeyGeneration?.column === this.getPrimaryKey() ? {
|
|
9150
|
+
strategy: persistedMetadata.primaryKeyGeneration.strategy,
|
|
9151
|
+
prismaDefault: persistedMetadata.primaryKeyGeneration.prismaDefault,
|
|
9152
|
+
databaseDefault: persistedMetadata.primaryKeyGeneration.databaseDefault,
|
|
9153
|
+
runtimeFactory: persistedMetadata.primaryKeyGeneration.runtimeFactory
|
|
9154
|
+
} : void 0,
|
|
9155
|
+
timestampColumns: persistedMetadata.timestampColumns?.map((column) => ({ ...column }))
|
|
9016
9156
|
};
|
|
9017
9157
|
}
|
|
9018
9158
|
static getRelationMetadata(name) {
|
|
@@ -10043,6 +10183,7 @@ exports.PRISMA_ENUM_MEMBER_REGEX = PRISMA_ENUM_MEMBER_REGEX;
|
|
|
10043
10183
|
exports.PRISMA_ENUM_REGEX = PRISMA_ENUM_REGEX;
|
|
10044
10184
|
exports.PRISMA_MODEL_REGEX = PRISMA_MODEL_REGEX;
|
|
10045
10185
|
exports.Paginator = Paginator;
|
|
10186
|
+
exports.PrimaryKeyGenerationPlanner = PrimaryKeyGenerationPlanner;
|
|
10046
10187
|
exports.PrismaDatabaseAdapter = PrismaDatabaseAdapter;
|
|
10047
10188
|
exports.QueryBuilder = QueryBuilder;
|
|
10048
10189
|
exports.QueryConstraintException = QueryConstraintException;
|
|
@@ -10112,7 +10253,9 @@ exports.getMigrationPlan = getMigrationPlan;
|
|
|
10112
10253
|
exports.getPersistedColumnMap = getPersistedColumnMap;
|
|
10113
10254
|
exports.getPersistedEnumMap = getPersistedEnumMap;
|
|
10114
10255
|
exports.getPersistedEnumTsType = getPersistedEnumTsType;
|
|
10256
|
+
exports.getPersistedPrimaryKeyGeneration = getPersistedPrimaryKeyGeneration;
|
|
10115
10257
|
exports.getPersistedTableMetadata = getPersistedTableMetadata;
|
|
10258
|
+
exports.getPersistedTimestampColumns = getPersistedTimestampColumns;
|
|
10116
10259
|
exports.getRuntimeAdapter = getRuntimeAdapter;
|
|
10117
10260
|
exports.getRuntimePaginationCurrentPageResolver = getRuntimePaginationCurrentPageResolver;
|
|
10118
10261
|
exports.getRuntimePaginationURLDriverFactory = getRuntimePaginationURLDriverFactory;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,17 @@ import { Command } from "@h3ravel/musket";
|
|
|
5
5
|
|
|
6
6
|
//#region src/types/migrations.d.ts
|
|
7
7
|
type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
|
|
8
|
+
interface PrimaryKeyGeneration {
|
|
9
|
+
strategy: 'uuid';
|
|
10
|
+
prismaDefault?: string;
|
|
11
|
+
databaseDefault?: string;
|
|
12
|
+
runtimeFactory?: 'uuid';
|
|
13
|
+
}
|
|
14
|
+
interface TimestampColumnBehavior {
|
|
15
|
+
column: string;
|
|
16
|
+
default?: 'now()';
|
|
17
|
+
updatedAt?: boolean;
|
|
18
|
+
}
|
|
8
19
|
interface SchemaColumn {
|
|
9
20
|
name: string;
|
|
10
21
|
type: SchemaColumnType;
|
|
@@ -18,6 +29,7 @@ interface SchemaColumn {
|
|
|
18
29
|
after?: string;
|
|
19
30
|
default?: unknown;
|
|
20
31
|
updatedAt?: boolean;
|
|
32
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
21
33
|
}
|
|
22
34
|
interface SchemaIndex {
|
|
23
35
|
columns: string[];
|
|
@@ -325,6 +337,8 @@ interface ModelMetadata {
|
|
|
325
337
|
primaryKey: string;
|
|
326
338
|
columns: ColumnMap;
|
|
327
339
|
softDelete: SoftDeleteConfig;
|
|
340
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
341
|
+
timestampColumns?: TimestampColumnBehavior[];
|
|
328
342
|
}
|
|
329
343
|
type RelationMetadataType = 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany' | 'hasOneThrough' | 'hasManyThrough' | 'morphOne' | 'morphMany' | 'morphToMany';
|
|
330
344
|
interface BaseRelationMetadata {
|
|
@@ -2407,6 +2421,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2407
2421
|
*/
|
|
2408
2422
|
doesntExist(): Promise<boolean>;
|
|
2409
2423
|
private normalizeInsertPayloads;
|
|
2424
|
+
private normalizeUpdatePayload;
|
|
2410
2425
|
private resolveAffectedCount;
|
|
2411
2426
|
private resolveInsertUsingRows;
|
|
2412
2427
|
private resolveInsertUsingSource;
|
|
@@ -2628,6 +2643,8 @@ interface QueryTarget<TModel = unknown> {
|
|
|
2628
2643
|
modelName?: string;
|
|
2629
2644
|
table?: string;
|
|
2630
2645
|
primaryKey?: string;
|
|
2646
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
2647
|
+
timestampColumns?: TimestampColumnBehavior[];
|
|
2631
2648
|
columns?: Record<string, string>;
|
|
2632
2649
|
softDelete?: SoftDeleteConfig;
|
|
2633
2650
|
alias?: string;
|
|
@@ -4175,6 +4192,14 @@ interface PersistedMetadataFeatures {
|
|
|
4175
4192
|
interface PersistedTableMetadata {
|
|
4176
4193
|
columns: Record<string, string>;
|
|
4177
4194
|
enums: Record<string, string[]>;
|
|
4195
|
+
primaryKeyGeneration?: PersistedPrimaryKeyGeneration;
|
|
4196
|
+
timestampColumns?: PersistedTimestampColumn[];
|
|
4197
|
+
}
|
|
4198
|
+
interface PersistedPrimaryKeyGeneration extends PrimaryKeyGeneration {
|
|
4199
|
+
column: string;
|
|
4200
|
+
}
|
|
4201
|
+
interface PersistedTimestampColumn extends TimestampColumnBehavior {
|
|
4202
|
+
column: string;
|
|
4178
4203
|
}
|
|
4179
4204
|
interface PersistedColumnMappingsState {
|
|
4180
4205
|
version: 1;
|
|
@@ -4205,6 +4230,18 @@ declare const getPersistedEnumMap: (table: string, options?: {
|
|
|
4205
4230
|
features?: PersistedMetadataFeatures;
|
|
4206
4231
|
strict?: boolean;
|
|
4207
4232
|
}) => Record<string, string[]>;
|
|
4233
|
+
declare const getPersistedPrimaryKeyGeneration: (table: string, options?: {
|
|
4234
|
+
cwd?: string;
|
|
4235
|
+
configuredPath?: string;
|
|
4236
|
+
features?: PersistedMetadataFeatures;
|
|
4237
|
+
strict?: boolean;
|
|
4238
|
+
}) => PersistedPrimaryKeyGeneration | undefined;
|
|
4239
|
+
declare const getPersistedTimestampColumns: (table: string, options?: {
|
|
4240
|
+
cwd?: string;
|
|
4241
|
+
configuredPath?: string;
|
|
4242
|
+
features?: PersistedMetadataFeatures;
|
|
4243
|
+
strict?: boolean;
|
|
4244
|
+
}) => PersistedTimestampColumn[];
|
|
4208
4245
|
declare const applyOperationsToPersistedColumnMappingsState: (state: PersistedColumnMappingsState, operations: SchemaOperation[], features?: PersistedMetadataFeatures) => PersistedColumnMappingsState;
|
|
4209
4246
|
declare const rebuildPersistedColumnMappingsState: (state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<PersistedColumnMappingsState>;
|
|
4210
4247
|
declare const syncPersistedColumnMappingsFromState: (cwd: string, state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<void>;
|
|
@@ -4525,6 +4562,12 @@ declare const runMigrationWithPrisma: (migration: Migration | (new () => Migrati
|
|
|
4525
4562
|
operations: SchemaOperation[];
|
|
4526
4563
|
}>;
|
|
4527
4564
|
//#endregion
|
|
4565
|
+
//#region src/helpers/PrimaryKeyGenerationPlanner.d.ts
|
|
4566
|
+
declare class PrimaryKeyGenerationPlanner {
|
|
4567
|
+
static plan(column: Pick<SchemaColumn, 'type' | 'primary' | 'default'>): PrimaryKeyGeneration | undefined;
|
|
4568
|
+
static generate(generation: PrimaryKeyGeneration | undefined): unknown;
|
|
4569
|
+
}
|
|
4570
|
+
//#endregion
|
|
4528
4571
|
//#region src/helpers/runtime-config.d.ts
|
|
4529
4572
|
/**
|
|
4530
4573
|
* Define the ArkORM runtime configuration. This function can be used to provide.
|
|
@@ -4656,4 +4699,4 @@ declare class URLDriver {
|
|
|
4656
4699
|
url(page: number): string;
|
|
4657
4700
|
}
|
|
4658
4701
|
//#endregion
|
|
4659
|
-
export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PersistedColumnMappingsState, PersistedMetadataFeatures, PersistedTableMetadata, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedTableMetadata, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
|
4702
|
+
export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PersistedColumnMappingsState, PersistedMetadataFeatures, PersistedPrimaryKeyGeneration, PersistedTableMetadata, PersistedTimestampColumn, PrimaryKeyGeneration, PrimaryKeyGenerationPlanner, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, TimestampColumnBehavior, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,17 @@ import { PrismaClient } from "@prisma/client";
|
|
|
5
5
|
|
|
6
6
|
//#region src/types/migrations.d.ts
|
|
7
7
|
type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
|
|
8
|
+
interface PrimaryKeyGeneration {
|
|
9
|
+
strategy: 'uuid';
|
|
10
|
+
prismaDefault?: string;
|
|
11
|
+
databaseDefault?: string;
|
|
12
|
+
runtimeFactory?: 'uuid';
|
|
13
|
+
}
|
|
14
|
+
interface TimestampColumnBehavior {
|
|
15
|
+
column: string;
|
|
16
|
+
default?: 'now()';
|
|
17
|
+
updatedAt?: boolean;
|
|
18
|
+
}
|
|
8
19
|
interface SchemaColumn {
|
|
9
20
|
name: string;
|
|
10
21
|
type: SchemaColumnType;
|
|
@@ -18,6 +29,7 @@ interface SchemaColumn {
|
|
|
18
29
|
after?: string;
|
|
19
30
|
default?: unknown;
|
|
20
31
|
updatedAt?: boolean;
|
|
32
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
21
33
|
}
|
|
22
34
|
interface SchemaIndex {
|
|
23
35
|
columns: string[];
|
|
@@ -325,6 +337,8 @@ interface ModelMetadata {
|
|
|
325
337
|
primaryKey: string;
|
|
326
338
|
columns: ColumnMap;
|
|
327
339
|
softDelete: SoftDeleteConfig;
|
|
340
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
341
|
+
timestampColumns?: TimestampColumnBehavior[];
|
|
328
342
|
}
|
|
329
343
|
type RelationMetadataType = 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany' | 'hasOneThrough' | 'hasManyThrough' | 'morphOne' | 'morphMany' | 'morphToMany';
|
|
330
344
|
interface BaseRelationMetadata {
|
|
@@ -2407,6 +2421,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2407
2421
|
*/
|
|
2408
2422
|
doesntExist(): Promise<boolean>;
|
|
2409
2423
|
private normalizeInsertPayloads;
|
|
2424
|
+
private normalizeUpdatePayload;
|
|
2410
2425
|
private resolveAffectedCount;
|
|
2411
2426
|
private resolveInsertUsingRows;
|
|
2412
2427
|
private resolveInsertUsingSource;
|
|
@@ -2628,6 +2643,8 @@ interface QueryTarget<TModel = unknown> {
|
|
|
2628
2643
|
modelName?: string;
|
|
2629
2644
|
table?: string;
|
|
2630
2645
|
primaryKey?: string;
|
|
2646
|
+
primaryKeyGeneration?: PrimaryKeyGeneration;
|
|
2647
|
+
timestampColumns?: TimestampColumnBehavior[];
|
|
2631
2648
|
columns?: Record<string, string>;
|
|
2632
2649
|
softDelete?: SoftDeleteConfig;
|
|
2633
2650
|
alias?: string;
|
|
@@ -4175,6 +4192,14 @@ interface PersistedMetadataFeatures {
|
|
|
4175
4192
|
interface PersistedTableMetadata {
|
|
4176
4193
|
columns: Record<string, string>;
|
|
4177
4194
|
enums: Record<string, string[]>;
|
|
4195
|
+
primaryKeyGeneration?: PersistedPrimaryKeyGeneration;
|
|
4196
|
+
timestampColumns?: PersistedTimestampColumn[];
|
|
4197
|
+
}
|
|
4198
|
+
interface PersistedPrimaryKeyGeneration extends PrimaryKeyGeneration {
|
|
4199
|
+
column: string;
|
|
4200
|
+
}
|
|
4201
|
+
interface PersistedTimestampColumn extends TimestampColumnBehavior {
|
|
4202
|
+
column: string;
|
|
4178
4203
|
}
|
|
4179
4204
|
interface PersistedColumnMappingsState {
|
|
4180
4205
|
version: 1;
|
|
@@ -4205,6 +4230,18 @@ declare const getPersistedEnumMap: (table: string, options?: {
|
|
|
4205
4230
|
features?: PersistedMetadataFeatures;
|
|
4206
4231
|
strict?: boolean;
|
|
4207
4232
|
}) => Record<string, string[]>;
|
|
4233
|
+
declare const getPersistedPrimaryKeyGeneration: (table: string, options?: {
|
|
4234
|
+
cwd?: string;
|
|
4235
|
+
configuredPath?: string;
|
|
4236
|
+
features?: PersistedMetadataFeatures;
|
|
4237
|
+
strict?: boolean;
|
|
4238
|
+
}) => PersistedPrimaryKeyGeneration | undefined;
|
|
4239
|
+
declare const getPersistedTimestampColumns: (table: string, options?: {
|
|
4240
|
+
cwd?: string;
|
|
4241
|
+
configuredPath?: string;
|
|
4242
|
+
features?: PersistedMetadataFeatures;
|
|
4243
|
+
strict?: boolean;
|
|
4244
|
+
}) => PersistedTimestampColumn[];
|
|
4208
4245
|
declare const applyOperationsToPersistedColumnMappingsState: (state: PersistedColumnMappingsState, operations: SchemaOperation[], features?: PersistedMetadataFeatures) => PersistedColumnMappingsState;
|
|
4209
4246
|
declare const rebuildPersistedColumnMappingsState: (state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<PersistedColumnMappingsState>;
|
|
4210
4247
|
declare const syncPersistedColumnMappingsFromState: (cwd: string, state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<void>;
|
|
@@ -4525,6 +4562,12 @@ declare const runMigrationWithPrisma: (migration: Migration | (new () => Migrati
|
|
|
4525
4562
|
operations: SchemaOperation[];
|
|
4526
4563
|
}>;
|
|
4527
4564
|
//#endregion
|
|
4565
|
+
//#region src/helpers/PrimaryKeyGenerationPlanner.d.ts
|
|
4566
|
+
declare class PrimaryKeyGenerationPlanner {
|
|
4567
|
+
static plan(column: Pick<SchemaColumn, 'type' | 'primary' | 'default'>): PrimaryKeyGeneration | undefined;
|
|
4568
|
+
static generate(generation: PrimaryKeyGeneration | undefined): unknown;
|
|
4569
|
+
}
|
|
4570
|
+
//#endregion
|
|
4528
4571
|
//#region src/helpers/runtime-config.d.ts
|
|
4529
4572
|
/**
|
|
4530
4573
|
* Define the ArkORM runtime configuration. This function can be used to provide.
|
|
@@ -4656,4 +4699,4 @@ declare class URLDriver {
|
|
|
4656
4699
|
url(page: number): string;
|
|
4657
4700
|
}
|
|
4658
4701
|
//#endregion
|
|
4659
|
-
export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PersistedColumnMappingsState, PersistedMetadataFeatures, PersistedTableMetadata, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedTableMetadata, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
|
4702
|
+
export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PersistedColumnMappingsState, PersistedMetadataFeatures, PersistedPrimaryKeyGeneration, PersistedTableMetadata, PersistedTimestampColumn, PrimaryKeyGeneration, PrimaryKeyGenerationPlanner, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, TimestampColumnBehavior, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { str } from "@h3ravel/support";
|
|
|
3
3
|
import { AsyncLocalStorage } from "async_hooks";
|
|
4
4
|
import { dirname, extname, join, resolve } from "node:path";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
6
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
8
|
import { createJiti } from "@rexxars/jiti";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
@@ -135,6 +135,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
135
135
|
return "timestamptz";
|
|
136
136
|
}
|
|
137
137
|
resolveSchemaColumnDefault(column) {
|
|
138
|
+
if (column.primaryKeyGeneration?.databaseDefault) return column.primaryKeyGeneration.databaseDefault;
|
|
138
139
|
const value = column.default ?? (column.updatedAt ? "now()" : void 0);
|
|
139
140
|
if (value === void 0) return null;
|
|
140
141
|
if (value === "now()") return "now()";
|
|
@@ -1118,6 +1119,23 @@ const getLatestAppliedMigrations = (state, steps) => {
|
|
|
1118
1119
|
}).slice(0, Math.max(0, steps)).map((entry) => entry.migration);
|
|
1119
1120
|
};
|
|
1120
1121
|
|
|
1122
|
+
//#endregion
|
|
1123
|
+
//#region src/helpers/PrimaryKeyGenerationPlanner.ts
|
|
1124
|
+
var PrimaryKeyGenerationPlanner = class {
|
|
1125
|
+
static plan(column) {
|
|
1126
|
+
if (!column.primary || column.default !== void 0) return void 0;
|
|
1127
|
+
if (column.type === "uuid" || column.type === "string") return {
|
|
1128
|
+
strategy: "uuid",
|
|
1129
|
+
prismaDefault: "@default(uuid())",
|
|
1130
|
+
databaseDefault: column.type === "uuid" ? "gen_random_uuid()" : "gen_random_uuid()::text",
|
|
1131
|
+
runtimeFactory: "uuid"
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
static generate(generation) {
|
|
1135
|
+
if (generation?.runtimeFactory === "uuid") return randomUUID();
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1121
1139
|
//#endregion
|
|
1122
1140
|
//#region src/database/ForeignKeyBuilder.ts
|
|
1123
1141
|
/**
|
|
@@ -1311,6 +1329,7 @@ var TableBuilder = class {
|
|
|
1311
1329
|
column.primary = true;
|
|
1312
1330
|
if (typeof config.autoIncrement === "boolean") column.autoIncrement = config.autoIncrement;
|
|
1313
1331
|
if (Object.prototype.hasOwnProperty.call(config, "default")) column.default = config.default;
|
|
1332
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
1314
1333
|
return this;
|
|
1315
1334
|
}
|
|
1316
1335
|
/**
|
|
@@ -1674,8 +1693,11 @@ var TableBuilder = class {
|
|
|
1674
1693
|
autoIncrement: options.autoIncrement,
|
|
1675
1694
|
after: options.after,
|
|
1676
1695
|
default: options.default,
|
|
1677
|
-
updatedAt: options.updatedAt
|
|
1696
|
+
updatedAt: options.updatedAt,
|
|
1697
|
+
primaryKeyGeneration: options.primaryKeyGeneration
|
|
1678
1698
|
});
|
|
1699
|
+
const column = this.columns[this.columns.length - 1];
|
|
1700
|
+
column.primaryKeyGeneration = PrimaryKeyGenerationPlanner.plan(column);
|
|
1679
1701
|
this.latestColumnName = name;
|
|
1680
1702
|
return this;
|
|
1681
1703
|
}
|
|
@@ -1930,7 +1952,7 @@ const buildFieldLine = (column) => {
|
|
|
1930
1952
|
const primary = column.primary ? " @id" : "";
|
|
1931
1953
|
const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
|
|
1932
1954
|
const updatedAt = column.updatedAt ? " @updatedAt" : "";
|
|
1933
|
-
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) :
|
|
1955
|
+
const defaultValue = column.type === "enum" ? formatEnumDefaultValue(column.default) : column.primaryKeyGeneration?.prismaDefault ?? formatDefaultValue(column.default);
|
|
1934
1956
|
const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
|
|
1935
1957
|
return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
|
|
1936
1958
|
};
|
|
@@ -2567,7 +2589,7 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
2567
2589
|
enums: {}
|
|
2568
2590
|
};
|
|
2569
2591
|
const candidate = table;
|
|
2570
|
-
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums"))) return {
|
|
2592
|
+
if (!(Object.prototype.hasOwnProperty.call(candidate, "columns") || Object.prototype.hasOwnProperty.call(candidate, "enums") || Object.prototype.hasOwnProperty.call(candidate, "primaryKeyGeneration") || Object.prototype.hasOwnProperty.call(candidate, "timestampColumns"))) return {
|
|
2571
2593
|
columns: normalizeLegacyTableColumns(candidate),
|
|
2572
2594
|
enums: {}
|
|
2573
2595
|
};
|
|
@@ -2578,16 +2600,45 @@ const normalizePersistedTableMetadata = (table) => {
|
|
|
2578
2600
|
const normalizedValues = normalizePersistedEnumValues(values);
|
|
2579
2601
|
if (normalizedValues.length > 0) all[columnName] = normalizedValues;
|
|
2580
2602
|
return all;
|
|
2581
|
-
}, {})
|
|
2603
|
+
}, {}),
|
|
2604
|
+
primaryKeyGeneration: normalizePersistedPrimaryKeyGeneration(candidate.primaryKeyGeneration),
|
|
2605
|
+
timestampColumns: normalizePersistedTimestampColumns(candidate.timestampColumns)
|
|
2606
|
+
};
|
|
2607
|
+
};
|
|
2608
|
+
const normalizePersistedPrimaryKeyGeneration = (value) => {
|
|
2609
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
2610
|
+
const candidate = value;
|
|
2611
|
+
if (candidate.strategy !== "uuid" || typeof candidate.column !== "string" || candidate.column.trim().length === 0) return void 0;
|
|
2612
|
+
return {
|
|
2613
|
+
column: candidate.column,
|
|
2614
|
+
strategy: "uuid",
|
|
2615
|
+
prismaDefault: typeof candidate.prismaDefault === "string" && candidate.prismaDefault.trim().length > 0 ? candidate.prismaDefault : void 0,
|
|
2616
|
+
databaseDefault: typeof candidate.databaseDefault === "string" && candidate.databaseDefault.trim().length > 0 ? candidate.databaseDefault : void 0,
|
|
2617
|
+
runtimeFactory: candidate.runtimeFactory === "uuid" ? "uuid" : void 0
|
|
2582
2618
|
};
|
|
2583
2619
|
};
|
|
2620
|
+
const normalizePersistedTimestampColumns = (value) => {
|
|
2621
|
+
if (!Array.isArray(value)) return void 0;
|
|
2622
|
+
const columns = value.reduce((all, entry) => {
|
|
2623
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return all;
|
|
2624
|
+
const candidate = entry;
|
|
2625
|
+
if (typeof candidate.column !== "string" || candidate.column.trim().length === 0) return all;
|
|
2626
|
+
const normalized = { column: candidate.column };
|
|
2627
|
+
if (candidate.default === "now()") normalized.default = "now()";
|
|
2628
|
+
if (candidate.updatedAt === true) normalized.updatedAt = true;
|
|
2629
|
+
if (!normalized.default && !normalized.updatedAt) return all;
|
|
2630
|
+
all.push(normalized);
|
|
2631
|
+
return all;
|
|
2632
|
+
}, []);
|
|
2633
|
+
return columns.length > 0 ? columns : void 0;
|
|
2634
|
+
};
|
|
2584
2635
|
const normalizePersistedColumnMappingsState = (state) => {
|
|
2585
2636
|
return {
|
|
2586
2637
|
version: 1,
|
|
2587
2638
|
tables: Object.entries(state?.tables ?? {}).reduce((all, [tableName, tableMetadata]) => {
|
|
2588
2639
|
if (tableName.trim().length === 0) return all;
|
|
2589
2640
|
const normalized = normalizePersistedTableMetadata(tableMetadata);
|
|
2590
|
-
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0) all[tableName] = normalized;
|
|
2641
|
+
if (Object.keys(normalized.columns).length > 0 || Object.keys(normalized.enums).length > 0 || normalized.primaryKeyGeneration || normalized.timestampColumns?.length) all[tableName] = normalized;
|
|
2591
2642
|
return all;
|
|
2592
2643
|
}, {})
|
|
2593
2644
|
};
|
|
@@ -2658,7 +2709,9 @@ const getPersistedTableMetadata = (table, options = {}) => {
|
|
|
2658
2709
|
enums: Object.entries(metadata.enums).reduce((all, [columnName, values]) => {
|
|
2659
2710
|
all[columnName] = [...values];
|
|
2660
2711
|
return all;
|
|
2661
|
-
}, {})
|
|
2712
|
+
}, {}),
|
|
2713
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
2714
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
2662
2715
|
};
|
|
2663
2716
|
};
|
|
2664
2717
|
const getPersistedColumnMap = (table, options = {}) => {
|
|
@@ -2667,6 +2720,12 @@ const getPersistedColumnMap = (table, options = {}) => {
|
|
|
2667
2720
|
const getPersistedEnumMap = (table, options = {}) => {
|
|
2668
2721
|
return getPersistedTableMetadata(table, options).enums;
|
|
2669
2722
|
};
|
|
2723
|
+
const getPersistedPrimaryKeyGeneration = (table, options = {}) => {
|
|
2724
|
+
return getPersistedTableMetadata(table, options).primaryKeyGeneration;
|
|
2725
|
+
};
|
|
2726
|
+
const getPersistedTimestampColumns = (table, options = {}) => {
|
|
2727
|
+
return getPersistedTableMetadata(table, options).timestampColumns ?? [];
|
|
2728
|
+
};
|
|
2670
2729
|
const applyMappedColumn = (tableColumns, column, features, table) => {
|
|
2671
2730
|
if (typeof column.map === "string" && column.map.trim().length > 0 && column.map !== column.name) {
|
|
2672
2731
|
if (!features.persistedColumnMappings) throw buildPersistedFeatureDisabledError("persistedColumnMappings", table);
|
|
@@ -2690,6 +2749,36 @@ const removePersistedColumnMetadata = (tableMetadata, columnName) => {
|
|
|
2690
2749
|
Object.entries(tableMetadata.columns).forEach(([attribute, mappedColumn]) => {
|
|
2691
2750
|
if (mappedColumn === columnName) delete tableMetadata.columns[attribute];
|
|
2692
2751
|
});
|
|
2752
|
+
if (tableMetadata.primaryKeyGeneration?.column === columnName) delete tableMetadata.primaryKeyGeneration;
|
|
2753
|
+
if (tableMetadata.timestampColumns) {
|
|
2754
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((column) => column.column !== columnName);
|
|
2755
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
const applyPrimaryKeyGeneration = (tableMetadata, column) => {
|
|
2759
|
+
if (!column.primary || !column.primaryKeyGeneration) {
|
|
2760
|
+
if (tableMetadata.primaryKeyGeneration?.column === column.name) delete tableMetadata.primaryKeyGeneration;
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
tableMetadata.primaryKeyGeneration = {
|
|
2764
|
+
column: column.name,
|
|
2765
|
+
...column.primaryKeyGeneration
|
|
2766
|
+
};
|
|
2767
|
+
};
|
|
2768
|
+
const applyTimestampColumn = (tableMetadata, column) => {
|
|
2769
|
+
if (column.type !== "timestamp" || column.default !== "now()" && column.updatedAt !== true) {
|
|
2770
|
+
if (tableMetadata.timestampColumns) {
|
|
2771
|
+
tableMetadata.timestampColumns = tableMetadata.timestampColumns.filter((entry) => entry.column !== column.name);
|
|
2772
|
+
if (tableMetadata.timestampColumns.length === 0) delete tableMetadata.timestampColumns;
|
|
2773
|
+
}
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
const nextColumn = {
|
|
2777
|
+
column: column.name,
|
|
2778
|
+
...column.default === "now()" ? { default: "now()" } : {},
|
|
2779
|
+
...column.updatedAt ? { updatedAt: true } : {}
|
|
2780
|
+
};
|
|
2781
|
+
tableMetadata.timestampColumns = [...(tableMetadata.timestampColumns ?? []).filter((entry) => entry.column !== column.name), nextColumn];
|
|
2693
2782
|
};
|
|
2694
2783
|
const applyOperationsToPersistedColumnMappingsState = (state, operations, features = resolvePersistedMetadataFeatures()) => {
|
|
2695
2784
|
const nextTables = Object.entries(state.tables).reduce((all, [table, metadata]) => {
|
|
@@ -2698,7 +2787,9 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2698
2787
|
enums: Object.entries(metadata.enums).reduce((nextEnums, [columnName, values]) => {
|
|
2699
2788
|
nextEnums[columnName] = [...values];
|
|
2700
2789
|
return nextEnums;
|
|
2701
|
-
}, {})
|
|
2790
|
+
}, {}),
|
|
2791
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration ? { ...metadata.primaryKeyGeneration } : void 0,
|
|
2792
|
+
timestampColumns: metadata.timestampColumns?.map((column) => ({ ...column }))
|
|
2702
2793
|
};
|
|
2703
2794
|
return all;
|
|
2704
2795
|
}, {});
|
|
@@ -2711,8 +2802,10 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2711
2802
|
operation.columns.forEach((column) => {
|
|
2712
2803
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
2713
2804
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
2805
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
2806
|
+
applyTimestampColumn(tableMetadata, column);
|
|
2714
2807
|
});
|
|
2715
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
2808
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
2716
2809
|
else delete nextTables[operation.table];
|
|
2717
2810
|
return;
|
|
2718
2811
|
}
|
|
@@ -2724,11 +2817,13 @@ const applyOperationsToPersistedColumnMappingsState = (state, operations, featur
|
|
|
2724
2817
|
operation.addColumns.forEach((column) => {
|
|
2725
2818
|
applyMappedColumn(tableMetadata.columns, column, features, operation.table);
|
|
2726
2819
|
applyEnumColumn(tableMetadata.enums, column, features, operation.table);
|
|
2820
|
+
applyPrimaryKeyGeneration(tableMetadata, column);
|
|
2821
|
+
applyTimestampColumn(tableMetadata, column);
|
|
2727
2822
|
});
|
|
2728
2823
|
operation.dropColumns.forEach((columnName) => {
|
|
2729
2824
|
removePersistedColumnMetadata(tableMetadata, columnName);
|
|
2730
2825
|
});
|
|
2731
|
-
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0) nextTables[operation.table] = tableMetadata;
|
|
2826
|
+
if (Object.keys(tableMetadata.columns).length > 0 || Object.keys(tableMetadata.enums).length > 0 || tableMetadata.primaryKeyGeneration || tableMetadata.timestampColumns?.length) nextTables[operation.table] = tableMetadata;
|
|
2732
2827
|
else delete nextTables[operation.table];
|
|
2733
2828
|
return;
|
|
2734
2829
|
}
|
|
@@ -7912,8 +8007,29 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7912
8007
|
return !await this.exists();
|
|
7913
8008
|
}
|
|
7914
8009
|
normalizeInsertPayloads(values) {
|
|
7915
|
-
|
|
7916
|
-
|
|
8010
|
+
const payloads = Array.isArray(values) ? values : [values];
|
|
8011
|
+
const metadata = this.model.getModelMetadata();
|
|
8012
|
+
return payloads.map((payload) => {
|
|
8013
|
+
const nextPayload = { ...payload };
|
|
8014
|
+
const now = /* @__PURE__ */ new Date();
|
|
8015
|
+
const primaryKeyValue = nextPayload[metadata.primaryKey];
|
|
8016
|
+
if (primaryKeyValue === void 0 || primaryKeyValue === null) {
|
|
8017
|
+
const generated = PrimaryKeyGenerationPlanner.generate(metadata.primaryKeyGeneration);
|
|
8018
|
+
if (generated !== void 0) nextPayload[metadata.primaryKey] = generated;
|
|
8019
|
+
}
|
|
8020
|
+
for (const column of metadata.timestampColumns ?? []) {
|
|
8021
|
+
if (nextPayload[column.column] !== void 0 && nextPayload[column.column] !== null) continue;
|
|
8022
|
+
if (column.default === "now()" || column.updatedAt) nextPayload[column.column] = now;
|
|
8023
|
+
}
|
|
8024
|
+
return nextPayload;
|
|
8025
|
+
});
|
|
8026
|
+
}
|
|
8027
|
+
normalizeUpdatePayload(values) {
|
|
8028
|
+
const metadata = this.model.getModelMetadata();
|
|
8029
|
+
const nextPayload = { ...values };
|
|
8030
|
+
const now = /* @__PURE__ */ new Date();
|
|
8031
|
+
for (const column of metadata.timestampColumns ?? []) if (column.updatedAt) nextPayload[column.column] = now;
|
|
8032
|
+
return nextPayload;
|
|
7917
8033
|
}
|
|
7918
8034
|
resolveAffectedCount(result, fallback) {
|
|
7919
8035
|
if (typeof result === "number") return result;
|
|
@@ -8156,6 +8272,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8156
8272
|
modelName: this.model.name,
|
|
8157
8273
|
table: metadata.table,
|
|
8158
8274
|
primaryKey: metadata.primaryKey,
|
|
8275
|
+
primaryKeyGeneration: metadata.primaryKeyGeneration,
|
|
8276
|
+
timestampColumns: metadata.timestampColumns,
|
|
8159
8277
|
columns: metadata.columns,
|
|
8160
8278
|
softDelete: metadata.softDelete
|
|
8161
8279
|
};
|
|
@@ -8520,13 +8638,15 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8520
8638
|
}) != null;
|
|
8521
8639
|
}
|
|
8522
8640
|
async executeInsertRow(values) {
|
|
8523
|
-
|
|
8641
|
+
const [payload] = this.normalizeInsertPayloads(values);
|
|
8642
|
+
return await this.requireAdapter().insert(this.tryBuildInsertSpec(payload));
|
|
8524
8643
|
}
|
|
8525
8644
|
async executeInsertManyRows(values, ignoreDuplicates = false) {
|
|
8526
8645
|
const adapter = this.requireAdapter();
|
|
8527
|
-
|
|
8646
|
+
const payloads = this.normalizeInsertPayloads(values);
|
|
8647
|
+
if (typeof adapter.insertMany === "function") return await adapter.insertMany(ignoreDuplicates ? this.tryBuildInsertOrIgnoreManySpec(payloads) : this.tryBuildInsertManySpec(payloads));
|
|
8528
8648
|
let inserted = 0;
|
|
8529
|
-
for (const value of
|
|
8649
|
+
for (const value of payloads) try {
|
|
8530
8650
|
await adapter.insert(this.tryBuildInsertSpec(value));
|
|
8531
8651
|
inserted += 1;
|
|
8532
8652
|
} catch (error) {
|
|
@@ -8536,15 +8656,18 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8536
8656
|
}
|
|
8537
8657
|
async executeUpsertRows(values, uniqueBy, updateColumns) {
|
|
8538
8658
|
const adapter = this.requireAdapter();
|
|
8659
|
+
const payloads = this.normalizeInsertPayloads(values);
|
|
8660
|
+
const timestampUpdateColumns = (this.model.getModelMetadata().timestampColumns ?? []).filter((column) => column.updatedAt).map((column) => column.column);
|
|
8661
|
+
const normalizedUpdateColumns = updateColumns ? Array.from(new Set([...updateColumns, ...timestampUpdateColumns])) : updateColumns;
|
|
8539
8662
|
if (typeof adapter.upsert !== "function") throw new UnsupportedAdapterFeatureException("Upsert is not supported by the current adapter.", {
|
|
8540
8663
|
operation: "query.upsert",
|
|
8541
8664
|
model: this.model.name
|
|
8542
8665
|
});
|
|
8543
|
-
return await adapter.upsert(this.tryBuildUpsertSpec(
|
|
8666
|
+
return await adapter.upsert(this.tryBuildUpsertSpec(payloads, uniqueBy, normalizedUpdateColumns));
|
|
8544
8667
|
}
|
|
8545
8668
|
async executeUpdateRow(where, values) {
|
|
8546
8669
|
const adapter = this.requireAdapter();
|
|
8547
|
-
const spec = this.tryBuildUpdateSpec(where, values);
|
|
8670
|
+
const spec = this.tryBuildUpdateSpec(where, this.normalizeUpdatePayload(values));
|
|
8548
8671
|
if (!spec) throw new UnsupportedAdapterFeatureException("Update could not be compiled into an Arkorm update specification.", {
|
|
8549
8672
|
operation: "query.update",
|
|
8550
8673
|
model: this.model.name
|
|
@@ -8555,7 +8678,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8555
8678
|
}
|
|
8556
8679
|
async executeUpdateManyRows(where, values) {
|
|
8557
8680
|
const adapter = this.requireAdapter();
|
|
8558
|
-
const
|
|
8681
|
+
const normalizedValues = this.normalizeUpdatePayload(values);
|
|
8682
|
+
const spec = this.tryBuildUpdateManySpec(where, normalizedValues);
|
|
8559
8683
|
if (!spec) throw new UnsupportedAdapterFeatureException("Update-many could not be compiled into an Arkorm update specification.", {
|
|
8560
8684
|
operation: "query.updateMany",
|
|
8561
8685
|
model: this.model.name
|
|
@@ -8572,7 +8696,7 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8572
8696
|
if (await adapter.update({
|
|
8573
8697
|
target: spec.target,
|
|
8574
8698
|
where: rowWhere,
|
|
8575
|
-
values:
|
|
8699
|
+
values: normalizedValues
|
|
8576
8700
|
})) updated += 1;
|
|
8577
8701
|
}
|
|
8578
8702
|
return updated;
|
|
@@ -8968,10 +9092,10 @@ var Model = class Model {
|
|
|
8968
9092
|
const adapter = this.getAdapter();
|
|
8969
9093
|
const shouldStrictlyValidatePersistedMappings = Boolean(adapter) && !(adapter instanceof PrismaDatabaseAdapter);
|
|
8970
9094
|
return {
|
|
8971
|
-
...
|
|
9095
|
+
...getPersistedTableMetadata(this.getTable(), {
|
|
8972
9096
|
features: resolvePersistedMetadataFeatures(getUserConfig("features")),
|
|
8973
9097
|
strict: shouldStrictlyValidatePersistedMappings
|
|
8974
|
-
}),
|
|
9098
|
+
}).columns,
|
|
8975
9099
|
...this.columns
|
|
8976
9100
|
};
|
|
8977
9101
|
}
|
|
@@ -8979,11 +9103,27 @@ var Model = class Model {
|
|
|
8979
9103
|
return this.getColumnMap()[attribute] ?? attribute;
|
|
8980
9104
|
}
|
|
8981
9105
|
static getModelMetadata() {
|
|
9106
|
+
const adapter = this.getAdapter();
|
|
9107
|
+
const shouldStrictlyValidatePersistedMappings = Boolean(adapter) && !(adapter instanceof PrismaDatabaseAdapter);
|
|
9108
|
+
const persistedMetadata = getPersistedTableMetadata(this.getTable(), {
|
|
9109
|
+
features: resolvePersistedMetadataFeatures(getUserConfig("features")),
|
|
9110
|
+
strict: shouldStrictlyValidatePersistedMappings
|
|
9111
|
+
});
|
|
8982
9112
|
return {
|
|
8983
9113
|
table: this.getTable(),
|
|
8984
9114
|
primaryKey: this.getPrimaryKey(),
|
|
8985
|
-
columns:
|
|
8986
|
-
|
|
9115
|
+
columns: {
|
|
9116
|
+
...persistedMetadata.columns,
|
|
9117
|
+
...this.columns
|
|
9118
|
+
},
|
|
9119
|
+
softDelete: this.getSoftDeleteConfig(),
|
|
9120
|
+
primaryKeyGeneration: persistedMetadata.primaryKeyGeneration?.column === this.getPrimaryKey() ? {
|
|
9121
|
+
strategy: persistedMetadata.primaryKeyGeneration.strategy,
|
|
9122
|
+
prismaDefault: persistedMetadata.primaryKeyGeneration.prismaDefault,
|
|
9123
|
+
databaseDefault: persistedMetadata.primaryKeyGeneration.databaseDefault,
|
|
9124
|
+
runtimeFactory: persistedMetadata.primaryKeyGeneration.runtimeFactory
|
|
9125
|
+
} : void 0,
|
|
9126
|
+
timestampColumns: persistedMetadata.timestampColumns?.map((column) => ({ ...column }))
|
|
8987
9127
|
};
|
|
8988
9128
|
}
|
|
8989
9129
|
static getRelationMetadata(name) {
|
|
@@ -9985,4 +10125,4 @@ var Model = class Model {
|
|
|
9985
10125
|
};
|
|
9986
10126
|
|
|
9987
10127
|
//#endregion
|
|
9988
|
-
export { ArkormCollection, ArkormException, Attribute, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedTableMetadata, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
|
10128
|
+
export { ArkormCollection, ArkormException, Attribute, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|