@uniformdev/context 20.72.4-alpha.11 → 20.72.4-alpha.16

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.
@@ -26,6 +26,11 @@ type ClientOptions = {
26
26
  signal?: AbortSignal;
27
27
  };
28
28
  type ExceptProject<T> = Omit<T, 'projectId'>;
29
+ /**
30
+ * Uniform API 401 message for an invalid or expired bearer token.
31
+ * Prefer catching {@link BearerTokenNotValidOrExpiredError} when using ApiClient-based SDKs.
32
+ */
33
+ declare const UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE: "Bearer token not valid or expired";
29
34
  declare class ApiClientError extends Error {
30
35
  errorMessage: string;
31
36
  fetchMethod: string;
@@ -35,6 +40,13 @@ declare class ApiClientError extends Error {
35
40
  requestId?: string | undefined;
36
41
  constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number | undefined, statusText?: string | undefined, requestId?: string | undefined);
37
42
  }
43
+ /**
44
+ * Thrown when the Uniform API responds with 401 and
45
+ * {@link UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE}.
46
+ */
47
+ declare class BearerTokenNotValidOrExpiredError extends ApiClientError {
48
+ constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number, statusText?: string, requestId?: string);
49
+ }
38
50
 
39
51
  declare class ApiClient<TOptions extends ClientOptions = ClientOptions> {
40
52
  protected options: TOptions;
@@ -1966,4 +1978,4 @@ declare class CachedContextClient extends ContextClient {
1966
1978
  constructor(options: Omit<ClientOptions, 'bypassCache'>);
1967
1979
  }
1968
1980
 
1969
- export { type Aggregate, AggregateClient, type AggregateDeleteParameters, type AggregateGetParameters, type AggregateGetResponse, type AggregatePutParameters, ApiClient, ApiClientError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, CachedTestClient, type ClientOptions, ContextClient, type ContextDefinitions, type CookieCriteria, type CurrentPageCriteria, DimensionClient, type DimensionDefinition, type DimensionDisplayData, type DimensionGetParameters, type DimensionGetResponse, type EnrichmentCategory, type EnrichmentCategoryWithValues, EnrichmentClient, type EnrichmentDeleteParameters, type EnrichmentGetParameters, type EnrichmentGetResponse, type EnrichmentPutParameters, type EnrichmentValue, type EnrichmentValueDeleteParameters, type EnrichmentValuePutParameters, type EventCriteria, type ExceptProject, type LimitPolicy, ManifestClient, type ManifestGetParameters, type ManifestGetResponse, type PageViewCountCriteria, type QueryStringCriteria, type Quirk, QuirkClient, type QuirkCriteria, type QuirkDeleteParameters, type QuirkGetParameters, type QuirkGetResponse, type QuirkPutParameters, type RootSignalCriteriaGroup, SignalClient, type SignalDeleteParameters, type SignalGetParameters, type SignalGetResponse, type SignalPutParameters, type SignalWithId, type Test, TestClient, type TestDeleteParameters, type TestGetParameters, type TestGetResponse, type TestPutParameters, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, UncachedTestClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, defaultLimitPolicy, handleRateLimits, nullLimitPolicy, rewriteFiltersForApi };
1981
+ export { type Aggregate, AggregateClient, type AggregateDeleteParameters, type AggregateGetParameters, type AggregateGetResponse, type AggregatePutParameters, ApiClient, ApiClientError, BearerTokenNotValidOrExpiredError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, CachedTestClient, type ClientOptions, ContextClient, type ContextDefinitions, type CookieCriteria, type CurrentPageCriteria, DimensionClient, type DimensionDefinition, type DimensionDisplayData, type DimensionGetParameters, type DimensionGetResponse, type EnrichmentCategory, type EnrichmentCategoryWithValues, EnrichmentClient, type EnrichmentDeleteParameters, type EnrichmentGetParameters, type EnrichmentGetResponse, type EnrichmentPutParameters, type EnrichmentValue, type EnrichmentValueDeleteParameters, type EnrichmentValuePutParameters, type EventCriteria, type ExceptProject, type LimitPolicy, ManifestClient, type ManifestGetParameters, type ManifestGetResponse, type PageViewCountCriteria, type QueryStringCriteria, type Quirk, QuirkClient, type QuirkCriteria, type QuirkDeleteParameters, type QuirkGetParameters, type QuirkGetResponse, type QuirkPutParameters, type RootSignalCriteriaGroup, SignalClient, type SignalDeleteParameters, type SignalGetParameters, type SignalGetResponse, type SignalPutParameters, type SignalWithId, type Test, TestClient, type TestDeleteParameters, type TestGetParameters, type TestGetResponse, type TestPutParameters, UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, UncachedTestClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, defaultLimitPolicy, handleRateLimits, nullLimitPolicy, rewriteFiltersForApi };
package/dist/api/api.d.ts CHANGED
@@ -26,6 +26,11 @@ type ClientOptions = {
26
26
  signal?: AbortSignal;
27
27
  };
28
28
  type ExceptProject<T> = Omit<T, 'projectId'>;
29
+ /**
30
+ * Uniform API 401 message for an invalid or expired bearer token.
31
+ * Prefer catching {@link BearerTokenNotValidOrExpiredError} when using ApiClient-based SDKs.
32
+ */
33
+ declare const UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE: "Bearer token not valid or expired";
29
34
  declare class ApiClientError extends Error {
30
35
  errorMessage: string;
31
36
  fetchMethod: string;
@@ -35,6 +40,13 @@ declare class ApiClientError extends Error {
35
40
  requestId?: string | undefined;
36
41
  constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number | undefined, statusText?: string | undefined, requestId?: string | undefined);
37
42
  }
43
+ /**
44
+ * Thrown when the Uniform API responds with 401 and
45
+ * {@link UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE}.
46
+ */
47
+ declare class BearerTokenNotValidOrExpiredError extends ApiClientError {
48
+ constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number, statusText?: string, requestId?: string);
49
+ }
38
50
 
