@lark-apaas/fullstack-nestjs-core 1.0.3-alpha.6 → 1.0.3-alpha.8
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 +33 -10
- package/dist/index.js +33 -10
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -369,8 +369,8 @@ var import_cookie_parser = __toESM(require("cookie-parser"), 1);
|
|
|
369
369
|
|
|
370
370
|
// src/modules/devtool/index.ts
|
|
371
371
|
var import_swagger = require("@nestjs/swagger");
|
|
372
|
-
var
|
|
373
|
-
var
|
|
372
|
+
var import_node_fs3 = require("fs");
|
|
373
|
+
var import_node_path3 = require("path");
|
|
374
374
|
|
|
375
375
|
// src/modules/devtool/helper.ts
|
|
376
376
|
var import_node_path = require("path");
|
|
@@ -409,6 +409,23 @@ function ensureDirAndWrite(filePath, content) {
|
|
|
409
409
|
}
|
|
410
410
|
__name(ensureDirAndWrite, "ensureDirAndWrite");
|
|
411
411
|
|
|
412
|
+
// src/modules/devtool/plugins/client-config-generator.ts
|
|
413
|
+
var import_node_fs2 = require("fs");
|
|
414
|
+
var import_node_path2 = require("path");
|
|
415
|
+
function generateClientConfig(options) {
|
|
416
|
+
const configFilePath = (0, import_node_path2.resolve)(options.outputPath, "client.config.ts");
|
|
417
|
+
const configContent = `// This file is auto-generated by @hey-api/openapi-ts
|
|
418
|
+
import axios from 'axios';
|
|
419
|
+
import type { CreateClientConfig } from './client/client.gen';
|
|
420
|
+
export const createClientConfig: CreateClientConfig = (config) => ({
|
|
421
|
+
axios
|
|
422
|
+
});
|
|
423
|
+
`;
|
|
424
|
+
(0, import_node_fs2.writeFileSync)(configFilePath, configContent, "utf-8");
|
|
425
|
+
return configFilePath;
|
|
426
|
+
}
|
|
427
|
+
__name(generateClientConfig, "generateClientConfig");
|
|
428
|
+
|
|
412
429
|
// src/modules/devtool/index.ts
|
|
413
430
|
var DevToolsModule = class {
|
|
414
431
|
static {
|
|
@@ -418,9 +435,7 @@ var DevToolsModule = class {
|
|
|
418
435
|
const options = resolveOptsWithDefaultValue(opts);
|
|
419
436
|
const baseDirname = process.cwd();
|
|
420
437
|
const builder = new import_swagger.DocumentBuilder().setTitle(options.swaggerOptions.title).setVersion(options.swaggerOptions.version);
|
|
421
|
-
const document = import_swagger.SwaggerModule.createDocument(app, builder.build()
|
|
422
|
-
operationIdFactory: /* @__PURE__ */ __name((_c, m) => m, "operationIdFactory")
|
|
423
|
-
});
|
|
438
|
+
const document = import_swagger.SwaggerModule.createDocument(app, builder.build());
|
|
424
439
|
if (options.needSetupServer) {
|
|
425
440
|
import_swagger.SwaggerModule.setup(options.docsPath, app, document, {
|
|
426
441
|
customSiteTitle: options.swaggerOptions.customSiteTitle,
|
|
@@ -431,21 +446,29 @@ var DevToolsModule = class {
|
|
|
431
446
|
});
|
|
432
447
|
console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
|
|
433
448
|
}
|
|
434
|
-
const openapiPath = (0,
|
|
449
|
+
const openapiPath = (0, import_node_path3.resolve)(baseDirname, options.openapiOut);
|
|
435
450
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
436
451
|
if (options.needGenerateClientSdk) {
|
|
437
|
-
const clientSdkOutPath = (0,
|
|
438
|
-
(0,
|
|
452
|
+
const clientSdkOutPath = (0, import_node_path3.resolve)(baseDirname, options.clientSdkOut);
|
|
453
|
+
(0, import_node_fs3.mkdirSync)(clientSdkOutPath, {
|
|
439
454
|
recursive: true
|
|
440
455
|
});
|
|
456
|
+
generateClientConfig({
|
|
457
|
+
outputPath: clientSdkOutPath
|
|
458
|
+
});
|
|
441
459
|
const { createClient } = await import("@hey-api/openapi-ts");
|
|
442
460
|
await createClient({
|
|
443
461
|
input: openapiPath,
|
|
444
|
-
output:
|
|
462
|
+
output: {
|
|
463
|
+
path: clientSdkOutPath
|
|
464
|
+
},
|
|
445
465
|
plugins: [
|
|
446
466
|
"@hey-api/typescript",
|
|
447
467
|
"@hey-api/sdk",
|
|
448
|
-
|
|
468
|
+
{
|
|
469
|
+
name: "@hey-api/client-axios",
|
|
470
|
+
runtimeConfigPath: (0, import_node_path3.join)(clientSdkOutPath, "./client.config.ts")
|
|
471
|
+
}
|
|
449
472
|
]
|
|
450
473
|
});
|
|
451
474
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
package/dist/index.js
CHANGED
|
@@ -322,14 +322,14 @@ PlatformModule = _ts_decorate5([
|
|
|
322
322
|
|
|
323
323
|
// src/setup.ts
|
|
324
324
|
import { AppLogger as AppLogger2 } from "@lark-apaas/nestjs-logger";
|
|
325
|
-
import { join } from "path";
|
|
325
|
+
import { join as join2 } from "path";
|
|
326
326
|
import { __express as hbsExpressEngine } from "hbs";
|
|
327
327
|
import cookieParser from "cookie-parser";
|
|
328
328
|
|
|
329
329
|
// src/modules/devtool/index.ts
|
|
330
330
|
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
|
|
331
331
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
332
|
-
import { resolve } from "path";
|
|
332
|
+
import { resolve as resolve2, join } from "path";
|
|
333
333
|
|
|
334
334
|
// src/modules/devtool/helper.ts
|
|
335
335
|
import { dirname } from "path";
|
|
@@ -368,6 +368,23 @@ function ensureDirAndWrite(filePath, content) {
|
|
|
368
368
|
}
|
|
369
369
|
__name(ensureDirAndWrite, "ensureDirAndWrite");
|
|
370
370
|
|
|
371
|
+
// src/modules/devtool/plugins/client-config-generator.ts
|
|
372
|
+
import { writeFileSync as writeFileSync2 } from "fs";
|
|
373
|
+
import { resolve } from "path";
|
|
374
|
+
function generateClientConfig(options) {
|
|
375
|
+
const configFilePath = resolve(options.outputPath, "client.config.ts");
|
|
376
|
+
const configContent = `// This file is auto-generated by @hey-api/openapi-ts
|
|
377
|
+
import axios from 'axios';
|
|
378
|
+
import type { CreateClientConfig } from './client/client.gen';
|
|
379
|
+
export const createClientConfig: CreateClientConfig = (config) => ({
|
|
380
|
+
axios
|
|
381
|
+
});
|
|
382
|
+
`;
|
|
383
|
+
writeFileSync2(configFilePath, configContent, "utf-8");
|
|
384
|
+
return configFilePath;
|
|
385
|
+
}
|
|
386
|
+
__name(generateClientConfig, "generateClientConfig");
|
|
387
|
+
|
|
371
388
|
// src/modules/devtool/index.ts
|
|
372
389
|
var DevToolsModule = class {
|
|
373
390
|
static {
|
|
@@ -377,9 +394,7 @@ var DevToolsModule = class {
|
|
|
377
394
|
const options = resolveOptsWithDefaultValue(opts);
|
|
378
395
|
const baseDirname = process.cwd();
|
|
379
396
|
const builder = new DocumentBuilder().setTitle(options.swaggerOptions.title).setVersion(options.swaggerOptions.version);
|
|
380
|
-
const document = SwaggerModule.createDocument(app, builder.build()
|
|
381
|
-
operationIdFactory: /* @__PURE__ */ __name((_c, m) => m, "operationIdFactory")
|
|
382
|
-
});
|
|
397
|
+
const document = SwaggerModule.createDocument(app, builder.build());
|
|
383
398
|
if (options.needSetupServer) {
|
|
384
399
|
SwaggerModule.setup(options.docsPath, app, document, {
|
|
385
400
|
customSiteTitle: options.swaggerOptions.customSiteTitle,
|
|
@@ -390,21 +405,29 @@ var DevToolsModule = class {
|
|
|
390
405
|
});
|
|
391
406
|
console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
|
|
392
407
|
}
|
|
393
|
-
const openapiPath =
|
|
408
|
+
const openapiPath = resolve2(baseDirname, options.openapiOut);
|
|
394
409
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
395
410
|
if (options.needGenerateClientSdk) {
|
|
396
|
-
const clientSdkOutPath =
|
|
411
|
+
const clientSdkOutPath = resolve2(baseDirname, options.clientSdkOut);
|
|
397
412
|
mkdirSync2(clientSdkOutPath, {
|
|
398
413
|
recursive: true
|
|
399
414
|
});
|
|
415
|
+
generateClientConfig({
|
|
416
|
+
outputPath: clientSdkOutPath
|
|
417
|
+
});
|
|
400
418
|
const { createClient } = await import("@hey-api/openapi-ts");
|
|
401
419
|
await createClient({
|
|
402
420
|
input: openapiPath,
|
|
403
|
-
output:
|
|
421
|
+
output: {
|
|
422
|
+
path: clientSdkOutPath
|
|
423
|
+
},
|
|
404
424
|
plugins: [
|
|
405
425
|
"@hey-api/typescript",
|
|
406
426
|
"@hey-api/sdk",
|
|
407
|
-
|
|
427
|
+
{
|
|
428
|
+
name: "@hey-api/client-axios",
|
|
429
|
+
runtimeConfigPath: join(clientSdkOutPath, "./client.config.ts")
|
|
430
|
+
}
|
|
408
431
|
]
|
|
409
432
|
});
|
|
410
433
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
@@ -420,7 +443,7 @@ async function configureApp(app, options) {
|
|
|
420
443
|
app.use(cookieParser());
|
|
421
444
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
422
445
|
app.setGlobalPrefix(globalPrefix);
|
|
423
|
-
app.setBaseViewsDir(
|
|
446
|
+
app.setBaseViewsDir(join2(process.cwd(), options?.viewsDir ?? "dist/client"));
|
|
424
447
|
app.setViewEngine("html");
|
|
425
448
|
app.engine("html", hbsExpressEngine);
|
|
426
449
|
if (process.env.NODE_ENV !== "production") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.0.3-alpha.
|
|
3
|
+
"version": "1.0.3-alpha.8",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,8 +45,7 @@
|
|
|
45
45
|
"@lark-apaas/nestjs-datapaas": "^1.0.1",
|
|
46
46
|
"@lark-apaas/nestjs-logger": "^1.0.0",
|
|
47
47
|
"cookie-parser": "^1.4.7",
|
|
48
|
-
"hbs": "^4.2.0"
|
|
49
|
-
"openapi-typescript-codegen": "^0.29.0"
|
|
48
|
+
"hbs": "^4.2.0"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@nestjs/common": "^10.4.20",
|