@uniformdev/context 12.2.1-alpha.184 → 14.2.1-alpha.145
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 +17 -1401
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +1 -1
- package/dist/chunk-5UOAJNMX.mjs +2 -0
- package/dist/chunk-A5FZYSIL.mjs +76 -0
- package/dist/{chunk-KZPEO35A.mjs → chunk-AFJ7PNM5.mjs} +0 -0
- package/dist/chunk-CEKV2MHL.mjs +1 -0
- package/dist/chunk-FJWWKKCL.mjs +307 -0
- package/dist/chunk-YGARAHYJ.mjs +11 -0
- package/dist/cli/cli.d.ts +14 -1
- package/dist/cli/cli.js +63 -53
- package/dist/cli/cli.mjs +62 -52
- package/dist/contextTypes-7f24fc7c.d.ts +1534 -0
- package/dist/index.d.ts +31 -9
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{types-1ad8439c.d.ts → types-c81df08a.d.ts} +35 -295
- package/dist/types-d77228a6.d.ts +732 -0
- package/dist/v2-manifest.swagger-d0899723.d.ts +285 -0
- package/package.json +7 -19
- package/dist/chunk-GU2YFM6V.mjs +0 -1
- package/dist/chunk-JKQJOIRC.mjs +0 -2
package/dist/api/api.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var
|
2
|
-
${
|
1
|
+
var N=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var z=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=r=>N(r,"__esModule",{value:!0});var B=(r,e)=>{for(var t in e)N(r,t,{get:e[t],enumerable:!0})},Y=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!K.call(r,s)&&(t||s!=="default")&&N(r,s,{get:()=>e[s],enumerable:!(i=$(e,s))||i.enumerable});return r};var F=(r=>(e,t)=>r&&r.get(e)||(t=Y(q({}),e,1),r&&r.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var m=(r,e,t)=>(z(r,typeof e!="symbol"?e+"":e,t),t),W=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var n=(r,e,t)=>(W(r,e,"read from private field"),t?t.call(r):e.get(r)),a=(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 _={};B(_,{AggregateClient:()=>U,ApiClientError:()=>y,ContextClient:()=>V,DimensionClient:()=>D,EnrichmentClient:()=>f,ManifestClient:()=>T,QuirkClient:()=>O,SignalClient:()=>w,computeDimensionDefinitionDisplayData:()=>Q,computeDimensionDisplayData:()=>X,computeDimensionDisplayName:()=>Z,nullLimitPolicy:()=>L});var L=async r=>await r(),y=class extends Error{constructor(e,t,i,s,o){super(`${e}
|
2
|
+
${s}${o?" "+o:""} (${t} ${i})`);this.errorMessage=e;this.fetchMethod=t;this.fetchUri=i;this.statusCode=s;this.statusText=o;Object.setPrototypeOf(this,y.prototype)}};var p=class{constructor(e){m(this,"options");var t,i,s,o,c,h;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options={...e,fetch:(t=e.fetch)!=null?t:fetch,apiHost:(i=e.apiHost)!=null?i:"https://uniform.app",apiKey:(s=e.apiKey)!=null?s:null,projectId:(o=e.projectId)!=null?o:null,bearerToken:(c=e.bearerToken)!=null?c:null,limitPolicy:(h=e.limitPolicy)!=null?h:L}}async apiClient(e,t){return this.options.limitPolicy(async()=>{var o;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},s=await fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!s.ok){let c="";try{let h=await s.text();try{let E=JSON.parse(h);E.errorMessage?c=Array.isArray(E.errorMessage)?E.errorMessage.join(", "):E.errorMessage:c=h}catch(E){c=h}}catch(h){c="General error"}throw new y(c,(o=t==null?void 0:t.method)!=null?o:"GET",e.toString(),s.status)}return t!=null&&t.expectNoContent?null:await s.json()})}createUrl(e,t){let i=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([s,o])=>{var c;typeof o!="undefined"&&o!==null&&i.searchParams.append(s,(c=o==null?void 0:o.toString())!=null?c:"")}),i}};var g,j=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(j,g),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(j,g));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(j,g));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},U=j;g=new WeakMap,a(U,g,"/api/v2/aggregate");var S,J=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(J,S),{...e,projectId:t});return await this.apiClient(i)}},D=J;S=new WeakMap,a(D,S,"/api/v2/dimension");var P,R,u=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(u,P),{...e,projectId:t});return await this.apiClient(i)}async upsertCategory(e){let t=this.createUrl(n(u,P));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(e){let t=this.createUrl(n(u,P));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(e){let t=this.createUrl(n(u,R));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(e){let t=this.createUrl(n(u,R));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},f=u;P=new WeakMap,R=new WeakMap,a(f,P,"/api/v1/enrichments"),a(f,R,"/api/v1/enrichment-values");var A,v=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(v,A),{...e,projectId:t});return await this.apiClient(i)}},T=v;A=new WeakMap,a(T,A,"/api/v2/manifest");var d,I=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(I,d),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(I,d));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(I,d));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},O=I;d=new WeakMap,a(O,d,"/api/v2/quirk");var x,G=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(G,x),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(G,x));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(G,x));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},w=G;x=new WeakMap,a(w,x,"/api/v2/signal");var C,b=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(b,C),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(b,C));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(b,C));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},k=b;C=new WeakMap,a(k,C,"/api/v2/test");var V=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 f(e),this.aggregates=new U(e),this.dimensions=new D(e),this.manifest=new T(e),this.quirks=new O(e),this.signals=new w(e),this.tests=new k(e)}};var M="_";function Q(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 X(r,e){var t,i,s,o;if((i=(t=e.project.pz)==null?void 0:t.agg)!=null&&i[r])return{dim:r,name:r,type:"Aggregate"};if((o=(s=e.project.pz)==null?void 0:s.sig)!=null&&o[r])return{dim:r,name:r,type:"Signal"};if(r.indexOf(M)>=0){let[c,h]=r.split(M);return{dim:r,name:h,type:"Enrichment",category:c}}}function Z(r){let{type:e,name:t}=Q(r);return`${e}: ${t}`}module.exports=F(_);0&&(module.exports={AggregateClient,ApiClientError,ContextClient,DimensionClient,EnrichmentClient,ManifestClient,QuirkClient,SignalClient,computeDimensionDefinitionDisplayData,computeDimensionDisplayData,computeDimensionDisplayName,nullLimitPolicy});
|
package/dist/api/api.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a as
|
1
|
+
import{a as m}from"../chunk-CEKV2MHL.mjs";import{a as O,b as P,c as u,d as x,e as C,f as h,g as E,h as A,i as d}from"../chunk-5UOAJNMX.mjs";import{d as n,e as y,f as D,i}from"../chunk-AFJ7PNM5.mjs";i();i();i();var a,c=class extends u{constructor(t){super(t)}async get(t){let{projectId:r}=this.options,o=this.createUrl(y(c,a),{...t,projectId:r});return await this.apiClient(o)}},s=c;a=new WeakMap,D(s,a,"/api/v2/dimension");var S=class{constructor(t){n(this,"enrichments");n(this,"aggregates");n(this,"dimensions");n(this,"manifest");n(this,"quirks");n(this,"signals");n(this,"tests");this.enrichments=new C(t),this.aggregates=new x(t),this.dimensions=new s(t),this.manifest=new h(t),this.quirks=new E(t),this.signals=new A(t),this.tests=new d(t)}};i();function G(e){let t=e.category==="ENR"?"Enrichment":e.category==="SIG"?"Signal":e.subcategory==="1"?"Intent":e.subcategory==="0"?"Audience":"Aggregate";return{dim:e.dim,name:e.name,type:t,category:e.category==="ENR"?e.subcategory:void 0}}function Q(e,t){var r,o,g,f;if((o=(r=t.project.pz)==null?void 0:r.agg)!=null&&o[e])return{dim:e,name:e,type:"Aggregate"};if((f=(g=t.project.pz)==null?void 0:g.sig)!=null&&f[e])return{dim:e,name:e,type:"Signal"};if(e.indexOf(m)>=0){let[w,R]=e.split(m);return{dim:e,name:R,type:"Enrichment",category:w}}}function V(e){let{type:t,name:r}=G(e);return`${t}: ${r}`}export{x as AggregateClient,P as ApiClientError,S as ContextClient,s as DimensionClient,C as EnrichmentClient,h as ManifestClient,E as QuirkClient,A as SignalClient,G as computeDimensionDefinitionDisplayData,Q as computeDimensionDisplayData,V as computeDimensionDisplayName,O as nullLimitPolicy};
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{d as w,e as r,f as n,i as s}from"./chunk-AFJ7PNM5.mjs";s();var N=async b=>await b(),j=class extends Error{constructor(t,e,i,c,o){super(`${t}
|
2
|
+
${c}${o?" "+o:""} (${e} ${i})`);this.errorMessage=t;this.fetchMethod=e;this.fetchUri=i;this.statusCode=c;this.statusText=o;Object.setPrototypeOf(this,j.prototype)}};s();s();var a=class{constructor(t){w(this,"options");var e,i,c,o,p,l;if(!t.apiKey&&!t.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options={...t,fetch:(e=t.fetch)!=null?e:fetch,apiHost:(i=t.apiHost)!=null?i:"https://uniform.app",apiKey:(c=t.apiKey)!=null?c:null,projectId:(o=t.projectId)!=null?o:null,bearerToken:(p=t.bearerToken)!=null?p:null,limitPolicy:(l=t.limitPolicy)!=null?l:N}}async apiClient(t,e){return this.options.limitPolicy(async()=>{var o;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},c=await fetch(t.toString(),{...e,headers:{...e==null?void 0:e.headers,...i}});if(!c.ok){let p="";try{let l=await c.text();try{let x=JSON.parse(l);x.errorMessage?p=Array.isArray(x.errorMessage)?x.errorMessage.join(", "):x.errorMessage:p=l}catch(x){p=l}}catch(l){p="General error"}throw new j(p,(o=e==null?void 0:e.method)!=null?o:"GET",t.toString(),c.status)}return e!=null&&e.expectNoContent?null:await c.json()})}createUrl(t,e){let i=new URL(`${this.options.apiHost}${t}`);return Object.entries(e!=null?e:{}).forEach(([c,o])=>{var p;typeof o!="undefined"&&o!==null&&i.searchParams.append(c,(p=o==null?void 0:o.toString())!=null?p:"")}),i}};var P,E=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(E,P),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(E,P));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(E,P));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},S=E;P=new WeakMap,n(S,P,"/api/v2/aggregate");s();var y,C,u=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(u,y),{...t,projectId:e});return await this.apiClient(i)}async upsertCategory(t){let e=this.createUrl(r(u,y));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(t){let e=this.createUrl(r(u,y));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(t){let e=this.createUrl(r(u,C));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(t){let e=this.createUrl(r(u,C));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},G=u;y=new WeakMap,C=new WeakMap,n(G,y,"/api/v1/enrichments"),n(G,C,"/api/v1/enrichment-values");s();var O,R=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(R,O),{...t,projectId:e});return await this.apiClient(i)}},k=R;O=new WeakMap,n(k,O,"/api/v2/manifest");s();var d,U=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(U,d),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(U,d));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(U,d));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},A=U;d=new WeakMap,n(A,d,"/api/v2/quirk");s();var g,T=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(T,g),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(T,g));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(T,g));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},D=T;g=new WeakMap,n(D,g,"/api/v2/signal");s();var f,I=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(I,f),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(I,f));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(I,f));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},L=I;f=new WeakMap,n(L,f,"/api/v2/test");export{N as a,j as b,a as c,S as d,G as e,k as f,A as g,D as h,L as i};
|
@@ -0,0 +1,76 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
11
|
+
}) : x)(function(x) {
|
12
|
+
if (typeof require !== "undefined")
|
13
|
+
return require.apply(this, arguments);
|
14
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
15
|
+
});
|
16
|
+
var __esm = (fn, res) => function __init() {
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
18
|
+
};
|
19
|
+
var __commonJS = (cb, mod) => function __require2() {
|
20
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
21
|
+
};
|
22
|
+
var __reExport = (target, module, copyDefault, desc) => {
|
23
|
+
if (module && typeof module === "object" || typeof module === "function") {
|
24
|
+
for (let key of __getOwnPropNames(module))
|
25
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
26
|
+
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
27
|
+
}
|
28
|
+
return target;
|
29
|
+
};
|
30
|
+
var __toESM = (module, isNodeMode) => {
|
31
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
32
|
+
};
|
33
|
+
var __publicField = (obj, key, value) => {
|
34
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
35
|
+
return value;
|
36
|
+
};
|
37
|
+
var __accessCheck = (obj, member, msg) => {
|
38
|
+
if (!member.has(obj))
|
39
|
+
throw TypeError("Cannot " + msg);
|
40
|
+
};
|
41
|
+
var __privateGet = (obj, member, getter) => {
|
42
|
+
__accessCheck(obj, member, "read from private field");
|
43
|
+
return getter ? getter.call(obj) : member.get(obj);
|
44
|
+
};
|
45
|
+
var __privateAdd = (obj, member, value) => {
|
46
|
+
if (member.has(obj))
|
47
|
+
throw TypeError("Cannot add the same private member more than once");
|
48
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
49
|
+
};
|
50
|
+
var __privateSet = (obj, member, value, setter) => {
|
51
|
+
__accessCheck(obj, member, "write to private field");
|
52
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
53
|
+
return value;
|
54
|
+
};
|
55
|
+
var __privateMethod = (obj, member, method) => {
|
56
|
+
__accessCheck(obj, member, "access private method");
|
57
|
+
return method;
|
58
|
+
};
|
59
|
+
|
60
|
+
// ../../node_modules/.pnpm/tsup@5.12.1_typescript@4.6.2/node_modules/tsup/assets/esm_shims.js
|
61
|
+
var init_esm_shims = __esm({
|
62
|
+
"../../node_modules/.pnpm/tsup@5.12.1_typescript@4.6.2/node_modules/tsup/assets/esm_shims.js"() {
|
63
|
+
}
|
64
|
+
});
|
65
|
+
|
66
|
+
export {
|
67
|
+
__require,
|
68
|
+
__commonJS,
|
69
|
+
__toESM,
|
70
|
+
__publicField,
|
71
|
+
__privateGet,
|
72
|
+
__privateAdd,
|
73
|
+
__privateSet,
|
74
|
+
__privateMethod,
|
75
|
+
init_esm_shims
|
76
|
+
};
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
import{i as R}from"./chunk-AFJ7PNM5.mjs";R();var A="_";export{A as a};
|
@@ -0,0 +1,307 @@
|
|
1
|
+
import {
|
2
|
+
__privateAdd,
|
3
|
+
__privateGet,
|
4
|
+
__publicField,
|
5
|
+
init_esm_shims
|
6
|
+
} from "./chunk-A5FZYSIL.mjs";
|
7
|
+
|
8
|
+
// src/api/apiClientUtils.ts
|
9
|
+
init_esm_shims();
|
10
|
+
var nullLimitPolicy = async (func) => await func();
|
11
|
+
var ApiClientError = class extends Error {
|
12
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText) {
|
13
|
+
super(`${errorMessage}
|
14
|
+
${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri})`);
|
15
|
+
this.errorMessage = errorMessage;
|
16
|
+
this.fetchMethod = fetchMethod;
|
17
|
+
this.fetchUri = fetchUri;
|
18
|
+
this.statusCode = statusCode;
|
19
|
+
this.statusText = statusText;
|
20
|
+
Object.setPrototypeOf(this, ApiClientError.prototype);
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
// src/api/AggregateClient.ts
|
25
|
+
init_esm_shims();
|
26
|
+
|
27
|
+
// src/api/ApiClient.ts
|
28
|
+
init_esm_shims();
|
29
|
+
var ApiClient = class {
|
30
|
+
constructor(options) {
|
31
|
+
__publicField(this, "options");
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
33
|
+
if (!options.apiKey && !options.bearerToken) {
|
34
|
+
throw new Error("You must provide an API key or a bearer token");
|
35
|
+
}
|
36
|
+
this.options = {
|
37
|
+
...options,
|
38
|
+
fetch: (_a = options.fetch) != null ? _a : fetch,
|
39
|
+
apiHost: (_b = options.apiHost) != null ? _b : "https://uniform.app",
|
40
|
+
apiKey: (_c = options.apiKey) != null ? _c : null,
|
41
|
+
projectId: (_d = options.projectId) != null ? _d : null,
|
42
|
+
bearerToken: (_e = options.bearerToken) != null ? _e : null,
|
43
|
+
limitPolicy: (_f = options.limitPolicy) != null ? _f : nullLimitPolicy
|
44
|
+
};
|
45
|
+
}
|
46
|
+
async apiClient(fetchUri, options) {
|
47
|
+
return this.options.limitPolicy(async () => {
|
48
|
+
var _a;
|
49
|
+
const authHeaders = this.options.apiKey ? {
|
50
|
+
"x-api-key": this.options.apiKey
|
51
|
+
} : {
|
52
|
+
Authorization: `Bearer ${this.options.bearerToken}`
|
53
|
+
};
|
54
|
+
const apiResponse = await fetch(fetchUri.toString(), {
|
55
|
+
...options,
|
56
|
+
headers: {
|
57
|
+
...options == null ? void 0 : options.headers,
|
58
|
+
...authHeaders
|
59
|
+
}
|
60
|
+
});
|
61
|
+
if (!apiResponse.ok) {
|
62
|
+
let message = "";
|
63
|
+
try {
|
64
|
+
const responseText = await apiResponse.text();
|
65
|
+
try {
|
66
|
+
const parsed = JSON.parse(responseText);
|
67
|
+
if (parsed.errorMessage) {
|
68
|
+
message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
|
69
|
+
} else {
|
70
|
+
message = responseText;
|
71
|
+
}
|
72
|
+
} catch (e) {
|
73
|
+
message = responseText;
|
74
|
+
}
|
75
|
+
} catch (e) {
|
76
|
+
message = `General error`;
|
77
|
+
}
|
78
|
+
throw new ApiClientError(message, (_a = options == null ? void 0 : options.method) != null ? _a : "GET", fetchUri.toString(), apiResponse.status);
|
79
|
+
}
|
80
|
+
if (options == null ? void 0 : options.expectNoContent) {
|
81
|
+
return null;
|
82
|
+
}
|
83
|
+
return await apiResponse.json();
|
84
|
+
});
|
85
|
+
}
|
86
|
+
createUrl(path, queryParams) {
|
87
|
+
const url = new URL(`${this.options.apiHost}${path}`);
|
88
|
+
Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
|
89
|
+
var _a;
|
90
|
+
if (typeof value !== "undefined" && value !== null) {
|
91
|
+
url.searchParams.append(key, (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
|
92
|
+
}
|
93
|
+
});
|
94
|
+
return url;
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
// src/api/AggregateClient.ts
|
99
|
+
var _url;
|
100
|
+
var _AggregateClient = class extends ApiClient {
|
101
|
+
constructor(options) {
|
102
|
+
super(options);
|
103
|
+
}
|
104
|
+
async get(options) {
|
105
|
+
const { projectId } = this.options;
|
106
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url), { ...options, projectId });
|
107
|
+
return await this.apiClient(fetchUri);
|
108
|
+
}
|
109
|
+
async upsert(body) {
|
110
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
|
111
|
+
await this.apiClient(fetchUri, {
|
112
|
+
method: "PUT",
|
113
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
114
|
+
expectNoContent: true
|
115
|
+
});
|
116
|
+
}
|
117
|
+
async remove(body) {
|
118
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
|
119
|
+
await this.apiClient(fetchUri, {
|
120
|
+
method: "DELETE",
|
121
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
122
|
+
expectNoContent: true
|
123
|
+
});
|
124
|
+
}
|
125
|
+
};
|
126
|
+
var AggregateClient = _AggregateClient;
|
127
|
+
_url = new WeakMap();
|
128
|
+
__privateAdd(AggregateClient, _url, "/api/v2/aggregate");
|
129
|
+
|
130
|
+
// src/api/EnrichmentClient.ts
|
131
|
+
init_esm_shims();
|
132
|
+
var _url2, _valueUrl;
|
133
|
+
var _EnrichmentClient = class extends ApiClient {
|
134
|
+
constructor(options) {
|
135
|
+
super(options);
|
136
|
+
}
|
137
|
+
async get(options) {
|
138
|
+
const { projectId } = this.options;
|
139
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2), { ...options, projectId });
|
140
|
+
return await this.apiClient(fetchUri);
|
141
|
+
}
|
142
|
+
async upsertCategory(body) {
|
143
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2));
|
144
|
+
await this.apiClient(fetchUri, {
|
145
|
+
method: "PUT",
|
146
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
147
|
+
expectNoContent: true
|
148
|
+
});
|
149
|
+
}
|
150
|
+
async removeCategory(body) {
|
151
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2));
|
152
|
+
await this.apiClient(fetchUri, {
|
153
|
+
method: "DELETE",
|
154
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
155
|
+
expectNoContent: true
|
156
|
+
});
|
157
|
+
}
|
158
|
+
async upsertValue(body) {
|
159
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
|
160
|
+
await this.apiClient(fetchUri, {
|
161
|
+
method: "PUT",
|
162
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
163
|
+
expectNoContent: true
|
164
|
+
});
|
165
|
+
}
|
166
|
+
async removeValue(body) {
|
167
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
|
168
|
+
await this.apiClient(fetchUri, {
|
169
|
+
method: "DELETE",
|
170
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
171
|
+
expectNoContent: true
|
172
|
+
});
|
173
|
+
}
|
174
|
+
};
|
175
|
+
var EnrichmentClient = _EnrichmentClient;
|
176
|
+
_url2 = new WeakMap();
|
177
|
+
_valueUrl = new WeakMap();
|
178
|
+
__privateAdd(EnrichmentClient, _url2, "/api/v1/enrichments");
|
179
|
+
__privateAdd(EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
|
180
|
+
|
181
|
+
// src/api/ManifestClient.ts
|
182
|
+
init_esm_shims();
|
183
|
+
var _url3;
|
184
|
+
var _ManifestClient = class extends ApiClient {
|
185
|
+
constructor(options) {
|
186
|
+
super(options);
|
187
|
+
}
|
188
|
+
async get(options) {
|
189
|
+
const { projectId } = this.options;
|
190
|
+
const fetchUri = this.createUrl(__privateGet(_ManifestClient, _url3), { ...options, projectId });
|
191
|
+
return await this.apiClient(fetchUri);
|
192
|
+
}
|
193
|
+
};
|
194
|
+
var ManifestClient = _ManifestClient;
|
195
|
+
_url3 = new WeakMap();
|
196
|
+
__privateAdd(ManifestClient, _url3, "/api/v2/manifest");
|
197
|
+
|
198
|
+
// src/api/QuirkClient.ts
|
199
|
+
init_esm_shims();
|
200
|
+
var _url4;
|
201
|
+
var _QuirkClient = class extends ApiClient {
|
202
|
+
constructor(options) {
|
203
|
+
super(options);
|
204
|
+
}
|
205
|
+
async get(options) {
|
206
|
+
const { projectId } = this.options;
|
207
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4), { ...options, projectId });
|
208
|
+
return await this.apiClient(fetchUri);
|
209
|
+
}
|
210
|
+
async upsert(body) {
|
211
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4));
|
212
|
+
await this.apiClient(fetchUri, {
|
213
|
+
method: "PUT",
|
214
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
215
|
+
expectNoContent: true
|
216
|
+
});
|
217
|
+
}
|
218
|
+
async remove(body) {
|
219
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4));
|
220
|
+
await this.apiClient(fetchUri, {
|
221
|
+
method: "DELETE",
|
222
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
223
|
+
expectNoContent: true
|
224
|
+
});
|
225
|
+
}
|
226
|
+
};
|
227
|
+
var QuirkClient = _QuirkClient;
|
228
|
+
_url4 = new WeakMap();
|
229
|
+
__privateAdd(QuirkClient, _url4, "/api/v2/quirk");
|
230
|
+
|
231
|
+
// src/api/SignalClient.ts
|
232
|
+
init_esm_shims();
|
233
|
+
var _url5;
|
234
|
+
var _SignalClient = class extends ApiClient {
|
235
|
+
constructor(options) {
|
236
|
+
super(options);
|
237
|
+
}
|
238
|
+
async get(options) {
|
239
|
+
const { projectId } = this.options;
|
240
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5), { ...options, projectId });
|
241
|
+
return await this.apiClient(fetchUri);
|
242
|
+
}
|
243
|
+
async upsert(body) {
|
244
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5));
|
245
|
+
await this.apiClient(fetchUri, {
|
246
|
+
method: "PUT",
|
247
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
248
|
+
expectNoContent: true
|
249
|
+
});
|
250
|
+
}
|
251
|
+
async remove(body) {
|
252
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5));
|
253
|
+
await this.apiClient(fetchUri, {
|
254
|
+
method: "DELETE",
|
255
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
256
|
+
expectNoContent: true
|
257
|
+
});
|
258
|
+
}
|
259
|
+
};
|
260
|
+
var SignalClient = _SignalClient;
|
261
|
+
_url5 = new WeakMap();
|
262
|
+
__privateAdd(SignalClient, _url5, "/api/v2/signal");
|
263
|
+
|
264
|
+
// src/api/TestClient.ts
|
265
|
+
init_esm_shims();
|
266
|
+
var _url6;
|
267
|
+
var _TestClient = class extends ApiClient {
|
268
|
+
constructor(options) {
|
269
|
+
super(options);
|
270
|
+
}
|
271
|
+
async get(options) {
|
272
|
+
const { projectId } = this.options;
|
273
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6), { ...options, projectId });
|
274
|
+
return await this.apiClient(fetchUri);
|
275
|
+
}
|
276
|
+
async upsert(body) {
|
277
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6));
|
278
|
+
await this.apiClient(fetchUri, {
|
279
|
+
method: "PUT",
|
280
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
281
|
+
expectNoContent: true
|
282
|
+
});
|
283
|
+
}
|
284
|
+
async remove(body) {
|
285
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6));
|
286
|
+
await this.apiClient(fetchUri, {
|
287
|
+
method: "DELETE",
|
288
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
289
|
+
expectNoContent: true
|
290
|
+
});
|
291
|
+
}
|
292
|
+
};
|
293
|
+
var TestClient = _TestClient;
|
294
|
+
_url6 = new WeakMap();
|
295
|
+
__privateAdd(TestClient, _url6, "/api/v2/test");
|
296
|
+
|
297
|
+
export {
|
298
|
+
nullLimitPolicy,
|
299
|
+
ApiClientError,
|
300
|
+
ApiClient,
|
301
|
+
AggregateClient,
|
302
|
+
EnrichmentClient,
|
303
|
+
ManifestClient,
|
304
|
+
QuirkClient,
|
305
|
+
SignalClient,
|
306
|
+
TestClient
|
307
|
+
};
|
package/dist/cli/cli.d.ts
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
import { UniformCLIPlugin } from '@uniformdev/cli';
|
2
|
+
import { UniformPackage } from '@uniformdev/cli/sync';
|
3
|
+
import { A as Aggregate, Q as Quirk, S as SignalWithId, E as EnrichmentCategoryWithValues, T as Test } from '../contextTypes-7f24fc7c';
|
4
|
+
import '../v2-manifest.swagger-d0899723';
|
5
|
+
|
6
|
+
declare type ContextPackage = UniformPackage & {
|
7
|
+
aggregates?: Array<Aggregate>;
|
8
|
+
quirks?: Array<Quirk>;
|
9
|
+
signals?: Array<SignalWithId>;
|
10
|
+
enrichments?: Array<EnrichmentCategoryWithValues>;
|
11
|
+
tests?: Array<Test>;
|
12
|
+
};
|
13
|
+
declare function readContextPackage(filename: string, assertExists: boolean): ContextPackage;
|
14
|
+
declare function writeContextPackage(filename: string, packageContents: ContextPackage): void;
|
2
15
|
|
3
16
|
declare const uniformCLI: UniformCLIPlugin;
|
4
17
|
|
5
|
-
export { uniformCLI };
|
18
|
+
export { ContextPackage, readContextPackage, uniformCLI, writeContextPackage };
|