39
51
  declare class ApiClient<TOptions extends ClientOptions = ClientOptions> {
40
52
  protected options: TOptions;
@@ -1966,4 +1978,4 @@ declare class CachedContextClient extends ContextClient {
1966
1978
  constructor(options: Omit<ClientOptions, 'bypassCache'>);
1967
1979
  }
1968
1980
 
1969
- export { type Aggregate, AggregateClient, type AggregateDeleteParameters, type AggregateGetParameters, type AggregateGetResponse, type AggregatePutParameters, ApiClient, ApiClientError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, CachedTestClient, type ClientOptions, ContextClient, type ContextDefinitions, type CookieCriteria, type CurrentPageCriteria, DimensionClient, type DimensionDefinition, type DimensionDisplayData, type DimensionGetParameters, type DimensionGetResponse, type EnrichmentCategory, type EnrichmentCategoryWithValues, EnrichmentClient, type EnrichmentDeleteParameters, type EnrichmentGetParameters, type EnrichmentGetResponse, type EnrichmentPutParameters, type EnrichmentValue, type EnrichmentValueDeleteParameters, type EnrichmentValuePutParameters, type EventCriteria, type ExceptProject, type LimitPolicy, ManifestClient, type ManifestGetParameters, type ManifestGetResponse, type PageViewCountCriteria, type QueryStringCriteria, type Quirk, QuirkClient, type QuirkCriteria, type QuirkDeleteParameters, type QuirkGetParameters, type QuirkGetResponse, type QuirkPutParameters, type RootSignalCriteriaGroup, SignalClient, type SignalDeleteParameters, type SignalGetParameters, type SignalGetResponse, type SignalPutParameters, type SignalWithId, type Test, TestClient, type TestDeleteParameters, type TestGetParameters, type TestGetResponse, type TestPutParameters, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, UncachedTestClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, defaultLimitPolicy, handleRateLimits, nullLimitPolicy, rewriteFiltersForApi };
1981
+ export { type Aggregate, AggregateClient, type AggregateDeleteParameters, type AggregateGetParameters, type AggregateGetResponse, type AggregatePutParameters, ApiClient, ApiClientError, BearerTokenNotValidOrExpiredError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, CachedTestClient, type ClientOptions, ContextClient, type ContextDefinitions, type CookieCriteria, type CurrentPageCriteria, DimensionClient, type DimensionDefinition, type DimensionDisplayData, type DimensionGetParameters, type DimensionGetResponse, type EnrichmentCategory, type EnrichmentCategoryWithValues, EnrichmentClient, type EnrichmentDeleteParameters, type EnrichmentGetParameters, type EnrichmentGetResponse, type EnrichmentPutParameters, type EnrichmentValue, type EnrichmentValueDeleteParameters, type EnrichmentValuePutParameters, type EventCriteria, type ExceptProject, type LimitPolicy, ManifestClient, type ManifestGetParameters, type ManifestGetResponse, type PageViewCountCriteria, type QueryStringCriteria, type Quirk, QuirkClient, type QuirkCriteria, type QuirkDeleteParameters, type QuirkGetParameters, type QuirkGetResponse, type QuirkPutParameters, type RootSignalCriteriaGroup, SignalClient, type SignalDeleteParameters, type SignalGetParameters, type SignalGetResponse, type SignalPutParameters, type SignalWithId, type Test, TestClient, type TestDeleteParameters, type TestGetParameters, type TestGetResponse, type TestPutParameters, UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, UncachedTestClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, defaultLimitPolicy, handleRateLimits, nullLimitPolicy, rewriteFiltersForApi };
package/dist/api/api.js CHANGED
@@ -41,6 +41,7 @@ __export(api_exports, {
41
41
  AggregateClient: () => AggregateClient,
42
42
  ApiClient: () => ApiClient,
43
43
  ApiClientError: () => ApiClientError,
44
+ BearerTokenNotValidOrExpiredError: () => BearerTokenNotValidOrExpiredError,
44
45
  CachedAggregateClient: () => CachedAggregateClient,
45
46
  CachedContextClient: () => CachedContextClient,
46
47
  CachedDimensionClient: () => CachedDimensionClient,
@@ -56,6 +57,7 @@ __export(api_exports, {
56
57
  QuirkClient: () => QuirkClient,
57
58
  SignalClient: () => SignalClient,
58
59
  TestClient: () => TestClient,
60
+ UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE: () => UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE,
59
61
  UncachedAggregateClient: () => UncachedAggregateClient,
60
62
  UncachedContextClient: () => UncachedContextClient,
61
63
  UncachedDimensionClient: () => UncachedDimensionClient,
@@ -78,6 +80,7 @@ module.exports = __toCommonJS(api_exports);
78
80
  var import_p_limit = __toESM(require("p-limit"));
79
81
  var nullLimitPolicy = async (func) => await func();
80
82
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
83
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
81
84
  var ApiClientError = class _ApiClientError extends Error {
82
85
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
83
86
  super(
@@ -93,6 +96,12 @@ var ApiClientError = class _ApiClientError extends Error {
93
96
  Object.setPrototypeOf(this, _ApiClientError.prototype);
94
97
  }
95
98
  };
99
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
100
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
101
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
102
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
103
+ }
104
+ };
96
105
 
97
106
  // src/api/ApiClient.ts
98
107
  var ApiClient = class _ApiClient {
@@ -128,7 +137,7 @@ var ApiClient = class _ApiClient {
128
137
  }
129
138
  async apiClientWithResponse(fetchUri, options) {
130
139
  return this.options.limitPolicy(async () => {
131
- var _a;
140
+ var _a, _b;
132
141
  const coreHeaders = this.options.apiKey ? {
133
142
  "x-api-key": this.options.apiKey
134
143
  } : {
@@ -164,9 +173,19 @@ var ApiClient = class _ApiClient {
164
173
  } catch (e) {
165
174
  message = `General error`;
166
175
  }
176
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
177
+ throw new BearerTokenNotValidOrExpiredError(
178
+ message,
179
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
180
+ fetchUri.toString(),
181
+ apiResponse.status,
182
+ apiResponse.statusText,
183
+ _ApiClient.getRequestId(apiResponse)
184
+ );
185
+ }
167
186
  throw new ApiClientError(
168
187
  message,
169
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
188
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
170
189
  fetchUri.toString(),
171
190
  apiResponse.status,
172
191
  apiResponse.statusText,
@@ -637,6 +656,7 @@ var CachedContextClient = class extends ContextClient {
637
656
  AggregateClient,
638
657
  ApiClient,
639
658
  ApiClientError,
659
+ BearerTokenNotValidOrExpiredError,
640
660
  CachedAggregateClient,
641
661
  CachedContextClient,
642
662
  CachedDimensionClient,
@@ -652,6 +672,7 @@ var CachedContextClient = class extends ContextClient {
652
672
  QuirkClient,
653
673
  SignalClient,
654
674
  TestClient,
675
+ UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE,
655
676
  UncachedAggregateClient,
656
677
  UncachedContextClient,
657
678
  UncachedDimensionClient,
package/dist/api/api.mjs CHANGED
@@ -12,6 +12,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12
12
  import pLimit from "p-limit";
13
13
  var nullLimitPolicy = async (func) => await func();
14
14
  var defaultLimitPolicy = pLimit(6);
15
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
15
16
  var ApiClientError = class _ApiClientError extends Error {
16
17
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
17
18
  super(
@@ -27,6 +28,12 @@ var ApiClientError = class _ApiClientError extends Error {
27
28
  Object.setPrototypeOf(this, _ApiClientError.prototype);
28
29
  }
29
30
  };
31
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
32
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
33
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
34
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
35
+ }
36
+ };
30
37
 
31
38
  // src/api/ApiClient.ts
32
39
  var ApiClient = class _ApiClient {
@@ -62,7 +69,7 @@ var ApiClient = class _ApiClient {
62
69
  }
63
70
  async apiClientWithResponse(fetchUri, options) {
64
71
  return this.options.limitPolicy(async () => {
65
- var _a;
72
+ var _a, _b;
66
73
  const coreHeaders = this.options.apiKey ? {
67
74
  "x-api-key": this.options.apiKey
68
75
  } : {
@@ -98,9 +105,19 @@ var ApiClient = class _ApiClient {
98
105
  } catch (e) {
99
106
  message = `General error`;
100
107
  }
108
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
109
+ throw new BearerTokenNotValidOrExpiredError(
110
+ message,
111
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
112
+ fetchUri.toString(),
113
+ apiResponse.status,
114
+ apiResponse.statusText,
115
+ _ApiClient.getRequestId(apiResponse)
116
+ );
117
+ }
101
118
  throw new ApiClientError(
102
119
  message,
103
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
120
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
104
121
  fetchUri.toString(),
105
122
  apiResponse.status,
106
123
  apiResponse.statusText,
@@ -570,6 +587,7 @@ export {
570
587
  AggregateClient,
571
588
  ApiClient,
572
589
  ApiClientError,
590
+ BearerTokenNotValidOrExpiredError,
573
591
  CachedAggregateClient,
574
592
  CachedContextClient,
575
593
  CachedDimensionClient,
@@ -585,6 +603,7 @@ export {
585
603
  QuirkClient,
586
604
  SignalClient,
587
605
  TestClient,
606
+ UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE,
588
607
  UncachedAggregateClient,
589
608
  UncachedContextClient,
590
609
  UncachedDimensionClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "20.72.4-alpha.11+e751b54a11",
3
+ "version": "20.72.4-alpha.16+0254f3a82e",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "e751b54a117bad0887d6bfb74c3ff9ccd0b21d88"
73
+ "gitHead": "0254f3a82ed24bc02a26abbb3b7c453c44f0f8a8"
74
74
  }