@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.js CHANGED
@@ -7333,7 +7333,7 @@ var require_chokidar = __commonJS({
7333
7333
  // src/modules/platform/module.ts
7334
7334
  import { Global, Module as Module2, ValidationPipe } from "@nestjs/common";
7335
7335
  import { APP_INTERCEPTOR, APP_PIPE } from "@nestjs/core";
7336
- import { CommonModule as CommonModule2, OBSERVABLE_SERVICE } from "@lark-apaas/nestjs-common";
7336
+ import { CommonModule as CommonModule2, OBSERVABLE_SERVICE as OBSERVABLE_SERVICE2 } from "@lark-apaas/nestjs-common";
7337
7337
  import { ConfigModule, ConfigService } from "@nestjs/config";
7338
7338
  import { NestjsObservableModule as ObservableModule, Observable, ObservableTraceMiddleware, TraceInterceptor } from "@lark-apaas/nestjs-observable";
7339
7339
  import { HttpModule } from "@nestjs/axios";
@@ -7341,7 +7341,7 @@ import { LoggerModule, AppLogger as AppLogger2, LoggerContextMiddleware } from "
7341
7341
  import { DataPaasModule, SqlExecutionContextMiddleware } from "@lark-apaas/nestjs-datapaas";
7342
7342
  import { AuthNPaasModule } from "@lark-apaas/nestjs-authnpaas";
7343
7343
  import { AutomationModule } from "@lark-apaas/nestjs-trigger";
7344
- import { PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT4 } from "@lark-apaas/nestjs-common";
7344
+ import { PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT5 } from "@lark-apaas/nestjs-common";
7345
7345
 
7346
7346
  // ../nestjs-capability/dist/index.js
7347
7347
  var chokidar = __toESM(require_chokidar(), 1);
@@ -7386,6 +7386,15 @@ function _ts_decorate(decorators, target, key, desc) {
7386
7386
  }
7387
7387
  __name(_ts_decorate, "_ts_decorate");
7388
7388
  __name2(_ts_decorate, "_ts_decorate");
7389
+ var TYPE_DEFAULT_VALUES = {
7390
+ array: [],
7391
+ object: {},
7392
+ string: "",
7393
+ number: 0,
7394
+ integer: 0,
7395
+ boolean: false,
7396
+ null: null
7397
+ };
7389
7398
  var TemplateEngineService = class {
7390
7399
  static {
7391
7400
  __name(this, "TemplateEngineService");
@@ -7397,24 +7406,40 @@ var TemplateEngineService = class {
7397
7406
  EXPR_REGEX = /\{\{\s*input\.([a-zA-Z_][a-zA-Z_0-9]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*)\}\}/g;
7398
7407
  // 匹配整串单个表达式
7399
7408
  WHOLE_STRING_EXPR_REGEX = /^\{\{\s*input\.([a-zA-Z_][a-zA-Z_0-9]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*)\s*\}\}$/;
7400
- resolve(template, input) {
7409
+ /**
7410
+ * 解析 formValue 模板
7411
+ * @param template - formValue 模板对象
7412
+ * @param input - 用户输入参数
7413
+ * @param paramsSchema - 可选,输入参数的 JSON Schema,用于推断默认值
7414
+ * @returns 解析后的参数对象
7415
+ */
7416
+ resolve(template, input, paramsSchema) {
7401
7417
  if (typeof template === "string") {
7402
- return this.resolveString(template, input);
7418
+ return this.resolveString(template, input, paramsSchema);
7403
7419
  }
7404
7420
  if (Array.isArray(template)) {
7405
- return template.map((item) => this.resolve(item, input));
7421
+ return template.map((item) => this.resolve(item, input, paramsSchema));
7406
7422
  }
7407
7423
  if (template !== null && typeof template === "object") {
7408
- return this.resolveObject(template, input);
7424
+ return this.resolveObject(template, input, paramsSchema);
7409
7425
  }
7410
7426
  return template;
7411
7427
  }
7412
- resolveString(template, input) {
7428
+ resolveString(template, input, paramsSchema) {
7413
7429
  const wholeMatch = template.match(this.WHOLE_STRING_EXPR_REGEX);
7414
7430
  if (wholeMatch) {
7415
7431
  const path2 = wholeMatch[1];
7416
7432
  const value = this.getValueByPath(input, path2);
7417
- return value !== void 0 ? value : template;
7433
+ if (value !== void 0) {
7434
+ return value;
7435
+ }
7436
+ if (paramsSchema) {
7437
+ const defaultValue = this.getDefaultValueForPath(path2, paramsSchema);
7438
+ if (defaultValue !== void 0) {
7439
+ return defaultValue;
7440
+ }
7441
+ }
7442
+ return template;
7418
7443
  }
7419
7444
  this.EXPR_REGEX.lastIndex = 0;
7420
7445
  if (!this.EXPR_REGEX.test(template)) {
@@ -7430,10 +7455,10 @@ var TemplateEngineService = class {
7430
7455
  });
7431
7456
  return result;
7432
7457
  }
7433
- resolveObject(template, input) {
7458
+ resolveObject(template, input, paramsSchema) {
7434
7459
  const result = {};
7435
7460
  for (const [key, value] of Object.entries(template)) {
7436
- result[key] = this.resolve(value, input);
7461
+ result[key] = this.resolve(value, input, paramsSchema);
7437
7462
  }
7438
7463
  return result;
7439
7464
  }
@@ -7448,6 +7473,66 @@ var TemplateEngineService = class {
7448
7473
  }
7449
7474
  return current;
7450
7475
  }
7476
+ /**
7477
+ * 根据路径从 schema 获取默认值
7478
+ * @param path - 变量路径,如 "a.b.c"
7479
+ * @param schema - JSON Schema
7480
+ * @returns 默认值,如果无法确定则返回 undefined
7481
+ */
7482
+ getDefaultValueForPath(path2, schema) {
7483
+ const fieldSchema = this.getSchemaForPath(path2, schema);
7484
+ if (!fieldSchema) {
7485
+ return void 0;
7486
+ }
7487
+ return this.getDefaultValueFromSchema(fieldSchema);
7488
+ }
7489
+ /**
7490
+ * 根据路径查找对应的 schema 定义
7491
+ * @param path - 变量路径,如 "a.b.c"
7492
+ * @param schema - 根 JSON Schema
7493
+ * @returns 路径对应的 schema,如果不存在则返回 undefined
7494
+ */
7495
+ getSchemaForPath(path2, schema) {
7496
+ const keys = path2.split(".");
7497
+ let currentSchema = schema;
7498
+ for (const key of keys) {
7499
+ if (!currentSchema?.properties) {
7500
+ return void 0;
7501
+ }
7502
+ currentSchema = currentSchema.properties[key];
7503
+ if (!currentSchema) {
7504
+ return void 0;
7505
+ }
7506
+ }
7507
+ return currentSchema;
7508
+ }
7509
+ /**
7510
+ * 从 schema 获取默认值
7511
+ * 优先级:default > type > undefined
7512
+ * @param schema - 字段的 JSON Schema
7513
+ * @returns 默认值
7514
+ */
7515
+ getDefaultValueFromSchema(schema) {
7516
+ if (schema.default !== void 0) {
7517
+ return schema.default;
7518
+ }
7519
+ if (schema.oneOf || schema.anyOf) {
7520
+ return void 0;
7521
+ }
7522
+ const type = schema.type;
7523
+ if (!type) {
7524
+ return void 0;
7525
+ }
7526
+ if (Array.isArray(type)) {
7527
+ for (const t of type) {
7528
+ if (t in TYPE_DEFAULT_VALUES) {
7529
+ return TYPE_DEFAULT_VALUES[t];
7530
+ }
7531
+ }
7532
+ return void 0;
7533
+ }
7534
+ return TYPE_DEFAULT_VALUES[type];
7535
+ }
7451
7536
  };
7452
7537
  TemplateEngineService = _ts_decorate([
7453
7538
  Injectable()
@@ -7940,7 +8025,7 @@ var CapabilityService = class _CapabilityService {
7940
8025
  if (!pluginInstance.hasAction(actionName)) {
7941
8026
  throw new ActionNotFoundError(config.pluginKey, actionName);
7942
8027
  }
7943
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8028
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
7944
8029
  const context = this.buildActionContext(contextOverride);
7945
8030
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
7946
8031
  this.logger.log("Executing capability (call)", {
@@ -7991,7 +8076,7 @@ var CapabilityService = class _CapabilityService {
7991
8076
  if (!pluginInstance.hasAction(actionName)) {
7992
8077
  throw new ActionNotFoundError(config.pluginKey, actionName);
7993
8078
  }
7994
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8079
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
7995
8080
  const context = this.buildActionContext(contextOverride);
7996
8081
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
7997
8082
  this.logger.log("Executing capability (stream)", {
@@ -8042,7 +8127,7 @@ var CapabilityService = class _CapabilityService {
8042
8127
  if (!pluginInstance.hasAction(actionName)) {
8043
8128
  throw new ActionNotFoundError(config.pluginKey, actionName);
8044
8129
  }
8045
- const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input) : input;
8130
+ const resolvedParams = config.formValue ? this.templateEngineService.resolve(config.formValue, input, config.paramsSchema) : input;
8046
8131
  const context = this.buildActionContext(contextOverride);
8047
8132
  const isStream = pluginInstance.isStreamAction?.(actionName) ?? false;
8048
8133
  this.logger.log("Executing capability (streamWithEvents)", {
@@ -8237,7 +8322,7 @@ var DebugController = class _DebugController {
8237
8322
  try {
8238
8323
  const config = this.getCapabilityConfig(capabilityId, body.capability);
8239
8324
  const action = await this.getActionName(config.pluginKey, body.action);
8240
- const resolvedParams = this.templateEngineService.resolve(config.formValue, params);
8325
+ const resolvedParams = this.templateEngineService.resolve(config.formValue, params, config.paramsSchema);
8241
8326
  const result = await this.capabilityService.loadWithConfig(config).call(action, params, {
8242
8327
  isDebug: true
8243
8328
  });
@@ -9496,7 +9581,10 @@ PlatformHttpClientService = _ts_decorate14([
9496
9581
  // src/modules/platform/config/feature-switch.ts
9497
9582
  var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
9498
9583
 
9499
- // src/modules/platform/module.ts
9584
+ // src/services/file.service.ts
9585
+ import { Injectable as Injectable12, Inject as Inject3, Logger as Logger7 } from "@nestjs/common";
9586
+ import { ObservableService, RequestContextService as RequestContextService4, PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT4, OBSERVABLE_SERVICE } from "@lark-apaas/nestjs-common";
9587
+ import { FileService as FileServiceCore, FileDownloadBuilder } from "@lark-apaas/file-service";
9500
9588
  function _ts_decorate15(decorators, target, key, desc) {
9501
9589
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9502
9590
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9504,6 +9592,390 @@ function _ts_decorate15(decorators, target, key, desc) {
9504
9592
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9505
9593
  }
9506
9594
  __name(_ts_decorate15, "_ts_decorate");
9595
+ function _ts_metadata9(k, v) {
9596
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9597
+ }
9598
+ __name(_ts_metadata9, "_ts_metadata");
9599
+ function _ts_param5(paramIndex, decorator) {
9600
+ return function(target, key) {
9601
+ decorator(target, key, paramIndex);
9602
+ };
9603
+ }
9604
+ __name(_ts_param5, "_ts_param");
9605
+ var FileService = class {
9606
+ static {
9607
+ __name(this, "FileService");
9608
+ }
9609
+ requestContextService;
9610
+ httpClient;
9611
+ observable;
9612
+ fileServiceCore;
9613
+ nestLogger;
9614
+ constructor(requestContextService, httpClient, observable) {
9615
+ this.requestContextService = requestContextService;
9616
+ this.httpClient = httpClient;
9617
+ this.observable = observable;
9618
+ this.fileServiceCore = new FileServiceCore(this.httpClient);
9619
+ this.nestLogger = new Logger7("file");
9620
+ }
9621
+ /**
9622
+ * 返回一个绑定了指定 bucket 的代理对象
9623
+ * 不会修改 context,避免副作用
9624
+ */
9625
+ from(bucket) {
9626
+ return {
9627
+ upload: /* @__PURE__ */ __name((file, options) => this._upload(bucket, file, options), "upload"),
9628
+ download: /* @__PURE__ */ __name((path2) => this._download(bucket, path2), "download"),
9629
+ list: /* @__PURE__ */ __name((prefix, searchOptions) => this._list(bucket, prefix, searchOptions), "list"),
9630
+ remove: /* @__PURE__ */ __name((filePaths) => this._remove(bucket, filePaths), "remove"),
9631
+ createSignedUrl: /* @__PURE__ */ __name((path2, expiresIn) => this._createSignedUrl(bucket, path2, expiresIn), "createSignedUrl"),
9632
+ getFileMetadata: /* @__PURE__ */ __name((filePath) => this._getFileMetadata(bucket, filePath), "getFileMetadata")
9633
+ };
9634
+ }
9635
+ // ============ 公开方法(使用默认 bucket)============
9636
+ async upload(file, options) {
9637
+ return this._upload(await this.getDefaultBucket(), file, options);
9638
+ }
9639
+ download(path2) {
9640
+ const capturedBucketPromise = this.getDefaultBucket();
9641
+ return this._download(capturedBucketPromise, path2);
9642
+ }
9643
+ async list(prefix, searchOptions) {
9644
+ return this._list(await this.getDefaultBucket(), prefix, searchOptions);
9645
+ }
9646
+ async remove(filePaths) {
9647
+ return this._remove(await this.getDefaultBucket(), filePaths);
9648
+ }
9649
+ async createSignedUrl(path2, expiresIn) {
9650
+ return this._createSignedUrl(await this.getDefaultBucket(), path2, expiresIn);
9651
+ }
9652
+ async getFileMetadata(filePath) {
9653
+ return this._getFileMetadata(await this.getDefaultBucket(), filePath);
9654
+ }
9655
+ async getDefaultBucket() {
9656
+ const reqContext = this.requestContextService.getContext();
9657
+ const bucketFromContext = reqContext?.bucket;
9658
+ if (bucketFromContext) {
9659
+ return bucketFromContext;
9660
+ }
9661
+ const appId = this.getAppId();
9662
+ const bucket = await this.fileServiceCore.getDefaultBucket(appId);
9663
+ return bucket;
9664
+ }
9665
+ getAppId() {
9666
+ const requestCtx = this.requestContextService.getContext();
9667
+ return requestCtx?.appId ?? "";
9668
+ }
9669
+ // ============ 核心实现方法(接受 bucket 参数)============
9670
+ async _upload(bucket, file, options) {
9671
+ const span = this.observable.startTrace("\u6587\u4EF6: upload", this.requestContextService.getContext()?.requestRootSpan);
9672
+ span.setAttribute("module", "file");
9673
+ span.setAttribute("source_type", "platform");
9674
+ const spanContext = {
9675
+ traceId: span.spanContext().traceId,
9676
+ spanId: span.spanContext().spanId
9677
+ };
9678
+ const logContext = {
9679
+ source_type: "platform",
9680
+ paas_attributes_module: "file",
9681
+ paas_parent_span_context: spanContext
9682
+ };
9683
+ const baseParams = {
9684
+ method: "upload",
9685
+ source_type: "server",
9686
+ request: {
9687
+ options
9688
+ }
9689
+ };
9690
+ const startTime = Date.now();
9691
+ try {
9692
+ const res = await this.fileServiceCore.upload({
9693
+ appId: this.getAppId(),
9694
+ bucketId: await bucket,
9695
+ fileBody: file,
9696
+ options
9697
+ });
9698
+ this.nestLogger.log(JSON.stringify({
9699
+ ...baseParams,
9700
+ response: res,
9701
+ status: "succeed",
9702
+ duration_ms: Date.now() - startTime
9703
+ }), logContext);
9704
+ return res;
9705
+ } catch (e) {
9706
+ this.nestLogger.error(JSON.stringify({
9707
+ ...baseParams,
9708
+ error_message: e instanceof Error ? e.message : String(e),
9709
+ status: "failed",
9710
+ duration_ms: Date.now() - startTime
9711
+ }), logContext);
9712
+ throw e;
9713
+ } finally {
9714
+ span.end();
9715
+ }
9716
+ }
9717
+ _download(bucket, path2) {
9718
+ const capturedAppId = this.getAppId();
9719
+ const capturedRootSpan = this.requestContextService.getContext()?.requestRootSpan;
9720
+ const downloadFn = /* @__PURE__ */ __name(async () => {
9721
+ const span = this.observable.startTrace("\u6587\u4EF6: download", capturedRootSpan);
9722
+ span.setAttribute("module", "file");
9723
+ span.setAttribute("source_type", "platform");
9724
+ const spanContext = {
9725
+ traceId: span.spanContext().traceId,
9726
+ spanId: span.spanContext().spanId
9727
+ };
9728
+ const logContext = {
9729
+ source_type: "platform",
9730
+ paas_attributes_module: "file",
9731
+ paas_parent_span_context: spanContext
9732
+ };
9733
+ const baseParams = {
9734
+ method: "download",
9735
+ source_type: "server",
9736
+ request: {
9737
+ path: path2
9738
+ }
9739
+ };
9740
+ const startTime = Date.now();
9741
+ try {
9742
+ const res = await this.fileServiceCore.downloadInner({
9743
+ appId: capturedAppId,
9744
+ bucketId: await bucket,
9745
+ filePath: path2
9746
+ });
9747
+ this.nestLogger.log(JSON.stringify({
9748
+ ...baseParams,
9749
+ response: {
9750
+ metadata: res.metadata
9751
+ },
9752
+ status: "succeed",
9753
+ duration_ms: Date.now() - startTime
9754
+ }), logContext);
9755
+ return res;
9756
+ } catch (e) {
9757
+ this.nestLogger.error(JSON.stringify({
9758
+ ...baseParams,
9759
+ error_message: e instanceof Error ? e.message : String(e),
9760
+ status: "failed",
9761
+ duration_ms: Date.now() - startTime
9762
+ }), logContext);
9763
+ throw e;
9764
+ } finally {
9765
+ span.end();
9766
+ }
9767
+ }, "downloadFn");
9768
+ return new FileDownloadBuilder(downloadFn);
9769
+ }
9770
+ async _list(bucket, prefix, searchOptions) {
9771
+ const span = this.observable.startTrace("\u6587\u4EF6: list", this.requestContextService.getContext()?.requestRootSpan);
9772
+ span.setAttribute("module", "file");
9773
+ span.setAttribute("source_type", "platform");
9774
+ const spanContext = {
9775
+ traceId: span.spanContext().traceId,
9776
+ spanId: span.spanContext().spanId
9777
+ };
9778
+ const logContext = {
9779
+ source_type: "platform",
9780
+ paas_attributes_module: "file",
9781
+ paas_parent_span_context: spanContext
9782
+ };
9783
+ const baseParams = {
9784
+ method: "list",
9785
+ source_type: "server",
9786
+ request: {
9787
+ prefix,
9788
+ searchOptions
9789
+ }
9790
+ };
9791
+ const startTime = Date.now();
9792
+ try {
9793
+ const res = await this.fileServiceCore.list({
9794
+ appId: this.getAppId(),
9795
+ bucketId: await bucket,
9796
+ prefix,
9797
+ searchOptions
9798
+ });
9799
+ this.nestLogger.log(JSON.stringify({
9800
+ ...baseParams,
9801
+ response: res,
9802
+ status: "succeed",
9803
+ duration_ms: Date.now() - startTime
9804
+ }), logContext);
9805
+ return res;
9806
+ } catch (e) {
9807
+ this.nestLogger.error(JSON.stringify({
9808
+ ...baseParams,
9809
+ error_message: e instanceof Error ? e.message : String(e),
9810
+ status: "failed",
9811
+ duration_ms: Date.now() - startTime
9812
+ }), logContext);
9813
+ throw e;
9814
+ } finally {
9815
+ span.end();
9816
+ }
9817
+ }
9818
+ async _remove(bucket, filePaths) {
9819
+ const span = this.observable.startTrace("\u6587\u4EF6: remove", this.requestContextService.getContext()?.requestRootSpan);
9820
+ span.setAttribute("module", "file");
9821
+ span.setAttribute("source_type", "platform");
9822
+ const spanContext = {
9823
+ traceId: span.spanContext().traceId,
9824
+ spanId: span.spanContext().spanId
9825
+ };
9826
+ const logContext = {
9827
+ source_type: "platform",
9828
+ paas_attributes_module: "file",
9829
+ paas_parent_span_context: spanContext
9830
+ };
9831
+ const baseParams = {
9832
+ method: "remove",
9833
+ source_type: "server",
9834
+ request: {
9835
+ filePaths
9836
+ }
9837
+ };
9838
+ const startTime = Date.now();
9839
+ try {
9840
+ const res = await this.fileServiceCore.remove({
9841
+ appId: this.getAppId(),
9842
+ bucketId: await bucket,
9843
+ filePaths
9844
+ });
9845
+ this.nestLogger.log(JSON.stringify({
9846
+ ...baseParams,
9847
+ response: res,
9848
+ status: "succeed",
9849
+ duration_ms: Date.now() - startTime
9850
+ }), logContext);
9851
+ return res;
9852
+ } catch (e) {
9853
+ this.nestLogger.error(JSON.stringify({
9854
+ ...baseParams,
9855
+ error_message: e instanceof Error ? e.message : String(e),
9856
+ status: "failed",
9857
+ duration_ms: Date.now() - startTime
9858
+ }), logContext);
9859
+ throw e;
9860
+ } finally {
9861
+ span.end();
9862
+ }
9863
+ }
9864
+ async _createSignedUrl(bucket, path2, expiresIn) {
9865
+ const span = this.observable.startTrace("\u6587\u4EF6: createSignedUrl", this.requestContextService.getContext()?.requestRootSpan);
9866
+ span.setAttribute("module", "file");
9867
+ span.setAttribute("source_type", "platform");
9868
+ const spanContext = {
9869
+ traceId: span.spanContext().traceId,
9870
+ spanId: span.spanContext().spanId
9871
+ };
9872
+ const logContext = {
9873
+ source_type: "platform",
9874
+ paas_attributes_module: "file",
9875
+ paas_parent_span_context: spanContext
9876
+ };
9877
+ const baseParams = {
9878
+ method: "createSignedUrl",
9879
+ source_type: "server",
9880
+ request: {
9881
+ path: path2,
9882
+ expiresIn
9883
+ }
9884
+ };
9885
+ const startTime = Date.now();
9886
+ try {
9887
+ const res = await this.fileServiceCore.createSignedUrl({
9888
+ appId: this.getAppId(),
9889
+ bucketId: await bucket,
9890
+ filePath: path2,
9891
+ expiresIn
9892
+ });
9893
+ this.nestLogger.log(JSON.stringify({
9894
+ ...baseParams,
9895
+ response: res,
9896
+ status: "succeed",
9897
+ duration_ms: Date.now() - startTime
9898
+ }), logContext);
9899
+ return res;
9900
+ } catch (e) {
9901
+ this.nestLogger.error(JSON.stringify({
9902
+ ...baseParams,
9903
+ error_message: e instanceof Error ? e.message : String(e),
9904
+ status: "failed",
9905
+ duration_ms: Date.now() - startTime
9906
+ }), logContext);
9907
+ throw e;
9908
+ } finally {
9909
+ span.end();
9910
+ }
9911
+ }
9912
+ async _getFileMetadata(bucket, filePath) {
9913
+ const span = this.observable.startTrace("\u6587\u4EF6: getFileMetadata", this.requestContextService.getContext()?.requestRootSpan);
9914
+ span.setAttribute("module", "file");
9915
+ span.setAttribute("source_type", "platform");
9916
+ const spanContext = {
9917
+ traceId: span.spanContext().traceId,
9918
+ spanId: span.spanContext().spanId
9919
+ };
9920
+ const logContext = {
9921
+ source_type: "platform",
9922
+ paas_attributes_module: "file",
9923
+ paas_parent_span_context: spanContext
9924
+ };
9925
+ const baseParams = {
9926
+ method: "getFileMetadata",
9927
+ source_type: "server",
9928
+ request: {
9929
+ filePath
9930
+ }
9931
+ };
9932
+ const startTime = Date.now();
9933
+ try {
9934
+ const res = await this.fileServiceCore.getFileMetadata({
9935
+ appId: this.getAppId(),
9936
+ bucketId: await bucket,
9937
+ filePath
9938
+ });
9939
+ this.nestLogger.log(JSON.stringify({
9940
+ ...baseParams,
9941
+ response: res,
9942
+ status: "succeed",
9943
+ duration_ms: Date.now() - startTime
9944
+ }), logContext);
9945
+ return res;
9946
+ } catch (e) {
9947
+ this.nestLogger.error(JSON.stringify({
9948
+ ...baseParams,
9949
+ error_message: e instanceof Error ? e.message : String(e),
9950
+ status: "failed",
9951
+ duration_ms: Date.now() - startTime
9952
+ }), logContext);
9953
+ throw e;
9954
+ } finally {
9955
+ span.end();
9956
+ }
9957
+ }
9958
+ };
9959
+ FileService = _ts_decorate15([
9960
+ Injectable12(),
9961
+ _ts_param5(1, Inject3(PLATFORM_HTTP_CLIENT4)),
9962
+ _ts_param5(2, Inject3(OBSERVABLE_SERVICE)),
9963
+ _ts_metadata9("design:type", Function),
9964
+ _ts_metadata9("design:paramtypes", [
9965
+ typeof RequestContextService4 === "undefined" ? Object : RequestContextService4,
9966
+ typeof PlatformHttpClient === "undefined" ? Object : PlatformHttpClient,
9967
+ typeof ObservableService === "undefined" ? Object : ObservableService
9968
+ ])
9969
+ ], FileService);
9970
+
9971
+ // src/modules/platform/module.ts
9972
+ function _ts_decorate16(decorators, target, key, desc) {
9973
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9974
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9975
+ 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;
9976
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9977
+ }
9978
+ __name(_ts_decorate16, "_ts_decorate");
9507
9979
  var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
9508
9980
  var PlatformModule = class _PlatformModule {
9509
9981
  static {
@@ -9585,12 +10057,12 @@ var PlatformModule = class _PlatformModule {
9585
10057
  })
9586
10058
  },
9587
10059
  {
9588
- provide: OBSERVABLE_SERVICE,
10060
+ provide: OBSERVABLE_SERVICE2,
9589
10061
  useClass: Observable
9590
10062
  },
9591
10063
  PlatformHttpClientService,
9592
10064
  {
9593
- provide: PLATFORM_HTTP_CLIENT4,
10065
+ provide: PLATFORM_HTTP_CLIENT5,
9594
10066
  useFactory: /* @__PURE__ */ __name((svc) => svc.instance, "useFactory"),
9595
10067
  inject: [
9596
10068
  PlatformHttpClientService
@@ -9600,15 +10072,17 @@ var PlatformModule = class _PlatformModule {
9600
10072
  {
9601
10073
  provide: APP_INTERCEPTOR,
9602
10074
  useClass: TraceInterceptor
9603
- }
10075
+ },
10076
+ FileService
9604
10077
  ],
9605
10078
  exports: [
9606
10079
  ConfigModule,
9607
10080
  LoggerModule,
9608
10081
  CommonModule2,
9609
- OBSERVABLE_SERVICE,
9610
- PLATFORM_HTTP_CLIENT4,
9611
- CapabilityModule
10082
+ OBSERVABLE_SERVICE2,
10083
+ PLATFORM_HTTP_CLIENT5,
10084
+ CapabilityModule,
10085
+ FileService
9612
10086
  ]
9613
10087
  };
9614
10088
  }
@@ -9637,7 +10111,7 @@ var PlatformModule = class _PlatformModule {
9637
10111
  }
9638
10112
  }
9639
10113
  };
9640
- PlatformModule = _ts_decorate15([
10114
+ PlatformModule = _ts_decorate16([
9641
10115
  Global(),
9642
10116
  Module2({})
9643
10117
  ], PlatformModule);
@@ -9677,6 +10151,7 @@ export * from "@lark-apaas/nestjs-authnpaas";
9677
10151
  export * from "@lark-apaas/nestjs-datapaas";
9678
10152
  export * from "@lark-apaas/nestjs-observable";
9679
10153
  export * from "@lark-apaas/nestjs-trigger";
10154
+ export * from "@lark-apaas/file-service";
9680
10155
  import { AutoTrace } from "@lark-apaas/nestjs-common";
9681
10156
  export {
9682
10157
  ActionNotFoundError,
@@ -9690,6 +10165,7 @@ export {
9690
10165
  DevToolsModule,
9691
10166
  DevToolsV2Module2 as DevToolsV2Module,
9692
10167
  ErrorCodes,
10168
+ FileService,
9693
10169
  PlatformModule,
9694
10170
  PluginLoadError,
9695
10171
  PluginLoaderService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.16-alpha.6",
3
+ "version": "1.1.16-alpha.7",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,6 +39,7 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
+ "@lark-apaas/file-service": "0.0.1-alpha.12",
42
43
  "@lark-apaas/http-client": "^0.1.2",
43
44
  "@lark-apaas/nestjs-authnpaas": "^1.0.2",
44
45
  "@lark-apaas/nestjs-common": "^0.1.1",