@lark-apaas/fullstack-nestjs-core 1.1.16-alpha.6 → 1.1.16-alpha.7

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
@@ -7335,7 +7335,7 @@ var require_chokidar = __commonJS({
7335
7335
  var index_exports = {};
7336
7336
  __export(index_exports, {
7337
7337
  ActionNotFoundError: () => ActionNotFoundError,
7338
- AutoTrace: () => import_nestjs_common7.AutoTrace,
7338
+ AutoTrace: () => import_nestjs_common8.AutoTrace,
7339
7339
  CapabilityModule: () => CapabilityModule,
7340
7340
  CapabilityNotFoundError: () => CapabilityNotFoundError,
7341
7341
  CapabilityService: () => CapabilityService,
@@ -7345,6 +7345,7 @@ __export(index_exports, {
7345
7345
  DevToolsModule: () => import_nestjs_openapi_devtools2.DevToolsModule,
7346
7346
  DevToolsV2Module: () => import_nestjs_openapi_devtools2.DevToolsV2Module,
7347
7347
  ErrorCodes: () => ErrorCodes,
7348
+ FileService: () => FileService,
7348
7349
  PlatformModule: () => PlatformModule,
7349
7350
  PluginLoadError: () => PluginLoadError,
7350
7351
  PluginLoaderService: () => PluginLoaderService,
@@ -7359,9 +7360,9 @@ __export(index_exports, {
7359
7360
  module.exports = __toCommonJS(index_exports);
7360
7361
 
7361
7362
  // src/modules/platform/module.ts
7362
- var import_common15 = require("@nestjs/common");
7363
+ var import_common16 = require("@nestjs/common");
7363
7364
  var import_core2 = require("@nestjs/core");
7364
- var import_nestjs_common5 = require("@lark-apaas/nestjs-common");
7365
+ var import_nestjs_common6 = require("@lark-apaas/nestjs-common");
7365
7366
  var import_config2 = require("@nestjs/config");
7366
7367
  var import_nestjs_observable = require("@lark-apaas/nestjs-observable");
7367
7368
  var import_axios2 = require("@nestjs/axios");
@@ -7369,7 +7370,7 @@ var import_nestjs_logger2 = require("@lark-apaas/nestjs-logger");
7369
7370
  var import_nestjs_datapaas = require("@lark-apaas/nestjs-datapaas");
7370
7371
  var import_nestjs_authnpaas = require("@lark-apaas/nestjs-authnpaas");
7371
7372
  var import_nestjs_trigger = require("@lark-apaas/nestjs-trigger");
7372
- var import_nestjs_common6 = require("@lark-apaas/nestjs-common");
7373
+ var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
7373
7374
 
7374
7375
  // ../nestjs-capability/dist/index.js
7375
7376
  var import_common = require("@nestjs/common");
@@ -7415,6 +7416,15 @@ function _ts_decorate(decorators, target, key, desc) {
7415
7416
  }
7416
7417
  __name(_ts_decorate, "_ts_decorate");
7417
7418
  __name2(_ts_decorate, "_ts_decorate");
7419
+ var TYPE_DEFAULT_VALUES = {
7420
+ array: [],
7421
+ object: {},
7422
+ string: "",
7423
+ number: 0,
7424
+ integer: 0,
7425
+ boolean: false,
7426
+ null: null
7427
+ };
7418
7428
  var TemplateEngineService = class {
7419
7429
  static {
7420
7430
  __name(this, "TemplateEngineService");
@@ -7426,24 +7436,40 @@ var TemplateEngineService = class {
7426
7436
  EXPR_REGEX = /\{\{\s*input\.([a-zA-Z_][a-zA-Z_0-9]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*)\}\}/g;
7427
7437
  // 匹配整串单个表达式
7428
7438
  WHOLE_STRING_EXPR_REGEX = /^\{\{\s*input\.([a-zA-Z_][a-zA-Z_0-9]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*)\s*\}\}$/;
7429
- resolve(template, input) {
7439
+ /**
7440
+ * 解析 formValue 模板
7441
+ * @param template - formValue 模板对象
7442
+ * @param input - 用户输入参数
7443
+ * @param paramsSchema - 可选,输入参数的 JSON Schema,用于推断默认值
7444
+ * @returns 解析后的参数对象
7445
+ */
7446
+ resolve(template, input, paramsSchema) {
7430
7447
  if (typeof template === "string") {
7431
- return this.resolveString(template, input);
7448
+ return this.resolveString(template, input, paramsSchema);
7432
7449
  }
7433
7450
  if (Array.isArray(template)) {
7434
- return template.map((item) => this.resolve(item, input));
7451
+ return template.map((item) => this.resolve(item, input, paramsSchema));
7435
7452
  }
7436
7453
  if (template !== null && typeof template === "object") {
7437
- return this.resolveObject(template, input);
7454
+ return this.resolveObject(template, input, paramsSchema);
7438
7455
  }
7439
7456
  return template;
7440
7457
  }
7441
- resolveString(template, input) {
7458
+ resolveString(template, input, paramsSchema) {
7442
7459
  const wholeMatch = template.match(this.WHOLE_STRING_EXPR_REGEX);
7443
7460
  if (wholeMatch) {
7444
7461
  const path2 = wholeMatch[1];
7445
7462
  const value = this.getValueByPath(input, path2);
7446
- return value !== void 0 ? value : template;
7463
+ if (value !== void 0) {
7464
+ return value;
7465
+ }
7466
+ if (paramsSchema) {
7467
+ const defaultValue = this.getDefaultValueForPath(path2, paramsSchema);
7468
+ if (defaultValue !== void 0) {
7469
+ return defaultValue;
7470
+ }
7471
+ }
7472
+ return template;
7447
7473
  }
7448
7474
  this.EXPR_REGEX.lastIndex = 0;
7449
7475
  if (!this.EXPR_REGEX.test(template)) {
@@ -7459,10 +7485,10 @@ var TemplateEngineService = class {
7459
7485
  });
7460
7486
  return result;
7461
7487
  }
7462
- resolveObject(template, input) {
7488
+ resolveObject(template, input, paramsSchema) {
7463
7489
  const result = {};
7464
7490
  for (const [key, value] of Object.entries(template)) {
7465
- result[key] = this.resolve(value, input);
7491
+ result[key] = this.resolve(value, input, paramsSchema);
7466
7492
  }
7467
7493
  return result;
7468
7494
  }
@@ -7477,6 +7503,66 @@ var TemplateEngineService = class {
7477
7503
  }
7478
7504
  return current;
7479
7505
  }
7506
+ /**
7507
+ * 根据路径从 schema 获取默认值
7508
+ * @param path - 变量路径,如 "a.b.c"
7509
+ * @param schema - JSON Schema
7510
+ * @returns 默认值,如果无法确定则返回 undefined
7511
+ */
7512
+ getDefaultValueForPath(path2, schema) {
7513
+ const fieldSchema = this.getSchemaForPath(path2, schema);
7514
+ if (!fieldSchema) {
7515
+ return void 0;
7516
+ }
7517
+ return this.getDefaultValueFromSchema(fieldSchema);
7518
+ }
7519
+ /**
7520
+ * 根据路径查找对应的 schema 定义
7521
+ * @param path - 变量路径,如 "a.b.c"
7522
+ * @param schema - 根 JSON Schema
7523
+ * @returns 路径对应的 schema,如果不存在则返回 undefined
7524
+ */
7525
+ getSchemaForPath(path2, schema) {
7526
+ const keys = path2.split(".");
7527
+ let currentSchema = schema;
7528
+ for (const key of keys) {
7529
+ if (!currentSchema?.properties) {
7530
+ return void 0;
7531
+ }
7532
+ currentSchema = currentSchema.properties[key];
7533
+ if (!currentSchema) {
7534
+ return void 0;
7535
+ }
7536
+ }
7537
+ return currentSchema;
7538
+ }
7539
+ /**
7540
+ * 从 schema 获取默认值
7541
+ * 优先级:default > type > undefined
7542
+ * @param schema - 字段的 JSON Schema
7543
+ * @returns 默认值
7544
+ */
7545
+ getDefaultValueFromSchema(schema) {
7546
+ if (schema.default !== void 0) {
7547
+ return schema.default;
7548
+ }
7549
+ if (schema.oneOf || schema.anyOf) {
7550
+ return void 0;
7551
+ }
7552
+ const type = schema.type;
7553
+ if (!type) {
7554
+ return void 0;
7555
+ }
7556
+ if (Array.isArray(type)) {
7557
+ for (const t of type) {
7558
+ if (t in TYPE_DEFAULT_VALUES) {
7559
+ return TYPE_DEFAULT_VALUES[t];
7560
+ }
7561
+ }
7562
+ return void 0;
7563
+ }
7564
+ return TYPE_DEFAULT_VALUES[type];
7565
+ }
7480
7566
  };
7481
7567
  TemplateEngineService = _ts_decorate([
7482
7568
  (0, import_common.Injectable)()
@@ -7969,7 +8055,7 @@ var CapabilityService = class _CapabilityService {
7969
8055
  if (!pluginInstance.hasAction(actionName)) {
7970
8056
  throw new ActionNotFoundError(config.pluginKey, actionName);
7971
8057
  }
7972
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8058
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
7973
8059
  const context = this.buildActionContext(contextOverride);
7974
8060
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
7975
8061
  this.logger.log("Executing capability (call)", {
@@ -8020,7 +8106,7 @@ var CapabilityService = class _CapabilityService {
8020
8106
  if (!pluginInstance.hasAction(actionName)) {
8021
8107
  throw new ActionNotFoundError(config.pluginKey, actionName);
8022
8108
  }
8023
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8109
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
8024
8110
  const context = this.buildActionContext(contextOverride);
8025
8111
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
8026
8112
  this.logger.log("Executing capability (stream)", {
@@ -8071,7 +8157,7 @@ var CapabilityService = class _CapabilityService {
8071
8157
  if (!pluginInstance.hasAction(actionName)) {
8072
8158
  throw new ActionNotFoundError(config.pluginKey, actionName);
8073
8159
  }
8074
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8160
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
8075
8161
  const context = this.buildActionContext(contextOverride);
8076
8162
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
8077
8163
  this.logger.log("Executing capability (streamWithEvents)", {
@@ -8266,7 +8352,7 @@ var DebugController = class _DebugController {
8266
8352
  try {
8267
8353
  const config = this.getCapabilityConfig(capabilityId, body.capability);
8268
8354
  const action = await this.getActionName(config.pluginKey, body.action);
8269
- const resolvedParams = this.templateEngineService.resolve(config.formValue, params);
8355
+ const resolvedParams = this.templateEngineService.resolve(config.formValue, params, config.paramsSchema);
8270
8356
  const result = await this.capabilityService.loadWithConfig(config).call(action, params, {
8271
8357
  isDebug: true
8272
8358
  });
@@ -9525,7 +9611,10 @@ PlatformHttpClientService = _ts_decorate14([
9525
9611
  // src/modules/platform/config/feature-switch.ts
9526
9612
  var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
9527
9613
 
9528
- // src/modules/platform/module.ts
9614
+ // src/services/file.service.ts
9615
+ var import_common15 = require("@nestjs/common");
9616
+ var import_nestjs_common5 = require("@lark-apaas/nestjs-common");
9617
+ var import_file_service = require("@lark-apaas/file-service");
9529
9618
  function _ts_decorate15(decorators, target, key, desc) {
9530
9619
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9531
9620
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9533,6 +9622,390 @@ function _ts_decorate15(decorators, target, key, desc) {
9533
9622
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9534
9623
  }
9535
9624
  __name(_ts_decorate15, "_ts_decorate");
9625
+ function _ts_metadata9(k, v) {
9626
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9627
+ }
9628
+ __name(_ts_metadata9, "_ts_metadata");
9629
+ function _ts_param5(paramIndex, decorator) {
9630
+ return function(target, key) {
9631
+ decorator(target, key, paramIndex);
9632
+ };
9633
+ }
9634
+ __name(_ts_param5, "_ts_param");
9635
+ var FileService = class {
9636
+ static {
9637
+ __name(this, "FileService");
9638
+ }
9639
+ requestContextService;
9640
+ httpClient;
9641
+ observable;
9642
+ fileServiceCore;
9643
+ nestLogger;
9644
+ constructor(requestContextService, httpClient, observable) {
9645
+ this.requestContextService = requestContextService;
9646
+ this.httpClient = httpClient;
9647
+ this.observable = observable;
9648
+ this.fileServiceCore = new import_file_service.FileService(this.httpClient);
9649
+ this.nestLogger = new import_common15.Logger("file");
9650
+ }
9651
+ /**
9652
+ * 返回一个绑定了指定 bucket 的代理对象
9653
+ * 不会修改 context,避免副作用
9654
+ */
9655
+ from(bucket) {
9656
+ return {
9657
+ upload: /* @__PURE__ */ __name((file, options) => this._upload(bucket, file, options), "upload"),
9658
+ download: /* @__PURE__ */ __name((path2) => this._download(bucket, path2), "download"),
9659
+ list: /* @__PURE__ */ __name((prefix, searchOptions) => this._list(bucket, prefix, searchOptions), "list"),
9660
+ remove: /* @__PURE__ */ __name((filePaths) => this._remove(bucket, filePaths), "remove"),
9661
+ createSignedUrl: /* @__PURE__ */ __name((path2, expiresIn) => this._createSignedUrl(bucket, path2, expiresIn), "createSignedUrl"),
9662
+ getFileMetadata: /* @__PURE__ */ __name((filePath) => this._getFileMetadata(bucket, filePath), "getFileMetadata")
9663
+ };
9664
+ }
9665
+ // ============ 公开方法(使用默认 bucket)============
9666
+ async upload(file, options) {
9667
+ return this._upload(await this.getDefaultBucket(), file, options);
9668
+ }
9669
+ download(path2) {
9670
+ const capturedBucketPromise = this.getDefaultBucket();
9671
+ return this._download(capturedBucketPromise, path2);
9672
+ }
9673
+ async list(prefix, searchOptions) {
9674
+ return this._list(await this.getDefaultBucket(), prefix, searchOptions);
9675
+ }
9676
+ async remove(filePaths) {
9677
+ return this._remove(await this.getDefaultBucket(), filePaths);
9678
+ }
9679
+ async createSignedUrl(path2, expiresIn) {
9680
+ return this._createSignedUrl(await this.getDefaultBucket(), path2, expiresIn);
9681
+ }
9682
+ async getFileMetadata(filePath) {
9683
+ return this._getFileMetadata(await this.getDefaultBucket(), filePath);
9684
+ }
9685
+ async getDefaultBucket() {
9686
+ const reqContext = this.requestContextService.getContext();
9687
+ const bucketFromContext = reqContext?.bucket;
9688
+ if (bucketFromContext) {
9689
+ return bucketFromContext;
9690
+ }
9691
+ const appId = this.getAppId();
9692
+ const bucket = await this.fileServiceCore.getDefaultBucket(appId);
9693
+ return bucket;
9694
+ }
9695
+ getAppId() {
9696
+ const requestCtx = this.requestContextService.getContext();
9697
+ return requestCtx?.appId ?? "";
9698
+ }
9699
+ // ============ 核心实现方法(接受 bucket 参数)============
9700
+ async _upload(bucket, file, options) {
9701
+ const span = this.observable.startTrace("\u6587\u4EF6: upload", this.requestContextService.getContext()?.requestRootSpan);
9702
+ span.setAttribute("module", "file");
9703
+ span.setAttribute("source_type", "platform");
9704
+ const spanContext = {
9705
+ traceId: span.spanContext().traceId,
9706
+ spanId: span.spanContext().spanId
9707
+ };
9708
+ const logContext = {
9709
+ source_type: "platform",
9710
+ paas_attributes_module: "file",
9711
+ paas_parent_span_context: spanContext
9712
+ };
9713
+ const baseParams = {
9714
+ method: "upload",
9715
+ source_type: "server",
9716
+ request: {
9717
+ options
9718
+ }
9719
+ };
9720
+ const startTime = Date.now();
9721
+ try {
9722
+ const res = await this.fileServiceCore.upload({
9723
+ appId: this.getAppId(),
9724
+ bucketId: await bucket,
9725
+ fileBody: file,
9726
+ options
9727
+ });
9728
+ this.nestLogger.log(JSON.stringify({
9729
+ ...baseParams,
9730
+ response: res,
9731
+ status: "succeed",
9732
+ duration_ms: Date.now() - startTime
9733
+ }), logContext);
9734
+ return res;
9735
+ } catch (e) {
9736
+ this.nestLogger.error(JSON.stringify({
9737
+ ...baseParams,
9738
+ error_message: e instanceof Error ? e.message : String(e),
9739
+ status: "failed",
9740
+ duration_ms: Date.now() - startTime
9741
+ }), logContext);
9742
+ throw e;
9743
+ } finally {
9744
+ span.end();
9745
+ }
9746
+ }
9747
+ _download(bucket, path2) {
9748
+ const capturedAppId = this.getAppId();
9749
+ const capturedRootSpan = this.requestContextService.getContext()?.requestRootSpan;
9750
+ const downloadFn = /* @__PURE__ */ __name(async () => {
9751
+ const span = this.observable.startTrace("\u6587\u4EF6: download", capturedRootSpan);
9752
+ span.setAttribute("module", "file");
9753
+ span.setAttribute("source_type", "platform");
9754
+ const spanContext = {
9755
+ traceId: span.spanContext().traceId,
9756
+ spanId: span.spanContext().spanId
9757
+ };
9758
+ const logContext = {
9759
+ source_type: "platform",
9760
+ paas_attributes_module: "file",
9761
+ paas_parent_span_context: spanContext
9762
+ };
9763
+ const baseParams = {
9764
+ method: "download",
9765
+ source_type: "server",
9766
+ request: {
9767
+ path: path2
9768
+ }
9769
+ };
9770
+ const startTime = Date.now();
9771
+ try {
9772
+ const res = await this.fileServiceCore.downloadInner({
9773
+ appId: capturedAppId,
9774
+ bucketId: await bucket,
9775
+ filePath: path2
9776
+ });
9777
+ this.nestLogger.log(JSON.stringify({
9778
+ ...baseParams,
9779
+ response: {
9780
+ metadata: res.metadata
9781
+ },
9782
+ status: "succeed",
9783
+ duration_ms: Date.now() - startTime
9784
+ }), logContext);
9785
+ return res;
9786
+ } catch (e) {
9787
+ this.nestLogger.error(JSON.stringify({
9788
+ ...baseParams,
9789
+ error_message: e instanceof Error ? e.message : String(e),
9790
+ status: "failed",
9791
+ duration_ms: Date.now() - startTime
9792
+ }), logContext);
9793
+ throw e;
9794
+ } finally {
9795
+ span.end();
9796
+ }
9797
+ }, "downloadFn");
9798
+ return new import_file_service.FileDownloadBuilder(downloadFn);
9799
+ }
9800
+ async _list(bucket, prefix, searchOptions) {
9801
+ const span = this.observable.startTrace("\u6587\u4EF6: list", this.requestContextService.getContext()?.requestRootSpan);
9802
+ span.setAttribute("module", "file");
9803
+ span.setAttribute("source_type", "platform");
9804
+ const spanContext = {
9805
+ traceId: span.spanContext().traceId,
9806
+ spanId: span.spanContext().spanId
9807
+ };
9808
+ const logContext = {
9809
+ source_type: "platform",
9810
+ paas_attributes_module: "file",
9811
+ paas_parent_span_context: spanContext
9812
+ };
9813
+ const baseParams = {
9814
+ method: "list",
9815
+ source_type: "server",
9816
+ request: {
9817
+ prefix,
9818
+ searchOptions
9819
+ }
9820
+ };
9821
+ const startTime = Date.now();
9822
+ try {
9823
+ const res = await this.fileServiceCore.list({
9824
+ appId: this.getAppId(),
9825
+ bucketId: await bucket,
9826
+ prefix,
9827
+ searchOptions
9828
+ });
9829
+ this.nestLogger.log(JSON.stringify({
9830
+ ...baseParams,
9831
+ response: res,
9832
+ status: "succeed",
9833
+ duration_ms: Date.now() - startTime
9834
+ }), logContext);
9835
+ return res;
9836
+ } catch (e) {
9837
+ this.nestLogger.error(JSON.stringify({
9838
+ ...baseParams,
9839
+ error_message: e instanceof Error ? e.message : String(e),
9840
+ status: "failed",
9841
+ duration_ms: Date.now() - startTime
9842
+ }), logContext);
9843
+ throw e;
9844
+ } finally {
9845
+ span.end();
9846
+ }
9847
+ }
9848
+ async _remove(bucket, filePaths) {
9849
+ const span = this.observable.startTrace("\u6587\u4EF6: remove", this.requestContextService.getContext()?.requestRootSpan);
9850
+ span.setAttribute("module", "file");
9851
+ span.setAttribute("source_type", "platform");
9852
+ const spanContext = {
9853
+ traceId: span.spanContext().traceId,
9854
+ spanId: span.spanContext().spanId
9855
+ };
9856
+ const logContext = {
9857
+ source_type: "platform",
9858
+ paas_attributes_module: "file",
9859
+ paas_parent_span_context: spanContext
9860
+ };
9861
+ const baseParams = {
9862
+ method: "remove",
9863
+ source_type: "server",
9864
+ request: {
9865
+ filePaths
9866
+ }
9867
+ };
9868
+ const startTime = Date.now();
9869
+ try {
9870
+ const res = await this.fileServiceCore.remove({
9871
+ appId: this.getAppId(),
9872
+ bucketId: await bucket,
9873
+ filePaths
9874
+ });
9875
+ this.nestLogger.log(JSON.stringify({
9876
+ ...baseParams,
9877
+ response: res,
9878
+ status: "succeed",
9879
+ duration_ms: Date.now() - startTime
9880
+ }), logContext);
9881
+ return res;
9882
+ } catch (e) {
9883
+ this.nestLogger.error(JSON.stringify({
9884
+ ...baseParams,
9885
+ error_message: e instanceof Error ? e.message : String(e),
9886
+ status: "failed",
9887
+ duration_ms: Date.now() - startTime
9888
+ }), logContext);
9889
+ throw e;
9890
+ } finally {
9891
+ span.end();
9892
+ }
9893
+ }
9894
+ async _createSignedUrl(bucket, path2, expiresIn) {
9895
+ const span = this.observable.startTrace("\u6587\u4EF6: createSignedUrl", this.requestContextService.getContext()?.requestRootSpan);
9896
+ span.setAttribute("module", "file");
9897
+ span.setAttribute("source_type", "platform");
9898
+ const spanContext = {
9899
+ traceId: span.spanContext().traceId,
9900
+ spanId: span.spanContext().spanId
9901
+ };
9902
+ const logContext = {
9903
+ source_type: "platform",
9904
+ paas_attributes_module: "file",
9905
+ paas_parent_span_context: spanContext
9906
+ };
9907
+ const baseParams = {
9908
+ method: "createSignedUrl",
9909
+ source_type: "server",
9910
+ request: {
9911
+ path: path2,
9912
+ expiresIn
9913
+ }
9914
+ };
9915
+ const startTime = Date.now();
9916
+ try {
9917
+ const res = await this.fileServiceCore.createSignedUrl({
9918
+ appId: this.getAppId(),
9919
+ bucketId: await bucket,
9920
+ filePath: path2,
9921
+ expiresIn
9922
+ });
9923
+ this.nestLogger.log(JSON.stringify({
9924
+ ...baseParams,
9925
+ response: res,
9926
+ status: "succeed",
9927
+ duration_ms: Date.now() - startTime
9928
+ }), logContext);
9929
+ return res;
9930
+ } catch (e) {
9931
+ this.nestLogger.error(JSON.stringify({
9932
+ ...baseParams,
9933
+ error_message: e instanceof Error ? e.message : String(e),
9934
+ status: "failed",
9935
+ duration_ms: Date.now() - startTime
9936
+ }), logContext);
9937
+ throw e;
9938
+ } finally {
9939
+ span.end();
9940
+ }
9941
+ }
9942
+ async _getFileMetadata(bucket, filePath) {
9943
+ const span = this.observable.startTrace("\u6587\u4EF6: getFileMetadata", this.requestContextService.getContext()?.requestRootSpan);
9944
+ span.setAttribute("module", "file");
9945
+ span.setAttribute("source_type", "platform");
9946
+ const spanContext = {
9947
+ traceId: span.spanContext().traceId,
9948
+ spanId: span.spanContext().spanId
9949
+ };
9950
+ const logContext = {
9951
+ source_type: "platform",
9952
+ paas_attributes_module: "file",
9953
+ paas_parent_span_context: spanContext
9954
+ };
9955
+ const baseParams = {
9956
+ method: "getFileMetadata",
9957
+ source_type: "server",
9958
+ request: {
9959
+ filePath
9960
+ }
9961
+ };
9962
+ const startTime = Date.now();
9963
+ try {
9964
+ const res = await this.fileServiceCore.getFileMetadata({
9965
+ appId: this.getAppId(),
9966
+ bucketId: await bucket,
9967
+ filePath
9968
+ });
9969
+ this.nestLogger.log(JSON.stringify({
9970
+ ...baseParams,
9971
+ response: res,
9972
+ status: "succeed",
9973
+ duration_ms: Date.now() - startTime
9974
+ }), logContext);
9975
+ return res;
9976
+ } catch (e) {
9977
+ this.nestLogger.error(JSON.stringify({
9978
+ ...baseParams,
9979
+ error_message: e instanceof Error ? e.message : String(e),
9980
+ status: "failed",
9981
+ duration_ms: Date.now() - startTime
9982
+ }), logContext);
9983
+ throw e;
9984
+ } finally {
9985
+ span.end();
9986
+ }
9987
+ }
9988
+ };
9989
+ FileService = _ts_decorate15([
9990
+ (0, import_common15.Injectable)(),
9991
+ _ts_param5(1, (0, import_common15.Inject)(import_nestjs_common5.PLATFORM_HTTP_CLIENT)),
9992
+ _ts_param5(2, (0, import_common15.Inject)(import_nestjs_common5.OBSERVABLE_SERVICE)),
9993
+ _ts_metadata9("design:type", Function),
9994
+ _ts_metadata9("design:paramtypes", [
9995
+ typeof import_nestjs_common5.RequestContextService === "undefined" ? Object : import_nestjs_common5.RequestContextService,
9996
+ typeof PlatformHttpClient === "undefined" ? Object : PlatformHttpClient,
9997
+ typeof import_nestjs_common5.ObservableService === "undefined" ? Object : import_nestjs_common5.ObservableService
9998
+ ])
9999
+ ], FileService);
10000
+
10001
+ // src/modules/platform/module.ts
10002
+ function _ts_decorate16(decorators, target, key, desc) {
10003
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10004
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10005
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10006
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10007
+ }
10008
+ __name(_ts_decorate16, "_ts_decorate");
9536
10009
  var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
9537
10010
  var PlatformModule = class _PlatformModule {
9538
10011
  static {
@@ -9554,7 +10027,7 @@ var PlatformModule = class _PlatformModule {
9554
10027
  app_config_default
9555
10028
  ]
9556
10029
  }),
9557
- import_nestjs_common5.CommonModule,
10030
+ import_nestjs_common6.CommonModule,
9558
10031
  import_nestjs_observable.NestjsObservableModule,
9559
10032
  import_nestjs_logger2.LoggerModule,
9560
10033
  import_axios2.HttpModule.register({
@@ -9606,7 +10079,7 @@ var PlatformModule = class _PlatformModule {
9606
10079
  },
9607
10080
  {
9608
10081
  provide: import_core2.APP_PIPE,
9609
- useValue: new import_common15.ValidationPipe({
10082
+ useValue: new import_common16.ValidationPipe({
9610
10083
  transform: true,
9611
10084
  transformOptions: {
9612
10085
  enableImplicitConversion: true
@@ -9614,12 +10087,12 @@ var PlatformModule = class _PlatformModule {
9614
10087
  })
9615
10088
  },
9616
10089
  {
9617
- provide: import_nestjs_common5.OBSERVABLE_SERVICE,
10090
+ provide: import_nestjs_common6.OBSERVABLE_SERVICE,
9618
10091
  useClass: import_nestjs_observable.Observable
9619
10092
  },
9620
10093
  PlatformHttpClientService,
9621
10094
  {
9622
- provide: import_nestjs_common6.PLATFORM_HTTP_CLIENT,
10095
+ provide: import_nestjs_common7.PLATFORM_HTTP_CLIENT,
9623
10096
  useFactory: /* @__PURE__ */ __name((svc) => svc.instance, "useFactory"),
9624
10097
  inject: [
9625
10098
  PlatformHttpClientService
@@ -9629,15 +10102,17 @@ var PlatformModule = class _PlatformModule {
9629
10102
  {
9630
10103
  provide: import_core2.APP_INTERCEPTOR,
9631
10104
  useClass: import_nestjs_observable.TraceInterceptor
9632
- }
10105
+ },
10106
+ FileService
9633
10107
  ],
9634
10108
  exports: [
9635
10109
  import_config2.ConfigModule,
9636
10110
  import_nestjs_logger2.LoggerModule,
9637
- import_nestjs_common5.CommonModule,
9638
- import_nestjs_common5.OBSERVABLE_SERVICE,
9639
- import_nestjs_common6.PLATFORM_HTTP_CLIENT,
9640
- CapabilityModule
10111
+ import_nestjs_common6.CommonModule,
10112
+ import_nestjs_common6.OBSERVABLE_SERVICE,
10113
+ import_nestjs_common7.PLATFORM_HTTP_CLIENT,
10114
+ CapabilityModule,
10115
+ FileService
9641
10116
  ]
9642
10117
  };
9643
10118
  }
@@ -9666,9 +10141,9 @@ var PlatformModule = class _PlatformModule {
9666
10141
  }
9667
10142
  }
9668
10143
  };
9669
- PlatformModule = _ts_decorate15([
9670
- (0, import_common15.Global)(),
9671
- (0, import_common15.Module)({})
10144
+ PlatformModule = _ts_decorate16([
10145
+ (0, import_common16.Global)(),
10146
+ (0, import_common16.Module)({})
9672
10147
  ], PlatformModule);
9673
10148
 
9674
10149
  // src/setup.ts
@@ -9706,7 +10181,8 @@ __reExport(index_exports, require("@lark-apaas/nestjs-authnpaas"), module.export
9706
10181
  __reExport(index_exports, require("@lark-apaas/nestjs-datapaas"), module.exports);
9707
10182
  __reExport(index_exports, require("@lark-apaas/nestjs-observable"), module.exports);
9708
10183
  __reExport(index_exports, require("@lark-apaas/nestjs-trigger"), module.exports);
9709
- var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
10184
+ __reExport(index_exports, require("@lark-apaas/file-service"), module.exports);
10185
+ var import_nestjs_common8 = require("@lark-apaas/nestjs-common");
9710
10186
  // Annotate the CommonJS export names for ESM import in node:
9711
10187
  0 && (module.exports = {
9712
10188
  ActionNotFoundError,
@@ -9720,6 +10196,7 @@ var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
9720
10196
  DevToolsModule,
9721
10197
  DevToolsV2Module,
9722
10198
  ErrorCodes,
10199
+ FileService,
9723
10200
  PlatformModule,
9724
10201
  PluginLoadError,
9725
10202
  PluginLoaderService,
@@ -9733,7 +10210,8 @@ var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
9733
10210
  ...require("@lark-apaas/nestjs-authnpaas"),
9734
10211
  ...require("@lark-apaas/nestjs-datapaas"),
9735
10212
  ...require("@lark-apaas/nestjs-observable"),
9736
- ...require("@lark-apaas/nestjs-trigger")
10213
+ ...require("@lark-apaas/nestjs-trigger"),
10214
+ ...require("@lark-apaas/file-service")
9737
10215
  });
9738
10216
  /*! Bundled license information:
9739
10217