@uniformdev/context 17.7.1-alpha.140 → 17.7.1-alpha.169

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/api/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as AggregateGetParameters, a as AggregateGetResponse, b as AggregatePutParameters, c as AggregateDeleteParameters, D as DimensionDefinition, d as DimensionGetParameters, e as DimensionGetResponse, E as EnrichmentGetParameters, f as EnrichmentGetResponse, g as EnrichmentPutParameters, h as EnrichmentDeleteParameters, i as EnrichmentValuePutParameters, j as EnrichmentValueDeleteParameters, M as ManifestGetParameters, k as ManifestGetResponse, Q as QuirkGetParameters, l as QuirkGetResponse, m as QuirkPutParameters, n as QuirkDeleteParameters, S as SignalGetParameters, o as SignalGetResponse, p as SignalPutParameters, q as SignalDeleteParameters, T as TestGetParameters, r as TestGetResponse, s as TestPutParameters, t as TestDeleteParameters } from '../contextTypes-defd0c5d.js';
2
- export { x as Aggregate, c as AggregateDeleteParameters, A as AggregateGetParameters, a as AggregateGetResponse, b as AggregatePutParameters, C as ContextDefinitions, F as CookieCriteria, J as CurrentPageCriteria, D as DimensionDefinition, d as DimensionGetParameters, e as DimensionGetResponse, u as EnrichmentCategory, v as EnrichmentCategoryWithValues, h as EnrichmentDeleteParameters, E as EnrichmentGetParameters, f as EnrichmentGetResponse, g as EnrichmentPutParameters, w as EnrichmentValue, j as EnrichmentValueDeleteParameters, i as EnrichmentValuePutParameters, I as EventCriteria, M as ManifestGetParameters, k as ManifestGetResponse, P as PageViewCountCriteria, G as QueryStringCriteria, y as Quirk, H as QuirkCriteria, n as QuirkDeleteParameters, Q as QuirkGetParameters, l as QuirkGetResponse, m as QuirkPutParameters, R as RootSignalCriteriaGroup, q as SignalDeleteParameters, S as SignalGetParameters, o as SignalGetResponse, p as SignalPutParameters, B as SignalWithId, z as Test, t as TestDeleteParameters, T as TestGetParameters, r as TestGetResponse, s as TestPutParameters } from '../contextTypes-defd0c5d.js';
2
+ export { x as Aggregate, C as ContextDefinitions, F as CookieCriteria, J as CurrentPageCriteria, u as EnrichmentCategory, v as EnrichmentCategoryWithValues, w as EnrichmentValue, I as EventCriteria, P as PageViewCountCriteria, G as QueryStringCriteria, y as Quirk, H as QuirkCriteria, R as RootSignalCriteriaGroup, B as SignalWithId, z as Test } from '../contextTypes-defd0c5d.js';
3
3
  import { I as ManifestV2 } from '../types-1c9fdbd2.js';
4
4
  import '../v2-manifest.swagger-74a3dcac.js';
5
5
  import 'mitt';
@@ -186,4 +186,4 @@ declare class CachedContextClient extends ContextClient {
186
186
  constructor(options: Omit<ClientOptions, 'bypassCache'>);
187
187
  }
188
188
 
