@laiye_packages/uci 1.0.4 → 1.0.6

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.
@@ -1,5 +1,5 @@
1
1
  import { LYObject } from '../../object';
2
- import { LYAppHttpClient, type IHeaderProvider } from '../../http';
2
+ import { LYAppHttpClient, LYOrganizationHttpClient, type IHeaderProvider } from '../../http';
3
3
  import type { LYAppPermission } from '../../permission';
4
4
  import { LYCrypto } from '../../crypto';
5
5
  import { LYi18n, ILYi18n, LYKeyofLang } from '../../i18n';
@@ -71,8 +71,12 @@ export declare class LYBaseApp extends LYObject {
71
71
  protected _createHttpClient(): LYAppHttpClient;
72
72
  load(): Promise<void>;
73
73
  protected doLoad(): Promise<void>;
74
+ protected getBaseUrl(): string;
74
75
  private initI18n;
75
76
  getI18nResourceUrl(relativeUrl: string, lang?: LYKeyofLang): string;
76
77
  getComponent<T>(componentName: string): Promise<T>;
77
78
  private loadRemoteComponents;
78
79
  }
80
+ export declare class LYBaseOrganizationApp extends LYBaseApp {
81
+ protected _createHttpClient(): LYOrganizationHttpClient;
82
+ }
@@ -1,5 +1,5 @@
1
1
  import { LYEnv } from '../env';
2
- import { LYBaseApp, ORGANIZATION_APP_NAME, TENANT_APP_NAME } from './base';
2
+ import { LYBaseApp, LYBaseOrganizationApp, ORGANIZATION_APP_NAME, TENANT_APP_NAME } from './base';
3
3
  import { LYOrganizationApp, SSOConfig } from './organization';
4
4
  import { LYTenantApp } from './tenant';
5
5
  import { LYTenantSession } from './tenant/session';
@@ -8,7 +8,7 @@ import { LYGatewayAuthorizer } from './organization/authorizer/gateway';
8
8
  import { LYDirectAuthorizer } from './organization/authorizer/direct';
9
9
  import { LYRedirectAuthorizer } from './organization/authorizer/redirect';
10
10
  import { LYTenantAuthorizer } from './tenant/authorizer';
