toilscript 0.1.50 → 0.1.52
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/cli.generated.d.ts +2 -2
- package/dist/cli.js +213 -16
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +2 -2
- package/dist/toilscript.js +1 -1
- package/dist/toilscript.js.map +1 -1
- package/dist/web.js +3 -3
- package/package.json +1 -1
- package/std/assembly/bindings/toildb.ts +6 -0
- package/std/assembly/toildb.ts +205 -14
- package/std/assembly/toilscript.d.ts +93 -8
package/dist/cli.generated.d.ts
CHANGED
|
@@ -2972,7 +2972,7 @@ declare module "types:toilscript/src/dbcatalog" {
|
|
|
2972
2972
|
* u16 format_version = 1
|
|
2973
2973
|
* u16 n_methods
|
|
2974
2974
|
* per method:
|
|
2975
|
-
* u32 method_id (FNV-1a of "ClassName.methodName" or "fnName", the `
|
|
2975
|
+
* u32 method_id (FNV-1a of "ClassName.methodName" or "fnName", the `dacely-rpc` header id)
|
|
2976
2976
|
* u8 function_kind (1 = Action)
|
|
2977
2977
|
*/
|
|
2978
2978
|
export function buildToilDbRpcKinds(program: Program): Uint8Array | null;
|
|
@@ -3241,7 +3241,7 @@ declare module "types:toilscript/src/parser" {
|
|
|
3241
3241
|
* `injectRestController`. Each method becomes an id-matched arm of a synthesized
|
|
3242
3242
|
* `__rpcDispatch(__id, __body)`: decode the positional args from the body, call the method on a FRESH
|
|
3243
3243
|
* instance (stateless, exactly like a `@rest` controller), encode the result. The id is FNV-1a of
|
|
3244
|
-
* `"Class.method"` - the identical hash the generated client sends in the `
|
|
3244
|
+
* `"Class.method"` - the identical hash the generated client sends in the `dacely-rpc` header, so the
|
|
3245
3245
|
* wire matches without the two sides sharing state. `DataReader`/`DataWriter` are ambient (std).
|
|
3246
3246
|
*/
|
|
3247
3247
|
private injectService;
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
var le=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var dn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(a){throw n=[a],a}};var nn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pe(t))!Ve.call(e,s)&&s!==n&&le(e,s,{get:()=>t[s],enumerable:!(a=Me(t,s))||a.enumerable});return e},In=(e,t,n)=>(se(e,t,"default"),n&&se(n,t,"default"));var ue={};nn(ue,{promises:()=>Ge});var Ge,fe=dn(()=>{"use strict";Ge={}});var ce={};nn(ce,{createRequire:()=>He});function He(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var de=dn(()=>{"use strict"});var kn={};nn(kn,{argv:()=>Xe,cwd:()=>On,exit:()=>qe,hrtime:()=>Ye,platform:()=>je,umask:()=>Ke});function On(){return"."}function Ke(){return 0}function qe(e=0){throw Error(`exit ${e}`)}function Ye(e){var t=We.call(pe),n=Math.floor(t*.001),a=Math.floor(t*1e6-n*1e9);return e&&(n-=e[0],a-=e[1],a<0&&(n--,a+=1e9)),[n,a]}var je,Xe,pe,We,Ln=dn(()=>{"use strict";je="linux";Xe=[];pe=globalThis.performance||{},We=pe.now||function(){return new Date().getTime()}});var Nn={};nn(Nn,{basename:()=>et,delimiter:()=>at,dirname:()=>nt,extname:()=>tt,format:()=>it,isAbsolute:()=>Ze,join:()=>$e,normalize:()=>xe,parse:()=>rt,relative:()=>Qe,resolve:()=>pn,sep:()=>Rn,win32:()=>ot});function G(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function he(e,t){for(var n="",a=0,s=-1,o=0,c,d=0;d<=e.length;++d){if(d<e.length)c=e.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(n.length<2||a!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var x=n.lastIndexOf("/");if(x!==n.length-1){x===-1?(n="",a=0):(n=n.slice(0,x),a=n.length-1-n.lastIndexOf("/")),s=d,o=0;continue}}else if(n.length===2||n.length===1){n="",a=0,s=d,o=0;continue}}t&&(n.length>0?n+="/..":n="..",a=2)}else n.length>0?n+="/"+e.slice(s+1,d):n=e.slice(s+1,d),a=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return n}function Je(e,t){var n=t.dir||t.root,a=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+a:n+e+a:a}function pn(){for(var e="",t=!1,n,a=arguments.length-1;a>=-1&&!t;a--){var s;a>=0?s=arguments[a]:(n===void 0&&(n=On()),s=n),G(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=he(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."}function xe(e){if(G(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=he(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e}function Ze(e){return G(e),e.length>0&&e.charCodeAt(0)===47}function $e(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];G(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":xe(e)}function Qe(e,t){if(G(e),G(t),e===t||(e=pn(e),t=pn(t),e===t))return"";if(e===".")return t;for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var a=e.length,s=a-n,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var c=t.length,d=c-o,x=s<d?s:d,b=-1,p=0;p<=x;++p){if(p===x){if(d>x){if(t.charCodeAt(o+p)===47)return t.slice(o+p+1);if(p===0)return t.slice(o+p)}else s>x&&(e.charCodeAt(n+p)===47?b=p:p===0&&(b=0));break}var g=e.charCodeAt(n+p),y=t.charCodeAt(o+p);if(g!==y)break;g===47&&(b=p)}var m="";for(p=n+b+1;p<=a;++p)(p===a||e.charCodeAt(p)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(o+b):(o+=b,t.charCodeAt(o)===47&&++o,t.slice(o))}function nt(e){if(G(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,a=-1,s=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!s){a=o;break}}else s=!1;return a===-1?n?"/":".":n&&a===1?"//":e.slice(0,a)}function et(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');G(e);var n=0,a=-1,s=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var c=t.length-1,d=-1;for(o=e.length-1;o>=0;--o){var x=e.charCodeAt(o);if(x===47){if(!s){n=o+1;break}}else d===-1&&(s=!1,d=o+1),c>=0&&(x===t.charCodeAt(c)?--c===-1&&(a=o):(c=-1,a=d))}return n===a?a=d:a===-1&&(a=e.length),e.slice(n,a)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!s){n=o+1;break}}else a===-1&&(s=!1,a=o+1);return a===-1?"":e.slice(n,a)}}function tt(e){G(e);for(var t=-1,n=0,a=-1,s=!0,o=0,c=e.length-1;c>=0;--c){var d=e.charCodeAt(c);if(d===47){if(!s){n=c+1;break}continue}a===-1&&(s=!1,a=c+1),d===46?t===-1?t=c:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||a===-1||o===0||o===1&&t===a-1&&t===n+1?"":e.slice(t,a)}function it(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return Je("/",e)}function rt(e){G(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),a=n===47,s;a?(t.root="/",s=1):s=0;for(var o=-1,c=0,d=-1,x=!0,b=e.length-1,p=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!x){c=b+1;break}continue}d===-1&&(x=!1,d=b+1),n===46?o===-1?o=b:p!==1&&(p=1):o!==-1&&(p=-1)}return o===-1||d===-1||p===0||p===1&&o===d-1&&o===c+1?d!==-1&&(c===0&&a?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(c,d)):(c===0&&a?(t.name=e.slice(1,o),t.base=e.slice(1,d)):(t.name=e.slice(c,o),t.base=e.slice(c,d)),t.ext=e.slice(o,d)),c>0?t.dir=e.slice(0,c-1):a&&(t.dir="/"),t}var Rn,at,ot,Un=dn(()=>{"use strict";Ln();Rn="/",at=":",ot=null});var ge={};nn(ge,{pathToFileURL:()=>lt});function st(e){return e.replace(/%/g,"%25").replace(/\\/g,"%5C").replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/\t/g,"%09")}function lt(e){let t=pn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==Rn&&(t+="/");let n=new URL("file://");return n.pathname=st(t),n}var me=dn(()=>{"use strict";Un()});var Yn={};nn(Yn,{Stats:()=>zn,checkDiagnostics:()=>mn,compileString:()=>Dt,configToArguments:()=>Wn,createMemoryStream:()=>Xn,default:()=>Yn,defaultOptimizeLevel:()=>we,defaultShrinkLevel:()=>Be,definitionFiles:()=>Bt,libraryFiles:()=>j,libraryPrefix:()=>V,main:()=>De,options:()=>wt,tscOptions:()=>It,version:()=>Kn});var ut=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",M,sn,E,P,hn;ut?(M=await import("fs"),sn=await import("module"),E=await import("path"),P=globalThis.process,hn=await import("url")):(M=await Promise.resolve().then(()=>(fe(),ue)),sn=await Promise.resolve().then(()=>(de(),ce)),E=await Promise.resolve().then(()=>(Un(),Nn)),P=await Promise.resolve().then(()=>(Ln(),kn)),hn=await Promise.resolve().then(()=>(me(),ge)));var _n=typeof process<"u"&&process||{},ft=_n.env&&"CI"in _n.env,ct="\x1B[90m",dt="\x1B[91m",pt="\x1B[92m",ht="\x1B[93m",xt="\x1B[94m",gt="\x1B[95m",mt="\x1B[96m",bt="\x1B[97m",W="\x1B[0m",en=class{constructor(t){this.stream=t,this.enabled=!!(this.stream&&this.stream.isTTY||ft)}gray(t){return this.enabled?ct+t+W:t}red(t){return this.enabled?dt+t+W:t}green(t){return this.enabled?pt+t+W:t}yellow(t){return this.enabled?ht+t+W:t}blue(t){return this.enabled?xt+t+W:t}magenta(t){return this.enabled?gt+t+W:t}cyan(t){return this.enabled?mt+t+W:t}white(t){return this.enabled?bt+t+W:t}},Tn=new en(_n.stdout),Lt=new en(_n.stderr);function yt(e){for(var t=0,n=0,a=e.length;n<a;++n){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:(s&64512)===55296&&n+1<a&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3}return t}function vt(e,t,n){var a=n-t;if(a<1)return"";for(var s=null,o=[],c=0,d;t<n;)d=e[t++],d<128?o[c++]=d:d>191&&d<224?o[c++]=(d&31)<<6|e[t++]&63:d>239&&d<365?(d=((d&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[c++]=55296+(d>>10),o[c++]=56320+(d&1023)):o[c++]=(d&15)<<12|(e[t++]&63)<<6|e[t++]&63,c>=8192&&((s||(s=[])).push(String.fromCharCode(...o)),c=0);return s?(c&&s.push(String.fromCharCode(...o.slice(0,c))),s.join("")):String.fromCharCode(...o.slice(0,c))}function Ft(e,t,n){for(var a=n,s=0,o=e.length;s<o;++s){let c=e.charCodeAt(s),d;c<128?t[n++]=c:c<2048?(t[n++]=c>>6|192,t[n++]=c&63|128):(c&64512)===55296&&s+1<o&&((d=e.charCodeAt(s+1))&64512)===56320?(c=65536+((c&1023)<<10)+(d&1023),++s,t[n++]=c>>18|240,t[n++]=c>>12&63|128,t[n++]=c>>6&63|128,t[n++]=c&63|128):(t[n++]=c>>12|224,t[n++]=c>>6&63|128,t[n++]=c&63|128)}return n-a}var Cn={length:yt,read:vt,write:Ft};var be=sn.createRequire(import.meta.url);function ve(e,t,n=!0){var a={},s=[],o=[],c=[],d={};Object.keys(t).forEach(p=>{if(!p.startsWith(" ")){var g=t[p];g.alias!=null&&(typeof g.alias=="string"?d[g.alias]=p:Array.isArray(g.alias)&&g.alias.forEach(y=>d[y]=p)),n&&g.default!=null&&(a[p]=g.default)}});for(var x=0,b=(e=e.slice()).length;x<b;++x){let p=e[x];if(p=="--"){++x;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(p),y,m;if(g)t[p]?y=t[m=p]:g[1]!=null?(y=t[m=d[g[1].substring(1)]],y&&g[2]!=null&&(e[x--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[x--]=g[4]));else if(p.charCodeAt(0)==45)y=t[m=p];else{o.push(p);continue}if(y)if(y.value)Object.keys(y.value).forEach(i=>a[i]=y.value[i]);else if(y.type==null||y.type==="b")a[m]=!0;else if(x+1<e.length&&e[x+1].charCodeAt(0)!=45)switch(y.type){case"i":a[m]=parseInt(e[++x],10);break;case"I":a[m]=(a[m]||[]).concat(parseInt(e[++x],10));break;case"f":a[m]=parseFloat(e[++x]);break;case"F":a[m]=(a[m]||[]).concat(parseFloat(e[++x]));break;case"s":a[m]=String(e[++x]);break;case"S":a[m]=(a[m]||[]).concat(e[++x].split(","));break;default:s.push(p),--x}else switch(y.type){case"i":case"f":a[m]=y.default||0;break;case"s":a[m]=y.default||"";break;case"I":case"F":case"S":a[m]=y.default||[];break;default:s.push(p)}else s.push(p)}for(;x<b;)c.push(e[x++]);return n&&Pn(t,a),{options:a,unknown:s,arguments:o,trailing:c}}function Fe(e,t){t||(t={});var n=t.indent||2,a=t.padding||24,s=t.eol||`
|
|
8
|
-
`,o={},c=[];Object.keys(e).forEach(b=>{var p=e[b];if(p.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,p.alias&&(g+=", -"+p.alias);g.length<a;)g+=" ";var y;!t.noCategories&&p.category?(y=o[p.category])||(o[p.category]=y=[]):y=c,Array.isArray(p.description)?y.push(g+p.description[0]+p.description.slice(1).map(m=>{for(let i=0;i<a;++i)m=" "+m;return s+m}).join("")):y.push(g+p.description)}});var d=[],x=!1;return Object.keys(o).forEach(b=>{x=!0,d.push(s+" "+Tn.gray(b)+s),d.push(o[b].join(s))}),x&&c.length&&d.push(s+" "+Tn.gray("Other")+s),d.push(c.join(s)),d.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Mn(e,t,n,a){let s={};for(let[o,{type:c,mutuallyExclusive:d,isPath:x,useNodeResolution:b,cliOnly:p}]of Object.entries(e)){let g=ye(t[o],c),y=ye(n[o],c);if(g==null){if(y!=null){if(p)continue;if(Array.isArray(y)){let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=y.filter(i=>!m.includes(i)):s[o]=y.slice()}else x&&(y=tn(y,a,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(p){s[o]=g.slice();continue}let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=[...g,...y.filter(i=>!g.includes(i)&&!m.includes(i))]:s[o]=[...g,...y.filter(i=>!g.includes(i))]}else s[o]=g}return s}function Et(e){let t=E.parse(e);return t.root||(t.root="./"),E.format(t)}function tn(e,t,n=!1){return E.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(E.join(t,e))}function Pn(e,t){for(let[n,{default:a}]of Object.entries(e))t[n]==null&&a!=null&&(t[n]=a)}var Ee="0.1.50",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},targetMode:{category:"General",description:"Toil compile surface mode: 'hot' (request/stream) or 'cold' (daemon). Omit for the default request artifact.",type:"s"},noConfigEntries:{category:"General",description:"Ignore the toilconfig 'entries' array and compile ONLY the entry files given on the command line. Used by the toiljs multi-artifact build, which hands each pass (request/stream/daemon) its own entry subset.",type:"b"},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcSurfaceFiles:{category:"Output",description:"Files parsed for the rpc module's @rest/@stream client surface but NOT compiled into this artifact (folds a sibling tier's @stream classes into the Server surface).",type:"S",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
|
|
8
|
+
`,o={},c=[];Object.keys(e).forEach(b=>{var p=e[b];if(p.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,p.alias&&(g+=", -"+p.alias);g.length<a;)g+=" ";var y;!t.noCategories&&p.category?(y=o[p.category])||(o[p.category]=y=[]):y=c,Array.isArray(p.description)?y.push(g+p.description[0]+p.description.slice(1).map(m=>{for(let i=0;i<a;++i)m=" "+m;return s+m}).join("")):y.push(g+p.description)}});var d=[],x=!1;return Object.keys(o).forEach(b=>{x=!0,d.push(s+" "+Tn.gray(b)+s),d.push(o[b].join(s))}),x&&c.length&&d.push(s+" "+Tn.gray("Other")+s),d.push(c.join(s)),d.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Mn(e,t,n,a){let s={};for(let[o,{type:c,mutuallyExclusive:d,isPath:x,useNodeResolution:b,cliOnly:p}]of Object.entries(e)){let g=ye(t[o],c),y=ye(n[o],c);if(g==null){if(y!=null){if(p)continue;if(Array.isArray(y)){let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=y.filter(i=>!m.includes(i)):s[o]=y.slice()}else x&&(y=tn(y,a,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(p){s[o]=g.slice();continue}let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=[...g,...y.filter(i=>!g.includes(i)&&!m.includes(i))]:s[o]=[...g,...y.filter(i=>!g.includes(i))]}else s[o]=g}return s}function Et(e){let t=E.parse(e);return t.root||(t.root="./"),E.format(t)}function tn(e,t,n=!1){return E.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(E.join(t,e))}function Pn(e,t){for(let[n,{default:a}]of Object.entries(e))t[n]==null&&a!=null&&(t[n]=a)}var Ee="0.1.52",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},targetMode:{category:"General",description:"Toil compile surface mode: 'hot' (request/stream) or 'cold' (daemon). Omit for the default request artifact.",type:"s"},noConfigEntries:{category:"General",description:"Ignore the toilconfig 'entries' array and compile ONLY the entry files given on the command line. Used by the toiljs multi-artifact build, which hands each pass (request/stream/daemon) its own entry subset.",type:"b"},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcSurfaceFiles:{category:"Output",description:"Files parsed for the rpc module's @rest/@stream client surface but NOT compiled into this artifact (folds a sibling tier's @stream classes into the Server surface).",type:"S",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
|
|
9
9
|
|
|
10
10
|
import { BLOCK_MAXSIZE } from "./rt/common";
|
|
11
11
|
import { Runtime } from "shared/runtime";
|
|
@@ -4867,6 +4867,12 @@ export namespace analyticsHost {
|
|
|
4867
4867
|
@external("env", "analytics_read")
|
|
4868
4868
|
export declare function read(domainPtr: usize, domainLen: i32): i32;
|
|
4869
4869
|
|
|
4870
|
+
// analytics_series(domain, metricId, range): frame length (v2 series frame) stashed for takeResult,
|
|
4871
|
+
// or a negative status (-2 absent / -3 forbidden / bad metric or range).
|
|
4872
|
+
// @ts-ignore: decorator
|
|
4873
|
+
@external("env", "analytics_series")
|
|
4874
|
+
export declare function series(domainPtr: usize, domainLen: i32, metricId: i32, range: i32): i32;
|
|
4875
|
+
|
|
4870
4876
|
// analytics_list_sites(cursor, limit): frame length (count u32 | (u32 nameLen, name)* |
|
|
4871
4877
|
// has_more u8) stashed for takeResult; -3 forbidden when the caller is not dacely.com.
|
|
4872
4878
|
// @ts-ignore: decorator
|
|
@@ -19182,16 +19188,172 @@ export class Counter<K> {
|
|
|
19182
19188
|
}
|
|
19183
19189
|
}
|
|
19184
19190
|
|
|
19185
|
-
///
|
|
19186
|
-
/// \`
|
|
19187
|
-
///
|
|
19188
|
-
///
|
|
19191
|
+
/// Every per-domain metric, by stable numeric id. This is the WIRE CONTRACT shared with the edge
|
|
19192
|
+
/// (\`src/analytics/metric_id.rs\`) and the dev server; it orders the snapshot frame and addresses a
|
|
19193
|
+
/// time-series. Ids \`0..=42\` are cumulative COUNTERS (a rate is \`value / seconds\`); \`43..=46\` are the
|
|
19194
|
+
/// avg/peak series of the two GAUGES. Append-only: never renumber.
|
|
19195
|
+
export enum MetricId {
|
|
19196
|
+
Requests = 0,
|
|
19197
|
+
BytesOutL1 = 1,
|
|
19198
|
+
BytesInL1 = 2,
|
|
19199
|
+
Status2xx = 3,
|
|
19200
|
+
Status3xx = 4,
|
|
19201
|
+
Status4xx = 5,
|
|
19202
|
+
Status5xx = 6,
|
|
19203
|
+
StaticHits = 7,
|
|
19204
|
+
WasmDispatches = 8,
|
|
19205
|
+
ExecutorFullRejects = 9,
|
|
19206
|
+
UnknownHostRejects = 10,
|
|
19207
|
+
RateLimitedRejects = 11,
|
|
19208
|
+
GasUsed = 12,
|
|
19209
|
+
DbOps = 13,
|
|
19210
|
+
DbReads = 14,
|
|
19211
|
+
DbWrites = 15,
|
|
19212
|
+
DbErrors = 16,
|
|
19213
|
+
DbLatencyNsSum = 17,
|
|
19214
|
+
StreamAccepts = 18,
|
|
19215
|
+
StreamRejectWrongNode = 19,
|
|
19216
|
+
StreamRejectCapacity = 20,
|
|
19217
|
+
StreamRejectArtifact = 21,
|
|
19218
|
+
StreamRejectGuest = 22,
|
|
19219
|
+
StreamTraps = 23,
|
|
19220
|
+
StreamIdleTimeouts = 24,
|
|
19221
|
+
StreamBytesIn = 25,
|
|
19222
|
+
StreamBytesOut = 26,
|
|
19223
|
+
StreamBackpressureEvents = 27,
|
|
19224
|
+
StreamCloses = 28,
|
|
19225
|
+
StreamDisconnects = 29,
|
|
19226
|
+
DaemonStarts = 30,
|
|
19227
|
+
DaemonStartFailures = 31,
|
|
19228
|
+
DaemonTicksFired = 32,
|
|
19229
|
+
DaemonTicksSkippedNotLeader = 33,
|
|
19230
|
+
DaemonTicksFailed = 34,
|
|
19231
|
+
DaemonLeaderAcquires = 35,
|
|
19232
|
+
DaemonLeaderFenced = 36,
|
|
19233
|
+
DaemonHttpCallAttempts = 37,
|
|
19234
|
+
DaemonHttpCallFailures = 38,
|
|
19235
|
+
MemGrownBytes = 39,
|
|
19236
|
+
Emails = 40,
|
|
19237
|
+
CacheHits = 41,
|
|
19238
|
+
CacheMisses = 42,
|
|
19239
|
+
ConnectedStreamsAvg = 43,
|
|
19240
|
+
ConnectedStreamsPeak = 44,
|
|
19241
|
+
CommittedMemoryAvg = 45,
|
|
19242
|
+
CommittedMemoryPeak = 46,
|
|
19243
|
+
}
|
|
19244
|
+
|
|
19245
|
+
/// The number of cumulative counter metrics (\`MetricId 0..=42\`) = the length of the snapshot's lifetime
|
|
19246
|
+
/// section.
|
|
19247
|
+
export const METRIC_COUNTERS: i32 = 43;
|
|
19248
|
+
|
|
19249
|
+
/// A dashboard time range for \`Analytics.series\`. Short ranges (1h/6h) read the per-MINUTE ring; the rest
|
|
19250
|
+
/// read the per-HOUR ring (30-day retention).
|
|
19251
|
+
export enum AnalyticsRange {
|
|
19252
|
+
H1 = 0,
|
|
19253
|
+
H6 = 1,
|
|
19254
|
+
H12 = 2,
|
|
19255
|
+
H24 = 3,
|
|
19256
|
+
D3 = 4,
|
|
19257
|
+
D7 = 5,
|
|
19258
|
+
D14 = 6,
|
|
19259
|
+
D30 = 7,
|
|
19260
|
+
}
|
|
19261
|
+
|
|
19262
|
+
/// One tenant's analytics snapshot: the lifetime totals (indexed by \`MetricId\`, NO string keys), the two
|
|
19263
|
+
/// live gauge levels, and the request windows paired with the plan caps (cap 0 = unlimited). Read every
|
|
19264
|
+
/// value either by the typed getter (\`stats.requests\`) or by id (\`stats.metric(MetricId.Requests)\`).
|
|
19189
19265
|
export class TenantStats {
|
|
19190
|
-
|
|
19191
|
-
|
|
19266
|
+
/// Lifetime totals indexed by \`MetricId\` (length \`METRIC_COUNTERS\`). Prefer the named getters below.
|
|
19267
|
+
life: StaticArray<u64> = new StaticArray<u64>(METRIC_COUNTERS);
|
|
19268
|
+
/// Live gauges (current level, not a total).
|
|
19269
|
+
connectedStreams: u64 = 0;
|
|
19270
|
+
committedMemory: u64 = 0;
|
|
19271
|
+
/// Request windows: current bucket usage + plan cap (0 = unlimited).
|
|
19272
|
+
reqMinuteUsed: u64 = 0;
|
|
19192
19273
|
reqMinuteCap: u64 = 0;
|
|
19193
|
-
reqDayUsed:
|
|
19274
|
+
reqDayUsed: u64 = 0;
|
|
19194
19275
|
reqDayCap: u64 = 0;
|
|
19276
|
+
/// Edge wall-clock (ms) when the snapshot was read.
|
|
19277
|
+
nowMs: u64 = 0;
|
|
19278
|
+
|
|
19279
|
+
/// Any counter metric by id (0 for an out-of-range id).
|
|
19280
|
+
metric(id: MetricId): u64 {
|
|
19281
|
+
return <i32>id < METRIC_COUNTERS ? this.life[<i32>id] : 0;
|
|
19282
|
+
}
|
|
19283
|
+
|
|
19284
|
+
// Typed getters for every counter (the catalog: no magic strings, self-documenting).
|
|
19285
|
+
get requests(): u64 { return this.life[MetricId.Requests]; }
|
|
19286
|
+
get bytesOutL1(): u64 { return this.life[MetricId.BytesOutL1]; }
|
|
19287
|
+
get bytesInL1(): u64 { return this.life[MetricId.BytesInL1]; }
|
|
19288
|
+
get status2xx(): u64 { return this.life[MetricId.Status2xx]; }
|
|
19289
|
+
get status3xx(): u64 { return this.life[MetricId.Status3xx]; }
|
|
19290
|
+
get status4xx(): u64 { return this.life[MetricId.Status4xx]; }
|
|
19291
|
+
get status5xx(): u64 { return this.life[MetricId.Status5xx]; }
|
|
19292
|
+
get staticHits(): u64 { return this.life[MetricId.StaticHits]; }
|
|
19293
|
+
get wasmDispatches(): u64 { return this.life[MetricId.WasmDispatches]; }
|
|
19294
|
+
get executorFullRejects(): u64 { return this.life[MetricId.ExecutorFullRejects]; }
|
|
19295
|
+
get unknownHostRejects(): u64 { return this.life[MetricId.UnknownHostRejects]; }
|
|
19296
|
+
get rateLimitedRejects(): u64 { return this.life[MetricId.RateLimitedRejects]; }
|
|
19297
|
+
get gasUsed(): u64 { return this.life[MetricId.GasUsed]; }
|
|
19298
|
+
get dbOps(): u64 { return this.life[MetricId.DbOps]; }
|
|
19299
|
+
get dbReads(): u64 { return this.life[MetricId.DbReads]; }
|
|
19300
|
+
get dbWrites(): u64 { return this.life[MetricId.DbWrites]; }
|
|
19301
|
+
get dbErrors(): u64 { return this.life[MetricId.DbErrors]; }
|
|
19302
|
+
get dbLatencyNsSum(): u64 { return this.life[MetricId.DbLatencyNsSum]; }
|
|
19303
|
+
get streamAccepts(): u64 { return this.life[MetricId.StreamAccepts]; }
|
|
19304
|
+
get streamRejectWrongNode(): u64 { return this.life[MetricId.StreamRejectWrongNode]; }
|
|
19305
|
+
get streamRejectCapacity(): u64 { return this.life[MetricId.StreamRejectCapacity]; }
|
|
19306
|
+
get streamRejectArtifact(): u64 { return this.life[MetricId.StreamRejectArtifact]; }
|
|
19307
|
+
get streamRejectGuest(): u64 { return this.life[MetricId.StreamRejectGuest]; }
|
|
19308
|
+
get streamTraps(): u64 { return this.life[MetricId.StreamTraps]; }
|
|
19309
|
+
get streamIdleTimeouts(): u64 { return this.life[MetricId.StreamIdleTimeouts]; }
|
|
19310
|
+
get streamBytesIn(): u64 { return this.life[MetricId.StreamBytesIn]; }
|
|
19311
|
+
get streamBytesOut(): u64 { return this.life[MetricId.StreamBytesOut]; }
|
|
19312
|
+
get streamBackpressureEvents(): u64 { return this.life[MetricId.StreamBackpressureEvents]; }
|
|
19313
|
+
get streamCloses(): u64 { return this.life[MetricId.StreamCloses]; }
|
|
19314
|
+
get streamDisconnects(): u64 { return this.life[MetricId.StreamDisconnects]; }
|
|
19315
|
+
get daemonStarts(): u64 { return this.life[MetricId.DaemonStarts]; }
|
|
19316
|
+
get daemonStartFailures(): u64 { return this.life[MetricId.DaemonStartFailures]; }
|
|
19317
|
+
get daemonTicksFired(): u64 { return this.life[MetricId.DaemonTicksFired]; }
|
|
19318
|
+
get daemonTicksSkippedNotLeader(): u64 { return this.life[MetricId.DaemonTicksSkippedNotLeader]; }
|
|
19319
|
+
get daemonTicksFailed(): u64 { return this.life[MetricId.DaemonTicksFailed]; }
|
|
19320
|
+
get daemonLeaderAcquires(): u64 { return this.life[MetricId.DaemonLeaderAcquires]; }
|
|
19321
|
+
get daemonLeaderFenced(): u64 { return this.life[MetricId.DaemonLeaderFenced]; }
|
|
19322
|
+
get daemonHttpCallAttempts(): u64 { return this.life[MetricId.DaemonHttpCallAttempts]; }
|
|
19323
|
+
get daemonHttpCallFailures(): u64 { return this.life[MetricId.DaemonHttpCallFailures]; }
|
|
19324
|
+
get memGrownBytes(): u64 { return this.life[MetricId.MemGrownBytes]; }
|
|
19325
|
+
get emails(): u64 { return this.life[MetricId.Emails]; }
|
|
19326
|
+
get cacheHits(): u64 { return this.life[MetricId.CacheHits]; }
|
|
19327
|
+
get cacheMisses(): u64 { return this.life[MetricId.CacheMisses]; }
|
|
19328
|
+
|
|
19329
|
+
/// Mean host-observed DB op latency (ns), or 0 with no ops.
|
|
19330
|
+
get meanDbLatencyNs(): u64 {
|
|
19331
|
+
const ops = this.dbOps;
|
|
19332
|
+
return ops > 0 ? this.dbLatencyNsSum / ops : 0;
|
|
19333
|
+
}
|
|
19334
|
+
|
|
19335
|
+
/// Fraction of cacheable responses served from cache (\`hits / (hits + misses)\`),
|
|
19336
|
+
/// 0.0 when there were no cacheable responses.
|
|
19337
|
+
get cacheRatio(): f64 {
|
|
19338
|
+
const hits = this.cacheHits;
|
|
19339
|
+
const total = hits + this.cacheMisses;
|
|
19340
|
+
return total > 0 ? <f64>hits / <f64>total : 0.0;
|
|
19341
|
+
}
|
|
19342
|
+
}
|
|
19343
|
+
|
|
19344
|
+
/// One metric's time series for a range: \`points\` oldest\u2192newest, \`bucketSecs\` the per-bucket width, and
|
|
19345
|
+
/// \`headMs\` the newest bucket's end. Rates are derived, never stored.
|
|
19346
|
+
export class Series {
|
|
19347
|
+
metric: MetricId = MetricId.Requests;
|
|
19348
|
+
bucketSecs: u32 = 0;
|
|
19349
|
+
headMs: u64 = 0;
|
|
19350
|
+
points: i64[] = [];
|
|
19351
|
+
|
|
19352
|
+
/// Per-second rate of bucket \`i\` (its total divided by the bucket width). 0 for an out-of-range index.
|
|
19353
|
+
ratePerSec(i: i32): f64 {
|
|
19354
|
+
if (i < 0 || i >= this.points.length || this.bucketSecs == 0) return 0;
|
|
19355
|
+
return <f64>this.points[i] / <f64>this.bucketSecs;
|
|
19356
|
+
}
|
|
19195
19357
|
}
|
|
19196
19358
|
|
|
19197
19359
|
/// A page of site names from \`Analytics.listSites\` (dacely.com only). When \`hasMore\` is
|
|
@@ -19209,19 +19371,39 @@ export class Analytics {
|
|
|
19209
19371
|
private static decode(buf: Uint8Array): TenantStats {
|
|
19210
19372
|
const r = new DataReader(buf);
|
|
19211
19373
|
const stats = new TenantStats();
|
|
19212
|
-
r.readU16();
|
|
19213
|
-
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
19217
|
-
|
|
19218
|
-
|
|
19374
|
+
const version = r.readU16();
|
|
19375
|
+
if (version < 2) return stats; // pre-v2 edge: refuse rather than mis-decode
|
|
19376
|
+
stats.nowMs = r.readU64();
|
|
19377
|
+
const count = <i32>r.readU32();
|
|
19378
|
+
for (let i: i32 = 0; i < count && r.ok; i++) {
|
|
19379
|
+
// Wire fields are non-negative i64; read the same bytes as u64.
|
|
19380
|
+
const v = r.readU64();
|
|
19381
|
+
if (i < METRIC_COUNTERS) stats.life[i] = v; // ignore any extra (forward-compat)
|
|
19382
|
+
}
|
|
19383
|
+
stats.connectedStreams = r.readU64();
|
|
19384
|
+
stats.committedMemory = r.readU64();
|
|
19385
|
+
stats.reqMinuteUsed = r.readU64();
|
|
19219
19386
|
stats.reqMinuteCap = r.readU64();
|
|
19220
|
-
stats.reqDayUsed = r.
|
|
19387
|
+
stats.reqDayUsed = r.readU64();
|
|
19221
19388
|
stats.reqDayCap = r.readU64();
|
|
19222
19389
|
return stats;
|
|
19223
19390
|
}
|
|
19224
19391
|
|
|
19392
|
+
private static decodeSeries(buf: Uint8Array): Series {
|
|
19393
|
+
const r = new DataReader(buf);
|
|
19394
|
+
const out = new Series();
|
|
19395
|
+
const version = r.readU16();
|
|
19396
|
+
if (version < 2) return out;
|
|
19397
|
+
out.metric = <MetricId>r.readU16();
|
|
19398
|
+
out.bucketSecs = r.readU32();
|
|
19399
|
+
out.headMs = r.readU64();
|
|
19400
|
+
const count = <i32>r.readU32();
|
|
19401
|
+
const pts = new Array<i64>(count);
|
|
19402
|
+
for (let i: i32 = 0; i < count && r.ok; i++) pts[i] = r.readI64();
|
|
19403
|
+
out.points = pts;
|
|
19404
|
+
return out;
|
|
19405
|
+
}
|
|
19406
|
+
|
|
19225
19407
|
/// This site's own analytics. Returns empty stats if unavailable.
|
|
19226
19408
|
static self(): TenantStats {
|
|
19227
19409
|
const status = analyticsHost.read(0, 0);
|
|
@@ -19238,6 +19420,21 @@ export class Analytics {
|
|
|
19238
19420
|
return Analytics.decode(__toildbTake(status));
|
|
19239
19421
|
}
|
|
19240
19422
|
|
|
19423
|
+
/// This site's time-series for \`metric\` over \`range\` (for graphs). Empty series if unavailable.
|
|
19424
|
+
static series(metric: MetricId, range: AnalyticsRange): Series {
|
|
19425
|
+
const status = analyticsHost.series(0, 0, <i32>metric, <i32>range);
|
|
19426
|
+
if (status < 0) return new Series();
|
|
19427
|
+
return Analytics.decodeSeries(__toildbTake(status));
|
|
19428
|
+
}
|
|
19429
|
+
|
|
19430
|
+
/// Another site's time-series (dacely.com only, else \`null\`).
|
|
19431
|
+
static siteSeries(domain: string, metric: MetricId, range: AnalyticsRange): Series | null {
|
|
19432
|
+
const db = Uint8Array.wrap(String.UTF8.encode(domain));
|
|
19433
|
+
const status = analyticsHost.series(db.dataStart, db.byteLength, <i32>metric, <i32>range);
|
|
19434
|
+
if (status < 0) return null;
|
|
19435
|
+
return Analytics.decodeSeries(__toildbTake(status));
|
|
19436
|
+
}
|
|
19437
|
+
|
|
19241
19438
|
/// Enumerate sites, paginated. ONLY \`dacely.com\` gets results; any other caller gets an
|
|
19242
19439
|
/// empty list. \`cursor\` is the previous page's last name (\`""\` = from the start); reads up
|
|
19243
19440
|
/// to \`limit\` names. When \`hasMore\` is true, pass the last \`sites\` entry as the next cursor.
|