@based/opts
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -1,1 +0,1 @@ | ||
var z=Object.create;var w=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ne=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ee(t))!re.call(e,u)&&u!==r&&w(e,u,{get:()=>t[u],enumerable:!(n=h(t,u))||n.enumerable});return e};var E=(e,t,r)=>(r=e!=null?z(te(e)):{},U(t||!e||!e.__esModule?w(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>U(w({},"__esModule",{value:!0}),e);var p=b(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var oe=(e,t=5381)=>{let r=e.length;for(;r;){let n=e.charCodeAt(--r);t=t*33^n}return t};v.default=oe});var K=b(y=>{"use strict";var fe=y&&y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0});var c=fe(p()),I=(e,t=5381,r=52711)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++){let u=e[n],o=typeof u;if(o==="string"){let l=n+":"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="number"){let l=n+"n:"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="object")if(u===null){let l=n+"v:null";t=c.default(l,t),r=c.default(l,r)}else{let l=I(u,t,r);t=c.default(n+"o:",l[0]),r=c.default(n+"o:",l[1])}else if(o==="boolean"){let l=n+"b:"+(u?"true":"false");t=c.default(l,t),r=c.default(l,r)}}else for(let n in e){let u=e[n],o=typeof u;if(o==="string"){let l=n+":"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="number"){let l=n+"n:"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="object")if(u===null){let l=n+"v:null";t=c.default(l,t),r=c.default(l,r)}else{let l=I(u,t,r);t=c.default(n+"o:",l[0]),r=c.default(n+"o:",l[1])}else if(o==="boolean"){let l=n+"b:"+(u?"true":"false");t=c.default(l,t),r=c.default(l,r)}}return[t,r]};y.default=I});var D=b(O=>{"use strict";var se=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});var ie=se(K()),ce=e=>{let t=ie.default(e);return(t[0]>>>0)*4096+t[1]};O.default=ce});var S=b(j=>{"use strict";var R=j&&j.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0});var de=R(D()),m=R(p()),ae=(e,t)=>{let r;if(typeof e=="object"?e===null?r=0:r=de.default(e):typeof e=="boolean"?r=(m.default(e?":true":":false")>>>0)*4096:typeof e=="number"?r=(m.default("n:"+e)>>>0)*4096+(m.default("n:"+e,52711)>>>0):r=(m.default(e)>>>0)*4096+(m.default(e,52711)>>>0),t){let n=Math.ceil(Math.log10(r+1));if(n<t)return r*Math.pow(10,t-n)}return r};j.default=ae});var G=b(M=>{"use strict";var N=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});var F=N(S()),A=N(p()),_e=N(D()),V=k(),be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W=e=>{let t="",r;do r=e%62,t=be.charAt(r)+t,e=Math.floor(e/62);while(e>0);return t},ge=(e,t,r)=>{let n;if(typeof e=="object")if(e===null)n=0;else if(t&&t>9&&e.constructor===Array){let l="",f=e.length;for(let s=0;s<f;s++)l+=W(r&&e[s]&&typeof e[s]=="object"?V.hashObjectIgnoreKeyOrder(e[s]):F.default(e[s]));let d=l.length;if(d<t)l+="x",d+1<t&&(l+=new Array(t-d).join("0"));else if(d>t)return l.slice(0,t);return l}else n=(r?V.hashObjectIgnoreKeyOrder(e):_e.default(e))>>>0;else typeof e=="boolean"?n=A.default(e?":true":":false")*4096:typeof e=="number"?n=(A.default("n:"+e)>>>0)*4096:n=A.default(e)>>>0;let u=W(n),o=u.length;return o<t&&(u+="x",o+1<t&&(u+=new Array(t-o).join("0"))),u};M.default=ge});var B=b(q=>{"use strict";var pe=q&&q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});var i=pe(p()),x=(e,t=5381,r=52711)=>{if(Array.isArray(e)){let n="__len:"+e.length+1;t=i.default(n,t),r=i.default(n,r);for(let u=0;u<e.length;u++){let o=e[u],l=typeof o;if(l==="string"){let f=u+":"+o;t=i.default(f,t),r=i.default(f,r)}else if(l==="number"){let f=u+"n:"+o;t=i.default(f,t),r=i.default(f,r)}else if(l==="object")if(o===null){let f=u+"v:null";t=i.default(f,t),r=i.default(f,r)}else{let f=x(o,t,r),d=u+"o:";t=i.default(d,f[0]),r=i.default(d,f[1])}else if(l==="boolean"){let f=u+"b:"+(o?"true":"false");t=i.default(f,t),r=i.default(f,r)}}}else{let n=Object.keys(e).sort(),u="__len:"+n.length+1;t=i.default(u,t),r=i.default(u,r);for(let o=0;o<n.length;o++){let l=n[o],f=e[l],d=typeof f;if(d==="string"){let s=l+":"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="number"){let s=l+"n:"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="object")if(f===null){let s=l+"v:null";t=i.default(s,t),r=i.default(s,r)}else{let s=x(f,t,r),_=l+"o:";t=i.default(_,s[0]),r=i.default(_,s[1])}else if(d==="boolean"){let s=l+"b:"+(f?"true":"false");t=i.default(s,t),r=i.default(s,r)}}}return[t,r]};q.default=x});var J=b(C=>{"use strict";var ye=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});var Oe=ye(B()),me=e=>{let t=Oe.default(e);return(t[0]>>>0)*4096+(t[1]>>>0)};C.default=me});var k=b(a=>{"use strict";var g=a&&a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0});var je=g(S());a.hash=je.default;var Me=g(G());a.hashCompact=Me.default;var qe=g(D());a.hashObject=qe.default;var Ce=g(J());a.hashObjectIgnoreKeyOrder=Ce.default;var $e=g(B());a.hashObjectIgnoreKeyOrderNest=$e.default;var we=g(K());a.hashObjectNest=we.default;var De=g(p());a.stringHash=De.default});var Ae={};ne(Ae,{default:()=>Se,genCache:()=>H,getServicePort:()=>P});module.exports=le(Ae);var Q=E(require("cross-fetch")),$=require("@saulx/utils");var ue=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);let n=t>>>0;for(;n>65535;)n=n/10;return Math.round(n)},P=(e,t,r,n,u="allServices",o=0)=>ue(`${u}-${e}-${t}-${r}-${n}-${o}`);var T=E(k()),X=e=>e||"@based/env-hub",Pe={"@based/env-hub":0,"@based/env-admin-hub":1,"@based/admin-hub":2,"@based/machine-hub":3},H=e=>{let t=Pe[X(e.name)],r=Math.floor(Math.random()*1e4),n=t+""+r;return e.key?n+"/"+(e.optionalKey?e.key+"$":e.key):n},ve=async(e,t,r)=>{try{let n=await(0,Q.default)(`${e}/status/${H(t)}`,{headers:t.headers});if(n.ok){let u=n.headers.get("x-request-id");if(!u)return 1;let{decode:o}=(0,$.createEncoder)(Ke,u.slice(0,6).split("")),l=o(u.slice(6)).split(","),f=[];for(let _=0;_<Math.floor(l.length/2);_++)f.push([l[_],encodeURIComponent(l[l.length-1-_])]);let[d,s]=f[~~(Math.random()*f.length)];return r?`${/^https/.test(e)?"https":"http"}://${d}`:`${/^https/.test(e)?"wss":"ws"}://${d}/${s}`}else return!1}catch{return!1}},L=/^ws/,Ie=({cluster:e="production",org:t,project:r,env:n,name:u})=>{if(e==="local")return[`http://localhost:${P(t,r,n,X(u).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`];let o="-status";return[`https://${(0,T.hashObjectIgnoreKeyOrder)({org:t,project:r,env:n,cluster:e}).toString(36)}${o}.based.dev`]},Y=async(e,t=!1,r=0)=>{if(e.url){let u;return typeof e.url=="function"?u=await e.url():u=e.url,t&&u&&L.test(u)?u.replace(L,"http"):u}let n=e.discoveryUrls||Ie(e);for(let u=0;u<n.length;u++){let o=n[u],l=await Promise.race([ve(o,e,t),(0,$.wait)(3e3)]);if(l===1||!l&&u===n.length-1)return await(0,$.wait)(Math.min(r*r*50+500,5e3)),Y(e,t,++r);if(l)return l}},Ke=[",",".based.dev","localhost:","localhost","based.io","based.dev","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],Z=Y;var Se=async(e,t)=>Z(e,t);0&&(module.exports={genCache,getServicePort}); | ||
var z=Object.create;var w=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ne=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ee(t))!re.call(e,u)&&u!==r&&w(e,u,{get:()=>t[u],enumerable:!(n=h(t,u))||n.enumerable});return e};var E=(e,t,r)=>(r=e!=null?z(te(e)):{},U(t||!e||!e.__esModule?w(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>U(w({},"__esModule",{value:!0}),e);var p=b(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var oe=(e,t=5381)=>{let r=e.length;for(;r;){let n=e.charCodeAt(--r);t=t*33^n}return t};v.default=oe});var K=b(y=>{"use strict";var fe=y&&y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0});var c=fe(p()),I=(e,t=5381,r=52711)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++){let u=e[n],o=typeof u;if(o==="string"){let l=n+":"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="number"){let l=n+"n:"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="object")if(u===null){let l=n+"v:null";t=c.default(l,t),r=c.default(l,r)}else{let l=I(u,t,r);t=c.default(n+"o:",l[0]),r=c.default(n+"o:",l[1])}else if(o==="boolean"){let l=n+"b:"+(u?"true":"false");t=c.default(l,t),r=c.default(l,r)}}else for(let n in e){let u=e[n],o=typeof u;if(o==="string"){let l=n+":"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="number"){let l=n+"n:"+u;t=c.default(l,t),r=c.default(l,r)}else if(o==="object")if(u===null){let l=n+"v:null";t=c.default(l,t),r=c.default(l,r)}else{let l=I(u,t,r);t=c.default(n+"o:",l[0]),r=c.default(n+"o:",l[1])}else if(o==="boolean"){let l=n+"b:"+(u?"true":"false");t=c.default(l,t),r=c.default(l,r)}}return[t,r]};y.default=I});var D=b(O=>{"use strict";var se=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});var ie=se(K()),ce=e=>{let t=ie.default(e);return(t[0]>>>0)*4096+t[1]};O.default=ce});var S=b(j=>{"use strict";var R=j&&j.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0});var de=R(D()),m=R(p()),ae=(e,t)=>{let r;if(typeof e=="object"?e===null?r=0:r=de.default(e):typeof e=="boolean"?r=(m.default(e?":true":":false")>>>0)*4096:typeof e=="number"?r=(m.default("n:"+e)>>>0)*4096+(m.default("n:"+e,52711)>>>0):r=(m.default(e)>>>0)*4096+(m.default(e,52711)>>>0),t){let n=Math.ceil(Math.log10(r+1));if(n<t)return r*Math.pow(10,t-n)}return r};j.default=ae});var G=b(M=>{"use strict";var N=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});var F=N(S()),A=N(p()),_e=N(D()),V=k(),be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W=e=>{let t="",r;do r=e%62,t=be.charAt(r)+t,e=Math.floor(e/62);while(e>0);return t},ge=(e,t,r)=>{let n;if(typeof e=="object")if(e===null)n=0;else if(t&&t>9&&e.constructor===Array){let l="",f=e.length;for(let s=0;s<f;s++)l+=W(r&&e[s]&&typeof e[s]=="object"?V.hashObjectIgnoreKeyOrder(e[s]):F.default(e[s]));let d=l.length;if(d<t)l+="x",d+1<t&&(l+=new Array(t-d).join("0"));else if(d>t)return l.slice(0,t);return l}else n=(r?V.hashObjectIgnoreKeyOrder(e):_e.default(e))>>>0;else typeof e=="boolean"?n=A.default(e?":true":":false")*4096:typeof e=="number"?n=(A.default("n:"+e)>>>0)*4096:n=A.default(e)>>>0;let u=W(n),o=u.length;return o<t&&(u+="x",o+1<t&&(u+=new Array(t-o).join("0"))),u};M.default=ge});var B=b(q=>{"use strict";var pe=q&&q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});var i=pe(p()),x=(e,t=5381,r=52711)=>{if(Array.isArray(e)){let n="__len:"+e.length+1;t=i.default(n,t),r=i.default(n,r);for(let u=0;u<e.length;u++){let o=e[u],l=typeof o;if(l==="string"){let f=u+":"+o;t=i.default(f,t),r=i.default(f,r)}else if(l==="number"){let f=u+"n:"+o;t=i.default(f,t),r=i.default(f,r)}else if(l==="object")if(o===null){let f=u+"v:null";t=i.default(f,t),r=i.default(f,r)}else{let f=x(o,t,r),d=u+"o:";t=i.default(d,f[0]),r=i.default(d,f[1])}else if(l==="boolean"){let f=u+"b:"+(o?"true":"false");t=i.default(f,t),r=i.default(f,r)}}}else{let n=Object.keys(e).sort(),u="__len:"+n.length+1;t=i.default(u,t),r=i.default(u,r);for(let o=0;o<n.length;o++){let l=n[o],f=e[l],d=typeof f;if(d==="string"){let s=l+":"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="number"){let s=l+"n:"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="object")if(f===null){let s=l+"v:null";t=i.default(s,t),r=i.default(s,r)}else{let s=x(f,t,r),_=l+"o:";t=i.default(_,s[0]),r=i.default(_,s[1])}else if(d==="boolean"){let s=l+"b:"+(f?"true":"false");t=i.default(s,t),r=i.default(s,r)}}}return[t,r]};q.default=x});var J=b(C=>{"use strict";var ye=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});var Oe=ye(B()),me=e=>{let t=Oe.default(e);return(t[0]>>>0)*4096+(t[1]>>>0)};C.default=me});var k=b(a=>{"use strict";var g=a&&a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0});var je=g(S());a.hash=je.default;var Me=g(G());a.hashCompact=Me.default;var qe=g(D());a.hashObject=qe.default;var Ce=g(J());a.hashObjectIgnoreKeyOrder=Ce.default;var $e=g(B());a.hashObjectIgnoreKeyOrderNest=$e.default;var we=g(K());a.hashObjectNest=we.default;var De=g(p());a.stringHash=De.default});var Ae={};ne(Ae,{default:()=>Se,genCache:()=>H,getServicePort:()=>P});module.exports=le(Ae);var Q=E(require("@based/fetch")),$=require("@saulx/utils");var ue=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);let n=t>>>0;for(;n>65535;)n=n/10;return Math.round(n)},P=(e,t,r,n,u="allServices",o=0)=>ue(`${u}-${e}-${t}-${r}-${n}-${o}`);var T=E(k()),X=e=>e||"@based/env-hub",Pe={"@based/env-hub":0,"@based/env-admin-hub":1,"@based/admin-hub":2,"@based/machine-hub":3},H=e=>{let t=Pe[X(e.name)],r=Math.floor(Math.random()*1e4),n=t+""+r;return e.key?n+"/"+(e.optionalKey?e.key+"$":e.key):n},ve=async(e,t,r)=>{try{let n=await(0,Q.default)(`${e}/status/${H(t)}`,{headers:t.headers});if(n.ok){let u=n.headers.get("x-request-id");if(!u)return 1;let{decode:o}=(0,$.createEncoder)(Ke,u.slice(0,6).split("")),l=o(u.slice(6)).split(","),f=[];for(let _=0;_<Math.floor(l.length/2);_++)f.push([l[_],encodeURIComponent(l[l.length-1-_])]);let[d,s]=f[~~(Math.random()*f.length)];return r?`${/^https/.test(e)?"https":"http"}://${d}`:`${/^https/.test(e)?"wss":"ws"}://${d}/${s}`}else return!1}catch{return!1}},L=/^ws/,Ie=({cluster:e="production",org:t,project:r,env:n,name:u})=>{if(e==="local")return[`http://localhost:${P(t,r,n,X(u).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`];let o="-status";return[`https://${(0,T.hashObjectIgnoreKeyOrder)({org:t,project:r,env:n,cluster:e}).toString(36)}${o}.based.dev`]},Y=async(e,t=!1,r=0)=>{if(e.url){let u;return typeof e.url=="function"?u=await e.url():u=e.url,t&&u&&L.test(u)?u.replace(L,"http"):u}let n=e.discoveryUrls||Ie(e);for(let u=0;u<n.length;u++){let o=n[u],l=await Promise.race([ve(o,e,t),(0,$.wait)(3e3)]);if(l===1||!l&&u===n.length-1)return await(0,$.wait)(Math.min(r*r*50+500,5e3)),Y(e,t,++r);if(l)return l}},Ke=[",",".based.dev","localhost:","localhost","based.io","based.dev","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],Z=Y;var Se=async(e,t)=>Z(e,t);0&&(module.exports={genCache,getServicePort}); |
{ | ||
"name": "@based/opts", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"main": "dist/index.js", | ||
@@ -11,13 +11,13 @@ "source": "src/index.ts", | ||
"watch": "npx tsc --watch", | ||
"build-for-publish": "rm -rf ./dist/ & esbuild ./src/index.ts --bundle --minify --outdir=./dist/ --external:@saulx/utils --external:cross-fetch --platform=node" | ||
"build-for-publish": "rm -rf ./dist/ & esbuild ./src/index.ts --bundle --minify --outdir=./dist/ --external:@saulx/utils --external:@based/fetch --platform=node" | ||
}, | ||
"dependencies": { | ||
"@saulx/utils": "^3.4.0", | ||
"@saulx/utils": "^3.4.2", | ||
"@saulx/hash": "2.0.0", | ||
"cross-fetch": "^3.1.5" | ||
"@based/fetch": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "^10.9.1", | ||
"esbuild": "0.16.8" | ||
"esbuild": "^0.17.19" | ||
} | ||
} |
8255
+ Added@based/fetch@^1.0.0
+ Added@based/fetch@1.0.5(transitive)
+ Addedcross-fetch@3.1.8(transitive)
- Removedcross-fetch@^3.1.5
- Removedcross-fetch@3.2.0(transitive)
Updated@saulx/utils@^3.4.2