@uniformdev/context 17.1.0 → 17.1.1-alpha.151
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 +5 -5
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +2 -2
- package/dist/cli/cli.js +1 -1
- package/dist/cli/cli.mjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/api/api.d.ts
CHANGED
@@ -36,14 +36,14 @@ declare class ApiClientError extends Error {
|
|
36
36
|
constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number | undefined, statusText?: string | undefined, requestId?: string | undefined);
|
37
37
|
}
|
38
38
|
|
39
|
-
declare class ApiClient {
|
40
|
-
protected options:
|
41
|
-
constructor(options:
|
39
|
+
declare class ApiClient<TOptions extends ClientOptions = ClientOptions> {
|
40
|
+
protected options: TOptions;
|
41
|
+
constructor(options: TOptions);
|
42
42
|
protected apiClient<TResponse>(fetchUri: URL, options?: RequestInit & {
|
43
43
|
/** Whether to expect a JSON response or not */
|
44
44
|
expectNoContent?: boolean;
|
45
45
|
}): Promise<TResponse>;
|
46
|
-
protected createUrl(path: string, queryParams?: Record<string, string | boolean | undefined | null | number
|
46
|
+
protected createUrl(path: string, queryParams?: Record<string, string | boolean | undefined | null | number | Array<string | boolean | number>>): URL;
|
47
47
|
private static getRequestId;
|
48
48
|
}
|
49
49
|
|
@@ -186,4 +186,4 @@ declare function computeDimensionDisplayData(dim: string, manifest: ManifestV2):
|
|
186
186
|
/** Computes the standard display name for a given dimension from the dimensions API */
|
187
187
|
declare function computeDimensionDisplayName(dim: DimensionDefinition): string;
|
188
188
|
|
189
|
-
export { AggregateClient, 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, 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 };
|
package/dist/api/api.js
CHANGED
@@ -1,2 +1,2 @@
|
|
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,ApiClientError:()=>P,CachedAggregateClient:()=>J,CachedContextClient:()=>Z,CachedDimensionClient:()=>V,CachedEnrichmentClient:()=>H,CachedManifestClient:()=>q,CachedQuirkClient:()=>B,CachedSignalClient:()=>W,ContextClient:()=>N,DimensionClient:()=>f,EnrichmentClient:()=>u,ManifestClient:()=>x,QuirkClient:()=>g,SignalClient:()=>d,UncachedAggregateClient:()=>L,UncachedContextClient:()=>X,UncachedDimensionClient:()=>$,UncachedEnrichmentClient:()=>Q,UncachedManifestClient:()=>K,UncachedQuirkClient:()=>Y,UncachedSignalClient:()=>F,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,(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 A,M=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(M,A),{...e,projectId:t});return await this.apiClient(s)}},f=M;A=new WeakMap,c(f,A,"/api/v2/dimension");var $=class extends f{constructor(e){super({...e,bypassCache:!0})}},V=class extends f{constructor(e){super({...e,bypassCache:!1})}};var O,
|
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:()=>Z,CachedDimensionClient:()=>V,CachedEnrichmentClient:()=>H,CachedManifestClient:()=>q,CachedQuirkClient:()=>B,CachedSignalClient:()=>W,ContextClient:()=>N,DimensionClient:()=>f,EnrichmentClient:()=>u,ManifestClient:()=>x,QuirkClient:()=>g,SignalClient:()=>d,UncachedAggregateClient:()=>L,UncachedContextClient:()=>X,UncachedDimensionClient:()=>$,UncachedEnrichmentClient:()=>Q,UncachedManifestClient:()=>K,UncachedQuirkClient:()=>Y,UncachedSignalClient:()=>F,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 A,M=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(M,A),{...e,projectId:t});return await this.apiClient(s)}},f=M;A=new WeakMap,c(f,A,"/api/v2/dimension");var $=class extends f{constructor(e){super({...e,bypassCache:!0})}},V=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 Q=class extends u{constructor(e){super({...e,bypassCache:!0})}},H=class extends u{constructor(e){super({...e,bypassCache:!1})}};var k,z=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(z,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=z;k=new WeakMap,c(x,k,"/api/v2/manifest");var K=class extends x{constructor(e){super({...e,bypassCache:!0})}},q=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 Y=class extends g{constructor(e){super({...e,bypassCache:!0})}},B=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 F=class extends d{constructor(e){super({...e,bypassCache:!0})}},W=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)}},X=class extends N{constructor(e){super({...e,bypassCache:!0})}},Z=class extends N{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}`}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});
|
package/dist/api/api.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var _=Object.defineProperty;var ee=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var m=(r,e,t)=>(ee(r,typeof e!="symbol"?e+"":e,t),t),te=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var i=(r,e,t)=>(te(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 J=async r=>await r(),C=class extends Error{constructor(t,s,
|
2
|
-
${
|
1
|
+
var _=Object.defineProperty;var ee=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var m=(r,e,t)=>(ee(r,typeof e!="symbol"?e+"":e,t),t),te=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var i=(r,e,t)=>(te(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 J=async r=>await r(),C=class extends Error{constructor(t,s,a,o,p,l){super(`${t}
|
2
|
+
${o}${p?" "+p:""} (${s} ${a}${l?` Request ID: ${l}`:""})`);this.errorMessage=t;this.fetchMethod=s;this.fetchUri=a;this.statusCode=o;this.statusText=p;this.requestId=l;Object.setPrototypeOf(this,C.prototype)}};var n=class{constructor(e){m(this,"options");var s,a,o,p,l,u;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:(a=e.apiKey)!=null?a:null,projectId:(o=e.projectId)!=null?o:null,bearerToken:(p=e.bearerToken)!=null?p:null,limitPolicy:(l=e.limitPolicy)!=null?l:J,bypassCache:(u=e.bypassCache)!=null?u:!1}}async apiClient(e,t){return this.options.limitPolicy(async()=>{var o;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 a=await this.options.fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...s}});if(!a.ok){let p="";try{let l=await a.text();try{let u=JSON.parse(l);u.errorMessage?p=Array.isArray(u.errorMessage)?u.errorMessage.join(", "):u.errorMessage:p=l}catch(u){p=l}}catch(l){p="General error"}throw new C(p,(o=t==null?void 0:t.method)!=null?o:"GET",e.toString(),a.status,a.statusText,n.getRequestId(a))}return t!=null&&t.expectNoContent?null:await a.json()})}createUrl(e,t){let s=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([a,o])=>{var p;typeof o!="undefined"&&o!==null&&s.searchParams.append(a,Array.isArray(o)?o.join(","):(p=o==null?void 0:o.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 $=class extends y{constructor(e){super({...e,bypassCache:!0})}},V=class extends y{constructor(e){super({...e,bypassCache:!1})}};var N,k=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(k,N),{...e,projectId:t});return await this.apiClient(s)}},f=k;N=new WeakMap,c(f,N,"/api/v2/dimension");var M=class extends f{constructor(e){super({...e,bypassCache:!0})}},Q=class extends f{constructor(e){super({...e,bypassCache:!1})}};var O,w,x=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(x,O),{...e,projectId:t});return await this.apiClient(s)}async upsertCategory(e){let t=this.createUrl(i(x,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(x,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(x,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(x,w));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},h=x;O=new WeakMap,w=new WeakMap,c(h,O,"/api/v1/enrichments"),c(h,w,"/api/v1/enrichment-values");var H=class extends h{constructor(e){super({...e,bypassCache:!0})}},K=class extends h{constructor(e){super({...e,bypassCache:!1})}};var S,v=class extends n{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,s=this.createUrl(i(v,S),{...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})}},g=v;S=new WeakMap,c(g,S,"/api/v2/manifest");var q=class extends g{constructor(e){super({...e,bypassCache:!0})}},z=class extends g{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})}},d=R;j=new WeakMap,c(d,j,"/api/v2/quirk");var Y=class extends d{constructor(e){super({...e,bypassCache:!0})}},B=class extends d{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})}},P=I;E=new WeakMap,c(P,E,"/api/v2/signal");var F=class extends P{constructor(e){super({...e,bypassCache:!0})}},W=class extends P{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 A=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 h(e),this.aggregates=new y(e),this.dimensions=new f(e),this.manifest=new g(e),this.quirks=new d(e),this.signals=new P(e),this.tests=new T(e)}},X=class extends A{constructor(e){super({...e,bypassCache:!0})}},Z=class extends A{constructor(e){super({...e,bypassCache:!1})}};var L="_";function re(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 Ne(r,e){var t,s,a,o;if((s=(t=e.project.pz)==null?void 0:t.agg)!=null&&s[r])return{dim:r,name:r,type:"Aggregate"};if((o=(a=e.project.pz)==null?void 0:a.sig)!=null&&o[r])return{dim:r,name:r,type:"Signal"};if(r.indexOf(L)>=0){let[p,l]=r.split(L);return{dim:r,name:l,type:"Enrichment",category:p}}}function Se(r){let{type:e,name:t}=re(r);return`${e}: ${t}`}export{y as AggregateClient,n as ApiClient,C as ApiClientError,V as CachedAggregateClient,Z as CachedContextClient,Q as CachedDimensionClient,K as CachedEnrichmentClient,z as CachedManifestClient,B as CachedQuirkClient,W as CachedSignalClient,A as ContextClient,f as DimensionClient,h as EnrichmentClient,g as ManifestClient,d as QuirkClient,P as SignalClient,$ as UncachedAggregateClient,X as UncachedContextClient,M as UncachedDimensionClient,H as UncachedEnrichmentClient,q as UncachedManifestClient,Y as UncachedQuirkClient,F as UncachedSignalClient,re as computeDimensionDefinitionDisplayData,Ne as computeDimensionDisplayData,Se as computeDimensionDisplayName,J as nullLimitPolicy};
|
package/dist/cli/cli.js
CHANGED
@@ -122,7 +122,7 @@ ${g.join(`
|
|
122
122
|
${l==null?void 0:l.message}`)),l}}}return{objects:d(),deleteObject:async s=>{await(0,Np.unlink)(s)},writeObject:async s=>{he(s.object,a,n(s.id))}}}function el(e,a){if(!a&&!Xo.default.existsSync(e))return{};let t=B1(e);if(typeof t!="object")throw new Error(`Package ${e} does not appear valid.`);return t}function al(e,a){he(a,void 0,e)}async function ge({source:e,target:a,compareContents:t=(d,s)=>(0,tl.default)(d.object,s.object,(o,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:i,allowEmptySource:p=!1,whatIf:r=!1,log:n=()=>{}}){var d,s;let o=new Map;for await(let c of a.objects)o.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,g=o.get(u);if(g){if(!t(c,g)&&(i==="createOrUpdate"||i==="mirror")){let v=async(h,_)=>{var A;if(!r)try{await a.writeObject(h,_)}catch(j){throw new Ep(j,h)}n({action:"update",id:u,providerId:h.providerId,displayName:(A=h.displayName)!=null?A:h.providerId,whatIf:r,diff:bo(_.object,h.object)})};l.push(v(c,g))}o.delete(u)}else{let v=async(h,_)=>{var A;if(!r)try{await a.writeObject(h)}catch(j){throw new Ep(j,h)}n({action:"create",id:_,providerId:_,displayName:(A=h.displayName)!=null?A:h.providerId,whatIf:r,diff:zn("",JSON.stringify(h.object,null,2))})};l.push(v(c,u))}}if(await Promise.all(l),i==="mirror"){if(!m&&!p)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];o.forEach(async u=>{let g=async v=>{var h;if(!r)try{await a.deleteObject(v.providerId)}catch(_){throw new Ep(_,v)}n({action:"delete",id:v.id,providerId:v.providerId,displayName:(h=v.displayName)!=null?h:v.providerId,whatIf:r,diff:zn(JSON.stringify(v.object,null,2),"")})};c.push(g(u))}),await Promise.all(c)}await Promise.all([(d=e.onSyncComplete)==null?void 0:d.call(e,!1),(s=a.onSyncComplete)==null?void 0:s.call(a,!0)])}var Ep=class extends Error{constructor(e,a){var t;super(`Error syncing ${(t=a.displayName)!=null?t:a.providerId} (${a.providerId})
|
123
123
|
${e}`),this.stack=void 0,Object.setPrototypeOf(this,Ep.prototype)}},St=wr(br());function ve(e){let{diffMode:a="off",indent:t,prefix:i}=e!=null?e:{};return function({action:p,displayName:r,whatIf:n,diff:d}){let s="";switch(p){case"create":s=St.default.green("[A]");break;case"update":s=St.default.white("[U]");break;case"delete":s=St.default.yellow("[D]");break}let o="";(a==="on"||a==="update"&&p==="update")&&(o=`
|
124
124
|
`+d.map(l=>l.added?St.default.green(l.value):l.removed?St.default.red(l.value):l.value).join("")),console.log(`${t!=null?t:""}${n?St.default.gray("[WHATIF]"):""}${s}${i!=null?i:""} ${r}${o}`)}}var il=async e=>await e(),k1=class extends Error{constructor(t,i,p,r,n,d){super(`${t}
|
125
|
-
${r}${n?" "+n:""} (${i} ${p}${d?` Request ID: ${d}`:""})`);this.errorMessage=t;this.fetchMethod=i;this.fetchUri=p;this.statusCode=r;this.statusText=n;this.requestId=d;Object.setPrototypeOf(this,k1.prototype)}};var ze=class{constructor(a){Ad(this,"options");var i,p,r,n,d,s;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.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={...a,fetch:t,apiHost:(i=a.apiHost)!=null?i:"https://uniform.app",apiKey:(p=a.apiKey)!=null?p:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(n=a.bearerToken)!=null?n:null,limitPolicy:(d=a.limitPolicy)!=null?d:il,bypassCache:(s=a.bypassCache)!=null?s:!1}}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(i["x-bypass-cache"]="true");let p=await this.options.fetch(a.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!p.ok){let n="";try{let d=await p.text();try{let s=JSON.parse(d);s.errorMessage?n=Array.isArray(s.errorMessage)?s.errorMessage.join(", "):s.errorMessage:n=d}catch(s){n=d}}catch(d){n="General error"}throw new k1(n,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),p.status,p.statusText,ze.getRequestId(p))}return t!=null&&t.expectNoContent?null:await p.json()})}createUrl(a,t){let i=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([p,r])=>{var n;typeof r!="undefined"&&r!==null&&i.searchParams.append(p,(n=r==null?void 0:r.toString())!=null?n:"")}),i}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}};var Et,ci=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(ci,Et),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(le(ci,Et));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(le(ci,Et));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Dp=ci;Et=new WeakMap,n1(Dp,Et,"/api/v2/aggregate");var e1=class extends Dp{constructor(a){super({...a,bypassCache:!0})}};var pl={command:"get <id>",describe:"Fetch an aggregate",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new e1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({aggregateId:i});o.aggregates.length===0?(console.error("Aggregate did not exist"),process.exit(1)):he(o.aggregates[0],p,n)}};var rl={command:"list",describe:"List aggregates",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new e1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get({});he(s.aggregates,i,p)}};var va=e=>e.id,wa=e=>`${e.name} (pid: ${e.id})`;function _e(e,a){return el(e,a)}function D1(e,a){al(e,a)}var nl=r1(require("p-limit")),De=(0,nl.default)(8);function Tp({client:e,type:a}){async function*t(){let p=(await e.get({type:a})).aggregates;for await(let r of p)yield{id:va(r),displayName:wa(r),providerId:r.id,object:r}}let i=[];return{objects:t(),deleteObject:async p=>{await e.remove({aggregateId:p})},writeObject:async p=>{await e.upsert({aggregate:p.object,skipInputs:!0}),i.push(p.object)},complete:async()=>{await Promise.all(i.map(p=>e.upsert({aggregate:p,skipInputs:!1})))}}}var dl={command:"pull <directory>",describe:"Pulls all aggregates to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new e1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=Tp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.aggregates)!=null?g:[],selectIdentifier:va,selectDisplayName:wa,onSyncComplete:async(h,_)=>{v.aggregates=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var sl={command:"push <directory>",describe:"Pushes all aggregates from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the aggregates from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new e1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.aggregates)!=null?u:[],selectIdentifier:va,selectDisplayName:wa})}else l=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa});let c=Tp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})}),await c.complete()}};var ol={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an aggregate",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new e1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({aggregateId:i})}};var ll={command:"update <filename>",aliases:["put"],describe:"Insert or update an aggregate",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Aggregate file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new e1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=B1(i);await n.upsert({aggregate:d})}};var ml={command:"aggregate <command>",aliases:["agg","intent","audience"],describe:"Commands for Context aggregates (intents, audiences)",builder:e=>e.command(dl).command(sl).command(pl).command(ol).command(rl).command(ll).demandCommand(),handler:()=>{Qe.help()}};var Ot,fi,Qa=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(Qa,Ot),{...a,projectId:t});return await this.apiClient(i)}async upsertCategory(a){let t=this.createUrl(le(Qa,Ot));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(a){let t=this.createUrl(le(Qa,Ot));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(a){let t=this.createUrl(le(Qa,fi));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(a){let t=this.createUrl(le(Qa,fi));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},ui=Qa;Ot=new WeakMap,fi=new WeakMap,n1(ui,Ot,"/api/v1/enrichments"),n1(ui,fi,"/api/v1/enrichment-values");var S1=class extends ui{constructor(a){super({...a,bypassCache:!0})}};var cl={command:"get <id>",describe:"Fetch an enrichment category and its values",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{var l,m;let d=P(t),o=(m=(l=await new S1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get())==null?void 0:l.enrichments)==null?void 0:m.filter(c=>c.id===i);o.length===0?(console.error("Enrichment did not exist"),process.exit(1)):he(o[0],p,n)}};var ul={command:"list",describe:"List enrichments",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new S1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();he(s.enrichments,i,p)}};var ba=e=>e.id,ya=e=>`${e.name} (pid: ${e.id})`;function Pp({client:e}){async function*a(){let t=(await e.get()).enrichments;for await(let i of t)yield{id:ba(i),displayName:ya(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeCategory({enrichmentId:t})},writeObject:async(t,i)=>{var n,d;await e.upsertCategory({enrichment:t.object});let p=fl({categoryId:t.id,values:t.object.values}),r=fl({categoryId:t.id,values:(d=(n=i==null?void 0:i.object)==null?void 0:n.values)!=null?d:[],client:e});await ge({source:p,target:r,mode:"mirror",whatIf:!1,log:ve({diffMode:"off",prefix:` ${t.displayName} value`,indent:"> "})})}}}var fl=({client:e,categoryId:a,values:t})=>({objects:async function*(){for(let p of t)yield{id:p.id,providerId:p.id,object:p,displayName:`${p.value} (pid: ${p.id})`}}(),deleteObject:async p=>{if(!e)throw new Error("Provider is read only");await e.removeValue({enrichmentId:a,enrichmentValueId:p})},writeObject:async p=>{if(!e)throw new Error("Provider is read only");await e.upsertValue({enrichmentId:a,enrichmentValue:p.object})}});var hl={command:"pull <directory>",describe:"Pulls all enrichments to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new S1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=Pp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.enrichments)!=null?g:[],selectIdentifier:ba,selectDisplayName:ya,onSyncComplete:async(h,_)=>{v.enrichments=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var gl={command:"push <directory>",describe:"Pushes all enrichments from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the enrichments from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new S1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.enrichments)!=null?u:[],selectIdentifier:ba,selectDisplayName:ya})}else l=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya});let c=Pp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})})}};var vl={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an enrichment category and its values",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new S1({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeCategory({enrichmentId:i})}};var wl={command:"enrichment <command>",aliases:["enr"],describe:"Commands for Context enrichments",builder:e=>e.command(hl).command(gl).command(cl).command(vl).command(ul).demandCommand(),handler:()=>{Qe.help()}};var Up=r1(gd()),zl=require("fs"),wd=require("process");var kp,vd=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(vd,kp),{...a,projectId:t});return await this.apiClient(i)}async publish(){let{projectId:a}=this.options,t=this.createUrl("/api/v1/publish",{siteId:a});await this.apiClient(t,{method:"POST",expectNoContent:!0})}},Bp=vd;kp=new WeakMap,n1(Bp,kp,"/api/v2/manifest");var Ft=class extends Bp{constructor(a){super({...a,bypassCache:!0})}};var Gl={command:"get [output]",aliases:["dl","download"],describe:"Download the Uniform Context manifest for a project",builder:e=>T(F(e.option("preview",{describe:"If set, fetches the unpublished preview manifest (The API key must have permission)",default:!1,type:"boolean",alias:["d"]}).option("output",{string:!0,alias:"o",default:process.env.UNIFORM_MANIFEST_PATH,describe:"Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",demandOption:!0}))),handler:async({apiKey:e,apiHost:a,proxy:t,output:i,project:p,preview:r})=>{let n=P(t),d=new Ft({apiHost:a,projectId:p,apiKey:e,fetch:n});try{let s=await d.get({preview:r}),o=JSON.stringify(s,null,2);i?(0,zl.writeFile)(i,o,l=>{l&&(console.error(`Error writing file to ${i}
|
125
|
+
${r}${n?" "+n:""} (${i} ${p}${d?` Request ID: ${d}`:""})`);this.errorMessage=t;this.fetchMethod=i;this.fetchUri=p;this.statusCode=r;this.statusText=n;this.requestId=d;Object.setPrototypeOf(this,k1.prototype)}};var ze=class{constructor(a){Ad(this,"options");var i,p,r,n,d,s;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.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={...a,fetch:t,apiHost:(i=a.apiHost)!=null?i:"https://uniform.app",apiKey:(p=a.apiKey)!=null?p:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(n=a.bearerToken)!=null?n:null,limitPolicy:(d=a.limitPolicy)!=null?d:il,bypassCache:(s=a.bypassCache)!=null?s:!1}}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(i["x-bypass-cache"]="true");let p=await this.options.fetch(a.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!p.ok){let n="";try{let d=await p.text();try{let s=JSON.parse(d);s.errorMessage?n=Array.isArray(s.errorMessage)?s.errorMessage.join(", "):s.errorMessage:n=d}catch(s){n=d}}catch(d){n="General error"}throw new k1(n,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),p.status,p.statusText,ze.getRequestId(p))}return t!=null&&t.expectNoContent?null:await p.json()})}createUrl(a,t){let i=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([p,r])=>{var n;typeof r!="undefined"&&r!==null&&i.searchParams.append(p,Array.isArray(r)?r.join(","):(n=r==null?void 0:r.toString())!=null?n:"")}),i}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}};var Et,ci=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(ci,Et),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(le(ci,Et));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(le(ci,Et));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Dp=ci;Et=new WeakMap,n1(Dp,Et,"/api/v2/aggregate");var e1=class extends Dp{constructor(a){super({...a,bypassCache:!0})}};var pl={command:"get <id>",describe:"Fetch an aggregate",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new e1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({aggregateId:i});o.aggregates.length===0?(console.error("Aggregate did not exist"),process.exit(1)):he(o.aggregates[0],p,n)}};var rl={command:"list",describe:"List aggregates",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new e1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get({});he(s.aggregates,i,p)}};var va=e=>e.id,wa=e=>`${e.name} (pid: ${e.id})`;function _e(e,a){return el(e,a)}function D1(e,a){al(e,a)}var nl=r1(require("p-limit")),De=(0,nl.default)(8);function Tp({client:e,type:a}){async function*t(){let p=(await e.get({type:a})).aggregates;for await(let r of p)yield{id:va(r),displayName:wa(r),providerId:r.id,object:r}}let i=[];return{objects:t(),deleteObject:async p=>{await e.remove({aggregateId:p})},writeObject:async p=>{await e.upsert({aggregate:p.object,skipInputs:!0}),i.push(p.object)},complete:async()=>{await Promise.all(i.map(p=>e.upsert({aggregate:p,skipInputs:!1})))}}}var dl={command:"pull <directory>",describe:"Pulls all aggregates to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new e1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=Tp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.aggregates)!=null?g:[],selectIdentifier:va,selectDisplayName:wa,onSyncComplete:async(h,_)=>{v.aggregates=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var sl={command:"push <directory>",describe:"Pushes all aggregates from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the aggregates from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new e1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.aggregates)!=null?u:[],selectIdentifier:va,selectDisplayName:wa})}else l=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa});let c=Tp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})}),await c.complete()}};var ol={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an aggregate",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new e1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({aggregateId:i})}};var ll={command:"update <filename>",aliases:["put"],describe:"Insert or update an aggregate",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Aggregate file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new e1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=B1(i);await n.upsert({aggregate:d})}};var ml={command:"aggregate <command>",aliases:["agg","intent","audience"],describe:"Commands for Context aggregates (intents, audiences)",builder:e=>e.command(dl).command(sl).command(pl).command(ol).command(rl).command(ll).demandCommand(),handler:()=>{Qe.help()}};var Ot,fi,Qa=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(Qa,Ot),{...a,projectId:t});return await this.apiClient(i)}async upsertCategory(a){let t=this.createUrl(le(Qa,Ot));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(a){let t=this.createUrl(le(Qa,Ot));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(a){let t=this.createUrl(le(Qa,fi));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(a){let t=this.createUrl(le(Qa,fi));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},ui=Qa;Ot=new WeakMap,fi=new WeakMap,n1(ui,Ot,"/api/v1/enrichments"),n1(ui,fi,"/api/v1/enrichment-values");var S1=class extends ui{constructor(a){super({...a,bypassCache:!0})}};var cl={command:"get <id>",describe:"Fetch an enrichment category and its values",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{var l,m;let d=P(t),o=(m=(l=await new S1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get())==null?void 0:l.enrichments)==null?void 0:m.filter(c=>c.id===i);o.length===0?(console.error("Enrichment did not exist"),process.exit(1)):he(o[0],p,n)}};var ul={command:"list",describe:"List enrichments",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new S1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();he(s.enrichments,i,p)}};var ba=e=>e.id,ya=e=>`${e.name} (pid: ${e.id})`;function Pp({client:e}){async function*a(){let t=(await e.get()).enrichments;for await(let i of t)yield{id:ba(i),displayName:ya(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeCategory({enrichmentId:t})},writeObject:async(t,i)=>{var n,d;await e.upsertCategory({enrichment:t.object});let p=fl({categoryId:t.id,values:t.object.values}),r=fl({categoryId:t.id,values:(d=(n=i==null?void 0:i.object)==null?void 0:n.values)!=null?d:[],client:e});await ge({source:p,target:r,mode:"mirror",whatIf:!1,log:ve({diffMode:"off",prefix:` ${t.displayName} value`,indent:"> "})})}}}var fl=({client:e,categoryId:a,values:t})=>({objects:async function*(){for(let p of t)yield{id:p.id,providerId:p.id,object:p,displayName:`${p.value} (pid: ${p.id})`}}(),deleteObject:async p=>{if(!e)throw new Error("Provider is read only");await e.removeValue({enrichmentId:a,enrichmentValueId:p})},writeObject:async p=>{if(!e)throw new Error("Provider is read only");await e.upsertValue({enrichmentId:a,enrichmentValue:p.object})}});var hl={command:"pull <directory>",describe:"Pulls all enrichments to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new S1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=Pp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.enrichments)!=null?g:[],selectIdentifier:ba,selectDisplayName:ya,onSyncComplete:async(h,_)=>{v.enrichments=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var gl={command:"push <directory>",describe:"Pushes all enrichments from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the enrichments from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new S1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.enrichments)!=null?u:[],selectIdentifier:ba,selectDisplayName:ya})}else l=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya});let c=Pp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})})}};var vl={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an enrichment category and its values",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new S1({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeCategory({enrichmentId:i})}};var wl={command:"enrichment <command>",aliases:["enr"],describe:"Commands for Context enrichments",builder:e=>e.command(hl).command(gl).command(cl).command(vl).command(ul).demandCommand(),handler:()=>{Qe.help()}};var Up=r1(gd()),zl=require("fs"),wd=require("process");var kp,vd=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(vd,kp),{...a,projectId:t});return await this.apiClient(i)}async publish(){let{projectId:a}=this.options,t=this.createUrl("/api/v1/publish",{siteId:a});await this.apiClient(t,{method:"POST",expectNoContent:!0})}},Bp=vd;kp=new WeakMap,n1(Bp,kp,"/api/v2/manifest");var Ft=class extends Bp{constructor(a){super({...a,bypassCache:!0})}};var Gl={command:"get [output]",aliases:["dl","download"],describe:"Download the Uniform Context manifest for a project",builder:e=>T(F(e.option("preview",{describe:"If set, fetches the unpublished preview manifest (The API key must have permission)",default:!1,type:"boolean",alias:["d"]}).option("output",{string:!0,alias:"o",default:process.env.UNIFORM_MANIFEST_PATH,describe:"Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",demandOption:!0}))),handler:async({apiKey:e,apiHost:a,proxy:t,output:i,project:p,preview:r})=>{let n=P(t),d=new Ft({apiHost:a,projectId:p,apiKey:e,fetch:n});try{let s=await d.get({preview:r}),o=JSON.stringify(s,null,2);i?(0,zl.writeFile)(i,o,l=>{l&&(console.error(`Error writing file to ${i}
|
126
126
|
`,l),(0,wd.exit)(1)),console.log(Up.default.green(`\u2705 ${i} has been updated from ${a}`))}):console.log(o)}catch(s){let o;s instanceof k1?(s.statusCode===403&&(o=`The API key ${e} did not have permissions to fetch the manifest. Ensure ${r?"Uniform Context > Read Drafts":"Uniform Context > Manifest > Read"} permissions are granted.`),o=s.message):o=s.toString(),console.error(Up.default.red("\u26A0 Error fetching Context manifest")),console.error(Up.default.gray(` \u2757 ${o}`)),(0,wd.exit)(1)}}};var bd=r1(gd()),Yl=require("process");var Kl={command:"publish",describe:"Publish the Uniform Context manifest for a project",builder:e=>T(F(e)),handler:async({apiKey:e,apiHost:a,proxy:t,project:i})=>{let p=P(t);try{await new Ft({apiHost:a,projectId:i,apiKey:e,fetch:p}).publish()}catch(r){let n;r instanceof k1?(r.statusCode===403&&(n=`The API key ${e} did not have permissions to publish the manifest. Ensure Uniform Context > Manifest > Publish permissions are granted.`),n=r.message):n=r.toString(),console.error(bd.default.red("\u26A0 Error publishing Context manifest")),console.error(bd.default.gray(` \u2757 ${n}`)),(0,Yl.exit)(1)}}};var Ql={command:"manifest <command>",describe:"Commands for context manifests",aliases:["man"],builder:e=>e.command(Gl).command(Kl).demandCommand(),handler:()=>{Qe.help()}};var jt,vi=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(vi,jt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(le(vi,jt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(le(vi,jt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Rp=vi;jt=new WeakMap,n1(Rp,jt,"/api/v2/quirk");var a1=class extends Rp{constructor(a){super({...a,bypassCache:!0})}};var Jl={command:"get <id>",describe:"Fetch a quirk",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Quirk public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new a1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({quirkId:i,withIntegrations:!0});o.quirks.length===0?(console.error("Quirk did not exist"),process.exit(1)):he(o.quirks[0],p,n)}};var Zl={command:"list",describe:"List quirks",aliases:["ls"],builder:e=>Se(T(F(e.option("withIntegrations",{alias:["i"],describe:"Whether to include meta-quirks created by integrations in the list. Defaults to false.",type:"boolean"})))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r,withIntegrations:n})=>{let d=P(t),o=await new a1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({withIntegrations:n});he(o.quirks,i,p)}};var _a=e=>e.id,xa=e=>`${e.name} (pid: ${e.id})`;function $p({client:e}){async function*a(){let t=(await e.get({withIntegrations:!1})).quirks;for await(let i of t)yield{id:_a(i),displayName:xa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({quirkId:t})},writeObject:async t=>{await e.upsert({quirk:t.object})}}}var Xl={command:"pull <directory>",describe:"Pulls all quirks to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the quirks to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new a1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=$p({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.quirks)!=null?g:[],selectIdentifier:_a,selectDisplayName:xa,onSyncComplete:async(h,_)=>{v.quirks=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:_a,selectDisplayName:xa,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var e6={command:"push <directory>",describe:"Pushes all quirks from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the quirks from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new a1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.quirks)!=null?u:[],selectIdentifier:_a,selectDisplayName:xa})}else l=await Ne({directory:i,selectIdentifier:_a,selectDisplayName:xa});let c=$p({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})})}};var a6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a quirk",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Quirk public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({quirkId:i})}};var t6={command:"update <filename>",aliases:["put"],describe:"Insert or update a quirk",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Quirk file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=B1(i);await n.upsert({quirk:d})}};var i6={command:"quirk <command>",aliases:["qk"],describe:"Commands for Context quirks",builder:e=>e.command(Xl).command(e6).command(Jl).command(a6).command(Zl).command(t6).demandCommand(),handler:()=>{Qe.help()}};var It,wi=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(wi,It),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(le(wi,It));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(le(wi,It));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},qp=wi;It=new WeakMap,n1(qp,It,"/api/v2/signal");var t1=class extends qp{constructor(a){super({...a,bypassCache:!0})}};var p6={command:"get <id>",describe:"Fetch a signal",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Signal public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new t1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({signalId:i});o.signals.length===0?(console.error("Signal did not exist"),process.exit(1)):he(o.signals[0],p,n)}};var r6={command:"list",describe:"List signals",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new t1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();he(s.signals,i,p)}};var Aa=e=>e.id,Ca=e=>`${e.name} (pid: ${e.id})`;function Hp({client:e}){async function*a(){let t=(await e.get()).signals;for await(let i of t)yield{id:Aa(i),displayName:Ca(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({signalId:t})},writeObject:async t=>{await e.upsert({signal:t.object})}}}var n6={command:"pull <directory>",describe:"Pulls all signals to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the signals to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new t1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=Hp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.signals)!=null?g:[],selectIdentifier:Aa,selectDisplayName:Ca,onSyncComplete:async(h,_)=>{v.signals=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:Aa,selectDisplayName:Ca,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var d6={command:"push <directory>",describe:"Pushes all signals from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the signals from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new t1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.signals)!=null?u:[],selectIdentifier:Aa,selectDisplayName:Ca})}else l=await Ne({directory:i,selectIdentifier:Aa,selectDisplayName:Ca});let c=Hp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})})}};var s6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a signal",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Signal public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new t1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({signalId:i})}};var o6={command:"update <filename>",aliases:["put"],describe:"Insert or update a signal",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Signal file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new t1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=B1(i);await n.upsert({signal:d})}};var l6={command:"signal <command>",aliases:["sig"],describe:"Commands for Context signals",builder:e=>e.command(n6).command(d6).command(p6).command(s6).command(r6).command(o6).demandCommand(),handler:()=>{Qe.help()}};var Mt,bi=class extends ze{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(le(bi,Mt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(le(bi,Mt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(le(bi,Mt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Wp=bi;Mt=new WeakMap,n1(Wp,Mt,"/api/v2/test");var i1=class extends Wp{constructor(a){super({...a,bypassCache:!0})}};var m6={command:"get <id>",describe:"Fetch a test",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Test public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new i1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({testId:i});o.tests.length===0?(console.error("Test did not exist"),process.exit(1)):he(o.tests[0],p,n)}};var c6={command:"list",describe:"List tests",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new i1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();he(s.tests,i,p)}};var Sa=e=>e.id,Ea=e=>`${e.name} (pid: ${e.id})`;function zp({client:e}){async function*a(){let t=(await e.get()).tests;for await(let i of t)yield{id:Sa(i),displayName:Ea(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({testId:t})},writeObject:async t=>{await e.upsert({test:t.object})}}}var u6={command:"pull <directory>",describe:"Pulls all tests to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the tests to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new i1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:De}),m=zp({client:l}),c;if(Oe(i)){let v=_e(i,!1);c=await Ce({objects:(g=v.tests)!=null?g:[],selectIdentifier:Sa,selectDisplayName:Ea,onSyncComplete:async(h,_)=>{v.tests=_,D1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:Sa,selectDisplayName:Ea,format:p});await ge({source:m,target:c,mode:r,whatIf:n,log:ve({diffMode:s})})}};var f6={command:"push <directory>",describe:"Pushes all tests from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the tests from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new i1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:De}),l;if(Oe(i)){let g=_e(i,!0);l=await Ce({objects:(u=g.tests)!=null?u:[],selectIdentifier:Sa,selectDisplayName:Ea})}else l=await Ne({directory:i,selectIdentifier:Sa,selectDisplayName:Ea});let c=zp({client:o});await ge({source:l,target:c,mode:p,whatIf:r,log:ve({diffMode:d})})}};var h6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a test",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Test public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new i1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({testId:i})}};var g6={command:"update <filename>",aliases:["put"],describe:"Insert or update a test",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Test file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new i1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=B1(i);await n.upsert({test:d})}};var v6={command:"test <command>",describe:"Commands for Context A/B tests",builder:e=>e.command(u6).command(f6).command(m6).command(h6).command(c6).command(g6).demandCommand(),handler:()=>{Qe.help()}};var x7={commands:[{command:"context <command>",aliases:["ctx"],describe:"Uniform Context commands",builder:e=>e.command(Ql).command(l6).command(wl).command(ml).command(i6).command(v6).demandCommand(),handler:()=>{Qe.showHelp()}}]};0&&(module.exports={readContextPackage,uniformCLI,writeContextPackage});
|
127
127
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
128
128
|
/**
|
package/dist/cli/cli.mjs
CHANGED
@@ -122,7 +122,7 @@ ${g.join(`
|
|
122
122
|
${l==null?void 0:l.message}`)),l}}}return{objects:d(),deleteObject:async s=>{await n7(s)},writeObject:async s=>{ge(s.object,a,n(s.id))}}}function Bo(e,a){if(!a&&!l7.existsSync(e))return{};let t=V1(e);if(typeof t!="object")throw new Error(`Package ${e} does not appear valid.`);return t}function ko(e,a){ge(a,void 0,e)}async function ve({source:e,target:a,compareContents:t=(d,s)=>(0,Uo.default)(d.object,s.object,(o,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:i,allowEmptySource:p=!1,whatIf:r=!1,log:n=()=>{}}){var d,s;let o=new Map;for await(let c of a.objects)o.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,g=o.get(u);if(g){if(!t(c,g)&&(i==="createOrUpdate"||i==="mirror")){let v=async(h,_)=>{var A;if(!r)try{await a.writeObject(h,_)}catch(j){throw new yp(j,h)}n({action:"update",id:u,providerId:h.providerId,displayName:(A=h.displayName)!=null?A:h.providerId,whatIf:r,diff:io(_.object,h.object)})};l.push(v(c,g))}o.delete(u)}else{let v=async(h,_)=>{var A;if(!r)try{await a.writeObject(h)}catch(j){throw new yp(j,h)}n({action:"create",id:_,providerId:_,displayName:(A=h.displayName)!=null?A:h.providerId,whatIf:r,diff:Mn("",JSON.stringify(h.object,null,2))})};l.push(v(c,u))}}if(await Promise.all(l),i==="mirror"){if(!m&&!p)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];o.forEach(async u=>{let g=async v=>{var h;if(!r)try{await a.deleteObject(v.providerId)}catch(_){throw new yp(_,v)}n({action:"delete",id:v.id,providerId:v.providerId,displayName:(h=v.displayName)!=null?h:v.providerId,whatIf:r,diff:Mn(JSON.stringify(v.object,null,2),"")})};c.push(g(u))}),await Promise.all(c)}await Promise.all([(d=e.onSyncComplete)==null?void 0:d.call(e,!1),(s=a.onSyncComplete)==null?void 0:s.call(a,!0)])}var yp=class extends Error{constructor(e,a){var t;super(`Error syncing ${(t=a.displayName)!=null?t:a.providerId} (${a.providerId})
|
123
123
|
${e}`),this.stack=void 0,Object.setPrototypeOf(this,yp.prototype)}},At=sr(or());function we(e){let{diffMode:a="off",indent:t,prefix:i}=e!=null?e:{};return function({action:p,displayName:r,whatIf:n,diff:d}){let s="";switch(p){case"create":s=At.default.green("[A]");break;case"update":s=At.default.white("[U]");break;case"delete":s=At.default.yellow("[D]");break}let o="";(a==="on"||a==="update"&&p==="update")&&(o=`
|
124
124
|
`+d.map(l=>l.added?At.default.green(l.value):l.removed?At.default.red(l.value):l.value).join("")),console.log(`${t!=null?t:""}${n?At.default.gray("[WHATIF]"):""}${s}${i!=null?i:""} ${r}${o}`)}}var Ro=async e=>await e(),L1=class extends Error{constructor(t,i,p,r,n,d){super(`${t}
|
125
|
-
${r}${n?" "+n:""} (${i} ${p}${d?` Request ID: ${d}`:""})`);this.errorMessage=t;this.fetchMethod=i;this.fetchUri=p;this.statusCode=r;this.statusText=n;this.requestId=d;Object.setPrototypeOf(this,L1.prototype)}};var Ge=class{constructor(a){cd(this,"options");var i,p,r,n,d,s;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.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={...a,fetch:t,apiHost:(i=a.apiHost)!=null?i:"https://uniform.app",apiKey:(p=a.apiKey)!=null?p:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(n=a.bearerToken)!=null?n:null,limitPolicy:(d=a.limitPolicy)!=null?d:Ro,bypassCache:(s=a.bypassCache)!=null?s:!1}}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(i["x-bypass-cache"]="true");let p=await this.options.fetch(a.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!p.ok){let n="";try{let d=await p.text();try{let s=JSON.parse(d);s.errorMessage?n=Array.isArray(s.errorMessage)?s.errorMessage.join(", "):s.errorMessage:n=d}catch(s){n=d}}catch(d){n="General error"}throw new L1(n,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),p.status,p.statusText,Ge.getRequestId(p))}return t!=null&&t.expectNoContent?null:await p.json()})}createUrl(a,t){let i=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([p,r])=>{var n;typeof r!="undefined"&&r!==null&&i.searchParams.append(p,(n=r==null?void 0:r.toString())!=null?n:"")}),i}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}};var Ct,si=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(si,Ct),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(me(si,Ct));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(me(si,Ct));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},_p=si;Ct=new WeakMap,n1(_p,Ct,"/api/v2/aggregate");var a1=class extends _p{constructor(a){super({...a,bypassCache:!0})}};var $o={command:"get <id>",describe:"Fetch an aggregate",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new a1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({aggregateId:i});o.aggregates.length===0?(console.error("Aggregate did not exist"),process.exit(1)):ge(o.aggregates[0],p,n)}};var qo={command:"list",describe:"List aggregates",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new a1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get({});ge(s.aggregates,i,p)}};var ha=e=>e.id,ga=e=>`${e.name} (pid: ${e.id})`;function De(e,a){return Bo(e,a)}function B1(e,a){ko(e,a)}import m7 from"p-limit";var Te=m7(8);function xp({client:e,type:a}){async function*t(){let p=(await e.get({type:a})).aggregates;for await(let r of p)yield{id:ha(r),displayName:ga(r),providerId:r.id,object:r}}let i=[];return{objects:t(),deleteObject:async p=>{await e.remove({aggregateId:p})},writeObject:async p=>{await e.upsert({aggregate:p.object,skipInputs:!0}),i.push(p.object)},complete:async()=>{await Promise.all(i.map(p=>e.upsert({aggregate:p,skipInputs:!1})))}}}var Ho={command:"pull <directory>",describe:"Pulls all aggregates to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new a1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=xp({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.aggregates)!=null?g:[],selectIdentifier:ha,selectDisplayName:ga,onSyncComplete:async(h,_)=>{v.aggregates=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:ha,selectDisplayName:ga,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Wo={command:"push <directory>",describe:"Pushes all aggregates from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the aggregates from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new a1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.aggregates)!=null?u:[],selectIdentifier:ha,selectDisplayName:ga})}else l=await Ne({directory:i,selectIdentifier:ha,selectDisplayName:ga});let c=xp({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})}),await c.complete()}};var zo={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an aggregate",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({aggregateId:i})}};var Go={command:"update <filename>",aliases:["put"],describe:"Insert or update an aggregate",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Aggregate file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=V1(i);await n.upsert({aggregate:d})}};var Yo={command:"aggregate <command>",aliases:["agg","intent","audience"],describe:"Commands for Context aggregates (intents, audiences)",builder:e=>e.command(Ho).command(Wo).command($o).command(zo).command(qo).command(Go).demandCommand(),handler:()=>{Je.help()}};var St,li,Ka=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(Ka,St),{...a,projectId:t});return await this.apiClient(i)}async upsertCategory(a){let t=this.createUrl(me(Ka,St));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(a){let t=this.createUrl(me(Ka,St));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(a){let t=this.createUrl(me(Ka,li));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(a){let t=this.createUrl(me(Ka,li));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},oi=Ka;St=new WeakMap,li=new WeakMap,n1(oi,St,"/api/v1/enrichments"),n1(oi,li,"/api/v1/enrichment-values");var C1=class extends oi{constructor(a){super({...a,bypassCache:!0})}};var Ko={command:"get <id>",describe:"Fetch an enrichment category and its values",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{var l,m;let d=P(t),o=(m=(l=await new C1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get())==null?void 0:l.enrichments)==null?void 0:m.filter(c=>c.id===i);o.length===0?(console.error("Enrichment did not exist"),process.exit(1)):ge(o[0],p,n)}};var Qo={command:"list",describe:"List enrichments",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new C1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();ge(s.enrichments,i,p)}};var va=e=>e.id,wa=e=>`${e.name} (pid: ${e.id})`;function Ap({client:e}){async function*a(){let t=(await e.get()).enrichments;for await(let i of t)yield{id:va(i),displayName:wa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeCategory({enrichmentId:t})},writeObject:async(t,i)=>{var n,d;await e.upsertCategory({enrichment:t.object});let p=Jo({categoryId:t.id,values:t.object.values}),r=Jo({categoryId:t.id,values:(d=(n=i==null?void 0:i.object)==null?void 0:n.values)!=null?d:[],client:e});await ve({source:p,target:r,mode:"mirror",whatIf:!1,log:we({diffMode:"off",prefix:` ${t.displayName} value`,indent:"> "})})}}}var Jo=({client:e,categoryId:a,values:t})=>({objects:async function*(){for(let p of t)yield{id:p.id,providerId:p.id,object:p,displayName:`${p.value} (pid: ${p.id})`}}(),deleteObject:async p=>{if(!e)throw new Error("Provider is read only");await e.removeValue({enrichmentId:a,enrichmentValueId:p})},writeObject:async p=>{if(!e)throw new Error("Provider is read only");await e.upsertValue({enrichmentId:a,enrichmentValue:p.object})}});var Zo={command:"pull <directory>",describe:"Pulls all enrichments to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new C1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=Ap({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.enrichments)!=null?g:[],selectIdentifier:va,selectDisplayName:wa,onSyncComplete:async(h,_)=>{v.enrichments=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Xo={command:"push <directory>",describe:"Pushes all enrichments from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the enrichments from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new C1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.enrichments)!=null?u:[],selectIdentifier:va,selectDisplayName:wa})}else l=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa});let c=Ap({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})})}};var el={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an enrichment category and its values",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new C1({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeCategory({enrichmentId:i})}};var al={command:"enrichment <command>",aliases:["enr"],describe:"Commands for Context enrichments",builder:e=>e.command(Zo).command(Xo).command(Ko).command(el).command(Qo).demandCommand(),handler:()=>{Je.help()}};var Fp=Ja(pd());import{writeFile as I7}from"fs";import{exit as Dl}from"process";var Pp,rd=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(rd,Pp),{...a,projectId:t});return await this.apiClient(i)}async publish(){let{projectId:a}=this.options,t=this.createUrl("/api/v1/publish",{siteId:a});await this.apiClient(t,{method:"POST",expectNoContent:!0})}},Tp=rd;Pp=new WeakMap,n1(Tp,Pp,"/api/v2/manifest");var Tt=class extends Tp{constructor(a){super({...a,bypassCache:!0})}};var Tl={command:"get [output]",aliases:["dl","download"],describe:"Download the Uniform Context manifest for a project",builder:e=>T(F(e.option("preview",{describe:"If set, fetches the unpublished preview manifest (The API key must have permission)",default:!1,type:"boolean",alias:["d"]}).option("output",{string:!0,alias:"o",default:process.env.UNIFORM_MANIFEST_PATH,describe:"Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",demandOption:!0}))),handler:async({apiKey:e,apiHost:a,proxy:t,output:i,project:p,preview:r})=>{let n=P(t),d=new Tt({apiHost:a,projectId:p,apiKey:e,fetch:n});try{let s=await d.get({preview:r}),o=JSON.stringify(s,null,2);i?I7(i,o,l=>{l&&(console.error(`Error writing file to ${i}
|
125
|
+
${r}${n?" "+n:""} (${i} ${p}${d?` Request ID: ${d}`:""})`);this.errorMessage=t;this.fetchMethod=i;this.fetchUri=p;this.statusCode=r;this.statusText=n;this.requestId=d;Object.setPrototypeOf(this,L1.prototype)}};var Ge=class{constructor(a){cd(this,"options");var i,p,r,n,d,s;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.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={...a,fetch:t,apiHost:(i=a.apiHost)!=null?i:"https://uniform.app",apiKey:(p=a.apiKey)!=null?p:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(n=a.bearerToken)!=null?n:null,limitPolicy:(d=a.limitPolicy)!=null?d:Ro,bypassCache:(s=a.bypassCache)!=null?s:!1}}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(i["x-bypass-cache"]="true");let p=await this.options.fetch(a.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!p.ok){let n="";try{let d=await p.text();try{let s=JSON.parse(d);s.errorMessage?n=Array.isArray(s.errorMessage)?s.errorMessage.join(", "):s.errorMessage:n=d}catch(s){n=d}}catch(d){n="General error"}throw new L1(n,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),p.status,p.statusText,Ge.getRequestId(p))}return t!=null&&t.expectNoContent?null:await p.json()})}createUrl(a,t){let i=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([p,r])=>{var n;typeof r!="undefined"&&r!==null&&i.searchParams.append(p,Array.isArray(r)?r.join(","):(n=r==null?void 0:r.toString())!=null?n:"")}),i}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}};var Ct,si=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(si,Ct),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(me(si,Ct));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(me(si,Ct));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},_p=si;Ct=new WeakMap,n1(_p,Ct,"/api/v2/aggregate");var a1=class extends _p{constructor(a){super({...a,bypassCache:!0})}};var $o={command:"get <id>",describe:"Fetch an aggregate",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new a1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({aggregateId:i});o.aggregates.length===0?(console.error("Aggregate did not exist"),process.exit(1)):ge(o.aggregates[0],p,n)}};var qo={command:"list",describe:"List aggregates",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new a1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get({});ge(s.aggregates,i,p)}};var ha=e=>e.id,ga=e=>`${e.name} (pid: ${e.id})`;function De(e,a){return Bo(e,a)}function B1(e,a){ko(e,a)}import m7 from"p-limit";var Te=m7(8);function xp({client:e,type:a}){async function*t(){let p=(await e.get({type:a})).aggregates;for await(let r of p)yield{id:ha(r),displayName:ga(r),providerId:r.id,object:r}}let i=[];return{objects:t(),deleteObject:async p=>{await e.remove({aggregateId:p})},writeObject:async p=>{await e.upsert({aggregate:p.object,skipInputs:!0}),i.push(p.object)},complete:async()=>{await Promise.all(i.map(p=>e.upsert({aggregate:p,skipInputs:!1})))}}}var Ho={command:"pull <directory>",describe:"Pulls all aggregates to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new a1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=xp({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.aggregates)!=null?g:[],selectIdentifier:ha,selectDisplayName:ga,onSyncComplete:async(h,_)=>{v.aggregates=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:ha,selectDisplayName:ga,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Wo={command:"push <directory>",describe:"Pushes all aggregates from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the aggregates from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new a1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.aggregates)!=null?u:[],selectIdentifier:ha,selectDisplayName:ga})}else l=await Ne({directory:i,selectIdentifier:ha,selectDisplayName:ga});let c=xp({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})}),await c.complete()}};var zo={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an aggregate",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Aggregate public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({aggregateId:i})}};var Go={command:"update <filename>",aliases:["put"],describe:"Insert or update an aggregate",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Aggregate file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new a1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=V1(i);await n.upsert({aggregate:d})}};var Yo={command:"aggregate <command>",aliases:["agg","intent","audience"],describe:"Commands for Context aggregates (intents, audiences)",builder:e=>e.command(Ho).command(Wo).command($o).command(zo).command(qo).command(Go).demandCommand(),handler:()=>{Je.help()}};var St,li,Ka=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(Ka,St),{...a,projectId:t});return await this.apiClient(i)}async upsertCategory(a){let t=this.createUrl(me(Ka,St));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(a){let t=this.createUrl(me(Ka,St));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(a){let t=this.createUrl(me(Ka,li));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(a){let t=this.createUrl(me(Ka,li));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},oi=Ka;St=new WeakMap,li=new WeakMap,n1(oi,St,"/api/v1/enrichments"),n1(oi,li,"/api/v1/enrichment-values");var C1=class extends oi{constructor(a){super({...a,bypassCache:!0})}};var Ko={command:"get <id>",describe:"Fetch an enrichment category and its values",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{var l,m;let d=P(t),o=(m=(l=await new C1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get())==null?void 0:l.enrichments)==null?void 0:m.filter(c=>c.id===i);o.length===0?(console.error("Enrichment did not exist"),process.exit(1)):ge(o[0],p,n)}};var Qo={command:"list",describe:"List enrichments",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new C1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();ge(s.enrichments,i,p)}};var va=e=>e.id,wa=e=>`${e.name} (pid: ${e.id})`;function Ap({client:e}){async function*a(){let t=(await e.get()).enrichments;for await(let i of t)yield{id:va(i),displayName:wa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeCategory({enrichmentId:t})},writeObject:async(t,i)=>{var n,d;await e.upsertCategory({enrichment:t.object});let p=Jo({categoryId:t.id,values:t.object.values}),r=Jo({categoryId:t.id,values:(d=(n=i==null?void 0:i.object)==null?void 0:n.values)!=null?d:[],client:e});await ve({source:p,target:r,mode:"mirror",whatIf:!1,log:we({diffMode:"off",prefix:` ${t.displayName} value`,indent:"> "})})}}}var Jo=({client:e,categoryId:a,values:t})=>({objects:async function*(){for(let p of t)yield{id:p.id,providerId:p.id,object:p,displayName:`${p.value} (pid: ${p.id})`}}(),deleteObject:async p=>{if(!e)throw new Error("Provider is read only");await e.removeValue({enrichmentId:a,enrichmentValueId:p})},writeObject:async p=>{if(!e)throw new Error("Provider is read only");await e.upsertValue({enrichmentId:a,enrichmentValue:p.object})}});var Zo={command:"pull <directory>",describe:"Pulls all enrichments to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new C1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=Ap({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.enrichments)!=null?g:[],selectIdentifier:va,selectDisplayName:wa,onSyncComplete:async(h,_)=>{v.enrichments=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Xo={command:"push <directory>",describe:"Pushes all enrichments from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the enrichments from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new C1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.enrichments)!=null?u:[],selectIdentifier:va,selectDisplayName:wa})}else l=await Ne({directory:i,selectIdentifier:va,selectDisplayName:wa});let c=Ap({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})})}};var el={command:"remove <id>",aliases:["delete","rm"],describe:"Delete an enrichment category and its values",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Enrichment category public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new C1({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeCategory({enrichmentId:i})}};var al={command:"enrichment <command>",aliases:["enr"],describe:"Commands for Context enrichments",builder:e=>e.command(Zo).command(Xo).command(Ko).command(el).command(Qo).demandCommand(),handler:()=>{Je.help()}};var Fp=Ja(pd());import{writeFile as I7}from"fs";import{exit as Dl}from"process";var Pp,rd=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(rd,Pp),{...a,projectId:t});return await this.apiClient(i)}async publish(){let{projectId:a}=this.options,t=this.createUrl("/api/v1/publish",{siteId:a});await this.apiClient(t,{method:"POST",expectNoContent:!0})}},Tp=rd;Pp=new WeakMap,n1(Tp,Pp,"/api/v2/manifest");var Tt=class extends Tp{constructor(a){super({...a,bypassCache:!0})}};var Tl={command:"get [output]",aliases:["dl","download"],describe:"Download the Uniform Context manifest for a project",builder:e=>T(F(e.option("preview",{describe:"If set, fetches the unpublished preview manifest (The API key must have permission)",default:!1,type:"boolean",alias:["d"]}).option("output",{string:!0,alias:"o",default:process.env.UNIFORM_MANIFEST_PATH,describe:"Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",demandOption:!0}))),handler:async({apiKey:e,apiHost:a,proxy:t,output:i,project:p,preview:r})=>{let n=P(t),d=new Tt({apiHost:a,projectId:p,apiKey:e,fetch:n});try{let s=await d.get({preview:r}),o=JSON.stringify(s,null,2);i?I7(i,o,l=>{l&&(console.error(`Error writing file to ${i}
|
126
126
|
`,l),Dl(1)),console.log(Fp.default.green(`\u2705 ${i} has been updated from ${a}`))}):console.log(o)}catch(s){let o;s instanceof L1?(s.statusCode===403&&(o=`The API key ${e} did not have permissions to fetch the manifest. Ensure ${r?"Uniform Context > Read Drafts":"Uniform Context > Manifest > Read"} permissions are granted.`),o=s.message):o=s.toString(),console.error(Fp.default.red("\u26A0 Error fetching Context manifest")),console.error(Fp.default.gray(` \u2757 ${o}`)),Dl(1)}}};var nd=Ja(pd());import{exit as M7}from"process";var Pl={command:"publish",describe:"Publish the Uniform Context manifest for a project",builder:e=>T(F(e)),handler:async({apiKey:e,apiHost:a,proxy:t,project:i})=>{let p=P(t);try{await new Tt({apiHost:a,projectId:i,apiKey:e,fetch:p}).publish()}catch(r){let n;r instanceof L1?(r.statusCode===403&&(n=`The API key ${e} did not have permissions to publish the manifest. Ensure Uniform Context > Manifest > Publish permissions are granted.`),n=r.message):n=r.toString(),console.error(nd.default.red("\u26A0 Error publishing Context manifest")),console.error(nd.default.gray(` \u2757 ${n}`)),M7(1)}}};var Fl={command:"manifest <command>",describe:"Commands for context manifests",aliases:["man"],builder:e=>e.command(Tl).command(Pl).demandCommand(),handler:()=>{Je.help()}};var Pt,ui=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(ui,Pt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(me(ui,Pt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(me(ui,Pt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},jp=ui;Pt=new WeakMap,n1(jp,Pt,"/api/v2/quirk");var t1=class extends jp{constructor(a){super({...a,bypassCache:!0})}};var jl={command:"get <id>",describe:"Fetch a quirk",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Quirk public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new t1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({quirkId:i,withIntegrations:!0});o.quirks.length===0?(console.error("Quirk did not exist"),process.exit(1)):ge(o.quirks[0],p,n)}};var Il={command:"list",describe:"List quirks",aliases:["ls"],builder:e=>Se(T(F(e.option("withIntegrations",{alias:["i"],describe:"Whether to include meta-quirks created by integrations in the list. Defaults to false.",type:"boolean"})))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r,withIntegrations:n})=>{let d=P(t),o=await new t1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({withIntegrations:n});ge(o.quirks,i,p)}};var ba=e=>e.id,ya=e=>`${e.name} (pid: ${e.id})`;function Ip({client:e}){async function*a(){let t=(await e.get({withIntegrations:!1})).quirks;for await(let i of t)yield{id:ba(i),displayName:ya(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({quirkId:t})},writeObject:async t=>{await e.upsert({quirk:t.object})}}}var Ml={command:"pull <directory>",describe:"Pulls all quirks to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the quirks to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new t1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=Ip({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.quirks)!=null?g:[],selectIdentifier:ba,selectDisplayName:ya,onSyncComplete:async(h,_)=>{v.quirks=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Vl={command:"push <directory>",describe:"Pushes all quirks from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the quirks from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new t1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.quirks)!=null?u:[],selectIdentifier:ba,selectDisplayName:ya})}else l=await Ne({directory:i,selectIdentifier:ba,selectDisplayName:ya});let c=Ip({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})})}};var Ll={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a quirk",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Quirk public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new t1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({quirkId:i})}};var Bl={command:"update <filename>",aliases:["put"],describe:"Insert or update a quirk",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Quirk file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new t1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=V1(i);await n.upsert({quirk:d})}};var kl={command:"quirk <command>",aliases:["qk"],describe:"Commands for Context quirks",builder:e=>e.command(Ml).command(Vl).command(jl).command(Ll).command(Il).command(Bl).demandCommand(),handler:()=>{Je.help()}};var Ft,fi=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(fi,Ft),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(me(fi,Ft));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(me(fi,Ft));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Mp=fi;Ft=new WeakMap,n1(Mp,Ft,"/api/v2/signal");var i1=class extends Mp{constructor(a){super({...a,bypassCache:!0})}};var Ul={command:"get <id>",describe:"Fetch a signal",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Signal public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new i1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({signalId:i});o.signals.length===0?(console.error("Signal did not exist"),process.exit(1)):ge(o.signals[0],p,n)}};var Rl={command:"list",describe:"List signals",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new i1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();ge(s.signals,i,p)}};var _a=e=>e.id,xa=e=>`${e.name} (pid: ${e.id})`;function Vp({client:e}){async function*a(){let t=(await e.get()).signals;for await(let i of t)yield{id:_a(i),displayName:xa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({signalId:t})},writeObject:async t=>{await e.upsert({signal:t.object})}}}var $l={command:"pull <directory>",describe:"Pulls all signals to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the signals to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new i1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=Vp({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.signals)!=null?g:[],selectIdentifier:_a,selectDisplayName:xa,onSyncComplete:async(h,_)=>{v.signals=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:_a,selectDisplayName:xa,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var ql={command:"push <directory>",describe:"Pushes all signals from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the signals from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new i1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.signals)!=null?u:[],selectIdentifier:_a,selectDisplayName:xa})}else l=await Ne({directory:i,selectIdentifier:_a,selectDisplayName:xa});let c=Vp({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})})}};var Hl={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a signal",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Signal public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new i1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({signalId:i})}};var Wl={command:"update <filename>",aliases:["put"],describe:"Insert or update a signal",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Signal file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new i1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=V1(i);await n.upsert({signal:d})}};var zl={command:"signal <command>",aliases:["sig"],describe:"Commands for Context signals",builder:e=>e.command($l).command(ql).command(Ul).command(Hl).command(Rl).command(Wl).demandCommand(),handler:()=>{Je.help()}};var jt,hi=class extends Ge{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(me(hi,jt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(me(hi,jt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(me(hi,jt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Lp=hi;jt=new WeakMap,n1(Lp,jt,"/api/v2/test");var p1=class extends Lp{constructor(a){super({...a,bypassCache:!0})}};var Gl={command:"get <id>",describe:"Fetch a test",builder:e=>Se(T(F(e.positional("id",{demandOption:!0,describe:"Test public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:n})=>{let d=P(t),o=await new p1({apiKey:a,apiHost:e,fetch:d,projectId:r}).get({testId:i});o.tests.length===0?(console.error("Test did not exist"),process.exit(1)):ge(o.tests[0],p,n)}};var Yl={command:"list",describe:"List tests",aliases:["ls"],builder:e=>Se(T(F(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let n=P(t),s=await new p1({apiKey:a,apiHost:e,fetch:n,projectId:r}).get();ge(s.tests,i,p)}};var Aa=e=>e.id,Ca=e=>`${e.name} (pid: ${e.id})`;function Bp({client:e}){async function*a(){let t=(await e.get()).tests;for await(let i of t)yield{id:Aa(i),displayName:Ca(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({testId:t})},writeObject:async t=>{await e.upsert({test:t.object})}}}var Kl={command:"pull <directory>",describe:"Pulls all tests to local files in a directory",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to save the tests to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:n,project:d,diff:s})=>{var g;let o=P(t),l=new p1({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Te}),m=Bp({client:l}),c;if(Oe(i)){let v=De(i,!1);c=await Ce({objects:(g=v.tests)!=null?g:[],selectIdentifier:Aa,selectDisplayName:Ca,onSyncComplete:async(h,_)=>{v.tests=_,B1(i,v)}})}else c=await Ne({directory:i,selectIdentifier:Aa,selectDisplayName:Ca,format:p});await ve({source:m,target:c,mode:r,whatIf:n,log:we({diffMode:s})})}};var Ql={command:"push <directory>",describe:"Pushes all tests from files in a directory or package to Uniform",builder:e=>T(F(Ee(e.positional("directory",{describe:"Directory to read the tests from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:n,diff:d})=>{var u;let s=P(t),o=new p1({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Te}),l;if(Oe(i)){let g=De(i,!0);l=await Ce({objects:(u=g.tests)!=null?u:[],selectIdentifier:Aa,selectDisplayName:Ca})}else l=await Ne({directory:i,selectIdentifier:Aa,selectDisplayName:Ca});let c=Bp({client:o});await ve({source:l,target:c,mode:p,whatIf:r,log:we({diffMode:d})})}};var Jl={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a test",builder:e=>T(F(e.positional("id",{demandOption:!0,describe:"Test public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=P(t);await new p1({apiKey:a,apiHost:e,fetch:r,projectId:p}).remove({testId:i})}};var Zl={command:"update <filename>",aliases:["put"],describe:"Insert or update a test",builder:e=>T(F(e.positional("filename",{demandOption:!0,describe:"Test file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=P(t),n=new p1({apiKey:a,apiHost:e,fetch:r,projectId:p}),d=V1(i);await n.upsert({test:d})}};var Xl={command:"test <command>",describe:"Commands for Context A/B tests",builder:e=>e.command(Kl).command(Ql).command(Gl).command(Jl).command(Yl).command(Zl).demandCommand(),handler:()=>{Je.help()}};var Jy={commands:[{command:"context <command>",aliases:["ctx"],describe:"Uniform Context commands",builder:e=>e.command(Fl).command(zl).command(al).command(Yo).command(kl).command(Xl).demandCommand(),handler:()=>{Je.showHelp()}}]};export{De as readContextPackage,Jy as uniformCLI,B1 as writeContextPackage};
|
127
127
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
128
128
|
/**
|
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
"use strict";var Te=Object.create;var F=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Oe=(e,t,i)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ue=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},Bt=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Re.call(e,n)&&n!==i&&F(e,n,{get:()=>t[n],enumerable:!(r=ke(t,n))||r.enumerable});return e};var $=(e,t,i)=>(i=e!=null?Te(we(e)):{},Bt(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),$e=e=>Bt(F({},"__esModule",{value:!0}),e);var y=(e,t,i)=>(Oe(e,typeof t!="symbol"?t+"":t,i),i),Dt=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(Dt(e,t,"read from private field"),i?i.call(e):t.get(e)),d=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},p=(e,t,i,r)=>(Dt(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(Dt(e,t,"access private method"),i);var Ye={};Ue(Ye,{Context:()=>qt,CookieTransitionDataStore:()=>Ut,EdgeNodeTagName:()=>Ke,EdgeTransitionDataStore:()=>$t,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>B,SERVER_STATE_ID:()=>ee,ScriptType:()=>Ve,TransitionDataStore:()=>N,UNIFORM_DEFAULT_COOKIE_NAME:()=>ae,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Ct,cookieEvaluator:()=>xt,createConsoleLogDrain:()=>Ce,createDebugConsoleLogDrain:()=>Ee,createLinearDecay:()=>ze,currentPageEvaluator:()=>Tt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>_e,enableContextDevTools:()=>He,enableDebugConsoleLogDrain:()=>Fe,evaluateVariantMatch:()=>zt,eventEvaluator:()=>Vt,explainStringMatch:()=>P,explainStringMatchCriteria:()=>ut,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>lt,pageViewCountEvaluator:()=>ct,parseQuickConnect:()=>We,personalizeVariations:()=>Gt,queryStringEvaluator:()=>bt,quirkEvaluator:()=>Et,serializeQuickConnect:()=>Je,testVariations:()=>vt});module.exports=$e(Ye);function Ct(e,t){let i={...e};for(let r in t){let n=Jt(e,r,t,new Set([r]));n!==0&&(i[r]=n)}return i}function Jt(e,t,i,r){var s;let n=0;for(let o of i[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&i[o.dim]){if(r.has(o.dim))continue;let l=new Set(r);l.add(o.dim),u=Jt(e,o.dim,i,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var st="_";var K,H,at=class{constructor(t,i,r){d(this,K,void 0);d(this,H,void 0);y(this,"signal");this.signal=t,p(this,K,i),p(this,H,r)}computeSignal(t,i){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,K).evaluate(t,this.signal.crit,i,this.signal,a(this,H)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&i.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,J,O,B=class{constructor({manifest:t,evaluator:i=new A({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,E,void 0);d(this,J,void 0);d(this,O,void 0);var n,s,o;p(this,E,(n=t.project)!=null?n:{}),this.data=t,p(this,J,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new at({...c,id:u},i,r))),p(this,O,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,E).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,E).test)==null?void 0:i[t]}computeSignals(t){let i=[];a(this,O).call(this,["debug",200,"GROUP"]);try{a(this,J).forEach(r=>{a(this,O).call(this,["debug",201,"GROUP",r.signal]);try{r.computeSignal(t,i)}finally{a(this,O).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,O).call(this,["debug",200,"ENDGROUP"])}return i}computeAggregateDimensions(t){var i,r;return Ct(t,(r=(i=a(this,E).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,s,o;let i=t.indexOf(st);return i<=0?(n=(r=a(this,E).pz)==null?void 0:r.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,i)]}};E=new WeakMap,J=new WeakMap,O=new WeakMap;var Xt=require("dequal/lite");function x(e,t){var o,u,c,l,f,m;let i=(o=t==null?void 0:t.op)!=null?o:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":Wt(e)).toString(),s=(r?t.rhs:Wt(t.rhs)).toString();switch(i){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),r?"":"i").test((f=e==null?void 0:e.toString())!=null?f:"");case"!//":return!new RegExp(t.rhs.toString(),r?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${i}.`)}}function P(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ut(t)}`}function ut(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Wt(e){var t,i;return(i=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?i:""}var xt=({update:e,criteria:t,onLogMessage:i})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let r=!(0,Xt.dequal)(Yt(e.state.cookies),Yt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};function Yt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...i}=e;return i}function Zt(e,t){var r;if(typeof e=="undefined"||e===null)return!1;let i=Number(e);if(isNaN(i))return!1;switch((r=t==null?void 0:t.op)!=null?r:"="){case"=":return i===t.rhs;case"!=":return i!==t.rhs;case">":return i>t.rhs;case"<":return i<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function Mt(e,t){return`${e} ${Ae(t)}`}function Ae(e){return`${e.op} ${e.rhs}`}function W(e,t){return`${e}${st}${t}`}var lt=W("$pvc","v"),ct=({update:e,criteria:t,commands:i,onLogMessage:r})=>{var l,f;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((f=e.previousState.url)==null?void 0:f.toString()))),o=(e.visitor.sessionScores[lt]||0)+1,u={result:!1,changed:n},c=i.some(m=>m.type==="modscoreS"&&m.data.dimension===lt);return n&&!c&&i.push({type:"modscoreS",data:{dimension:lt,delta:1}}),Zt(o,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:Mt(o,t.match)}]),u};ct.alwaysExecute=!0;var bt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,f,m;if(t.type!=="QS")return{result:!1,changed:!1};let r=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};var Et=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var f;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&i.dur==="t"&&e.scores[i.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(f=e.state.quirks)==null?void 0:f[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:x(o,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:P(o,t.match)}]),l};var Vt=({update:e,criteria:t,onLogMessage:i})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!1,n={result:r,changed:r};return i==null||i(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${ut(t.event)}`}]),n};var Tt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let r=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(r==null?void 0:r.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:x(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(r,t.path)}]),o};var Y,A=class{constructor(t){d(this,Y,void 0);p(this,Y,t)}evaluate(t,i,r,n,s){let o=i.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",i]));try{let u=!(i.op==="&"||!i.op),c=null,l=!1;for(let m of i.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,r,n,s);else{let D=a(this,Y)[m.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${m.type} signal criteria not registered`);S=D({update:t,criteria:m,commands:r,signal:n,onLogMessage:s})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let f=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,f])),f}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};Y=new WeakMap;var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Lt=$(require("mitt")),te=require("dequal/lite"),ee="__UNIFORM_DATA__",U,Z,q,N=class{constructor({initialData:t}){d(this,U,void 0);d(this,Z,void 0);d(this,q,(0,Lt.default)());y(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&(p(this,U,t),p(this,Z,t))}get data(){return a(this,U)}get initialData(){return a(this,Z)}updateData(t,i){return p(this,U,i),this.handleUpdateData(t,i)}async delete(t){p(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,te.dequal)(this.data,t)||(p(this,U,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(ee);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,Z=new WeakMap,q=new WeakMap;var kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ie=kt.split(""),re=new Array(123);for(let e=0;e<kt.length;e++)re[kt.charCodeAt(e)]=e;var Pt=e=>{if(e<0)return`-${Pt(-e)}`;let t=e>>>0,i=e/4294967296>>>0,r="";for(;i>0;)r=ie[63&t]+r,t>>>=6,t|=(63&i)<<26,i>>>=6;let n="";do n=ie[63&t]+n,t>>>=6;while(t>0);return n+r},ne=e=>{let t=0,i=e.charAt(0)==="-"?1:0;for(let r=i;r<e.length;r++)t=t*64+re[e.charCodeAt(r)];return i?-t:t};var dt=$(require("js-cookie")),wt=typeof document=="undefined",ae="ufvd",G,M,Ut=class extends N{constructor({serverCookieValue:i,cookieName:r=ae,cookieAttributes:n={sameSite:"lax"}}){super({initialData:wt?Ne(i):void 0});d(this,G,void 0);d(this,M,void 0);p(this,G,r),p(this,M,n)}handleDelete(){return wt||dt.default.remove(a(this,G)),Promise.resolve()}async handleUpdateData(i,r){wt||(r.consent?dt.default.set(a(this,G),Ge(r),a(this,M)):dt.default.remove(a(this,G)))}};G=new WeakMap,M=new WeakMap;var ue="~",le="!",ce="-";function Ne(e){if(!e)return;let t=e.split(ue);if(t.length>3)return;let[i,r,n]=t;return{consent:!0,sessionScores:oe(Rt(r)),scores:oe(Rt(n)),tests:Rt(i)}}function Rt(e){return e.split(le).map(i=>i.split(ce)).reduce((i,r)=>(r.length<2||(i[r[0]]=r.slice(1).join("-")),i),{})}function oe(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=ne(r),t),{})}function Ge(e){return[Ot(e.tests),Ot(se(e.sessionScores)),Ot(se(e.scores))].join(ue)}function se(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=Pt(r),t),{})}function Ot(e){return Object.entries(e).map(t=>t.join(ce)).join(le)}var ft,de,$t=class extends N{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,ft);n.initialData||v(this,ft,de).call(this).catch(s=>{console.error(s)})}handleDelete(i){throw new Error("Method not implemented.")}async handleUpdateData(i){let r=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};ft=new WeakSet,de=async function(){let i=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)};function ze(e){let{gracePeriod:t=864e5,decayRate:i=1/30,decayCap:r=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(fe(u,D),fe(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function fe(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}var he=$(require("mitt")),L=require("dequal/lite");var pt=class{constructor(){y(this,"inMemoryFallback",{});y(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let i=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||i)return i;try{let r=localStorage.getItem(t);return r?JSON.parse(r):void 0}catch(r){return i}}set(t,i,r){if(this.inMemoryFallback[t]=i,!(!this.hasLocalStorageObject||!r))try{localStorage.setItem(t,JSON.stringify(i))}catch(n){console.warn(n)}}delete(t,i){i||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(r){}}};var pe=$(require("rfdc"));var Ie=(0,pe.default)();function me(e,t,i){let r=t?Ie(t):X();return e.forEach(n=>{var s,o;switch(n.type){case"consent":r.consent=n.data;break;case"setquirk":r.quirks[n.data.key]=n.data.value;break;case"settest":r.tests[n.data.test]=n.data.variant;break;case"modscore":if(i)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=r.scores[n.data.dimension])!=null?s:0;r.scores[n.data.dimension]=c+u;break;case"modscoreS":if(i)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let f=(o=r.sessionScores[n.data.dimension])!=null?o:0;r.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var mt="ufvisitor",V,I,j,g,b,w,R,z,ht,ge,gt,ve,et,At,it,Nt,tt=class{constructor(t){d(this,b);d(this,R);d(this,ht);d(this,gt);d(this,et);d(this,it);d(this,V,(0,he.default)());d(this,I,new pt);d(this,j,void 0);d(this,g,void 0);y(this,"events",{on:a(this,V).on,off:a(this,V).off});if(p(this,g,t),a(this,b,w)||v(this,R,z).call(this,v(this,it,Nt).call(this),!0),t.transitionStore){let i=t.transitionStore.getClientTransitionState();i&&t.onServerTransitionReceived&&t.onServerTransitionReceived(i),t.transitionStore.events.on("dataUpdatedAsync",n=>{v(this,R,z).call(this,{...a(this,b,w).visitorData,...n})});let r=t.transitionStore.data;r&&v(this,R,z).call(this,{...a(this,b,w).visitorData,...r},!0)}}get data(){var i,r;let t=a(this,b,w);if(v(this,gt,ve).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return v(this,R,z).call(this,{...s,sessionScores:{}}),(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}get options(){return a(this,g)}async updateData(t){var r,n,s,o;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=me(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(mt,!0),v(this,R,z).call(this,i),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var i,r,n,s,o;(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",103,"GROUP",t]);try{a(this,I).delete(mt,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),v(this,R,z).call(this,v(this,it,Nt).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};V=new WeakMap,I=new WeakMap,j=new WeakMap,g=new WeakMap,b=new WeakSet,w=function(){return a(this,I).get(mt)},R=new WeakSet,z=function(t,i=!1){var f,m,S,D,ot,Qt,Ft,Kt,Ht;let r=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,et,At).call(this,t.scores),v(this,et,At).call(this,t.sessionScores),(m=(f=a(this,g)).decay)==null||m.call(f,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!(0,L.dequal)(r==null?void 0:r.visitorData.scores,t.scores),o=!(0,L.dequal)(r==null?void 0:r.visitorData.sessionScores,t.sessionScores),u=!(0,L.dequal)(r==null?void 0:r.visitorData.quirks,t.quirks),c=!(0,L.dequal)(r==null?void 0:r.visitorData.tests,t.tests),l={updated:n,visitorData:t};v(this,ht,ge).call(this),a(this,I).set(mt,l,!!t.consent),(D=(S=a(this,g)).onLogMessage)==null||D.call(S,["debug",102,t]),i||((s||o)&&a(this,V).emit("scoresUpdated",t),u&&a(this,V).emit("quirksUpdated",t),c&&a(this,V).emit("testsUpdated",t),((ot=r==null?void 0:r.visitorData)==null?void 0:ot.consent)!==t.consent&&a(this,V).emit("consentUpdated",t),((Qt=r==null?void 0:r.visitorData)==null?void 0:Qt.controlGroup)!==t.controlGroup&&(a(this,V).emit("controlGroupUpdated",t),(Ht=(Kt=a(this,g)).onLogMessage)==null||Ht.call(Kt,["debug",104,(Ft=t.controlGroup)!=null?Ft:!1])))},ht=new WeakSet,ge=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),p(this,j,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},gt=new WeakSet,ve=function(t){let i=a(this,g).visitLifespan;return i?t.updated+i<Date.now():!1},et=new WeakSet,At=function(t){var i,r;if(!!a(this,g).manifest)for(let n in t){let s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},it=new WeakSet,Nt=function(){var t,i,r;return{...X(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(r=(i=a(this,g).manifest)==null?void 0:i.rollForControlGroup())!=null?r:!1}};var ye=$(require("mitt"));function Gt({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],f=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||zt(S.id,S.pz,m,n)&&(f=!0,l.push(S))}return{personalized:f,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function zt(e,t,i,r){r==null||r(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>Se(s,i,r)):n=t.crit.some(s=>Se(s,i,r)):(r==null||r(["info",302,{matched:!0,description:"default variation"}]),n=!0),r==null||r(["info",303,n])}finally{r==null||r(["info",301,"ENDGROUP"])}return n}function Se(e,t,i){var u,c;let{op:r,l:n}=e,s=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(r==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(o))return i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=s>o;return _(i,l,e,s,o),l}else if(r===">="){let l=s>=o;return _(i,l,e,s,o),l}else if(r==="<"){let l=s<o;return _(i,l,e,s,o),l}else if(r==="<="){let l=s<=o;return _(i,l,e,s,o),l}else if(r==="="){let l=s===o;return _(i,l,e,s,o),l}else if(r==="!="){let l=s!==o;return _(i,l,e,s,o),l}else throw new Error(`Unknown op: ${r}`)}function _(e,t,i,r,n){e==null||e(["info",302,{matched:t,description:`${i.l}[${r}] ${i.op} ${i.rDim?`${i.rDim}[${n}]`:i.r}`}])}var qe=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{values:[],total:0,missingDistribution:0});if(i>100)throw new Error(`Total distribution ${i} is over the maximum 100.`);if(i<100){let s=(100-i)/r;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=i.find(o=>o.id===s),n||r==null||r(["warn",402,{missingVariant:s,variants:i.map(o=>o.id)}])),!n){let o=qe(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,f)=>{let m=o[f];if(u>c&&u<=c+m)return l;c+=m}),n&&(r==null||r(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(r==null||r(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{r==null||r(["info",400,"ENDGROUP"])}};var It=require("dequal/lite"),C,T,k,rt,h,nt,jt,Q,St,qt=class{constructor(t){d(this,nt);d(this,Q);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,rt,{});d(this,h,(0,ye.default)());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:i,...r}=t;p(this,k,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,h).on("log",o.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new B({onLogMessage:o=>a(this,h).emit("log",o),manifest:i,evaluator:new A({CK:xt,QS:bt,QK:Et,PVC:ct,EVT:Vt,PV:Tt})}),this.storage=new tt({...r,manifest:this.manifest,onServerTransitionReceived:o=>{p(this,C,o),o.ssv&&(p(this,T,o.ssv),a(this,h).emit("log",["debug",130,o]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",v(this,Q,St).bind(this)),a(this,C)||v(this,Q,St).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(u),a(this,h).emit("quirksUpdated",o.quirks),a(this,h).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,T)}get quirks(){var t,i;return(i=(t=a(this,C))==null?void 0:t.quirks)!=null?i:this.storage.data.quirks}async update(t){var n,s,o;let i=[],r={};if((n=a(this,C))!=null&&n.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(s=a(this,C))!=null&&s.tests){let u=Object.entries(a(this,C).tests);if(u.length>0){let c=[];u.forEach(([l,f])=>{this.storage.data.tests[l]||(c.push([l,f]),r[l]=f)}),i.push(...c.map(([l,f])=>({type:"settest",data:{test:l,variant:f}})))}}try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(o=t.url)==null?void 0:o.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([u,c])=>({type:"setquirk",data:{key:u,value:c}}))),t.enrichments&&t.enrichments.forEach(u=>{let c=W(u.cat,u.key);this.manifest.getDimensionByKey(c)?i.push({type:"modscore",data:{dimension:c,delta:u.str}}):a(this,h).emit("log",["warn",5,u])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),p(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,Q,St).call(this,this.storage.data),Object.entries(r).forEach(([u,c])=>{v(this,nt,jt).call(this,{name:u,variantId:c,variantAssigned:!0})}),p(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r,n,s,o;let i=this.manifest.getTest(t);return i?(o=(s=i.wv)!=null?s:(n=(r=a(this,C))==null?void 0:r.tests)==null?void 0:n[t])!=null?o:this.storage.data.tests[t]:(a(this,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,i){this.storage.updateData([{type:"settest",data:{test:t,variant:i}}])}log(...t){a(this,h).emit("log",t)}test(t){var r,n;let i=vt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)});return v(this,nt,jt).call(this,{name:t.name,variantId:(n=(r=i.result)==null?void 0:r.id)!=null?n:void 0,variantAssigned:i.variantAssigned}),i}personalize(t){let i=Gt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)}),r=a(this,rt)[t.name],n={name:t.name,variantIds:i.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return r&&(0,It.dequal)(n.variantIds,r)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,rt)[t.name]=n.variantIds,i}async forget(t){p(this,k,{}),await this.storage.delete(t)}getServerToClientTransitionState(){let t={quirks:this.storage.data.quirks,ssv:a(this,T),tests:{}},i=this.storage.data.tests;return Object.entries(i).map(([r,n])=>{var s,o,u;((u=(o=(s=this.storage.options.transitionStore)==null?void 0:s.initialData)==null?void 0:o.tests)==null?void 0:u[r])!==i[r]&&t.tests&&(t.tests[r]=n)}),t}};C=new WeakMap,T=new WeakMap,k=new WeakMap,rt=new WeakMap,h=new WeakMap,nt=new WeakSet,jt=function(t){a(this,h).emit("testResult",t)},Q=new WeakSet,St=function(t){var n;let i={...t.scores};for(let s in t.sessionScores)i[s]=((n=i[s])!=null?n:0)+t.sessionScores[s];i=this.manifest.computeAggregateDimensions(i),!(0,It.dequal)(i,a(this,T))&&(p(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};var De=$(require("rfdc"));function yt(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var je=(0,De.default)();function Ce(e){return([t,...i])=>{if(!yt(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
|
1
|
+
"use strict";var Te=Object.create;var F=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Oe=(e,t,i)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ue=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},Bt=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Re.call(e,n)&&n!==i&&F(e,n,{get:()=>t[n],enumerable:!(r=ke(t,n))||r.enumerable});return e};var $=(e,t,i)=>(i=e!=null?Te(we(e)):{},Bt(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),$e=e=>Bt(F({},"__esModule",{value:!0}),e);var y=(e,t,i)=>(Oe(e,typeof t!="symbol"?t+"":t,i),i),Dt=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(Dt(e,t,"read from private field"),i?i.call(e):t.get(e)),d=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},p=(e,t,i,r)=>(Dt(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(Dt(e,t,"access private method"),i);var Ye={};Ue(Ye,{Context:()=>qt,CookieTransitionDataStore:()=>Ut,EdgeNodeTagName:()=>Ke,EdgeTransitionDataStore:()=>$t,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>B,SERVER_STATE_ID:()=>ee,ScriptType:()=>Ve,TransitionDataStore:()=>N,UNIFORM_DEFAULT_COOKIE_NAME:()=>ae,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Ct,cookieEvaluator:()=>xt,createConsoleLogDrain:()=>Ce,createDebugConsoleLogDrain:()=>Ee,createLinearDecay:()=>ze,currentPageEvaluator:()=>Tt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>_e,enableContextDevTools:()=>He,enableDebugConsoleLogDrain:()=>Fe,evaluateVariantMatch:()=>zt,eventEvaluator:()=>Vt,explainStringMatch:()=>P,explainStringMatchCriteria:()=>ut,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>lt,pageViewCountEvaluator:()=>ct,parseQuickConnect:()=>We,personalizeVariations:()=>Gt,queryStringEvaluator:()=>bt,quirkEvaluator:()=>Et,serializeQuickConnect:()=>Je,testVariations:()=>vt});module.exports=$e(Ye);function Ct(e,t){let i={...e};for(let r in t){let n=Jt(e,r,t,new Set([r]));n!==0&&(i[r]=n)}return i}function Jt(e,t,i,r){var s;let n=0;for(let o of i[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&i[o.dim]){if(r.has(o.dim))continue;let l=new Set(r);l.add(o.dim),u=Jt(e,o.dim,i,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var st="_";var K,H,at=class{constructor(t,i,r){d(this,K,void 0);d(this,H,void 0);y(this,"signal");this.signal=t,p(this,K,i),p(this,H,r)}computeSignal(t,i){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,K).evaluate(t,this.signal.crit,i,this.signal,a(this,H)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&i.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,J,O,B=class{constructor({manifest:t,evaluator:i=new A({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,E,void 0);d(this,J,void 0);d(this,O,void 0);var n,s,o;p(this,E,(n=t.project)!=null?n:{}),this.data=t,p(this,J,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new at({...c,id:u},i,r))),p(this,O,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,E).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,E).test)==null?void 0:i[t]}computeSignals(t){let i=[];a(this,O).call(this,["debug",200,"GROUP"]);try{a(this,J).forEach(r=>{a(this,O).call(this,["debug",201,"GROUP",r.signal]);try{r.computeSignal(t,i)}finally{a(this,O).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,O).call(this,["debug",200,"ENDGROUP"])}return i}computeAggregateDimensions(t){var i,r;return Ct(t,(r=(i=a(this,E).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,s,o;let i=t.indexOf(st);return i<=0?(n=(r=a(this,E).pz)==null?void 0:r.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,i)]}};E=new WeakMap,J=new WeakMap,O=new WeakMap;var Xt=require("dequal/lite");function x(e,t){var o,u,c,l,f,m;let i=(o=t==null?void 0:t.op)!=null?o:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":Wt(e)).toString(),s=(r?t.rhs:Wt(t.rhs)).toString();switch(i){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),r?"":"i").test((f=e==null?void 0:e.toString())!=null?f:"");case"!//":return!new RegExp(t.rhs.toString(),r?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${i}.`)}}function P(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ut(t)}`}function ut(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Wt(e){var t,i;return(i=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?i:""}var xt=({update:e,criteria:t,onLogMessage:i})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let r=!(0,Xt.dequal)(Yt(e.state.cookies),Yt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};function Yt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...i}=e;return i}function Zt(e,t){var r;if(typeof e=="undefined"||e===null)return!1;let i=Number(e);if(isNaN(i))return!1;switch((r=t==null?void 0:t.op)!=null?r:"="){case"=":return i===t.rhs;case"!=":return i!==t.rhs;case">":return i>t.rhs;case"<":return i<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function Mt(e,t){return`${e} ${Ae(t)}`}function Ae(e){return`${e.op} ${e.rhs}`}function W(e,t){return`${e}${st}${t}`}var lt=W("$pvc","v"),ct=({update:e,criteria:t,commands:i,onLogMessage:r})=>{var l,f;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((f=e.previousState.url)==null?void 0:f.toString()))),o=(e.visitor.sessionScores[lt]||0)+1,u={result:!1,changed:n},c=i.some(m=>m.type==="modscoreS"&&m.data.dimension===lt);return n&&!c&&i.push({type:"modscoreS",data:{dimension:lt,delta:1}}),Zt(o,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:Mt(o,t.match)}]),u};ct.alwaysExecute=!0;var bt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,f,m;if(t.type!=="QS")return{result:!1,changed:!1};let r=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};var Et=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var f;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&i.dur==="t"&&e.scores[i.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(f=e.state.quirks)==null?void 0:f[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:x(o,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:P(o,t.match)}]),l};var Vt=({update:e,criteria:t,onLogMessage:i})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!1,n={result:r,changed:r};return i==null||i(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${ut(t.event)}`}]),n};var Tt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let r=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(r==null?void 0:r.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:x(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(r,t.path)}]),o};var Y,A=class{constructor(t){d(this,Y,void 0);p(this,Y,t)}evaluate(t,i,r,n,s){let o=i.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",i]));try{let u=!(i.op==="&"||!i.op),c=null,l=!1;for(let m of i.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,r,n,s);else{let D=a(this,Y)[m.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${m.type} signal criteria not registered`);S=D({update:t,criteria:m,commands:r,signal:n,onLogMessage:s})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let f=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,f])),f}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};Y=new WeakMap;var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Lt=$(require("mitt")),te=require("dequal/lite");var ee="__UNIFORM_DATA__",U,Z,q,N=class{constructor({initialData:t}){d(this,U,void 0);d(this,Z,void 0);d(this,q,(0,Lt.default)());y(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&(p(this,U,t),p(this,Z,t))}get data(){return a(this,U)}get initialData(){return a(this,Z)}updateData(t,i){return p(this,U,i),this.handleUpdateData(t,i)}async delete(t){p(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,te.dequal)(this.data,t)||(p(this,U,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(ee);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,Z=new WeakMap,q=new WeakMap;var kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ie=kt.split(""),re=new Array(123);for(let e=0;e<kt.length;e++)re[kt.charCodeAt(e)]=e;var Pt=e=>{if(e<0)return`-${Pt(-e)}`;let t=e>>>0,i=e/4294967296>>>0,r="";for(;i>0;)r=ie[63&t]+r,t>>>=6,t|=(63&i)<<26,i>>>=6;let n="";do n=ie[63&t]+n,t>>>=6;while(t>0);return n+r},ne=e=>{let t=0,i=e.charAt(0)==="-"?1:0;for(let r=i;r<e.length;r++)t=t*64+re[e.charCodeAt(r)];return i?-t:t};var dt=$(require("js-cookie"));var wt=typeof document=="undefined",ae="ufvd",G,M,Ut=class extends N{constructor({serverCookieValue:i,cookieName:r=ae,cookieAttributes:n={sameSite:"lax"}}){super({initialData:wt?Ne(i):void 0});d(this,G,void 0);d(this,M,void 0);p(this,G,r),p(this,M,n)}handleDelete(){return wt||dt.default.remove(a(this,G)),Promise.resolve()}async handleUpdateData(i,r){wt||(r.consent?dt.default.set(a(this,G),Ge(r),a(this,M)):dt.default.remove(a(this,G)))}};G=new WeakMap,M=new WeakMap;var ue="~",le="!",ce="-";function Ne(e){if(!e)return;let t=e.split(ue);if(t.length>3)return;let[i,r,n]=t;return{consent:!0,sessionScores:oe(Rt(r)),scores:oe(Rt(n)),tests:Rt(i)}}function Rt(e){return e.split(le).map(i=>i.split(ce)).reduce((i,r)=>(r.length<2||(i[r[0]]=r.slice(1).join("-")),i),{})}function oe(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=ne(r),t),{})}function Ge(e){return[Ot(e.tests),Ot(se(e.sessionScores)),Ot(se(e.scores))].join(ue)}function se(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=Pt(r),t),{})}function Ot(e){return Object.entries(e).map(t=>t.join(ce)).join(le)}var ft,de,$t=class extends N{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,ft);n.initialData||v(this,ft,de).call(this).catch(s=>{console.error(s)})}handleDelete(i){throw new Error("Method not implemented.")}async handleUpdateData(i){let r=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};ft=new WeakSet,de=async function(){let i=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)};function ze(e){let{gracePeriod:t=864e5,decayRate:i=1/30,decayCap:r=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(fe(u,D),fe(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function fe(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}var he=$(require("mitt")),L=require("dequal/lite");var pt=class{constructor(){y(this,"inMemoryFallback",{});y(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let i=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||i)return i;try{let r=localStorage.getItem(t);return r?JSON.parse(r):void 0}catch(r){return i}}set(t,i,r){if(this.inMemoryFallback[t]=i,!(!this.hasLocalStorageObject||!r))try{localStorage.setItem(t,JSON.stringify(i))}catch(n){console.warn(n)}}delete(t,i){i||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(r){}}};var pe=$(require("rfdc"));var Ie=(0,pe.default)();function me(e,t,i){let r=t?Ie(t):X();return e.forEach(n=>{var s,o;switch(n.type){case"consent":r.consent=n.data;break;case"setquirk":r.quirks[n.data.key]=n.data.value;break;case"settest":r.tests[n.data.test]=n.data.variant;break;case"modscore":if(i)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=r.scores[n.data.dimension])!=null?s:0;r.scores[n.data.dimension]=c+u;break;case"modscoreS":if(i)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let f=(o=r.sessionScores[n.data.dimension])!=null?o:0;r.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var mt="ufvisitor",V,I,j,g,b,w,R,z,ht,ge,gt,ve,et,At,it,Nt,tt=class{constructor(t){d(this,b);d(this,R);d(this,ht);d(this,gt);d(this,et);d(this,it);d(this,V,(0,he.default)());d(this,I,new pt);d(this,j,void 0);d(this,g,void 0);y(this,"events",{on:a(this,V).on,off:a(this,V).off});if(p(this,g,t),a(this,b,w)||v(this,R,z).call(this,v(this,it,Nt).call(this),!0),t.transitionStore){let i=t.transitionStore.getClientTransitionState();i&&t.onServerTransitionReceived&&t.onServerTransitionReceived(i),t.transitionStore.events.on("dataUpdatedAsync",n=>{v(this,R,z).call(this,{...a(this,b,w).visitorData,...n})});let r=t.transitionStore.data;r&&v(this,R,z).call(this,{...a(this,b,w).visitorData,...r},!0)}}get data(){var i,r;let t=a(this,b,w);if(v(this,gt,ve).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return v(this,R,z).call(this,{...s,sessionScores:{}}),(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}get options(){return a(this,g)}async updateData(t){var r,n,s,o;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=me(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(mt,!0),v(this,R,z).call(this,i),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var i,r,n,s,o;(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",103,"GROUP",t]);try{a(this,I).delete(mt,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),v(this,R,z).call(this,v(this,it,Nt).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};V=new WeakMap,I=new WeakMap,j=new WeakMap,g=new WeakMap,b=new WeakSet,w=function(){return a(this,I).get(mt)},R=new WeakSet,z=function(t,i=!1){var f,m,S,D,ot,Qt,Ft,Kt,Ht;let r=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,et,At).call(this,t.scores),v(this,et,At).call(this,t.sessionScores),(m=(f=a(this,g)).decay)==null||m.call(f,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!(0,L.dequal)(r==null?void 0:r.visitorData.scores,t.scores),o=!(0,L.dequal)(r==null?void 0:r.visitorData.sessionScores,t.sessionScores),u=!(0,L.dequal)(r==null?void 0:r.visitorData.quirks,t.quirks),c=!(0,L.dequal)(r==null?void 0:r.visitorData.tests,t.tests),l={updated:n,visitorData:t};v(this,ht,ge).call(this),a(this,I).set(mt,l,!!t.consent),(D=(S=a(this,g)).onLogMessage)==null||D.call(S,["debug",102,t]),i||((s||o)&&a(this,V).emit("scoresUpdated",t),u&&a(this,V).emit("quirksUpdated",t),c&&a(this,V).emit("testsUpdated",t),((ot=r==null?void 0:r.visitorData)==null?void 0:ot.consent)!==t.consent&&a(this,V).emit("consentUpdated",t),((Qt=r==null?void 0:r.visitorData)==null?void 0:Qt.controlGroup)!==t.controlGroup&&(a(this,V).emit("controlGroupUpdated",t),(Ht=(Kt=a(this,g)).onLogMessage)==null||Ht.call(Kt,["debug",104,(Ft=t.controlGroup)!=null?Ft:!1])))},ht=new WeakSet,ge=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),p(this,j,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},gt=new WeakSet,ve=function(t){let i=a(this,g).visitLifespan;return i?t.updated+i<Date.now():!1},et=new WeakSet,At=function(t){var i,r;if(!!a(this,g).manifest)for(let n in t){let s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},it=new WeakSet,Nt=function(){var t,i,r;return{...X(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(r=(i=a(this,g).manifest)==null?void 0:i.rollForControlGroup())!=null?r:!1}};var ye=$(require("mitt"));function Gt({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],f=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||zt(S.id,S.pz,m,n)&&(f=!0,l.push(S))}return{personalized:f,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function zt(e,t,i,r){r==null||r(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>Se(s,i,r)):n=t.crit.some(s=>Se(s,i,r)):(r==null||r(["info",302,{matched:!0,description:"default variation"}]),n=!0),r==null||r(["info",303,n])}finally{r==null||r(["info",301,"ENDGROUP"])}return n}function Se(e,t,i){var u,c;let{op:r,l:n}=e,s=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(r==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(o))return i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=s>o;return _(i,l,e,s,o),l}else if(r===">="){let l=s>=o;return _(i,l,e,s,o),l}else if(r==="<"){let l=s<o;return _(i,l,e,s,o),l}else if(r==="<="){let l=s<=o;return _(i,l,e,s,o),l}else if(r==="="){let l=s===o;return _(i,l,e,s,o),l}else if(r==="!="){let l=s!==o;return _(i,l,e,s,o),l}else throw new Error(`Unknown op: ${r}`)}function _(e,t,i,r,n){e==null||e(["info",302,{matched:t,description:`${i.l}[${r}] ${i.op} ${i.rDim?`${i.rDim}[${n}]`:i.r}`}])}var qe=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{values:[],total:0,missingDistribution:0});if(i>100)throw new Error(`Total distribution ${i} is over the maximum 100.`);if(i<100){let s=(100-i)/r;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=i.find(o=>o.id===s),n||r==null||r(["warn",402,{missingVariant:s,variants:i.map(o=>o.id)}])),!n){let o=qe(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,f)=>{let m=o[f];if(u>c&&u<=c+m)return l;c+=m}),n&&(r==null||r(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(r==null||r(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{r==null||r(["info",400,"ENDGROUP"])}};var It=require("dequal/lite");var C,T,k,rt,h,nt,jt,Q,St,qt=class{constructor(t){d(this,nt);d(this,Q);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,rt,{});d(this,h,(0,ye.default)());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:i,...r}=t;p(this,k,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,h).on("log",o.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new B({onLogMessage:o=>a(this,h).emit("log",o),manifest:i,evaluator:new A({CK:xt,QS:bt,QK:Et,PVC:ct,EVT:Vt,PV:Tt})}),this.storage=new tt({...r,manifest:this.manifest,onServerTransitionReceived:o=>{p(this,C,o),o.ssv&&(p(this,T,o.ssv),a(this,h).emit("log",["debug",130,o]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",v(this,Q,St).bind(this)),a(this,C)||v(this,Q,St).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(u),a(this,h).emit("quirksUpdated",o.quirks),a(this,h).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,T)}get quirks(){var t,i;return(i=(t=a(this,C))==null?void 0:t.quirks)!=null?i:this.storage.data.quirks}async update(t){var n,s,o;let i=[],r={};if((n=a(this,C))!=null&&n.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(s=a(this,C))!=null&&s.tests){let u=Object.entries(a(this,C).tests);if(u.length>0){let c=[];u.forEach(([l,f])=>{this.storage.data.tests[l]||(c.push([l,f]),r[l]=f)}),i.push(...c.map(([l,f])=>({type:"settest",data:{test:l,variant:f}})))}}try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(o=t.url)==null?void 0:o.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([u,c])=>({type:"setquirk",data:{key:u,value:c}}))),t.enrichments&&t.enrichments.forEach(u=>{let c=W(u.cat,u.key);this.manifest.getDimensionByKey(c)?i.push({type:"modscore",data:{dimension:c,delta:u.str}}):a(this,h).emit("log",["warn",5,u])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),p(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,Q,St).call(this,this.storage.data),Object.entries(r).forEach(([u,c])=>{v(this,nt,jt).call(this,{name:u,variantId:c,variantAssigned:!0})}),p(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r,n,s,o;let i=this.manifest.getTest(t);return i?(o=(s=i.wv)!=null?s:(n=(r=a(this,C))==null?void 0:r.tests)==null?void 0:n[t])!=null?o:this.storage.data.tests[t]:(a(this,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,i){this.storage.updateData([{type:"settest",data:{test:t,variant:i}}])}log(...t){a(this,h).emit("log",t)}test(t){var r,n;let i=vt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)});return v(this,nt,jt).call(this,{name:t.name,variantId:(n=(r=i.result)==null?void 0:r.id)!=null?n:void 0,variantAssigned:i.variantAssigned}),i}personalize(t){let i=Gt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)}),r=a(this,rt)[t.name],n={name:t.name,variantIds:i.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return r&&(0,It.dequal)(n.variantIds,r)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,rt)[t.name]=n.variantIds,i}async forget(t){p(this,k,{}),await this.storage.delete(t)}getServerToClientTransitionState(){let t={quirks:this.storage.data.quirks,ssv:a(this,T),tests:{}},i=this.storage.data.tests;return Object.entries(i).map(([r,n])=>{var s,o,u;((u=(o=(s=this.storage.options.transitionStore)==null?void 0:s.initialData)==null?void 0:o.tests)==null?void 0:u[r])!==i[r]&&t.tests&&(t.tests[r]=n)}),t}};C=new WeakMap,T=new WeakMap,k=new WeakMap,rt=new WeakMap,h=new WeakMap,nt=new WeakSet,jt=function(t){a(this,h).emit("testResult",t)},Q=new WeakSet,St=function(t){var n;let i={...t.scores};for(let s in t.sessionScores)i[s]=((n=i[s])!=null?n:0)+t.sessionScores[s];i=this.manifest.computeAggregateDimensions(i),!(0,It.dequal)(i,a(this,T))&&(p(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};var De=$(require("rfdc"));function yt(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var je=(0,De.default)();function Ce(e){return([t,...i])=>{if(!yt(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
|
2
2
|
`,...n.map(je))}}function _e(e){return{logDrain:Ce(e)}}var xe={1:()=>["context","initializing Uniform Context"],2:e=>["context","received update()",e],3:e=>["context","new score vector",e],4:e=>["context","updated quirks",e],5:e=>["context","ignored enrichment update for unknown enrichment category",e.cat],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],110:({dim:e,cap:t,score:i})=>["storage",`${e} score ${i} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],131:()=>["storage","server to client transition data was discarded"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:i})=>["signals",`${e.type}: ${i} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};var be=$(require("rfdc")),Qe=(0,be.default)();function Ee(e,t){let i=typeof document=="undefined",{enableOnServer:r=!1}=t!=null?t:{};return([n,...s])=>{if(!yt(e,n)||i&&!r)return;let[o,...u]=s,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=xe[o],f="";switch(n){case"debug":f="\u{1F41E}";break;case"info":f="\u{1F4AC}";break;case"warn":f="\u26A0\uFE0F";break;case"error":f="\u{1F4A5}";break}let m=f;if(!l){c(`${m} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,D,...ot]=l(...u);c(`${m}[${S}] ${D}
|
3
3
|
`,...ot.map(Qe))}}function Fe(e,t){return{logDrain:Ee(e,t)}}var Ve=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(Ve||{}),Ke="nesitag";var _t=typeof top!="undefined";function He(){return{logDrain:e=>{!_t||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!_t||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:i}},window.location.origin)},n=o=>{!o.changed||t.push(o)},s=o=>{!o.variantAssigned||i.push(o)};if(_t){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Be(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.events.on("scoresUpdated",r),e.storage.events.on("*",r),()=>{e.events.off("scoresUpdated",r),e.storage.events.off("*",r),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Be(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}function Je(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function We(e){let[t,i,r]=e.split("|");if(!t.startsWith("uf"))throw new Error("Invalid API key");if(!/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/i.test(i))throw new Error("Invalid project ID");return{apiKey:t,projectId:i,apiHost:r||"https://uniform.app"}}0&&(module.exports={Context,CookieTransitionDataStore,EdgeNodeTagName,EdgeTransitionDataStore,GroupCriteriaEvaluator,ManifestInstance,SERVER_STATE_ID,ScriptType,TransitionDataStore,UNIFORM_DEFAULT_COOKIE_NAME,VisitorDataStore,computeAggregateDimensions,cookieEvaluator,createConsoleLogDrain,createDebugConsoleLogDrain,createLinearDecay,currentPageEvaluator,emptyVisitorData,enableConsoleLogDrain,enableContextDevTools,enableDebugConsoleLogDrain,evaluateVariantMatch,eventEvaluator,explainStringMatch,explainStringMatchCriteria,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,parseQuickConnect,personalizeVariations,queryStringEvaluator,quirkEvaluator,serializeQuickConnect,testVariations});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "17.1.
|
3
|
+
"version": "17.1.1-alpha.151+3c57dd245",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -58,8 +58,8 @@
|
|
58
58
|
},
|
59
59
|
"devDependencies": {
|
60
60
|
"@types/js-cookie": "3.0.2",
|
61
|
-
"@types/yargs": "17.0.
|
62
|
-
"@uniformdev/cli": "^17.1.
|
61
|
+
"@types/yargs": "17.0.12",
|
62
|
+
"@uniformdev/cli": "^17.1.1-alpha.151+3c57dd245",
|
63
63
|
"benny": "3.7.1",
|
64
64
|
"yargs": "17.5.1"
|
65
65
|
},
|
@@ -76,5 +76,5 @@
|
|
76
76
|
"publishConfig": {
|
77
77
|
"access": "public"
|
78
78
|
},
|
79
|
-
"gitHead": "
|
79
|
+
"gitHead": "3c57dd245b59aa55368da8991d1e39bc633bbed8"
|
80
80
|
}
|