@getjusto/team-cli 0.0.3 → 0.0.4
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/bin/cli.js +96 -49
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Y={main:{local:"http://localhost:3000",develop:"https://api.bejusto.com",prod:"https://api.getjusto.com"},auth:{local:"http://localhost:4112",develop:"https://auth.service.bejusto.com",prod:"https://auth.service.getjusto.com"},webdata:{local:"http://localhost:4125",develop:"https://webdata.service.bejusto.com",prod:"https://webdatacdn.getjusto.com"},preferences:{local:"http://localhost:4120",develop:"https://preferences.service.bejusto.com",prod:"https://preferences.service.getjusto.com"},buckets:{local:"http://localhost:4106",develop:"https://buckets.service.bejusto.com",prod:"https://buckets.service.getjusto.com"},reservations:{local:"http://localhost:4113",develop:"https://reservations.service.bejusto.com",prod:"https://reservations.service.getjusto.com"},data:{local:"http://localhost:4107",develop:"https://data.service.bejusto.com",prod:"https://data.service.getjusto.com"},finances:{local:"http://localhost:4105",develop:"https://finances.service.bejusto.com",prod:"https://finances.service.getjusto.com"},"url-shortener":{local:"http://localhost:4102",develop:"https://url-shortener.service.bejusto.com",prod:"https://url-shortener.service.getjusto.com"},files:{local:"http://localhost:4108",develop:"https://files.service.bejusto.com",prod:"https://files.service.getjusto.com"},tabs:{local:"http://localhost:4115",develop:"https://tabs.service.bejusto.com",prod:"https://tabs.service.getjusto.com"},commander:{local:"http://localhost:4109",develop:"https://commander.service.bejusto.com",prod:"https://commander.service.getjusto.com"},experiments:{local:"http://localhost:4114",develop:"https://experiments.service.bejusto.com",prod:"https://experiments.service.getjusto.com"},sales:{local:"http://localhost:4117",develop:"https://sales.service.bejusto.com",prod:"https://sales.service.getjusto.com"},delivery:{local:"http://localhost:3410",develop:"https://api-delivery.bejusto.com",prod:"https://api-delivery-2.getjusto.com"},payments:{local:"http://localhost:4118",develop:"https://payments.service.bejusto.com",prod:"https://payments.service.getjusto.com"},addresses:{local:"http://localhost:4051",develop:"https://addresses.service.bejusto.com",prod:"https://addresses.service.getjusto.com"},royalty:{local:"http://localhost:4121",develop:"https://royalty.service.bejusto.com",prod:"https://royalty.service.getjusto.com"},marketing:{local:"http://localhost:4005",develop:"https://marketing.service.bejusto.com",prod:"https://marketing.service.getjusto.com"},api:{local:"http://localhost:4119",develop:"https://api.service.bejusto.com",prod:"https://api.service.getjusto.com"},messenger:{local:"http://localhost:4122",develop:"https://messenger.service.bejusto.com",prod:"https://messenger.service.getjusto.com"},invoice:{local:"http://localhost:4123",develop:"https://invoice.service.bejusto.com",prod:"https://invoice.service.getjusto.com"},"drivers-server":{local:"http://localhost:3410",develop:"https://api-delivery.bejusto.com",prod:"https://api-delivery-2.getjusto.com"}},L="prod";function lo(o){L=o}function po(){return L}function G(o){return Y[o][L]}function wo(o){let i=[],t={},r={};for(let e=0;e<o.length;e++)if(o[e].startsWith("--")&&o[e+1]&&!o[e+1].startsWith("--")){let s=o[e].slice(2);if(t[s]=o[e+1],!r[s])r[s]=[];r[s].push(o[e+1]),e++}else if(o[e].startsWith("--"))t[o[e].slice(2)]="true";else i.push(o[e]);return{positional:i,flags:t,arrayFlags:r}}function J(o,i){let t=o[i];if(!t)throw Error(`--${i} es requerido.`);return t}import{existsSync as io,mkdirSync as fi,readFileSync as bi,writeFileSync as qi,unlinkSync as Ci}from"node:fs";import{join as fo}from"node:path";import{homedir as $i}from"node:os";var oo=fo($i(),".justo-team");function to(){let o=po(),i=o==="prod"?"credentials.json":`credentials.${o}.json`;return fo(oo,i)}function Ii(){if(!io(oo))fi(oo,{recursive:!0})}function Z(o){Ii(),qi(to(),JSON.stringify(o,null,2))}function d(){let o=to();if(!io(o))return null;try{let i=bi(o,"utf-8");return JSON.parse(i)}catch{return null}}function ro(){let o=to();if(io(o))Ci(o)}import{existsSync as bo,readFileSync as ji,writeFileSync as yi,mkdirSync as hi}from"node:fs";import{join as qo}from"node:path";import{homedir as Ri}from"node:os";function Ui(){let o=qo(Ri(),".justo-team"),i=qo(o,"device-id");if(bo(i))return ji(i,"utf-8").trim();let t=crypto.randomUUID();if(!bo(o))hi(o,{recursive:!0});return yi(i,t),t}var $o={required:({label:o})=>`${o} no es opcional`,notAString:({label:o})=>`${o} no es un texto`,notANumber:({label:o})=>`${o} no es un número`,notAnInteger:({label:o})=>`${o} no es un número entero`,notABoolean:({label:o})=>`${o} no es un valor verdadero o falso`,notAnEmail:({label:o})=>`${o} no es un email`,notAnId:({label:o})=>`${o} no es un ID válido`,notADate:({label:o})=>`${o} no es una fecha válida`,notAnArray:({label:o})=>`${o} no es un arreglo`,notAnObject:({label:o})=>`${o} no es un objeto`,stringTooShort:({label:o})=>`${o} no tiene el largo suficiente`,stringTooLong:"El largo es mayor al permitido",numberTooSmall:({label:o})=>`${o} es un número muy pequeño`,numberTooBig:({label:o})=>`${o} es un número muy grande`,notInSchema:({label:o})=>`${o} no esta permitido`,notUnique:({label:o})=>`${o} no es único`,notFound:({label:o})=>`${o} no se encontró`,invalid:"No es válido",rateLimitExceeded:"Has excedido el límite de intentos. Intenta de nuevo más tarde.",incorrectLoginCode:"El código es incorrecto",loginCodeExpired:"El código expiró. Solicita un nuevo",loginCodeLocked:"El código se bloqueó. Genera un nuevo código para continuar",userNotFound:"No existe una cuenta con este email"};function xi(o,i){let t=$o[o];if(!t)return`${i}: ${o}`;if(typeof t==="function")return t({label:i});return t}function Co(o){return Object.entries(o).map(([i,t])=>xi(t,i)).join(", ")}function Ei(o){if(o.error==="validationError"&&o.validationErrors)return Co(o.validationErrors);if(o.extensions?.code==="PermissionsError"){let e=o.extensions.info?.type;if(e?.includes("User doesn't have permissions for "))return`Tu usuario no tiene permisos para [${e.split("User doesn't have permissions for ")[1]}]`;return o.message}if(o.validationErrors)return`${o.message} (${Co(o.validationErrors)})`;let i=o.message||"Error desconocido",t=$o[i];if(t)return typeof t==="function"?t({label:""}).trim():t;let r=o.error||o.code||o.type;return r?`${i} [${r}]`:i}function Pi(o){try{return JSON.parse(Buffer.from(o.split(".")[1],"base64").toString()).exp*1000<Date.now()}catch{return!0}}async function Wi(){let o=d();if(!o?.refreshToken)return null;let i=`${G("auth")}/refresh-token`,r=await(await fetch(i,{method:"POST",headers:{"X-ORION-REFRESH":o.refreshToken}})).json();if(!r.token)return null;return Z({...o,token:r.token}),r.token}async function Ni(){let o=d();if(!o?.token)return;if(!Pi(o.token))return o.token;return await Wi()??void 0}async function c(o){let i=`${G(o.service)}/graphql`,t=await Ni(),r={"Content-Type":"application/json","X-ORION-DEVICEID":Ui(),"X-ORION-PLATFORM":"web"};if(t)r["x-orion-jwt"]=t;let e;try{e=await fetch(i,{method:"POST",headers:r,body:JSON.stringify({query:o.query,variables:o.variables}),signal:AbortSignal.timeout(15000)})}catch{throw Error("La solicitud tardó demasiado. Intenta de nuevo.")}let s=await e.json();if(s.errors?.length)throw Error(Ei(s.errors[0]));if(!s.data)throw Error("No data returned from server");return s.data}import{createInterface as Ai}from"node:readline";function eo(o){let i=Ai({input:process.stdin,output:process.stderr});return new Promise((t)=>{i.question(o,(r)=>{i.close(),t(r.trim())})})}var Oi={comma:",",tab:"\t",pipe:"|"},M=Oi.comma;function jo(o){return o.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Si(o){return o==="true"||o==="false"||o==="null"}function h(o){if(o===null)return null;if(typeof o==="object"&&o!==null&&"toJSON"in o&&typeof o.toJSON==="function"){let i=o.toJSON();if(i!==o)return h(i)}if(typeof o==="string"||typeof o==="boolean")return o;if(typeof o==="number"){if(Object.is(o,-0))return 0;if(!Number.isFinite(o))return null;return o}if(typeof o==="bigint"){if(o>=Number.MIN_SAFE_INTEGER&&o<=Number.MAX_SAFE_INTEGER)return Number(o);return o.toString()}if(o instanceof Date)return o.toISOString();if(Array.isArray(o))return o.map(h);if(o instanceof Set)return Array.from(o).map(h);if(o instanceof Map)return Object.fromEntries(Array.from(o,([i,t])=>[String(i),h(t)]));if(Qi(o)){let i={};for(let t in o)if(Object.prototype.hasOwnProperty.call(o,t))i[t]=h(o[t]);return i}return null}function W(o){return o===null||typeof o==="string"||typeof o==="number"||typeof o==="boolean"}function E(o){return Array.isArray(o)}function w(o){return o!==null&&typeof o==="object"&&!Array.isArray(o)}function _(o){return Object.keys(o).length===0}function Qi(o){if(o===null||typeof o!=="object")return!1;let i=Object.getPrototypeOf(o);return i===null||i===Object.prototype}function F(o){return o.length===0||o.every((i)=>W(i))}function Bi(o){return o.length===0||o.every((i)=>E(i))}function yo(o){return o.length===0||o.every((i)=>w(i))}function Gi(o){return/^[A-Z_][\w.]*$/i.test(o)}function Ji(o){return/^[A-Z_]\w*$/i.test(o)}function _i(o,i=M){if(!o)return!1;if(o!==o.trim())return!1;if(Si(o)||Fi(o))return!1;if(o.includes(":"))return!1;if(o.includes('"')||o.includes("\\"))return!1;if(/[[\]{}]/.test(o))return!1;if(/[\n\r\t]/.test(o))return!1;if(o.includes(i))return!1;if(o.startsWith("-"))return!1;return!0}function Fi(o){return/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(o)||/^0\d+$/.test(o)}var St=Symbol("quotedKey");function Ti(o,i,t,r,e,s,n){if(r.keyFolding!=="safe")return;if(!w(i))return;let{segments:a,tail:u,leafValue:j}=Mi(o,i,n??r.flattenDepth);if(a.length<2)return;if(!a.every((y)=>Ji(y)))return;let b=Xi(a),q=s?`${s}.${b}`:b;if(t.includes(b))return;if(e&&e.has(q))return;return{foldedKey:b,remainder:u,leafValue:j,segmentCount:a.length}}function Mi(o,i,t){let r=[o],e=i;while(r.length<t){if(!w(e))break;let s=Object.keys(e);if(s.length!==1)break;let n=s[0],a=e[n];r.push(n),e=a}if(!w(e)||_(e))return{segments:r,tail:void 0,leafValue:e};return{segments:r,tail:e,leafValue:e}}function Xi(o){return o.join(".")}function A(o,i){if(o===null)return"null";if(typeof o==="boolean")return String(o);if(typeof o==="number")return String(o);return Yi(o,i)}function Yi(o,i=M){if(_i(o,i))return o;return`"${jo(o)}"`}function T(o){if(Gi(o))return o;return`"${jo(o)}"`}function ho(o,i=M){return o.map((t)=>A(t,i)).join(i)}function R(o,i){let t=i?.key,r=i?.fields,e=i?.delimiter??",",s="";if(t)s+=T(t);if(s+=`[${o}${e!==M?e:""}]`,r){let n=r.map((a)=>T(a));s+=`{${n.join(e)}}`}return s+=":",s}function*Zi(o,i,t){if(W(o)){let r=A(o,i.delimiter);if(r!=="")yield r;return}if(E(o))yield*so(void 0,o,t,i);else if(w(o))yield*N(o,t,i)}function*N(o,i,t,r,e,s){let n=Object.keys(o);if(i===0&&!r)r=new Set(n.filter((u)=>u.includes(".")));let a=s??t.flattenDepth;for(let[u,j]of Object.entries(o))yield*vi(u,j,i,t,n,r,e,a)}function*vi(o,i,t,r,e,s,n,a){let u=n?`${n}.${o}`:o,j=a??r.flattenDepth;if(r.keyFolding==="safe"&&e){let q=Ti(o,i,e,r,s,n,j);if(q){let{foldedKey:y,remainder:B,leafValue:x,segmentCount:li}=q,V=T(y);if(B===void 0){if(W(x)){yield p(t,`${V}: ${A(x,r.delimiter)}`,r.indent);return}else if(E(x)){yield*so(y,x,t,r);return}else if(w(x)&&_(x)){yield p(t,`${V}:`,r.indent);return}}if(w(B)){yield p(t,`${V}:`,r.indent);let pi=j-li,wi=n?`${n}.${y}`:y;yield*N(B,t+1,r,s,wi,pi);return}}}let b=T(o);if(W(i))yield p(t,`${b}: ${A(i,r.delimiter)}`,r.indent);else if(E(i))yield*so(o,i,t,r);else if(w(i)){if(yield p(t,`${b}:`,r.indent),!_(i))yield*N(i,t+1,r,s,u,j)}}function*so(o,i,t,r){if(i.length===0){yield p(t,R(0,{key:o,delimiter:r.delimiter}),r.indent);return}if(F(i)){yield p(t,z(i,r.delimiter,o),r.indent);return}if(Bi(i)){if(i.every((e)=>F(e))){yield*zi(o,i,t,r);return}}if(yo(i)){let e=Ro(i);if(e)yield*Hi(o,i,e,t,r);else yield*Io(o,i,t,r);return}yield*Io(o,i,t,r)}function*zi(o,i,t,r){yield p(t,R(i.length,{key:o,delimiter:r.delimiter}),r.indent);for(let e of i)if(F(e)){let s=z(e,r.delimiter);yield C(t+1,s,r.indent)}}function z(o,i,t){let r=R(o.length,{key:t,delimiter:i}),e=ho(o,i);if(o.length===0)return r;return`${r} ${e}`}function*Hi(o,i,t,r,e){yield p(r,R(i.length,{key:o,fields:t,delimiter:e.delimiter}),e.indent),yield*Uo(i,t,r+1,e)}function Ro(o){if(o.length===0)return;let i=o[0],t=Object.keys(i);if(t.length===0)return;if(Di(o,t))return t}function Di(o,i){for(let t of o){if(Object.keys(t).length!==i.length)return!1;for(let r of i){if(!(r in t))return!1;if(!W(t[r]))return!1}}return!0}function*Uo(o,i,t,r){for(let e of o)yield p(t,ho(i.map((s)=>e[s]),r.delimiter),r.indent)}function*Io(o,i,t,r){yield p(t,R(i.length,{key:o,delimiter:r.delimiter}),r.indent);for(let e of i)yield*no(e,t+1,r)}function*Ki(o,i,t){if(_(o)){yield p(i,"-",t.indent);return}let r=Object.entries(o),[e,s]=r[0],n=r.slice(1);if(E(s)&&yo(s)){let u=Ro(s);if(u){if(yield C(i,R(s.length,{key:e,fields:u,delimiter:t.delimiter}),t.indent),yield*Uo(s,u,i+2,t),n.length>0)yield*N(Object.fromEntries(n),i+1,t);return}}let a=T(e);if(W(s))yield C(i,`${a}: ${A(s,t.delimiter)}`,t.indent);else if(E(s))if(s.length===0)yield C(i,`${a}${R(0,{delimiter:t.delimiter})}`,t.indent);else if(F(s))yield C(i,`${a}${z(s,t.delimiter)}`,t.indent);else{yield C(i,`${a}${R(s.length,{delimiter:t.delimiter})}`,t.indent);for(let u of s)yield*no(u,i+2,t)}else if(w(s)){if(yield C(i,`${a}:`,t.indent),!_(s))yield*N(s,i+2,t)}if(n.length>0)yield*N(Object.fromEntries(n),i+1,t)}function*no(o,i,t){if(W(o))yield C(i,A(o,t.delimiter),t.indent);else if(E(o))if(F(o))yield C(i,z(o,t.delimiter),t.indent);else{yield C(i,R(o.length,{delimiter:t.delimiter}),t.indent);for(let r of o)yield*no(r,i+1,t)}else if(w(o))yield*Ki(o,i,t)}function p(o,i,t){return" ".repeat(t*o)+i}function C(o,i,t){return p(o,"- "+i,t)}function ki(o,i){let t=i("",o,[]);if(t===void 0)return v(o,i,[]);return v(h(t),i,[])}function v(o,i,t){if(w(o))return Vi(o,i,t);if(E(o))return Li(o,i,t);return o}function Vi(o,i,t){let r={};for(let[e,s]of Object.entries(o)){let n=[...t,e],a=i(e,s,n);if(a===void 0)continue;r[e]=v(h(a),i,n)}return r}function Li(o,i,t){let r=[];for(let e=0;e<o.length;e++){let s=o[e],n=[...t,e],a=i(String(e),s,n);if(a===void 0)continue;let u=h(a);r.push(v(u,i,n))}return r}function ao(o,i){return Array.from(ot(o,i)).join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
2
|
+
var X={main:{local:"http://localhost:3000",develop:"https://api.bejusto.com",prod:"https://api.getjusto.com"},auth:{local:"http://localhost:4112",develop:"https://auth.service.bejusto.com",prod:"https://auth.service.getjusto.com"},webdata:{local:"http://localhost:4125",develop:"https://webdata.service.bejusto.com",prod:"https://webdatacdn.getjusto.com"},preferences:{local:"http://localhost:4120",develop:"https://preferences.service.bejusto.com",prod:"https://preferences.service.getjusto.com"},buckets:{local:"http://localhost:4106",develop:"https://buckets.service.bejusto.com",prod:"https://buckets.service.getjusto.com"},reservations:{local:"http://localhost:4113",develop:"https://reservations.service.bejusto.com",prod:"https://reservations.service.getjusto.com"},data:{local:"http://localhost:4107",develop:"https://data.service.bejusto.com",prod:"https://data.service.getjusto.com"},finances:{local:"http://localhost:4105",develop:"https://finances.service.bejusto.com",prod:"https://finances.service.getjusto.com"},"url-shortener":{local:"http://localhost:4102",develop:"https://url-shortener.service.bejusto.com",prod:"https://url-shortener.service.getjusto.com"},files:{local:"http://localhost:4108",develop:"https://files.service.bejusto.com",prod:"https://files.service.getjusto.com"},tabs:{local:"http://localhost:4115",develop:"https://tabs.service.bejusto.com",prod:"https://tabs.service.getjusto.com"},commander:{local:"http://localhost:4109",develop:"https://commander.service.bejusto.com",prod:"https://commander.service.getjusto.com"},experiments:{local:"http://localhost:4114",develop:"https://experiments.service.bejusto.com",prod:"https://experiments.service.getjusto.com"},sales:{local:"http://localhost:4117",develop:"https://sales.service.bejusto.com",prod:"https://sales.service.getjusto.com"},delivery:{local:"http://localhost:3410",develop:"https://api-delivery.bejusto.com",prod:"https://api-delivery-2.getjusto.com"},payments:{local:"http://localhost:4118",develop:"https://payments.service.bejusto.com",prod:"https://payments.service.getjusto.com"},addresses:{local:"http://localhost:4051",develop:"https://addresses.service.bejusto.com",prod:"https://addresses.service.getjusto.com"},royalty:{local:"http://localhost:4121",develop:"https://royalty.service.bejusto.com",prod:"https://royalty.service.getjusto.com"},marketing:{local:"http://localhost:4005",develop:"https://marketing.service.bejusto.com",prod:"https://marketing.service.getjusto.com"},api:{local:"http://localhost:4119",develop:"https://api.service.bejusto.com",prod:"https://api.service.getjusto.com"},messenger:{local:"http://localhost:4122",develop:"https://messenger.service.bejusto.com",prod:"https://messenger.service.getjusto.com"},invoice:{local:"http://localhost:4123",develop:"https://invoice.service.bejusto.com",prod:"https://invoice.service.getjusto.com"},"drivers-server":{local:"http://localhost:3410",develop:"https://api-delivery.bejusto.com",prod:"https://api-delivery-2.getjusto.com"}},L="prod";function lo(o){L=o}function po(){return L}function B(o){return X[o][L]}function wo(o){let t=[],e={},i={};for(let r=0;r<o.length;r++)if(o[r].startsWith("--")&&o[r+1]&&!o[r+1].startsWith("--")){let s=o[r].slice(2);if(e[s]=o[r+1],!i[s])i[s]=[];i[s].push(o[r+1]),r++}else if(o[r].startsWith("--"))e[o[r].slice(2)]="true";else t.push(o[r]);return{positional:t,flags:e,arrayFlags:i}}function J(o,t){let e=o[t];if(!e)throw Error(`--${t} es requerido.`);return e}import{existsSync as to,mkdirSync as bt,readFileSync as qt,writeFileSync as Ct,unlinkSync as It}from"node:fs";import{join as fo}from"node:path";import{homedir as $t}from"node:os";var oo=fo($t(),".justo-team");function eo(){let o=po(),t=o==="prod"?"credentials.json":`credentials.${o}.json`;return fo(oo,t)}function yt(){if(!to(oo))bt(oo,{recursive:!0})}function Y(o){yt(),Ct(eo(),JSON.stringify(o,null,2))}function d(){let o=eo();if(!to(o))return null;try{let t=qt(o,"utf-8");return JSON.parse(t)}catch{return null}}function io(){let o=eo();if(to(o))It(o)}import{existsSync as bo,readFileSync as jt,writeFileSync as ht,mkdirSync as Rt}from"node:fs";import{join as qo}from"node:path";import{homedir as Et}from"node:os";function xt(){let o=qo(Et(),".justo-team"),t=qo(o,"device-id");if(bo(t))return jt(t,"utf-8").trim();let e=crypto.randomUUID();if(!bo(o))Rt(o,{recursive:!0});return ht(t,e),e}var Io={required:({label:o})=>`${o} no es opcional`,notAString:({label:o})=>`${o} no es un texto`,notANumber:({label:o})=>`${o} no es un número`,notAnInteger:({label:o})=>`${o} no es un número entero`,notABoolean:({label:o})=>`${o} no es un valor verdadero o falso`,notAnEmail:({label:o})=>`${o} no es un email`,notAnId:({label:o})=>`${o} no es un ID válido`,notADate:({label:o})=>`${o} no es una fecha válida`,notAnArray:({label:o})=>`${o} no es un arreglo`,notAnObject:({label:o})=>`${o} no es un objeto`,stringTooShort:({label:o})=>`${o} no tiene el largo suficiente`,stringTooLong:"El largo es mayor al permitido",numberTooSmall:({label:o})=>`${o} es un número muy pequeño`,numberTooBig:({label:o})=>`${o} es un número muy grande`,notInSchema:({label:o})=>`${o} no esta permitido`,notUnique:({label:o})=>`${o} no es único`,notFound:({label:o})=>`${o} no se encontró`,invalid:"No es válido",rateLimitExceeded:"Has excedido el límite de intentos. Intenta de nuevo más tarde.",incorrectLoginCode:"El código es incorrecto",loginCodeExpired:"El código expiró. Solicita un nuevo",loginCodeLocked:"El código se bloqueó. Genera un nuevo código para continuar",userNotFound:"No existe una cuenta con este email"};function Ut(o,t){let e=Io[o];if(!e)return`${t}: ${o}`;if(typeof e==="function")return e({label:t});return e}function Co(o){return Object.entries(o).map(([t,e])=>Ut(e,t)).join(", ")}function Pt(o){if(o.error==="validationError"&&o.validationErrors)return Co(o.validationErrors);if(o.extensions?.code==="PermissionsError"){let r=o.extensions.info?.type;if(r?.includes("User doesn't have permissions for "))return`Tu usuario no tiene permisos para [${r.split("User doesn't have permissions for ")[1]}]`;return o.message}if(o.validationErrors)return`${o.message} (${Co(o.validationErrors)})`;let t=o.message||"Error desconocido",e=Io[t];if(e)return typeof e==="function"?e({label:""}).trim():e;let i=o.error||o.code||o.type;return i?`${t} [${i}]`:t}function Nt(o){try{return JSON.parse(Buffer.from(o.split(".")[1],"base64").toString()).exp*1000<Date.now()}catch{return!0}}async function Wt(){let o=d();if(!o?.refreshToken)return null;let t=`${B("auth")}/refresh-token`,i=await(await fetch(t,{method:"POST",headers:{"X-ORION-REFRESH":o.refreshToken}})).json();if(!i.token)return null;return Y({...o,token:i.token}),i.token}async function At(){let o=d();if(!o?.token)return;if(!Nt(o.token))return o.token;return await Wt()??void 0}async function c(o){let t=`${B(o.service)}/graphql`,e=await At(),i={"Content-Type":"application/json","X-ORION-DEVICEID":xt(),"X-ORION-PLATFORM":"web"};if(e)i["x-orion-jwt"]=e;let r;try{r=await fetch(t,{method:"POST",headers:i,body:JSON.stringify({query:o.query,variables:o.variables}),signal:AbortSignal.timeout(15000)})}catch{throw Error("La solicitud tardó demasiado. Intenta de nuevo.")}let s=await r.json();if(s.errors?.length)throw Error(Pt(s.errors[0]));if(!s.data)throw Error("No data returned from server");return s.data}import{createInterface as Ot}from"node:readline";function ro(o){let t=Ot({input:process.stdin,output:process.stderr});return new Promise((e)=>{t.question(o,(i)=>{t.close(),e(i.trim())})})}var St={comma:",",tab:"\t",pipe:"|"},F=St.comma;function yo(o){return o.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Qt(o){return o==="true"||o==="false"||o==="null"}function h(o){if(o===null)return null;if(typeof o==="object"&&o!==null&&"toJSON"in o&&typeof o.toJSON==="function"){let t=o.toJSON();if(t!==o)return h(t)}if(typeof o==="string"||typeof o==="boolean")return o;if(typeof o==="number"){if(Object.is(o,-0))return 0;if(!Number.isFinite(o))return null;return o}if(typeof o==="bigint"){if(o>=Number.MIN_SAFE_INTEGER&&o<=Number.MAX_SAFE_INTEGER)return Number(o);return o.toString()}if(o instanceof Date)return o.toISOString();if(Array.isArray(o))return o.map(h);if(o instanceof Set)return Array.from(o).map(h);if(o instanceof Map)return Object.fromEntries(Array.from(o,([t,e])=>[String(t),h(e)]));if(Gt(o)){let t={};for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e))t[e]=h(o[e]);return t}return null}function N(o){return o===null||typeof o==="string"||typeof o==="number"||typeof o==="boolean"}function U(o){return Array.isArray(o)}function w(o){return o!==null&&typeof o==="object"&&!Array.isArray(o)}function v(o){return Object.keys(o).length===0}function Gt(o){if(o===null||typeof o!=="object")return!1;let t=Object.getPrototypeOf(o);return t===null||t===Object.prototype}function T(o){return o.length===0||o.every((t)=>N(t))}function Bt(o){return o.length===0||o.every((t)=>U(t))}function jo(o){return o.length===0||o.every((t)=>w(t))}function Jt(o){return/^[A-Z_][\w.]*$/i.test(o)}function vt(o){return/^[A-Z_]\w*$/i.test(o)}function Tt(o,t=F){if(!o)return!1;if(o!==o.trim())return!1;if(Qt(o)||_t(o))return!1;if(o.includes(":"))return!1;if(o.includes('"')||o.includes("\\"))return!1;if(/[[\]{}]/.test(o))return!1;if(/[\n\r\t]/.test(o))return!1;if(o.includes(t))return!1;if(o.startsWith("-"))return!1;return!0}function _t(o){return/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(o)||/^0\d+$/.test(o)}var Be=Symbol("quotedKey");function Ft(o,t,e,i,r,s,n){if(i.keyFolding!=="safe")return;if(!w(t))return;let{segments:a,tail:u,leafValue:y}=Mt(o,t,n??i.flattenDepth);if(a.length<2)return;if(!a.every((j)=>vt(j)))return;let b=Xt(a),q=s?`${s}.${b}`:b;if(e.includes(b))return;if(r&&r.has(q))return;return{foldedKey:b,remainder:u,leafValue:y,segmentCount:a.length}}function Mt(o,t,e){let i=[o],r=t;while(i.length<e){if(!w(r))break;let s=Object.keys(r);if(s.length!==1)break;let n=s[0],a=r[n];i.push(n),r=a}if(!w(r)||v(r))return{segments:i,tail:void 0,leafValue:r};return{segments:i,tail:r,leafValue:r}}function Xt(o){return o.join(".")}function A(o,t){if(o===null)return"null";if(typeof o==="boolean")return String(o);if(typeof o==="number")return String(o);return Yt(o,t)}function Yt(o,t=F){if(Tt(o,t))return o;return`"${yo(o)}"`}function _(o){if(Jt(o))return o;return`"${yo(o)}"`}function ho(o,t=F){return o.map((e)=>A(e,t)).join(t)}function R(o,t){let e=t?.key,i=t?.fields,r=t?.delimiter??",",s="";if(e)s+=_(e);if(s+=`[${o}${r!==F?r:""}]`,i){let n=i.map((a)=>_(a));s+=`{${n.join(r)}}`}return s+=":",s}function*Zt(o,t,e){if(N(o)){let i=A(o,t.delimiter);if(i!=="")yield i;return}if(U(o))yield*so(void 0,o,e,t);else if(w(o))yield*W(o,e,t)}function*W(o,t,e,i,r,s){let n=Object.keys(o);if(t===0&&!i)i=new Set(n.filter((u)=>u.includes(".")));let a=s??e.flattenDepth;for(let[u,y]of Object.entries(o))yield*zt(u,y,t,e,n,i,r,a)}function*zt(o,t,e,i,r,s,n,a){let u=n?`${n}.${o}`:o,y=a??i.flattenDepth;if(i.keyFolding==="safe"&&r){let q=Ft(o,t,r,i,s,n,y);if(q){let{foldedKey:j,remainder:G,leafValue:x,segmentCount:pt}=q,V=_(j);if(G===void 0){if(N(x)){yield p(e,`${V}: ${A(x,i.delimiter)}`,i.indent);return}else if(U(x)){yield*so(j,x,e,i);return}else if(w(x)&&v(x)){yield p(e,`${V}:`,i.indent);return}}if(w(G)){yield p(e,`${V}:`,i.indent);let wt=y-pt,ft=n?`${n}.${j}`:j;yield*W(G,e+1,i,s,ft,wt);return}}}let b=_(o);if(N(t))yield p(e,`${b}: ${A(t,i.delimiter)}`,i.indent);else if(U(t))yield*so(o,t,e,i);else if(w(t)){if(yield p(e,`${b}:`,i.indent),!v(t))yield*W(t,e+1,i,s,u,y)}}function*so(o,t,e,i){if(t.length===0){yield p(e,R(0,{key:o,delimiter:i.delimiter}),i.indent);return}if(T(t)){yield p(e,z(t,i.delimiter,o),i.indent);return}if(Bt(t)){if(t.every((r)=>T(r))){yield*Ht(o,t,e,i);return}}if(jo(t)){let r=Ro(t);if(r)yield*Dt(o,t,r,e,i);else yield*$o(o,t,e,i);return}yield*$o(o,t,e,i)}function*Ht(o,t,e,i){yield p(e,R(t.length,{key:o,delimiter:i.delimiter}),i.indent);for(let r of t)if(T(r)){let s=z(r,i.delimiter);yield C(e+1,s,i.indent)}}function z(o,t,e){let i=R(o.length,{key:e,delimiter:t}),r=ho(o,t);if(o.length===0)return i;return`${i} ${r}`}function*Dt(o,t,e,i,r){yield p(i,R(t.length,{key:o,fields:e,delimiter:r.delimiter}),r.indent),yield*Eo(t,e,i+1,r)}function Ro(o){if(o.length===0)return;let t=o[0],e=Object.keys(t);if(e.length===0)return;if(kt(o,e))return e}function kt(o,t){for(let e of o){if(Object.keys(e).length!==t.length)return!1;for(let i of t){if(!(i in e))return!1;if(!N(e[i]))return!1}}return!0}function*Eo(o,t,e,i){for(let r of o)yield p(e,ho(t.map((s)=>r[s]),i.delimiter),i.indent)}function*$o(o,t,e,i){yield p(e,R(t.length,{key:o,delimiter:i.delimiter}),i.indent);for(let r of t)yield*no(r,e+1,i)}function*Kt(o,t,e){if(v(o)){yield p(t,"-",e.indent);return}let i=Object.entries(o),[r,s]=i[0],n=i.slice(1);if(U(s)&&jo(s)){let u=Ro(s);if(u){if(yield C(t,R(s.length,{key:r,fields:u,delimiter:e.delimiter}),e.indent),yield*Eo(s,u,t+2,e),n.length>0)yield*W(Object.fromEntries(n),t+1,e);return}}let a=_(r);if(N(s))yield C(t,`${a}: ${A(s,e.delimiter)}`,e.indent);else if(U(s))if(s.length===0)yield C(t,`${a}${R(0,{delimiter:e.delimiter})}`,e.indent);else if(T(s))yield C(t,`${a}${z(s,e.delimiter)}`,e.indent);else{yield C(t,`${a}${R(s.length,{delimiter:e.delimiter})}`,e.indent);for(let u of s)yield*no(u,t+2,e)}else if(w(s)){if(yield C(t,`${a}:`,e.indent),!v(s))yield*W(s,t+2,e)}if(n.length>0)yield*W(Object.fromEntries(n),t+1,e)}function*no(o,t,e){if(N(o))yield C(t,A(o,e.delimiter),e.indent);else if(U(o))if(T(o))yield C(t,z(o,e.delimiter),e.indent);else{yield C(t,R(o.length,{delimiter:e.delimiter}),e.indent);for(let i of o)yield*no(i,t+1,e)}else if(w(o))yield*Kt(o,t,e)}function p(o,t,e){return" ".repeat(e*o)+t}function C(o,t,e){return p(o,"- "+t,e)}function Vt(o,t){let e=t("",o,[]);if(e===void 0)return Z(o,t,[]);return Z(h(e),t,[])}function Z(o,t,e){if(w(o))return Lt(o,t,e);if(U(o))return oe(o,t,e);return o}function Lt(o,t,e){let i={};for(let[r,s]of Object.entries(o)){let n=[...e,r],a=t(r,s,n);if(a===void 0)continue;i[r]=Z(h(a),t,n)}return i}function oe(o,t,e){let i=[];for(let r=0;r<o.length;r++){let s=o[r],n=[...e,r],a=t(String(r),s,n);if(a===void 0)continue;let u=h(a);i.push(Z(u,t,n))}return i}function ao(o,t){return Array.from(te(o,t)).join(`
|
|
3
|
+
`)}function te(o,t){let e=h(o),i=ee(t);return Zt(i.replacer?Vt(e,i.replacer):e,i,0)}function ee(o){return{indent:o?.indent??2,delimiter:o?.delimiter??F,keyFolding:o?.keyFolding??"off",flattenDepth:o?.flattenDepth??Number.POSITIVE_INFINITY,replacer:o?.replacer}}function ie(o){let t=o.format??"toon";if(t!=="toon"&&t!=="json")throw Error("--format debe ser toon o json.");return t}function xo(o,t){if(ie(t)==="json"){console.log(JSON.stringify(o,null,2));return}console.log(ao(o))}function g(o){process.stdout.write(`${o}
|
|
4
|
+
`)}function Uo(o,t){let i={ok:!1,error:o instanceof Error?o.message:String(o)};if((t.format==="json"?"json":"toon")==="json"){console.error(JSON.stringify(i,null,2));return}console.error(ao(i))}function I(o){process.stderr.write(o)}async function Po(o){return(await c({service:"auth",query:`mutation ($email: String!) {
|
|
5
5
|
requestLoginCode(email: $email)
|
|
6
|
-
}`,variables:{email:o}})).requestLoginCode}async function
|
|
6
|
+
}`,variables:{email:o}})).requestLoginCode}async function No(o,t,e){let i=await c({service:"auth",query:`mutation ($email: String!, $token: String!, $code: String!) {
|
|
7
7
|
loginWithCode(email: $email, token: $token, code: $code) {
|
|
8
8
|
token
|
|
9
9
|
refreshToken
|
|
10
10
|
}
|
|
11
|
-
}`,variables:{email:o,token:
|
|
12
|
-
`);let
|
|
13
|
-
`);let
|
|
14
|
-
`);let
|
|
11
|
+
}`,variables:{email:o,token:t,code:e.toUpperCase()}});Y({email:o,token:i.loginWithCode.token,refreshToken:i.loginWithCode.refreshToken}),await re()}async function re(){if(!(await c({service:"main",query:"query { me { roles } }"})).me?.roles?.length)throw io(),Error("Solo miembros del equipo Justo pueden usar esta herramienta.")}async function Wo(){let o=await ro("Email: ");I(`Enviando codigo de verificacion...
|
|
12
|
+
`);let t=await Po(o);I(`Codigo enviado a tu email.
|
|
13
|
+
`);let e=await ro("Codigo: ");return await No(o,t,e),{ok:!0,authenticated:!0,email:o}}async function Ao(o){let t=J(o,"email"),e=J(o,"token"),i=J(o,"code");return await No(t,e,i),{ok:!0,authenticated:!0,email:t}}async function Oo(o){let t=J(o,"email");I(`Enviando codigo de verificacion...
|
|
14
|
+
`);let e=await Po(t);return{ok:!0,email:t,token:e,nextCommand:`npx @getjusto/team-cli auth login-with-token --email ${t} --token ${e} --code <CODIGO>`}}async function So(){return io(),{ok:!0,authenticated:!1}}async function Qo(){let o=d();if(!o)return{authenticated:!1,loginCommand:"npx @getjusto/team-cli@latest auth login"};return{authenticated:!0,email:o.email}}function co(){return`team-cli auth
|
|
15
15
|
|
|
16
16
|
Gestion de sesion.
|
|
17
17
|
|
|
@@ -37,23 +37,40 @@ Subcomandos:
|
|
|
37
37
|
|
|
38
38
|
login-with-token
|
|
39
39
|
Iniciar sesion sin prompts.
|
|
40
|
-
Uso: team-cli auth login-with-token --email <email> --token <token> --code <codigo>`}var mo=["main","auth","webdata","preferences","buckets","reservations","data","finances","url-shortener","files","tabs","commander","experiments","sales","delivery","payments","addresses","royalty","marketing","api","messenger","invoice","drivers-server"]
|
|
40
|
+
Uso: team-cli auth login-with-token --email <email> --token <token> --code <codigo>`}var mo=["main","auth","webdata","preferences","buckets","reservations","data","finances","url-shortener","files","tabs","commander","experiments","sales","delivery","payments","addresses","royalty","marketing","api","messenger","invoice","drivers-server"],Go=`
|
|
41
|
+
query ResolverInfo($name: ID!, $mutation: Boolean!) {
|
|
42
|
+
params(name: $name, mutation: $mutation) {
|
|
43
|
+
name
|
|
44
|
+
params
|
|
45
|
+
result
|
|
46
|
+
basicResultQuery
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;function se(o){if(!o)throw Error("Uso: team-cli graphql <servicio> '<query>' [--variables '<json>'] [--format toon|json]");if(!mo.includes(o))throw Error(`Servicio "${o}" no válido. Servicios disponibles: ${mo.join(", ")}`)}async function ne(o,t){let e;try{let i=await c({service:o,query:Go,variables:{name:t,mutation:!1}});return{service:o,operationName:t,operationType:"query",info:i.params}}catch(i){e=i}try{let i=await c({service:o,query:Go,variables:{name:t,mutation:!0}});return{service:o,operationName:t,operationType:"mutation",info:i.params}}catch(i){let r=e instanceof Error?e.message:"",s=i instanceof Error?i.message:"";if(r.includes('Cannot query field "params"')||s.includes('Cannot query field "params"'))throw Error(`El servicio "${o}" no expone metadata de resolvers por GraphQL.`);throw e instanceof Error?e:i}}async function Bo(o,t){let e=o[1],i=o[2],r=o[2];if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login");if(se(e),i==="info"){let a=o[3];if(!a)throw Error("Uso: team-cli graphql <servicio> info <queryName|mutationName> [--format toon|json]");return await ne(e,a)}if(!r)throw Error("Uso: team-cli graphql <servicio> '<query>' [--variables '<json>'] [--format toon|json]");let s;if(t.variables)try{s=JSON.parse(t.variables)}catch{throw Error("Las variables deben ser un JSON válido.")}return await c({service:e,query:r,variables:s})}function Jo(){return`team-cli graphql
|
|
41
50
|
|
|
42
51
|
Ejecutar queries y mutations GraphQL.
|
|
43
52
|
|
|
44
53
|
Uso:
|
|
45
54
|
team-cli graphql <servicio> '<query>' [--variables '<json>'] [--format toon|json]
|
|
55
|
+
team-cli graphql <servicio> info <queryName|mutationName> [--format toon|json]
|
|
46
56
|
|
|
47
57
|
Ejemplos:
|
|
48
58
|
team-cli graphql main 'query { me { _id roles } }'
|
|
49
59
|
team-cli graphql main 'query($id: ID) { user(userId: $id) { _id } }' --variables '{"id": "abc123"}'
|
|
50
60
|
team-cli graphql main 'query { me { _id } }' --format json
|
|
61
|
+
team-cli graphql main info website
|
|
62
|
+
team-cli graphql webdata info setWebsiteTheme --format json
|
|
51
63
|
|
|
52
64
|
Servicios disponibles:
|
|
53
65
|
${mo.join(", ")}
|
|
54
66
|
|
|
67
|
+
Comando info:
|
|
68
|
+
Consulta la metadata publicada por OrionJS para un query o mutation.
|
|
69
|
+
Devuelve el tipo de operación, los params serializados, el resultado y un basicResultQuery.
|
|
70
|
+
Si no indicas si es query o mutation, la CLI prueba ambas automáticamente.
|
|
71
|
+
|
|
55
72
|
Formato:
|
|
56
|
-
Por defecto usa toon. Usa --format json para JSON estándar.`}function
|
|
73
|
+
Por defecto usa toon. Usa --format json para JSON estándar.`}function ae(o){return o.replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/\/.*$/,"")}function ce(o){return o.includes(".")||o.startsWith("http://")||o.startsWith("https://")}async function O(o){if(ce(o)){let t=ae(o),e=await fetch(`${B("main")}/website-id/${t}`,{signal:AbortSignal.timeout(1e4)});if(!e.ok)throw Error(`No se encontro el sitio "${t}"`);let i=await e.json();if(!i.websiteId)throw Error(`No se pudo resolver el websiteId para "${t}"`);return{input:o,websiteId:i.websiteId,targetType:"domain"}}return{input:o,websiteId:o,targetType:"websiteId"}}async function vo(o){let t=await c({service:"main",query:`query ($websiteId: ID) {
|
|
57
74
|
website(websiteId: $websiteId) {
|
|
58
75
|
_id
|
|
59
76
|
name
|
|
@@ -65,7 +82,7 @@ Formato:
|
|
|
65
82
|
timezone
|
|
66
83
|
defaultMenuId
|
|
67
84
|
}
|
|
68
|
-
}`,variables:{websiteId:o}});if(!
|
|
85
|
+
}`,variables:{websiteId:o}});if(!t.website)throw Error(`No se encontro el website "${o}"`);return t.website}function me(){if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login")}async function To(o){if(me(),!o)throw Error("Uso: team-cli admin <websiteId|domain> show");let t=await O(o),e=await vo(t.websiteId);return{context:t,website:e}}function H(){return`team-cli admin
|
|
69
86
|
|
|
70
87
|
Comandos administrativos con contexto de website.
|
|
71
88
|
|
|
@@ -87,7 +104,7 @@ Modulos:
|
|
|
87
104
|
|
|
88
105
|
coupons
|
|
89
106
|
Administrar cupones y sus códigos.
|
|
90
|
-
Uso: team-cli admin <websiteId|domain> coupons <accion> [opciones]`}var
|
|
107
|
+
Uso: team-cli admin <websiteId|domain> coupons <accion> [opciones]`}var _o=`
|
|
91
108
|
availableAtPeriods
|
|
92
109
|
closedDays
|
|
93
110
|
closedUntilDate
|
|
@@ -138,13 +155,13 @@ Modulos:
|
|
|
138
155
|
requiredBINs
|
|
139
156
|
extraRequirementsForPaymentTypes
|
|
140
157
|
schedule {
|
|
141
|
-
${
|
|
158
|
+
${_o}
|
|
142
159
|
}
|
|
143
160
|
scheduleAtUse {
|
|
144
|
-
${
|
|
161
|
+
${_o}
|
|
145
162
|
}
|
|
146
163
|
codesCode
|
|
147
|
-
`,
|
|
164
|
+
`,Fo=`
|
|
148
165
|
_id
|
|
149
166
|
code
|
|
150
167
|
couponId
|
|
@@ -153,12 +170,12 @@ Modulos:
|
|
|
153
170
|
sentToEmail
|
|
154
171
|
totalRedemptions
|
|
155
172
|
createdAt
|
|
156
|
-
`;function uo(){if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login")}function S(o,
|
|
173
|
+
`;function uo(){if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login")}function S(o,t){let e=o[t];if(!e)throw Error(`--${t} es requerido.`);try{return JSON.parse(e)}catch{throw Error(`--${t} debe ser un JSON válido.`)}}function $(o,t){let e=o[t];if(!e)return;let i=Number.parseInt(e,10);if(Number.isNaN(i))throw Error(`--${t} debe ser un número entero.`);return i}function Mo(o,t){let e=o[t];if(!e)return;if(e==="true")return!0;if(e==="false")return!1;throw Error(`--${t} debe ser true o false.`)}async function f(o){if(uo(),!o)throw Error("Debes indicar <websiteId|domain>.");return O(o)}async function E(o,t){let e=await c({service:"main",query:`query ($couponId: ID) {
|
|
157
174
|
coupon(couponId: $couponId) {
|
|
158
175
|
_id
|
|
159
176
|
websiteId
|
|
160
177
|
}
|
|
161
|
-
}`,variables:{couponId:o}});if(!
|
|
178
|
+
}`,variables:{couponId:o}});if(!e.coupon)throw Error(`No se encontró el cupón "${o}"`);if(e.coupon.websiteId!==t)throw Error(`El cupón "${o}" no pertenece al website seleccionado.`);return e.coupon}async function Xo(o,t){uo();let e=o[2]??t.filter;if(!e)throw Error("Debes indicar un término de búsqueda. Uso: team-cli admin search <texto>");let i=$(t,"limit"),r=$(t,"page"),s=Mo(t,"only-active"),n=await c({service:"main",query:`query ($filter: String, $limit: BigInt, $page: BigInt, $onlyActiveWebsites: Boolean) {
|
|
162
179
|
websites(filter: $filter, limit: $limit, page: $page, onlyActiveWebsites: $onlyActiveWebsites) {
|
|
163
180
|
items {
|
|
164
181
|
_id
|
|
@@ -174,7 +191,7 @@ Modulos:
|
|
|
174
191
|
hasNextPage
|
|
175
192
|
hasPreviousPage
|
|
176
193
|
}
|
|
177
|
-
}`,variables:{filter:
|
|
194
|
+
}`,variables:{filter:e,limit:i,page:r,onlyActiveWebsites:s}});return{searchTerm:e,websites:n.websites.items??[],pagination:{totalCount:n.websites.totalCount??0,totalPages:n.websites.totalPages??0,hasNextPage:Boolean(n.websites.hasNextPage),hasPreviousPage:Boolean(n.websites.hasPreviousPage),page:r??1,limit:i??null}}}function Yo(){return`team-cli admin search
|
|
178
195
|
|
|
179
196
|
Buscar websites en admin.
|
|
180
197
|
|
|
@@ -194,7 +211,7 @@ Opciones:
|
|
|
194
211
|
Ejemplos:
|
|
195
212
|
team-cli admin search milas
|
|
196
213
|
team-cli admin search buffalo --limit 5
|
|
197
|
-
team-cli admin search pizza --only-active true`}function
|
|
214
|
+
team-cli admin search pizza --only-active true`}function ue(){if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login")}function ge(o){let t=[o.address?.streetAddress,o.address?.extendedAddress,o.address?.locality].filter(Boolean);if(!t.length)return null;return t.join(", ")}async function Zo(o){if(ue(),!o)throw Error("Uso: team-cli admin <websiteId|domain> stores list");let t=await O(o),i=((await c({service:"main",query:`query ($websiteId: ID) {
|
|
198
215
|
stores(websiteId: $websiteId) {
|
|
199
216
|
items {
|
|
200
217
|
_id
|
|
@@ -206,11 +223,11 @@ Ejemplos:
|
|
|
206
223
|
}
|
|
207
224
|
}
|
|
208
225
|
}
|
|
209
|
-
}`,variables:{websiteId:
|
|
210
|
-
createCoupon(${
|
|
226
|
+
}`,variables:{websiteId:t.websiteId}})).stores.items??[]).map((r)=>({_id:r._id,name:r.name,address:ge(r)})).sort((r,s)=>r.name.localeCompare(s.name,"es",{sensitivity:"base"}));return{context:t,stores:i,totalCount:i.length}}var zo={active:"Boolean",allowedEmails:"[String]",applyDeliveryDiscount:"Boolean",code:"ID",deliveryDiscountPercentage:"Float",deliveryDiscountType:"String",deliveryDiscountValue:"Float",description:"String",discountAmount:"Float",dontApplyToProductsIds:"[ID]",endDate:"Date",externalId:"String",extraRequirementsForPaymentTypes:"JSON",fixedAmount:"Float",fromDate:"Date",isBirthdayCoupon:"Boolean",isHidden:"Boolean",maxPercentageOffDiscount:"Float",maxProductsPerOrder:"Float",maxRedemptions:"Float",maxRedemptionsPerUser:"Float",maxRedemptionsPerUserPerDay:"Boolean",maximumOrderPrice:"Float",minimumOrderPrice:"Float",name:"String",onlyForNewUsers:"Boolean",onlyForProductsWithoutDiscount:"Boolean",onlyRedeemOnBirthday:"Boolean",percentageOff:"Float",requireChannels:"[ID]",requirePhoneVerification:"Boolean",requiredBINs:"[String]",requiresCategoriesIds:"[ID]",requiresMenusIds:"[ID]",requiresPaymentTypes:"[ID]",requiresProductsIds:"[ID]",requiresStoresIds:"[ID]",schedule:"ScheduleInput",scheduleAtUse:"ScheduleInput",type:"ID",websiteId:"ID"};function de(o){let t=Object.entries(o).filter(([,s])=>s!==void 0),e=t.map(([s])=>s).filter((s)=>!zo[s]);if(e.length)throw Error(`Campos no soportados para create: ${e.join(", ")}`);let i=t.map(([s])=>`$${s}: ${zo[s]}`).join(", "),r=t.map(([s])=>`${s}: $${s}`).join(", ");return`mutation (${i}) {
|
|
227
|
+
createCoupon(${r}) {
|
|
211
228
|
${D}
|
|
212
229
|
}
|
|
213
|
-
}`}async function
|
|
230
|
+
}`}async function Ho(o,t){let e=await f(o),i=$(t,"limit"),r=$(t,"page"),s=t.filter,n=await c({service:"main",query:`query ($websiteId: ID, $filter: String, $limit: BigInt, $page: BigInt) {
|
|
214
231
|
coupons(websiteId: $websiteId, filter: $filter, limit: $limit, page: $page) {
|
|
215
232
|
items {
|
|
216
233
|
_id
|
|
@@ -230,17 +247,17 @@ Ejemplos:
|
|
|
230
247
|
hasNextPage
|
|
231
248
|
hasPreviousPage
|
|
232
249
|
}
|
|
233
|
-
}`,variables:{websiteId:
|
|
250
|
+
}`,variables:{websiteId:e.websiteId,filter:s,limit:i,page:r}});return{context:e,coupons:n.coupons.items??[],pagination:{totalCount:n.coupons.totalCount??0,totalPages:n.coupons.totalPages??0,hasNextPage:Boolean(n.coupons.hasNextPage),hasPreviousPage:Boolean(n.coupons.hasPreviousPage),page:r??1,limit:i??null}}}async function Do(o,t){let e=await f(o);await E(t,e.websiteId);let i=await c({service:"main",query:`query ($couponId: ID) {
|
|
234
251
|
coupon(couponId: $couponId) {
|
|
235
252
|
${D}
|
|
236
253
|
}
|
|
237
|
-
}`,variables:{couponId:
|
|
254
|
+
}`,variables:{couponId:t}});return{context:e,coupon:i.coupon}}async function ko(o,t){let e=await f(o),i=S(t,"input");if(i.websiteId&&i.websiteId!==e.websiteId)throw Error("El websiteId del input no coincide con el website seleccionado.");let r={...i,websiteId:e.websiteId},s=de(r),n=await c({service:"main",query:s,variables:r});return{context:e,coupon:n.createCoupon}}async function Ko(o,t,e){let i=await f(o);await E(t,i.websiteId);let r=S(e,"input"),s=await c({service:"main",query:`mutation ($couponId: ID, $coupon: UpdateCouponInput) {
|
|
238
255
|
updateCoupon(couponId: $couponId, coupon: $coupon) {
|
|
239
256
|
${D}
|
|
240
257
|
}
|
|
241
|
-
}`,variables:{couponId:
|
|
258
|
+
}`,variables:{couponId:t,coupon:r}});return{context:i,coupon:s.updateCoupon}}async function Vo(o,t){let e=await f(o);await E(t,e.websiteId);let i=await c({service:"main",query:`mutation ($couponsIds: [ID]) {
|
|
242
259
|
deleteCoupons(couponsIds: $couponsIds, globalCoupon: false)
|
|
243
|
-
}`,variables:{couponsIds:[
|
|
260
|
+
}`,variables:{couponsIds:[t]}});return{context:e,couponId:t,deleted:i.deleteCoupons}}function M(){return`team-cli admin coupons
|
|
244
261
|
|
|
245
262
|
Administracion de cupones para el website seleccionado.
|
|
246
263
|
|
|
@@ -288,7 +305,7 @@ Acciones:
|
|
|
288
305
|
Uso: team-cli admin <web> coupons codes delete <couponId> --ids '["id1","id2"]'
|
|
289
306
|
|
|
290
307
|
Nota:
|
|
291
|
-
El schema actual no expone update para coupon codes.`}function
|
|
308
|
+
El schema actual no expone update para coupon codes.`}function Lo(){return`team-cli admin coupons create
|
|
292
309
|
|
|
293
310
|
Crea un cupón para el website seleccionado.
|
|
294
311
|
|
|
@@ -337,7 +354,7 @@ Ejemplo con schedule:
|
|
|
337
354
|
Tips:
|
|
338
355
|
Usa comillas simples afuera del JSON en shell.
|
|
339
356
|
Usa arrays JSON reales para ids o listas.
|
|
340
|
-
Si necesitas el shape exacto de un cupón existente, parte con: team-cli admin <web> coupons show <couponId>`}function
|
|
357
|
+
Si necesitas el shape exacto de un cupón existente, parte con: team-cli admin <web> coupons show <couponId>`}function ot(){return`team-cli admin coupons update
|
|
341
358
|
|
|
342
359
|
Actualiza un cupón existente.
|
|
343
360
|
|
|
@@ -379,23 +396,23 @@ Ejemplo reemplazando restricciones:
|
|
|
379
396
|
team-cli admin <web> coupons update <couponId> --input '{"requiresStoresIds":["store1"],"requiresPaymentTypes":["card"]}'
|
|
380
397
|
|
|
381
398
|
Tip:
|
|
382
|
-
Primero mira el cupón actual con: team-cli admin <web> coupons show <couponId>`}function
|
|
399
|
+
Primero mira el cupón actual con: team-cli admin <web> coupons show <couponId>`}function le(o){if(!Array.isArray(o))throw Error("--input debe ser un arreglo JSON.");return o.map((t)=>{if(!t||typeof t!=="object"||typeof t.code!=="string")throw Error('Cada item de --input debe tener al menos { "code": "..." }.');if(t.userEmail!=null&&typeof t.userEmail!=="string")throw Error("userEmail debe ser string cuando viene informado.");return{code:t.code,userEmail:t.userEmail}})}function pe(o){if(!Array.isArray(o)||o.some((t)=>typeof t!=="string"))throw Error("--ids debe ser un arreglo JSON de strings.");return o}async function tt(o,t,e){let i=await f(o);await E(t,i.websiteId);let r=$(e,"limit"),s=$(e,"page"),n=e.filter,a=await c({service:"main",query:`query ($couponId: ID, $filter: String, $limit: BigInt, $page: BigInt) {
|
|
383
400
|
couponCodes(couponId: $couponId, filter: $filter, limit: $limit, page: $page) {
|
|
384
401
|
items {
|
|
385
|
-
${
|
|
402
|
+
${Fo}
|
|
386
403
|
}
|
|
387
404
|
totalCount
|
|
388
405
|
totalPages
|
|
389
406
|
hasNextPage
|
|
390
407
|
hasPreviousPage
|
|
391
408
|
}
|
|
392
|
-
}`,variables:{couponId:
|
|
409
|
+
}`,variables:{couponId:t,filter:n,limit:r,page:s}});return{context:i,couponId:t,codes:a.couponCodes.items??[],pagination:{totalCount:a.couponCodes.totalCount??0,totalPages:a.couponCodes.totalPages??0,hasNextPage:Boolean(a.couponCodes.hasNextPage),hasPreviousPage:Boolean(a.couponCodes.hasPreviousPage),page:s??1,limit:r??null}}}async function et(o,t,e){let i=await f(o);await E(t,i.websiteId);let r=le(S(e,"input")),s=r.some((a)=>a.userEmail),n=await c({service:"main",query:`mutation ($couponId: ID, $codesWithEmail: [CodeWithEmailInput], $useCodeWithEmail: Boolean) {
|
|
393
410
|
createCouponCodes(couponId: $couponId, codesWithEmail: $codesWithEmail, useCodeWithEmail: $useCodeWithEmail)
|
|
394
|
-
}`,variables:{couponId:
|
|
411
|
+
}`,variables:{couponId:t,codesWithEmail:r,useCodeWithEmail:s}});return{context:i,couponId:t,requestedCount:r.length,result:n.createCouponCodes}}async function it(o,t,e){let i=await f(o);await E(t,i.websiteId);let r=$(e,"quantity");if(!r)throw Error("--quantity es requerido.");let s=await c({service:"main",query:`mutation ($couponId: ID, $couponQuantity: Float, $couponCodePrefix: String) {
|
|
395
412
|
createRandomCouponCodes(couponId: $couponId, couponQuantity: $couponQuantity, couponCodePrefix: $couponCodePrefix)
|
|
396
|
-
}`,variables:{couponId:
|
|
413
|
+
}`,variables:{couponId:t,couponQuantity:r,couponCodePrefix:e.prefix}});return{context:i,couponId:t,quantity:r,prefix:e.prefix??null,result:s.createRandomCouponCodes}}async function rt(o,t,e){let i=await f(o);await E(t,i.websiteId);let r=pe(S(e,"ids")),s=await c({service:"main",query:`mutation ($couponId: ID, $couponCodesIds: [ID]) {
|
|
397
414
|
deleteCouponCodes(couponId: $couponId, couponCodesIds: $couponCodesIds, globalCoupon: false)
|
|
398
|
-
}`,variables:{couponId:
|
|
415
|
+
}`,variables:{couponId:t,couponCodesIds:r}});return{context:i,couponId:t,deleted:s.deleteCouponCodes,couponCodesIds:r}}function st(){return`team-cli admin coupons codes create
|
|
399
416
|
|
|
400
417
|
Crea códigos explícitos para un cupón.
|
|
401
418
|
|
|
@@ -418,7 +435,7 @@ Ejemplo:
|
|
|
418
435
|
|
|
419
436
|
Notas:
|
|
420
437
|
Si algún item trae userEmail, team-cli activa useCodeWithEmail automáticamente.
|
|
421
|
-
couponId se valida contra el website seleccionado antes de ejecutar la mutation.`}import{writeFileSync as
|
|
438
|
+
couponId se valida contra el website seleccionado antes de ejecutar la mutation.`}import{writeFileSync as we}from"node:fs";function k(){if(!d())throw Error("Debes iniciar sesión primero. Usa: team-cli auth login")}function K(o,t){let e=o[3];if(!e)throw Error(`Uso: ${t}`);return e}function nt(o){if(!o.params)return{};try{return JSON.parse(o.params)}catch{throw Error("--params debe ser un JSON válido.")}}function fe(o){if(typeof o!=="string")return o;try{return JSON.parse(o)}catch{return{value:o}}}async function at(o){k();let t=K(o,"team-cli data queries view <queryId>");return(await c({service:"data",query:`query ($aggregationQueryId: String) {
|
|
422
439
|
aggregationQuery(aggregationQueryId: $aggregationQueryId) {
|
|
423
440
|
_id
|
|
424
441
|
name
|
|
@@ -431,17 +448,17 @@ Notas:
|
|
|
431
448
|
fieldParams
|
|
432
449
|
}
|
|
433
450
|
}
|
|
434
|
-
}`,variables:{aggregationQueryId:
|
|
451
|
+
}`,variables:{aggregationQueryId:t}})).aggregationQuery}async function ct(o){k();let t=K(o,"team-cli data queries view-pipeline <queryId>"),e=await c({service:"data",query:`query ($aggregationQueryId: String) {
|
|
435
452
|
aggregationQuery(aggregationQueryId: $aggregationQueryId) {
|
|
436
453
|
pipeline
|
|
437
454
|
}
|
|
438
|
-
}`,variables:{aggregationQueryId:
|
|
455
|
+
}`,variables:{aggregationQueryId:t}});return{queryId:t,pipeline:e.aggregationQuery.pipeline}}async function mt(o,t){k();let e=K(o,"team-cli data queries preview <queryId> --params '<json>'"),i=nt(t),r=await c({service:"data",query:`mutation ($aggregationQueryId: String, $params: JSON) {
|
|
439
456
|
testAggregationQuery(aggregationQueryId: $aggregationQueryId, params: $params)
|
|
440
|
-
}`,variables:{aggregationQueryId:
|
|
457
|
+
}`,variables:{aggregationQueryId:e,params:i}});return fe(r.testAggregationQuery)}function be(o){return new Promise((t)=>setTimeout(t,o))}async function ut(o,t){k();let e=K(o,"team-cli data queries download <queryId> --params '<json>'"),i=nt(t);if(!t.path)throw Error("--path es requerido. Ejemplo: --path resultado.xlsx");let r=t.path;I(`Iniciando descarga...
|
|
441
458
|
`);let n=(await c({service:"data",query:`mutation ($aggregationQueryId: String, $params: JSON) {
|
|
442
459
|
downloadAggregationQueryData(aggregationQueryId: $aggregationQueryId, params: $params)
|
|
443
|
-
}`,variables:{aggregationQueryId:
|
|
444
|
-
`);let a=null;while(!a){await
|
|
460
|
+
}`,variables:{aggregationQueryId:e,params:i}})).downloadAggregationQueryData;I(`Reporte en proceso (${n})...
|
|
461
|
+
`);let a=null;while(!a){await be(1000);let b=await c({service:"data",query:`query ($id: String) {
|
|
445
462
|
getAsyncReport(id: $id) {
|
|
446
463
|
_id
|
|
447
464
|
status
|
|
@@ -449,9 +466,9 @@ Notas:
|
|
|
449
466
|
fileUrl
|
|
450
467
|
}
|
|
451
468
|
getAsyncReportRecordsCount(id: $id)
|
|
452
|
-
}`,variables:{id:n}}),q=b.getAsyncReport,
|
|
453
|
-
`)
|
|
454
|
-
`);let u=await fetch(a);if(!u.ok)throw Error(`Error descargando archivo: ${u.status}`);let
|
|
469
|
+
}`,variables:{id:n}}),q=b.getAsyncReport,j=b.getAsyncReportRecordsCount;if(q.status==="error")throw Error("El reporte falló al generarse.");if(q.fileUrl)a=q.fileUrl;else{let G=q.estimatedRecordsCount?` (~${q.estimatedRecordsCount} registros)`:"",x=j!=null?` ${j} procesados`:"";I(`\rGenerando...${G}${x}`)}}I(`
|
|
470
|
+
`),I(`Descargando archivo...
|
|
471
|
+
`);let u=await fetch(a);if(!u.ok)throw Error(`Error descargando archivo: ${u.status}`);let y=Buffer.from(await u.arrayBuffer());return we(r,y),{ok:!0,queryId:e,asyncReportId:n,outputPath:r,fileUrl:a}}function go(){return`team-cli data
|
|
455
472
|
|
|
456
473
|
Comandos de datos y reportes.
|
|
457
474
|
|
|
@@ -482,9 +499,9 @@ Ejemplos:
|
|
|
482
499
|
team-cli data queries view abc123
|
|
483
500
|
team-cli data queries view-pipeline abc123
|
|
484
501
|
team-cli data queries preview abc123 --params '{"startDate": "2026-01-01"}'
|
|
485
|
-
team-cli data queries download abc123 --params '{"startDate": "2026-01-01"}' --path resultado.xlsx`}var
|
|
502
|
+
team-cli data queries download abc123 --params '{"startDate": "2026-01-01"}' --path resultado.xlsx`}var qe=["local","develop","prod"];function gt(){return Object.keys(X)}function Ce(){return gt().map((o)=>{return[`- \`${o}\``,...qe.map((e)=>{let i=X[o][e];return` - ${e}: \`${i}/graphql\``})].join(`
|
|
486
503
|
`)}).join(`
|
|
487
|
-
`)}function
|
|
504
|
+
`)}function Ie(){let t=gt().join(", "),e=Ce();return`# @getjusto/team-cli
|
|
488
505
|
|
|
489
506
|
CLI tool for Justo team members. Authenticated access to Justo's GraphQL services and data queries.
|
|
490
507
|
|
|
@@ -513,7 +530,7 @@ npx @getjusto/team-cli auth login
|
|
|
513
530
|
npx @getjusto/team-cli graphql <service> '<query>' [--variables '<json>'] [--format toon|json]
|
|
514
531
|
\`\`\`
|
|
515
532
|
|
|
516
|
-
Available services: ${
|
|
533
|
+
Available services: ${t}.
|
|
517
534
|
|
|
518
535
|
Examples:
|
|
519
536
|
\`\`\`bash
|
|
@@ -522,6 +539,33 @@ npx @getjusto/team-cli graphql main 'query($id: ID) { user(userId: $id) { _id }
|
|
|
522
539
|
npx @getjusto/team-cli graphql tabs 'query { tab(tabId: "t123") { _id status } }' --format json
|
|
523
540
|
\`\`\`
|
|
524
541
|
|
|
542
|
+
### graphql info — Inspect query/mutation params and result metadata
|
|
543
|
+
|
|
544
|
+
Use this before writing the final GraphQL call when you only know the operation name, or when someone shares a curl and you need to understand the params expected by the resolver.
|
|
545
|
+
|
|
546
|
+
\`\`\`bash
|
|
547
|
+
npx @getjusto/team-cli graphql <service> info <queryName|mutationName> [--format toon|json]
|
|
548
|
+
\`\`\`
|
|
549
|
+
|
|
550
|
+
What it returns:
|
|
551
|
+
- \`operationType\` — whether Orion exposed it as query or mutation
|
|
552
|
+
- \`info.params\` — serialized params schema, including optional fields and GraphQL scalar types
|
|
553
|
+
- \`info.result\` — top-level result model/type name when available
|
|
554
|
+
- \`info.basicResultQuery\` — a starter field selection you can reuse in the final GraphQL document
|
|
555
|
+
|
|
556
|
+
Examples:
|
|
557
|
+
\`\`\`bash
|
|
558
|
+
npx @getjusto/team-cli graphql main info website
|
|
559
|
+
npx @getjusto/team-cli graphql auth info requestLoginCode --format json
|
|
560
|
+
\`\`\`
|
|
561
|
+
|
|
562
|
+
Recommended workflow for converting a curl into team-cli:
|
|
563
|
+
1. Identify the service from the GraphQL URL.
|
|
564
|
+
2. If you know the operation name, inspect it first with \`graphql <service> info <name>\`.
|
|
565
|
+
3. Use \`info.params\` to build the variables object.
|
|
566
|
+
4. Use \`info.basicResultQuery\` as the starting selection set.
|
|
567
|
+
5. Run the final command with \`graphql <service> '<queryOrMutation>' --variables '<json>'\`.
|
|
568
|
+
|
|
525
569
|
### GraphQL Service Map
|
|
526
570
|
|
|
527
571
|
Use this when someone shares a GraphQL \`curl\` and you need to map the URL to the correct \`team-cli graphql <service>\` value.
|
|
@@ -531,7 +575,7 @@ Rule:
|
|
|
531
575
|
- In \`team-cli\`, you pass the service name only, not the full URL.
|
|
532
576
|
|
|
533
577
|
Service name to endpoint map:
|
|
534
|
-
${
|
|
578
|
+
${e}
|
|
535
579
|
|
|
536
580
|
Example conversion:
|
|
537
581
|
\`\`\`bash
|
|
@@ -540,6 +584,9 @@ curl 'https://tabs.service.getjusto.com/graphql' \\
|
|
|
540
584
|
-H 'content-type: application/json' \\
|
|
541
585
|
--data-raw '{"query":"query { tab(tabId: \\"t123\\") { _id status } }"}'
|
|
542
586
|
|
|
587
|
+
# inspect the resolver first
|
|
588
|
+
npx @getjusto/team-cli graphql tabs info tab
|
|
589
|
+
|
|
543
590
|
# team-cli
|
|
544
591
|
npx @getjusto/team-cli graphql tabs 'query { tab(tabId: "t123") { _id status } }'
|
|
545
592
|
\`\`\`
|
|
@@ -621,7 +668,7 @@ Default output is TOON (Token-Oriented Object Notation), a compact human-readabl
|
|
|
621
668
|
1. View a query to understand its variables: \`data queries view <id>\`
|
|
622
669
|
2. Preview with params: \`data queries preview <id> --params '{"startDate": "2026-01-01"}'\`
|
|
623
670
|
3. Download full data: \`data queries download <id> --params '{"startDate": "2026-01-01"}' --path output.xlsx\`
|
|
624
|
-
`}function
|
|
671
|
+
`}function dt(){return{skill:Ie()}}var{positional:l,flags:m}=wo(process.argv.slice(2));if(m.env)lo(m.env);var Q=l[0],P=l[1];function lt(){let o=d();return`team-cli
|
|
625
672
|
|
|
626
673
|
Herramienta CLI para el equipo Justo.
|
|
627
674
|
|
|
@@ -650,4 +697,4 @@ Opciones globales:
|
|
|
650
697
|
--env <local|develop|prod>
|
|
651
698
|
--version
|
|
652
699
|
--help
|
|
653
|
-
--format <toon|json>`}async function
|
|
700
|
+
--format <toon|json>`}async function $e(){try{let o;if(m.version)o={version:"0.0.4"};else if(m.help&&!Q){g(lt());return}else if(Q==="auth")if(P==="--help"||m.help){g(co());return}else if(P==="login")o=await Wo();else if(P==="login-with-token")o=await Ao(m);else if(P==="request-code")o=await Oo(m);else if(P==="logout")o=await So();else if(P==="status")o=await Qo();else{g(co());return}else if(Q==="admin"){let t=l[1],e=l[2],i=l[3],r=l[4];if(!t||t==="--help"){g(H());return}else if(t==="search"&&m.help){g(Yo());return}else if(t==="search")o=await Xo(l,m);else if(!e||e==="--help"){g(H());return}else if(e==="show")o=await To(t);else if(e==="stores"&&i==="list")o=await Zo(t);else if(e==="coupons"&&(!i||i==="--help")){g(M());return}else if(e==="coupons"&&i==="create"&&m.help){g(Lo());return}else if(e==="coupons"&&i==="update"&&m.help){g(ot());return}else if(e==="coupons"&&i==="codes"&&l[4]==="create"&&m.help){g(st());return}else if(e==="coupons"&&m.help){g(M());return}else if(e==="coupons"&&i==="list")o=await Ho(t,m);else if(e==="coupons"&&i==="show"){if(!r)throw Error("Uso: team-cli admin <web> coupons show <couponId>");o=await Do(t,r)}else if(e==="coupons"&&i==="create")o=await ko(t,m);else if(e==="coupons"&&i==="update"){if(!r)throw Error("Uso: team-cli admin <web> coupons update <couponId> --input '<json>'");o=await Ko(t,r,m)}else if(e==="coupons"&&i==="delete"){if(!r)throw Error("Uso: team-cli admin <web> coupons delete <couponId>");o=await Vo(t,r)}else if(e==="coupons"&&i==="codes"){let s=l[4],n=l[5];if(!s||s==="--help"){g(M());return}else if(s==="list"){if(!n)throw Error("Uso: team-cli admin <web> coupons codes list <couponId>");o=await tt(t,n,m)}else if(s==="create"){if(!n)throw Error("Uso: team-cli admin <web> coupons codes create <couponId> --input '<json>'");o=await et(t,n,m)}else if(s==="create-random"){if(!n)throw Error("Uso: team-cli admin <web> coupons codes create-random <couponId> --quantity <n>");o=await it(t,n,m)}else if(s==="delete"){if(!n)throw Error(`Uso: team-cli admin <web> coupons codes delete <couponId> --ids '["id1"]'`);o=await rt(t,n,m)}else{g(M());return}}else{g(H());return}}else if(Q==="graphql")if(P==="--help"||m.help){g(Jo());return}else o=await Bo(l,m);else if(Q==="get-skill")o=dt();else if(Q==="data"){let t=l[1],e=l[2];if(m.help||P==="--help"){g(go());return}else if(t==="queries"&&e==="view")o=await at(l);else if(t==="queries"&&e==="view-pipeline")o=await ct(l);else if(t==="queries"&&e==="preview")o=await mt(l,m);else if(t==="queries"&&e==="download")o=await ut(l,m);else{g(go());return}}else{g(lt());return}if(o!==void 0)xo(o,m)}catch(o){Uo(o,m),process.exit(1)}}$e();
|