@sailfish-ai/sf-veritas 0.1.35 → 0.2.2
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/funcSpanTransformer-CTddGtUV.cjs +1 -0
- package/dist/funcSpanTransformer-coYDqcrs.js +136 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -0
- package/dist/plugins/funcspanEsbuildPlugin.mjs +21 -0
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -0
- package/dist/plugins/funcspanRollupPlugin.mjs +18 -0
- package/dist/plugins/funcspanTscPlugin.cjs +1 -0
- package/dist/plugins/funcspanTscPlugin.mjs +39 -0
- package/dist/plugins/funcspanVitePlugin.cjs +1 -0
- package/dist/plugins/funcspanVitePlugin.mjs +17 -0
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -0
- package/dist/plugins/funcspanWebpackLoader.mjs +15 -0
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -0
- package/dist/plugins/funcspanWebpackPlugin.mjs +28 -0
- package/dist/sf-veritas.cjs +38 -20
- package/dist/sf-veritas.mjs +850 -1239
- package/dist/source-map-Cr6YkjTd.js +631 -0
- package/dist/source-map-rHHEdpre.cjs +1 -0
- package/dist/types/baseTransmitter.d.ts +2 -1
- package/dist/types/contextManager.d.ts +23 -0
- package/dist/types/exceptionTransmitter.d.ts +1 -1
- package/dist/types/funcSpanCapture.d.ts +24 -0
- package/dist/types/funcSpanConfig.d.ts +83 -0
- package/dist/types/funcSpanConfigLoader.d.ts +70 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/types/networkRequestTransmitter.d.ts +1 -0
- package/dist/types/plugins/funcSpanTransformer.d.ts +31 -0
- package/dist/types/plugins/funcspanEsbuildPlugin.d.ts +28 -0
- package/dist/types/plugins/funcspanRollupPlugin.d.ts +28 -0
- package/dist/types/plugins/funcspanTscPlugin.d.ts +35 -0
- package/dist/types/plugins/funcspanVitePlugin.d.ts +27 -0
- package/dist/types/plugins/funcspanWebpackLoader.d.ts +1 -0
- package/dist/types/plugins/funcspanWebpackPlugin.d.ts +32 -0
- package/package.json +49 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var F,$,N={},j={},G={},U={};function te(){if(F)return U;F=1;var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return U.encode=function(p){if(0<=p&&p<u.length)return u[p];throw new TypeError("Must be between 0 and 63: "+p)},U.decode=function(p){return 65<=p&&p<=90?p-65:97<=p&&p<=122?p-97+26:48<=p&&p<=57?p-48+52:p==43?62:p==47?63:-1},U}function ne(){if($)return G;$=1;var u=te();return G.encode=function(p){var m,d="",c=(function(r){return r<0?1+(-r<<1):0+(r<<1)})(p);do m=31&c,(c>>>=5)>0&&(m|=32),d+=u.encode(m);while(c>0);return d},G.decode=function(p,m,d){var c,r,t,l,g=p.length,h=0,_=0;do{if(m>=g)throw new Error("Expected more digits in base 64 VLQ value.");if((r=u.decode(p.charCodeAt(m++)))===-1)throw new Error("Invalid base64 digit: "+p.charAt(m-1));c=!!(32&r),h+=(r&=31)<<_,_+=5}while(c);d.value=(l=(t=h)>>1,1&~t?l:-l),d.rest=m},G}var z,W={};function R(){return z||(z=1,(function(u){u.getArg=function(e,n,a){if(n in e)return e[n];if(arguments.length===3)return a;throw new Error('"'+n+'" is a required argument.')};var p=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,m=/^data:.+\,.+$/;function d(e){var n=e.match(p);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function c(e){var n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}u.urlParse=d,u.urlGenerate=c;var r,t,l=(r=function(e){var n=e,a=d(e);if(a){if(!a.path)return e;n=a.path}for(var o=u.isAbsolute(n),f=[],v=0,C=0;;){if(v=C,(C=n.indexOf("/",v))===-1){f.push(n.slice(v));break}for(f.push(n.slice(v,C));C<n.length&&n[C]==="/";)C++}var S,y=0;for(C=f.length-1;C>=0;C--)(S=f[C])==="."?f.splice(C,1):S===".."?y++:y>0&&(S===""?(f.splice(C+1,y),y=0):(f.splice(C,2),y--));return(n=f.join("/"))===""&&(n=o?"/":"."),a?(a.path=n,c(a)):n},t=[],function(e){for(var n=0;n<t.length;n++)if(t[n].input===e){var a=t[0];return t[0]=t[n],t[n]=a,t[0].result}var o=r(e);return t.unshift({input:e,result:o}),t.length>32&&t.pop(),o});function g(e,n){e===""&&(e="."),n===""&&(n=".");var a=d(n),o=d(e);if(o&&(e=o.path||"/"),a&&!a.scheme)return o&&(a.scheme=o.scheme),c(a);if(a||n.match(m))return n;if(o&&!o.host&&!o.path)return o.host=n,c(o);var f=n.charAt(0)==="/"?n:l(e.replace(/\/+$/,"")+"/"+n);return o?(o.path=f,c(o)):f}u.normalize=l,u.join=g,u.isAbsolute=function(e){return e.charAt(0)==="/"||p.test(e)},u.relative=function(e,n){e===""&&(e="."),e=e.replace(/\/$/,"");for(var a=0;n.indexOf(e+"/")!==0;){var o=e.lastIndexOf("/");if(o<0||(e=e.slice(0,o)).match(/^([^\/]+:\/)?\/*$/))return n;++a}return Array(a+1).join("../")+n.substr(e.length+1)};var h=!("__proto__"in Object.create(null));function _(e){return e}function i(e){if(!e)return!1;var n=e.length;if(n<9||e.charCodeAt(n-1)!==95||e.charCodeAt(n-2)!==95||e.charCodeAt(n-3)!==111||e.charCodeAt(n-4)!==116||e.charCodeAt(n-5)!==111||e.charCodeAt(n-6)!==114||e.charCodeAt(n-7)!==112||e.charCodeAt(n-8)!==95||e.charCodeAt(n-9)!==95)return!1;for(var a=n-10;a>=0;a--)if(e.charCodeAt(a)!==36)return!1;return!0}function s(e,n){return e===n?0:e===null?1:n===null?-1:e>n?1:-1}u.toSetString=h?_:function(e){return i(e)?"$"+e:e},u.fromSetString=h?_:function(e){return i(e)?e.slice(1):e},u.compareByOriginalPositions=function(e,n,a){var o=s(e.source,n.source);return o!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0||a||(o=e.generatedColumn-n.generatedColumn)!==0||(o=e.generatedLine-n.generatedLine)!==0?o:s(e.name,n.name)},u.compareByOriginalPositionsNoSource=function(e,n,a){var o;return(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0||a||(o=e.generatedColumn-n.generatedColumn)!==0||(o=e.generatedLine-n.generatedLine)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsDeflated=function(e,n,a){var o=e.generatedLine-n.generatedLine;return o!==0||(o=e.generatedColumn-n.generatedColumn)!==0||a||(o=s(e.source,n.source))!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsDeflatedNoLine=function(e,n,a){var o=e.generatedColumn-n.generatedColumn;return o!==0||a||(o=s(e.source,n.source))!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsInflated=function(e,n){var a=e.generatedLine-n.generatedLine;return a!==0||(a=e.generatedColumn-n.generatedColumn)!==0||(a=s(e.source,n.source))!==0||(a=e.originalLine-n.originalLine)!==0||(a=e.originalColumn-n.originalColumn)!==0?a:s(e.name,n.name)},u.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},u.computeSourceURL=function(e,n,a){if(n=n||"",e&&(e[e.length-1]!=="/"&&n[0]!=="/"&&(e+="/"),n=e+n),a){var o=d(a);if(!o)throw new Error("sourceMapURL could not be parsed");if(o.path){var f=o.path.lastIndexOf("/");f>=0&&(o.path=o.path.substring(0,f+1))}n=g(c(o),n)}return l(n)}})(W)),W}var q,x={};function re(){if(q)return x;q=1;var u=R(),p=Object.prototype.hasOwnProperty,m=typeof Map<"u";function d(){this._array=[],this._set=m?new Map:Object.create(null)}return d.fromArray=function(c,r){for(var t=new d,l=0,g=c.length;l<g;l++)t.add(c[l],r);return t},d.prototype.size=function(){return m?this._set.size:Object.getOwnPropertyNames(this._set).length},d.prototype.add=function(c,r){var t=m?c:u.toSetString(c),l=m?this.has(c):p.call(this._set,t),g=this._array.length;l&&!r||this._array.push(c),l||(m?this._set.set(c,g):this._set[t]=g)},d.prototype.has=function(c){if(m)return this._set.has(c);var r=u.toSetString(c);return p.call(this._set,r)},d.prototype.indexOf=function(c){if(m){var r=this._set.get(c);if(r>=0)return r}else{var t=u.toSetString(c);if(p.call(this._set,t))return this._set[t]}throw new Error('"'+c+'" is not in the set.')},d.prototype.at=function(c){if(c>=0&&c<this._array.length)return this._array[c];throw new Error("No element indexed by "+c)},d.prototype.toArray=function(){return this._array.slice()},x.ArraySet=d,x}var J,V,D={};function oe(){if(J)return D;J=1;var u=R();function p(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return p.prototype.unsortedForEach=function(m,d){this._array.forEach(m,d)},p.prototype.add=function(m){var d,c,r,t,l,g;d=this._last,c=m,r=d.generatedLine,t=c.generatedLine,l=d.generatedColumn,g=c.generatedColumn,t>r||t==r&&g>=l||u.compareByGeneratedPositionsInflated(d,c)<=0?(this._last=m,this._array.push(m)):(this._sorted=!1,this._array.push(m))},p.prototype.toArray=function(){return this._sorted||(this._array.sort(u.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},D.MappingList=p,D}function Q(){if(V)return j;V=1;var u=ne(),p=R(),m=re().ArraySet,d=oe().MappingList;function c(r){r||(r={}),this._file=p.getArg(r,"file",null),this._sourceRoot=p.getArg(r,"sourceRoot",null),this._skipValidation=p.getArg(r,"skipValidation",!1),this._ignoreInvalidMapping=p.getArg(r,"ignoreInvalidMapping",!1),this._sources=new m,this._names=new m,this._mappings=new d,this._sourcesContents=null}return c.prototype._version=3,c.fromSourceMap=function(r,t){var l=r.sourceRoot,g=new c(Object.assign(t||{},{file:r.file,sourceRoot:l}));return r.eachMapping(function(h){var _={generated:{line:h.generatedLine,column:h.generatedColumn}};h.source!=null&&(_.source=h.source,l!=null&&(_.source=p.relative(l,_.source)),_.original={line:h.originalLine,column:h.originalColumn},h.name!=null&&(_.name=h.name)),g.addMapping(_)}),r.sources.forEach(function(h){var _=h;l!==null&&(_=p.relative(l,h)),g._sources.has(_)||g._sources.add(_);var i=r.sourceContentFor(h);i!=null&&g.setSourceContent(h,i)}),g},c.prototype.addMapping=function(r){var t=p.getArg(r,"generated"),l=p.getArg(r,"original",null),g=p.getArg(r,"source",null),h=p.getArg(r,"name",null);(this._skipValidation||this._validateMapping(t,l,g,h)!==!1)&&(g!=null&&(g=String(g),this._sources.has(g)||this._sources.add(g)),h!=null&&(h=String(h),this._names.has(h)||this._names.add(h)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:l!=null&&l.line,originalColumn:l!=null&&l.column,source:g,name:h}))},c.prototype.setSourceContent=function(r,t){var l=r;this._sourceRoot!=null&&(l=p.relative(this._sourceRoot,l)),t!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[p.toSetString(l)]=t):this._sourcesContents&&(delete this._sourcesContents[p.toSetString(l)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},c.prototype.applySourceMap=function(r,t,l){var g=t;if(t==null){if(r.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);g=r.file}var h=this._sourceRoot;h!=null&&(g=p.relative(h,g));var _=new m,i=new m;this._mappings.unsortedForEach(function(s){if(s.source===g&&s.originalLine!=null){var e=r.originalPositionFor({line:s.originalLine,column:s.originalColumn});e.source!=null&&(s.source=e.source,l!=null&&(s.source=p.join(l,s.source)),h!=null&&(s.source=p.relative(h,s.source)),s.originalLine=e.line,s.originalColumn=e.column,e.name!=null&&(s.name=e.name))}var n=s.source;n==null||_.has(n)||_.add(n);var a=s.name;a==null||i.has(a)||i.add(a)},this),this._sources=_,this._names=i,r.sources.forEach(function(s){var e=r.sourceContentFor(s);e!=null&&(l!=null&&(s=p.join(l,s)),h!=null&&(s=p.relative(h,s)),this.setSourceContent(s,e))},this)},c.prototype._validateMapping=function(r,t,l,g){if(t&&typeof t.line!="number"&&typeof t.column!="number"){var h="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}if((!(r&&"line"in r&&"column"in r&&r.line>0&&r.column>=0)||t||l||g)&&!(r&&"line"in r&&"column"in r&&t&&"line"in t&&"column"in t&&r.line>0&&r.column>=0&&t.line>0&&t.column>=0&&l)){if(h="Invalid mapping: "+JSON.stringify({generated:r,source:l,original:t,name:g}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}},c.prototype._serializeMappings=function(){for(var r,t,l,g,h=0,_=1,i=0,s=0,e=0,n=0,a="",o=this._mappings.toArray(),f=0,v=o.length;f<v;f++){if(r="",(t=o[f]).generatedLine!==_)for(h=0;t.generatedLine!==_;)r+=";",_++;else if(f>0){if(!p.compareByGeneratedPositionsInflated(t,o[f-1]))continue;r+=","}r+=u.encode(t.generatedColumn-h),h=t.generatedColumn,t.source!=null&&(g=this._sources.indexOf(t.source),r+=u.encode(g-n),n=g,r+=u.encode(t.originalLine-1-s),s=t.originalLine-1,r+=u.encode(t.originalColumn-i),i=t.originalColumn,t.name!=null&&(l=this._names.indexOf(t.name),r+=u.encode(l-e),e=l)),a+=r}return a},c.prototype._generateSourcesContent=function(r,t){return r.map(function(l){if(!this._sourcesContents)return null;t!=null&&(l=p.relative(t,l));var g=p.toSetString(l);return Object.prototype.hasOwnProperty.call(this._sourcesContents,g)?this._sourcesContents[g]:null},this)},c.prototype.toJSON=function(){var r={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(r.file=this._file),this._sourceRoot!=null&&(r.sourceRoot=this._sourceRoot),this._sourcesContents&&(r.sourcesContent=this._generateSourcesContent(r.sources,r.sourceRoot)),r},c.prototype.toString=function(){return JSON.stringify(this.toJSON())},j.SourceMapGenerator=c,j}var H,E={},K={};function ie(){return H||(H=1,(function(u){function p(m,d,c,r,t,l){var g=Math.floor((d-m)/2)+m,h=t(c,r[g],!0);return h===0?g:h>0?d-g>1?p(g,d,c,r,t,l):l==u.LEAST_UPPER_BOUND?d<r.length?d:-1:g:g-m>1?p(m,g,c,r,t,l):l==u.LEAST_UPPER_BOUND?g:m<0?-1:m}u.GREATEST_LOWER_BOUND=1,u.LEAST_UPPER_BOUND=2,u.search=function(m,d,c,r){if(d.length===0)return-1;var t=p(-1,d.length,m,d,c,r||u.GREATEST_LOWER_BOUND);if(t<0)return-1;for(;t-1>=0&&c(d[t],d[t-1],!0)===0;)--t;return t}})(K)),K}var X,Y,T={};function se(){if(X)return T;function u(m){function d(c,r,t){var l=c[r];c[r]=c[t],c[t]=l}return function c(r,t,l,g){if(l<g){var h=l-1;d(r,(e=l,n=g,Math.round(e+Math.random()*(n-e))),g);for(var _=r[g],i=l;i<g;i++)t(r[i],_,!1)<=0&&d(r,h+=1,i);d(r,h+1,i);var s=h+1;c(r,t,l,s-1),c(r,t,s+1,g)}var e,n}}X=1;let p=new WeakMap;return T.quickSort=function(m,d,c=0){let r=p.get(d);r===void 0&&(r=(function(t){let l=u.toString();return new Function(`return ${l}`)()(t)})(d),p.set(d,r)),r(m,d,c,m.length-1)},T}var Z,ee,k={},ae=(ee||(ee=1,N.SourceMapGenerator=Q().SourceMapGenerator,N.SourceMapConsumer=(function(){if(Y)return E;Y=1;var u=R(),p=ie(),m=re().ArraySet,d=ne(),c=se().quickSort;function r(i,s){var e=i;return typeof i=="string"&&(e=u.parseSourceMapInput(i)),e.sections!=null?new _(e,s):new t(e,s)}function t(i,s){var e=i;typeof i=="string"&&(e=u.parseSourceMapInput(i));var n=u.getArg(e,"version"),a=u.getArg(e,"sources"),o=u.getArg(e,"names",[]),f=u.getArg(e,"sourceRoot",null),v=u.getArg(e,"sourcesContent",null),C=u.getArg(e,"mappings"),S=u.getArg(e,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);f&&(f=u.normalize(f)),a=a.map(String).map(u.normalize).map(function(y){return f&&u.isAbsolute(f)&&u.isAbsolute(y)?u.relative(f,y):y}),this._names=m.fromArray(o.map(String),!0),this._sources=m.fromArray(a,!0),this._absoluteSources=this._sources.toArray().map(function(y){return u.computeSourceURL(f,y,s)}),this.sourceRoot=f,this.sourcesContent=v,this._mappings=C,this._sourceMapURL=s,this.file=S}function l(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}r.fromSourceMap=function(i,s){return t.fromSourceMap(i,s)},r.prototype._version=3,r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),r.prototype.__originalMappings=null,Object.defineProperty(r.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),r.prototype._charIsMappingSeparator=function(i,s){var e=i.charAt(s);return e===";"||e===","},r.prototype._parseMappings=function(i,s){throw new Error("Subclasses must implement _parseMappings")},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,r.GREATEST_LOWER_BOUND=1,r.LEAST_UPPER_BOUND=2,r.prototype.eachMapping=function(i,s,e){var n,a=s||null;switch(e||r.GENERATED_ORDER){case r.GENERATED_ORDER:n=this._generatedMappings;break;case r.ORIGINAL_ORDER:n=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var o=this.sourceRoot,f=i.bind(a),v=this._names,C=this._sources,S=this._sourceMapURL,y=0,A=n.length;y<A;y++){var M=n[y],L=M.source===null?null:C.at(M.source);L!==null&&(L=u.computeSourceURL(o,L,S)),f({source:L,generatedLine:M.generatedLine,generatedColumn:M.generatedColumn,originalLine:M.originalLine,originalColumn:M.originalColumn,name:M.name===null?null:v.at(M.name)})}},r.prototype.allGeneratedPositionsFor=function(i){var s=u.getArg(i,"line"),e={source:u.getArg(i,"source"),originalLine:s,originalColumn:u.getArg(i,"column",0)};if(e.source=this._findSourceIndex(e.source),e.source<0)return[];var n=[],a=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,p.LEAST_UPPER_BOUND);if(a>=0){var o=this._originalMappings[a];if(i.column===void 0)for(var f=o.originalLine;o&&o.originalLine===f;)n.push({line:u.getArg(o,"generatedLine",null),column:u.getArg(o,"generatedColumn",null),lastColumn:u.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a];else for(var v=o.originalColumn;o&&o.originalLine===s&&o.originalColumn==v;)n.push({line:u.getArg(o,"generatedLine",null),column:u.getArg(o,"generatedColumn",null),lastColumn:u.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a]}return n},E.SourceMapConsumer=r,t.prototype=Object.create(r.prototype),t.prototype.consumer=r,t.prototype._findSourceIndex=function(i){var s,e=i;if(this.sourceRoot!=null&&(e=u.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);for(s=0;s<this._absoluteSources.length;++s)if(this._absoluteSources[s]==i)return s;return-1},t.fromSourceMap=function(i,s){var e=Object.create(t.prototype),n=e._names=m.fromArray(i._names.toArray(),!0),a=e._sources=m.fromArray(i._sources.toArray(),!0);e.sourceRoot=i._sourceRoot,e.sourcesContent=i._generateSourcesContent(e._sources.toArray(),e.sourceRoot),e.file=i._file,e._sourceMapURL=s,e._absoluteSources=e._sources.toArray().map(function(M){return u.computeSourceURL(e.sourceRoot,M,s)});for(var o=i._mappings.toArray().slice(),f=e.__generatedMappings=[],v=e.__originalMappings=[],C=0,S=o.length;C<S;C++){var y=o[C],A=new l;A.generatedLine=y.generatedLine,A.generatedColumn=y.generatedColumn,y.source&&(A.source=a.indexOf(y.source),A.originalLine=y.originalLine,A.originalColumn=y.originalColumn,y.name&&(A.name=n.indexOf(y.name)),v.push(A)),f.push(A)}return c(e.__originalMappings,u.compareByOriginalPositions),e},t.prototype._version=3,Object.defineProperty(t.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const g=u.compareByGeneratedPositionsDeflatedNoLine;function h(i,s){let e=i.length,n=i.length-s;if(!(n<=1))if(n==2){let a=i[s],o=i[s+1];g(a,o)>0&&(i[s]=o,i[s+1]=a)}else if(n<20)for(let a=s;a<e;a++)for(let o=a;o>s;o--){let f=i[o-1],v=i[o];if(g(f,v)<=0)break;i[o-1]=v,i[o]=f}else c(i,g,s)}function _(i,s){var e=i;typeof i=="string"&&(e=u.parseSourceMapInput(i));var n=u.getArg(e,"version"),a=u.getArg(e,"sections");if(n!=this._version)throw new Error("Unsupported version: "+n);this._sources=new m,this._names=new m;var o={line:-1,column:0};this._sections=a.map(function(f){if(f.url)throw new Error("Support for url field in sections not implemented.");var v=u.getArg(f,"offset"),C=u.getArg(v,"line"),S=u.getArg(v,"column");if(C<o.line||C===o.line&&S<o.column)throw new Error("Section offsets must be ordered and non-overlapping.");return o=v,{generatedOffset:{generatedLine:C+1,generatedColumn:S+1},consumer:new r(u.getArg(f,"map"),s)}})}return t.prototype._parseMappings=function(i,s){var e,n,a,o,f=1,v=0,C=0,S=0,y=0,A=0,M=i.length,L=0,I={},w=[],O=[];let B=0;for(;L<M;)if(i.charAt(L)===";")f++,L++,v=0,h(O,B),B=O.length;else if(i.charAt(L)===",")L++;else{for((e=new l).generatedLine=f,a=L;a<M&&!this._charIsMappingSeparator(i,a);a++);for(i.slice(L,a),n=[];L<a;)d.decode(i,L,I),o=I.value,L=I.rest,n.push(o);if(n.length===2)throw new Error("Found a source, but no line and column");if(n.length===3)throw new Error("Found a source and line, but no column");if(e.generatedColumn=v+n[0],v=e.generatedColumn,n.length>1&&(e.source=y+n[1],y+=n[1],e.originalLine=C+n[2],C=e.originalLine,e.originalLine+=1,e.originalColumn=S+n[3],S=e.originalColumn,n.length>4&&(e.name=A+n[4],A+=n[4])),O.push(e),typeof e.originalLine=="number"){let P=e.source;for(;w.length<=P;)w.push(null);w[P]===null&&(w[P]=[]),w[P].push(e)}}h(O,B),this.__generatedMappings=O;for(var b=0;b<w.length;b++)w[b]!=null&&c(w[b],u.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...w)},t.prototype._findMapping=function(i,s,e,n,a,o){if(i[e]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+i[e]);if(i[n]<0)throw new TypeError("Column must be greater than or equal to 0, got "+i[n]);return p.search(i,s,a,o)},t.prototype.computeColumnSpans=function(){for(var i=0;i<this._generatedMappings.length;++i){var s=this._generatedMappings[i];if(i+1<this._generatedMappings.length){var e=this._generatedMappings[i+1];if(s.generatedLine===e.generatedLine){s.lastGeneratedColumn=e.generatedColumn-1;continue}}s.lastGeneratedColumn=1/0}},t.prototype.originalPositionFor=function(i){var s={generatedLine:u.getArg(i,"line"),generatedColumn:u.getArg(i,"column")},e=this._findMapping(s,this._generatedMappings,"generatedLine","generatedColumn",u.compareByGeneratedPositionsDeflated,u.getArg(i,"bias",r.GREATEST_LOWER_BOUND));if(e>=0){var n=this._generatedMappings[e];if(n.generatedLine===s.generatedLine){var a=u.getArg(n,"source",null);a!==null&&(a=this._sources.at(a),a=u.computeSourceURL(this.sourceRoot,a,this._sourceMapURL));var o=u.getArg(n,"name",null);return o!==null&&(o=this._names.at(o)),{source:a,line:u.getArg(n,"originalLine",null),column:u.getArg(n,"originalColumn",null),name:o}}}return{source:null,line:null,column:null,name:null}},t.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(i){return i==null})},t.prototype.sourceContentFor=function(i,s){if(!this.sourcesContent)return null;var e=this._findSourceIndex(i);if(e>=0)return this.sourcesContent[e];var n,a=i;if(this.sourceRoot!=null&&(a=u.relative(this.sourceRoot,a)),this.sourceRoot!=null&&(n=u.urlParse(this.sourceRoot))){var o=a.replace(/^file:\/\//,"");if(n.scheme=="file"&&this._sources.has(o))return this.sourcesContent[this._sources.indexOf(o)];if((!n.path||n.path=="/")&&this._sources.has("/"+a))return this.sourcesContent[this._sources.indexOf("/"+a)]}if(s)return null;throw new Error('"'+a+'" is not in the SourceMap.')},t.prototype.generatedPositionFor=function(i){var s=u.getArg(i,"source");if((s=this._findSourceIndex(s))<0)return{line:null,column:null,lastColumn:null};var e={source:s,originalLine:u.getArg(i,"line"),originalColumn:u.getArg(i,"column")},n=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,u.getArg(i,"bias",r.GREATEST_LOWER_BOUND));if(n>=0){var a=this._originalMappings[n];if(a.source===e.source)return{line:u.getArg(a,"generatedLine",null),column:u.getArg(a,"generatedColumn",null),lastColumn:u.getArg(a,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},E.BasicSourceMapConsumer=t,_.prototype=Object.create(r.prototype),_.prototype.constructor=r,_.prototype._version=3,Object.defineProperty(_.prototype,"sources",{get:function(){for(var i=[],s=0;s<this._sections.length;s++)for(var e=0;e<this._sections[s].consumer.sources.length;e++)i.push(this._sections[s].consumer.sources[e]);return i}}),_.prototype.originalPositionFor=function(i){var s={generatedLine:u.getArg(i,"line"),generatedColumn:u.getArg(i,"column")},e=p.search(s,this._sections,function(a,o){return a.generatedLine-o.generatedOffset.generatedLine||a.generatedColumn-o.generatedOffset.generatedColumn}),n=this._sections[e];return n?n.consumer.originalPositionFor({line:s.generatedLine-(n.generatedOffset.generatedLine-1),column:s.generatedColumn-(n.generatedOffset.generatedLine===s.generatedLine?n.generatedOffset.generatedColumn-1:0),bias:i.bias}):{source:null,line:null,column:null,name:null}},_.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(i){return i.consumer.hasContentsOfAllSources()})},_.prototype.sourceContentFor=function(i,s){for(var e=0;e<this._sections.length;e++){var n=this._sections[e].consumer.sourceContentFor(i,!0);if(n||n==="")return n}if(s)return null;throw new Error('"'+i+'" is not in the SourceMap.')},_.prototype.generatedPositionFor=function(i){for(var s=0;s<this._sections.length;s++){var e=this._sections[s];if(e.consumer._findSourceIndex(u.getArg(i,"source"))!==-1){var n=e.consumer.generatedPositionFor(i);if(n)return{line:n.line+(e.generatedOffset.generatedLine-1),column:n.column+(e.generatedOffset.generatedLine===n.line?e.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},_.prototype._parseMappings=function(i,s){this.__generatedMappings=[],this.__originalMappings=[];for(var e=0;e<this._sections.length;e++)for(var n=this._sections[e],a=n.consumer._generatedMappings,o=0;o<a.length;o++){var f=a[o],v=n.consumer._sources.at(f.source);v!==null&&(v=u.computeSourceURL(n.consumer.sourceRoot,v,this._sourceMapURL)),this._sources.add(v),v=this._sources.indexOf(v);var C=null;f.name&&(C=n.consumer._names.at(f.name),this._names.add(C),C=this._names.indexOf(C));var S={source:v,generatedLine:f.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:f.generatedColumn+(n.generatedOffset.generatedLine===f.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:f.originalLine,originalColumn:f.originalColumn,name:C};this.__generatedMappings.push(S),typeof S.originalLine=="number"&&this.__originalMappings.push(S)}c(this.__generatedMappings,u.compareByGeneratedPositionsDeflated),c(this.__originalMappings,u.compareByOriginalPositions)},E.IndexedSourceMapConsumer=_,E})().SourceMapConsumer,N.SourceNode=(function(){if(Z)return k;Z=1;var u=Q().SourceMapGenerator,p=R(),m=/(\r?\n)/,d="$$$isSourceNode$$$";function c(r,t,l,g,h){this.children=[],this.sourceContents={},this.line=r??null,this.column=t??null,this.source=l??null,this.name=h??null,this[d]=!0,g!=null&&this.add(g)}return c.fromStringWithSourceMap=function(r,t,l){var g=new c,h=r.split(m),_=0,i=function(){return o()+(o()||"");function o(){return _<h.length?h[_++]:void 0}},s=1,e=0,n=null;return t.eachMapping(function(o){if(n!==null){if(!(s<o.generatedLine)){var f=(v=h[_]||"").substr(0,o.generatedColumn-e);return h[_]=v.substr(o.generatedColumn-e),e=o.generatedColumn,a(n,f),void(n=o)}a(n,i()),s++,e=0}for(;s<o.generatedLine;)g.add(i()),s++;if(e<o.generatedColumn){var v=h[_]||"";g.add(v.substr(0,o.generatedColumn)),h[_]=v.substr(o.generatedColumn),e=o.generatedColumn}n=o},this),_<h.length&&(n&&a(n,i()),g.add(h.splice(_).join(""))),t.sources.forEach(function(o){var f=t.sourceContentFor(o);f!=null&&(l!=null&&(o=p.join(l,o)),g.setSourceContent(o,f))}),g;function a(o,f){if(o===null||o.source===void 0)g.add(f);else{var v=l?p.join(l,o.source):o.source;g.add(new c(o.originalLine,o.originalColumn,v,f,o.name))}}},c.prototype.add=function(r){if(Array.isArray(r))r.forEach(function(t){this.add(t)},this);else{if(!r[d]&&typeof r!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+r);r&&this.children.push(r)}return this},c.prototype.prepend=function(r){if(Array.isArray(r))for(var t=r.length-1;t>=0;t--)this.prepend(r[t]);else{if(!r[d]&&typeof r!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+r);this.children.unshift(r)}return this},c.prototype.walk=function(r){for(var t,l=0,g=this.children.length;l<g;l++)(t=this.children[l])[d]?t.walk(r):t!==""&&r(t,{source:this.source,line:this.line,column:this.column,name:this.name})},c.prototype.join=function(r){var t,l,g=this.children.length;if(g>0){for(t=[],l=0;l<g-1;l++)t.push(this.children[l]),t.push(r);t.push(this.children[l]),this.children=t}return this},c.prototype.replaceRight=function(r,t){var l=this.children[this.children.length-1];return l[d]?l.replaceRight(r,t):typeof l=="string"?this.children[this.children.length-1]=l.replace(r,t):this.children.push("".replace(r,t)),this},c.prototype.setSourceContent=function(r,t){this.sourceContents[p.toSetString(r)]=t},c.prototype.walkSourceContents=function(r){for(var t=0,l=this.children.length;t<l;t++)this.children[t][d]&&this.children[t].walkSourceContents(r);var g=Object.keys(this.sourceContents);for(t=0,l=g.length;t<l;t++)r(p.fromSetString(g[t]),this.sourceContents[g[t]])},c.prototype.toString=function(){var r="";return this.walk(function(t){r+=t}),r},c.prototype.toStringWithSourceMap=function(r){var t={code:"",line:1,column:0},l=new u(r),g=!1,h=null,_=null,i=null,s=null;return this.walk(function(e,n){t.code+=e,n.source!==null&&n.line!==null&&n.column!==null?(h===n.source&&_===n.line&&i===n.column&&s===n.name||l.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:t.line,column:t.column},name:n.name}),h=n.source,_=n.line,i=n.column,s=n.name,g=!0):g&&(l.addMapping({generated:{line:t.line,column:t.column}}),h=null,g=!1);for(var a=0,o=e.length;a<o;a++)e.charCodeAt(a)===10?(t.line++,t.column=0,a+1===o?(h=null,g=!1):g&&l.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:t.line,column:t.column},name:n.name})):t.column++}),this.walkSourceContents(function(e,n){l.setSourceContent(e,n)}),{code:t.code,map:l}},k.SourceNode=c,k})().SourceNode),N);exports.sourceMapExports=ae;
|
|
@@ -32,7 +32,7 @@ export declare class BaseTransmitter {
|
|
|
32
32
|
protected get queryName(): string;
|
|
33
33
|
/**
|
|
34
34
|
* Generates default variables to be included in GraphQL queries.
|
|
35
|
-
* These variables include the API key, service UUID, session ID, and
|
|
35
|
+
* These variables include the API key, service UUID, session ID, timestamp, and parentSpanId.
|
|
36
36
|
*
|
|
37
37
|
* @returns An object containing the default variables for the request.
|
|
38
38
|
*/
|
|
@@ -41,6 +41,7 @@ export declare class BaseTransmitter {
|
|
|
41
41
|
serviceUuid: string;
|
|
42
42
|
sessionId: string;
|
|
43
43
|
timestampMs: string;
|
|
44
|
+
parentSpanId: string;
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* Merges the default variables with any additional variables passed as arguments.
|
|
@@ -5,6 +5,7 @@ export declare const DEFAULT_DOMAINS_TO_EXCLUDE: readonly ["identitytoolkit.goog
|
|
|
5
5
|
type Context = {
|
|
6
6
|
traceId?: string;
|
|
7
7
|
pageVisitUUID?: string;
|
|
8
|
+
currentFunctionSpanId?: string;
|
|
8
9
|
handledExceptions: Set<any>;
|
|
9
10
|
reentrancyGuardLoggingActive: boolean;
|
|
10
11
|
reentrancyGuardLoggingPreActive: boolean;
|
|
@@ -40,6 +41,9 @@ export declare class ContextManager {
|
|
|
40
41
|
getPageVisitUUID(): string | undefined;
|
|
41
42
|
setTraceId(traceId: string): void;
|
|
42
43
|
setPageVisitUUID(pageVisitUUID: string): void;
|
|
44
|
+
getCurrentFunctionSpanId(): string | undefined;
|
|
45
|
+
setCurrentFunctionSpanId(spanId: string): void;
|
|
46
|
+
clearCurrentFunctionSpanId(): void;
|
|
43
47
|
getOrSetSfTraceId(newTraceIdIfNotSet?: string, isAssociatedWithInboundRequest?: boolean): string;
|
|
44
48
|
getOrSetPageVisitUUID(): string;
|
|
45
49
|
getHandledExceptions(): Set<any>;
|
|
@@ -54,4 +58,23 @@ export declare class ContextManager {
|
|
|
54
58
|
}
|
|
55
59
|
export declare function runWithContext(fn: Function): void;
|
|
56
60
|
export declare function runWithSession(sessionId: string, fn: Function): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get the current function span ID for linking telemetry events.
|
|
63
|
+
*
|
|
64
|
+
* This is async-safe and uses AsyncLocalStorage for proper request isolation.
|
|
65
|
+
* Returns undefined if:
|
|
66
|
+
* - No active function span
|
|
67
|
+
* - Called outside of a function span context
|
|
68
|
+
*
|
|
69
|
+
* Usage:
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { getCurrentFunctionSpanId } from '@sailfish-ai/sf-veritas';
|
|
72
|
+
*
|
|
73
|
+
* const parentSpanId = getCurrentFunctionSpanId();
|
|
74
|
+
* // Use parentSpanId to link logs, exceptions, or network requests to the current function span
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @returns Current function span ID, or undefined if not in a function span
|
|
78
|
+
*/
|
|
79
|
+
export declare function getCurrentFunctionSpanId(): string | undefined;
|
|
57
80
|
export {};
|
|
@@ -53,7 +53,7 @@ export declare class ExceptionTransmitter extends BaseTransmitter {
|
|
|
53
53
|
send(exceptionMessage: string, trace: FrameInfo[]): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* Generates the GraphQL mutation query for reporting the exception.
|
|
56
|
-
* Adds optional $isFromLocalService: Boolean and forwards
|
|
56
|
+
* Adds optional $isFromLocalService: Boolean and $parentSpanId: String and forwards them when provided.
|
|
57
57
|
*
|
|
58
58
|
* @returns The GraphQL mutation query string.
|
|
59
59
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function Span Capture Runtime
|
|
3
|
+
*
|
|
4
|
+
* Provides the runtime function that wraps instrumented functions to capture
|
|
5
|
+
* their execution details (arguments, return values, timing, etc.)
|
|
6
|
+
*
|
|
7
|
+
* Implements full configuration system with HTTP header overrides, .sailfish files,
|
|
8
|
+
* sampling, and size limits.
|
|
9
|
+
*/
|
|
10
|
+
export interface FunctionSpanMetadata {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
paramNames: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a function to capture its execution as a span
|
|
17
|
+
*
|
|
18
|
+
* @param fn - The function to wrap
|
|
19
|
+
* @param functionName - The name of the function
|
|
20
|
+
* @param filePath - The file path where the function is defined
|
|
21
|
+
* @param metadata - Additional metadata (line, column, parameter names)
|
|
22
|
+
* @returns The wrapped function
|
|
23
|
+
*/
|
|
24
|
+
export declare function captureFunctionSpan<T extends Function>(fn: T, functionName: string, filePath: string, metadata: FunctionSpanMetadata): T;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function Span Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines configuration interfaces and provides runtime config lookup
|
|
5
|
+
* with support for HTTP header overrides, .sailfish files, and environment variables.
|
|
6
|
+
*
|
|
7
|
+
* Configuration hierarchy (highest to lowest priority):
|
|
8
|
+
* 1. HTTP Header X-Sf3-FunctionSpanCaptureOverride (per-request)
|
|
9
|
+
* 2. Function-level config in .sailfish (functions: section)
|
|
10
|
+
* 3. File-level config in .sailfish (files: section)
|
|
11
|
+
* 4. Directory .sailfish (cascades down)
|
|
12
|
+
* 5. Parent directory .sailfish (inherited)
|
|
13
|
+
* 6. Environment variables SF_FUNCSPAN_*
|
|
14
|
+
* 7. Hard-coded defaults
|
|
15
|
+
*/
|
|
16
|
+
export interface FuncspanConfig {
|
|
17
|
+
/** Capture function input arguments */
|
|
18
|
+
capture_arguments: boolean;
|
|
19
|
+
/** Capture function return values */
|
|
20
|
+
capture_return_value: boolean;
|
|
21
|
+
/** Maximum size in MB for capturing arguments */
|
|
22
|
+
arg_limit_mb: number;
|
|
23
|
+
/** Maximum size in MB for capturing return values */
|
|
24
|
+
return_limit_mb: number;
|
|
25
|
+
/** Also capture all functions called by this function */
|
|
26
|
+
autocapture_all_child_functions: boolean;
|
|
27
|
+
/** Sample rate: 1.0 = 100%, 0.1 = 10%, 0.0 = disabled */
|
|
28
|
+
sample_rate: number;
|
|
29
|
+
/** Enable probabilistic sampling based on sample_rate */
|
|
30
|
+
enable_sampling: boolean;
|
|
31
|
+
/** Capture internal Sailfish library functions */
|
|
32
|
+
capture_sf_veritas: boolean;
|
|
33
|
+
/** Attempt to parse JSON strings in arguments/returns */
|
|
34
|
+
parse_json_strings: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parsed HTTP header override
|
|
38
|
+
* Header format: args-ret-argMB-retMB-children-rate-sampling-sfVeritas-parseJson
|
|
39
|
+
* Example: "1-1-10-10-1-1.0-1-0-0"
|
|
40
|
+
*/
|
|
41
|
+
export interface FuncspanHeaderOverride extends FuncspanConfig {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Environment variable configuration
|
|
45
|
+
*/
|
|
46
|
+
export declare function getEnvConfig(): FuncspanConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Default configuration (used when no .sailfish files exist)
|
|
49
|
+
*
|
|
50
|
+
* Sets sample_rate to 0.0 to completely disable capture when no .sailfish files are present.
|
|
51
|
+
* This makes function span capture opt-in: you must create a .sailfish file to enable it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getDefaultConfig(): FuncspanConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Parse HTTP header override
|
|
56
|
+
* Format: args-ret-argMB-retMB-children-rate-sampling-sfVeritas-parseJson
|
|
57
|
+
* Example: "1-1-10-10-1-1.0-1-0-0"
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseHeaderOverride(header: string): FuncspanHeaderOverride | null;
|
|
60
|
+
/**
|
|
61
|
+
* Set funcspan override from HTTP header (per-request)
|
|
62
|
+
*/
|
|
63
|
+
export declare function setFuncspanOverride(headerValue: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Get funcspan override from current request context
|
|
66
|
+
*/
|
|
67
|
+
export declare function getFuncspanOverride(): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Clear funcspan override (usually at end of request)
|
|
70
|
+
*/
|
|
71
|
+
export declare function clearFuncspanOverride(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Merge configurations with priority
|
|
74
|
+
*/
|
|
75
|
+
export declare function mergeConfigs(...configs: Partial<FuncspanConfig>[]): FuncspanConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Check if size exceeds limit
|
|
78
|
+
*/
|
|
79
|
+
export declare function exceedsSizeLimit(data: any, limitMB: number): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Truncate data if it exceeds size limit
|
|
82
|
+
*/
|
|
83
|
+
export declare function truncateToLimit(data: any, limitMB: number): any;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function Span Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Scans directory tree for .sailfish files at startup.
|
|
5
|
+
* Parses YAML/JSON configuration files.
|
|
6
|
+
* Builds lookup tables for ultra-fast runtime config resolution.
|
|
7
|
+
*
|
|
8
|
+
* Configuration hierarchy (highest to lowest priority):
|
|
9
|
+
* 1. HTTP Header X-Sf3-FunctionSpanCaptureOverride
|
|
10
|
+
* 2. Function config in .sailfish (functions: section)
|
|
11
|
+
* 3. File config in .sailfish (files: section)
|
|
12
|
+
* 4. Directory .sailfish (cascades down)
|
|
13
|
+
* 5. Parent directory .sailfish (inherited)
|
|
14
|
+
* 6. Environment variables SF_FUNCSPAN_*
|
|
15
|
+
* 7. Hard-coded defaults
|
|
16
|
+
*/
|
|
17
|
+
import { type FuncspanConfig } from "./funcSpanConfig";
|
|
18
|
+
export declare class FuncspanConfigLoader {
|
|
19
|
+
private rootPaths;
|
|
20
|
+
private fileConfigs;
|
|
21
|
+
private functionConfigs;
|
|
22
|
+
private directoryConfigs;
|
|
23
|
+
private hasSailfishFiles;
|
|
24
|
+
private debug;
|
|
25
|
+
constructor(rootPaths?: string[], debug?: boolean);
|
|
26
|
+
/**
|
|
27
|
+
* Load all .sailfish files and build lookup tables
|
|
28
|
+
*/
|
|
29
|
+
loadAllConfigs(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Get configuration for a specific file and function
|
|
32
|
+
*/
|
|
33
|
+
getConfig(filePath: string, functionName?: string): FuncspanConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Walk directory recursively looking for .sailfish files
|
|
36
|
+
*/
|
|
37
|
+
private _walkDirectory;
|
|
38
|
+
/**
|
|
39
|
+
* Load and parse a single .sailfish file
|
|
40
|
+
*/
|
|
41
|
+
private _loadConfigFile;
|
|
42
|
+
/**
|
|
43
|
+
* Expand glob patterns to actual file paths
|
|
44
|
+
*/
|
|
45
|
+
private _expandFileGlobs;
|
|
46
|
+
/**
|
|
47
|
+
* Store function-specific configs
|
|
48
|
+
*/
|
|
49
|
+
private _storeFunctionConfigs;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve inheritance (not implemented yet - currently each config is standalone)
|
|
52
|
+
*/
|
|
53
|
+
private _resolveInheritance;
|
|
54
|
+
/**
|
|
55
|
+
* Get directory config by walking up the tree
|
|
56
|
+
*/
|
|
57
|
+
private _getDirectoryConfig;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Initialize global config loader
|
|
61
|
+
*/
|
|
62
|
+
export declare function initializeConfigLoader(rootPaths?: string[], debug?: boolean): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get configuration for a file and function
|
|
65
|
+
*/
|
|
66
|
+
export declare function getGlobalConfig(filePath: string, functionName?: string): FuncspanConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Check if global config loader has been initialized
|
|
69
|
+
*/
|
|
70
|
+
export declare function isConfigLoaderInitialized(): boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { ContextManager, runWithContext } from "./contextManager";
|
|
1
|
+
export { ContextManager, runWithContext, getCurrentFunctionSpanId } from "./contextManager";
|
|
2
2
|
export { addOrUpdateMetadata, identify, setupInterceptors } from "./unifiedInterceptor";
|
|
3
|
+
export { captureFunctionSpan, type FunctionSpanMetadata } from "./funcSpanCapture";
|
|
4
|
+
export { type FuncspanConfig, type FuncspanHeaderOverride, setFuncspanOverride, getFuncspanOverride, clearFuncspanOverride, parseHeaderOverride, getEnvConfig, getDefaultConfig, } from "./funcSpanConfig";
|
|
5
|
+
export { initializeConfigLoader, getGlobalConfig, isConfigLoaderInitialized, } from "./funcSpanConfigLoader";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function Span AST Transformer
|
|
3
|
+
*
|
|
4
|
+
* Transforms JavaScript/TypeScript code to wrap functions with captureFunctionSpan()
|
|
5
|
+
* for automatic instrumentation.
|
|
6
|
+
*/
|
|
7
|
+
export interface TransformOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Project root directory for resolving relative paths
|
|
10
|
+
*/
|
|
11
|
+
projectRoot?: string;
|
|
12
|
+
/**
|
|
13
|
+
* List of node_modules packages to instrument (e.g., ['express', 'axios'])
|
|
14
|
+
* If empty, only user code is instrumented
|
|
15
|
+
*/
|
|
16
|
+
includeNodeModules?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Enable debug logging
|
|
19
|
+
*/
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface TransformResult {
|
|
23
|
+
code: string;
|
|
24
|
+
map?: any;
|
|
25
|
+
modified: boolean;
|
|
26
|
+
functionsWrapped: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Transform JavaScript/TypeScript source code to wrap functions
|
|
30
|
+
*/
|
|
31
|
+
export declare function transformFunctionSpans(source: string, filePath: string, options?: TransformOptions): Promise<TransformResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Esbuild Plugin for Function Span Instrumentation
|
|
3
|
+
*
|
|
4
|
+
* Transforms TypeScript/JavaScript files during the Esbuild build process
|
|
5
|
+
* to inject function span capture.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { funcspanEsbuildPlugin } = require('@sailfish-ai/sf-veritas/funcspan-esbuild');
|
|
9
|
+
*
|
|
10
|
+
* require('esbuild').build({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* funcspanEsbuildPlugin({ debug: true })
|
|
13
|
+
* ]
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
import type { Plugin } from "esbuild";
|
|
17
|
+
import { TransformOptions } from "./funcSpanTransformer";
|
|
18
|
+
export interface FuncspanEsbuildPluginOptions extends Omit<TransformOptions, "projectRoot"> {
|
|
19
|
+
/**
|
|
20
|
+
* Enable the plugin (default: true)
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Esbuild plugin for automatic function span instrumentation
|
|
26
|
+
*/
|
|
27
|
+
export declare function funcspanEsbuildPlugin(options?: FuncspanEsbuildPluginOptions): Plugin;
|
|
28
|
+
export default funcspanEsbuildPlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rollup Plugin for Function Span Instrumentation
|
|
3
|
+
*
|
|
4
|
+
* Transforms TypeScript/JavaScript files during the Rollup build process
|
|
5
|
+
* to inject function span capture.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { funcspanRollupPlugin } from '@sailfish-ai/sf-veritas/funcspan-rollup';
|
|
9
|
+
*
|
|
10
|
+
* export default {
|
|
11
|
+
* plugins: [
|
|
12
|
+
* funcspanRollupPlugin({ debug: true })
|
|
13
|
+
* ]
|
|
14
|
+
* };
|
|
15
|
+
*/
|
|
16
|
+
import type { Plugin } from "rollup";
|
|
17
|
+
import { TransformOptions } from "./funcSpanTransformer";
|
|
18
|
+
export interface FuncspanRollupPluginOptions extends Omit<TransformOptions, "projectRoot"> {
|
|
19
|
+
/**
|
|
20
|
+
* Enable the plugin (default: true)
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Rollup plugin for automatic function span instrumentation
|
|
26
|
+
*/
|
|
27
|
+
export declare function funcspanRollupPlugin(options?: FuncspanRollupPluginOptions): Plugin;
|
|
28
|
+
export default funcspanRollupPlugin;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Compiler Post-Build Plugin
|
|
3
|
+
*
|
|
4
|
+
* Processes compiled JavaScript files after `tsc` runs to inject
|
|
5
|
+
* function span instrumentation.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* In package.json:
|
|
9
|
+
* "scripts": {
|
|
10
|
+
* "build": "tsc && node -e \"require('@sailfish-ai/sf-veritas/funcspan-tsc').process()\""
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
import { TransformOptions } from "./funcSpanTransformer";
|
|
14
|
+
export interface TscPluginOptions extends TransformOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Output directory where TypeScript compiled the files (default: 'dist')
|
|
17
|
+
*/
|
|
18
|
+
outDir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* File patterns to process (default: all .js files)
|
|
21
|
+
*/
|
|
22
|
+
include?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* File patterns to exclude
|
|
25
|
+
*/
|
|
26
|
+
exclude?: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Process compiled JavaScript files and inject function span instrumentation
|
|
30
|
+
*/
|
|
31
|
+
export declare function processTscFiles(options?: TscPluginOptions): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* CLI entry point
|
|
34
|
+
*/
|
|
35
|
+
export declare function cli(): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite Plugin for Function Span Instrumentation
|
|
3
|
+
*
|
|
4
|
+
* Transforms TypeScript/JavaScript files during the Vite build process
|
|
5
|
+
* to inject function span capture.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { funcspanVitePlugin } from '@sailfish-ai/sf-veritas/funcspan-vite';
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* funcspanVitePlugin({ debug: true })
|
|
13
|
+
* ]
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
import type { Plugin } from "vite";
|
|
17
|
+
import { TransformOptions } from "./funcSpanTransformer";
|
|
18
|
+
export interface FuncspanVitePluginOptions extends Omit<TransformOptions, "projectRoot"> {
|
|
19
|
+
/**
|
|
20
|
+
* Enable the plugin (default: true)
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Vite plugin for automatic function span instrumentation
|
|
26
|
+
*/
|
|
27
|
+
export declare function funcspanVitePlugin(options?: FuncspanVitePluginOptions): Plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function funcspanWebpackLoader(this: any, source: string): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack Plugin for Function Span Instrumentation
|
|
3
|
+
*
|
|
4
|
+
* Transforms TypeScript/JavaScript files during the Webpack build process
|
|
5
|
+
* to inject function span capture.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { FuncspanWebpackPlugin } = require('@sailfish-ai/sf-veritas/funcspan-webpack');
|
|
9
|
+
*
|
|
10
|
+
* module.exports = {
|
|
11
|
+
* plugins: [
|
|
12
|
+
* new FuncspanWebpackPlugin({ debug: true })
|
|
13
|
+
* ]
|
|
14
|
+
* };
|
|
15
|
+
*/
|
|
16
|
+
import type { Compiler } from "webpack";
|
|
17
|
+
import { TransformOptions } from "./funcSpanTransformer";
|
|
18
|
+
export interface FuncspanWebpackPluginOptions extends Omit<TransformOptions, "projectRoot"> {
|
|
19
|
+
/**
|
|
20
|
+
* Enable the plugin (default: true)
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Webpack plugin for automatic function span instrumentation
|
|
26
|
+
*/
|
|
27
|
+
export declare class FuncspanWebpackPlugin {
|
|
28
|
+
private options;
|
|
29
|
+
constructor(options?: FuncspanWebpackPluginOptions);
|
|
30
|
+
apply(compiler: Compiler): void;
|
|
31
|
+
}
|
|
32
|
+
export default FuncspanWebpackPlugin;
|
package/package.json
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sailfish-ai/sf-veritas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"publishPublicly": true,
|
|
5
5
|
"description": "A versatile Edge Runtime-compatible package for JavaScript and TypeScript backend systems and scripts.",
|
|
6
6
|
"main": "./dist/sf-veritas.cjs",
|
|
7
7
|
"module": "./dist/sf-veritas.mjs",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/sf-veritas.mjs",
|
|
13
|
+
"require": "./dist/sf-veritas.cjs",
|
|
14
|
+
"types": "./dist/types/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./funcspan-webpack": {
|
|
17
|
+
"import": "./dist/plugins/funcspanWebpackPlugin.mjs",
|
|
18
|
+
"require": "./dist/plugins/funcspanWebpackPlugin.cjs",
|
|
19
|
+
"types": "./dist/types/plugins/funcspanWebpackPlugin.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./funcspan-vite": {
|
|
22
|
+
"import": "./dist/plugins/funcspanVitePlugin.mjs",
|
|
23
|
+
"require": "./dist/plugins/funcspanVitePlugin.cjs",
|
|
24
|
+
"types": "./dist/types/plugins/funcspanVitePlugin.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./funcspan-rollup": {
|
|
27
|
+
"import": "./dist/plugins/funcspanRollupPlugin.mjs",
|
|
28
|
+
"require": "./dist/plugins/funcspanRollupPlugin.cjs",
|
|
29
|
+
"types": "./dist/types/plugins/funcspanRollupPlugin.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./funcspan-esbuild": {
|
|
32
|
+
"import": "./dist/plugins/funcspanEsbuildPlugin.mjs",
|
|
33
|
+
"require": "./dist/plugins/funcspanEsbuildPlugin.cjs",
|
|
34
|
+
"types": "./dist/types/plugins/funcspanEsbuildPlugin.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./funcspan-tsc": {
|
|
37
|
+
"import": "./dist/plugins/funcspanTscPlugin.mjs",
|
|
38
|
+
"require": "./dist/plugins/funcspanTscPlugin.cjs",
|
|
39
|
+
"types": "./dist/types/plugins/funcspanTscPlugin.d.ts"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
10
42
|
"scripts": {
|
|
11
43
|
"build:types": "vite build --mode types",
|
|
12
44
|
"dev": "vite",
|
|
@@ -27,21 +59,35 @@
|
|
|
27
59
|
],
|
|
28
60
|
"author": "SailfishAI",
|
|
29
61
|
"dependencies": {
|
|
62
|
+
"@babel/core": "^7.26.0",
|
|
63
|
+
"@babel/generator": "^7.26.0",
|
|
64
|
+
"@babel/parser": "^7.26.0",
|
|
65
|
+
"@babel/traverse": "^7.26.0",
|
|
66
|
+
"@babel/types": "^7.26.0",
|
|
67
|
+
"glob": "^11.0.0",
|
|
68
|
+
"js-yaml": "^4.1.0",
|
|
30
69
|
"next": "^15.1.7",
|
|
31
70
|
"source-map-js": "^1.2.1",
|
|
32
71
|
"uuid": "^11.1.0"
|
|
33
72
|
},
|
|
34
73
|
"devDependencies": {
|
|
35
74
|
"@rollup/plugin-terser": "^0.4.4",
|
|
75
|
+
"@types/babel__core": "^7.20.5",
|
|
76
|
+
"@types/babel__generator": "^7.6.8",
|
|
77
|
+
"@types/babel__traverse": "^7.20.6",
|
|
78
|
+
"@types/js-yaml": "^4.0.9",
|
|
36
79
|
"@types/node": "^22.13.10",
|
|
80
|
+
"@types/uuid": "^10.0.0",
|
|
81
|
+
"@types/webpack": "^5.28.5",
|
|
82
|
+
"esbuild": "^0.23.0",
|
|
37
83
|
"eslint": "^9.22.0",
|
|
38
84
|
"eslint-config-next": "^15.2.3",
|
|
39
|
-
"@types/uuid": "^10.0.0",
|
|
40
85
|
"rollup": "^3.29.5",
|
|
41
86
|
"rollup-plugin-dts": "^5.3.1",
|
|
42
87
|
"ts-node": "^10.9.2",
|
|
43
88
|
"typescript": "^5.8.2",
|
|
44
|
-
"vite": "^6.2.2"
|
|
89
|
+
"vite": "^6.2.2",
|
|
90
|
+
"webpack": "^5.95.0"
|
|
45
91
|
},
|
|
46
92
|
"files": [
|
|
47
93
|
"dist"
|