@lark-apaas/fullstack-nestjs-core 1.0.3-alpha.7 → 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 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 import_node_fs2 = require("fs");
373
- var import_node_path2 = require("path");
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 {
@@ -429,13 +446,16 @@ var DevToolsModule = class {
429
446
  });
430
447
  console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
431
448
  }
432
- const openapiPath = (0, import_node_path2.resolve)(baseDirname, options.openapiOut);
449
+ const openapiPath = (0, import_node_path3.resolve)(baseDirname, options.openapiOut);
433
450
  ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
434
451
  if (options.needGenerateClientSdk) {
435
- const clientSdkOutPath = (0, import_node_path2.resolve)(baseDirname, options.clientSdkOut);
436
- (0, import_node_fs2.mkdirSync)(clientSdkOutPath, {
452
+ const clientSdkOutPath = (0, import_node_path3.resolve)(baseDirname, options.clientSdkOut);
453
+ (0, import_node_fs3.mkdirSync)(clientSdkOutPath, {
437
454
  recursive: true
438
455
  });
456
+ generateClientConfig({
457
+ outputPath: clientSdkOutPath
458
+ });
439
459
  const { createClient } = await import("@hey-api/openapi-ts");
440
460
  await createClient({
441
461
  input: openapiPath,
@@ -445,7 +465,10 @@ var DevToolsModule = class {
445
465
  plugins: [
446
466
  "@hey-api/typescript",
447
467
  "@hey-api/sdk",
448
- "@hey-api/client-axios"
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 {
@@ -388,13 +405,16 @@ var DevToolsModule = class {
388
405
  });
389
406
  console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
390
407
  }
391
- const openapiPath = resolve(baseDirname, options.openapiOut);
408
+ const openapiPath = resolve2(baseDirname, options.openapiOut);
392
409
  ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
393
410
  if (options.needGenerateClientSdk) {
394
- const clientSdkOutPath = resolve(baseDirname, options.clientSdkOut);
411
+ const clientSdkOutPath = resolve2(baseDirname, options.clientSdkOut);
395
412
  mkdirSync2(clientSdkOutPath, {
396
413
  recursive: true
397
414
  });
415
+ generateClientConfig({
416
+ outputPath: clientSdkOutPath
417
+ });
398
418
  const { createClient } = await import("@hey-api/openapi-ts");
399
419
  await createClient({
400
420
  input: openapiPath,
@@ -404,7 +424,10 @@ var DevToolsModule = class {
404
424
  plugins: [
405
425
  "@hey-api/typescript",
406
426
  "@hey-api/sdk",
407
- "@hey-api/client-axios"
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(join(process.cwd(), options?.viewsDir ?? "dist/client"));
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.7",
3
+ "version": "1.0.3-alpha.8",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",