@farm.js/core 0.1.18 → 0.1.19
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/app-markdown.cjs +4 -4
- package/dist/app-markdown.mjs +3 -3
- package/dist/{chunk-EN7WTEAY.mjs → chunk-2ANEVVF7.mjs} +1 -1
- package/dist/{chunk-3XG26Z3J.mjs → chunk-2GNATDDE.mjs} +1 -1
- package/dist/{chunk-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
- package/dist/{chunk-J2OP5GG3.cjs → chunk-A777V5WU.cjs} +28 -28
- package/dist/{chunk-E2BMSZ2W.cjs → chunk-AH7HOAQ3.cjs} +2 -2
- package/dist/{chunk-TWGMSEHX.cjs → chunk-BBVSJVBZ.cjs} +88 -13
- package/dist/{chunk-AWRISO2H.cjs → chunk-E2ROOWQC.cjs} +30 -4
- package/dist/{chunk-KPNVGRBL.mjs → chunk-FVZGEVTO.mjs} +7 -7
- package/dist/{chunk-WZMNW2IW.cjs → chunk-GPVTX3HT.cjs} +2 -2
- package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
- package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
- package/dist/{chunk-BSTRERPP.cjs → chunk-I5YBCWQ6.cjs} +2 -2
- package/dist/{chunk-TYQUSXUG.cjs → chunk-ISTFC3MZ.cjs} +4 -4
- package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
- package/dist/{chunk-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
- package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
- package/dist/{chunk-GNEO2XOF.cjs → chunk-NBAHDVOJ.cjs} +4 -4
- package/dist/{chunk-UN5GHC5V.cjs → chunk-NSFC3LHB.cjs} +68 -68
- package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
- package/dist/{chunk-OIEOCXKG.cjs → chunk-OYDRPBBV.cjs} +2 -2
- package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
- package/dist/{chunk-UTBVHYS3.mjs → chunk-QBPKKQTD.mjs} +2 -2
- package/dist/{chunk-NWOD6NIT.cjs → chunk-RFYO7QUD.cjs} +1 -1
- package/dist/{chunk-B4CH33IG.cjs → chunk-S27FMYAM.cjs} +13 -13
- package/dist/{chunk-NV3A5DXM.cjs → chunk-U5BMPGS3.cjs} +10 -10
- package/dist/{chunk-QGVJVSNX.mjs → chunk-V4AICMQA.mjs} +2 -2
- package/dist/{chunk-GYKJCFTS.mjs → chunk-WZXN4R5Y.mjs} +24 -13
- package/dist/{chunk-IKNRN4VS.cjs → chunk-XDGMADQM.cjs} +100 -89
- package/dist/{devtools-OUIPHVV6.cjs → devtools-5KGPDVKL.cjs} +4 -4
- package/dist/{devtools-UFVTMQX5.mjs → devtools-FY5R7TQ4.mjs} +3 -3
- package/dist/docs.cjs +6 -6
- package/dist/docs.mjs +5 -5
- package/dist/index.cjs +15 -15
- package/dist/index.mjs +14 -14
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +14 -14
- package/dist/internal/build-runtime.mjs +13 -13
- package/dist/internal/cli-runtime.cjs +8 -8
- package/dist/internal/cli-runtime.mjs +7 -7
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/config-runtime.cjs +4 -4
- package/dist/internal/config-runtime.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +4 -4
- package/dist/internal/production-runtime.mjs +3 -3
- package/dist/markdown.cjs +2 -2
- package/dist/markdown.mjs +1 -1
- package/dist/plugin.cjs +10 -10
- package/dist/plugin.mjs +9 -9
- package/dist/{schema-dev-notice-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
- package/dist/{schema-dev-notice-MXSZMVDG.cjs → schema-dev-notice-Y7MQEFGN.cjs} +3 -3
- package/dist/server.cjs +25 -25
- package/dist/server.mjs +11 -11
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +10 -10
- package/dist/vite.mjs +9 -9
- package/package.json +1 -1
package/dist/app-markdown.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkI5YBCWQ6cjs = require('./chunk-I5YBCWQ6.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ var _chunkBSTRERPPcjs = require('./chunk-BSTRERPP.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkAH7HOAQ3cjs = require('./chunk-AH7HOAQ3.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkBBVSJVBZcjs = require('./chunk-BBVSJVBZ.cjs');
|
|
23
23
|
require('./chunk-S3JO3N4H.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
@@ -36,4 +36,4 @@ require('./chunk-S3JO3N4H.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
exports.FARM_MARKDOWN_CONTENT_TYPE =
|
|
39
|
+
exports.FARM_MARKDOWN_CONTENT_TYPE = _chunkBBVSJVBZcjs.FARM_MARKDOWN_CONTENT_TYPE; exports.createFarmMarkdownErrorBody = _chunkBBVSJVBZcjs.createFarmMarkdownErrorBody; exports.createFarmMarkdownRouteModule = _chunkAH7HOAQ3cjs.createFarmMarkdownRouteModule; exports.createFarmMarkdownRouteModuleFromFile = _chunkI5YBCWQ6cjs.createFarmMarkdownRouteModuleFromFile; exports.createFarmMarkdownSourceResponse = _chunkAH7HOAQ3cjs.createFarmMarkdownSourceResponse; exports.createMarkdownMetadata = _chunkAH7HOAQ3cjs.createMarkdownMetadata; exports.farmRequestWantsMarkdown = _chunkBBVSJVBZcjs.farmRequestWantsMarkdown; exports.isFarmMarkdownPageFile = _chunkAH7HOAQ3cjs.isFarmMarkdownPageFile; exports.loadFarmMdxComponents = _chunkI5YBCWQ6cjs.loadFarmMdxComponents; exports.normalizeFarmMarkdownRoutePath = _chunkAH7HOAQ3cjs.normalizeFarmMarkdownRoutePath; exports.parseMarkdownFrontmatter = _chunkAH7HOAQ3cjs.parseMarkdownFrontmatter; exports.resolveFarmMdxComponentsModulePath = _chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath; exports.resolveMdxConfig = _chunkOHY2ZWUGcjs.resolveMdxConfig; exports.titleFromMarkdown = _chunkAH7HOAQ3cjs.titleFromMarkdown;
|
package/dist/app-markdown.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createFarmMarkdownRouteModuleFromFile,
|
|
3
3
|
loadFarmMdxComponents
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MVUREHPN.mjs";
|
|
5
5
|
import {
|
|
6
6
|
createFarmMarkdownRouteModule,
|
|
7
7
|
createFarmMarkdownSourceResponse,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
normalizeFarmMarkdownRoutePath,
|
|
11
11
|
parseMarkdownFrontmatter,
|
|
12
12
|
titleFromMarkdown
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-N255VYFP.mjs";
|
|
14
14
|
import {
|
|
15
15
|
resolveFarmMdxComponentsModulePath,
|
|
16
16
|
resolveMdxConfig
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
FARM_MARKDOWN_CONTENT_TYPE,
|
|
20
20
|
createFarmMarkdownErrorBody,
|
|
21
21
|
farmRequestWantsMarkdown
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-OFEY6KHO.mjs";
|
|
23
23
|
import "./chunk-LPEX4YW6.mjs";
|
|
24
24
|
export {
|
|
25
25
|
FARM_MARKDOWN_CONTENT_TYPE,
|
|
@@ -21,7 +21,7 @@ var _chunkD2ULAULScjs = require('./chunk-D2ULAULS.cjs');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkE2ROOWQCcjs = require('./chunk-E2ROOWQC.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
var _chunkJSROZYYOcjs = require('./chunk-JSROZYYO.cjs');
|
|
@@ -41,7 +41,7 @@ function collectSchemaDependencies(owners) {
|
|
|
41
41
|
for (const owner of owners) {
|
|
42
42
|
try {
|
|
43
43
|
known.set(owner.name, _chunkJSROZYYOcjs.resolveSchemaModels.call(void 0, owner.name, owner.schema));
|
|
44
|
-
for (const model of
|
|
44
|
+
for (const model of _chunkE2ROOWQCcjs.collectSchemaModels.call(void 0, [[owner.name, owner.schema, owner.models]])) {
|
|
45
45
|
creators.set(model.modelName.toLowerCase(), owner.name);
|
|
46
46
|
claimedKeys.set(model.modelKey, owner.name);
|
|
47
47
|
}
|
|
@@ -65,12 +65,12 @@ function collectSchemaDependencies(owners) {
|
|
|
65
65
|
if (creator && creator !== owner.name) needs.add(creator);
|
|
66
66
|
}, "add");
|
|
67
67
|
try {
|
|
68
|
-
for (const model of
|
|
68
|
+
for (const model of _chunkE2ROOWQCcjs.collectSchemaModels.call(void 0, [[owner.name, owner.schema, owner.models]])) {
|
|
69
69
|
for (const field of Object.values(model.model.fields)) {
|
|
70
70
|
if (field.reference) add(referencedTable(owner.name, field.reference.model));
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
for (const extension of
|
|
73
|
+
for (const extension of _chunkE2ROOWQCcjs.collectSchemaExtensions.call(void 0, owner.name, owner.schema, owner.models)) {
|
|
74
74
|
add(extension.table);
|
|
75
75
|
}
|
|
76
76
|
} catch (e2) {
|
|
@@ -129,7 +129,7 @@ function collectSchemaOwners(config) {
|
|
|
129
129
|
resolveClient: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (resolved) => _nullishCoalesce(integrationClient, () => ( (integrationClient = _chunkD2ULAULScjs.resolveIntegrationOrmRuntimeClient.call(void 0, { config: resolved })))), "resolveClient")
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
for (const declaration of
|
|
132
|
+
for (const declaration of _chunkE2ROOWQCcjs.findSchemaTableOwners.call(void 0, config)) {
|
|
133
133
|
if (owners.some((owner) => owner.name === declaration.name)) continue;
|
|
134
134
|
owners.push({
|
|
135
135
|
name: declaration.name,
|
|
@@ -159,7 +159,7 @@ function resolveSchemaExecutor(client, owner, timeoutMs) {
|
|
|
159
159
|
if (candidate === void 0 || candidate === null) continue;
|
|
160
160
|
let adapter;
|
|
161
161
|
try {
|
|
162
|
-
adapter =
|
|
162
|
+
adapter = _chunkE2ROOWQCcjs.createSchemaExecutor.call(void 0, candidate, owner);
|
|
163
163
|
} catch (e3) {
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
@@ -179,7 +179,7 @@ function resolveSchemaExecutor(client, owner, timeoutMs) {
|
|
|
179
179
|
return void 0;
|
|
180
180
|
}
|
|
181
181
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveSchemaExecutor, "resolveSchemaExecutor");
|
|
182
|
-
var describeReferencedTable = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (database, table) =>
|
|
182
|
+
var describeReferencedTable = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (database, table) => _chunkE2ROOWQCcjs.describeSchemaTable.call(void 0, database.executor, database.dialect, table), "describeReferencedTable");
|
|
183
183
|
async function checkSchema(config, options = {}) {
|
|
184
184
|
const timeoutMs = _nullishCoalesce(options.timeoutMs, () => ( DEFAULT_TIMEOUT_MS));
|
|
185
185
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
@@ -191,7 +191,7 @@ async function checkSchema(config, options = {}) {
|
|
|
191
191
|
const issues = [];
|
|
192
192
|
const declared = /* @__PURE__ */ new Map();
|
|
193
193
|
for (const candidate of _nullishCoalesce(config.plugins, () => ( []))) {
|
|
194
|
-
const declaration =
|
|
194
|
+
const declaration = _chunkE2ROOWQCcjs.readSchemaTables.call(void 0, candidate);
|
|
195
195
|
if (!declaration) continue;
|
|
196
196
|
const schemas = _nullishCoalesce(declared.get(declaration.name), () => ( []));
|
|
197
197
|
if (!schemas.includes(declaration.schema)) schemas.push(declaration.schema);
|
|
@@ -213,7 +213,7 @@ async function checkSchema(config, options = {}) {
|
|
|
213
213
|
for (const owner of owners) {
|
|
214
214
|
try {
|
|
215
215
|
knownModels.set(owner.name, _chunkJSROZYYOcjs.resolveSchemaModels.call(void 0, owner.name, owner.schema));
|
|
216
|
-
ownedModels.set(owner.name,
|
|
216
|
+
ownedModels.set(owner.name, _chunkE2ROOWQCcjs.collectSchemaModels.call(void 0, [[owner.name, owner.schema, owner.models]]));
|
|
217
217
|
} catch (error) {
|
|
218
218
|
issues.push({
|
|
219
219
|
severity: "error",
|
|
@@ -329,7 +329,7 @@ async function checkSchema(config, options = {}) {
|
|
|
329
329
|
for (const owner of owners) {
|
|
330
330
|
if (!ownedModels.has(owner.name)) continue;
|
|
331
331
|
try {
|
|
332
|
-
const owned =
|
|
332
|
+
const owned = _chunkE2ROOWQCcjs.collectSchemaExtensions.call(void 0, owner.name, owner.schema, owner.models);
|
|
333
333
|
extensions.set(owner.name, owned);
|
|
334
334
|
for (const extension of owned) {
|
|
335
335
|
for (const { field } of extension.fields) {
|
|
@@ -369,9 +369,9 @@ async function checkSchema(config, options = {}) {
|
|
|
369
369
|
const database = databases.get(owner.name);
|
|
370
370
|
if (!models || !database) continue;
|
|
371
371
|
try {
|
|
372
|
-
const crossOwner = await
|
|
372
|
+
const crossOwner = await _chunkE2ROOWQCcjs.planCrossOwnerReferences.call(void 0,
|
|
373
373
|
owner,
|
|
374
|
-
|
|
374
|
+
_chunkE2ROOWQCcjs.findSchemaTableOwners.call(void 0, config),
|
|
375
375
|
database.dialect,
|
|
376
376
|
database.executor
|
|
377
377
|
);
|
|
@@ -384,7 +384,7 @@ async function checkSchema(config, options = {}) {
|
|
|
384
384
|
onDelete: reference.onDelete
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
|
-
const stepPlan = _optionalChain([owner, 'access', _30 => _30.migrations, 'optionalAccess', _31 => _31.length]) ? await
|
|
387
|
+
const stepPlan = _optionalChain([owner, 'access', _30 => _30.migrations, 'optionalAccess', _31 => _31.length]) ? await _chunkE2ROOWQCcjs.planOwnerSchemaSteps.call(void 0, {
|
|
388
388
|
owner: owner.name,
|
|
389
389
|
schema: owner.schema,
|
|
390
390
|
steps: owner.migrations,
|
|
@@ -399,15 +399,15 @@ async function checkSchema(config, options = {}) {
|
|
|
399
399
|
const plan = await checkOwnerTables(
|
|
400
400
|
owner,
|
|
401
401
|
// What a pending rename will produce is not missing yet.
|
|
402
|
-
|
|
402
|
+
_chunkE2ROOWQCcjs.withoutRenameTargets.call(void 0, models, stepPlan),
|
|
403
403
|
database.dialect,
|
|
404
404
|
database.executor,
|
|
405
405
|
issues
|
|
406
406
|
);
|
|
407
407
|
const pending = plan.statements.length + (_nullishCoalesce(_optionalChain([plan, 'access', _32 => _32.upgrades, 'optionalAccess', _33 => _33.length]), () => ( 0)));
|
|
408
|
-
const state = pending > 0 ? await
|
|
409
|
-
const changes = state ?
|
|
410
|
-
if (state && changes &&
|
|
408
|
+
const state = pending > 0 ? await _chunkE2ROOWQCcjs.readSchemaState.call(void 0, database.executor, database.dialect, owner.name) : void 0;
|
|
409
|
+
const changes = state ? _chunkE2ROOWQCcjs.diffSchemaSnapshots.call(void 0, state.snapshot, _chunkE2ROOWQCcjs.createSchemaSnapshot.call(void 0, models)) : void 0;
|
|
410
|
+
if (state && changes && _chunkE2ROOWQCcjs.hasSchemaChanges.call(void 0, changes)) {
|
|
411
411
|
const versions = state.version && owner.version && state.version !== owner.version ? `upgraded ${state.version} \u2192 ${owner.version}` : "changed since it was last migrated";
|
|
412
412
|
issues.push({
|
|
413
413
|
severity: "warning",
|
|
@@ -444,7 +444,7 @@ async function checkSchema(config, options = {}) {
|
|
|
444
444
|
}
|
|
445
445
|
_chunkS3JO3N4Hcjs.__name.call(void 0, checkSchema, "checkSchema");
|
|
446
446
|
async function checkOwnerTables(owner, models, dialect, executor, issues) {
|
|
447
|
-
const plan = await
|
|
447
|
+
const plan = await _chunkE2ROOWQCcjs.planSchemaMigration.call(void 0, models, dialect, executor);
|
|
448
448
|
const present = /* @__PURE__ */ new Set([
|
|
449
449
|
...plan.upToDate,
|
|
450
450
|
...plan.drift.map((drift) => drift.table),
|
|
@@ -525,7 +525,7 @@ async function checkOwnerTables(owner, models, dialect, executor, issues) {
|
|
|
525
525
|
table: key.table,
|
|
526
526
|
column: key.column,
|
|
527
527
|
message: `"${key.table}.${key.column}" has no foreign key to "${key.referencedTable}.${key.referencedColumn}", which ${owner.name} could have.`,
|
|
528
|
-
hint: dialect === "sqlite" ? "SQLite can only add a foreign key when it creates the table." : `Allow it with \`${
|
|
528
|
+
hint: dialect === "sqlite" ? "SQLite can only add a foreign key when it creates the table." : `Allow it with \`${_chunkE2ROOWQCcjs.describeForeignKeyApproval.call(void 0, { owner: owner.name, modelKey: key.modelKey })}\` in farm.config, then run \`farm ${owner.name} migrate --apply\`. Rows that point at nothing are checked first.`
|
|
529
529
|
});
|
|
530
530
|
}
|
|
531
531
|
return plan;
|
|
@@ -609,9 +609,9 @@ async function checkReferences(owner, models, database, databases, resolveTarget
|
|
|
609
609
|
continue;
|
|
610
610
|
}
|
|
611
611
|
if (database.dialect === "sqlite" || dialect === "sqlite") continue;
|
|
612
|
-
const expected =
|
|
613
|
-
const mine =
|
|
614
|
-
const theirs =
|
|
612
|
+
const expected = _chunkE2ROOWQCcjs.getSqlColumnType.call(void 0, field, database.dialect);
|
|
613
|
+
const mine = _chunkE2ROOWQCcjs.columnTypeFamily.call(void 0, expected);
|
|
614
|
+
const theirs = _chunkE2ROOWQCcjs.columnTypeFamily.call(void 0, column.type);
|
|
615
615
|
if (mine && theirs && mine !== theirs) {
|
|
616
616
|
issues.push({
|
|
617
617
|
severity: "warning",
|
|
@@ -630,7 +630,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, checkReferences, "checkReferences");
|
|
|
630
630
|
async function checkExtensions(owner, extensions, databaseForTable, ownDatabase, allowExtend, issues) {
|
|
631
631
|
for (const extension of extensions) {
|
|
632
632
|
const database = _nullishCoalesce(databaseForTable(extension.table), () => ( ownDatabase));
|
|
633
|
-
const table = await
|
|
633
|
+
const table = await _chunkE2ROOWQCcjs.describeSchemaTable.call(void 0, database.executor, database.dialect, extension.table);
|
|
634
634
|
const columns = extension.fields.map(({ field }) => field.name);
|
|
635
635
|
if (!table) {
|
|
636
636
|
issues.push({
|
|
@@ -643,7 +643,7 @@ async function checkExtensions(owner, extensions, databaseForTable, ownDatabase,
|
|
|
643
643
|
});
|
|
644
644
|
continue;
|
|
645
645
|
}
|
|
646
|
-
const allowed =
|
|
646
|
+
const allowed = _chunkE2ROOWQCcjs.isSchemaExtensionAllowed.call(void 0, allowExtend, extension);
|
|
647
647
|
for (const { field } of extension.fields) {
|
|
648
648
|
const existing = table.columns.find(
|
|
649
649
|
(column) => database.dialect === "postgres" ? column.name === field.name : column.name.toLowerCase() === field.name.toLowerCase()
|
|
@@ -657,14 +657,14 @@ async function checkExtensions(owner, extensions, databaseForTable, ownDatabase,
|
|
|
657
657
|
table: extension.table,
|
|
658
658
|
column: field.name,
|
|
659
659
|
message: `${owner.name} needs "${extension.table}.${field.name}", which does not exist.`,
|
|
660
|
-
hint: allowed ? `Add it with ${command}. If your ORM owns "${extension.table}", add the column to its schema instead.` : `Allow it in farm.config with \`${
|
|
660
|
+
hint: allowed ? `Add it with ${command}. If your ORM owns "${extension.table}", add the column to its schema instead.` : `Allow it in farm.config with \`${_chunkE2ROOWQCcjs.describeSchemaExtensionApproval.call(void 0, extension)}\`, then add it with ${command}. If your ORM owns "${extension.table}", add the column to its schema instead.`
|
|
661
661
|
});
|
|
662
662
|
continue;
|
|
663
663
|
}
|
|
664
664
|
if (database.dialect === "sqlite") continue;
|
|
665
|
-
const expected =
|
|
666
|
-
const mine =
|
|
667
|
-
const theirs =
|
|
665
|
+
const expected = _chunkE2ROOWQCcjs.getSqlColumnType.call(void 0, field, database.dialect);
|
|
666
|
+
const mine = _chunkE2ROOWQCcjs.columnTypeFamily.call(void 0, expected);
|
|
667
|
+
const theirs = _chunkE2ROOWQCcjs.columnTypeFamily.call(void 0, existing.type);
|
|
668
668
|
if (mine && theirs && mine !== theirs) {
|
|
669
669
|
issues.push({
|
|
670
670
|
severity: "warning",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkBBVSJVBZcjs = require('./chunk-BBVSJVBZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -115,7 +115,7 @@ async function createFarmMarkdownSourceResponse(options) {
|
|
|
115
115
|
}
|
|
116
116
|
const url = new URL(options.request.url);
|
|
117
117
|
const hasMarkdownExtension = url.pathname.toLowerCase().endsWith(".md");
|
|
118
|
-
if (!hasMarkdownExtension && !
|
|
118
|
+
if (!hasMarkdownExtension && !_chunkBBVSJVBZcjs.requestAcceptsMarkdown.call(void 0, options.request.headers.get("accept"))) {
|
|
119
119
|
return null;
|
|
120
120
|
}
|
|
121
121
|
const targetPathname = normalizeFarmMarkdownRoutePath(url.pathname);
|
|
@@ -145,9 +145,13 @@ var BLOCK_TAGS = /<\/?(ul|ol|main|section|article|header|footer|nav|aside|div|fo
|
|
|
145
145
|
var BOX_TAGS = /<\/?(label|button|input|select|textarea|option|output|meter|progress|td|th)\b[^>]*>/gi;
|
|
146
146
|
function htmlToMarkdown(html, options = {}) {
|
|
147
147
|
const title = _nullishCoalesce(options.title, () => ( extractHtmlTitle(html)));
|
|
148
|
+
const streamed = readStreamedBoundaryInstructions(html);
|
|
148
149
|
let source = extractHtmlBody(
|
|
149
150
|
removeHiddenElements(
|
|
150
|
-
|
|
151
|
+
resolveStreamedBoundaries(
|
|
152
|
+
html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ""),
|
|
153
|
+
streamed
|
|
154
|
+
).replace(/<!--[\s\S]*?-->/g, "")
|
|
151
155
|
)
|
|
152
156
|
);
|
|
153
157
|
const codeBlocks = [];
|
|
@@ -422,6 +426,7 @@ var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
|
422
426
|
]);
|
|
423
427
|
function removeHiddenElements(html) {
|
|
424
428
|
const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
429
|
+
let closingTags;
|
|
425
430
|
let result = "";
|
|
426
431
|
let cursor = 0;
|
|
427
432
|
let match;
|
|
@@ -431,7 +436,8 @@ function removeHiddenElements(html) {
|
|
|
431
436
|
const start = match.index;
|
|
432
437
|
let end = start + tag.length;
|
|
433
438
|
if (!VOID_TAGS.has(name.toLowerCase()) && !isSelfClosingTag(tag)) {
|
|
434
|
-
|
|
439
|
+
_nullishCoalesce(closingTags, () => ( (closingTags = matchClosingTags(html))));
|
|
440
|
+
const close = closingTags.get(start);
|
|
435
441
|
if (close === void 0) continue;
|
|
436
442
|
end = close;
|
|
437
443
|
}
|
|
@@ -458,24 +464,93 @@ function isSelfClosingTag(tag) {
|
|
|
458
464
|
return /(?:^<[a-zA-Z][\w:-]*|[\s"'])\/>$/.test(tag);
|
|
459
465
|
}
|
|
460
466
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isSelfClosingTag, "isSelfClosingTag");
|
|
461
|
-
function
|
|
467
|
+
function matchClosingTags(html) {
|
|
462
468
|
const tags = /<(\/?)([a-zA-Z][\w:-]*)(?:[^>"']|"[^"]*"|'[^']*')*>/g;
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
let depth = 1;
|
|
469
|
+
const open = /* @__PURE__ */ new Map();
|
|
470
|
+
const closes = /* @__PURE__ */ new Map();
|
|
466
471
|
let match;
|
|
467
472
|
while (match = tags.exec(html)) {
|
|
468
|
-
|
|
473
|
+
const name = match[2].toLowerCase();
|
|
469
474
|
if (match[1]) {
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
} else if (!isSelfClosingTag(match[0])) {
|
|
473
|
-
|
|
475
|
+
const start = _optionalChain([open, 'access', _19 => _19.get, 'call', _20 => _20(name), 'optionalAccess', _21 => _21.pop, 'call', _22 => _22()]);
|
|
476
|
+
if (start !== void 0) closes.set(start, match.index + match[0].length);
|
|
477
|
+
} else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
|
|
478
|
+
let starts = open.get(name);
|
|
479
|
+
if (!starts) open.set(name, starts = []);
|
|
480
|
+
starts.push(match.index);
|
|
474
481
|
}
|
|
475
482
|
}
|
|
476
|
-
return
|
|
483
|
+
return closes;
|
|
484
|
+
}
|
|
485
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, matchClosingTags, "matchClosingTags");
|
|
486
|
+
function readStreamedBoundaryInstructions(html) {
|
|
487
|
+
const boundaries = /* @__PURE__ */ new Map();
|
|
488
|
+
const placeholders = /* @__PURE__ */ new Map();
|
|
489
|
+
for (const [, script] of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)) {
|
|
490
|
+
for (const [, kind, first, second] of script.matchAll(
|
|
491
|
+
/\$R([CRS])\("([^"\\]+)","([^"\\]+)"/g
|
|
492
|
+
)) {
|
|
493
|
+
if (kind === "S") placeholders.set(second, first);
|
|
494
|
+
else boundaries.set(first, second);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return { boundaries, placeholders };
|
|
498
|
+
}
|
|
499
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readStreamedBoundaryInstructions, "readStreamedBoundaryInstructions");
|
|
500
|
+
function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
|
|
501
|
+
if (boundaries.size === 0 && placeholders.size === 0) return html;
|
|
502
|
+
const wanted = /* @__PURE__ */ new Set([...boundaries.values(), ...placeholders.values()]);
|
|
503
|
+
const segments = /* @__PURE__ */ new Map();
|
|
504
|
+
const closingTags = matchClosingTags(html);
|
|
505
|
+
const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
506
|
+
let page = "";
|
|
507
|
+
let cursor = 0;
|
|
508
|
+
let match;
|
|
509
|
+
while (match = openingTag.exec(html)) {
|
|
510
|
+
const id = _optionalChain([/\sid="([^"]*)"/, 'access', _23 => _23.exec, 'call', _24 => _24(match[2]), 'optionalAccess', _25 => _25[1]]);
|
|
511
|
+
if (!id || !wanted.has(id) || segments.has(id)) continue;
|
|
512
|
+
const close = closingTags.get(match.index);
|
|
513
|
+
if (close === void 0) continue;
|
|
514
|
+
const contentStart = match.index + match[0].length;
|
|
515
|
+
segments.set(id, html.slice(contentStart, html.lastIndexOf("<", close - 1)));
|
|
516
|
+
page += html.slice(cursor, match.index);
|
|
517
|
+
cursor = close;
|
|
518
|
+
openingTag.lastIndex = close;
|
|
519
|
+
}
|
|
520
|
+
page += html.slice(cursor);
|
|
521
|
+
const used = /* @__PURE__ */ new Set();
|
|
522
|
+
const expand = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (fragment) => {
|
|
523
|
+
const template = /<template\b[^>]*\sid="([^"]+)"[^>]*>\s*<\/template>/gi;
|
|
524
|
+
let output = "";
|
|
525
|
+
let position = 0;
|
|
526
|
+
let found;
|
|
527
|
+
while (found = template.exec(fragment)) {
|
|
528
|
+
const id = found[1];
|
|
529
|
+
const segmentId = _nullishCoalesce(boundaries.get(id), () => ( placeholders.get(id)));
|
|
530
|
+
const segment = segmentId === void 0 ? void 0 : segments.get(segmentId);
|
|
531
|
+
if (segment === void 0 || used.has(segmentId)) continue;
|
|
532
|
+
used.add(segmentId);
|
|
533
|
+
output += fragment.slice(position, found.index) + expand(segment);
|
|
534
|
+
position = found.index + found[0].length;
|
|
535
|
+
if (boundaries.has(id)) {
|
|
536
|
+
const marker = /<!--(\/?)(?:\$[?!~]?|&)-->/g;
|
|
537
|
+
marker.lastIndex = position;
|
|
538
|
+
let depth = 0;
|
|
539
|
+
let end;
|
|
540
|
+
while (end = marker.exec(fragment)) {
|
|
541
|
+
if (!end[1]) depth += 1;
|
|
542
|
+
else if (depth === 0) break;
|
|
543
|
+
else depth -= 1;
|
|
544
|
+
}
|
|
545
|
+
if (end) position = end.index;
|
|
546
|
+
}
|
|
547
|
+
template.lastIndex = position;
|
|
548
|
+
}
|
|
549
|
+
return output + fragment.slice(position);
|
|
550
|
+
}, "expand");
|
|
551
|
+
return expand(page);
|
|
477
552
|
}
|
|
478
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
553
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveStreamedBoundaries, "resolveStreamedBoundaries");
|
|
479
554
|
function stripTags(input) {
|
|
480
555
|
return input.replace(/<[^>]+>/g, "");
|
|
481
556
|
}
|
|
@@ -7,6 +7,28 @@ var _chunkJSROZYYOcjs = require('./chunk-JSROZYYO.cjs');
|
|
|
7
7
|
|
|
8
8
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
9
9
|
|
|
10
|
+
// src/schema-sql-identifiers.ts
|
|
11
|
+
var POSTGRES_IDENTIFIER_BYTES = 63;
|
|
12
|
+
function fitSqlIndexName(dialect, name) {
|
|
13
|
+
if (dialect !== "postgres") return name;
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
const bytes = encoder.encode(name);
|
|
16
|
+
if (bytes.length <= POSTGRES_IDENTIFIER_BYTES) return name;
|
|
17
|
+
let hash = 2166136261;
|
|
18
|
+
for (const byte of bytes) hash = Math.imul(hash ^ byte, 16777619);
|
|
19
|
+
const suffix = `_${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
20
|
+
let prefix = "";
|
|
21
|
+
let length = 0;
|
|
22
|
+
for (const character of name) {
|
|
23
|
+
const size = encoder.encode(character).length;
|
|
24
|
+
if (length + size > POSTGRES_IDENTIFIER_BYTES - suffix.length) break;
|
|
25
|
+
prefix += character;
|
|
26
|
+
length += size;
|
|
27
|
+
}
|
|
28
|
+
return prefix + suffix;
|
|
29
|
+
}
|
|
30
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, fitSqlIndexName, "fitSqlIndexName");
|
|
31
|
+
|
|
10
32
|
// src/schema-sql.ts
|
|
11
33
|
function describeSchemaReference(model, fieldKey) {
|
|
12
34
|
const field = model.model.fields[fieldKey];
|
|
@@ -155,14 +177,17 @@ function collectSchemaIndexes(model, dialect) {
|
|
|
155
177
|
continue;
|
|
156
178
|
}
|
|
157
179
|
definitions.push({
|
|
158
|
-
name: `${model.modelName}_${field.name}_idx
|
|
180
|
+
name: fitSqlIndexName(dialect, `${model.modelName}_${field.name}_idx`),
|
|
159
181
|
columns: [quoteSqlIdentifier(dialect, field.name)],
|
|
160
182
|
unique: false
|
|
161
183
|
});
|
|
162
184
|
}
|
|
163
185
|
for (const constraint of model.model.constraints || []) {
|
|
164
186
|
definitions.push({
|
|
165
|
-
name:
|
|
187
|
+
name: fitSqlIndexName(
|
|
188
|
+
dialect,
|
|
189
|
+
constraint.name || `${model.modelName}_${constraint.fields.map((fieldKey) => _optionalChain([model, 'access', _12 => _12.model, 'access', _13 => _13.fields, 'access', _14 => _14[fieldKey], 'optionalAccess', _15 => _15.name]) || fieldKey).join("_")}_${constraint.type}`
|
|
190
|
+
),
|
|
166
191
|
columns: constraint.fields.map(
|
|
167
192
|
(fieldKey) => quoteSqlIdentifier(dialect, _optionalChain([model, 'access', _16 => _16.model, 'access', _17 => _17.fields, 'access', _18 => _18[fieldKey], 'optionalAccess', _19 => _19.name]) || fieldKey)
|
|
168
193
|
),
|
|
@@ -473,11 +498,12 @@ async function planSchemaMigration(models, dialect, executor) {
|
|
|
473
498
|
continue;
|
|
474
499
|
}
|
|
475
500
|
const columns = index.columns.map((column) => quoteSqlIdentifier(dialect, column)).join(", ");
|
|
501
|
+
const name = fitSqlIndexName(dialect, index.name);
|
|
476
502
|
upgrades.push({
|
|
477
503
|
kind: "index",
|
|
478
504
|
table: model.modelName,
|
|
479
|
-
target:
|
|
480
|
-
sql: `CREATE INDEX${dialect === "mysql" ? "" : " IF NOT EXISTS"} ${quoteSqlIdentifier(dialect,
|
|
505
|
+
target: name,
|
|
506
|
+
sql: `CREATE INDEX${dialect === "mysql" ? "" : " IF NOT EXISTS"} ${quoteSqlIdentifier(dialect, name)} ON ${quoteTableName(dialect, model.modelName)} (${columns});`
|
|
481
507
|
});
|
|
482
508
|
}
|
|
483
509
|
const entry = {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
compileFarmDocsAdapterEdgeManifest,
|
|
9
9
|
createFarmDocsAPIHandler
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QBPKKQTD.mjs";
|
|
11
11
|
import {
|
|
12
12
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
13
13
|
createFarmDocsHandler,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
loadFarmDocsPage,
|
|
18
18
|
resolveFarmDocsContentDir,
|
|
19
19
|
toFarmDocsMarkdownPage
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HSDL2AUR.mjs";
|
|
21
21
|
import {
|
|
22
22
|
generateFarmDocsSearchClientRuntime,
|
|
23
23
|
isFarmDocsSearchEnabled,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
getDeployTargetForPreset,
|
|
32
32
|
hasCustomFarmRouteContext,
|
|
33
33
|
resolveDeployOutputPath
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-V4AICMQA.mjs";
|
|
35
35
|
import {
|
|
36
36
|
resolveFarmInstrumentationFile
|
|
37
37
|
} from "./chunk-F5D4XEAS.mjs";
|
|
@@ -64,13 +64,13 @@ import {
|
|
|
64
64
|
resolveFarmClientCacheAdapterEntry,
|
|
65
65
|
resolveFarmIsolatedClientHydrationMode,
|
|
66
66
|
resolveFarmNotFoundComponentPath
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-WZXN4R5Y.mjs";
|
|
68
68
|
import {
|
|
69
69
|
findRequestBoundSourceBlockers,
|
|
70
70
|
generateFarmTypeArtifacts,
|
|
71
71
|
parseRouteRenderingDirective,
|
|
72
72
|
resolveRouteRenderingConfigFromFile
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-2ANEVVF7.mjs";
|
|
74
74
|
import {
|
|
75
75
|
isFarmPreviewDeploymentEnvironment
|
|
76
76
|
} from "./chunk-BOYNDCZL.mjs";
|
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
} from "./chunk-OLYK7EAK.mjs";
|
|
98
98
|
import {
|
|
99
99
|
applyFarmCspHashesToHtml
|
|
100
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-7BC6GAL7.mjs";
|
|
101
101
|
import {
|
|
102
102
|
applyFarmCronVercelCrons,
|
|
103
103
|
createFarmCronCloudflareConfig,
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
} from "./chunk-4OOBRCJX.mjs";
|
|
110
110
|
import {
|
|
111
111
|
isFarmMarkdownPageFile
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-N255VYFP.mjs";
|
|
113
113
|
import {
|
|
114
114
|
resolveFarmMdxComponentsModulePath,
|
|
115
115
|
resolveMdxConfig
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkE2ROOWQCcjs = require('./chunk-E2ROOWQC.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkJSROZYYOcjs = require('./chunk-JSROZYYO.cjs');
|
|
@@ -1079,7 +1079,7 @@ function createSyncModelTypeDeclarations(plugins) {
|
|
|
1079
1079
|
const rowEntries = [];
|
|
1080
1080
|
const insertEntries = [];
|
|
1081
1081
|
for (const plugin of _nullishCoalesce(plugins, () => ( []))) {
|
|
1082
|
-
const declaration =
|
|
1082
|
+
const declaration = _chunkE2ROOWQCcjs.readSchemaTables.call(void 0, plugin);
|
|
1083
1083
|
if (!declaration || declaration.name !== "sync") continue;
|
|
1084
1084
|
const exposed = declaration.models ? new Set(declaration.models) : null;
|
|
1085
1085
|
const models = _chunkJSROZYYOcjs.resolveSchemaModels.call(void 0, declaration.name, declaration.schema);
|
|
@@ -7,6 +7,28 @@ import {
|
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-LPEX4YW6.mjs";
|
|
9
9
|
|
|
10
|
+
// src/schema-sql-identifiers.ts
|
|
11
|
+
var POSTGRES_IDENTIFIER_BYTES = 63;
|
|
12
|
+
function fitSqlIndexName(dialect, name) {
|
|
13
|
+
if (dialect !== "postgres") return name;
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
const bytes = encoder.encode(name);
|
|
16
|
+
if (bytes.length <= POSTGRES_IDENTIFIER_BYTES) return name;
|
|
17
|
+
let hash = 2166136261;
|
|
18
|
+
for (const byte of bytes) hash = Math.imul(hash ^ byte, 16777619);
|
|
19
|
+
const suffix = `_${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
20
|
+
let prefix = "";
|
|
21
|
+
let length = 0;
|
|
22
|
+
for (const character of name) {
|
|
23
|
+
const size = encoder.encode(character).length;
|
|
24
|
+
if (length + size > POSTGRES_IDENTIFIER_BYTES - suffix.length) break;
|
|
25
|
+
prefix += character;
|
|
26
|
+
length += size;
|
|
27
|
+
}
|
|
28
|
+
return prefix + suffix;
|
|
29
|
+
}
|
|
30
|
+
__name(fitSqlIndexName, "fitSqlIndexName");
|
|
31
|
+
|
|
10
32
|
// src/schema-sql.ts
|
|
11
33
|
function describeSchemaReference(model, fieldKey) {
|
|
12
34
|
const field = model.model.fields[fieldKey];
|
|
@@ -155,14 +177,17 @@ function collectSchemaIndexes(model, dialect) {
|
|
|
155
177
|
continue;
|
|
156
178
|
}
|
|
157
179
|
definitions.push({
|
|
158
|
-
name: `${model.modelName}_${field.name}_idx
|
|
180
|
+
name: fitSqlIndexName(dialect, `${model.modelName}_${field.name}_idx`),
|
|
159
181
|
columns: [quoteSqlIdentifier(dialect, field.name)],
|
|
160
182
|
unique: false
|
|
161
183
|
});
|
|
162
184
|
}
|
|
163
185
|
for (const constraint of model.model.constraints || []) {
|
|
164
186
|
definitions.push({
|
|
165
|
-
name:
|
|
187
|
+
name: fitSqlIndexName(
|
|
188
|
+
dialect,
|
|
189
|
+
constraint.name || `${model.modelName}_${constraint.fields.map((fieldKey) => model.model.fields[fieldKey]?.name || fieldKey).join("_")}_${constraint.type}`
|
|
190
|
+
),
|
|
166
191
|
columns: constraint.fields.map(
|
|
167
192
|
(fieldKey) => quoteSqlIdentifier(dialect, model.model.fields[fieldKey]?.name || fieldKey)
|
|
168
193
|
),
|
|
@@ -473,11 +498,12 @@ async function planSchemaMigration(models, dialect, executor) {
|
|
|
473
498
|
continue;
|
|
474
499
|
}
|
|
475
500
|
const columns = index.columns.map((column) => quoteSqlIdentifier(dialect, column)).join(", ");
|
|
501
|
+
const name = fitSqlIndexName(dialect, index.name);
|
|
476
502
|
upgrades.push({
|
|
477
503
|
kind: "index",
|
|
478
504
|
table: model.modelName,
|
|
479
|
-
target:
|
|
480
|
-
sql: `CREATE INDEX${dialect === "mysql" ? "" : " IF NOT EXISTS"} ${quoteSqlIdentifier(dialect,
|
|
505
|
+
target: name,
|
|
506
|
+
sql: `CREATE INDEX${dialect === "mysql" ? "" : " IF NOT EXISTS"} ${quoteSqlIdentifier(dialect, name)} ON ${quoteTableName(dialect, model.modelName)} (${columns});`
|
|
481
507
|
});
|
|
482
508
|
}
|
|
483
509
|
const entry = {
|