@momentumcms/migrations 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/generate.cjs +62 -13
- package/src/cli/generate.js +62 -13
- package/src/cli/rollback.cjs +34 -1
- package/src/cli/rollback.js +34 -1
- package/src/cli/run.cjs +34 -1
- package/src/cli/run.js +34 -1
- package/src/cli/status.cjs +34 -1
- package/src/cli/status.js +34 -1
- package/src/index.cjs +61 -12
- package/src/index.js +61 -12
package/package.json
CHANGED
package/src/cli/generate.cjs
CHANGED
|
@@ -88,6 +88,31 @@ function json(name, options = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// libs/core/src/lib/collections/media.collection.ts
|
|
91
|
+
var validateFocalPoint = (value) => {
|
|
92
|
+
if (value === null || value === void 0)
|
|
93
|
+
return true;
|
|
94
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
95
|
+
return "Focal point must be an object with x and y coordinates";
|
|
96
|
+
}
|
|
97
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
98
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
99
|
+
return "Focal point must have both x and y properties";
|
|
100
|
+
}
|
|
101
|
+
const { x, y } = fp;
|
|
102
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
103
|
+
return "Focal point x must be a finite number";
|
|
104
|
+
}
|
|
105
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
106
|
+
return "Focal point y must be a finite number";
|
|
107
|
+
}
|
|
108
|
+
if (x < 0 || x > 1) {
|
|
109
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
110
|
+
}
|
|
111
|
+
if (y < 0 || y > 1) {
|
|
112
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
};
|
|
91
116
|
var MediaCollection = defineCollection({
|
|
92
117
|
slug: "media",
|
|
93
118
|
labels: {
|
|
@@ -142,6 +167,14 @@ var MediaCollection = defineCollection({
|
|
|
142
167
|
json("focalPoint", {
|
|
143
168
|
label: "Focal Point",
|
|
144
169
|
description: "Focal point coordinates for image cropping",
|
|
170
|
+
validate: validateFocalPoint,
|
|
171
|
+
admin: {
|
|
172
|
+
hidden: true
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
json("sizes", {
|
|
176
|
+
label: "Image Sizes",
|
|
177
|
+
description: "Generated image size variants",
|
|
145
178
|
admin: {
|
|
146
179
|
hidden: true
|
|
147
180
|
}
|
|
@@ -161,7 +194,7 @@ var MediaCollection = defineCollection({
|
|
|
161
194
|
function resolveMigrationMode(mode) {
|
|
162
195
|
if (mode === "push" || mode === "migrate")
|
|
163
196
|
return mode;
|
|
164
|
-
const env = process
|
|
197
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
165
198
|
if (env === "production")
|
|
166
199
|
return "migrate";
|
|
167
200
|
return "push";
|
|
@@ -686,10 +719,14 @@ function diffColumns(tableName, desiredColumns, actualColumns, dialect, opts) {
|
|
|
686
719
|
const extraInActual = [...actualMap.keys()].filter((k) => !desiredMap.has(k));
|
|
687
720
|
for (const newName of missingInActual) {
|
|
688
721
|
const desiredCol = desiredMap.get(newName);
|
|
722
|
+
if (!desiredCol)
|
|
723
|
+
continue;
|
|
689
724
|
for (const oldName of extraInActual) {
|
|
690
725
|
if (renamedFrom.has(oldName))
|
|
691
726
|
continue;
|
|
692
727
|
const actualCol = actualMap.get(oldName);
|
|
728
|
+
if (!actualCol)
|
|
729
|
+
continue;
|
|
693
730
|
if (areTypesCompatible(desiredCol.type, actualCol.type, dialect)) {
|
|
694
731
|
operations.push({
|
|
695
732
|
type: "renameColumn",
|
|
@@ -802,6 +839,8 @@ function diffForeignKeys(tableName, desiredFks, actualFks) {
|
|
|
802
839
|
summary.push(`Add foreign key "${name}" on "${tableName}"`);
|
|
803
840
|
} else {
|
|
804
841
|
const actualFk = actualMap.get(name);
|
|
842
|
+
if (!actualFk)
|
|
843
|
+
continue;
|
|
805
844
|
if (fk.column !== actualFk.column || fk.referencedTable !== actualFk.referencedTable || fk.referencedColumn !== actualFk.referencedColumn || fk.onDelete !== actualFk.onDelete) {
|
|
806
845
|
operations.push({
|
|
807
846
|
type: "dropForeignKey",
|
|
@@ -854,6 +893,8 @@ function diffIndexes(tableName, desiredIdxs, actualIdxs) {
|
|
|
854
893
|
summary.push(`Create index "${name}" on "${tableName}"`);
|
|
855
894
|
} else {
|
|
856
895
|
const actualIdx = actualMap.get(name);
|
|
896
|
+
if (!actualIdx)
|
|
897
|
+
continue;
|
|
857
898
|
if (idx.unique !== actualIdx.unique || JSON.stringify(idx.columns) !== JSON.stringify(actualIdx.columns)) {
|
|
858
899
|
operations.push({
|
|
859
900
|
type: "dropIndex",
|
|
@@ -1400,22 +1441,26 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1400
1441
|
const pkLookup = /* @__PURE__ */ new Map();
|
|
1401
1442
|
for (const row2 of pkRows) {
|
|
1402
1443
|
const tableName = row2.table_name;
|
|
1403
|
-
|
|
1404
|
-
|
|
1444
|
+
let pkSet = pkLookup.get(tableName);
|
|
1445
|
+
if (!pkSet) {
|
|
1446
|
+
pkSet = /* @__PURE__ */ new Set();
|
|
1447
|
+
pkLookup.set(tableName, pkSet);
|
|
1405
1448
|
}
|
|
1406
|
-
|
|
1449
|
+
pkSet.add(row2.column_name);
|
|
1407
1450
|
}
|
|
1408
1451
|
const tableColumnsMap = /* @__PURE__ */ new Map();
|
|
1409
1452
|
for (const row2 of columnRows) {
|
|
1410
1453
|
const tableName = row2.table_name;
|
|
1411
1454
|
if (INTERNAL_TABLES.has(tableName))
|
|
1412
1455
|
continue;
|
|
1413
|
-
|
|
1414
|
-
|
|
1456
|
+
let columnList = tableColumnsMap.get(tableName);
|
|
1457
|
+
if (!columnList) {
|
|
1458
|
+
columnList = [];
|
|
1459
|
+
tableColumnsMap.set(tableName, columnList);
|
|
1415
1460
|
}
|
|
1416
1461
|
const rawType = buildPgColumnType(row2);
|
|
1417
1462
|
const pkSet = pkLookup.get(tableName);
|
|
1418
|
-
|
|
1463
|
+
columnList.push({
|
|
1419
1464
|
name: row2.column_name,
|
|
1420
1465
|
type: normalizeColumnType(rawType, "postgresql"),
|
|
1421
1466
|
nullable: row2.is_nullable === "YES",
|
|
@@ -1428,10 +1473,12 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1428
1473
|
const tableName = row2.table_name;
|
|
1429
1474
|
if (INTERNAL_TABLES.has(tableName))
|
|
1430
1475
|
continue;
|
|
1431
|
-
|
|
1432
|
-
|
|
1476
|
+
let fkList = tableFkMap.get(tableName);
|
|
1477
|
+
if (!fkList) {
|
|
1478
|
+
fkList = [];
|
|
1479
|
+
tableFkMap.set(tableName, fkList);
|
|
1433
1480
|
}
|
|
1434
|
-
|
|
1481
|
+
fkList.push({
|
|
1435
1482
|
constraintName: row2.constraint_name,
|
|
1436
1483
|
column: row2.column_name,
|
|
1437
1484
|
referencedTable: row2.foreign_table_name,
|
|
@@ -1451,12 +1498,14 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1451
1498
|
continue;
|
|
1452
1499
|
if (row2.indexname.endsWith("_pkey"))
|
|
1453
1500
|
continue;
|
|
1454
|
-
|
|
1455
|
-
|
|
1501
|
+
let indexList = tableIndexMap.get(tableName);
|
|
1502
|
+
if (!indexList) {
|
|
1503
|
+
indexList = [];
|
|
1504
|
+
tableIndexMap.set(tableName, indexList);
|
|
1456
1505
|
}
|
|
1457
1506
|
const columns = extractIndexColumns(row2.indexdef);
|
|
1458
1507
|
const unique = row2.indexdef.toUpperCase().includes("UNIQUE");
|
|
1459
|
-
|
|
1508
|
+
indexList.push({
|
|
1460
1509
|
name: row2.indexname,
|
|
1461
1510
|
columns,
|
|
1462
1511
|
unique
|
package/src/cli/generate.js
CHANGED
|
@@ -86,6 +86,31 @@ function json(name, options = {}) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// libs/core/src/lib/collections/media.collection.ts
|
|
89
|
+
var validateFocalPoint = (value) => {
|
|
90
|
+
if (value === null || value === void 0)
|
|
91
|
+
return true;
|
|
92
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
93
|
+
return "Focal point must be an object with x and y coordinates";
|
|
94
|
+
}
|
|
95
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
96
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
97
|
+
return "Focal point must have both x and y properties";
|
|
98
|
+
}
|
|
99
|
+
const { x, y } = fp;
|
|
100
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
101
|
+
return "Focal point x must be a finite number";
|
|
102
|
+
}
|
|
103
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
104
|
+
return "Focal point y must be a finite number";
|
|
105
|
+
}
|
|
106
|
+
if (x < 0 || x > 1) {
|
|
107
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
108
|
+
}
|
|
109
|
+
if (y < 0 || y > 1) {
|
|
110
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
};
|
|
89
114
|
var MediaCollection = defineCollection({
|
|
90
115
|
slug: "media",
|
|
91
116
|
labels: {
|
|
@@ -140,6 +165,14 @@ var MediaCollection = defineCollection({
|
|
|
140
165
|
json("focalPoint", {
|
|
141
166
|
label: "Focal Point",
|
|
142
167
|
description: "Focal point coordinates for image cropping",
|
|
168
|
+
validate: validateFocalPoint,
|
|
169
|
+
admin: {
|
|
170
|
+
hidden: true
|
|
171
|
+
}
|
|
172
|
+
}),
|
|
173
|
+
json("sizes", {
|
|
174
|
+
label: "Image Sizes",
|
|
175
|
+
description: "Generated image size variants",
|
|
143
176
|
admin: {
|
|
144
177
|
hidden: true
|
|
145
178
|
}
|
|
@@ -159,7 +192,7 @@ var MediaCollection = defineCollection({
|
|
|
159
192
|
function resolveMigrationMode(mode) {
|
|
160
193
|
if (mode === "push" || mode === "migrate")
|
|
161
194
|
return mode;
|
|
162
|
-
const env = process
|
|
195
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
163
196
|
if (env === "production")
|
|
164
197
|
return "migrate";
|
|
165
198
|
return "push";
|
|
@@ -684,10 +717,14 @@ function diffColumns(tableName, desiredColumns, actualColumns, dialect, opts) {
|
|
|
684
717
|
const extraInActual = [...actualMap.keys()].filter((k) => !desiredMap.has(k));
|
|
685
718
|
for (const newName of missingInActual) {
|
|
686
719
|
const desiredCol = desiredMap.get(newName);
|
|
720
|
+
if (!desiredCol)
|
|
721
|
+
continue;
|
|
687
722
|
for (const oldName of extraInActual) {
|
|
688
723
|
if (renamedFrom.has(oldName))
|
|
689
724
|
continue;
|
|
690
725
|
const actualCol = actualMap.get(oldName);
|
|
726
|
+
if (!actualCol)
|
|
727
|
+
continue;
|
|
691
728
|
if (areTypesCompatible(desiredCol.type, actualCol.type, dialect)) {
|
|
692
729
|
operations.push({
|
|
693
730
|
type: "renameColumn",
|
|
@@ -800,6 +837,8 @@ function diffForeignKeys(tableName, desiredFks, actualFks) {
|
|
|
800
837
|
summary.push(`Add foreign key "${name}" on "${tableName}"`);
|
|
801
838
|
} else {
|
|
802
839
|
const actualFk = actualMap.get(name);
|
|
840
|
+
if (!actualFk)
|
|
841
|
+
continue;
|
|
803
842
|
if (fk.column !== actualFk.column || fk.referencedTable !== actualFk.referencedTable || fk.referencedColumn !== actualFk.referencedColumn || fk.onDelete !== actualFk.onDelete) {
|
|
804
843
|
operations.push({
|
|
805
844
|
type: "dropForeignKey",
|
|
@@ -852,6 +891,8 @@ function diffIndexes(tableName, desiredIdxs, actualIdxs) {
|
|
|
852
891
|
summary.push(`Create index "${name}" on "${tableName}"`);
|
|
853
892
|
} else {
|
|
854
893
|
const actualIdx = actualMap.get(name);
|
|
894
|
+
if (!actualIdx)
|
|
895
|
+
continue;
|
|
855
896
|
if (idx.unique !== actualIdx.unique || JSON.stringify(idx.columns) !== JSON.stringify(actualIdx.columns)) {
|
|
856
897
|
operations.push({
|
|
857
898
|
type: "dropIndex",
|
|
@@ -1398,22 +1439,26 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1398
1439
|
const pkLookup = /* @__PURE__ */ new Map();
|
|
1399
1440
|
for (const row2 of pkRows) {
|
|
1400
1441
|
const tableName = row2.table_name;
|
|
1401
|
-
|
|
1402
|
-
|
|
1442
|
+
let pkSet = pkLookup.get(tableName);
|
|
1443
|
+
if (!pkSet) {
|
|
1444
|
+
pkSet = /* @__PURE__ */ new Set();
|
|
1445
|
+
pkLookup.set(tableName, pkSet);
|
|
1403
1446
|
}
|
|
1404
|
-
|
|
1447
|
+
pkSet.add(row2.column_name);
|
|
1405
1448
|
}
|
|
1406
1449
|
const tableColumnsMap = /* @__PURE__ */ new Map();
|
|
1407
1450
|
for (const row2 of columnRows) {
|
|
1408
1451
|
const tableName = row2.table_name;
|
|
1409
1452
|
if (INTERNAL_TABLES.has(tableName))
|
|
1410
1453
|
continue;
|
|
1411
|
-
|
|
1412
|
-
|
|
1454
|
+
let columnList = tableColumnsMap.get(tableName);
|
|
1455
|
+
if (!columnList) {
|
|
1456
|
+
columnList = [];
|
|
1457
|
+
tableColumnsMap.set(tableName, columnList);
|
|
1413
1458
|
}
|
|
1414
1459
|
const rawType = buildPgColumnType(row2);
|
|
1415
1460
|
const pkSet = pkLookup.get(tableName);
|
|
1416
|
-
|
|
1461
|
+
columnList.push({
|
|
1417
1462
|
name: row2.column_name,
|
|
1418
1463
|
type: normalizeColumnType(rawType, "postgresql"),
|
|
1419
1464
|
nullable: row2.is_nullable === "YES",
|
|
@@ -1426,10 +1471,12 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1426
1471
|
const tableName = row2.table_name;
|
|
1427
1472
|
if (INTERNAL_TABLES.has(tableName))
|
|
1428
1473
|
continue;
|
|
1429
|
-
|
|
1430
|
-
|
|
1474
|
+
let fkList = tableFkMap.get(tableName);
|
|
1475
|
+
if (!fkList) {
|
|
1476
|
+
fkList = [];
|
|
1477
|
+
tableFkMap.set(tableName, fkList);
|
|
1431
1478
|
}
|
|
1432
|
-
|
|
1479
|
+
fkList.push({
|
|
1433
1480
|
constraintName: row2.constraint_name,
|
|
1434
1481
|
column: row2.column_name,
|
|
1435
1482
|
referencedTable: row2.foreign_table_name,
|
|
@@ -1449,12 +1496,14 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
1449
1496
|
continue;
|
|
1450
1497
|
if (row2.indexname.endsWith("_pkey"))
|
|
1451
1498
|
continue;
|
|
1452
|
-
|
|
1453
|
-
|
|
1499
|
+
let indexList = tableIndexMap.get(tableName);
|
|
1500
|
+
if (!indexList) {
|
|
1501
|
+
indexList = [];
|
|
1502
|
+
tableIndexMap.set(tableName, indexList);
|
|
1454
1503
|
}
|
|
1455
1504
|
const columns = extractIndexColumns(row2.indexdef);
|
|
1456
1505
|
const unique = row2.indexdef.toUpperCase().includes("UNIQUE");
|
|
1457
|
-
|
|
1506
|
+
indexList.push({
|
|
1458
1507
|
name: row2.indexname,
|
|
1459
1508
|
columns,
|
|
1460
1509
|
unique
|
package/src/cli/rollback.cjs
CHANGED
|
@@ -48,6 +48,31 @@ function json(name, options = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// libs/core/src/lib/collections/media.collection.ts
|
|
51
|
+
var validateFocalPoint = (value) => {
|
|
52
|
+
if (value === null || value === void 0)
|
|
53
|
+
return true;
|
|
54
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
55
|
+
return "Focal point must be an object with x and y coordinates";
|
|
56
|
+
}
|
|
57
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
58
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
59
|
+
return "Focal point must have both x and y properties";
|
|
60
|
+
}
|
|
61
|
+
const { x, y } = fp;
|
|
62
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
63
|
+
return "Focal point x must be a finite number";
|
|
64
|
+
}
|
|
65
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
66
|
+
return "Focal point y must be a finite number";
|
|
67
|
+
}
|
|
68
|
+
if (x < 0 || x > 1) {
|
|
69
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
70
|
+
}
|
|
71
|
+
if (y < 0 || y > 1) {
|
|
72
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
51
76
|
var MediaCollection = defineCollection({
|
|
52
77
|
slug: "media",
|
|
53
78
|
labels: {
|
|
@@ -102,6 +127,14 @@ var MediaCollection = defineCollection({
|
|
|
102
127
|
json("focalPoint", {
|
|
103
128
|
label: "Focal Point",
|
|
104
129
|
description: "Focal point coordinates for image cropping",
|
|
130
|
+
validate: validateFocalPoint,
|
|
131
|
+
admin: {
|
|
132
|
+
hidden: true
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
json("sizes", {
|
|
136
|
+
label: "Image Sizes",
|
|
137
|
+
description: "Generated image size variants",
|
|
105
138
|
admin: {
|
|
106
139
|
hidden: true
|
|
107
140
|
}
|
|
@@ -121,7 +154,7 @@ var MediaCollection = defineCollection({
|
|
|
121
154
|
function resolveMigrationMode(mode) {
|
|
122
155
|
if (mode === "push" || mode === "migrate")
|
|
123
156
|
return mode;
|
|
124
|
-
const env = process
|
|
157
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
125
158
|
if (env === "production")
|
|
126
159
|
return "migrate";
|
|
127
160
|
return "push";
|
package/src/cli/rollback.js
CHANGED
|
@@ -46,6 +46,31 @@ function json(name, options = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// libs/core/src/lib/collections/media.collection.ts
|
|
49
|
+
var validateFocalPoint = (value) => {
|
|
50
|
+
if (value === null || value === void 0)
|
|
51
|
+
return true;
|
|
52
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
53
|
+
return "Focal point must be an object with x and y coordinates";
|
|
54
|
+
}
|
|
55
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
56
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
57
|
+
return "Focal point must have both x and y properties";
|
|
58
|
+
}
|
|
59
|
+
const { x, y } = fp;
|
|
60
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
61
|
+
return "Focal point x must be a finite number";
|
|
62
|
+
}
|
|
63
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
64
|
+
return "Focal point y must be a finite number";
|
|
65
|
+
}
|
|
66
|
+
if (x < 0 || x > 1) {
|
|
67
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
68
|
+
}
|
|
69
|
+
if (y < 0 || y > 1) {
|
|
70
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
49
74
|
var MediaCollection = defineCollection({
|
|
50
75
|
slug: "media",
|
|
51
76
|
labels: {
|
|
@@ -100,6 +125,14 @@ var MediaCollection = defineCollection({
|
|
|
100
125
|
json("focalPoint", {
|
|
101
126
|
label: "Focal Point",
|
|
102
127
|
description: "Focal point coordinates for image cropping",
|
|
128
|
+
validate: validateFocalPoint,
|
|
129
|
+
admin: {
|
|
130
|
+
hidden: true
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
json("sizes", {
|
|
134
|
+
label: "Image Sizes",
|
|
135
|
+
description: "Generated image size variants",
|
|
103
136
|
admin: {
|
|
104
137
|
hidden: true
|
|
105
138
|
}
|
|
@@ -119,7 +152,7 @@ var MediaCollection = defineCollection({
|
|
|
119
152
|
function resolveMigrationMode(mode) {
|
|
120
153
|
if (mode === "push" || mode === "migrate")
|
|
121
154
|
return mode;
|
|
122
|
-
const env = process
|
|
155
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
123
156
|
if (env === "production")
|
|
124
157
|
return "migrate";
|
|
125
158
|
return "push";
|
package/src/cli/run.cjs
CHANGED
|
@@ -48,6 +48,31 @@ function json(name, options = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// libs/core/src/lib/collections/media.collection.ts
|
|
51
|
+
var validateFocalPoint = (value) => {
|
|
52
|
+
if (value === null || value === void 0)
|
|
53
|
+
return true;
|
|
54
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
55
|
+
return "Focal point must be an object with x and y coordinates";
|
|
56
|
+
}
|
|
57
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
58
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
59
|
+
return "Focal point must have both x and y properties";
|
|
60
|
+
}
|
|
61
|
+
const { x, y } = fp;
|
|
62
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
63
|
+
return "Focal point x must be a finite number";
|
|
64
|
+
}
|
|
65
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
66
|
+
return "Focal point y must be a finite number";
|
|
67
|
+
}
|
|
68
|
+
if (x < 0 || x > 1) {
|
|
69
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
70
|
+
}
|
|
71
|
+
if (y < 0 || y > 1) {
|
|
72
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
51
76
|
var MediaCollection = defineCollection({
|
|
52
77
|
slug: "media",
|
|
53
78
|
labels: {
|
|
@@ -102,6 +127,14 @@ var MediaCollection = defineCollection({
|
|
|
102
127
|
json("focalPoint", {
|
|
103
128
|
label: "Focal Point",
|
|
104
129
|
description: "Focal point coordinates for image cropping",
|
|
130
|
+
validate: validateFocalPoint,
|
|
131
|
+
admin: {
|
|
132
|
+
hidden: true
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
json("sizes", {
|
|
136
|
+
label: "Image Sizes",
|
|
137
|
+
description: "Generated image size variants",
|
|
105
138
|
admin: {
|
|
106
139
|
hidden: true
|
|
107
140
|
}
|
|
@@ -121,7 +154,7 @@ var MediaCollection = defineCollection({
|
|
|
121
154
|
function resolveMigrationMode(mode) {
|
|
122
155
|
if (mode === "push" || mode === "migrate")
|
|
123
156
|
return mode;
|
|
124
|
-
const env = process
|
|
157
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
125
158
|
if (env === "production")
|
|
126
159
|
return "migrate";
|
|
127
160
|
return "push";
|
package/src/cli/run.js
CHANGED
|
@@ -54,6 +54,31 @@ function json(name, options = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// libs/core/src/lib/collections/media.collection.ts
|
|
57
|
+
var validateFocalPoint = (value) => {
|
|
58
|
+
if (value === null || value === void 0)
|
|
59
|
+
return true;
|
|
60
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
61
|
+
return "Focal point must be an object with x and y coordinates";
|
|
62
|
+
}
|
|
63
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
64
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
65
|
+
return "Focal point must have both x and y properties";
|
|
66
|
+
}
|
|
67
|
+
const { x, y } = fp;
|
|
68
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
69
|
+
return "Focal point x must be a finite number";
|
|
70
|
+
}
|
|
71
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
72
|
+
return "Focal point y must be a finite number";
|
|
73
|
+
}
|
|
74
|
+
if (x < 0 || x > 1) {
|
|
75
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
76
|
+
}
|
|
77
|
+
if (y < 0 || y > 1) {
|
|
78
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
};
|
|
57
82
|
var MediaCollection = defineCollection({
|
|
58
83
|
slug: "media",
|
|
59
84
|
labels: {
|
|
@@ -108,6 +133,14 @@ var MediaCollection = defineCollection({
|
|
|
108
133
|
json("focalPoint", {
|
|
109
134
|
label: "Focal Point",
|
|
110
135
|
description: "Focal point coordinates for image cropping",
|
|
136
|
+
validate: validateFocalPoint,
|
|
137
|
+
admin: {
|
|
138
|
+
hidden: true
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
json("sizes", {
|
|
142
|
+
label: "Image Sizes",
|
|
143
|
+
description: "Generated image size variants",
|
|
111
144
|
admin: {
|
|
112
145
|
hidden: true
|
|
113
146
|
}
|
|
@@ -127,7 +160,7 @@ var MediaCollection = defineCollection({
|
|
|
127
160
|
function resolveMigrationMode(mode) {
|
|
128
161
|
if (mode === "push" || mode === "migrate")
|
|
129
162
|
return mode;
|
|
130
|
-
const env = process
|
|
163
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
131
164
|
if (env === "production")
|
|
132
165
|
return "migrate";
|
|
133
166
|
return "push";
|
package/src/cli/status.cjs
CHANGED
|
@@ -48,6 +48,31 @@ function json(name, options = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// libs/core/src/lib/collections/media.collection.ts
|
|
51
|
+
var validateFocalPoint = (value) => {
|
|
52
|
+
if (value === null || value === void 0)
|
|
53
|
+
return true;
|
|
54
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
55
|
+
return "Focal point must be an object with x and y coordinates";
|
|
56
|
+
}
|
|
57
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
58
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
59
|
+
return "Focal point must have both x and y properties";
|
|
60
|
+
}
|
|
61
|
+
const { x, y } = fp;
|
|
62
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
63
|
+
return "Focal point x must be a finite number";
|
|
64
|
+
}
|
|
65
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
66
|
+
return "Focal point y must be a finite number";
|
|
67
|
+
}
|
|
68
|
+
if (x < 0 || x > 1) {
|
|
69
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
70
|
+
}
|
|
71
|
+
if (y < 0 || y > 1) {
|
|
72
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
51
76
|
var MediaCollection = defineCollection({
|
|
52
77
|
slug: "media",
|
|
53
78
|
labels: {
|
|
@@ -102,6 +127,14 @@ var MediaCollection = defineCollection({
|
|
|
102
127
|
json("focalPoint", {
|
|
103
128
|
label: "Focal Point",
|
|
104
129
|
description: "Focal point coordinates for image cropping",
|
|
130
|
+
validate: validateFocalPoint,
|
|
131
|
+
admin: {
|
|
132
|
+
hidden: true
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
json("sizes", {
|
|
136
|
+
label: "Image Sizes",
|
|
137
|
+
description: "Generated image size variants",
|
|
105
138
|
admin: {
|
|
106
139
|
hidden: true
|
|
107
140
|
}
|
|
@@ -121,7 +154,7 @@ var MediaCollection = defineCollection({
|
|
|
121
154
|
function resolveMigrationMode(mode) {
|
|
122
155
|
if (mode === "push" || mode === "migrate")
|
|
123
156
|
return mode;
|
|
124
|
-
const env = process
|
|
157
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
125
158
|
if (env === "production")
|
|
126
159
|
return "migrate";
|
|
127
160
|
return "push";
|
package/src/cli/status.js
CHANGED
|
@@ -46,6 +46,31 @@ function json(name, options = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// libs/core/src/lib/collections/media.collection.ts
|
|
49
|
+
var validateFocalPoint = (value) => {
|
|
50
|
+
if (value === null || value === void 0)
|
|
51
|
+
return true;
|
|
52
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
53
|
+
return "Focal point must be an object with x and y coordinates";
|
|
54
|
+
}
|
|
55
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
56
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
57
|
+
return "Focal point must have both x and y properties";
|
|
58
|
+
}
|
|
59
|
+
const { x, y } = fp;
|
|
60
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
61
|
+
return "Focal point x must be a finite number";
|
|
62
|
+
}
|
|
63
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
64
|
+
return "Focal point y must be a finite number";
|
|
65
|
+
}
|
|
66
|
+
if (x < 0 || x > 1) {
|
|
67
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
68
|
+
}
|
|
69
|
+
if (y < 0 || y > 1) {
|
|
70
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
49
74
|
var MediaCollection = defineCollection({
|
|
50
75
|
slug: "media",
|
|
51
76
|
labels: {
|
|
@@ -100,6 +125,14 @@ var MediaCollection = defineCollection({
|
|
|
100
125
|
json("focalPoint", {
|
|
101
126
|
label: "Focal Point",
|
|
102
127
|
description: "Focal point coordinates for image cropping",
|
|
128
|
+
validate: validateFocalPoint,
|
|
129
|
+
admin: {
|
|
130
|
+
hidden: true
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
json("sizes", {
|
|
134
|
+
label: "Image Sizes",
|
|
135
|
+
description: "Generated image size variants",
|
|
103
136
|
admin: {
|
|
104
137
|
hidden: true
|
|
105
138
|
}
|
|
@@ -119,7 +152,7 @@ var MediaCollection = defineCollection({
|
|
|
119
152
|
function resolveMigrationMode(mode) {
|
|
120
153
|
if (mode === "push" || mode === "migrate")
|
|
121
154
|
return mode;
|
|
122
|
-
const env = process
|
|
155
|
+
const env = globalThis["process"]?.env?.["NODE_ENV"];
|
|
123
156
|
if (env === "production")
|
|
124
157
|
return "migrate";
|
|
125
158
|
return "push";
|
package/src/index.cjs
CHANGED
|
@@ -285,22 +285,26 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
285
285
|
const pkLookup = /* @__PURE__ */ new Map();
|
|
286
286
|
for (const row2 of pkRows) {
|
|
287
287
|
const tableName = row2.table_name;
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
let pkSet = pkLookup.get(tableName);
|
|
289
|
+
if (!pkSet) {
|
|
290
|
+
pkSet = /* @__PURE__ */ new Set();
|
|
291
|
+
pkLookup.set(tableName, pkSet);
|
|
290
292
|
}
|
|
291
|
-
|
|
293
|
+
pkSet.add(row2.column_name);
|
|
292
294
|
}
|
|
293
295
|
const tableColumnsMap = /* @__PURE__ */ new Map();
|
|
294
296
|
for (const row2 of columnRows) {
|
|
295
297
|
const tableName = row2.table_name;
|
|
296
298
|
if (INTERNAL_TABLES.has(tableName))
|
|
297
299
|
continue;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
+
let columnList = tableColumnsMap.get(tableName);
|
|
301
|
+
if (!columnList) {
|
|
302
|
+
columnList = [];
|
|
303
|
+
tableColumnsMap.set(tableName, columnList);
|
|
300
304
|
}
|
|
301
305
|
const rawType = buildPgColumnType(row2);
|
|
302
306
|
const pkSet = pkLookup.get(tableName);
|
|
303
|
-
|
|
307
|
+
columnList.push({
|
|
304
308
|
name: row2.column_name,
|
|
305
309
|
type: normalizeColumnType(rawType, "postgresql"),
|
|
306
310
|
nullable: row2.is_nullable === "YES",
|
|
@@ -313,10 +317,12 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
313
317
|
const tableName = row2.table_name;
|
|
314
318
|
if (INTERNAL_TABLES.has(tableName))
|
|
315
319
|
continue;
|
|
316
|
-
|
|
317
|
-
|
|
320
|
+
let fkList = tableFkMap.get(tableName);
|
|
321
|
+
if (!fkList) {
|
|
322
|
+
fkList = [];
|
|
323
|
+
tableFkMap.set(tableName, fkList);
|
|
318
324
|
}
|
|
319
|
-
|
|
325
|
+
fkList.push({
|
|
320
326
|
constraintName: row2.constraint_name,
|
|
321
327
|
column: row2.column_name,
|
|
322
328
|
referencedTable: row2.foreign_table_name,
|
|
@@ -336,12 +342,14 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
336
342
|
continue;
|
|
337
343
|
if (row2.indexname.endsWith("_pkey"))
|
|
338
344
|
continue;
|
|
339
|
-
|
|
340
|
-
|
|
345
|
+
let indexList = tableIndexMap.get(tableName);
|
|
346
|
+
if (!indexList) {
|
|
347
|
+
indexList = [];
|
|
348
|
+
tableIndexMap.set(tableName, indexList);
|
|
341
349
|
}
|
|
342
350
|
const columns = extractIndexColumns(row2.indexdef);
|
|
343
351
|
const unique = row2.indexdef.toUpperCase().includes("UNIQUE");
|
|
344
|
-
|
|
352
|
+
indexList.push({
|
|
345
353
|
name: row2.indexname,
|
|
346
354
|
columns,
|
|
347
355
|
unique
|
|
@@ -520,6 +528,31 @@ function json(name, options = {}) {
|
|
|
520
528
|
}
|
|
521
529
|
|
|
522
530
|
// libs/core/src/lib/collections/media.collection.ts
|
|
531
|
+
var validateFocalPoint = (value) => {
|
|
532
|
+
if (value === null || value === void 0)
|
|
533
|
+
return true;
|
|
534
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
535
|
+
return "Focal point must be an object with x and y coordinates";
|
|
536
|
+
}
|
|
537
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
538
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
539
|
+
return "Focal point must have both x and y properties";
|
|
540
|
+
}
|
|
541
|
+
const { x, y } = fp;
|
|
542
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
543
|
+
return "Focal point x must be a finite number";
|
|
544
|
+
}
|
|
545
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
546
|
+
return "Focal point y must be a finite number";
|
|
547
|
+
}
|
|
548
|
+
if (x < 0 || x > 1) {
|
|
549
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
550
|
+
}
|
|
551
|
+
if (y < 0 || y > 1) {
|
|
552
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
};
|
|
523
556
|
var MediaCollection = defineCollection({
|
|
524
557
|
slug: "media",
|
|
525
558
|
labels: {
|
|
@@ -574,6 +607,14 @@ var MediaCollection = defineCollection({
|
|
|
574
607
|
json("focalPoint", {
|
|
575
608
|
label: "Focal Point",
|
|
576
609
|
description: "Focal point coordinates for image cropping",
|
|
610
|
+
validate: validateFocalPoint,
|
|
611
|
+
admin: {
|
|
612
|
+
hidden: true
|
|
613
|
+
}
|
|
614
|
+
}),
|
|
615
|
+
json("sizes", {
|
|
616
|
+
label: "Image Sizes",
|
|
617
|
+
description: "Generated image size variants",
|
|
577
618
|
admin: {
|
|
578
619
|
hidden: true
|
|
579
620
|
}
|
|
@@ -935,10 +976,14 @@ function diffColumns(tableName, desiredColumns, actualColumns, dialect, opts) {
|
|
|
935
976
|
const extraInActual = [...actualMap.keys()].filter((k) => !desiredMap.has(k));
|
|
936
977
|
for (const newName of missingInActual) {
|
|
937
978
|
const desiredCol = desiredMap.get(newName);
|
|
979
|
+
if (!desiredCol)
|
|
980
|
+
continue;
|
|
938
981
|
for (const oldName of extraInActual) {
|
|
939
982
|
if (renamedFrom.has(oldName))
|
|
940
983
|
continue;
|
|
941
984
|
const actualCol = actualMap.get(oldName);
|
|
985
|
+
if (!actualCol)
|
|
986
|
+
continue;
|
|
942
987
|
if (areTypesCompatible(desiredCol.type, actualCol.type, dialect)) {
|
|
943
988
|
operations.push({
|
|
944
989
|
type: "renameColumn",
|
|
@@ -1051,6 +1096,8 @@ function diffForeignKeys(tableName, desiredFks, actualFks) {
|
|
|
1051
1096
|
summary.push(`Add foreign key "${name}" on "${tableName}"`);
|
|
1052
1097
|
} else {
|
|
1053
1098
|
const actualFk = actualMap.get(name);
|
|
1099
|
+
if (!actualFk)
|
|
1100
|
+
continue;
|
|
1054
1101
|
if (fk.column !== actualFk.column || fk.referencedTable !== actualFk.referencedTable || fk.referencedColumn !== actualFk.referencedColumn || fk.onDelete !== actualFk.onDelete) {
|
|
1055
1102
|
operations.push({
|
|
1056
1103
|
type: "dropForeignKey",
|
|
@@ -1103,6 +1150,8 @@ function diffIndexes(tableName, desiredIdxs, actualIdxs) {
|
|
|
1103
1150
|
summary.push(`Create index "${name}" on "${tableName}"`);
|
|
1104
1151
|
} else {
|
|
1105
1152
|
const actualIdx = actualMap.get(name);
|
|
1153
|
+
if (!actualIdx)
|
|
1154
|
+
continue;
|
|
1106
1155
|
if (idx.unique !== actualIdx.unique || JSON.stringify(idx.columns) !== JSON.stringify(actualIdx.columns)) {
|
|
1107
1156
|
operations.push({
|
|
1108
1157
|
type: "dropIndex",
|
package/src/index.js
CHANGED
|
@@ -220,22 +220,26 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
220
220
|
const pkLookup = /* @__PURE__ */ new Map();
|
|
221
221
|
for (const row2 of pkRows) {
|
|
222
222
|
const tableName = row2.table_name;
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
let pkSet = pkLookup.get(tableName);
|
|
224
|
+
if (!pkSet) {
|
|
225
|
+
pkSet = /* @__PURE__ */ new Set();
|
|
226
|
+
pkLookup.set(tableName, pkSet);
|
|
225
227
|
}
|
|
226
|
-
|
|
228
|
+
pkSet.add(row2.column_name);
|
|
227
229
|
}
|
|
228
230
|
const tableColumnsMap = /* @__PURE__ */ new Map();
|
|
229
231
|
for (const row2 of columnRows) {
|
|
230
232
|
const tableName = row2.table_name;
|
|
231
233
|
if (INTERNAL_TABLES.has(tableName))
|
|
232
234
|
continue;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
let columnList = tableColumnsMap.get(tableName);
|
|
236
|
+
if (!columnList) {
|
|
237
|
+
columnList = [];
|
|
238
|
+
tableColumnsMap.set(tableName, columnList);
|
|
235
239
|
}
|
|
236
240
|
const rawType = buildPgColumnType(row2);
|
|
237
241
|
const pkSet = pkLookup.get(tableName);
|
|
238
|
-
|
|
242
|
+
columnList.push({
|
|
239
243
|
name: row2.column_name,
|
|
240
244
|
type: normalizeColumnType(rawType, "postgresql"),
|
|
241
245
|
nullable: row2.is_nullable === "YES",
|
|
@@ -248,10 +252,12 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
248
252
|
const tableName = row2.table_name;
|
|
249
253
|
if (INTERNAL_TABLES.has(tableName))
|
|
250
254
|
continue;
|
|
251
|
-
|
|
252
|
-
|
|
255
|
+
let fkList = tableFkMap.get(tableName);
|
|
256
|
+
if (!fkList) {
|
|
257
|
+
fkList = [];
|
|
258
|
+
tableFkMap.set(tableName, fkList);
|
|
253
259
|
}
|
|
254
|
-
|
|
260
|
+
fkList.push({
|
|
255
261
|
constraintName: row2.constraint_name,
|
|
256
262
|
column: row2.column_name,
|
|
257
263
|
referencedTable: row2.foreign_table_name,
|
|
@@ -271,12 +277,14 @@ async function introspectPostgres(queryFn, schema = "public") {
|
|
|
271
277
|
continue;
|
|
272
278
|
if (row2.indexname.endsWith("_pkey"))
|
|
273
279
|
continue;
|
|
274
|
-
|
|
275
|
-
|
|
280
|
+
let indexList = tableIndexMap.get(tableName);
|
|
281
|
+
if (!indexList) {
|
|
282
|
+
indexList = [];
|
|
283
|
+
tableIndexMap.set(tableName, indexList);
|
|
276
284
|
}
|
|
277
285
|
const columns = extractIndexColumns(row2.indexdef);
|
|
278
286
|
const unique = row2.indexdef.toUpperCase().includes("UNIQUE");
|
|
279
|
-
|
|
287
|
+
indexList.push({
|
|
280
288
|
name: row2.indexname,
|
|
281
289
|
columns,
|
|
282
290
|
unique
|
|
@@ -455,6 +463,31 @@ function json(name, options = {}) {
|
|
|
455
463
|
}
|
|
456
464
|
|
|
457
465
|
// libs/core/src/lib/collections/media.collection.ts
|
|
466
|
+
var validateFocalPoint = (value) => {
|
|
467
|
+
if (value === null || value === void 0)
|
|
468
|
+
return true;
|
|
469
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
470
|
+
return "Focal point must be an object with x and y coordinates";
|
|
471
|
+
}
|
|
472
|
+
const fp = Object.fromEntries(Object.entries(value));
|
|
473
|
+
if (!("x" in fp) || !("y" in fp)) {
|
|
474
|
+
return "Focal point must have both x and y properties";
|
|
475
|
+
}
|
|
476
|
+
const { x, y } = fp;
|
|
477
|
+
if (typeof x !== "number" || !Number.isFinite(x)) {
|
|
478
|
+
return "Focal point x must be a finite number";
|
|
479
|
+
}
|
|
480
|
+
if (typeof y !== "number" || !Number.isFinite(y)) {
|
|
481
|
+
return "Focal point y must be a finite number";
|
|
482
|
+
}
|
|
483
|
+
if (x < 0 || x > 1) {
|
|
484
|
+
return `Focal point x must be between 0 and 1 (received ${x})`;
|
|
485
|
+
}
|
|
486
|
+
if (y < 0 || y > 1) {
|
|
487
|
+
return `Focal point y must be between 0 and 1 (received ${y})`;
|
|
488
|
+
}
|
|
489
|
+
return true;
|
|
490
|
+
};
|
|
458
491
|
var MediaCollection = defineCollection({
|
|
459
492
|
slug: "media",
|
|
460
493
|
labels: {
|
|
@@ -509,6 +542,14 @@ var MediaCollection = defineCollection({
|
|
|
509
542
|
json("focalPoint", {
|
|
510
543
|
label: "Focal Point",
|
|
511
544
|
description: "Focal point coordinates for image cropping",
|
|
545
|
+
validate: validateFocalPoint,
|
|
546
|
+
admin: {
|
|
547
|
+
hidden: true
|
|
548
|
+
}
|
|
549
|
+
}),
|
|
550
|
+
json("sizes", {
|
|
551
|
+
label: "Image Sizes",
|
|
552
|
+
description: "Generated image size variants",
|
|
512
553
|
admin: {
|
|
513
554
|
hidden: true
|
|
514
555
|
}
|
|
@@ -870,10 +911,14 @@ function diffColumns(tableName, desiredColumns, actualColumns, dialect, opts) {
|
|
|
870
911
|
const extraInActual = [...actualMap.keys()].filter((k) => !desiredMap.has(k));
|
|
871
912
|
for (const newName of missingInActual) {
|
|
872
913
|
const desiredCol = desiredMap.get(newName);
|
|
914
|
+
if (!desiredCol)
|
|
915
|
+
continue;
|
|
873
916
|
for (const oldName of extraInActual) {
|
|
874
917
|
if (renamedFrom.has(oldName))
|
|
875
918
|
continue;
|
|
876
919
|
const actualCol = actualMap.get(oldName);
|
|
920
|
+
if (!actualCol)
|
|
921
|
+
continue;
|
|
877
922
|
if (areTypesCompatible(desiredCol.type, actualCol.type, dialect)) {
|
|
878
923
|
operations.push({
|
|
879
924
|
type: "renameColumn",
|
|
@@ -986,6 +1031,8 @@ function diffForeignKeys(tableName, desiredFks, actualFks) {
|
|
|
986
1031
|
summary.push(`Add foreign key "${name}" on "${tableName}"`);
|
|
987
1032
|
} else {
|
|
988
1033
|
const actualFk = actualMap.get(name);
|
|
1034
|
+
if (!actualFk)
|
|
1035
|
+
continue;
|
|
989
1036
|
if (fk.column !== actualFk.column || fk.referencedTable !== actualFk.referencedTable || fk.referencedColumn !== actualFk.referencedColumn || fk.onDelete !== actualFk.onDelete) {
|
|
990
1037
|
operations.push({
|
|
991
1038
|
type: "dropForeignKey",
|
|
@@ -1038,6 +1085,8 @@ function diffIndexes(tableName, desiredIdxs, actualIdxs) {
|
|
|
1038
1085
|
summary.push(`Create index "${name}" on "${tableName}"`);
|
|
1039
1086
|
} else {
|
|
1040
1087
|
const actualIdx = actualMap.get(name);
|
|
1088
|
+
if (!actualIdx)
|
|
1089
|
+
continue;
|
|
1041
1090
|
if (idx.unique !== actualIdx.unique || JSON.stringify(idx.columns) !== JSON.stringify(actualIdx.columns)) {
|
|
1042
1091
|
operations.push({
|
|
1043
1092
|
type: "dropIndex",
|