@opexa/portal-sdk 0.59.132 → 0.59.134

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
@@ -4222,6 +4222,11 @@ var AccountService = class {
4222
4222
  }
4223
4223
  async registerMemberAccountViaMobile(variables) {
4224
4224
  const { reCAPTCHAResponse, domain, testPass, ...others } = variables;
4225
+ const { branch, branchCode, ...input } = others.input;
4226
+ others.input = {
4227
+ ...input,
4228
+ ...branch?.trim() ? { branch } : { branchCode }
4229
+ };
4225
4230
  const res = await this.client.request(REGISTER_MEMBER_ACCOUNT_VIA_MOBILE_MUTATION, others, {
4226
4231
  headers: {
4227
4232
  ...reCAPTCHAResponse && {
@@ -4663,6 +4668,11 @@ var AccountService = class {
4663
4668
  }
4664
4669
  async registerMemberAccountByMobileNumber__next(variables) {
4665
4670
  const { reCAPTCHAResponse, domain, testPass, fingerprint, ...others } = variables;
4671
+ const { branch, branchCode, ...input } = others.input;
4672
+ others.input = {
4673
+ ...input,
4674
+ ...branch?.trim() ? { branch } : { branchCode }
4675
+ };
4666
4676
  const res = await this.client.request(REGISTER_MEMBER_ACCOUNT_BY_MOBILE_NUMBER_MUTATION__NEXT, others, {
4667
4677
  headers: {
4668
4678
  ...reCAPTCHAResponse && {
@@ -4854,6 +4864,18 @@ var AccountService = class {
4854
4864
  };
4855
4865
  }
4856
4866
  };
4867
+
4868
+ // src/utils/call-if-fn.ts
4869
+ function isFunction(value) {
4870
+ return typeof value === "function";
4871
+ }
4872
+ function callIfFn(value, ...args) {
4873
+ if (isFunction(value)) {
4874
+ return value(...args);
4875
+ } else {
4876
+ return value;
4877
+ }
4878
+ }
4857
4879
  var thumbmark_instance;
4858
4880
  async function getFingerPrint() {
4859
4881
  if (typeof window === "undefined") return null;
@@ -4939,7 +4961,7 @@ var AuthService = class {
4939
4961
  return await this.graphqlClient.request(GENERATE_OUTBOUND_SINGLE_SIGN_ON_REDIRECT_URL_MUTATION, variables);
4940
4962
  }
4941
4963
  get headers() {
4942
- const headers = new Headers(this.options.headers);
4964
+ const headers = new Headers(callIfFn(this.options).headers);
4943
4965
  headers.append("Accept", "application/json, text/plain");
4944
4966
  headers.append("Content-Type", "application/json");
4945
4967
  return headers;
@@ -5272,18 +5294,6 @@ var AuthService = class {
5272
5294
  }
5273
5295
  };
5274
5296
 
5275
- // src/utils/call-if-fn.ts
5276
- function isFunction(value) {
5277
- return typeof value === "function";
5278
- }
5279
- function callIfFn(value, ...args) {
5280
- if (isFunction(value)) {
5281
- return value(...args);
5282
- } else {
5283
- return value;
5284
- }
5285
- }
5286
-
5287
5297
  // src/services/cms-portal.service.ts
5288
5298
  var CmsPortalService = class {
5289
5299
  config;
@@ -5471,16 +5481,16 @@ var CmsPortalService = class {
5471
5481
  async getJson(path, params) {
5472
5482
  const config = callIfFn(this.config);
5473
5483
  const fetch_ = config.fetch ?? fetch;
5484
+ const headers = new Headers(config.headers);
5485
+ headers.set("Accept", "application/json");
5486
+ headers.set("Content-Type", "application/json");
5487
+ headers.set("Site-ID", config.site);
5488
+ headers.set("Platform-ID", config.platform);
5474
5489
  const req = new Request(
5475
5490
  `${config.url}${path}?${params?.toString() ?? ""}`,
5476
5491
  {
5477
5492
  method: "GET",
5478
- headers: {
5479
- Accept: "application/json",
5480
- "Content-Type": "application/json",
5481
- "Site-ID": config.site,
5482
- "Platform-ID": config.platform
5483
- }
5493
+ headers
5484
5494
  }
5485
5495
  );
5486
5496
  try {
@@ -11050,7 +11060,12 @@ var Sdk = class {
11050
11060
  url: cmsPortalUrl,
11051
11061
  site,
11052
11062
  platform: sitePlatform,
11053
- fetch: this.getFetch()
11063
+ fetch: this.getFetch(),
11064
+ headers: {
11065
+ ...this._testHeader && {
11066
+ Test: this._testHeader
11067
+ }
11068
+ }
11054
11069
  }));
11055
11070
  this._fetch = config.fetch ?? null;
11056
11071
  this._middleware = config.middleware ?? ((req) => req);
@@ -11060,6 +11075,7 @@ var Sdk = class {
11060
11075
  this.authMiddleware,
11061
11076
  this.fingerprintMiddleware,
11062
11077
  this.miscMiddleware,
11078
+ this.testHeaderMiddleware,
11063
11079
  this.middleware
11064
11080
  ],
11065
11081
  fetch: this.getFetch(),
@@ -11092,6 +11108,7 @@ var Sdk = class {
11092
11108
  middlewares: [
11093
11109
  this.fingerprintMiddleware,
11094
11110
  this.miscMiddleware,
11111
+ this.testHeaderMiddleware,
11095
11112
  this.middleware,
11096
11113
  this.publicRequestMiddleware
11097
11114
  ],
@@ -11120,15 +11137,18 @@ var Sdk = class {
11120
11137
  `${authUrl}/graphql`,
11121
11138
  graphqlClientConfig
11122
11139
  ),
11123
- fetchOptions: {
11140
+ fetchOptions: () => ({
11124
11141
  headers: {
11125
11142
  Role: "MEMBER",
11126
11143
  "Platform-Code": platform,
11127
11144
  ...!production && {
11128
11145
  "Test-Pass": ""
11146
+ },
11147
+ ...this._testHeader && {
11148
+ Test: this._testHeader
11129
11149
  }
11130
11150
  }
11131
- }
11151
+ })
11132
11152
  });
11133
11153
  const sessionManager = config.sessionStorage === "cookie" ? new SessionManagerCookie({
11134
11154
  logger,
@@ -11168,6 +11188,7 @@ var Sdk = class {
11168
11188
  }
11169
11189
  _fetch = null;
11170
11190
  _middleware;
11191
+ _testHeader = null;
11171
11192
  /**
11172
11193
  * @deprecated use `setFetch` instead
11173
11194
  */
@@ -11195,6 +11216,16 @@ var Sdk = class {
11195
11216
  get middleware() {
11196
11217
  return this._middleware;
11197
11218
  }
11219
+ /**
11220
+ * Sets a header value appended to all outgoing requests (GraphQL, auth
11221
+ * REST, and CMS portal REST). Pass `null` to remove it.
11222
+ */
11223
+ setTestHeader(value) {
11224
+ this._testHeader = value;
11225
+ }
11226
+ get testHeader() {
11227
+ return this._testHeader;
11228
+ }
11198
11229
  initMarketDomain() {
11199
11230
  if (typeof window === "undefined") return;
11200
11231
  const searchParams = new URLSearchParams(window.location.search);
@@ -11343,6 +11374,14 @@ var Sdk = class {
11343
11374
  return request;
11344
11375
  };
11345
11376
  }
11377
+ get testHeaderMiddleware() {
11378
+ return (request) => {
11379
+ if (this._testHeader) {
11380
+ request.headers.set("Test", this._testHeader);
11381
+ }
11382
+ return request;
11383
+ };
11384
+ }
11346
11385
  get publicRequestMiddleware() {
11347
11386
  return (request) => {
11348
11387
  request.headers.delete("Authorization");
@@ -11725,6 +11764,7 @@ var Sdk = class {
11725
11764
  mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
11726
11765
  realName: input.realName,
11727
11766
  birthDay: input.dateOfBirth,
11767
+ branch: input.branch,
11728
11768
  branchCode: input.branchCode,
11729
11769
  agentCode: input.agentCode,
11730
11770
  ...this.cxd && {
@@ -11787,6 +11827,7 @@ var Sdk = class {
11787
11827
  mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
11788
11828
  mobileNumberVerificationCode: input.mobileNumberVerificationCode,
11789
11829
  emailAddress: input.emailAddress,
11830
+ branch: input.branch,
11790
11831
  branchCode: input.branchCode,
11791
11832
  agentCode: input.agentCode,
11792
11833
  gigRewardsQuestDetails: input.gigRewardsQuestDetails,