drizzle-kit 0.20.17-b4f119e → 0.20.17-c347d7b
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/@types/utils.d.ts +1 -0
- package/bin.cjs +21468 -21192
- package/cli/commands/utils.d.ts +123 -1
- package/cli/connections.d.ts +7 -2
- package/cli/validations/cli.d.ts +50 -50
- package/cli/validations/common.d.ts +10 -10
- package/cli/validations/outputs.d.ts +1 -0
- package/cli/validations/studio.d.ts +92 -0
- package/cli/views.d.ts +7 -0
- package/index.d.mts +5 -3
- package/index.d.ts +5 -3
- package/package.json +2 -2
- package/payload.js +103 -38
- package/payload.mjs +99 -34
- package/serializer/studio.d.ts +3 -1
- package/utils-studio.js +7 -2
- package/utils-studio.mjs +7 -2
package/payload.mjs
CHANGED
|
@@ -5906,8 +5906,8 @@ var init_serializer = __esm({
|
|
|
5906
5906
|
"src/serializer/index.ts"() {
|
|
5907
5907
|
"use strict";
|
|
5908
5908
|
init_views();
|
|
5909
|
-
sqlToStr = (
|
|
5910
|
-
return
|
|
5909
|
+
sqlToStr = (sql) => {
|
|
5910
|
+
return sql.toQuery({
|
|
5911
5911
|
escapeName: () => {
|
|
5912
5912
|
throw new Error("we don't support params for `sql` default values");
|
|
5913
5913
|
},
|
|
@@ -5933,7 +5933,8 @@ var init_outputs = __esm({
|
|
|
5933
5933
|
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
|
5934
5934
|
errorWarning: (str) => `${source_default.red(`${source_default.white.bgRed(" Warning ")} ${str}`)}`,
|
|
5935
5935
|
fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`,
|
|
5936
|
-
suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}
|
|
5936
|
+
suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`,
|
|
5937
|
+
info: (str) => `${source_default.grey(str)}`
|
|
5937
5938
|
};
|
|
5938
5939
|
}
|
|
5939
5940
|
});
|
|
@@ -6138,7 +6139,7 @@ var init_cli = __esm({
|
|
|
6138
6139
|
dialect: dialect3,
|
|
6139
6140
|
schema: unionType([stringType(), stringType().array()]).optional(),
|
|
6140
6141
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
|
6141
|
-
|
|
6142
|
+
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
|
6142
6143
|
driver: stringType().optional(),
|
|
6143
6144
|
// pg
|
|
6144
6145
|
connectionString: stringType().optional(),
|
|
@@ -6177,7 +6178,7 @@ var init_cli = __esm({
|
|
|
6177
6178
|
authToken: stringType().optional(),
|
|
6178
6179
|
introspectCasing: casing,
|
|
6179
6180
|
breakpoints: booleanType().optional().default(true)
|
|
6180
|
-
});
|
|
6181
|
+
}).passthrough();
|
|
6181
6182
|
configCheck = objectType({
|
|
6182
6183
|
dialect: dialect3.optional(),
|
|
6183
6184
|
out: stringType().optional()
|
|
@@ -6191,6 +6192,33 @@ var init_cli = __esm({
|
|
|
6191
6192
|
}
|
|
6192
6193
|
});
|
|
6193
6194
|
|
|
6195
|
+
// src/cli/validations/studio.ts
|
|
6196
|
+
var credentials, studioCliParams, studioConfig;
|
|
6197
|
+
var init_studio = __esm({
|
|
6198
|
+
"src/cli/validations/studio.ts"() {
|
|
6199
|
+
"use strict";
|
|
6200
|
+
init_lib();
|
|
6201
|
+
init_mysql();
|
|
6202
|
+
init_sqlite();
|
|
6203
|
+
init_schemaValidator();
|
|
6204
|
+
init_pg();
|
|
6205
|
+
credentials = intersectionType(
|
|
6206
|
+
postgresCredentials,
|
|
6207
|
+
mysqlCredentials,
|
|
6208
|
+
sqliteCredentials
|
|
6209
|
+
);
|
|
6210
|
+
studioCliParams = objectType({
|
|
6211
|
+
port: coerce.number().optional().default(4983),
|
|
6212
|
+
host: stringType().optional().default("127.0.0.1"),
|
|
6213
|
+
config: stringType().optional()
|
|
6214
|
+
});
|
|
6215
|
+
studioConfig = objectType({
|
|
6216
|
+
dialect: dialect3,
|
|
6217
|
+
schema: unionType([stringType(), stringType().array()])
|
|
6218
|
+
});
|
|
6219
|
+
}
|
|
6220
|
+
});
|
|
6221
|
+
|
|
6194
6222
|
// src/cli/commands/_es5.ts
|
|
6195
6223
|
var es5_exports = {};
|
|
6196
6224
|
__export(es5_exports, {
|
|
@@ -9220,13 +9248,13 @@ var require_node2 = __commonJS({
|
|
|
9220
9248
|
}
|
|
9221
9249
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9222
9250
|
try {
|
|
9223
|
-
var
|
|
9224
|
-
var value =
|
|
9251
|
+
var info2 = gen[key](arg);
|
|
9252
|
+
var value = info2.value;
|
|
9225
9253
|
} catch (error2) {
|
|
9226
9254
|
reject(error2);
|
|
9227
9255
|
return;
|
|
9228
9256
|
}
|
|
9229
|
-
if (
|
|
9257
|
+
if (info2.done) {
|
|
9230
9258
|
resolve(value);
|
|
9231
9259
|
} else {
|
|
9232
9260
|
Promise.resolve(value).then(_next, _throw);
|
|
@@ -11811,7 +11839,7 @@ var require_node2 = __commonJS({
|
|
|
11811
11839
|
});
|
|
11812
11840
|
|
|
11813
11841
|
// src/cli/commands/utils.ts
|
|
11814
|
-
var import_hanji2, assertES5, safeRegister;
|
|
11842
|
+
var import_hanji2, assertES5, safeRegister, migrateCliParams, migrateConfig;
|
|
11815
11843
|
var init_utils2 = __esm({
|
|
11816
11844
|
"src/cli/commands/utils.ts"() {
|
|
11817
11845
|
"use strict";
|
|
@@ -11823,8 +11851,11 @@ var init_utils2 = __esm({
|
|
|
11823
11851
|
init_pg();
|
|
11824
11852
|
init_sqlite();
|
|
11825
11853
|
init_common();
|
|
11854
|
+
init_schemaValidator();
|
|
11826
11855
|
init_cli();
|
|
11827
11856
|
init_outputs();
|
|
11857
|
+
init_studio();
|
|
11858
|
+
init_lib();
|
|
11828
11859
|
assertES5 = async (unregister) => {
|
|
11829
11860
|
try {
|
|
11830
11861
|
init_es5();
|
|
@@ -11866,6 +11897,17 @@ var init_utils2 = __esm({
|
|
|
11866
11897
|
await assertES5(res.unregister);
|
|
11867
11898
|
return res;
|
|
11868
11899
|
};
|
|
11900
|
+
migrateCliParams = objectType({
|
|
11901
|
+
config: stringType().optional()
|
|
11902
|
+
});
|
|
11903
|
+
migrateConfig = objectType({
|
|
11904
|
+
dialect: dialect3,
|
|
11905
|
+
out: stringType().optional().default("drizzle"),
|
|
11906
|
+
migrations: objectType({
|
|
11907
|
+
table: stringType().optional(),
|
|
11908
|
+
schema: stringType().optional()
|
|
11909
|
+
}).optional()
|
|
11910
|
+
});
|
|
11869
11911
|
}
|
|
11870
11912
|
});
|
|
11871
11913
|
|
|
@@ -15722,7 +15764,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15722
15764
|
const jsonTableAlternations = alteredTables.map((it) => {
|
|
15723
15765
|
return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
|
|
15724
15766
|
}).flat();
|
|
15725
|
-
const
|
|
15767
|
+
const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
|
|
15726
15768
|
return prepareCreateIndexesJson(
|
|
15727
15769
|
it.name,
|
|
15728
15770
|
it.schema,
|
|
@@ -15751,14 +15793,21 @@ var init_snapshotsDiffer = __esm({
|
|
|
15751
15793
|
},
|
|
15752
15794
|
{}
|
|
15753
15795
|
);
|
|
15754
|
-
|
|
15796
|
+
jsonCreateIndexesFoAlteredTables.push(
|
|
15755
15797
|
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
|
15756
15798
|
);
|
|
15757
15799
|
jsonDropIndexesForAllAlteredTables.push(
|
|
15758
15800
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15759
15801
|
);
|
|
15760
15802
|
});
|
|
15761
|
-
const
|
|
15803
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15804
|
+
return prepareCreateReferencesJson(
|
|
15805
|
+
it.name,
|
|
15806
|
+
it.schema,
|
|
15807
|
+
it.foreignKeys
|
|
15808
|
+
);
|
|
15809
|
+
}).flat();
|
|
15810
|
+
const jsonReferencesForAlteredTables = alteredTables.map((it) => {
|
|
15762
15811
|
const forAdded = prepareCreateReferencesJson(
|
|
15763
15812
|
it.name,
|
|
15764
15813
|
it.schema,
|
|
@@ -15776,10 +15825,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15776
15825
|
);
|
|
15777
15826
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
15778
15827
|
}).flat();
|
|
15779
|
-
const jsonCreatedReferencesForAlteredTables =
|
|
15828
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15780
15829
|
(t) => t.type === "create_reference"
|
|
15781
15830
|
);
|
|
15782
|
-
const jsonDroppedReferencesForAlteredTables =
|
|
15831
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15783
15832
|
(t) => t.type === "delete_reference"
|
|
15784
15833
|
);
|
|
15785
15834
|
const createEnums = createdEnums.map((it) => {
|
|
@@ -15806,7 +15855,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15806
15855
|
const dropSchemas = prepareDeleteSchemasJson(
|
|
15807
15856
|
deletedSchemas.map((it) => it.name)
|
|
15808
15857
|
);
|
|
15809
|
-
const
|
|
15858
|
+
const createTables = createdTables.map((it) => {
|
|
15810
15859
|
return preparePgCreateTableJson(it, curFull);
|
|
15811
15860
|
});
|
|
15812
15861
|
jsonStatements.push(...createSchemas);
|
|
@@ -15815,7 +15864,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15815
15864
|
jsonStatements.push(...moveEnums);
|
|
15816
15865
|
jsonStatements.push(...renameEnums);
|
|
15817
15866
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
15818
|
-
jsonStatements.push(...
|
|
15867
|
+
jsonStatements.push(...createTables);
|
|
15819
15868
|
jsonStatements.push(...jsonDropTables);
|
|
15820
15869
|
jsonStatements.push(...jsonSetTableSchemas);
|
|
15821
15870
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -15826,9 +15875,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15826
15875
|
jsonStatements.push(...jsonTableAlternations);
|
|
15827
15876
|
jsonStatements.push(...jsonAddedCompositePKs);
|
|
15828
15877
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15878
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15829
15879
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15830
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15831
15880
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15881
|
+
jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
|
|
15832
15882
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15833
15883
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15834
15884
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
|
@@ -16087,6 +16137,13 @@ var init_snapshotsDiffer = __esm({
|
|
|
16087
16137
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
16088
16138
|
);
|
|
16089
16139
|
});
|
|
16140
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
16141
|
+
return prepareCreateReferencesJson(
|
|
16142
|
+
it.name,
|
|
16143
|
+
it.schema,
|
|
16144
|
+
it.foreignKeys
|
|
16145
|
+
);
|
|
16146
|
+
}).flat();
|
|
16090
16147
|
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
16091
16148
|
const forAdded = prepareCreateReferencesJson(
|
|
16092
16149
|
it.name,
|
|
@@ -16127,9 +16184,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
16127
16184
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
16128
16185
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
16129
16186
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
16187
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
16130
16188
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
16131
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
16132
16189
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
16190
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
16133
16191
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
16134
16192
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
16135
16193
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
@@ -17554,12 +17612,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17554
17612
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
|
|
17555
17613
|
const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
|
|
17556
17614
|
const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
|
|
17557
|
-
let
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
return
|
|
17615
|
+
let sql = "DO $$ BEGIN\n";
|
|
17616
|
+
sql += " " + alterStatement + ";\n";
|
|
17617
|
+
sql += "EXCEPTION\n";
|
|
17618
|
+
sql += " WHEN duplicate_object THEN null;\n";
|
|
17619
|
+
sql += "END $$;\n";
|
|
17620
|
+
return sql;
|
|
17563
17621
|
}
|
|
17564
17622
|
};
|
|
17565
17623
|
SqliteCreateForeignKeyConvertor = class extends Convertor {
|
|
@@ -17605,7 +17663,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17605
17663
|
const newFk = PgSquasher.unsquashFK(statement.data);
|
|
17606
17664
|
const oldFk = PgSquasher.unsquashFK(statement.oldFkey);
|
|
17607
17665
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
|
|
17608
|
-
let
|
|
17666
|
+
let sql = `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${oldFk.name}";
|
|
17609
17667
|
`;
|
|
17610
17668
|
const onDeleteStatement = newFk.onDelete ? ` ON DELETE ${newFk.onDelete}` : "";
|
|
17611
17669
|
const onUpdateStatement = newFk.onUpdate ? ` ON UPDATE ${newFk.onUpdate}` : "";
|
|
@@ -17614,12 +17672,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17614
17672
|
const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
|
|
17615
17673
|
const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
|
|
17616
17674
|
const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
return
|
|
17675
|
+
sql += "DO $$ BEGIN\n";
|
|
17676
|
+
sql += " " + alterStatement + ";\n";
|
|
17677
|
+
sql += "EXCEPTION\n";
|
|
17678
|
+
sql += " WHEN duplicate_object THEN null;\n";
|
|
17679
|
+
sql += "END $$;\n";
|
|
17680
|
+
return sql;
|
|
17623
17681
|
}
|
|
17624
17682
|
};
|
|
17625
17683
|
SqliteAlterForeignKeyConvertor = class extends Convertor {
|
|
@@ -17993,7 +18051,9 @@ function mapSqlToSqliteType(sqlType) {
|
|
|
17993
18051
|
return "text";
|
|
17994
18052
|
} else if (lowered.startsWith("blob")) {
|
|
17995
18053
|
return "blob";
|
|
17996
|
-
} else if (["real", "double", "double precision", "float"].some(
|
|
18054
|
+
} else if (["real", "double", "double precision", "float"].some(
|
|
18055
|
+
(it) => lowered.startsWith(it)
|
|
18056
|
+
)) {
|
|
17997
18057
|
return "real";
|
|
17998
18058
|
} else {
|
|
17999
18059
|
return "numeric";
|
|
@@ -18178,7 +18238,7 @@ The unique constraint ${source_default.underline.blue(
|
|
|
18178
18238
|
`SELECT
|
|
18179
18239
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
18180
18240
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
18181
|
-
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table';
|
|
18241
|
+
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
|
|
18182
18242
|
`
|
|
18183
18243
|
);
|
|
18184
18244
|
const tablesWithSeq = [];
|
|
@@ -19677,6 +19737,9 @@ String.prototype.squashSpaces = function() {
|
|
|
19677
19737
|
String.prototype.camelCase = function() {
|
|
19678
19738
|
return camelCase(String(this));
|
|
19679
19739
|
};
|
|
19740
|
+
String.prototype.capitalise = function() {
|
|
19741
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
19742
|
+
};
|
|
19680
19743
|
String.prototype.concatIf = function(it, condition) {
|
|
19681
19744
|
return condition ? `${this}${it}` : String(this);
|
|
19682
19745
|
};
|
|
@@ -19987,7 +20050,6 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
|
19987
20050
|
init_mysqlSerializer();
|
|
19988
20051
|
init_global();
|
|
19989
20052
|
init_migrate();
|
|
19990
|
-
import { sql } from "drizzle-orm";
|
|
19991
20053
|
var generateDrizzleJson = (imports, prevId) => {
|
|
19992
20054
|
const prepared = prepareFromExports(imports);
|
|
19993
20055
|
const id = randomUUID();
|
|
@@ -20022,6 +20084,7 @@ var generateMigration = async (prev, cur) => {
|
|
|
20022
20084
|
};
|
|
20023
20085
|
var pushSchema = async (imports, drizzleInstance) => {
|
|
20024
20086
|
const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
|
20087
|
+
const { sql } = await import("drizzle-orm");
|
|
20025
20088
|
const db = {
|
|
20026
20089
|
query: async (query, params) => {
|
|
20027
20090
|
const res = await drizzleInstance.execute(sql.raw(query));
|
|
@@ -20083,6 +20146,7 @@ var generateSQLiteMigration = async (prev, cur) => {
|
|
|
20083
20146
|
};
|
|
20084
20147
|
var pushSQLiteSchema = async (imports, drizzleInstance) => {
|
|
20085
20148
|
const { applySqliteSnapshotsDiff: applySqliteSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
|
20149
|
+
const { sql } = await import("drizzle-orm");
|
|
20086
20150
|
const db = {
|
|
20087
20151
|
query: async (query, params) => {
|
|
20088
20152
|
const res = drizzleInstance.all(sql.raw(query));
|
|
@@ -20156,6 +20220,7 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
|
|
|
20156
20220
|
const { applyMysqlSnapshotsDiff: applyMysqlSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
|
20157
20221
|
const { logSuggestionsAndReturn: logSuggestionsAndReturn3 } = await Promise.resolve().then(() => (init_mysqlPushUtils(), mysqlPushUtils_exports));
|
|
20158
20222
|
const { mysqlPushIntrospect: mysqlPushIntrospect2 } = await Promise.resolve().then(() => (init_mysqlIntrospect(), mysqlIntrospect_exports));
|
|
20223
|
+
const { sql } = await import("drizzle-orm");
|
|
20159
20224
|
const db = {
|
|
20160
20225
|
query: async (query, params) => {
|
|
20161
20226
|
const res = await drizzleInstance.execute(sql.raw(query));
|
package/serializer/studio.d.ts
CHANGED
|
@@ -14,12 +14,14 @@ type CustomDefault = {
|
|
|
14
14
|
};
|
|
15
15
|
export type Setup = {
|
|
16
16
|
dialect: "postgresql" | "mysql" | "sqlite";
|
|
17
|
+
driver?: "aws-data-api";
|
|
17
18
|
proxy: (params: ProxyParams) => Promise<any[] | any>;
|
|
18
19
|
customDefaults: CustomDefault[];
|
|
19
20
|
};
|
|
20
21
|
export type ProxyParams = {
|
|
21
22
|
sql: string;
|
|
22
23
|
params: any[];
|
|
24
|
+
typings?: any[];
|
|
23
25
|
mode: "array" | "object";
|
|
24
26
|
method: "values" | "get" | "all" | "run" | "execute";
|
|
25
27
|
};
|
|
@@ -47,5 +49,5 @@ export type Server = {
|
|
|
47
49
|
cb: (err: Error | null, address: string) => void;
|
|
48
50
|
}) => void;
|
|
49
51
|
};
|
|
50
|
-
export declare const prepareServer: ({ dialect, proxy, customDefaults }: Setup, app?: Hono) => Promise<Server>;
|
|
52
|
+
export declare const prepareServer: ({ dialect, driver, proxy, customDefaults }: Setup, app?: Hono) => Promise<Server>;
|
|
51
53
|
export {};
|
package/utils-studio.js
CHANGED
|
@@ -4927,7 +4927,9 @@ function mapSqlToSqliteType(sqlType) {
|
|
|
4927
4927
|
return "text";
|
|
4928
4928
|
} else if (lowered.startsWith("blob")) {
|
|
4929
4929
|
return "blob";
|
|
4930
|
-
} else if (["real", "double", "double precision", "float"].some(
|
|
4930
|
+
} else if (["real", "double", "double precision", "float"].some(
|
|
4931
|
+
(it) => lowered.startsWith(it)
|
|
4932
|
+
)) {
|
|
4931
4933
|
return "real";
|
|
4932
4934
|
} else {
|
|
4933
4935
|
return "numeric";
|
|
@@ -4948,7 +4950,7 @@ var init_sqliteSerializer = __esm({
|
|
|
4948
4950
|
`SELECT
|
|
4949
4951
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
4950
4952
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
4951
|
-
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table';
|
|
4953
|
+
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
|
|
4952
4954
|
`
|
|
4953
4955
|
);
|
|
4954
4956
|
const tablesWithSeq = [];
|
|
@@ -6039,6 +6041,9 @@ String.prototype.squashSpaces = function() {
|
|
|
6039
6041
|
String.prototype.camelCase = function() {
|
|
6040
6042
|
return camelCase(String(this));
|
|
6041
6043
|
};
|
|
6044
|
+
String.prototype.capitalise = function() {
|
|
6045
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
6046
|
+
};
|
|
6042
6047
|
String.prototype.concatIf = function(it, condition) {
|
|
6043
6048
|
return condition ? `${this}${it}` : String(this);
|
|
6044
6049
|
};
|
package/utils-studio.mjs
CHANGED
|
@@ -4934,7 +4934,9 @@ function mapSqlToSqliteType(sqlType) {
|
|
|
4934
4934
|
return "text";
|
|
4935
4935
|
} else if (lowered.startsWith("blob")) {
|
|
4936
4936
|
return "blob";
|
|
4937
|
-
} else if (["real", "double", "double precision", "float"].some(
|
|
4937
|
+
} else if (["real", "double", "double precision", "float"].some(
|
|
4938
|
+
(it) => lowered.startsWith(it)
|
|
4939
|
+
)) {
|
|
4938
4940
|
return "real";
|
|
4939
4941
|
} else {
|
|
4940
4942
|
return "numeric";
|
|
@@ -4953,7 +4955,7 @@ var init_sqliteSerializer = __esm({
|
|
|
4953
4955
|
`SELECT
|
|
4954
4956
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
4955
4957
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
4956
|
-
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table';
|
|
4958
|
+
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
|
|
4957
4959
|
`
|
|
4958
4960
|
);
|
|
4959
4961
|
const tablesWithSeq = [];
|
|
@@ -6075,6 +6077,9 @@ String.prototype.squashSpaces = function() {
|
|
|
6075
6077
|
String.prototype.camelCase = function() {
|
|
6076
6078
|
return camelCase(String(this));
|
|
6077
6079
|
};
|
|
6080
|
+
String.prototype.capitalise = function() {
|
|
6081
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
6082
|
+
};
|
|
6078
6083
|
String.prototype.concatIf = function(it, condition) {
|
|
6079
6084
|
return condition ? `${this}${it}` : String(this);
|
|
6080
6085
|
};
|