@lark-apaas/fullstack-nestjs-core 1.1.48-alpha.14 → 1.1.48-alpha.15

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
@@ -35081,6 +35081,9 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35081
35081
  ...baseConfig,
35082
35082
  platform: {
35083
35083
  enabled: true
35084
+ },
35085
+ preInterceptors: {
35086
+ request: this.createClaimsPreInterceptors()
35084
35087
  }
35085
35088
  });
35086
35089
  this.protectedClient = new ProtectedHttpClient(this.client);
@@ -35155,7 +35158,10 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35155
35158
  };
35156
35159
  return new import_http_client.HttpClient({
35157
35160
  ...mergedConfig,
35158
- platform: mergedPlatform
35161
+ platform: mergedPlatform,
35162
+ preInterceptors: {
35163
+ request: this.createClaimsPreInterceptors()
35164
+ }
35159
35165
  });
35160
35166
  }
35161
35167
  /**
@@ -35183,6 +35189,36 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35183
35189
  this.registerInterceptorsForClient(client);
35184
35190
  return client;
35185
35191
  }
35192
+ createClaimsPreInterceptors() {
35193
+ return [
35194
+ {
35195
+ onFulfilled: /* @__PURE__ */ __name((config) => {
35196
+ const userId = this.requestContext.get("userId");
35197
+ const tenantId = this.requestContext.get("tenantId");
35198
+ const contextClaims = {};
35199
+ if (userId) {
35200
+ contextClaims.user_id = userId;
35201
+ }
35202
+ if (tenantId) {
35203
+ contextClaims.tenant_id = tenantId;
35204
+ }
35205
+ if (contextClaims.user_id === void 0 && contextClaims.tenant_id === void 0) {
35206
+ return config;
35207
+ }
35208
+ return {
35209
+ ...config,
35210
+ platformAuth: {
35211
+ ...config.platformAuth,
35212
+ customClaims: {
35213
+ ...contextClaims,
35214
+ ...config.platformAuth?.customClaims || {}
35215
+ }
35216
+ }
35217
+ };
35218
+ }, "onFulfilled")
35219
+ }
35220
+ ];
35221
+ }
35186
35222
  /**
35187
35223
  * 注册全局拦截器(用于单例实例)
35188
35224
  */
package/dist/index.d.cts CHANGED
@@ -385,6 +385,7 @@ declare class PlatformHttpClientService {
385
385
  * ```
386
386
  */
387
387
  createWithGlobalInterceptors(options?: PlatformHttpClientOptions): HttpClient;
388
+ private createClaimsPreInterceptors;
388
389
  /**
389
390
  * 注册全局拦截器(用于单例实例)
390
391
  */
package/dist/index.d.ts CHANGED
@@ -385,6 +385,7 @@ declare class PlatformHttpClientService {
385
385
  * ```
386
386
  */
387
387
  createWithGlobalInterceptors(options?: PlatformHttpClientOptions): HttpClient;
388
+ private createClaimsPreInterceptors;
388
389
  /**
389
390
  * 注册全局拦截器(用于单例实例)
390
391
  */
package/dist/index.js CHANGED
@@ -35054,6 +35054,9 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35054
35054
  ...baseConfig,
35055
35055
  platform: {
35056
35056
  enabled: true
35057
+ },
35058
+ preInterceptors: {
35059
+ request: this.createClaimsPreInterceptors()
35057
35060
  }
35058
35061
  });
35059
35062
  this.protectedClient = new ProtectedHttpClient(this.client);
@@ -35128,7 +35131,10 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35128
35131
  };
35129
35132
  return new HttpClient({
35130
35133
  ...mergedConfig,
35131
- platform: mergedPlatform
35134
+ platform: mergedPlatform,
35135
+ preInterceptors: {
35136
+ request: this.createClaimsPreInterceptors()
35137
+ }
35132
35138
  });
35133
35139
  }
35134
35140
  /**
@@ -35156,6 +35162,36 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
35156
35162
  this.registerInterceptorsForClient(client);
35157
35163
  return client;
35158
35164
  }
35165
+ createClaimsPreInterceptors() {
35166
+ return [
35167
+ {
35168
+ onFulfilled: /* @__PURE__ */ __name((config) => {
35169
+ const userId = this.requestContext.get("userId");
35170
+ const tenantId = this.requestContext.get("tenantId");
35171
+ const contextClaims = {};
35172
+ if (userId) {
35173
+ contextClaims.user_id = userId;
35174
+ }
35175
+ if (tenantId) {
35176
+ contextClaims.tenant_id = tenantId;
35177
+ }
35178
+ if (contextClaims.user_id === void 0 && contextClaims.tenant_id === void 0) {
35179
+ return config;
35180
+ }
35181
+ return {
35182
+ ...config,
35183
+ platformAuth: {
35184
+ ...config.platformAuth,
35185
+ customClaims: {
35186
+ ...contextClaims,
35187
+ ...config.platformAuth?.customClaims || {}
35188
+ }
35189
+ }
35190
+ };
35191
+ }, "onFulfilled")
35192
+ }
35193
+ ];
35194
+ }
35159
35195
  /**
35160
35196
  * 注册全局拦截器(用于单例实例)
35161
35197
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.48-alpha.14",
3
+ "version": "1.1.48-alpha.15",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@lark-apaas/file-service": "^0.1.2",
43
- "@lark-apaas/http-client": "^0.1.5",
43
+ "@lark-apaas/http-client": "0.1.6-alpha.2",
44
44
  "@lark-apaas/nestjs-authnpaas": "^1.0.3",
45
45
  "@lark-apaas/nestjs-authzpaas": "^0.1.8",
46
46
  "@lark-apaas/nestjs-capability": "^0.1.13",
47
47
  "@lark-apaas/nestjs-common": "^0.1.8",
48
- "@lark-apaas/nestjs-datapaas": "1.0.20-alpha.2",
48
+ "@lark-apaas/nestjs-datapaas": "^1.0.19",
49
49
  "@lark-apaas/nestjs-logger": "^1.0.16",
50
50
  "@lark-apaas/nestjs-observable": "^0.0.11",
51
51
  "@lark-apaas/nestjs-openapi-devtools": "^1.0.10",