11
- declare class LYApp extends LYBaseApp {
11
+ declare class LYApp extends LYBaseOrganizationApp {
12
12
  }
13
13
  export type { SSOConfig };
14
14
  export { LYApp, LYBaseApp, LYTenantApp, LYOrganizationApp, LYTenantSession, TENANT_APP_NAME, ORGANIZATION_APP_NAME, LYEnv, LYWebAuthorizer, LYGatewayAuthorizer, LYDirectAuthorizer, LYRedirectAuthorizer, LYTenantAuthorizer };
@@ -1,4 +1,4 @@
1
- import { LYBaseApp } from '../../base';
1
+ import { LYBaseOrganizationApp } from '../../base';
2
2
  import { LYSessionApi } from '../api/session';
3
3
  import type { SSOConfig } from '../api/session';
4
4
  import { LYUserApi } from '../api/user';
@@ -6,8 +6,7 @@ import type { LYBaseAuthorizer } from '../authorizer/base';
6
6
  import { LYLicenseApi } from '../api/license';
7
7
  import { LYOEMApi } from '../api/oem';
8
8
  import { LYVerificationCodesApi } from '../api/verificationCodes';
9
- import { LYAppHttpClient } from '../../../http';
10
- declare class LYOrganizationApp extends LYBaseApp {
9
+ declare class LYOrganizationApp extends LYBaseOrganizationApp {
11
10
  static _instance?: LYOrganizationApp;
12
11
  private _sessionApi;
13
12
  private _userApi;
@@ -17,7 +16,6 @@ declare class LYOrganizationApp extends LYBaseApp {
17
16
  private _verificationCodesApi;
18
17
  constructor(name: string, version: string, description: string);
19
18
  static get instance(): LYOrganizationApp;
20
- _createHttpClient(): LYAppHttpClient;
21
19
  get sessionApi(): LYSessionApi;
22
20
  get userApi(): LYUserApi;
23
21
  get oemApi(): LYOEMApi;
@@ -26,6 +24,5 @@ declare class LYOrganizationApp extends LYBaseApp {
26
24
  protected doLoad(): Promise<void>;
27
25
  private mergeOEM;
28
26
  getAuthorizer<T extends LYBaseAuthorizer = LYBaseAuthorizer>(name?: string): T;
29
- private getBaseUrl;
30
27
  }
31
28
  export { LYOrganizationApp, SSOConfig };
@@ -12,6 +12,7 @@ declare class LYTenantApp extends LYBaseApp {
12
12
  private _authorizer;
13
13
  constructor(name: string, version: string, description: string);
14
14
  _createHttpClient(): LYAppHttpClient;
15
+ getBaseUrl(): string;
15
16
  static get instance(): LYTenantApp;
16
17
  get tenantApi(): LYTenantApi;
17
18
  get userApi(): LYUserApi;
package/dist/index.js CHANGED
@@ -3624,7 +3624,7 @@ var __webpack_modules__ = {
3624
3624
  }, O.en = D[g], O.Ls = D, O.p = {}, O;
3625
3625
  });
3626
3626
  },
3627
- "../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.5.8_@swc+helpers@0.5.18__react-dom@18.3.1_r_dcbcwp56l5mltx2br2csa6d5sy/node_modules/@module-federation/enhanced/dist/src/runtime.js": function(__unused_webpack_module, exports, __webpack_require__) {
3627
+ "../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.4_react-dom@18.3.1_react@18.3.1_typescript@5.9.3_webpack@5.104.1/node_modules/@module-federation/enhanced/dist/src/runtime.js": function(__unused_webpack_module, exports, __webpack_require__) {
3628
3628
  var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
3629
3629
  if (void 0 === k2) k2 = k;
3630
3630
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -9703,7 +9703,7 @@ class LYAppHttpError extends LYBaseHttpError {
9703
9703
  return this._code;
9704
9704
  }
9705
9705
  }
9706
- var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.5.8_@swc+helpers@0.5.18__react-dom@18.3.1_r_dcbcwp56l5mltx2br2csa6d5sy/node_modules/@module-federation/enhanced/dist/src/runtime.js");
9706
+ var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.4_react-dom@18.3.1_react@18.3.1_typescript@5.9.3_webpack@5.104.1/node_modules/@module-federation/enhanced/dist/src/runtime.js");
9707
9707
  class LYAppPermission extends LYObject {
9708
9708
  constructor(app_name, codes){
9709
9709
  super(), this._codes = {};
@@ -10671,6 +10671,7 @@ class base_LYBaseApp extends LYObject {
10671
10671
  this._sessionStore = new LYSessionStorage(prefix);
10672
10672
  this._cloudStore = new LYCloudStorage(prefix);
10673
10673
  this._env = new LYEnv(this._name);
10674
+ this.env.baseUrl = this.getBaseUrl();
10674
10675
  this._httpClient = this._createHttpClient();
10675
10676
  }
10676
10677
  get location() {
@@ -10721,9 +10722,10 @@ class base_LYBaseApp extends LYObject {
10721
10722
  return crypto_crypto;
10722
10723
  }
10723
10724
  _createHttpClient() {
10724
- return new http_LYAppHttpClient(this._name, {
10725
+ return new LYOrganizationHttpClient(this._name, {
10725
10726
  get headers () {
10726
- return base_LYBaseApp.getHeaderProvider().headers;
10727
+ const headers = base_LYBaseApp.getHeaderProvider()?.headers;
10728
+ return headers;
10727
10729
  }
10728
10730
  });
10729
10731
  }
@@ -10737,6 +10739,50 @@ class base_LYBaseApp extends LYObject {
10737
10739
  async doLoad() {
10738
10740
  await this.initI18n();
10739
10741
  }
10742
+ getBaseUrl() {
10743
+ const config = LYConfig.get();
10744
+ const url = new URL(window.location.href);
10745
+ let baseUrl = "";
10746
+ for (const pattern of config.host_patterns){
10747
+ if (!pattern.includes("{tenant_name}") && pattern.startsWith(url.origin)) {
10748
+ const parts = url.pathname.split('/');
10749
+ const index = parts.findIndex((part)=>'view' === part);
10750
+ let tenantName = parts[index + 2];
10751
+ if (!tenantName) throw new Error('tenantName not found');
10752
+ baseUrl = `${pattern}/view/${this.name}/${tenantName}`;
10753
+ this._tenantName = tenantName;
10754
+ return baseUrl;
10755
+ }
10756
+ let filterhost = pattern.replace(/\./g, "\\.").replace("{tenant_name}", "([a-zA-Z0-9_\\-]+)");
10757
+ const reg = new RegExp(`^${filterhost}(?::\\d+)?(?:/.*)?$`);
10758
+ const matched = url.toString().match(reg);
10759
+ if (matched && matched[1]) {
10760
+ const tenantName = matched[1];
10761
+ const host = pattern.replace("{tenant_name}", tenantName);
10762
+ baseUrl = `${host}/view/${this.name}`;
10763
+ this._tenantName = tenantName;
10764
+ return baseUrl;
10765
+ }
10766
+ }
10767
+ try {
10768
+ if ('development' === process.env.NODE_ENV) {
10769
+ baseUrl = `${window.origin}/view/${this.name}/laiye`;
10770
+ this._tenantName = "laiye";
10771
+ return baseUrl;
10772
+ }
10773
+ const parts = url.pathname.split('/');
10774
+ const index = parts.findIndex((part)=>'view' === part);
10775
+ if (-1 === index) throw new Error('view not found in URL');
10776
+ let tenantName = parts[index + 2];
10777
+ if (!tenantName) throw new Error('tenantName not found');
10778
+ baseUrl = `${window.origin}/view/${this.name}/${tenantName}`;
10779
+ this._tenantName = tenantName;
10780
+ return baseUrl;
10781
+ } catch (error) {
10782
+ console.error('Error getting base URL:', error);
10783
+ }
10784
+ return window.origin;
10785
+ }
10740
10786
  async initI18n() {
10741
10787
  try {
10742
10788
  const resources = await this.provider.provideI18nResource(this);
@@ -10793,6 +10839,24 @@ base_LYBaseApp = app_base_ts_decorate([
10793
10839
  String
10794
10840
  ])
10795
10841
  ], base_LYBaseApp);
10842
+ class LYBaseOrganizationApp extends base_LYBaseApp {
10843
+ _createHttpClient() {
10844
+ const lang = this._i18n.lang;
10845
+ return new LYOrganizationHttpClient(this.name, {
10846
+ get headers () {
10847
+ const session = LYSession.get();
10848
+ if (!session) return;
10849
+ return {
10850
+ Authorization: `Bearer ${session.token}`,
10851
+ 'Accept-Language': lang
10852
+ };
10853
+ }
10854
+ });
10855
+ }
10856
+ }
10857
+ LYBaseOrganizationApp = app_base_ts_decorate([
10858
+ register('LYBaseOrganizationApp')
10859
+ ], LYBaseOrganizationApp);
10796
10860
  class session_LYSessionApi {
10797
10861
  constructor(httpClient){
10798
10862
  this._httpClient = httpClient;
@@ -11247,10 +11311,9 @@ function app_ts_decorate(decorators, target, key, desc) {
11247
11311
  function app_ts_metadata(k, v) {
11248
11312
  if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11249
11313
  }
11250
- class LYOrganizationApp extends base_LYBaseApp {
11314
+ class LYOrganizationApp extends LYBaseOrganizationApp {
11251
11315
  constructor(name1, version, description){
11252
11316
  super(name1, version, description);
11253
- this.env.baseUrl = this.getBaseUrl();
11254
11317
  LYOrganizationApp._instance = this;
11255
11318
  this._sessionApi = new session_LYSessionApi(this.httpClient);
11256
11319
  this._userApi = new LYUserApi(this.httpClient);
@@ -11268,19 +11331,6 @@ class LYOrganizationApp extends base_LYBaseApp {
11268
11331
  if (!LYOrganizationApp._instance) throw new Error('LYOrganizationApp not initialized');
11269
11332
  return LYOrganizationApp._instance;
11270
11333
  }
11271
- _createHttpClient() {
11272
- const lang = this._i18n.lang;
11273
- return new LYOrganizationHttpClient(this.name, {
11274
- get headers () {
11275
- const session = LYSession.get();
11276
- if (!session) return;
11277
- return {
11278
- Authorization: `Bearer ${session.token}`,
11279
- 'Accept-Language': lang
11280
- };
11281
- }
11282
- });
11283
- }
11284
11334
  get sessionApi() {
11285
11335
  return this._sessionApi;
11286
11336
  }
@@ -11315,50 +11365,6 @@ class LYOrganizationApp extends base_LYBaseApp {
11315
11365
  if (!this._authorizers[type]) throw new Error(`Authorizer ${type} not found`);
11316
11366
  return this._authorizers[type];
11317
11367
  }
11318
- getBaseUrl() {
11319
- const config = LYConfig.get();
11320
- const url = new URL(window.location.href);
11321
- let baseUrl = "";
11322
- for (const pattern of config.host_patterns){
11323
- if (!pattern.includes("{tenant_name}") && pattern.startsWith(url.origin)) {
11324
- const parts = url.pathname.split('/');
11325
- const index = parts.findIndex((part)=>'view' === part);
11326
- let tenantName = parts[index + 2];
11327
- if (!tenantName) throw new Error('tenantName not found');
11328
- baseUrl = `${pattern}/view/${this.name}/${tenantName}`;
11329
- this._tenantName = tenantName;
11330
- return baseUrl;
11331
- }
11332
- let filterhost = pattern.replace(/\./g, "\\.").replace("{tenant_name}", "([a-zA-Z0-9_\\-]+)");
11333
- const reg = new RegExp(`^${filterhost}(?::\\d+)?(?:/.*)?$`);
11334
- const matched = url.toString().match(reg);
11335
- if (matched && matched[1]) {
11336
- const tenantName = matched[1];
11337
- const host = pattern.replace("{tenant_name}", tenantName);
11338
- baseUrl = `${host}/view/${this.name}`;
11339
- this._tenantName = tenantName;
11340
- return baseUrl;
11341
- }
11342
- }
11343
- try {
11344
- if ('development' === process.env.NODE_ENV) {
11345
- baseUrl = `${window.origin}/view/${this.name}/laiye`;
11346
- this._tenantName = "laiye";
11347
- return baseUrl;
11348
- }
11349
- const parts = url.pathname.split('/');
11350
- const index = parts.findIndex((part)=>'view' === part);
11351
- if (-1 === index) throw new Error('view not found in URL');
11352
- let tenantName = parts[index + 2];
11353
- if (!tenantName) throw new Error('tenantName not found');
11354
- baseUrl = `${window.origin}/view/${this.name}/${tenantName}`;
11355
- this._tenantName = tenantName;
11356
- return baseUrl;
11357
- } catch (error) {
11358
- console.error('Error getting base URL:', error);
11359
- }
11360
- return window.origin;
11361
- }
11362
11368
  }
11363
11369
  LYOrganizationApp = app_ts_decorate([
11364
11370
  register('LYOrganizationApp'),
@@ -11734,6 +11740,9 @@ class LYTenantApp extends base_LYBaseApp {
11734
11740
  }
11735
11741
  });
11736
11742
  }
11743
+ getBaseUrl() {
11744
+ return window.origin;
11745
+ }
11737
11746
  static get instance() {
11738
11747
  if (!LYTenantApp._instance) throw new Error('LYTenantApp not initialized');
11739
11748
  return LYTenantApp._instance;
@@ -11769,7 +11778,7 @@ function src_app_ts_decorate(decorators, target, key, desc) {
11769
11778
  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;
11770
11779
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11771
11780
  }
11772
- class LYApp extends base_LYBaseApp {
11781
+ class LYApp extends LYBaseOrganizationApp {
11773
11782
  }
11774
11783
  LYApp = src_app_ts_decorate([
11775
11784
  register('LYApp')