@lark-apaas/devtool-kits 0.1.0-alpha.1 → 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 +24 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +381 -384
- 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);
|
|
@@ -28507,8 +28498,8 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
|
|
|
28507
28498
|
// src/middlewares/openapi/services.ts
|
|
28508
28499
|
async function enhanceOpenApiWithSourceInfo(options = {}) {
|
|
28509
28500
|
const startTime = Date.now();
|
|
28510
|
-
const openapiPath = options.openapiPath || import_node_path3.default.resolve(__dirname, "
|
|
28511
|
-
const serverDir = options.serverDir || import_node_path3.default.resolve(__dirname, "
|
|
28501
|
+
const openapiPath = options.openapiPath || import_node_path3.default.resolve(__dirname, "../client/src/api/gen/openapi.json");
|
|
28502
|
+
const serverDir = options.serverDir || import_node_path3.default.resolve(__dirname, "../server");
|
|
28512
28503
|
const writeFile = options.writeFile !== false;
|
|
28513
28504
|
let openapi;
|
|
28514
28505
|
if (options.openapiData) {
|
|
@@ -28621,7 +28612,7 @@ function extractControllerMetadata(sourceFile, filePath) {
|
|
|
28621
28612
|
__name(extractControllerMetadata, "extractControllerMetadata");
|
|
28622
28613
|
|
|
28623
28614
|
// src/middlewares/openapi/controller.ts
|
|
28624
|
-
function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
28615
|
+
function createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir) {
|
|
28625
28616
|
let cache = null;
|
|
28626
28617
|
return async (_req, res, context) => {
|
|
28627
28618
|
try {
|
|
@@ -28634,7 +28625,8 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28634
28625
|
if (enableEnhancement && context.isDev) {
|
|
28635
28626
|
const { openapi: enhancedPayload, stats } = await enhanceOpenApiWithSourceInfo({
|
|
28636
28627
|
openapiData: payload,
|
|
28637
|
-
writeFile: false
|
|
28628
|
+
writeFile: false,
|
|
28629
|
+
serverDir: serverDir || context.rootDir
|
|
28638
28630
|
});
|
|
28639
28631
|
payload = enhancedPayload;
|
|
28640
28632
|
console.log(`[OpenAPI] Enhanced in ${stats.duration}ms (${stats.endpointsEnhanced} endpoints)`);
|
|
@@ -28657,9 +28649,10 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28657
28649
|
__name(createOpenapiHandler, "createOpenapiHandler");
|
|
28658
28650
|
|
|
28659
28651
|
// src/middlewares/openapi/router.ts
|
|
28660
|
-
function createOpenapiRouter(
|
|
28652
|
+
function createOpenapiRouter(options, context) {
|
|
28653
|
+
const { openapiFilePath, enableEnhancement, serverDir } = options;
|
|
28661
28654
|
const router = import_express.default.Router();
|
|
28662
|
-
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement);
|
|
28655
|
+
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
|
|
28663
28656
|
router.get("/openapi.json", (req, res) => handler(req, res, context));
|
|
28664
28657
|
return router;
|
|
28665
28658
|
}
|
|
@@ -28674,14 +28667,18 @@ var OPENAPI_ROUTES = [
|
|
|
28674
28667
|
}
|
|
28675
28668
|
];
|
|
28676
28669
|
function createOpenapiMiddleware(options) {
|
|
28677
|
-
const { openapiFilePath, enableEnhancement = true } = options;
|
|
28670
|
+
const { openapiFilePath, enableEnhancement = true, serverDir } = options;
|
|
28678
28671
|
return {
|
|
28679
28672
|
name: "openapi",
|
|
28680
28673
|
mountPath: "/dev",
|
|
28681
28674
|
routes: OPENAPI_ROUTES,
|
|
28682
28675
|
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
28683
28676
|
createRouter: /* @__PURE__ */ __name((context) => {
|
|
28684
|
-
return createOpenapiRouter(
|
|
28677
|
+
return createOpenapiRouter({
|
|
28678
|
+
openapiFilePath,
|
|
28679
|
+
enableEnhancement,
|
|
28680
|
+
serverDir
|
|
28681
|
+
}, context);
|
|
28685
28682
|
}, "createRouter")
|
|
28686
28683
|
};
|
|
28687
28684
|
}
|