189
- export { AggregateClient, ApiClient, ApiClientError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, ClientOptions, ContextClient, DimensionClient, DimensionDisplayData, EnrichmentClient, ExceptProject, LimitPolicy, ManifestClient, QuirkClient, SignalClient, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, nullLimitPolicy };
189
+ export { AggregateClient, AggregateDeleteParameters, AggregateGetParameters, AggregateGetResponse, AggregatePutParameters, ApiClient, ApiClientError, CachedAggregateClient, CachedContextClient, CachedDimensionClient, CachedEnrichmentClient, CachedManifestClient, CachedQuirkClient, CachedSignalClient, ClientOptions, ContextClient, DimensionClient, DimensionDefinition, DimensionDisplayData, DimensionGetParameters, DimensionGetResponse, EnrichmentClient, EnrichmentDeleteParameters, EnrichmentGetParameters, EnrichmentGetResponse, EnrichmentPutParameters, EnrichmentValueDeleteParameters, EnrichmentValuePutParameters, ExceptProject, LimitPolicy, ManifestClient, ManifestGetParameters, ManifestGetResponse, QuirkClient, QuirkDeleteParameters, QuirkGetParameters, QuirkGetResponse, QuirkPutParameters, SignalClient, SignalDeleteParameters, SignalGetParameters, SignalGetResponse, SignalPutParameters, TestDeleteParameters, TestGetParameters, TestGetResponse, TestPutParameters, UncachedAggregateClient, UncachedContextClient, UncachedDimensionClient, UncachedEnrichmentClient, UncachedManifestClient, UncachedQuirkClient, UncachedSignalClient, computeDimensionDefinitionDisplayData, computeDimensionDisplayData, computeDimensionDisplayName, nullLimitPolicy };
package/dist/api/api.js CHANGED
@@ -1,2 +1,558 @@
1
- "use strict";var S=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ie=(r,e,t)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var oe=(r,e)=>{for(var t in e)S(r,t,{get:e[t],enumerable:!0})},ne=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of re(e))!se.call(r,o)&&o!==t&&S(r,o,{get:()=>e[o],enumerable:!(s=te(e,o))||s.enumerable});return r};var ae=r=>ne(S({},"__esModule",{value:!0}),r);var m=(r,e,t)=>(ie(r,typeof e!="symbol"?e+"":e,t),t),pe=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var i=(r,e,t)=>(pe(r,e,"read from private field"),t?t.call(r):e.get(r)),c=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)};var me={};oe(me,{AggregateClient:()=>y,ApiClient:()=>n,ApiClientError:()=>P,CachedAggregateClient:()=>J,CachedContextClient:()=>_,CachedDimensionClient:()=>M,CachedEnrichmentClient:()=>K,CachedManifestClient:()=>z,CachedQuirkClient:()=>F,CachedSignalClient:()=>X,ContextClient:()=>N,DimensionClient:()=>f,EnrichmentClient:()=>u,ManifestClient:()=>x,QuirkClient:()=>g,SignalClient:()=>d,UncachedAggregateClient:()=>L,UncachedContextClient:()=>Z,UncachedDimensionClient:()=>V,UncachedEnrichmentClient:()=>H,UncachedManifestClient:()=>q,UncachedQuirkClient:()=>B,UncachedSignalClient:()=>W,computeDimensionDefinitionDisplayData:()=>ee,computeDimensionDisplayData:()=>ce,computeDimensionDisplayName:()=>le,nullLimitPolicy:()=>v});module.exports=ae(me);var v=async r=>await r(),P=class extends Error{constructor(t,s,o,a,p,l){super(`${t}
2
- ${a}${p?" "+p:""} (${s} ${o}${l?` Request ID: ${l}`:""})`);this.errorMessage=t;this.fetchMethod=s;this.fetchUri=o;this.statusCode=a;this.statusText=p;this.requestId=l;Object.setPrototypeOf(this,P.prototype)}};var n=class{constructor(e){m(this,"options");var s,o,a,p,l,h;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof window!="undefined")t=window.fetch.bind(window);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(s=e.apiHost)!=null?s:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(a=e.projectId)!=null?a:null,bearerToken:(p=e.bearerToken)!=null?p:null,limitPolicy:(l=e.limitPolicy)!=null?l:v,bypassCache:(h=e.bypassCache)!=null?h:!1}}async apiClient(e,t){return this.options.limitPolicy(async()=>{var a;let s=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(s["x-bypass-cache"]="true");let o=await this.options.fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...s}});if(!o.ok){let p="";try{let l=await o.text();try{let h=JSON.parse(l);h.errorMessage?p=Array.isArray(h.errorMessage)?h.errorMessage.join(", "):h.errorMessage:p=l}catch(h){p=l}}catch(l){p="General error"}throw new P(p,(a=t==null?void 0:t.method)!=null?a:"GET",e.toString(),o.status,o.statusText,n.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let s=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,a])=>{var p;typeof a!="undefined"&&a!==null&&s.searchParams.append(o,Array.isArray(a)?a.join(","):(p=a==null?void 0:a.toString())!=null?p:"")}),s}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}};var b,U=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(U,b),{...e,projectId:t});return await this.apiClient(s)}async upsert(e){let t=this.createUrl(i(U,b));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(i(U,b));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},y=U;b=new WeakMap,c(y,b,"/api/v2/aggregate");var L=class extends y{constructor(e){super({...e,bypassCache:!0})}},J=class extends y{constructor(e){super({...e,bypassCache:!1})}};var $="_";function ee(r){let e=r.category==="ENR"?"Enrichment":r.category==="SIG"?"Signal":r.subcategory==="1"?"Intent":r.subcategory==="0"?"Audience":"Aggregate";return{dim:r.dim,name:r.name,type:e,category:r.category==="ENR"?r.subcategory:void 0}}function ce(r,e){var t,s,o,a;if((s=(t=e.project.pz)==null?void 0:t.agg)!=null&&s[r])return{dim:r,name:r,type:"Aggregate"};if((a=(o=e.project.pz)==null?void 0:o.sig)!=null&&a[r])return{dim:r,name:r,type:"Signal"};if(r.indexOf($)>=0){let[p,l]=r.split($);return{dim:r,name:l,type:"Enrichment",category:p}}}function le(r){let{type:e,name:t}=ee(r);return`${e}: ${t}`}var A,Q=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(Q,A),{...e,projectId:t});return await this.apiClient(s)}},f=Q;A=new WeakMap,c(f,A,"/api/v2/dimension");var V=class extends f{constructor(e){super({...e,bypassCache:!0})}},M=class extends f{constructor(e){super({...e,bypassCache:!1})}};var O,w,C=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(C,O),{...e,projectId:t});return await this.apiClient(s)}async upsertCategory(e){let t=this.createUrl(i(C,O));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(e){let t=this.createUrl(i(C,O));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(e){let t=this.createUrl(i(C,w));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(e){let t=this.createUrl(i(C,w));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},u=C;O=new WeakMap,w=new WeakMap,c(u,O,"/api/v1/enrichments"),c(u,w,"/api/v1/enrichment-values");var H=class extends u{constructor(e){super({...e,bypassCache:!0})}},K=class extends u{constructor(e){super({...e,bypassCache:!1})}};var k,Y=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(Y,k),{...e,projectId:t});return await this.apiClient(s)}async publish(){let{projectId:e}=this.options,t=this.createUrl("/api/v1/publish",{siteId:e});await this.apiClient(t,{method:"POST",expectNoContent:!0})}},x=Y;k=new WeakMap,c(x,k,"/api/v2/manifest");var q=class extends x{constructor(e){super({...e,bypassCache:!0})}},z=class extends x{constructor(e){super({...e,bypassCache:!1})}};var j,R=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(R,j),{...e,projectId:t});return await this.apiClient(s)}async upsert(e){let t=this.createUrl(i(R,j));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(i(R,j));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},g=R;j=new WeakMap,c(g,j,"/api/v2/quirk");var B=class extends g{constructor(e){super({...e,bypassCache:!0})}},F=class extends g{constructor(e){super({...e,bypassCache:!1})}};var E,I=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(I,E),{...e,projectId:t});return await this.apiClient(s)}async upsert(e){let t=this.createUrl(i(I,E));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(i(I,E));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},d=I;E=new WeakMap,c(d,E,"/api/v2/signal");var W=class extends d{constructor(e){super({...e,bypassCache:!0})}},X=class extends d{constructor(e){super({...e,bypassCache:!1})}};var D,G=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(G,D),{...e,projectId:t});return await this.apiClient(s)}async upsert(e){let t=this.createUrl(i(G,D));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(i(G,D));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},T=G;D=new WeakMap,c(T,D,"/api/v2/test");var N=class{constructor(e){m(this,"enrichments");m(this,"aggregates");m(this,"dimensions");m(this,"manifest");m(this,"quirks");m(this,"signals");m(this,"tests");this.enrichments=new u(e),this.aggregates=new y(e),this.dimensions=new f(e),this.manifest=new x(e),this.quirks=new g(e),this.signals=new d(e),this.tests=new T(e)}},Z=class extends N{constructor(e){super({...e,bypassCache:!0})}},_=class extends N{constructor(e){super({...e,bypassCache:!1})}};0&&(module.exports={AggregateClient,ApiClient,ApiClientError,CachedAggregateClient,CachedContextClient,CachedDimensionClient,CachedEnrichmentClient,CachedManifestClient,CachedQuirkClient,CachedSignalClient,ContextClient,DimensionClient,EnrichmentClient,ManifestClient,QuirkClient,SignalClient,UncachedAggregateClient,UncachedContextClient,UncachedDimensionClient,UncachedEnrichmentClient,UncachedManifestClient,UncachedQuirkClient,UncachedSignalClient,computeDimensionDefinitionDisplayData,computeDimensionDisplayData,computeDimensionDisplayName,nullLimitPolicy});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
24
+ var __accessCheck = (obj, member, msg) => {
25
+ if (!member.has(obj))
26
+ throw TypeError("Cannot " + msg);
27
+ };
28
+ var __privateGet = (obj, member, getter) => {
29
+ __accessCheck(obj, member, "read from private field");
30
+ return getter ? getter.call(obj) : member.get(obj);
31
+ };
32
+ var __privateAdd = (obj, member, value) => {
33
+ if (member.has(obj))
34
+ throw TypeError("Cannot add the same private member more than once");
35
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
+ };
37
+
38
+ // src/api/api.ts
39
+ var api_exports = {};
40
+ __export(api_exports, {
41
+ AggregateClient: () => AggregateClient,
42
+ ApiClient: () => ApiClient,
43
+ ApiClientError: () => ApiClientError,
44
+ CachedAggregateClient: () => CachedAggregateClient,
45
+ CachedContextClient: () => CachedContextClient,
46
+ CachedDimensionClient: () => CachedDimensionClient,
47
+ CachedEnrichmentClient: () => CachedEnrichmentClient,
48
+ CachedManifestClient: () => CachedManifestClient,
49
+ CachedQuirkClient: () => CachedQuirkClient,
50
+ CachedSignalClient: () => CachedSignalClient,
51
+ ContextClient: () => ContextClient,
52
+ DimensionClient: () => DimensionClient,
53
+ EnrichmentClient: () => EnrichmentClient,
54
+ ManifestClient: () => ManifestClient,
55
+ QuirkClient: () => QuirkClient,
56
+ SignalClient: () => SignalClient,
57
+ UncachedAggregateClient: () => UncachedAggregateClient,
58
+ UncachedContextClient: () => UncachedContextClient,
59
+ UncachedDimensionClient: () => UncachedDimensionClient,
60
+ UncachedEnrichmentClient: () => UncachedEnrichmentClient,
61
+ UncachedManifestClient: () => UncachedManifestClient,
62
+ UncachedQuirkClient: () => UncachedQuirkClient,
63
+ UncachedSignalClient: () => UncachedSignalClient,
64
+ computeDimensionDefinitionDisplayData: () => computeDimensionDefinitionDisplayData,
65
+ computeDimensionDisplayData: () => computeDimensionDisplayData,
66
+ computeDimensionDisplayName: () => computeDimensionDisplayName,
67
+ nullLimitPolicy: () => nullLimitPolicy
68
+ });
69
+ module.exports = __toCommonJS(api_exports);
70
+
71
+ // src/api/apiClientUtils.ts
72
+ var nullLimitPolicy = async (func) => await func();
73
+ var ApiClientError = class extends Error {
74
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
75
+ super(
76
+ `${errorMessage}
77
+ ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
78
+ );
79
+ this.errorMessage = errorMessage;
80
+ this.fetchMethod = fetchMethod;
81
+ this.fetchUri = fetchUri;
82
+ this.statusCode = statusCode;
83
+ this.statusText = statusText;
84
+ this.requestId = requestId;
85
+ Object.setPrototypeOf(this, ApiClientError.prototype);
86
+ }
87
+ };
88
+
89
+ // src/api/ApiClient.ts
90
+ var ApiClient = class {
91
+ constructor(options) {
92
+ __publicField(this, "options");
93
+ var _a, _b, _c, _d, _e, _f;
94
+ if (!options.apiKey && !options.bearerToken) {
95
+ throw new Error("You must provide an API key or a bearer token");
96
+ }
97
+ let leFetch = options.fetch;
98
+ if (!leFetch) {
99
+ if (typeof window !== "undefined") {
100
+ leFetch = window.fetch.bind(window);
101
+ } else if (typeof fetch !== "undefined") {
102
+ leFetch = fetch;
103
+ } else {
104
+ throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
105
+ }
106
+ }
107
+ this.options = {
108
+ ...options,
109
+ fetch: leFetch,
110
+ apiHost: (_a = options.apiHost) != null ? _a : "https://uniform.app",
111
+ apiKey: (_b = options.apiKey) != null ? _b : null,
112
+ projectId: (_c = options.projectId) != null ? _c : null,
113
+ bearerToken: (_d = options.bearerToken) != null ? _d : null,
114
+ limitPolicy: (_e = options.limitPolicy) != null ? _e : nullLimitPolicy,
115
+ bypassCache: (_f = options.bypassCache) != null ? _f : false
116
+ };
117
+ }
118
+ async apiClient(fetchUri, options) {
119
+ return this.options.limitPolicy(async () => {
120
+ var _a;
121
+ const coreHeaders = this.options.apiKey ? {
122
+ "x-api-key": this.options.apiKey
123
+ } : {
124
+ Authorization: `Bearer ${this.options.bearerToken}`
125
+ };
126
+ if (this.options.bypassCache) {
127
+ coreHeaders["x-bypass-cache"] = "true";
128
+ }
129
+ const apiResponse = await this.options.fetch(fetchUri.toString(), {
130
+ ...options,
131
+ headers: {
132
+ ...options == null ? void 0 : options.headers,
133
+ ...coreHeaders
134
+ }
135
+ });
136
+ if (!apiResponse.ok) {
137
+ let message = "";
138
+ try {
139
+ const responseText = await apiResponse.text();
140
+ try {
141
+ const parsed = JSON.parse(responseText);
142
+ if (parsed.errorMessage) {
143
+ message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
144
+ } else {
145
+ message = responseText;
146
+ }
147
+ } catch (e) {
148
+ message = responseText;
149
+ }
150
+ } catch (e) {
151
+ message = `General error`;
152
+ }
153
+ throw new ApiClientError(
154
+ message,
155
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
156
+ fetchUri.toString(),
157
+ apiResponse.status,
158
+ apiResponse.statusText,
159
+ ApiClient.getRequestId(apiResponse)
160
+ );
161
+ }
162
+ if (options == null ? void 0 : options.expectNoContent) {
163
+ return null;
164
+ }
165
+ return await apiResponse.json();
166
+ });
167
+ }
168
+ createUrl(path, queryParams) {
169
+ const url = new URL(`${this.options.apiHost}${path}`);
170
+ Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
171
+ var _a;
172
+ if (typeof value !== "undefined" && value !== null) {
173
+ url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
174
+ }
175
+ });
176
+ return url;
177
+ }
178
+ static getRequestId(response) {
179
+ const apigRequestId = response.headers.get("apigw-requestid");
180
+ if (apigRequestId) {
181
+ return apigRequestId;
182
+ }
183
+ return void 0;
184
+ }
185
+ };
186
+
187
+ // src/api/AggregateClient.ts
188
+ var _url;
189
+ var _AggregateClient = class extends ApiClient {
190
+ constructor(options) {
191
+ super(options);
192
+ }
193
+ async get(options) {
194
+ const { projectId } = this.options;
195
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url), { ...options, projectId });
196
+ return await this.apiClient(fetchUri);
197
+ }
198
+ async upsert(body) {
199
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
200
+ await this.apiClient(fetchUri, {
201
+ method: "PUT",
202
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
203
+ expectNoContent: true
204
+ });
205
+ }
206
+ async remove(body) {
207
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
208
+ await this.apiClient(fetchUri, {
209
+ method: "DELETE",
210
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
211
+ expectNoContent: true
212
+ });
213
+ }
214
+ };
215
+ var AggregateClient = _AggregateClient;
216
+ _url = new WeakMap();
217
+ __privateAdd(AggregateClient, _url, "/api/v2/aggregate");
218
+ var UncachedAggregateClient = class extends AggregateClient {
219
+ constructor(options) {
220
+ super({ ...options, bypassCache: true });
221
+ }
222
+ };
223
+ var CachedAggregateClient = class extends AggregateClient {
224
+ constructor(options) {
225
+ super({ ...options, bypassCache: false });
226
+ }
227
+ };
228
+
229
+ // src/manifest/constants.ts
230
+ var ENR_SEPARATOR = "_";
231
+
232
+ // src/api/computeDimensionDisplayName.ts
233
+ function computeDimensionDefinitionDisplayData(dim) {
234
+ const type = dim.category === "ENR" ? "Enrichment" : dim.category === "SIG" ? "Signal" : dim.subcategory === "1" ? "Intent" : dim.subcategory === "0" ? "Audience" : "Aggregate";
235
+ return {
236
+ dim: dim.dim,
237
+ name: dim.name,
238
+ type,
239
+ category: dim.category === "ENR" ? dim.subcategory : void 0
240
+ };
241
+ }
242
+ function computeDimensionDisplayData(dim, manifest) {
243
+ var _a, _b, _c, _d;
244
+ if ((_b = (_a = manifest.project.pz) == null ? void 0 : _a.agg) == null ? void 0 : _b[dim]) {
245
+ return { dim, name: dim, type: "Aggregate" };
246
+ } else if ((_d = (_c = manifest.project.pz) == null ? void 0 : _c.sig) == null ? void 0 : _d[dim]) {
247
+ return { dim, name: dim, type: "Signal" };
248
+ } else if (dim.indexOf(ENR_SEPARATOR) >= 0) {
249
+ const [cat, value] = dim.split(ENR_SEPARATOR);
250
+ return {
251
+ dim,
252
+ name: value,
253
+ type: "Enrichment",
254
+ category: cat
255
+ };
256
+ }
257
+ return void 0;
258
+ }
259
+ function computeDimensionDisplayName(dim) {
260
+ const { type, name } = computeDimensionDefinitionDisplayData(dim);
261
+ return `${type}: ${name}`;
262
+ }
263
+
264
+ // src/api/DimensionClient.ts
265
+ var _url2;
266
+ var _DimensionClient = class extends ApiClient {
267
+ constructor(options) {
268
+ super(options);
269
+ }
270
+ async get(options) {
271
+ const { projectId } = this.options;
272
+ const fetchUri = this.createUrl(__privateGet(_DimensionClient, _url2), { ...options, projectId });
273
+ return await this.apiClient(fetchUri);
274
+ }
275
+ };
276
+ var DimensionClient = _DimensionClient;
277
+ _url2 = new WeakMap();
278
+ __privateAdd(DimensionClient, _url2, "/api/v2/dimension");
279
+ var UncachedDimensionClient = class extends DimensionClient {
280
+ constructor(options) {
281
+ super({ ...options, bypassCache: true });
282
+ }
283
+ };
284
+ var CachedDimensionClient = class extends DimensionClient {
285
+ constructor(options) {
286
+ super({ ...options, bypassCache: false });
287
+ }
288
+ };
289
+
290
+ // src/api/EnrichmentClient.ts
291
+ var _url3, _valueUrl;
292
+ var _EnrichmentClient = class extends ApiClient {
293
+ constructor(options) {
294
+ super(options);
295
+ }
296
+ async get(options) {
297
+ const { projectId } = this.options;
298
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url3), { ...options, projectId });
299
+ return await this.apiClient(fetchUri);
300
+ }
301
+ async upsertCategory(body) {
302
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url3));
303
+ await this.apiClient(fetchUri, {
304
+ method: "PUT",
305
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
306
+ expectNoContent: true
307
+ });
308
+ }
309
+ async removeCategory(body) {
310
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url3));
311
+ await this.apiClient(fetchUri, {
312
+ method: "DELETE",
313
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
314
+ expectNoContent: true
315
+ });
316
+ }
317
+ async upsertValue(body) {
318
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
319
+ await this.apiClient(fetchUri, {
320
+ method: "PUT",
321
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
322
+ expectNoContent: true
323
+ });
324
+ }
325
+ async removeValue(body) {
326
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
327
+ await this.apiClient(fetchUri, {
328
+ method: "DELETE",
329
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
330
+ expectNoContent: true
331
+ });
332
+ }
333
+ };
334
+ var EnrichmentClient = _EnrichmentClient;
335
+ _url3 = new WeakMap();
336
+ _valueUrl = new WeakMap();
337
+ __privateAdd(EnrichmentClient, _url3, "/api/v1/enrichments");
338
+ __privateAdd(EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
339
+ var UncachedEnrichmentClient = class extends EnrichmentClient {
340
+ constructor(options) {
341
+ super({ ...options, bypassCache: true });
342
+ }
343
+ };
344
+ var CachedEnrichmentClient = class extends EnrichmentClient {
345
+ constructor(options) {
346
+ super({ ...options, bypassCache: false });
347
+ }
348
+ };
349
+
350
+ // src/api/ManifestClient.ts
351
+ var _url4;
352
+ var _ManifestClient = class extends ApiClient {
353
+ constructor(options) {
354
+ super(options);
355
+ }
356
+ async get(options) {
357
+ const { projectId } = this.options;
358
+ const fetchUri = this.createUrl(__privateGet(_ManifestClient, _url4), { ...options, projectId });
359
+ return await this.apiClient(fetchUri);
360
+ }
361
+ async publish() {
362
+ const { projectId } = this.options;
363
+ const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
364
+ await this.apiClient(fetchUri, {
365
+ method: "POST",
366
+ expectNoContent: true
367
+ });
368
+ }
369
+ };
370
+ var ManifestClient = _ManifestClient;
371
+ _url4 = new WeakMap();
372
+ __privateAdd(ManifestClient, _url4, "/api/v2/manifest");
373
+ var UncachedManifestClient = class extends ManifestClient {
374
+ constructor(options) {
375
+ super({ ...options, bypassCache: true });
376
+ }
377
+ };
378
+ var CachedManifestClient = class extends ManifestClient {
379
+ constructor(options) {
380
+ super({ ...options, bypassCache: false });
381
+ }
382
+ };
383
+
384
+ // src/api/QuirkClient.ts
385
+ var _url5;
386
+ var _QuirkClient = class extends ApiClient {
387
+ constructor(options) {
388
+ super(options);
389
+ }
390
+ async get(options) {
391
+ const { projectId } = this.options;
392
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url5), { ...options, projectId });
393
+ return await this.apiClient(fetchUri);
394
+ }
395
+ async upsert(body) {
396
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url5));
397
+ await this.apiClient(fetchUri, {
398
+ method: "PUT",
399
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
400
+ expectNoContent: true
401
+ });
402
+ }
403
+ async remove(body) {
404
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url5));
405
+ await this.apiClient(fetchUri, {
406
+ method: "DELETE",
407
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
408
+ expectNoContent: true
409
+ });
410
+ }
411
+ };
412
+ var QuirkClient = _QuirkClient;
413
+ _url5 = new WeakMap();
414
+ __privateAdd(QuirkClient, _url5, "/api/v2/quirk");
415
+ var UncachedQuirkClient = class extends QuirkClient {
416
+ constructor(options) {
417
+ super({ ...options, bypassCache: true });
418
+ }
419
+ };
420
+ var CachedQuirkClient = class extends QuirkClient {
421
+ constructor(options) {
422
+ super({ ...options, bypassCache: false });
423
+ }
424
+ };
425
+
426
+ // src/api/SignalClient.ts
427
+ var _url6;
428
+ var _SignalClient = class extends ApiClient {
429
+ constructor(options) {
430
+ super(options);
431
+ }
432
+ async get(options) {
433
+ const { projectId } = this.options;
434
+ const fetchUri = this.createUrl(__privateGet(_SignalClient, _url6), { ...options, projectId });
435
+ return await this.apiClient(fetchUri);
436
+ }
437
+ async upsert(body) {
438
+ const fetchUri = this.createUrl(__privateGet(_SignalClient, _url6));
439
+ await this.apiClient(fetchUri, {
440
+ method: "PUT",
441
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
442
+ expectNoContent: true
443
+ });
444
+ }
445
+ async remove(body) {
446
+ const fetchUri = this.createUrl(__privateGet(_SignalClient, _url6));
447
+ await this.apiClient(fetchUri, {
448
+ method: "DELETE",
449
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
450
+ expectNoContent: true
451
+ });
452
+ }
453
+ };
454
+ var SignalClient = _SignalClient;
455
+ _url6 = new WeakMap();
456
+ __privateAdd(SignalClient, _url6, "/api/v2/signal");
457
+ var UncachedSignalClient = class extends SignalClient {
458
+ constructor(options) {
459
+ super({ ...options, bypassCache: true });
460
+ }
461
+ };
462
+ var CachedSignalClient = class extends SignalClient {
463
+ constructor(options) {
464
+ super({ ...options, bypassCache: false });
465
+ }
466
+ };
467
+
468
+ // src/api/TestClient.ts
469
+ var _url7;
470
+ var _TestClient = class extends ApiClient {
471
+ constructor(options) {
472
+ super(options);
473
+ }
474
+ async get(options) {
475
+ const { projectId } = this.options;
476
+ const fetchUri = this.createUrl(__privateGet(_TestClient, _url7), { ...options, projectId });
477
+ return await this.apiClient(fetchUri);
478
+ }
479
+ async upsert(body) {
480
+ const fetchUri = this.createUrl(__privateGet(_TestClient, _url7));
481
+ await this.apiClient(fetchUri, {
482
+ method: "PUT",
483
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
484
+ expectNoContent: true
485
+ });
486
+ }
487
+ async remove(body) {
488
+ const fetchUri = this.createUrl(__privateGet(_TestClient, _url7));
489
+ await this.apiClient(fetchUri, {
490
+ method: "DELETE",
491
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
492
+ expectNoContent: true
493
+ });
494
+ }
495
+ };
496
+ var TestClient = _TestClient;
497
+ _url7 = new WeakMap();
498
+ __privateAdd(TestClient, _url7, "/api/v2/test");
499
+
500
+ // src/api/ContextClient.ts
501
+ var ContextClient = class {
502
+ constructor(options) {
503
+ __publicField(this, "enrichments");
504
+ __publicField(this, "aggregates");
505
+ __publicField(this, "dimensions");
506
+ __publicField(this, "manifest");
507
+ __publicField(this, "quirks");
508
+ __publicField(this, "signals");
509
+ __publicField(this, "tests");
510
+ this.enrichments = new EnrichmentClient(options);
511
+ this.aggregates = new AggregateClient(options);
512
+ this.dimensions = new DimensionClient(options);
513
+ this.manifest = new ManifestClient(options);
514
+ this.quirks = new QuirkClient(options);
515
+ this.signals = new SignalClient(options);
516
+ this.tests = new TestClient(options);
517
+ }
518
+ };
519
+ var UncachedContextClient = class extends ContextClient {
520
+ constructor(options) {
521
+ super({ ...options, bypassCache: true });
522
+ }
523
+ };
524
+ var CachedContextClient = class extends ContextClient {
525
+ constructor(options) {
526
+ super({ ...options, bypassCache: false });
527
+ }
528
+ };
529
+ // Annotate the CommonJS export names for ESM import in node:
530
+ 0 && (module.exports = {
531
+ AggregateClient,
532
+ ApiClient,
533
+ ApiClientError,
534
+ CachedAggregateClient,
535
+ CachedContextClient,
536
+ CachedDimensionClient,
537
+ CachedEnrichmentClient,
538
+ CachedManifestClient,
539
+ CachedQuirkClient,
540
+ CachedSignalClient,
541
+ ContextClient,
542
+ DimensionClient,
543
+ EnrichmentClient,
544
+ ManifestClient,
545
+ QuirkClient,
546
+ SignalClient,
547
+ UncachedAggregateClient,
548
+ UncachedContextClient,
549
+ UncachedDimensionClient,
550
+ UncachedEnrichmentClient,
551
+ UncachedManifestClient,
552
+ UncachedQuirkClient,
553
+ UncachedSignalClient,
554
+ computeDimensionDefinitionDisplayData,
555
+ computeDimensionDisplayData,
556
+ computeDimensionDisplayName,
557
+ nullLimitPolicy
558
+ });