griddo-sdk 2.0.12 → 2.0.13
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/config/version.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "v2.0.
|
|
1
|
+
export declare const version = "v2.0.13";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ Mapping modules ${r} from ${i?.template||"all"} pages with callback function ${e
|
|
|
58
58
|
Mapping ${r||"all"} structured data with callback function ${e.name}...`),Pe.checkCallbackStructureData(e,"StructuredDataFacade.updateStructuredData");let n=await this._structuredData(r,i?.toString());if(!n?.length){this.loggingService.verbose("- No structured data found.");return}let o=n.map(a=>this.concurrencyLimiter.run(async()=>{let c=structuredClone(a),l=await e(c);l&&JSON.stringify(a)!==JSON.stringify(l)&&await this.save(l)}));await Promise.allSettled(o)}};var kA=class{constructor(e,r,i){if(!e||!r)throw new mi({context:"AuthService.constructor",error:Bi.REQUIRED_AUTHENTICATION_PROPERTIES.message,detail:Bi.REQUIRED_AUTHENTICATION_PROPERTIES});this.authService=e,this.configService=r,this.loggingService=i}async authenticate(){this.loggingService.verbose("Logging to API...");let e=await this.authService.authenticate();if(!e?.token)throw new mi({context:"AuthService.authenticate",error:e,detail:Bi.AUTHENTICATION_ERROR});return this.loggingService.verbose("Authenticated."),e}async connect(){let e=this.configService.getEnvironment(),{api:r,publicApi:i}=e,{token:n}=await this.authenticate(),o=r.endsWith("/")?r.slice(0,-1):r,a=i&&(i.endsWith("/")?i.slice(0,-1):i),c={...e,api:o,publicApi:a,token:n};this.configService.setEnvironment(c)}};var Rs=(i=>(i.FETCH="fetch",i.NODE_FETCH="node-fetch",i.UNDICI="undici",i))(Rs||{}),we=(o=>(o.GET="GET",o.POST="POST",o.PUT="PUT",o.DELETE="DELETE",o.PATCH="PATCH",o))(we||{}),ru=(o=>(o.ACTIVE="active",o.UPLOAD_PENDING="upload-pending",o.OFFLINE="offline",o.OFFLINE_PENDING="offline-pending",o.SCHEDULED="scheduled",o))(ru||{});var FA=class{constructor(e){this.client=e}async get(e,r){return this.handleRequest(()=>this.client.get(e,r),e,"GET")}async post(e,r,i){return this.handleRequest(()=>this.client.post(e,r,i),e,"POST")}async put(e,r,i){return this.handleRequest(()=>this.client.put(e,r,i),e,"PUT")}async delete(e,r){return this.handleRequest(()=>this.client.delete(e,r),e,"DELETE")}async request(e,r){return this.handleRequest(()=>this.client.request(e,r),e,r.method)}async handleRequest(e,r,i){try{return await e()}catch(n){throw new mi({context:`HttpClientErrorHandler.${i} - ${r}`,error:n,detail:Bi.ERROR_DURING_FETCH_HTTP_CLIENT_REQUEST})}}};var NA=class{constructor(e,r){this.client=e;this.loggingService=r}async request(e,r){this.loggingService.log(`[HttpClientLogger] Request: ${r.method} ${e}`,r);let i=Date.now(),n=await this.client.request(e,r),o=Date.now()-i;return this.loggingService.log(`[HttpClientLogger] Response (${o}ms):`,n),n}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}};var TA=class{constructor(e,r,i=3,n=500){this.client=e,this.loggingService=r,this.retries=i,this.delay=n}async wait(e){return new Promise(r=>setTimeout(r,e))}async executeWithRetry(e,r,i){let n=0,o;for(;n<this.retries;)try{return await e()}catch(a){o=a,n++;let c=this.delay*n;if(this.loggingService.logError(`[HttpClientRetry] Error in ${i} ${r}, attempt ${n}/${this.retries}. Retrying in ${c}ms`,a),n>=this.retries)throw this.loggingService.logError(`[HttpClientRetry] Final failure after ${n} attempts for ${i} ${r}`,a),a;await this.wait(c)}throw o??new Error("Unexpected retry failure")}async request(e,r){return this.executeWithRetry(()=>this.client.request(e,r),e,r.method)}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}};var UA=class{constructor(e,r=3e3){this.client=e;this.timeoutMs=r}async withTimeout(e){let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeoutMs);try{return await e}catch(n){throw n.name==="AbortError"?new Error(`Request aborted after ${this.timeoutMs}ms`):n}finally{clearTimeout(i)}}async request(e,r){let i=AbortSignal.timeout?.(this.timeoutMs),n={...r,signal:i??void 0};return this.withTimeout(this.client.request(e,n))}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}};var MA=class{constructor(){this.name="Fetch"}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}async request(e,r){return await(await fetch(e,{method:r.method,headers:r.headers,body:r.body})).json()}};var Zf=ht(require("node:http"),1),Kf=ht(require("node:https"),1),xi=ht(require("node:zlib"),1),it=ht(require("node:stream"),1),Ms=require("node:buffer");function _S(t){if(!/^data:/i.test(t))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');t=t.replace(/\r?\n/g,"");let e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");let r=t.substring(5,e).split(";"),i="",n=!1,o=r[0]||"text/plain",a=o;for(let g=1;g<r.length;g++)r[g]==="base64"?n=!0:r[g]&&(a+=`;${r[g]}`,r[g].indexOf("charset=")===0&&(i=r[g].substring(8)));!r[0]&&!i.length&&(a+=";charset=US-ASCII",i="US-ASCII");let c=n?"base64":"ascii",l=unescape(t.substring(e+1)),p=Buffer.from(l,c);return p.type=o,p.typeFull=a,p.charset=i,p}var mf=_S;var ft=ht(require("node:stream"),1),Br=require("node:util"),tt=require("node:buffer");Ds();PA();var mr=class extends Error{constructor(e,r){super(e),Error.captureStackTrace(this,this.constructor),this.type=r}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}};var Ve=class extends mr{constructor(e,r,i){super(e,r),i&&(this.code=this.errno=i.code,this.erroredSysCall=i.syscall)}};var YA=Symbol.toStringTag,Au=t=>typeof t=="object"&&typeof t.append=="function"&&typeof t.delete=="function"&&typeof t.get=="function"&&typeof t.getAll=="function"&&typeof t.has=="function"&&typeof t.set=="function"&&typeof t.sort=="function"&&t[YA]==="URLSearchParams",Fs=t=>t&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.constructor=="function"&&/^(Blob|File)$/.test(t[YA]),Sf=t=>typeof t=="object"&&(t[YA]==="AbortSignal"||t[YA]==="EventTarget"),Rf=(t,e)=>{let r=new URL(e).hostname,i=new URL(t).hostname;return r===i||r.endsWith(`.${i}`)},Df=(t,e)=>{let r=new URL(e).protocol,i=new URL(t).protocol;return r===i};var sR=(0,Br.promisify)(ft.default.pipeline),We=Symbol("Body internals"),Xt=class{constructor(e,{size:r=0}={}){let i=null;e===null?e=null:Au(e)?e=tt.Buffer.from(e.toString()):Fs(e)||tt.Buffer.isBuffer(e)||(Br.types.isAnyArrayBuffer(e)?e=tt.Buffer.from(e):ArrayBuffer.isView(e)?e=tt.Buffer.from(e.buffer,e.byteOffset,e.byteLength):e instanceof ft.default||(e instanceof yi?(e=vf(e),i=e.type.split("=")[1]):e=tt.Buffer.from(String(e))));let n=e;tt.Buffer.isBuffer(e)?n=ft.default.Readable.from(e):Fs(e)&&(n=ft.default.Readable.from(e.stream())),this[We]={body:e,stream:n,boundary:i,disturbed:!1,error:null},this.size=r,e instanceof ft.default&&e.on("error",o=>{let a=o instanceof mr?o:new Ve(`Invalid response body while trying to fetch ${this.url}: ${o.message}`,"system",o);this[We].error=a})}get body(){return this[We].stream}get bodyUsed(){return this[We].disturbed}async arrayBuffer(){let{buffer:e,byteOffset:r,byteLength:i}=await lu(this);return e.slice(r,r+i)}async formData(){let e=this.headers.get("content-type");if(e.startsWith("application/x-www-form-urlencoded")){let i=new yi,n=new URLSearchParams(await this.text());for(let[o,a]of n)i.append(o,a);return i}let{toFormData:r}=await Promise.resolve().then(()=>(Uf(),Tf));return r(this.body,e)}async blob(){let e=this.headers&&this.headers.get("content-type")||this[We].body&&this[We].body.type||"",r=await this.arrayBuffer();return new Qr([r],{type:e})}async json(){let e=await this.text();return JSON.parse(e)}async text(){let e=await lu(this);return new TextDecoder().decode(e)}buffer(){return lu(this)}};Xt.prototype.buffer=(0,Br.deprecate)(Xt.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(Xt.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:(0,Br.deprecate)(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});async function lu(t){if(t[We].disturbed)throw new TypeError(`body used already for: ${t.url}`);if(t[We].disturbed=!0,t[We].error)throw t[We].error;let{body:e}=t;if(e===null)return tt.Buffer.alloc(0);if(!(e instanceof ft.default))return tt.Buffer.alloc(0);let r=[],i=0;try{for await(let n of e){if(t.size>0&&i+n.length>t.size){let o=new Ve(`content size at ${t.url} over limit: ${t.size}`,"max-size");throw e.destroy(o),o}i+=n.length,r.push(n)}}catch(n){throw n instanceof mr?n:new Ve(`Invalid response body while trying to fetch ${t.url}: ${n.message}`,"system",n)}if(e.readableEnded===!0||e._readableState.ended===!0)try{return r.every(n=>typeof n=="string")?tt.Buffer.from(r.join("")):tt.Buffer.concat(r,i)}catch(n){throw new Ve(`Could not create Buffer from response body for ${t.url}: ${n.message}`,"system",n)}else throw new Ve(`Premature close of server response while trying to fetch ${t.url}`)}var hn=(t,e)=>{let r,i,{body:n}=t[We];if(t.bodyUsed)throw new Error("cannot clone body after it is used");return n instanceof ft.default&&typeof n.getBoundary!="function"&&(r=new ft.PassThrough({highWaterMark:e}),i=new ft.PassThrough({highWaterMark:e}),n.pipe(r),n.pipe(i),t[We].stream=r,n=i),n},oR=(0,Br.deprecate)(t=>t.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),qA=(t,e)=>t===null?null:typeof t=="string"?"text/plain;charset=UTF-8":Au(t)?"application/x-www-form-urlencoded;charset=UTF-8":Fs(t)?t.type||null:tt.Buffer.isBuffer(t)||Br.types.isAnyArrayBuffer(t)||ArrayBuffer.isView(t)?null:t instanceof yi?`multipart/form-data; boundary=${e[We].boundary}`:t&&typeof t.getBoundary=="function"?`multipart/form-data;boundary=${oR(t)}`:t instanceof ft.default?null:"text/plain;charset=UTF-8",Mf=t=>{let{body:e}=t[We];return e===null?0:Fs(e)?e.size:tt.Buffer.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null},Lf=async(t,{body:e})=>{e===null?t.end():await sR(e,t)};var uu=require("node:util"),Ts=ht(require("node:http"),1),_A=typeof Ts.default.validateHeaderName=="function"?Ts.default.validateHeaderName:t=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(t)){let e=new TypeError(`Header name must be a valid HTTP token [${t}]`);throw Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),e}},pu=typeof Ts.default.validateHeaderValue=="function"?Ts.default.validateHeaderValue:(t,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){let r=new TypeError(`Invalid character in header content ["${t}"]`);throw Object.defineProperty(r,"code",{value:"ERR_INVALID_CHAR"}),r}},rt=class t extends URLSearchParams{constructor(e){let r=[];if(e instanceof t){let i=e.raw();for(let[n,o]of Object.entries(i))r.push(...o.map(a=>[n,a]))}else if(e!=null)if(typeof e=="object"&&!uu.types.isBoxedPrimitive(e)){let i=e[Symbol.iterator];if(i==null)r.push(...Object.entries(e));else{if(typeof i!="function")throw new TypeError("Header pairs must be iterable");r=[...e].map(n=>{if(typeof n!="object"||uu.types.isBoxedPrimitive(n))throw new TypeError("Each header pair must be an iterable object");return[...n]}).map(n=>{if(n.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...n]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");return r=r.length>0?r.map(([i,n])=>(_A(i),pu(i,String(n)),[String(i).toLowerCase(),String(n)])):void 0,super(r),new Proxy(this,{get(i,n,o){switch(n){case"append":case"set":return(a,c)=>(_A(a),pu(a,String(c)),URLSearchParams.prototype[n].call(i,String(a).toLowerCase(),String(c)));case"delete":case"has":case"getAll":return a=>(_A(a),URLSearchParams.prototype[n].call(i,String(a).toLowerCase()));case"keys":return()=>(i.sort(),new Set(URLSearchParams.prototype.keys.call(i)).keys());default:return Reflect.get(i,n,o)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){let r=this.getAll(e);if(r.length===0)return null;let i=r.join(", ");return/^content-encoding$/i.test(e)&&(i=i.toLowerCase()),i}forEach(e,r=void 0){for(let i of this.keys())Reflect.apply(e,r,[this.get(i),i,this])}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,r)=>(e[r]=this.getAll(r),e),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,r)=>{let i=this.getAll(r);return r==="host"?e[r]=i[0]:e[r]=i.length>1?i:i[0],e},{})}};Object.defineProperties(rt.prototype,["get","entries","forEach","values"].reduce((t,e)=>(t[e]={enumerable:!0},t),{}));function Pf(t=[]){return new rt(t.reduce((e,r,i,n)=>(i%2===0&&e.push(n.slice(i,i+2)),e),[]).filter(([e,r])=>{try{return _A(e),pu(e,String(r)),!0}catch{return!1}}))}var AR=new Set([301,302,303,307,308]),VA=t=>AR.has(t);var Ut=Symbol("Response internals"),Et=class t extends Xt{constructor(e=null,r={}){super(e,r);let i=r.status!=null?r.status:200,n=new rt(r.headers);if(e!==null&&!n.has("Content-Type")){let o=qA(e,this);o&&n.append("Content-Type",o)}this[Ut]={type:"default",url:r.url,status:i,statusText:r.statusText||"",headers:n,counter:r.counter,highWaterMark:r.highWaterMark}}get type(){return this[Ut].type}get url(){return this[Ut].url||""}get status(){return this[Ut].status}get ok(){return this[Ut].status>=200&&this[Ut].status<300}get redirected(){return this[Ut].counter>0}get statusText(){return this[Ut].statusText}get headers(){return this[Ut].headers}get highWaterMark(){return this[Ut].highWaterMark}clone(){return new t(hn(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,r=302){if(!VA(r))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new t(null,{headers:{location:new URL(e).toString()},status:r})}static error(){let e=new t(null,{status:0,statusText:""});return e[Ut].type="error",e}static json(e=void 0,r={}){let i=JSON.stringify(e);if(i===void 0)throw new TypeError("data is not JSON serializable");let n=new rt(r&&r.headers);return n.has("content-type")||n.set("content-type","application/json"),new t(i,{...r,headers:n})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(Et.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});var Of=require("node:url"),zf=require("node:util");var Yf=t=>{if(t.search)return t.search;let e=t.href.length-1,r=t.hash||(t.href[e]==="#"?"#":"");return t.href[e-r.length]==="?"?"?":""};var Hf=require("node:net");function Gf(t,e=!1){return t==null||(t=new URL(t),/^(about|blob|data):$/.test(t.protocol))?"no-referrer":(t.username="",t.password="",t.hash="",e&&(t.pathname="",t.search=""),t)}var Jf=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]),qf="strict-origin-when-cross-origin";function _f(t){if(!Jf.has(t))throw new TypeError(`Invalid referrerPolicy: ${t}`);return t}function aR(t){if(/^(http|ws)s:$/.test(t.protocol))return!0;let e=t.host.replace(/(^\[)|(]$)/g,""),r=(0,Hf.isIP)(e);return r===4&&/^127\./.test(e)||r===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(e)?!0:t.host==="localhost"||t.host.endsWith(".localhost")?!1:t.protocol==="file:"}function fn(t){return/^about:(blank|srcdoc)$/.test(t)||t.protocol==="data:"||/^(blob|filesystem):$/.test(t.protocol)?!0:aR(t)}function Vf(t,{referrerURLCallback:e,referrerOriginCallback:r}={}){if(t.referrer==="no-referrer"||t.referrerPolicy==="")return null;let i=t.referrerPolicy;if(t.referrer==="about:client")return"no-referrer";let n=t.referrer,o=Gf(n),a=Gf(n,!0);o.toString().length>4096&&(o=a),e&&(o=e(o)),r&&(a=r(a));let c=new URL(t.url);switch(i){case"no-referrer":return"no-referrer";case"origin":return a;case"unsafe-url":return o;case"strict-origin":return fn(o)&&!fn(c)?"no-referrer":a.toString();case"strict-origin-when-cross-origin":return o.origin===c.origin?o:fn(o)&&!fn(c)?"no-referrer":a;case"same-origin":return o.origin===c.origin?o:"no-referrer";case"origin-when-cross-origin":return o.origin===c.origin?o:a;case"no-referrer-when-downgrade":return fn(o)&&!fn(c)?"no-referrer":o;default:throw new TypeError(`Invalid referrerPolicy: ${i}`)}}function Wf(t){let e=(t.get("referrer-policy")||"").split(/[,\s]+/),r="";for(let i of e)i&&Jf.has(i)&&(r=i);return r}var xe=Symbol("Request internals"),Us=t=>typeof t=="object"&&typeof t[xe]=="object",cR=(0,zf.deprecate)(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)"),wi=class t extends Xt{constructor(e,r={}){let i;if(Us(e)?i=new URL(e.url):(i=new URL(e),e={}),i.username!==""||i.password!=="")throw new TypeError(`${i} is an url with embedded credentials.`);let n=r.method||e.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(n)&&(n=n.toUpperCase()),!Us(r)&&"data"in r&&cR(),(r.body!=null||Us(e)&&e.body!==null)&&(n==="GET"||n==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let o=r.body?r.body:Us(e)&&e.body!==null?hn(e):null;super(o,{size:r.size||e.size||0});let a=new rt(r.headers||e.headers||{});if(o!==null&&!a.has("Content-Type")){let p=qA(o,this);p&&a.set("Content-Type",p)}let c=Us(e)?e.signal:null;if("signal"in r&&(c=r.signal),c!=null&&!Sf(c))throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");let l=r.referrer==null?e.referrer:r.referrer;if(l==="")l="no-referrer";else if(l){let p=new URL(l);l=/^about:(\/\/)?client$/.test(p)?"client":p}else l=void 0;this[xe]={method:n,redirect:r.redirect||e.redirect||"follow",headers:a,parsedURL:i,signal:c,referrer:l},this.follow=r.follow===void 0?e.follow===void 0?20:e.follow:r.follow,this.compress=r.compress===void 0?e.compress===void 0?!0:e.compress:r.compress,this.counter=r.counter||e.counter||0,this.agent=r.agent||e.agent,this.highWaterMark=r.highWaterMark||e.highWaterMark||16384,this.insecureHTTPParser=r.insecureHTTPParser||e.insecureHTTPParser||!1,this.referrerPolicy=r.referrerPolicy||e.referrerPolicy||""}get method(){return this[xe].method}get url(){return(0,Of.format)(this[xe].parsedURL)}get headers(){return this[xe].headers}get redirect(){return this[xe].redirect}get signal(){return this[xe].signal}get referrer(){if(this[xe].referrer==="no-referrer")return"";if(this[xe].referrer==="client")return"about:client";if(this[xe].referrer)return this[xe].referrer.toString()}get referrerPolicy(){return this[xe].referrerPolicy}set referrerPolicy(e){this[xe].referrerPolicy=_f(e)}clone(){return new t(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(wi.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});var jf=t=>{let{parsedURL:e}=t[xe],r=new rt(t[xe].headers);r.has("Accept")||r.set("Accept","*/*");let i=null;if(t.body===null&&/^(post|put)$/i.test(t.method)&&(i="0"),t.body!==null){let c=Mf(t);typeof c=="number"&&!Number.isNaN(c)&&(i=String(c))}i&&r.set("Content-Length",i),t.referrerPolicy===""&&(t.referrerPolicy=qf),t.referrer&&t.referrer!=="no-referrer"?t[xe].referrer=Vf(t):t[xe].referrer="no-referrer",t[xe].referrer instanceof URL&&r.set("Referer",t.referrer),r.has("User-Agent")||r.set("User-Agent","node-fetch"),t.compress&&!r.has("Accept-Encoding")&&r.set("Accept-Encoding","gzip, deflate, br");let{agent:n}=t;typeof n=="function"&&(n=n(e));let o=Yf(e),a={path:e.pathname+o,method:t.method,headers:r[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:t.insecureHTTPParser,agent:n};return{parsedURL:e,options:a}};var WA=class extends mr{constructor(e,r="aborted"){super(e,r)}};PA();au();var lR=new Set(["data:","http:","https:"]);async function OA(t,e){return new Promise((r,i)=>{let n=new wi(t,e),{parsedURL:o,options:a}=jf(n);if(!lR.has(o.protocol))throw new TypeError(`node-fetch cannot load ${t}. URL scheme "${o.protocol.replace(/:$/,"")}" is not supported.`);if(o.protocol==="data:"){let Q=mf(n.url),y=new Et(Q,{headers:{"Content-Type":Q.typeFull}});r(y);return}let c=(o.protocol==="https:"?Kf.default:Zf.default).request,{signal:l}=n,p=null,g=()=>{let Q=new WA("The operation was aborted.");i(Q),n.body&&n.body instanceof it.default.Readable&&n.body.destroy(Q),!(!p||!p.body)&&p.body.emit("error",Q)};if(l&&l.aborted){g();return}let h=()=>{g(),I()},f=c(o.toString(),a);l&&l.addEventListener("abort",h);let I=()=>{f.abort(),l&&l.removeEventListener("abort",h)};f.on("error",Q=>{i(new Ve(`request to ${n.url} failed, reason: ${Q.message}`,"system",Q)),I()}),uR(f,Q=>{p&&p.body&&p.body.destroy(Q)}),process.version<"v14"&&f.on("socket",Q=>{let y;Q.prependListener("end",()=>{y=Q._eventsCount}),Q.prependListener("close",w=>{if(p&&y<Q._eventsCount&&!w){let m=new Error("Premature close");m.code="ERR_STREAM_PREMATURE_CLOSE",p.body.emit("error",m)}})}),f.on("response",Q=>{f.setTimeout(0);let y=Pf(Q.rawHeaders);if(VA(Q.statusCode)){let R=y.get("Location"),F=null;try{F=R===null?null:new URL(R,n.url)}catch{if(n.redirect!=="manual"){i(new Ve(`uri requested responds with an invalid redirect URL: ${R}`,"invalid-redirect")),I();return}}switch(n.redirect){case"error":i(new Ve(`uri requested responds with a redirect, redirect mode is set to error: ${n.url}`,"no-redirect")),I();return;case"manual":break;case"follow":{if(F===null)break;if(n.counter>=n.follow){i(new Ve(`maximum redirect reached at: ${n.url}`,"max-redirect")),I();return}let q={headers:new rt(n.headers),follow:n.follow,counter:n.counter+1,agent:n.agent,compress:n.compress,method:n.method,body:hn(n),signal:n.signal,size:n.size,referrer:n.referrer,referrerPolicy:n.referrerPolicy};if(!Rf(n.url,F)||!Df(n.url,F))for(let He of["authorization","www-authenticate","cookie","cookie2"])q.headers.delete(He);if(Q.statusCode!==303&&n.body&&e.body instanceof it.default.Readable){i(new Ve("Cannot follow redirect with body being a readable stream","unsupported-redirect")),I();return}(Q.statusCode===303||(Q.statusCode===301||Q.statusCode===302)&&n.method==="POST")&&(q.method="GET",q.body=void 0,q.headers.delete("content-length"));let $=Wf(y);$&&(q.referrerPolicy=$),r(OA(new wi(F,q))),I();return}default:return i(new TypeError(`Redirect option '${n.redirect}' is not a valid value of RequestRedirect`))}}l&&Q.once("end",()=>{l.removeEventListener("abort",h)});let w=(0,it.pipeline)(Q,new it.PassThrough,R=>{R&&i(R)});process.version<"v12.10"&&Q.on("aborted",h);let m={url:n.url,status:Q.statusCode,statusText:Q.statusMessage,headers:y,size:n.size,counter:n.counter,highWaterMark:n.highWaterMark},x=y.get("Content-Encoding");if(!n.compress||n.method==="HEAD"||x===null||Q.statusCode===204||Q.statusCode===304){p=new Et(w,m),r(p);return}let k={flush:xi.default.Z_SYNC_FLUSH,finishFlush:xi.default.Z_SYNC_FLUSH};if(x==="gzip"||x==="x-gzip"){w=(0,it.pipeline)(w,xi.default.createGunzip(k),R=>{R&&i(R)}),p=new Et(w,m),r(p);return}if(x==="deflate"||x==="x-deflate"){let R=(0,it.pipeline)(Q,new it.PassThrough,F=>{F&&i(F)});R.once("data",F=>{(F[0]&15)===8?w=(0,it.pipeline)(w,xi.default.createInflate(),q=>{q&&i(q)}):w=(0,it.pipeline)(w,xi.default.createInflateRaw(),q=>{q&&i(q)}),p=new Et(w,m),r(p)}),R.once("end",()=>{p||(p=new Et(w,m),r(p))});return}if(x==="br"){w=(0,it.pipeline)(w,xi.default.createBrotliDecompress(),R=>{R&&i(R)}),p=new Et(w,m),r(p);return}p=new Et(w,m),r(p)}),Lf(f,n).catch(i)})}function uR(t,e){let r=Ms.Buffer.from(`0\r
|
|
59
59
|
\r
|
|
60
60
|
`),i=!1,n=!1,o;t.on("response",a=>{let{headers:c}=a;i=c["transfer-encoding"]==="chunked"&&!c["content-length"]}),t.on("socket",a=>{let c=()=>{if(i&&!n){let p=new Error("Premature close");p.code="ERR_STREAM_PREMATURE_CLOSE",e(p)}},l=p=>{n=Ms.Buffer.compare(p.slice(-5),r)===0,!n&&o&&(n=Ms.Buffer.compare(o.slice(-3),r.slice(0,3))===0&&Ms.Buffer.compare(p.slice(-2),r.slice(3))===0),o=p};a.prependListener("close",c),a.on("data",l),t.on("close",()=>{a.removeListener("close",c),a.removeListener("data",l)})})}var zA=class{constructor(){this.name="NodeFetch"}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}async request(e,r){return await(await OA(e,{method:r.method,headers:r.headers,body:r.body})).json()}};var Yb=require("stream"),Gb=require("url"),Hb=ht(Pb());var Vc=class{constructor(){this.name="Undici";this.agent=new Hb.Agent({connections:100,pipelining:1})}async get(e,r){return this.request(e,{...r,method:"GET"})}async post(e,r,i){return this.request(e,{...i,method:"POST",body:r})}async put(e,r,i){return this.request(e,{...i,method:"PUT",body:r})}async delete(e,r){return this.request(e,{...r,method:"DELETE"})}async request(e,r){let{method:i,headers:n,body:o}=r,a=new Gb.URL(e),c=a.origin,l=`${a.pathname}${a.search}`,p={origin:c,method:i,path:l,headers:n,body:o??void 0};o instanceof Yb.Readable&&(p.duplex="half");let{body:g}=await this.agent.request(p);return await g.json()}async closeAll(){await this.agent.close()}};var Wc=class{static create(e="fetch",r,i){let n=this.createBaseHttpClient(e);return n=this.applyTimeout(n,r),n=this.applyErrorHandler(n),n=this.applyLogging(n,r,i),n=this.applyRetry(n,r,i),n}static createBaseHttpClient(e){let r={"node-fetch":()=>new zA,fetch:()=>new MA,undici:()=>{let i=new Vc;return process.once("SIGINT",async()=>{await i.closeAll?.()}),i}};return(r[e]||r.fetch)()}static applyTimeout(e,r){return r?.timeoutMs?new UA(e,r.timeoutMs):e}static applyErrorHandler(e){return new FA(e)}static applyLogging(e,r,i){return i&&r?.httpLog?new NA(e,i):e}static applyRetry(e,r,i){if(r?.retries&&r.retries>0){let n=r.retryDelay||500;return new TA(e,i,r.retries,n)}return e}};var Yo=ht(require("node:fs")),Jb=ht(require("node:path"));var Oc=class{constructor(e,r){this.filePath=e,this.environment=r,this._verbose=this.environment?.verbose||!1,this.ensureDirectoryExists()}ensureDirectoryExists(){let e=Jb.default.dirname(this.filePath);Yo.default.existsSync(e)||Yo.default.mkdirSync(e,{recursive:!0})}formatLog(e,...r){let i=new Date().toISOString(),n=r.map(o=>typeof o=="object"?JSON.stringify(o,null,2):o).join(" ");return`${i} - ${e} ${n}
|
|
61
|
-
`}verbose(e,...r){this._verbose&&this.log(e,...r)}log(e,...r){try{let i=this.formatLog(e,...r);Yo.default.appendFileSync(this.filePath,i)}catch(i){throw new Ss({context:"FileLogger.log",error:i,detail:bA.INVALID_ARRAY_RESPONSE})}}logError(e,...r){try{let i=this.formatLog(`ERROR: ${e}`,...r);Yo.default.appendFileSync(this.filePath,i)}catch(i){throw new Ss({context:"FileLogger.logError",error:i,detail:bA.INVALID_ARRAY_RESPONSE})}}isVerbose(){return this._verbose}};var zc=class{constructor(e){this.environment=e,this._verbose=this.environment?.verbose||!1}log(e,...r){console.info(e,...r)}logError(e,...r){console.error(e,...r)}verbose(e,...r){this._verbose&&this.log(e,...r)}isVerbose(){return this._verbose}};var jc=class{static create(e){let r=this.determineType(e);return this.createInstance(r,e)}static determineType(e){return e.logFilePath?"file":"stdout"}static createInstance(e,r){return{file:()=>this.createFileLogger(r),stdout:()=>new zc(r)}[e]()}static createFileLogger(e){let r=e.logFilePath;if(!r)throw new Error("File path is required for FileLogger");return new Oc(r,e)}};var Zc=class{constructor(e){this.apiService=e}async send(e){return this.apiService.publicApi({method:"POST",endpoint:"/alert",body:e})}async paginate(e){let{page:r=1,items:i=10,level:n,area:o}=e,a=new URLSearchParams({page:r.toString(),items:i.toString(),...n?{level:n}:{},...o?{area:o}:{}}).toString();return this.apiService.api({method:"GET",endpoint:`/logs/alert?${a}`})}};var Go="v2.0.12";var Kc=class{constructor(e,r){this.HTTP_CLIENT="fetch";this.httpClient=e,this.configService=r,this.verbose=this.configService.getEnvironment().verbose||!1,this.HTTP_CLIENT=this.configService.getEnvironment().client||"fetch"}async apiCall({api:e,token:r,method:i,endpoint:n,body:o=void 0,headers:a={},isFormData:c=!1}){let l=`${e}${n?.startsWith("/")?"":"/"}${n}`;r&&(a.authorization=r);let p=this.configService.getEnvironment(),h={...{"X-Client-Name":p.clientName||"SDK","X-Client-Version":p.clientVersion||Go,"X-Application-Id":p.applicationId??"griddo-sdk","User-Agent":`griddo-sdk-${Go}`},...a};r&&(h.authorization=r);let f={method:i,headers:h,body:o};return!c&&o&&(f.body=JSON.stringify(o)),c&&o&&(f.body=o),o&&!["GET","DELETE"].includes(i)&&!c&&(h["Content-Type"]="application/json"),this.httpClient.request(l,f)}async api(e){let{api:r,token:i}=this.configService.getEnvironment(),{method:n,endpoint:o,body:a,headers:c,isFormData:l}=e;return this.apiCall({api:r,token:i,method:n,endpoint:o,body:a,headers:c||{},isFormData:l})}async publicApi(e){let{publicApi:r,token:i}=this.configService.getEnvironment(),{method:n,endpoint:o,body:a,headers:c}=e;return this.apiCall({api:r,token:i,method:n,endpoint:o,body:a,headers:c||{}})}};var Xc=class{constructor(e,r){if(!e?.user||!e?.password)throw new yA({context:"AuthService.constructor",error:"Missing required username or password properties into authUserParams",detail:tu.REQUIRED_AUTH_USER_PARAMS});this.authUserParams=e,this.apiService=r}async authenticate(){let{user:e,password:r}=this.authUserParams;return this.apiService.api({method:"POST",endpoint:"/login_check",body:{email:e,password:r}})}};var Ho=class{constructor(e){this.ensureValidApiUrl(e),this.applyDefaults(e),this.config=e}ensureValidApiUrl(e){!e?.api.includes("http://")&&!e?.api.includes("https://")&&(e.api=`https://${e?.api}`)}applyDefaults(e){e.clientName||(e.clientName="SDK"),e.clientVersion||(e.clientVersion=Go),e.applicationId||(e.applicationId="griddo-sdk")}getConfig(){return this.config}};var $c=class{constructor(e){if(!e||!e?.api)throw new vs({context:"ConfigService.constructor",error:cn.REQUIRED_ENVIRONMENT_PROPERTIES.message,detail:cn.REQUIRED_ENVIRONMENT_PROPERTIES});this.environment=new Ho(e)}getEnvironment(){return this.environment.getConfig()}setEnvironment(e){if(!e||!e?.token)throw new vs({context:"ConfigService.constructor",error:cn.REQUIRED_ENVIRONMENT_PROPERTIES.message,detail:cn.REQUIRED_ENVIRONMENT_PROPERTIES});this.environment=new Ho(e)}};var Wx=require("stream"),Zd=ht(Vx());var ll=class t{constructor(e){if(!e)throw new kt({context:"PageService.constructor",error:Ft.REQUIRED_API_SERVICE_PROPERTY.message,detail:Ft.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}static{this.MIME_EXTENSIONS={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg"}}ensureFileExtension(e,r){if(/\.\w+$/.test(e))return e;let n=t.MIME_EXTENSIONS[r]??"";return`${e}${n}`}detectMimeType(e){return e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e[0]===71&&e[1]===73&&e[2]===70?"image/gif":e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":e[0]===60&&e[1]===63&&e[2]===120?"image/svg+xml":"application/octet-stream"}async streamToBuffer(e){let r=[];for await(let i of e)r.push(Buffer.isBuffer(i)?i:Buffer.from(i));return Buffer.concat(r)}formDataToBuffer(e){return new Promise((r,i)=>{let n=[],o=new Wx.PassThrough;o.on("data",a=>n.push(a)),o.on("end",()=>r(Buffer.concat(n))),o.on("error",i),e.pipe(o)})}async processImageUpload(e,r,i,n){let o=await this.streamToBuffer(r),a=n??this.detectMimeType(o),c=new Zd.default;c.append("site",String(e)),c.append("file",o,{filename:this.ensureFileExtension(i,a),contentType:a});let l=c.getHeaders(),p=await this.formDataToBuffer(c);return this.apiService.api({method:"POST",endpoint:"/images",body:p,headers:l,isFormData:!0})}async processImageReplace(e="global",r,i,n){let o=await this.streamToBuffer(r),a=n??this.detectMimeType(o),c=new Zd.default;c.append("site",String(e)),c.append("file",o,{filename:this.ensureFileExtension(`image-${i}`,a),contentType:a});let l=c.getHeaders(),p=await this.formDataToBuffer(c);return this.apiService.api({method:"PUT",endpoint:`/image/${i}/replace`,body:p,headers:l,isFormData:!0})}async paginate({queryParams:e,site:r,language:i}){let n=new URLSearchParams(e).toString(),o={};i&&(o.lang=i);let a=`${r?`/site/${r}`:""}/images/?${n}`;return this.apiService.api({method:"GET",endpoint:a,headers:o})}async byID(e,r){let i=new URLSearchParams(r).toString(),n={},o=`/image/${e}${i?`/?${i}`:""}`;return this.apiService.api({method:"GET",endpoint:o,headers:n})}async add({image:e,imageName:r,site:i,mimetype:n}){return this.processImageUpload(i,e,r,n)}async updateData({id:e,params:r}){let i={},n=`/image/${e}`;return this.apiService.api({method:"PUT",endpoint:n,headers:i,body:r})}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/image/${e}`})}async replace({id:e,image:r,site:i,mimetype:n}){return this.processImageReplace(i,r,e,n)}};var ul=class{constructor(e){if(!e)throw new ln({context:"LanguageService.constructor",error:un.REQUIRED_API_SERVICE_PROPERTY.message,detail:un.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}async fetchLanguages(){return this.apiService.api({method:"GET",endpoint:"/languages"})}};var pl=class{constructor(e){if(!e)throw new pn({context:"LiveStatusService.constructor",error:gn.REQUIRED_API_SERVICE_PROPERTY.message,detail:gn.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}async fetchLiveStatus(){return this.apiService.api({method:"GET",endpoint:"/live-status"})}};var gl=class{constructor(e){this.logger=e}log(e,...r){this.logger.log(e,...r)}logError(e,...r){this.logger.logError(e,...r)}verbose(e,...r){this.logger.verbose(e,...r)}isVerbose(){return this.logger.isVerbose()}};var dl=class{constructor(e){this.actions={new:{method:"POST",endpoint:"/page/",actionName:"created"},update:{method:"PUT",endpoint:"/page/",actionName:"updated"}};if(!e)throw new Nt({context:"PageService.constructor",error:qe.REQUIRED_API_SERVICE_PROPERTY.message,detail:qe.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}resolveSaveAction(e){let r=e?.id?"update":"new",i=structuredClone(this.actions[r]);return e?.id&&(i.endpoint+=e.id),i}async listIDs(e=null){return this.apiService.api({method:"GET",endpoint:`/pages/all/id/${e?`?template=${e}`:""}`})}async paginate({queryParams:e,site:r,language:i}){let n=new URLSearchParams(e).toString(),o={};i&&(o.lang=i);let a=`${r?`/site/${r}`:""}/pages/?${n}`;return this.apiService.api({method:"GET",endpoint:a,headers:o})}async byID(e){return this.apiService.api({method:"GET",endpoint:`/page/${e}`})}async save(e){let{method:r,endpoint:i}=this.resolveSaveAction(e);return this.apiService.api({method:r,endpoint:i,body:e,headers:{"Content-Type":"application/json"}})}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/page/${e}`})}async restore(e){return this.apiService.api({method:"DELETE",endpoint:`/page/${e}/undo`})}};var hl=class{constructor(e){this.actions={new:{method:"POST",endpoint:"/structured_data_content/",actionName:"created"},update:{method:"PUT",endpoint:"/structured_data_content/",actionName:"updated"}};if(!e)throw new _e({context:"StructuredDataService.constructor",error:Tt.REQUIRED_API_SERVICE_PROPERTY.message,detail:Tt.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}getSaveAction(e){let r=e?.id?"update":"new",i=structuredClone(this.actions[r]);return e?.id&&(i.endpoint+=e.id),i}async structuredData(e,r=null,i=null,n={page:0,itemsPerPage:0,pagination:!1,deleted:!1,includeDraft:!0,relatedFields:!1,query:null,related:null}){let o={};i&&(o.lang=i),n.pagination||(delete n.page,delete n.itemsPerPage,delete n.deleted),!n.pagination&&!n.related&&delete n.relatedFields,n.query||delete n.query;let a=new URLSearchParams(n).toString(),c=`${r?`/site/${r}`:""}/structured_data_contents/${e||""}?${a}`,l=await this.apiService.api({method:"GET",endpoint:c,headers:o});return n.pagination?l:l.items}async byID(e,r){let i=`/structured_data_content/${e}${r?`?relatedFields=${r}`:""}`;return this.apiService.api({method:"GET",endpoint:i})}async save(e){let{method:r,endpoint:i}=this.getSaveAction(e),n=await this.apiService.api({method:r,endpoint:i,body:e});if(!n.id||!n.content)throw new _e({context:"StructuredDataService.saveStructuredData",error:n,detail:Tt.REQUIRED_STRUCTURE_DATA_PROPERTIES});return n}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/structured_data_content/${e}`})}};var fl=class{constructor(e,r){this.loggingService=this.initializeLogger(e),this.httpClient=Wc.create(e.client,e,this.loggingService),this.createConfigService(e),this.createAuthService(r)}initializeLogger(e){let r=jc.create(e);return new gl(r)}createApiService(){return this.apiServiceInstance||(this.apiServiceInstance=new Kc(this.httpClient,this.configService)),this.apiServiceInstance}createAlertService(){return this.alertServiceInstance||(this.alertServiceInstance=new Zc(this.createApiService())),this.alertServiceInstance}createLanguageService(){return this.languageServiceInstance||(this.languageServiceInstance=new ul(this.createApiService())),this.languageServiceInstance}createPageService(){return this.pageServiceInstance||(this.pageServiceInstance=new dl(this.createApiService())),this.pageServiceInstance}createStructuredDataService(){return this.structuredDataServiceInstance||(this.structuredDataServiceInstance=new hl(this.createApiService())),this.structuredDataServiceInstance}createLiveStatusService(){return this.liveStatusServiceInstance||(this.liveStatusServiceInstance=new pl(this.createApiService())),this.liveStatusServiceInstance}createConfigService(e){return this.configService||(this.configService=new $c(e)),this.configService}createAuthService(e){return this.authService||(this.authService=new Xc(e,this.createApiService())),this.authService}createImageService(){return this.imageService||(this.imageService=new ll(this.createApiService())),this.imageService}createAuthFacade(){return new kA(this.authService,this.configService,this.loggingService)}};var Kd=class{value;next;constructor(e){this.value=e}},Wo=class{#e;#t;#i;constructor(){this.clear()}enqueue(e){let r=new Kd(e);this.#e?(this.#t.next=r,this.#t=r):(this.#e=r,this.#t=r),this.#i++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#i--,e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#i=0}get size(){return this.#i}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){let e;for(;(e=this.dequeue())!==void 0;)yield e}};function Xd(t){Ox(t);let e=new Wo,r=0,i=()=>{r<t&&e.size>0&&(e.dequeue()(),r++)},n=()=>{r--,i()},o=async(l,p,g)=>{let h=(async()=>l(...g))();p(h);try{await h}catch{}n()},a=(l,p,g)=>{new Promise(h=>{e.enqueue(h)}).then(o.bind(void 0,l,p,g)),(async()=>(await Promise.resolve(),r<t&&i()))()},c=(l,...p)=>new Promise(g=>{a(l,g,p)});return Object.defineProperties(c,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value(){e.clear()}},concurrency:{get:()=>t,set(l){Ox(l),t=l,queueMicrotask(()=>{for(;r<t&&e.size>0;)i()})}}}),c}function Ox(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}var El=class{constructor(e){this.limiter=Xd(e)}run(e){return this.limiter(e)}};var Ql=class{constructor(e,r){this.isConnected=!1;this.createConcurrencyLimiter=e=>new El(e?.concurrency&&e?.concurrency>0?e.concurrency:10);this.pages=async()=>(await this.connect(),this._pageFacade||(this._pageFacade=new RA(this.serviceFactory.createPageService(),this.serviceFactory.loggingService,this.concurrencyLimiter)),this._pageFacade);this.alerts=async()=>(await this.connect(),this._alert||(this._alert=new wA(this.serviceFactory.createAlertService(),this.serviceFactory.loggingService)),this._alert);this.languages=async()=>(await this.connect(),this._languages||(this._languages=new vA(this.serviceFactory.createLanguageService(),this.serviceFactory.loggingService)),this._languages);this.liveStatus=async()=>(await this.connect(),this._liveStatus||(this._liveStatus=new SA(this.serviceFactory.createLiveStatusService(),this.serviceFactory.loggingService)),this._liveStatus);this.structuredData=async()=>(await this.connect(),this._structuredData||(this._structuredData=new DA(this.serviceFactory.createStructuredDataService(),this.serviceFactory.loggingService,this.concurrencyLimiter)),this._structuredData);this.images=async()=>(await this.connect(),this._image||(this._image=new xA(this.serviceFactory.createImageService(),this.serviceFactory.loggingService)),this._image);this.api=async e=>(await this.connect(),await this.serviceFactory.createApiService().api(e));this.serviceFactory=new fl(e,r),this.concurrencyLimiter=this.createConcurrencyLimiter(e)}async connect(){this.isConnected||(await this.serviceFactory.createAuthFacade().connect(),this.isConnected=!0)}},lJ=Ql;0&&(module.exports={HttpClients,HttpMethod,LiveStatusList,SDK});
|
|
61
|
+
`}verbose(e,...r){this._verbose&&this.log(e,...r)}log(e,...r){try{let i=this.formatLog(e,...r);Yo.default.appendFileSync(this.filePath,i)}catch(i){throw new Ss({context:"FileLogger.log",error:i,detail:bA.INVALID_ARRAY_RESPONSE})}}logError(e,...r){try{let i=this.formatLog(`ERROR: ${e}`,...r);Yo.default.appendFileSync(this.filePath,i)}catch(i){throw new Ss({context:"FileLogger.logError",error:i,detail:bA.INVALID_ARRAY_RESPONSE})}}isVerbose(){return this._verbose}};var zc=class{constructor(e){this.environment=e,this._verbose=this.environment?.verbose||!1}log(e,...r){console.info(e,...r)}logError(e,...r){console.error(e,...r)}verbose(e,...r){this._verbose&&this.log(e,...r)}isVerbose(){return this._verbose}};var jc=class{static create(e){let r=this.determineType(e);return this.createInstance(r,e)}static determineType(e){return e.logFilePath?"file":"stdout"}static createInstance(e,r){return{file:()=>this.createFileLogger(r),stdout:()=>new zc(r)}[e]()}static createFileLogger(e){let r=e.logFilePath;if(!r)throw new Error("File path is required for FileLogger");return new Oc(r,e)}};var Zc=class{constructor(e){this.apiService=e}async send(e){return this.apiService.publicApi({method:"POST",endpoint:"/alert",body:e})}async paginate(e){let{page:r=1,items:i=10,level:n,area:o}=e,a=new URLSearchParams({page:r.toString(),items:i.toString(),...n?{level:n}:{},...o?{area:o}:{}}).toString();return this.apiService.api({method:"GET",endpoint:`/logs/alert?${a}`})}};var Go="v2.0.13";var Kc=class{constructor(e,r){this.HTTP_CLIENT="fetch";this.httpClient=e,this.configService=r,this.verbose=this.configService.getEnvironment().verbose||!1,this.HTTP_CLIENT=this.configService.getEnvironment().client||"fetch"}async apiCall({api:e,token:r,method:i,endpoint:n,body:o=void 0,headers:a={},isFormData:c=!1}){let l=`${e}${n?.startsWith("/")?"":"/"}${n}`;r&&(a.authorization=r);let p=this.configService.getEnvironment(),h={...{"X-Client-Name":p.clientName||"SDK","X-Client-Version":p.clientVersion||Go,"X-Application-Id":p.applicationId??"griddo-sdk","User-Agent":`griddo-sdk-${Go}`},...a};r&&(h.authorization=r);let f={method:i,headers:h,body:o};return!c&&o&&(f.body=JSON.stringify(o)),c&&o&&(f.body=o),o&&!["GET","DELETE"].includes(i)&&!c&&(h["Content-Type"]="application/json"),this.httpClient.request(l,f)}async api(e){let{api:r,token:i}=this.configService.getEnvironment(),{method:n,endpoint:o,body:a,headers:c,isFormData:l}=e;return this.apiCall({api:r,token:i,method:n,endpoint:o,body:a,headers:c||{},isFormData:l})}async publicApi(e){let{publicApi:r,token:i}=this.configService.getEnvironment(),{method:n,endpoint:o,body:a,headers:c}=e;return this.apiCall({api:r,token:i,method:n,endpoint:o,body:a,headers:c||{}})}};var Xc=class{constructor(e,r){if(!e?.user||!e?.password)throw new yA({context:"AuthService.constructor",error:"Missing required username or password properties into authUserParams",detail:tu.REQUIRED_AUTH_USER_PARAMS});this.authUserParams=e,this.apiService=r}async authenticate(){let{user:e,password:r}=this.authUserParams;return this.apiService.api({method:"POST",endpoint:"/login_check",body:{email:e,password:r}})}};var Ho=class{constructor(e){this.ensureValidApiUrl(e),this.applyDefaults(e),this.config=e}ensureValidApiUrl(e){!e?.api.includes("http://")&&!e?.api.includes("https://")&&(e.api=`https://${e?.api}`)}applyDefaults(e){e.clientName||(e.clientName="SDK"),e.clientVersion||(e.clientVersion=Go),e.applicationId||(e.applicationId="griddo-sdk")}getConfig(){return this.config}};var $c=class{constructor(e){if(!e||!e?.api)throw new vs({context:"ConfigService.constructor",error:cn.REQUIRED_ENVIRONMENT_PROPERTIES.message,detail:cn.REQUIRED_ENVIRONMENT_PROPERTIES});this.environment=new Ho(e)}getEnvironment(){return this.environment.getConfig()}setEnvironment(e){if(!e||!e?.token)throw new vs({context:"ConfigService.constructor",error:cn.REQUIRED_ENVIRONMENT_PROPERTIES.message,detail:cn.REQUIRED_ENVIRONMENT_PROPERTIES});this.environment=new Ho(e)}};var Wx=require("stream"),Zd=ht(Vx());var ll=class t{constructor(e){if(!e)throw new kt({context:"PageService.constructor",error:Ft.REQUIRED_API_SERVICE_PROPERTY.message,detail:Ft.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}static{this.MIME_EXTENSIONS={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg"}}ensureFileExtension(e,r){if(/\.\w+$/.test(e))return e;let n=t.MIME_EXTENSIONS[r]??"";return`${e}${n}`}detectMimeType(e){return e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e[0]===71&&e[1]===73&&e[2]===70?"image/gif":e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":e[0]===60&&e[1]===63&&e[2]===120?"image/svg+xml":"application/octet-stream"}async streamToBuffer(e){let r=[];for await(let i of e)r.push(Buffer.isBuffer(i)?i:Buffer.from(i));return Buffer.concat(r)}formDataToBuffer(e){return new Promise((r,i)=>{let n=[],o=new Wx.PassThrough;o.on("data",a=>n.push(a)),o.on("end",()=>r(Buffer.concat(n))),o.on("error",i),e.pipe(o)})}async processImageUpload(e,r,i,n){let o=await this.streamToBuffer(r),a=n??this.detectMimeType(o),c=new Zd.default;c.append("site",String(e)),c.append("file",o,{filename:this.ensureFileExtension(i,a),contentType:a});let l=c.getHeaders(),p=await this.formDataToBuffer(c);return this.apiService.api({method:"POST",endpoint:"/images",body:p,headers:l,isFormData:!0})}async processImageReplace(e="global",r,i,n){let o=await this.streamToBuffer(r),a=n??this.detectMimeType(o),c=new Zd.default;c.append("site",String(e)),c.append("file",o,{filename:this.ensureFileExtension(`image-${i}`,a),contentType:a});let l=c.getHeaders(),p=await this.formDataToBuffer(c);return this.apiService.api({method:"PUT",endpoint:`/image/${i}/replace`,body:p,headers:l,isFormData:!0})}async paginate({queryParams:e,site:r,language:i}){let n=new URLSearchParams(e).toString(),o={};i&&(o.lang=i);let a=`${r?`/site/${r}`:""}/images/?${n}`;return this.apiService.api({method:"GET",endpoint:a,headers:o})}async byID(e,r){let i=new URLSearchParams(r).toString(),n={},o=`/image/${e}${i?`/?${i}`:""}`;return this.apiService.api({method:"GET",endpoint:o,headers:n})}async add({image:e,imageName:r,site:i,mimetype:n}){return this.processImageUpload(i,e,r,n)}async updateData({id:e,params:r}){let i={},n=`/image/${e}`;return this.apiService.api({method:"PUT",endpoint:n,headers:i,body:r})}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/image/${e}`})}async replace({id:e,image:r,site:i,mimetype:n}){return this.processImageReplace(i,r,e,n)}};var ul=class{constructor(e){if(!e)throw new ln({context:"LanguageService.constructor",error:un.REQUIRED_API_SERVICE_PROPERTY.message,detail:un.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}async fetchLanguages(){return this.apiService.api({method:"GET",endpoint:"/languages"})}};var pl=class{constructor(e){if(!e)throw new pn({context:"LiveStatusService.constructor",error:gn.REQUIRED_API_SERVICE_PROPERTY.message,detail:gn.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}async fetchLiveStatus(){return this.apiService.api({method:"GET",endpoint:"/live-status"})}};var gl=class{constructor(e){this.logger=e}log(e,...r){this.logger.log(e,...r)}logError(e,...r){this.logger.logError(e,...r)}verbose(e,...r){this.logger.verbose(e,...r)}isVerbose(){return this.logger.isVerbose()}};var dl=class{constructor(e){this.actions={new:{method:"POST",endpoint:"/page/",actionName:"created"},update:{method:"PUT",endpoint:"/page/",actionName:"updated"}};if(!e)throw new Nt({context:"PageService.constructor",error:qe.REQUIRED_API_SERVICE_PROPERTY.message,detail:qe.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}resolveSaveAction(e){let r=e?.id?"update":"new",i=structuredClone(this.actions[r]);return e?.id&&(i.endpoint+=e.id),i}async listIDs(e=null){return this.apiService.api({method:"GET",endpoint:`/pages/all/id/${e?`?template=${e}`:""}`})}async paginate({queryParams:e,site:r,language:i}){let n=new URLSearchParams(e).toString(),o={};i&&(o.lang=i);let a=`${r?`/site/${r}`:""}/pages/?${n}`;return this.apiService.api({method:"GET",endpoint:a,headers:o})}async byID(e){return this.apiService.api({method:"GET",endpoint:`/page/${e}`})}async save(e){let{method:r,endpoint:i}=this.resolveSaveAction(e);return this.apiService.api({method:r,endpoint:i,body:e,headers:{"Content-Type":"application/json"}})}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/page/${e}`})}async restore(e){return this.apiService.api({method:"DELETE",endpoint:`/page/${e}/undo`})}};var hl=class{constructor(e){this.actions={new:{method:"POST",endpoint:"/structured_data_content/",actionName:"created"},update:{method:"PUT",endpoint:"/structured_data_content/",actionName:"updated"}};if(!e)throw new _e({context:"StructuredDataService.constructor",error:Tt.REQUIRED_API_SERVICE_PROPERTY.message,detail:Tt.REQUIRED_API_SERVICE_PROPERTY});this.apiService=e}getSaveAction(e){let r=e?.id?"update":"new",i=structuredClone(this.actions[r]);return e?.id&&(i.endpoint+=e.id),i}async structuredData(e,r=null,i=null,n={page:0,itemsPerPage:0,pagination:!1,deleted:!1,includeDraft:!0,relatedFields:!1,query:null,related:null}){let o={};i&&(o.lang=i),n.pagination||(delete n.page,delete n.itemsPerPage,delete n.deleted),!n.pagination&&!n.related&&delete n.relatedFields,n.query||delete n.query;let a=new URLSearchParams(n).toString(),c=`${r?`/site/${r}`:""}/structured_data_contents/${e||""}?${a}`,l=await this.apiService.api({method:"GET",endpoint:c,headers:o});return n.pagination?l:l.items}async byID(e,r){let i=`/structured_data_content/${e}${r?`?relatedFields=${r}`:""}`;return this.apiService.api({method:"GET",endpoint:i})}async save(e){let{method:r,endpoint:i}=this.getSaveAction(e),n=await this.apiService.api({method:r,endpoint:i,body:e});if(!n.id||!n.content)throw new _e({context:"StructuredDataService.saveStructuredData",error:n,detail:Tt.REQUIRED_STRUCTURE_DATA_PROPERTIES});return n}async delete(e){return this.apiService.api({method:"DELETE",endpoint:`/structured_data_content/${e}`})}};var fl=class{constructor(e,r){this.loggingService=this.initializeLogger(e),this.httpClient=Wc.create(e.client,e,this.loggingService),this.createConfigService(e),this.createAuthService(r)}initializeLogger(e){let r=jc.create(e);return new gl(r)}createApiService(){return this.apiServiceInstance||(this.apiServiceInstance=new Kc(this.httpClient,this.configService)),this.apiServiceInstance}createAlertService(){return this.alertServiceInstance||(this.alertServiceInstance=new Zc(this.createApiService())),this.alertServiceInstance}createLanguageService(){return this.languageServiceInstance||(this.languageServiceInstance=new ul(this.createApiService())),this.languageServiceInstance}createPageService(){return this.pageServiceInstance||(this.pageServiceInstance=new dl(this.createApiService())),this.pageServiceInstance}createStructuredDataService(){return this.structuredDataServiceInstance||(this.structuredDataServiceInstance=new hl(this.createApiService())),this.structuredDataServiceInstance}createLiveStatusService(){return this.liveStatusServiceInstance||(this.liveStatusServiceInstance=new pl(this.createApiService())),this.liveStatusServiceInstance}createConfigService(e){return this.configService||(this.configService=new $c(e)),this.configService}createAuthService(e){return this.authService||(this.authService=new Xc(e,this.createApiService())),this.authService}createImageService(){return this.imageService||(this.imageService=new ll(this.createApiService())),this.imageService}createAuthFacade(){return new kA(this.authService,this.configService,this.loggingService)}};var Kd=class{value;next;constructor(e){this.value=e}},Wo=class{#e;#t;#i;constructor(){this.clear()}enqueue(e){let r=new Kd(e);this.#e?(this.#t.next=r,this.#t=r):(this.#e=r,this.#t=r),this.#i++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#i--,e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#i=0}get size(){return this.#i}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){let e;for(;(e=this.dequeue())!==void 0;)yield e}};function Xd(t){Ox(t);let e=new Wo,r=0,i=()=>{r<t&&e.size>0&&(e.dequeue()(),r++)},n=()=>{r--,i()},o=async(l,p,g)=>{let h=(async()=>l(...g))();p(h);try{await h}catch{}n()},a=(l,p,g)=>{new Promise(h=>{e.enqueue(h)}).then(o.bind(void 0,l,p,g)),(async()=>(await Promise.resolve(),r<t&&i()))()},c=(l,...p)=>new Promise(g=>{a(l,g,p)});return Object.defineProperties(c,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value(){e.clear()}},concurrency:{get:()=>t,set(l){Ox(l),t=l,queueMicrotask(()=>{for(;r<t&&e.size>0;)i()})}}}),c}function Ox(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}var El=class{constructor(e){this.limiter=Xd(e)}run(e){return this.limiter(e)}};var Ql=class{constructor(e,r){this.isConnected=!1;this.createConcurrencyLimiter=e=>new El(e?.concurrency&&e?.concurrency>0?e.concurrency:10);this.pages=async()=>(await this.connect(),this._pageFacade||(this._pageFacade=new RA(this.serviceFactory.createPageService(),this.serviceFactory.loggingService,this.concurrencyLimiter)),this._pageFacade);this.alerts=async()=>(await this.connect(),this._alert||(this._alert=new wA(this.serviceFactory.createAlertService(),this.serviceFactory.loggingService)),this._alert);this.languages=async()=>(await this.connect(),this._languages||(this._languages=new vA(this.serviceFactory.createLanguageService(),this.serviceFactory.loggingService)),this._languages);this.liveStatus=async()=>(await this.connect(),this._liveStatus||(this._liveStatus=new SA(this.serviceFactory.createLiveStatusService(),this.serviceFactory.loggingService)),this._liveStatus);this.structuredData=async()=>(await this.connect(),this._structuredData||(this._structuredData=new DA(this.serviceFactory.createStructuredDataService(),this.serviceFactory.loggingService,this.concurrencyLimiter)),this._structuredData);this.images=async()=>(await this.connect(),this._image||(this._image=new xA(this.serviceFactory.createImageService(),this.serviceFactory.loggingService)),this._image);this.api=async e=>(await this.connect(),await this.serviceFactory.createApiService().api(e));this.serviceFactory=new fl(e,r),this.concurrencyLimiter=this.createConcurrencyLimiter(e)}async connect(){this.isConnected||(await this.serviceFactory.createAuthFacade().connect(),this.isConnected=!0)}},lJ=Ql;0&&(module.exports={HttpClients,HttpMethod,LiveStatusList,SDK});
|
|
62
62
|
/*! Bundled license information:
|
|
63
63
|
|
|
64
64
|
web-streams-polyfill/dist/ponyfill.es2018.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "griddo-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"descripcion": "Griddo SDK es una biblioteca que facilita la integración con la API de Griddo, permitiendo a los desarrolladores conectarse, realizar consultas estructuradas de datos con facilidad. Este SDK proporciona métodos sencillos para interactuar con los diferentes servicios de Griddo, manejando detalles como la autenticación y la paginación de resultados, y permitiendo personalizar consultas con diversos parámetros.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|