@lark-apaas/devtool-kits 0.1.0-alpha.2 → 0.1.0-alpha.3
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/index.cjs +10 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +367 -376
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28111,9 +28111,8 @@ __name(normalizeBasePath, "normalizeBasePath");
|
|
|
28111
28111
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
28112
28112
|
var import_node_path = __toESM(require("path"), 1);
|
|
28113
28113
|
var import_pinyin_pro = require("pinyin-pro");
|
|
28114
|
-
var USER_PROFILE_MARKER = "// TODO: failed to parse database type 'user_profile'";
|
|
28115
|
-
var FILE_ATTACHMENT_MARKER = "// TODO: failed to parse database type 'file_attachment'";
|
|
28116
28114
|
var HEADER_COMMENT = "/** auto generated, do not edit */";
|
|
28115
|
+
var CUSTOM_TYPE_PATTERN = /\/\/ TODO: failed to parse database type '(?:\w+\.)?(user_profile|file_attachment)(\[\])?'/;
|
|
28117
28116
|
function postprocessDrizzleSchema(targetPath) {
|
|
28118
28117
|
const resolvedPath = import_node_path.default.resolve(targetPath);
|
|
28119
28118
|
if (!import_node_fs.default.existsSync(resolvedPath)) {
|
|
@@ -28144,6 +28143,9 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
28144
28143
|
console.warn("[postprocess-drizzle-schema] Unmatched custom types:", replacement.unmatched.length);
|
|
28145
28144
|
replacement.unmatched.forEach((line) => console.warn(` ${line}`));
|
|
28146
28145
|
}
|
|
28146
|
+
if (tableConversion.converted > 0) {
|
|
28147
|
+
console.info(`[postprocess-drizzle-schema] Converted ${tableConversion.converted} schema.table invocations to pgTable`);
|
|
28148
|
+
}
|
|
28147
28149
|
return {
|
|
28148
28150
|
replacedUnknown: replacement.replaced,
|
|
28149
28151
|
unmatchedUnknown: replacement.unmatched
|
|
@@ -28258,25 +28260,18 @@ function replaceUnknownColumns(source) {
|
|
|
28258
28260
|
const unmatched = [];
|
|
28259
28261
|
for (let i = 0; i < lines.length; i += 1) {
|
|
28260
28262
|
const line = lines[i];
|
|
28261
|
-
|
|
28262
|
-
|
|
28263
|
-
|
|
28264
|
-
|
|
28265
|
-
|
|
28266
|
-
i += 1;
|
|
28267
|
-
} else {
|
|
28268
|
-
unmatched.push(line.trim());
|
|
28269
|
-
}
|
|
28270
|
-
continue;
|
|
28271
|
-
}
|
|
28272
|
-
if (line.includes(FILE_ATTACHMENT_MARKER)) {
|
|
28273
|
-
const replacedLine = replaceFollowingUnknown(lines[i + 1], "fileAttachment");
|
|
28263
|
+
const match = line.match(CUSTOM_TYPE_PATTERN);
|
|
28264
|
+
if (match) {
|
|
28265
|
+
const typeName = match[1];
|
|
28266
|
+
const factory = typeName === "user_profile" ? "userProfile" : "fileAttachment";
|
|
28267
|
+
const replacedLine = replaceFollowingUnknown(lines[i + 1], factory);
|
|
28274
28268
|
if (replacedLine) {
|
|
28275
28269
|
result.push(replacedLine);
|
|
28276
28270
|
replaced += 1;
|
|
28277
28271
|
i += 1;
|
|
28278
28272
|
} else {
|
|
28279
28273
|
unmatched.push(line.trim());
|
|
28274
|
+
result.push(line);
|
|
28280
28275
|
}
|
|
28281
28276
|
continue;
|
|
28282
28277
|
}
|
|
@@ -28404,10 +28399,6 @@ function collapseExtraBlankLines(text) {
|
|
|
28404
28399
|
return text.replace(/\n{3,}/g, "\n\n");
|
|
28405
28400
|
}
|
|
28406
28401
|
__name(collapseExtraBlankLines, "collapseExtraBlankLines");
|
|
28407
|
-
if (require.main === module) {
|
|
28408
|
-
const target = process.argv[2] ?? "server/database/schema.ts";
|
|
28409
|
-
postprocessDrizzleSchema(target);
|
|
28410
|
-
}
|
|
28411
28402
|
|
|
28412
28403
|
// src/middlewares/index.ts
|
|
28413
28404
|
var import_node_path6 = __toESM(require("path"), 1);
|