@sailfish-ai/sf-veritas 0.2.6 → 0.2.7
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-BLhIRZqX.js +765 -0
- package/dist/funcSpanTransformer-BpWuHXKT.cjs +1 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +1 -1
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +1 -1
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
- package/dist/sf-veritas.cjs +15 -15
- package/dist/sf-veritas.mjs +367 -324
- package/dist/types/funcSpanConfig.d.ts +8 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/unifiedInterceptor.d.ts +4 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/{workerPoolSpanCapture-BOnYC4s3.js → workerPoolSpanCapture-D0-0Z0Jw.js} +169 -156
- package/dist/workerPoolSpanCapture-DEwlTq0a.cjs +86 -0
- package/package.json +1 -1
- package/dist/funcSpanTransformer-TjdooSrw.cjs +0 -1
- package/dist/funcSpanTransformer-sqmZLAcs.js +0 -750
- package/dist/workerPoolSpanCapture-CNEouInA.cjs +0 -83
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const pe=require("@babel/parser"),z=require("@babel/traverse"),J=require("@babel/generator"),ge=require("@babel/types"),P=require("path"),de=require("fs");function fe(u){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const m in u)if(m!=="default"){const _=Object.getOwnPropertyDescriptor(u,m);Object.defineProperty(p,m,_.get?_:{enumerable:!0,get:()=>u[m]})}}return p.default=u,Object.freeze(p)}const s=fe(ge);var V,K,$={},G={},N={},T={};function he(){if(V)return T;V=1;var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return T.encode=function(p){if(0<=p&&p<u.length)return u[p];throw new TypeError("Must be between 0 and 63: "+p)},T.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},T}function le(){if(K)return N;K=1;var u=he();return N.encode=function(p){var m,_="",d=(function(t){return t<0?1+(-t<<1):0+(t<<1)})(p);do m=31&d,(d>>>=5)>0&&(m|=32),_+=u.encode(m);while(d>0);return _},N.decode=function(p,m,_){var d,t,o,c,f=p.length,h=0,v=0;do{if(m>=f)throw new Error("Expected more digits in base 64 VLQ value.");if((t=u.decode(p.charCodeAt(m++)))===-1)throw new Error("Invalid base64 digit: "+p.charAt(m-1));d=!!(32&t),h+=(t&=31)<<v,v+=5}while(d);_.value=(c=(o=h)>>1,1&~o?c:-c),_.rest=m},N}var Q,H={};function x(){return Q||(Q=1,(function(u){u.getArg=function(n,e,i){if(e in n)return n[e];if(arguments.length===3)return i;throw new Error('"'+e+'" is a required argument.')};var p=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,m=/^data:.+\,.+$/;function _(n){var e=n.match(p);return e?{scheme:e[1],auth:e[2],host:e[3],port:e[4],path:e[5]}:null}function d(n){var e="";return n.scheme&&(e+=n.scheme+":"),e+="//",n.auth&&(e+=n.auth+"@"),n.host&&(e+=n.host),n.port&&(e+=":"+n.port),n.path&&(e+=n.path),e}u.urlParse=_,u.urlGenerate=d;var t,o,c=(t=function(n){var e=n,i=_(n);if(i){if(!i.path)return n;e=i.path}for(var r=u.isAbsolute(e),g=[],y=0,S=0;;){if(y=S,(S=e.indexOf("/",y))===-1){g.push(e.slice(y));break}for(g.push(e.slice(y,S));S<e.length&&e[S]==="/";)S++}var L,C=0;for(S=g.length-1;S>=0;S--)(L=g[S])==="."?g.splice(S,1):L===".."?C++:C>0&&(L===""?(g.splice(S+1,C),C=0):(g.splice(S,2),C--));return(e=g.join("/"))===""&&(e=r?"/":"."),i?(i.path=e,d(i)):e},o=[],function(n){for(var e=0;e<o.length;e++)if(o[e].input===n){var i=o[0];return o[0]=o[e],o[e]=i,o[0].result}var r=t(n);return o.unshift({input:n,result:r}),o.length>32&&o.pop(),r});function f(n,e){n===""&&(n="."),e===""&&(e=".");var i=_(e),r=_(n);if(r&&(n=r.path||"/"),i&&!i.scheme)return r&&(i.scheme=r.scheme),d(i);if(i||e.match(m))return e;if(r&&!r.host&&!r.path)return r.host=e,d(r);var g=e.charAt(0)==="/"?e:c(n.replace(/\/+$/,"")+"/"+e);return r?(r.path=g,d(r)):g}u.normalize=c,u.join=f,u.isAbsolute=function(n){return n.charAt(0)==="/"||p.test(n)},u.relative=function(n,e){n===""&&(n="."),n=n.replace(/\/$/,"");for(var i=0;e.indexOf(n+"/")!==0;){var r=n.lastIndexOf("/");if(r<0||(n=n.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return e;++i}return Array(i+1).join("../")+e.substr(n.length+1)};var h=!("__proto__"in Object.create(null));function v(n){return n}function a(n){if(!n)return!1;var e=n.length;if(e<9||n.charCodeAt(e-1)!==95||n.charCodeAt(e-2)!==95||n.charCodeAt(e-3)!==111||n.charCodeAt(e-4)!==116||n.charCodeAt(e-5)!==111||n.charCodeAt(e-6)!==114||n.charCodeAt(e-7)!==112||n.charCodeAt(e-8)!==95||n.charCodeAt(e-9)!==95)return!1;for(var i=e-10;i>=0;i--)if(n.charCodeAt(i)!==36)return!1;return!0}function l(n,e){return n===e?0:n===null?1:e===null?-1:n>e?1:-1}u.toSetString=h?v:function(n){return a(n)?"$"+n:n},u.fromSetString=h?v:function(n){return a(n)?n.slice(1):n},u.compareByOriginalPositions=function(n,e,i){var r=l(n.source,e.source);return r!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0||i||(r=n.generatedColumn-e.generatedColumn)!==0||(r=n.generatedLine-e.generatedLine)!==0?r:l(n.name,e.name)},u.compareByOriginalPositionsNoSource=function(n,e,i){var r;return(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0||i||(r=n.generatedColumn-e.generatedColumn)!==0||(r=n.generatedLine-e.generatedLine)!==0?r:l(n.name,e.name)},u.compareByGeneratedPositionsDeflated=function(n,e,i){var r=n.generatedLine-e.generatedLine;return r!==0||(r=n.generatedColumn-e.generatedColumn)!==0||i||(r=l(n.source,e.source))!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0?r:l(n.name,e.name)},u.compareByGeneratedPositionsDeflatedNoLine=function(n,e,i){var r=n.generatedColumn-e.generatedColumn;return r!==0||i||(r=l(n.source,e.source))!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0?r:l(n.name,e.name)},u.compareByGeneratedPositionsInflated=function(n,e){var i=n.generatedLine-e.generatedLine;return i!==0||(i=n.generatedColumn-e.generatedColumn)!==0||(i=l(n.source,e.source))!==0||(i=n.originalLine-e.originalLine)!==0||(i=n.originalColumn-e.originalColumn)!==0?i:l(n.name,e.name)},u.parseSourceMapInput=function(n){return JSON.parse(n.replace(/^\)]}'[^\n]*\n/,""))},u.computeSourceURL=function(n,e,i){if(e=e||"",n&&(n[n.length-1]!=="/"&&e[0]!=="/"&&(n+="/"),e=n+e),i){var r=_(i);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var g=r.path.lastIndexOf("/");g>=0&&(r.path=r.path.substring(0,g+1))}e=f(d(r),e)}return c(e)}})(H)),H}var X,D={};function ce(){if(X)return D;X=1;var u=x(),p=Object.prototype.hasOwnProperty,m=typeof Map<"u";function _(){this._array=[],this._set=m?new Map:Object.create(null)}return _.fromArray=function(d,t){for(var o=new _,c=0,f=d.length;c<f;c++)o.add(d[c],t);return o},_.prototype.size=function(){return m?this._set.size:Object.getOwnPropertyNames(this._set).length},_.prototype.add=function(d,t){var o=m?d:u.toSetString(d),c=m?this.has(d):p.call(this._set,o),f=this._array.length;c&&!t||this._array.push(d),c||(m?this._set.set(d,f):this._set[o]=f)},_.prototype.has=function(d){if(m)return this._set.has(d);var t=u.toSetString(d);return p.call(this._set,t)},_.prototype.indexOf=function(d){if(m){var t=this._set.get(d);if(t>=0)return t}else{var o=u.toSetString(d);if(p.call(this._set,o))return this._set[o]}throw new Error('"'+d+'" is not in the set.')},_.prototype.at=function(d){if(d>=0&&d<this._array.length)return this._array[d];throw new Error("No element indexed by "+d)},_.prototype.toArray=function(){return this._array.slice()},D.ArraySet=_,D}var Y,Z,U={};function me(){if(Y)return U;Y=1;var u=x();function p(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return p.prototype.unsortedForEach=function(m,_){this._array.forEach(m,_)},p.prototype.add=function(m){var _,d,t,o,c,f;_=this._last,d=m,t=_.generatedLine,o=d.generatedLine,c=_.generatedColumn,f=d.generatedColumn,o>t||o==t&&f>=c||u.compareByGeneratedPositionsInflated(_,d)<=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},U.MappingList=p,U}function ee(){if(Z)return G;Z=1;var u=le(),p=x(),m=ce().ArraySet,_=me().MappingList;function d(t){t||(t={}),this._file=p.getArg(t,"file",null),this._sourceRoot=p.getArg(t,"sourceRoot",null),this._skipValidation=p.getArg(t,"skipValidation",!1),this._ignoreInvalidMapping=p.getArg(t,"ignoreInvalidMapping",!1),this._sources=new m,this._names=new m,this._mappings=new _,this._sourcesContents=null}return d.prototype._version=3,d.fromSourceMap=function(t,o){var c=t.sourceRoot,f=new d(Object.assign(o||{},{file:t.file,sourceRoot:c}));return t.eachMapping(function(h){var v={generated:{line:h.generatedLine,column:h.generatedColumn}};h.source!=null&&(v.source=h.source,c!=null&&(v.source=p.relative(c,v.source)),v.original={line:h.originalLine,column:h.originalColumn},h.name!=null&&(v.name=h.name)),f.addMapping(v)}),t.sources.forEach(function(h){var v=h;c!==null&&(v=p.relative(c,h)),f._sources.has(v)||f._sources.add(v);var a=t.sourceContentFor(h);a!=null&&f.setSourceContent(h,a)}),f},d.prototype.addMapping=function(t){var o=p.getArg(t,"generated"),c=p.getArg(t,"original",null),f=p.getArg(t,"source",null),h=p.getArg(t,"name",null);(this._skipValidation||this._validateMapping(o,c,f,h)!==!1)&&(f!=null&&(f=String(f),this._sources.has(f)||this._sources.add(f)),h!=null&&(h=String(h),this._names.has(h)||this._names.add(h)),this._mappings.add({generatedLine:o.line,generatedColumn:o.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:f,name:h}))},d.prototype.setSourceContent=function(t,o){var c=t;this._sourceRoot!=null&&(c=p.relative(this._sourceRoot,c)),o!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[p.toSetString(c)]=o):this._sourcesContents&&(delete this._sourcesContents[p.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},d.prototype.applySourceMap=function(t,o,c){var f=o;if(o==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);f=t.file}var h=this._sourceRoot;h!=null&&(f=p.relative(h,f));var v=new m,a=new m;this._mappings.unsortedForEach(function(l){if(l.source===f&&l.originalLine!=null){var n=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});n.source!=null&&(l.source=n.source,c!=null&&(l.source=p.join(c,l.source)),h!=null&&(l.source=p.relative(h,l.source)),l.originalLine=n.line,l.originalColumn=n.column,n.name!=null&&(l.name=n.name))}var e=l.source;e==null||v.has(e)||v.add(e);var i=l.name;i==null||a.has(i)||a.add(i)},this),this._sources=v,this._names=a,t.sources.forEach(function(l){var n=t.sourceContentFor(l);n!=null&&(c!=null&&(l=p.join(c,l)),h!=null&&(l=p.relative(h,l)),this.setSourceContent(l,n))},this)},d.prototype._validateMapping=function(t,o,c,f){if(o&&typeof o.line!="number"&&typeof o.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((!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0)||o||c||f)&&!(t&&"line"in t&&"column"in t&&o&&"line"in o&&"column"in o&&t.line>0&&t.column>=0&&o.line>0&&o.column>=0&&c)){if(h="Invalid mapping: "+JSON.stringify({generated:t,source:c,original:o,name:f}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}},d.prototype._serializeMappings=function(){for(var t,o,c,f,h=0,v=1,a=0,l=0,n=0,e=0,i="",r=this._mappings.toArray(),g=0,y=r.length;g<y;g++){if(t="",(o=r[g]).generatedLine!==v)for(h=0;o.generatedLine!==v;)t+=";",v++;else if(g>0){if(!p.compareByGeneratedPositionsInflated(o,r[g-1]))continue;t+=","}t+=u.encode(o.generatedColumn-h),h=o.generatedColumn,o.source!=null&&(f=this._sources.indexOf(o.source),t+=u.encode(f-e),e=f,t+=u.encode(o.originalLine-1-l),l=o.originalLine-1,t+=u.encode(o.originalColumn-a),a=o.originalColumn,o.name!=null&&(c=this._names.indexOf(o.name),t+=u.encode(c-n),n=c)),i+=t}return i},d.prototype._generateSourcesContent=function(t,o){return t.map(function(c){if(!this._sourcesContents)return null;o!=null&&(c=p.relative(o,c));var f=p.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,f)?this._sourcesContents[f]:null},this)},d.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},d.prototype.toString=function(){return JSON.stringify(this.toJSON())},G.SourceMapGenerator=d,G}var ne,R={},re={};function _e(){return ne||(ne=1,(function(u){function p(m,_,d,t,o,c){var f=Math.floor((_-m)/2)+m,h=o(d,t[f],!0);return h===0?f:h>0?_-f>1?p(f,_,d,t,o,c):c==u.LEAST_UPPER_BOUND?_<t.length?_:-1:f:f-m>1?p(m,f,d,t,o,c):c==u.LEAST_UPPER_BOUND?f:m<0?-1:m}u.GREATEST_LOWER_BOUND=1,u.LEAST_UPPER_BOUND=2,u.search=function(m,_,d,t){if(_.length===0)return-1;var o=p(-1,_.length,m,_,d,t||u.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&d(_[o],_[o-1],!0)===0;)--o;return o}})(re)),re}var te,oe,B={};function ye(){if(te)return B;function u(m){function _(d,t,o){var c=d[t];d[t]=d[o],d[o]=c}return function d(t,o,c,f){if(c<f){var h=c-1;_(t,(n=c,e=f,Math.round(n+Math.random()*(e-n))),f);for(var v=t[f],a=c;a<f;a++)o(t[a],v,!1)<=0&&_(t,h+=1,a);_(t,h+1,a);var l=h+1;d(t,o,c,l-1),d(t,o,l+1,f)}var n,e}}te=1;let p=new WeakMap;return B.quickSort=function(m,_,d=0){let t=p.get(_);t===void 0&&(t=(function(o){let c=u.toString();return new Function(`return ${c}`)()(o)})(_),p.set(_,t)),t(m,_,d,m.length-1)},B}var ie,se,W={},ae=(se||(se=1,$.SourceMapGenerator=ee().SourceMapGenerator,$.SourceMapConsumer=(function(){if(oe)return R;oe=1;var u=x(),p=_e(),m=ce().ArraySet,_=le(),d=ye().quickSort;function t(a,l){var n=a;return typeof a=="string"&&(n=u.parseSourceMapInput(a)),n.sections!=null?new v(n,l):new o(n,l)}function o(a,l){var n=a;typeof a=="string"&&(n=u.parseSourceMapInput(a));var e=u.getArg(n,"version"),i=u.getArg(n,"sources"),r=u.getArg(n,"names",[]),g=u.getArg(n,"sourceRoot",null),y=u.getArg(n,"sourcesContent",null),S=u.getArg(n,"mappings"),L=u.getArg(n,"file",null);if(e!=this._version)throw new Error("Unsupported version: "+e);g&&(g=u.normalize(g)),i=i.map(String).map(u.normalize).map(function(C){return g&&u.isAbsolute(g)&&u.isAbsolute(C)?u.relative(g,C):C}),this._names=m.fromArray(r.map(String),!0),this._sources=m.fromArray(i,!0),this._absoluteSources=this._sources.toArray().map(function(C){return u.computeSourceURL(g,C,l)}),this.sourceRoot=g,this.sourcesContent=y,this._mappings=S,this._sourceMapURL=l,this.file=L}function c(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}t.fromSourceMap=function(a,l){return o.fromSourceMap(a,l)},t.prototype._version=3,t.prototype.__generatedMappings=null,Object.defineProperty(t.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),t.prototype.__originalMappings=null,Object.defineProperty(t.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),t.prototype._charIsMappingSeparator=function(a,l){var n=a.charAt(l);return n===";"||n===","},t.prototype._parseMappings=function(a,l){throw new Error("Subclasses must implement _parseMappings")},t.GENERATED_ORDER=1,t.ORIGINAL_ORDER=2,t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2,t.prototype.eachMapping=function(a,l,n){var e,i=l||null;switch(n||t.GENERATED_ORDER){case t.GENERATED_ORDER:e=this._generatedMappings;break;case t.ORIGINAL_ORDER:e=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var r=this.sourceRoot,g=a.bind(i),y=this._names,S=this._sources,L=this._sourceMapURL,C=0,b=e.length;C<b;C++){var M=e[C],A=M.source===null?null:S.at(M.source);A!==null&&(A=u.computeSourceURL(r,A,L)),g({source:A,generatedLine:M.generatedLine,generatedColumn:M.generatedColumn,originalLine:M.originalLine,originalColumn:M.originalColumn,name:M.name===null?null:y.at(M.name)})}},t.prototype.allGeneratedPositionsFor=function(a){var l=u.getArg(a,"line"),n={source:u.getArg(a,"source"),originalLine:l,originalColumn:u.getArg(a,"column",0)};if(n.source=this._findSourceIndex(n.source),n.source<0)return[];var e=[],i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,p.LEAST_UPPER_BOUND);if(i>=0){var r=this._originalMappings[i];if(a.column===void 0)for(var g=r.originalLine;r&&r.originalLine===g;)e.push({line:u.getArg(r,"generatedLine",null),column:u.getArg(r,"generatedColumn",null),lastColumn:u.getArg(r,"lastGeneratedColumn",null)}),r=this._originalMappings[++i];else for(var y=r.originalColumn;r&&r.originalLine===l&&r.originalColumn==y;)e.push({line:u.getArg(r,"generatedLine",null),column:u.getArg(r,"generatedColumn",null),lastColumn:u.getArg(r,"lastGeneratedColumn",null)}),r=this._originalMappings[++i]}return e},R.SourceMapConsumer=t,o.prototype=Object.create(t.prototype),o.prototype.consumer=t,o.prototype._findSourceIndex=function(a){var l,n=a;if(this.sourceRoot!=null&&(n=u.relative(this.sourceRoot,n)),this._sources.has(n))return this._sources.indexOf(n);for(l=0;l<this._absoluteSources.length;++l)if(this._absoluteSources[l]==a)return l;return-1},o.fromSourceMap=function(a,l){var n=Object.create(o.prototype),e=n._names=m.fromArray(a._names.toArray(),!0),i=n._sources=m.fromArray(a._sources.toArray(),!0);n.sourceRoot=a._sourceRoot,n.sourcesContent=a._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=a._file,n._sourceMapURL=l,n._absoluteSources=n._sources.toArray().map(function(M){return u.computeSourceURL(n.sourceRoot,M,l)});for(var r=a._mappings.toArray().slice(),g=n.__generatedMappings=[],y=n.__originalMappings=[],S=0,L=r.length;S<L;S++){var C=r[S],b=new c;b.generatedLine=C.generatedLine,b.generatedColumn=C.generatedColumn,C.source&&(b.source=i.indexOf(C.source),b.originalLine=C.originalLine,b.originalColumn=C.originalColumn,C.name&&(b.name=e.indexOf(C.name)),y.push(b)),g.push(b)}return d(n.__originalMappings,u.compareByOriginalPositions),n},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const f=u.compareByGeneratedPositionsDeflatedNoLine;function h(a,l){let n=a.length,e=a.length-l;if(!(e<=1))if(e==2){let i=a[l],r=a[l+1];f(i,r)>0&&(a[l]=r,a[l+1]=i)}else if(e<20)for(let i=l;i<n;i++)for(let r=i;r>l;r--){let g=a[r-1],y=a[r];if(f(g,y)<=0)break;a[r-1]=y,a[r]=g}else d(a,f,l)}function v(a,l){var n=a;typeof a=="string"&&(n=u.parseSourceMapInput(a));var e=u.getArg(n,"version"),i=u.getArg(n,"sections");if(e!=this._version)throw new Error("Unsupported version: "+e);this._sources=new m,this._names=new m;var r={line:-1,column:0};this._sections=i.map(function(g){if(g.url)throw new Error("Support for url field in sections not implemented.");var y=u.getArg(g,"offset"),S=u.getArg(y,"line"),L=u.getArg(y,"column");if(S<r.line||S===r.line&&L<r.column)throw new Error("Section offsets must be ordered and non-overlapping.");return r=y,{generatedOffset:{generatedLine:S+1,generatedColumn:L+1},consumer:new t(u.getArg(g,"map"),l)}})}return o.prototype._parseMappings=function(a,l){var n,e,i,r,g=1,y=0,S=0,L=0,C=0,b=0,M=a.length,A=0,w={},E=[],O=[];let k=0;for(;A<M;)if(a.charAt(A)===";")g++,A++,y=0,h(O,k),k=O.length;else if(a.charAt(A)===",")A++;else{for((n=new c).generatedLine=g,i=A;i<M&&!this._charIsMappingSeparator(a,i);i++);for(a.slice(A,i),e=[];A<i;)_.decode(a,A,w),r=w.value,A=w.rest,e.push(r);if(e.length===2)throw new Error("Found a source, but no line and column");if(e.length===3)throw new Error("Found a source and line, but no column");if(n.generatedColumn=y+e[0],y=n.generatedColumn,e.length>1&&(n.source=C+e[1],C+=e[1],n.originalLine=S+e[2],S=n.originalLine,n.originalLine+=1,n.originalColumn=L+e[3],L=n.originalColumn,e.length>4&&(n.name=b+e[4],b+=e[4])),O.push(n),typeof n.originalLine=="number"){let I=n.source;for(;E.length<=I;)E.push(null);E[I]===null&&(E[I]=[]),E[I].push(n)}}h(O,k),this.__generatedMappings=O;for(var F=0;F<E.length;F++)E[F]!=null&&d(E[F],u.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...E)},o.prototype._findMapping=function(a,l,n,e,i,r){if(a[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+a[n]);if(a[e]<0)throw new TypeError("Column must be greater than or equal to 0, got "+a[e]);return p.search(a,l,i,r)},o.prototype.computeColumnSpans=function(){for(var a=0;a<this._generatedMappings.length;++a){var l=this._generatedMappings[a];if(a+1<this._generatedMappings.length){var n=this._generatedMappings[a+1];if(l.generatedLine===n.generatedLine){l.lastGeneratedColumn=n.generatedColumn-1;continue}}l.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(a){var l={generatedLine:u.getArg(a,"line"),generatedColumn:u.getArg(a,"column")},n=this._findMapping(l,this._generatedMappings,"generatedLine","generatedColumn",u.compareByGeneratedPositionsDeflated,u.getArg(a,"bias",t.GREATEST_LOWER_BOUND));if(n>=0){var e=this._generatedMappings[n];if(e.generatedLine===l.generatedLine){var i=u.getArg(e,"source",null);i!==null&&(i=this._sources.at(i),i=u.computeSourceURL(this.sourceRoot,i,this._sourceMapURL));var r=u.getArg(e,"name",null);return r!==null&&(r=this._names.at(r)),{source:i,line:u.getArg(e,"originalLine",null),column:u.getArg(e,"originalColumn",null),name:r}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(a){return a==null})},o.prototype.sourceContentFor=function(a,l){if(!this.sourcesContent)return null;var n=this._findSourceIndex(a);if(n>=0)return this.sourcesContent[n];var e,i=a;if(this.sourceRoot!=null&&(i=u.relative(this.sourceRoot,i)),this.sourceRoot!=null&&(e=u.urlParse(this.sourceRoot))){var r=i.replace(/^file:\/\//,"");if(e.scheme=="file"&&this._sources.has(r))return this.sourcesContent[this._sources.indexOf(r)];if((!e.path||e.path=="/")&&this._sources.has("/"+i))return this.sourcesContent[this._sources.indexOf("/"+i)]}if(l)return null;throw new Error('"'+i+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(a){var l=u.getArg(a,"source");if((l=this._findSourceIndex(l))<0)return{line:null,column:null,lastColumn:null};var n={source:l,originalLine:u.getArg(a,"line"),originalColumn:u.getArg(a,"column")},e=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,u.getArg(a,"bias",t.GREATEST_LOWER_BOUND));if(e>=0){var i=this._originalMappings[e];if(i.source===n.source)return{line:u.getArg(i,"generatedLine",null),column:u.getArg(i,"generatedColumn",null),lastColumn:u.getArg(i,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},R.BasicSourceMapConsumer=o,v.prototype=Object.create(t.prototype),v.prototype.constructor=t,v.prototype._version=3,Object.defineProperty(v.prototype,"sources",{get:function(){for(var a=[],l=0;l<this._sections.length;l++)for(var n=0;n<this._sections[l].consumer.sources.length;n++)a.push(this._sections[l].consumer.sources[n]);return a}}),v.prototype.originalPositionFor=function(a){var l={generatedLine:u.getArg(a,"line"),generatedColumn:u.getArg(a,"column")},n=p.search(l,this._sections,function(i,r){return i.generatedLine-r.generatedOffset.generatedLine||i.generatedColumn-r.generatedOffset.generatedColumn}),e=this._sections[n];return e?e.consumer.originalPositionFor({line:l.generatedLine-(e.generatedOffset.generatedLine-1),column:l.generatedColumn-(e.generatedOffset.generatedLine===l.generatedLine?e.generatedOffset.generatedColumn-1:0),bias:a.bias}):{source:null,line:null,column:null,name:null}},v.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(a){return a.consumer.hasContentsOfAllSources()})},v.prototype.sourceContentFor=function(a,l){for(var n=0;n<this._sections.length;n++){var e=this._sections[n].consumer.sourceContentFor(a,!0);if(e||e==="")return e}if(l)return null;throw new Error('"'+a+'" is not in the SourceMap.')},v.prototype.generatedPositionFor=function(a){for(var l=0;l<this._sections.length;l++){var n=this._sections[l];if(n.consumer._findSourceIndex(u.getArg(a,"source"))!==-1){var e=n.consumer.generatedPositionFor(a);if(e)return{line:e.line+(n.generatedOffset.generatedLine-1),column:e.column+(n.generatedOffset.generatedLine===e.line?n.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},v.prototype._parseMappings=function(a,l){this.__generatedMappings=[],this.__originalMappings=[];for(var n=0;n<this._sections.length;n++)for(var e=this._sections[n],i=e.consumer._generatedMappings,r=0;r<i.length;r++){var g=i[r],y=e.consumer._sources.at(g.source);y!==null&&(y=u.computeSourceURL(e.consumer.sourceRoot,y,this._sourceMapURL)),this._sources.add(y),y=this._sources.indexOf(y);var S=null;g.name&&(S=e.consumer._names.at(g.name),this._names.add(S),S=this._names.indexOf(S));var L={source:y,generatedLine:g.generatedLine+(e.generatedOffset.generatedLine-1),generatedColumn:g.generatedColumn+(e.generatedOffset.generatedLine===g.generatedLine?e.generatedOffset.generatedColumn-1:0),originalLine:g.originalLine,originalColumn:g.originalColumn,name:S};this.__generatedMappings.push(L),typeof L.originalLine=="number"&&this.__originalMappings.push(L)}d(this.__generatedMappings,u.compareByGeneratedPositionsDeflated),d(this.__originalMappings,u.compareByOriginalPositions)},R.IndexedSourceMapConsumer=v,R})().SourceMapConsumer,$.SourceNode=(function(){if(ie)return W;ie=1;var u=ee().SourceMapGenerator,p=x(),m=/(\r?\n)/,_="$$$isSourceNode$$$";function d(t,o,c,f,h){this.children=[],this.sourceContents={},this.line=t??null,this.column=o??null,this.source=c??null,this.name=h??null,this[_]=!0,f!=null&&this.add(f)}return d.fromStringWithSourceMap=function(t,o,c){var f=new d,h=t.split(m),v=0,a=function(){return r()+(r()||"");function r(){return v<h.length?h[v++]:void 0}},l=1,n=0,e=null;return o.eachMapping(function(r){if(e!==null){if(!(l<r.generatedLine)){var g=(y=h[v]||"").substr(0,r.generatedColumn-n);return h[v]=y.substr(r.generatedColumn-n),n=r.generatedColumn,i(e,g),void(e=r)}i(e,a()),l++,n=0}for(;l<r.generatedLine;)f.add(a()),l++;if(n<r.generatedColumn){var y=h[v]||"";f.add(y.substr(0,r.generatedColumn)),h[v]=y.substr(r.generatedColumn),n=r.generatedColumn}e=r},this),v<h.length&&(e&&i(e,a()),f.add(h.splice(v).join(""))),o.sources.forEach(function(r){var g=o.sourceContentFor(r);g!=null&&(c!=null&&(r=p.join(c,r)),f.setSourceContent(r,g))}),f;function i(r,g){if(r===null||r.source===void 0)f.add(g);else{var y=c?p.join(c,r.source):r.source;f.add(new d(r.originalLine,r.originalColumn,y,g,r.name))}}},d.prototype.add=function(t){if(Array.isArray(t))t.forEach(function(o){this.add(o)},this);else{if(!t[_]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);t&&this.children.push(t)}return this},d.prototype.prepend=function(t){if(Array.isArray(t))for(var o=t.length-1;o>=0;o--)this.prepend(t[o]);else{if(!t[_]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);this.children.unshift(t)}return this},d.prototype.walk=function(t){for(var o,c=0,f=this.children.length;c<f;c++)(o=this.children[c])[_]?o.walk(t):o!==""&&t(o,{source:this.source,line:this.line,column:this.column,name:this.name})},d.prototype.join=function(t){var o,c,f=this.children.length;if(f>0){for(o=[],c=0;c<f-1;c++)o.push(this.children[c]),o.push(t);o.push(this.children[c]),this.children=o}return this},d.prototype.replaceRight=function(t,o){var c=this.children[this.children.length-1];return c[_]?c.replaceRight(t,o):typeof c=="string"?this.children[this.children.length-1]=c.replace(t,o):this.children.push("".replace(t,o)),this},d.prototype.setSourceContent=function(t,o){this.sourceContents[p.toSetString(t)]=o},d.prototype.walkSourceContents=function(t){for(var o=0,c=this.children.length;o<c;o++)this.children[o][_]&&this.children[o].walkSourceContents(t);var f=Object.keys(this.sourceContents);for(o=0,c=f.length;o<c;o++)t(p.fromSetString(f[o]),this.sourceContents[f[o]])},d.prototype.toString=function(){var t="";return this.walk(function(o){t+=o}),t},d.prototype.toStringWithSourceMap=function(t){var o={code:"",line:1,column:0},c=new u(t),f=!1,h=null,v=null,a=null,l=null;return this.walk(function(n,e){o.code+=n,e.source!==null&&e.line!==null&&e.column!==null?(h===e.source&&v===e.line&&a===e.column&&l===e.name||c.addMapping({source:e.source,original:{line:e.line,column:e.column},generated:{line:o.line,column:o.column},name:e.name}),h=e.source,v=e.line,a=e.column,l=e.name,f=!0):f&&(c.addMapping({generated:{line:o.line,column:o.column}}),h=null,f=!1);for(var i=0,r=n.length;i<r;i++)n.charCodeAt(i)===10?(o.line++,o.column=0,i+1===r?(h=null,f=!1):f&&c.addMapping({source:e.source,original:{line:e.line,column:e.column},generated:{line:o.line,column:o.column},name:e.name})):o.column++}),this.walkSourceContents(function(n,e){c.setSourceContent(n,e)}),{code:o.code,map:c}},W.SourceNode=d,W})().SourceNode),$);const ue=new Set(["register","setupInterceptors","initializeConfigLoader","initializeWorkerPoolPatching"]),ve=[/instrumentation\.(ts|js|tsx|jsx)$/,/unifiedInterceptor\.(ts|js)$/],q=z.default||z,Se=J.default||J;function j(u){const p=[];for(const m of u)s.isIdentifier(m)?p.push(m.name):s.isRestElement(m)&&s.isIdentifier(m.argument)?p.push(`...${m.argument.name}`):s.isAssignmentPattern(m)&&s.isIdentifier(m.left)?p.push(m.left.name):s.isObjectPattern(m)?p.push("{}"):s.isArrayPattern(m)?p.push("[]"):p.push("_");return p}exports.sourceMapExports=ae,exports.transformFunctionSpans=async function(u,p,m={}){const{projectRoot:_=process.cwd(),includeNodeModules:d=[],debug:t=!1}=m;if(p.includes("node_modules")&&!d.some(e=>p.includes(`node_modules/${e}`)))return{code:u,modified:!1,functionsWrapped:0};if(ve.some(e=>e.test(p)))return t&&console.log(`[FuncSpan Transform] SKIPPING instrumentation entry point file: ${p}`),{code:u,modified:!1,functionsWrapped:0};const o=P.relative(_,p).replace(/\\/g,"/");let c;t&&console.log(`[FuncSpan Transform] Processing: ${o}`);try{c=pe.parse(u,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(e){return t&&console.error(`[FuncSpan Transform] Parse error in ${o}:`,e),{code:u,modified:!1,functionsWrapped:0}}let f=null,h=null;try{const e=de.readFileSync(`${p}.map`,"utf-8");f=await new ae.SourceMapConsumer(JSON.parse(e))}catch{}const v=(e,i)=>{if(f){const r=f.originalPositionFor({line:e,column:i});if(r.line!==null&&r.column!==null)return!h&&r.source&&(h=r.source),{line:r.line,column:r.column,source:r.source||void 0}}return{line:e,column:i}};let a=!1,l=0;const n=new Set;if(q(c,{FunctionDeclaration(e){const i=e.node.id?.name;if(!i)return;if(ue.has(i))return void(t&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${i}`));const r=`decl_${i}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping function declaration: ${i}`);const g=e.node.loc?.start.line??0,y=e.node.loc?.start.column??0,S=v(g,y),{line:L,column:C}=S;let b=p;S.source&&(b=P.resolve(P.dirname(p),S.source)),!t||L===g&&C===y||console.log(`[FuncSpan Transform] Mapped ${g}:${y} → ${L}:${C} in ${b}`);const M=j(e.node.params),A=s.callExpression(s.identifier("captureFunctionSpan"),[s.identifier(i),s.stringLiteral(i),s.stringLiteral(b),s.objectExpression([s.objectProperty(s.identifier("line"),s.numericLiteral(L)),s.objectProperty(s.identifier("column"),s.numericLiteral(C)),s.objectProperty(s.identifier("paramNames"),s.arrayExpression(M.map(E=>s.stringLiteral(E))))])]),w=s.expressionStatement(s.assignmentExpression("=",s.identifier(i),A));e.insertAfter(w),a=!0,l++,n.add(r)},VariableDeclarator(e){const i=e.node.id,r=e.node.init;if(!s.isIdentifier(i)||!r||!s.isFunctionExpression(r)&&!s.isArrowFunctionExpression(r))return;const g=i.name;if(ue.has(g))return void(t&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${g}`));const y=`var_${g}`;if(n.has(y))return;t&&console.log(`[FuncSpan Transform] Wrapping variable function: ${g}`);const S=r.loc?.start.line??0,L=r.loc?.start.column??0,C=v(S,L),{line:b,column:M}=C;let A=p;C.source&&(A=P.resolve(P.dirname(p),C.source)),!t||b===S&&M===L||console.log(`[FuncSpan Transform] Mapped ${S}:${L} → ${b}:${M} in ${A}`);const w=j(r.params),E=s.callExpression(s.identifier("captureFunctionSpan"),[r,s.stringLiteral(g),s.stringLiteral(A),s.objectExpression([s.objectProperty(s.identifier("line"),s.numericLiteral(b)),s.objectProperty(s.identifier("column"),s.numericLiteral(M)),s.objectProperty(s.identifier("paramNames"),s.arrayExpression(w.map(O=>s.stringLiteral(O))))])]);e.node.init=E,a=!0,l++,n.add(y)},ClassMethod(e){if(e.node.kind==="constructor"||e.node.kind==="get"||e.node.kind==="set")return;const i=s.isIdentifier(e.node.key)?e.node.key.name:"anonymous",r=`method_${i}_${e.node.start}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping class method: ${i}`);const g=e.node.body,y=s.functionExpression(null,e.node.params,g,e.node.generator,e.node.async),S=s.callExpression(s.identifier("captureFunctionSpan"),[y,s.stringLiteral(i),s.stringLiteral(o)]),L=s.blockStatement([s.returnStatement(s.callExpression(s.memberExpression(S,s.identifier("call")),[s.thisExpression(),s.spreadElement(s.identifier("arguments"))]))]);e.node.body=L,a=!0,l++,n.add(r)},ObjectMethod(e){if(e.node.kind==="get"||e.node.kind==="set")return;const i=s.isIdentifier(e.node.key)?e.node.key.name:s.isStringLiteral(e.node.key)?e.node.key.value:"anonymous",r=`objmethod_${i}_${e.node.start}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping object method: ${i}`);const g=e.node.loc?.start.line??0,y=e.node.loc?.start.column??0,S=v(g,y),{line:L,column:C}=S;let b=p;S.source&&(b=P.resolve(P.dirname(p),S.source));const M=j(e.node.params),A=s.functionExpression(s.identifier(i),e.node.params,e.node.body,e.node.generator,e.node.async),w=s.callExpression(s.identifier("captureFunctionSpan"),[A,s.stringLiteral(i),s.stringLiteral(b),s.objectExpression([s.objectProperty(s.identifier("line"),s.numericLiteral(L)),s.objectProperty(s.identifier("column"),s.numericLiteral(C)),s.objectProperty(s.identifier("paramNames"),s.arrayExpression(M.map(O=>s.stringLiteral(O))))])]),E=s.objectProperty(e.node.key,w,e.node.computed,!1);e.replaceWith(E),a=!0,l++,n.add(r)},ClassProperty(e){const i=e.node.key,r=e.node.value;if(!s.isIdentifier(i)||!r||!s.isFunctionExpression(r)&&!s.isArrowFunctionExpression(r))return;const g=i.name,y=`classprop_${g}_${e.node.start}`;if(n.has(y))return;t&&console.log(`[FuncSpan Transform] Wrapping class property function: ${g}`);const S=r.loc?.start.line??0,L=r.loc?.start.column??0,C=v(S,L),{line:b,column:M}=C;let A=p;C.source&&(A=P.resolve(P.dirname(p),C.source));const w=j(r.params),E=s.callExpression(s.identifier("captureFunctionSpan"),[r,s.stringLiteral(g),s.stringLiteral(A),s.objectExpression([s.objectProperty(s.identifier("line"),s.numericLiteral(b)),s.objectProperty(s.identifier("column"),s.numericLiteral(M)),s.objectProperty(s.identifier("paramNames"),s.arrayExpression(w.map(O=>s.stringLiteral(O))))])]);e.node.value=E,a=!0,l++,n.add(y)},ObjectProperty(e){const i=e.node.key,r=e.node.value;if(!s.isIdentifier(i)&&!s.isStringLiteral(i)||!r||!s.isFunctionExpression(r)&&!s.isArrowFunctionExpression(r))return;const g=s.isIdentifier(i)?i.name:i.value,y=`objprop_${g}_${e.node.start}`;if(n.has(y))return;t&&console.log(`[FuncSpan Transform] Wrapping object property function: ${g}`);const S=r.loc?.start.line??0,L=r.loc?.start.column??0,C=v(S,L),{line:b,column:M}=C;let A=p;C.source&&(A=P.resolve(P.dirname(p),C.source));const w=j(r.params),E=s.callExpression(s.identifier("captureFunctionSpan"),[r,s.stringLiteral(g),s.stringLiteral(A),s.objectExpression([s.objectProperty(s.identifier("line"),s.numericLiteral(b)),s.objectProperty(s.identifier("column"),s.numericLiteral(M)),s.objectProperty(s.identifier("paramNames"),s.arrayExpression(w.map(O=>s.stringLiteral(O))))])]);e.node.value=E,a=!0,l++,n.add(y)}}),a&&!(function(e){let i=!1;return q(e,{ImportDeclaration(r){s.isStringLiteral(r.node.source)&&r.node.source.value==="@sailfish-ai/sf-veritas"&&r.node.specifiers.some(g=>s.isImportSpecifier(g)&&s.isIdentifier(g.imported)&&g.imported.name==="captureFunctionSpan")&&(i=!0,r.stop())},VariableDeclarator(r){if(s.isObjectPattern(r.node.id)&&s.isCallExpression(r.node.init)&&s.isIdentifier(r.node.init.callee)&&r.node.init.callee.name==="require"){const g=r.node.init.arguments;g.length>0&&s.isStringLiteral(g[0])&&g[0].value==="@sailfish-ai/sf-veritas"&&r.node.id.properties.some(y=>s.isObjectProperty(y)&&s.isIdentifier(y.key)&&y.key.name==="captureFunctionSpan")&&(i=!0,r.stop())}}}),i})(c))if((function(e){let i=!1;return q(e,{CallExpression(r){s.isIdentifier(r.node.callee)&&r.node.callee.name==="require"&&(i=!0,r.stop())},MemberExpression(r){!s.isIdentifier(r.node.object)||r.node.object.name!=="module"&&r.node.object.name!=="exports"||(i=!0,r.stop())}}),i})(c)){const e=s.variableDeclaration("const",[s.variableDeclarator(s.objectPattern([s.objectProperty(s.identifier("captureFunctionSpan"),s.identifier("captureFunctionSpan"),!1,!0)]),s.callExpression(s.identifier("require"),[s.stringLiteral("@sailfish-ai/sf-veritas")]))]);c.program.body.unshift(e)}else{const e=s.importDeclaration([s.importSpecifier(s.identifier("captureFunctionSpan"),s.identifier("captureFunctionSpan"))],s.stringLiteral("@sailfish-ai/sf-veritas"));c.program.body.unshift(e)}if(l>0){const e=Se(c,{retainLines:!0,compact:!1,sourceMaps:!0,sourceFileName:p},u);return t&&console.log(`[FuncSpan Transform] ✅ Wrapped ${l} functions in ${o}`),{code:e.code,map:e.map,modified:!0,functionsWrapped:l}}return{code:u,modified:!1,functionsWrapped:0}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("fs"),r=require("../funcSpanTransformer-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("fs"),r=require("../funcSpanTransformer-BpWuHXKT.cjs");function u(o={}){const{enabled:l=!0,includeNodeModules:n=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(d){l&&(d.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!n.some(s=>e.path.includes(`node_modules/${s}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const s=a.readFileSync(e.path,"utf-8"),i=await r.transformFunctionSpans(s,e.path,{projectRoot:process.cwd(),includeNodeModules:n,debug:t});if(i.modified)return{contents:i.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(s){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,s)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=u,exports.funcspanEsbuildPlugin=u;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync as u } from "fs";
|
|
2
|
-
import { t as l } from "../funcSpanTransformer-
|
|
2
|
+
import { t as l } from "../funcSpanTransformer-BLhIRZqX.js";
|
|
3
3
|
function p(o = {}) {
|
|
4
4
|
const { enabled: a = !0, includeNodeModules: i = [], debug: t = !1 } = o;
|
|
5
5
|
return { name: "sailfish-funcspan-esbuild", setup(d) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../funcSpanTransformer-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../funcSpanTransformer-BpWuHXKT.cjs");function l(r={}){const{enabled:t=!0,includeNodeModules:u=[],debug:s=!1}=r;return{name:"sailfish-funcspan-rollup",async transform(i,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!u.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await o.transformFunctionSpans(i,e,{projectRoot:process.cwd(),includeNodeModules:u,debug:s});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){s&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=l,exports.funcspanRollupPlugin=l;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t } from "../funcSpanTransformer-
|
|
1
|
+
import { t } from "../funcSpanTransformer-BLhIRZqX.js";
|
|
2
2
|
function i(r = {}) {
|
|
3
3
|
const { enabled: o = !0, includeNodeModules: s = [], debug: u = !1 } = r;
|
|
4
4
|
return { name: "sailfish-funcspan-rollup", async transform(l, n) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),C=require("glob"),N=require("path"),T=require("../funcSpanTransformer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),C=require("glob"),N=require("path"),T=require("../funcSpanTransformer-BpWuHXKT.cjs");async function d(n={}){const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:s=process.cwd(),includeNodeModules:_=[],debug:t=!1}=n,u=N.resolve(s,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${s}`);const r=[];for(const o of F){const c=C.sync(o,{cwd:u,absolute:!0,ignore:g});r.push(...c)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,p=0;for(const o of r)try{const c=i.readFileSync(o,"utf-8"),e=await T.transformFunctionSpans(c,o,{projectRoot:s,includeNodeModules:_,debug:t});if(e.modified){if(i.writeFileSync(o,e.code,"utf-8"),e.map){const a=`${o}.map`;i.writeFileSync(a,JSON.stringify(e.map),"utf-8"),t&&console.log(`[FuncSpan TSC] Generated source map: ${a}`)}l++,p+=e.functionsWrapped,t&&console.log(`[FuncSpan TSC] Modified: ${o} (${e.functionsWrapped} functions)`)}}catch(c){console.error(`[FuncSpan TSC] Error processing ${o}:`,c)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${p} functions`)}async function S(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await d(n)}require.main===module&&S().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=S,exports.processTscFiles=d;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync as m, writeFileSync as l } from "fs";
|
|
2
2
|
import { sync as _ } from "glob";
|
|
3
3
|
import { resolve as C } from "path";
|
|
4
|
-
import { t as N } from "../funcSpanTransformer-
|
|
4
|
+
import { t as N } from "../funcSpanTransformer-BLhIRZqX.js";
|
|
5
5
|
async function g(n = {}) {
|
|
6
6
|
const { outDir: d = "dist", include: S = ["**/*.js"], exclude: f = ["**/*.test.js", "**/*.spec.js", "**/__tests__/**"], projectRoot: c = process.cwd(), includeNodeModules: F = [], debug: t = !1 } = n, i = C(c, d);
|
|
7
7
|
console.log("[FuncSpan TSC] Starting post-build function instrumentation..."), console.log(`[FuncSpan TSC] Output directory: ${i}`), console.log(`[FuncSpan TSC] Project root: ${c}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../funcSpanTransformer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../funcSpanTransformer-BpWuHXKT.cjs");exports.funcspanVitePlugin=function(t={}){const{enabled:i=!0,includeNodeModules:r=[],debug:s=!1}=t;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(o,e){if(!i||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!r.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await l.transformFunctionSpans(o,e,{projectRoot:process.cwd(),includeNodeModules:r,debug:s});if(n.modified)return{code:n.code,map:null}}catch(n){s&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as o } from "../funcSpanTransformer-
|
|
1
|
+
import { t as o } from "../funcSpanTransformer-BLhIRZqX.js";
|
|
2
2
|
function c(t = {}) {
|
|
3
3
|
const { enabled: i = !0, includeNodeModules: r = [], debug: s = !1 } = t;
|
|
4
4
|
return { name: "sailfish-funcspan-vite", enforce: "pre", async transform(l, e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const I=require("../funcSpanTransformer-
|
|
1
|
+
"use strict";const I=require("../funcSpanTransformer-BpWuHXKT.cjs"),M=require("@babel/parser"),x=require("@babel/traverse"),O=require("@babel/generator"),R=require("@babel/types"),z=require("path");function L(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(p,r,l.get?l:{enumerable:!0,get:()=>n[r]})}}return p.default=n,Object.freeze(p)}const e=L(R),C=x.default||x,N=O.default||O,Z=["lookup","lookupService","resolve","resolve4","resolve6","resolveAny","resolveCname","resolveMx","resolveNs","resolvePtr","resolveSoa","resolveSrv","resolveTxt","reverse","setServers","getServers"],A=["readFile","writeFile","appendFile","readdir","stat","lstat","mkdir","rmdir","unlink","rename","copyFile","open","close","read","write","access"],B=["pbkdf2","randomBytes","randomFill","scrypt"],G=["deflate","deflateRaw","gzip","gunzip","inflate","inflateRaw","unzip","brotliCompress","brotliDecompress"];module.exports=function(n){const p=this.async(),r=this.getOptions();(async()=>{try{let l=await I.transformFunctionSpans(n,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),includeNodeModules:r.includeNodeModules||[],debug:r.debug||!1}),m=l.modified?l.code:n,v=l.map;if(r.enableWorkerPoolTracking){const k=await(async function(g,W,D={}){const{projectRoot:q=process.cwd(),trackDns:h=!1,trackFs:w=!1,trackCrypto:j=!1,trackZlib:T=!1,debug:d=!1}=D;if(!(h||w||j||T))return{code:g,modified:!1,callsWrapped:0};const b=z.relative(q,W).replace(/\\/g,"/");let u;d&&console.log(`[WorkerPool Transform] Processing: ${b}`);try{u=M.parse(g,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(t){return d&&console.error(`[WorkerPool Transform] Parse error in ${b}:`,t),{code:g,modified:!1,callsWrapped:0}}let F=!1,y=0,S=!1;const P=new Map,c=new Map;if(h&&c.set("dns",Z),w&&c.set("fs",A),j&&c.set("crypto",B),T&&c.set("zlib",G),C(u,{VariableDeclarator(t){const o=t.node.init,i=t.node.id;if(o&&e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"require"})&&o.arguments.length===1&&e.isStringLiteral(o.arguments[0])){const s=o.arguments[0].value;for(const[a]of c)s!==a&&s!==`node:${a}`||e.isIdentifier(i)&&(P.set(i.name,a),d&&console.log(`[WorkerPool Transform] Found ${a} binding: ${i.name}`))}},ImportDeclaration(t){const o=t.node.source.value;for(const[i]of c)if(o===i||o===`node:${i}`){for(const s of t.node.specifiers)if(e.isImportDefaultSpecifier(s)||e.isImportNamespaceSpecifier(s)){const a=s.local.name;P.set(a,i),d&&console.log(`[WorkerPool Transform] Found ${i} import: ${a}`)}}}}),C(u,{CallExpression(t){const o=t.node.callee;if(e.isMemberExpression(o)&&e.isIdentifier(o.object)){const i=o.object.name,s=P.get(i);if(s&&c.has(s)){const a=c.get(s),f=e.isIdentifier(o.property)?o.property.name:null;if(f&&a.includes(f)){d&&console.log(`[WorkerPool Transform] Wrapping ${s}.${f}()`);const E=e.callExpression(e.identifier("captureWorkerPoolOperation"),[e.stringLiteral(s),e.stringLiteral(f),e.memberExpression(e.identifier(i),e.identifier(f)),e.arrayExpression(t.node.arguments),e.identifier(i)]);t.replaceWith(E),S=!0,y++,F=!0}}}}}),S){const t=e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureWorkerPoolOperation"),e.identifier("captureWorkerPoolOperation"),!1,!0)]),e.callExpression(e.identifier("require"),[e.stringLiteral("@sailfish-ai/sf-veritas/worker-pool-capture")]))]);u.program.body.length>0&&u.program.body.unshift(t),d&&console.log("[WorkerPool Transform] Added captureWorkerPoolOperation import")}if(!F)return{code:g,modified:!1,callsWrapped:0};const $=N(u,{sourceMaps:!0,sourceFileName:W});return d&&console.log(`[WorkerPool Transform] Wrapped ${y} calls in ${b}`),{code:$.code,map:$.map,modified:!0,callsWrapped:y}})(m,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),trackDns:r.workerPoolTrackDns||!1,trackFs:r.workerPoolTrackFs||!1,trackCrypto:r.workerPoolTrackCrypto||!1,trackZlib:r.workerPoolTrackZlib||!1,debug:r.debug||!1});k.modified&&(m=k.code,v=k.map)}m!==n?p(null,m,v):p(null,n)}catch(l){r.debug&&console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`,l),p(null,n)}})()};
|
package/dist/sf-veritas.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var me=Object.defineProperty;var he=(t,e,n)=>e in t?me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>he(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./workerPoolSpanCapture-DEwlTq0a.cjs"),X=require("fs"),O=require("./funcSpanTransformer-BpWuHXKT.cjs"),N=require("worker_threads"),be=require("node:module"),fe=require("path"),Ae=require("glob");var _=typeof document<"u"?document.currentScript:null;function Ce(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const k=Ce(X),S=Ce(fe);class V extends r.BaseTransmitter{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!r.getConfig().serviceIdentificationReceived)try{this.send()}catch(n){r.getConfig().sfDebug&&console.error(" Error during service identification:",n)}}async send(){const e=`
|
|
2
2
|
${this.queryType} ${this.operationName}(
|
|
3
3
|
$apiKey: String!,
|
|
4
4
|
$timestampMs: String!,
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
gitSha: $gitSha,
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
|
-
`,n=this.getVariables({serviceIdentifier:r.getConfig().serviceIdentifier,serviceVersion:r.getConfig().serviceVersion,library:r.getConfig().packageLibraryType,version:r.getConfig().version,serviceAdditionalMetadata:r.getConfig().serviceAdditionalMetadata,gitSha:r.getConfig().gitSha||""});r.nonBlockingPost(this.endpoint,this.operationName,e,n)}}function
|
|
25
|
+
`,n=this.getVariables({serviceIdentifier:r.getConfig().serviceIdentifier,serviceVersion:r.getConfig().serviceVersion,library:r.getConfig().packageLibraryType,version:r.getConfig().version,serviceAdditionalMetadata:r.getConfig().serviceAdditionalMetadata,gitSha:r.getConfig().gitSha||""});r.nonBlockingPost(this.endpoint,this.operationName,e,n)}}function ye(t){try{return JSON.stringify(t),!0}catch{return!1}}class Ze extends r.BaseTransmitter{constructor(){super();f(this,"serviceIdentifier",new V);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(n,i,o,s){this.sendAppIdentifier(),this.send(n,i,o,s)}async send(n,i,o,s){if(!i&&!s)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let l=[];if(!s){const g=(function(c){const d={},I=[];if(c)for(const[C,p]of Object.entries(c))ye(p)?d[C]=p:I.push(C);return{traitsJson:JSON.stringify(d),excludedFields:I}})(i);s=g.traitsJson,l=g.excludedFields}const a=this.getVariables({userId:n,traitsJson:s,excludedFields:l,override:o,library:r.getConfig().packageLibraryType,version:r.getConfig().version});r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),a)}getQuery(){return`
|
|
26
26
|
mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $userId: String!, $traitsJson: String!, $excludedFields: [String!]!, $library: String!, $timestampMs: String!, $version: String!, $override: Boolean!) {
|
|
27
27
|
${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, userId: $userId, traitsJson: $traitsJson, excludedFields: $excludedFields, library: $library, timestampMs: $timestampMs, version: $version, override: $override)
|
|
28
28
|
}
|
|
29
|
-
`}}class
|
|
29
|
+
`}}class M{constructor(e){f(this,"metadataTransmitter");this.apiKey=e,this.metadataTransmitter=new Ze}identify(e,n,i,o=!1){n||i?this.addOrUpdateMetadata(e,n,i,o):this.addOrUpdateMetadata(e,{},void 0,o)}addOrUpdateMetadata(e,n={},i,o=!1){if(!n&&!i)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');r.getConfig().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),r.getConfig().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",e,n,i),this.metadataTransmitter.doSend(e,n,o,i)}}class x extends r.BaseTransmitter{constructor(){super();f(this,"serviceIdentifier",new V)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(n){this.sendAppIdentifier(),this.send(n)}async send(n){try{const i=Array.isArray(n)?n:[n,"default"],o=this.getVariables({contents:i[0],level:i[1]});r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),o)}catch(i){r.getConfig().sfDebug&&console.error("🚨 Error in send():",i)}}getQuery(){return`
|
|
30
30
|
${this.queryType} ${this.operationName}(
|
|
31
31
|
$apiKey: String!,
|
|
32
32
|
$serviceUuid: String!,
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
parentSpanId: $parentSpanId
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
|
-
`}}const G={};class F{constructor({file:e,line:n,function:i,code:t,locals:s={},offender:l=!1,column:a}){A(this,"file");A(this,"line");A(this,"function");A(this,"code");A(this,"locals");A(this,"offender");A(this,"column");this.file=e,this.line=n,this.function=i,this.code=t,this.locals=s,this.offender=l,this.column=a}toDict(){const e={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([n,i])=>[n,String(i)]))};return this.offender&&(e.offender=this.offender),this.column!==void 0&&(e.column=this.column),e}toJson(){return JSON.stringify(this.toDict())}}class R{static encode(e){return e instanceof F?e.toDict():Array.isArray(e)?e.map(n=>R.encode(n)):typeof e=="object"&&e!==null?JSON.stringify(e):e}static stringify(e){return JSON.stringify(R.encode(e),(n,i)=>i instanceof F?i.toDict():i)}}let B,W=0;function fe(o){r.getConfig().sfDebug&&console.log("Initializing Exception Interceptor...");try{const a=(function(){if(B!==void 0)return B;const g=process.env||{},c=Q(g.SF_IS_LOCAL);if(c!==void 0)return B=c;const d=(g.SF_ENV||g.NODE_ENV||"").toLowerCase();if(["local","dev","development"].includes(d))return B=!0;if(["KUBERNETES_SERVICE_HOST","AWS_EXECUTION_ENV","ECS_CONTAINER_METADATA_URI","ECS_CONTAINER_METADATA_URI_V4","GAE_ENV","K_SERVICE","GOOGLE_CLOUD_PROJECT","WEBSITE_INSTANCE_ID","VERCEL","NETLIFY","DYNO","RENDER","FLY_APP_NAME","RAILWAY_STATIC_URL","CF_PAGES","CLOUDFLARE"].some(p=>!!g[p]))return B=!1;const I=(G.hostname?.()||g.HOSTNAME||"").toLowerCase();return I==="localhost"||I.endsWith(".local")||I.includes("local")?B=!0:B=!1})();o?.setSupplementalFields?.({isFromLocalService:a}),(async function(g){if(M)return;M=!0;const c=process.env||{};if(Q(c.SF_IS_LOCAL)===void 0)try{await(async function(d){const I=U("http://169.254.169.254/latest/meta-data/",{},d),p=U("http://metadata.google.internal/computeMetadata/v1/instance/",{"Metadata-Flavor":"Google"},d),C=U("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{Metadata:"true"},d);return(await Promise.allSettled([I,p,C])).some(u=>u.status==="fulfilled"&&(u.value==="ok"||u.value==="http_error"))})(150)&&B&&(B=!1,g?.setSupplementalFields?.({isFromLocalService:!1}))}catch{}})(o).catch(()=>{})}catch{}const e=new N.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZcyBwYXJlbnRQb3J0LgogKgogKiBAcGFyYW0gc2Vzc2lvbiAtIFRoZSBEZXZUb29scyBzZXNzaW9uIG9yIHNpbWlsYXIgb2JqZWN0IHlvdSB1c2UgdG8gcX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XSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICA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mFsdWUuY2xhc3NOYW1lID09PSAiQXJyYXkiKSB7CiAgICAgICAgICBjb25zdCBpZCA9IHByb3AudmFsdWUub2JqZWN0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxBcnJheShzZXNzaW9uLCBpZCwgcHJvcC5uYW1lLCB2YXJpYWJsZXMpOwogICAgICAgIH0gZWxzZSBpZiAoCiAgICAgICAgICBwcm9wPy52YWx1ZT8ub2JqZWN0SWQgJiYKICAgICAgICAgIHByb3A/LnZhbHVlPy5jbGFzc05hbWUgPT09ICJPYmplY3QiCiAgICAgICAgKSB7CiAgICAgICAgICBjb25zdCBpZCA9IHByb3AudmFsdWUub2JqZWN0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let n=null;const i=new WeakMap;e.on("message",a=>{if(typeof a=="string"&&r.getConfig().sfDebug&&console.log(`[Worker] ${a}`),a.readyToGetParameters&&e.postMessage({sfDebug:r.getConfig().sfDebug,stackDepthLocals:r.getConfig().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:r.getConfig().nodeModulesToCollectLocalVariablesOn}),a.type==="exception"){const{frames:g}=a,c=n;if(!c)return;const d=i.get(c),I=(function(C){return C?C.split(`
|
|
50
|
-
`).slice(1).map(u=>{const m=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(u)||/at (.+):(\d+):(\d+)/.exec(u);if(m){const[,h,Z,b,y]=m;return new F({function:h||"<anonymous>",locals:{},file:Z||"<unknown>",line:parseInt(b,10)||0,code:"<not captured>",column:parseInt(y)||0})}return new F({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(c.stack),
|
|
51
|
-
`)[1]?.trim()}`;if(!s.has(c)){s.add(c),n=g;const d=r.ContextManager.getInstance().getTraceId();i.set(g,d),e.postMessage({type:"processException",error:g.message})}return g}l.prototype=Object.create(
|
|
49
|
+
`}}const G={};class F{constructor({file:e,line:n,function:i,code:o,locals:s={},offender:l=!1,column:a}){f(this,"file");f(this,"line");f(this,"function");f(this,"code");f(this,"locals");f(this,"offender");f(this,"column");this.file=e,this.line=n,this.function=i,this.code=o,this.locals=s,this.offender=l,this.column=a}toDict(){const e={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([n,i])=>[n,String(i)]))};return this.offender&&(e.offender=this.offender),this.column!==void 0&&(e.column=this.column),e}toJson(){return JSON.stringify(this.toDict())}}class R{static encode(e){return e instanceof F?e.toDict():Array.isArray(e)?e.map(n=>R.encode(n)):typeof e=="object"&&e!==null?JSON.stringify(e):e}static stringify(e){return JSON.stringify(R.encode(e),(n,i)=>i instanceof F?i.toDict():i)}}let B,W=0;function Se(t){r.getConfig().sfDebug&&console.log("Initializing Exception Interceptor...");try{const a=(function(){if(B!==void 0)return B;const g=process.env||{},c=ee(g.SF_IS_LOCAL);if(c!==void 0)return B=c;const d=(g.SF_ENV||g.NODE_ENV||"").toLowerCase();if(["local","dev","development"].includes(d))return B=!0;if(["KUBERNETES_SERVICE_HOST","AWS_EXECUTION_ENV","ECS_CONTAINER_METADATA_URI","ECS_CONTAINER_METADATA_URI_V4","GAE_ENV","K_SERVICE","GOOGLE_CLOUD_PROJECT","WEBSITE_INSTANCE_ID","VERCEL","NETLIFY","DYNO","RENDER","FLY_APP_NAME","RAILWAY_STATIC_URL","CF_PAGES","CLOUDFLARE"].some(C=>!!g[C]))return B=!1;const I=(G.hostname?.()||g.HOSTNAME||"").toLowerCase();return I==="localhost"||I.endsWith(".local")||I.includes("local")?B=!0:B=!1})();t?.setSupplementalFields?.({isFromLocalService:a}),(async function(g){if(q)return;q=!0;const c=process.env||{};if(ee(c.SF_IS_LOCAL)===void 0)try{await(async function(d){const I=T("http://169.254.169.254/latest/meta-data/",{},d),C=T("http://metadata.google.internal/computeMetadata/v1/instance/",{"Metadata-Flavor":"Google"},d),p=T("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{Metadata:"true"},d);return(await Promise.allSettled([I,C,p])).some(u=>u.status==="fulfilled"&&(u.value==="ok"||u.value==="http_error"))})(150)&&B&&(B=!1,g?.setSupplementalFields?.({isFromLocalService:!1}))}catch{}})(t).catch(()=>{})}catch{}const e=new N.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGV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VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJ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VzTGlzdC5zb21lKChtb2R1bGVOYW1lKSA9PgogICAgICAgICAgZmlyc3RGcmFtZUxpbmUuaW5jbHVkZXMoYCR7bW9kdWxlTmFtZX1gKSwKICAgICAgICApOwoKICAgICAgICBpZiAoIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgfQoKICAgIC8vIElmIHdlIHJlYWNoIHRoaXMgcG9pbnQsIHRoZSBlcnJvciBpcyBlaXRoZXIgZnJvbSBhcHAgY29kZSwgb3IgZnJvb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CgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let n=null;const i=new WeakMap;e.on("message",a=>{if(typeof a=="string"&&r.getConfig().sfDebug&&console.log(`[Worker] ${a}`),a.readyToGetParameters&&e.postMessage({sfDebug:r.getConfig().sfDebug,stackDepthLocals:r.getConfig().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:r.getConfig().nodeModulesToCollectLocalVariablesOn}),a.type==="exception"){const{frames:g}=a,c=n;if(!c)return;const d=i.get(c),I=(function(p){return p?p.split(`
|
|
50
|
+
`).slice(1).map(u=>{const m=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(u)||/at (.+):(\d+):(\d+)/.exec(u);if(m){const[,h,Z,b,y]=m;return new F({function:h||"<anonymous>",locals:{},file:Z||"<unknown>",line:parseInt(b,10)||0,code:"<not captured>",column:parseInt(y)||0})}return new F({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(c.stack),C=(function(p,u){const m=[];let h=-1,Z=-1;for(let b=0;b<p.length;b++){const y=Be(p[b].file);if(Z=b,y!=="<unknown>"){for(let A=0;A<u.length;A++){const v=u[A];if(pe(v,y)||typeof v.file=="string"&&v.file.includes(y)){h=A,W=0,r.getConfig().sfDebug&&console.log(`✅ Matched Frame Found: ${y} @ Debugger Frame ${A}`);break}}if(h!==-1)break}}if(h===-1)return W===10?(W=0,p):(++W,r.getConfig().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${W}"`),[]);r.getConfig().sfDebug&&console.log(`🔄 Merging from matched index ${h} onward...`);for(let b=0;b<u.length;b++){const y=p[Z+b],A=u[h+b];m.push(new F({function:A?.function||y?.function||"<anonymous>",locals:A?.locals||y?.locals||{},file:y?.file||A?.file||"<unknown>",line:A?.line||y?.line||0,code:A?.code||y?.code||"<not captured>"}))}return m})(I,g||[]);if(C.length!==0){n=null;const p=r.getConfig().stackDepthCodeTraceDepth,u=p===-1?C:C.slice(0,p+1),m=Math.min(u.length,I.length);for(let y=0;y<m;y++)(async()=>{const A=Ge(u[y].file,I[y].line,I[y].column);A&&(A.content!=null&&(u[y].code=A.content),A.file!=null&&(u[y].file=A.file))})();t.setOperationName("CollectExceptions");const h=c.message?`${c.name}: ${c.message}`:c.name;r.getConfig().sfDebug&&console.log("error message is : ",h);const Z=r.ContextManager.getInstance(),b=i.get(c);b?(Z.setTraceIdFor(b,b),Z.runWithSession(b,()=>{Z.setTraceId(b),t.doSend(h,u)})):t.doSend(h,u),d?r.ContextManager.getInstance().runWithSession(d,()=>{t.doSend(h,u)}):t.doSend(h,u)}}}),e.on("error",a=>{console.error("[Worker Error]",a)}),e.on("exit",a=>{console.error(`[Worker] Exited with code ${a}`)}),e.unref();const o=Error,s=new Set;function l(...a){const g=Reflect.construct(o,a);Reflect.setPrototypeOf(g,l.prototype);try{const d=r.ContextManager.getInstance().getTraceId();i.set(g,d)}catch{}o.captureStackTrace&&o.captureStackTrace(g,l);const c=`${g.message}:${g.stack?.split(`
|
|
51
|
+
`)[1]?.trim()}`;if(!s.has(c)){s.add(c),n=g;const d=r.ContextManager.getInstance().getTraceId();i.set(g,d),e.postMessage({type:"processException",error:g.message})}return g}l.prototype=Object.create(o.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(l,o),globalThis.Error=l}function Q(t){return t=(t=(t=t.replace(/^webpack:\/\/[^\/]+\/\.?\//,"")).replace(/^.*\/pages\//,"pages/")).replace(/\.(js|ts)$/,"")}function Ge(t,e,n){const i=(function(s){s.startsWith("at ")&&(s=s.slice(3).trim());const l=s.match(/^(.*?)(:\d+)+(\.map)?$/);return l?l[1]:s})(t);if(!i||i==="<unknown>")return null;const o=i+".map";try{const s=X.readFileSync(o,"utf-8");if(s){const l=JSON.parse(s);let a=new O.sourceMapExports.SourceMapConsumer(l).originalPositionFor({line:e,column:n});if(i&&a.source){const g=Q(i),c=l.sources.findIndex(d=>Q(d)===g);if(c===-1)r.getConfig().sfDebug&&console.log(`Source file "${i}" not found in the source map.`);else{const d=l.sourcesContent[c],I=l.names.join(",");if(d)return{content:d.split(`
|
|
52
52
|
`).slice(a.line-1,a.line+20).join(`
|
|
53
|
-
`),name:I,file:a.source};r.getConfig().sfDebug&&console.log(`No source content available for file "${i}".`)}}return{content:l.sourcesContent[0],name:l.names[0],file:l.file}}}catch(s){r.getConfig().sfDebug&&console.log(`Cant read/parse "${
|
|
53
|
+
`),name:I,file:a.source};r.getConfig().sfDebug&&console.log(`No source content available for file "${i}".`)}}return{content:l.sourcesContent[0],name:l.names[0],file:l.file}}}catch(s){r.getConfig().sfDebug&&console.log(`Cant read/parse "${o}: Error - ".`,s)}return null}function Be(t){return t?.split("/").pop()||"<unknown>"}function pe(t,e){if(!t||typeof t!="object")return!1;for(const n of Object.values(t))if(typeof n=="string"&&n.includes(e)||typeof n=="object"&&pe(n,e))return!0;return!1}let q=!1;function ee(t){if(!t)return;const e=t.toLowerCase().trim();return!!["1","true","yes","on"].includes(e)||!["0","false","no","off"].includes(e)&&void 0}function T(t,e,n){return new Promise(i=>{try{const o=new URL(t),s=(o.protocol,G).request({method:"GET",hostname:o.hostname,port:o.port||(o.protocol==="https:"?443:80),path:o.pathname+(o.search||""),headers:e},l=>{l.resume(),l.statusCode&&l.statusCode>=200&&l.statusCode<400?i("ok"):i("http_error")});s.on("error",()=>i("error")),s.setTimeout(n,()=>{s.destroy(),i("timeout")}),s.end()}catch{i("error")}})}class ve extends r.BaseTransmitter{constructor(){super();f(this,"serviceIdentifier",new V);f(this,"supplementalFields",{});this.setOperationName("CollectExceptions")}setSupplementalFields(n){this.supplementalFields={...this.supplementalFields,...n}}normalizedSupplementalForGraphQL(){const{isFromLocalService:n}=this.supplementalFields,i={};return n!==void 0&&(i.isFromLocalService=n),i}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(n,i){this.sendAppIdentifier(),this.send(n,i)}async send(n,i){r.getConfig().sfDebug&&console.log(" SENDING EXCEPTION...");const o=JSON.stringify(R.encode(i)),s=this.normalizedSupplementalForGraphQL(),l=this.getVariables({exceptionMessage:n,traceJson:o,reentrancyGuardPreactive:!1,library:r.getConfig().packageLibraryType,version:r.getConfig().version,...s});r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),l)}getQuery(){return`
|
|
54
54
|
mutation ${this.operationName}(
|
|
55
55
|
$apiKey: String!,
|
|
56
56
|
$serviceUuid: String!,
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
parentSpanId: $parentSpanId
|
|
79
79
|
)
|
|
80
80
|
}
|
|
81
|
-
`}}const
|
|
81
|
+
`}}const ne="getting request source code";var Y=(t=>(t.UNKNOWN="unknown",t.ANONYMOUS="anonymous",t.NOT_CAPTURED="not captured",t))(Y||{});const U="http:",E="https:",We=be.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("sf-veritas.cjs",document.baseURI).href);let te=!1;function Ne(){const t=r.getConfig().sfDebug;if(te)return void(t&&console.log("[patchNodeHttpInbound] Already installed, skipping."));let e;te=!0;try{e=We("node:http"),t&&console.log("[patchNodeHttpInbound] node:http required successfully.")}catch(o){return void console.error("Failed to require node:http:",o)}if(!e?.Server?.prototype)return void(t&&console.log("[patchNodeHttpInbound] http.Server.prototype not found."));const n=e.Server.prototype,i=n.emit;i&&!n.__sf_inbound_patched__?(Object.defineProperty(n,"__sf_inbound_patched__",{value:!0,enumerable:!1,configurable:!1,writable:!1}),t&&console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."),n.emit=function(o,...s){if(o!=="request")return t&&console.log(`[patchNodeHttpInbound] Passing through event: ${o}`),i.call(this,o,...s);const l=s[0],a=s[1],g=(function(u){const m={};if(!u)return m;for(const[h,Z]of Object.entries(u))Z!=null&&(Array.isArray(Z)?m[h.toLowerCase()]=Z.join(", "):m[h.toLowerCase()]=String(Z));return m})(l?.headers),c=g["x-sf3-rid"],d=g["x-sf3-functionspancaptureoverride"];t&&(console.log("[patchNodeHttpInbound] Intercepted request event."),console.log("[patchNodeHttpInbound] Inbound headers:",g),console.log("[patchNodeHttpInbound] Trace header:",c),console.log("[patchNodeHttpInbound] FuncSpan override header:",d));const I=r.ContextManager.getInstance();I.setTraceId(c);const C=I.getTraceId();t&&console.log("[patchNodeHttpInbound] Context traceId set:",C);const p=()=>I.runWith({inboundHeaders:g,...c?{traceId:c}:{}},()=>{c&&I.setTraceId(c),t&&console.log("[patchNodeHttpInbound] Running request handler in context.");const u=()=>{t&&console.log("[patchNodeHttpInbound] Response finished/closed for traceId:",I.getTraceId())};return a.on("finish",u),a.on("close",u),i.call(this,o,l,a)});if(!d)return p();try{return r.funcspanOverrideStorage.run(d,()=>p())}catch{return p()}}):t&&console.log("[patchNodeHttpInbound] Already patched, skipping.")}class Fe extends x{constructor(){super(),this.setOperationName("DomainsToNotPassHeaderTo")}async doSend(e){this.sendAppIdentifier(),this.send(e)}async send(e){const n=`
|
|
82
82
|
${this.queryType} ${this.operationName}(
|
|
83
83
|
$apiKey: String!,
|
|
84
84
|
$serviceUuid: String!,
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
domains: $domains
|
|
91
91
|
)
|
|
92
92
|
}
|
|
93
|
-
`,i={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:e};r.nonBlockingPost(this.endpoint,this.operationName,n,i)}}class
|
|
93
|
+
`,i={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:e};r.nonBlockingPost(this.endpoint,this.operationName,n,i)}}class we extends r.BaseTransmitter{constructor(){super();f(this,"serviceIdentifier",new V);this.setOperationName("CollectNetworkHops")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(n){this.sendAppIdentifier(),this.send(n)}async send(n){const{name:i,column:o,line:s,entrypoint:l,retryWithoutTraceId:a}=n,g=this.getVariables({name:i,column:o,line:s,entrypoint:l,retryWithoutTraceId:a});r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),g)}getQuery(){return`
|
|
94
94
|
mutation ${this.operationName}(
|
|
95
95
|
$apiKey: String!,
|
|
96
96
|
$sessionId: String!,
|
|
@@ -114,15 +114,15 @@
|
|
|
114
114
|
${this.operationName==="CollectNetworkHops"?", retryWithoutTraceId: $retryWithoutTraceId":""}
|
|
115
115
|
)
|
|
116
116
|
}
|
|
117
|
-
`}}class
|
|
117
|
+
`}}class Ve extends r.BaseTransmitter{constructor(){super();f(this,"serviceIdentifier",new V);this.setOperationName("CollectNetworkRequest")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(n){this.sendAppIdentifier(),this.send(n)}getQuery(){return`
|
|
118
118
|
mutation ${this.operationName}(
|
|
119
119
|
$data: NetworkRequestInput!
|
|
120
120
|
) {
|
|
121
121
|
${this.queryName}(
|
|
122
122
|
data: $data)
|
|
123
123
|
}
|
|
124
|
-
`}async send(n){const i={data:{...n}};await r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),i)}}const
|
|
125
|
-
`).slice(1),c=[];for(const d of g)if(!(d.includes("node:internal")||d.includes("internal/modules")||d.includes("internal/process")||d.includes("node_modules")||d.includes(".next/server/chunks")||d.includes("RequestInterceptor")||d.includes("contextManager")||d.includes("setupConfig"))&&(c.push(d.trim()),c.length>=n))break;for(const d of c){const I=this.parseStackFrame(d);I?(async()=>{const{originalPos:
|
|
124
|
+
`}async send(n){const i={data:{...n}};await r.nonBlockingPost(this.endpoint,this.operationName,this.getQuery(),i)}}const z=[400,403];class He{constructor(e=[]){f(this,"HEADER_TRACING","X-Sf3-Rid");f(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");f(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");f(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");f(this,"contextManager");this.contextManager=r.ContextManager.getInstance(),e?.forEach(n=>{typeof n=="string"&&n.trim()&&this.contextManager.getExcludedDomains().add(n)}),r.getConfig().sfDebug&&console.log("[RequestInterceptor] Initialized with static excluded domains.")}extractIdsFromTraceHeader(e,n=this.HEADER_TRACING){let i;if(e instanceof Headers)i=e.get(n)??void 0;else{const s=n.toLowerCase();for(const[l,a]of Object.entries(e))if(l.toLowerCase()===s){i=a;break}}if(!i)return{};const o=i.split("/").filter(Boolean);return o.length<3?{}:{sessionId:o[0],pageVisitId:o[1],requestId:o[o.length-1]}}parseStackFrame(e){const n=/\((.*):(\d+):(\d+)\)$/.exec(e.trim());if(!n)return null;const[,i,o,s]=n;return{filePath:i,line:parseInt(o,10),column:parseInt(s,10)}}async getOriginalPosition(e,n,i){let o={source:e,line:n,column:i,name:null};const s=e+".map";try{const l=JSON.parse(X.readFileSync(s,"utf-8"));let a=(await new O.sourceMapExports.SourceMapConsumer(l)).originalPositionFor({line:n,column:i});a.source&&(o=a)}catch(l){r.getConfig().sfDebug&&console.error(`Could not read/parse map file at ${s}:`,l)}return{originalPos:o}}captureFirstUserLines(e,n=10,i=!1){const o=r.getConfig().sfDebug?10:n,s=Error.stackTraceLimit;Error.stackTraceLimit=Math.max(s,o);const l=new Error(ne);ne in Error&&Error.captureStackTrace(l,this.captureFirstUserLines);const a=l.stack||"";Error.stackTraceLimit=s;const g=a.split(`
|
|
125
|
+
`).slice(1),c=[];for(const d of g)if(!(d.includes("node:internal")||d.includes("internal/modules")||d.includes("internal/process")||d.includes("node_modules")||d.includes(".next/server/chunks")||d.includes("RequestInterceptor")||d.includes("contextManager")||d.includes("setupConfig"))&&(c.push(d.trim()),c.length>=n))break;for(const d of c){const I=this.parseStackFrame(d);I?(async()=>{const{originalPos:C}=await this.getOriginalPosition(I.filePath,I.line,I.column);if(C){r.getConfig().sfDebug&&console.log("[RequestInterceptor] First user code line:",C);const p={line:C.line?.toString()||Y.UNKNOWN,column:C.column?.toString()||Y.NOT_CAPTURED,name:C.name||Y.NOT_CAPTURED,entrypoint:C.source,retryWithoutTraceId:i};e.doSend(p)}})():r.getConfig().sfDebug&&console.error("Could not parse stack line:",d)}}addReentrancyGuardHeaders(e){e.set(this.HEADER_LOG_GUARD,"true"),e.set(this.HEADER_PRINT_GUARD,"true"),e.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(e){return!r.DEFAULT_DOMAINS_TO_EXCLUDE.some(n=>new RegExp(`^${n.replace(/\*/g,".*")}$`).test(e))}addTracingHeaders(e,n){const i=new URL(n).hostname,o=this.shouldPropagateHeaders(i);return o?this.addTracingHeader(e,n):r.getConfig().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${i}`),o}addTracingHeader(e,n){const i=r.getFuncspanOverride();if(i){const a=r.parseHeaderOverride(i);if(a&&a.sample_rate===0)return void(r.getConfig().sfDebug&&console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${n}`))}const o=this.contextManager.getOrSetSfTraceId(),s=this.contextManager.getOrSetPageVisitUUID(),l=r.v4();e.set(this.HEADER_TRACING,`${o}/${s}/${l}`),r.getConfig().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${n}`)}patchFetch(e,n){const i=globalThis.fetch;typeof i=="function"?globalThis.fetch=async(o,s)=>{const l=new Headers(s?.headers);if(l.get(this.HEADER_LOG_GUARD)==="true"||l.get(this.HEADER_PRINT_GUARD)==="true"||l.get(this.HEADER_EXCEPTION_GUARD)==="true")return i(o,s);this.captureFirstUserLines(e);const a=Date.now();let g;typeof o=="string"||o instanceof URL?g=o.toString():o instanceof Request?(g=o.url,o.headers.forEach((u,m)=>{l.set(m,u)})):r.getConfig().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),r.getConfig().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",g);const c=new URL(g).hostname,d=new Headers(l),I=this.addTracingHeaders(l,g),C={...s,headers:l};let p;try{let u=!1;this.addTracingHeaders(d,g),p=await i(g,C),I&&z.includes(p.status)?(p=await i(g,{...s,headers:d}),u=!0,this.captureFirstUserLines(e,10,u)):this.contextManager.addSupportedDomains(c);const m=Date.now();r.getConfig().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${g}, Status: ${p.status}, Duration: ${m-a}ms`);const{sessionId:h,pageVisitId:Z,requestId:b}=this.extractIdsFromTraceHeader(l);return n.doSend({apiKey:r.getConfig().apiKey,requestId:b,pageVisitId:Z,recordingSessionId:h,serviceUuid:r.getConfig().serviceUUID,timestampStart:a.toString(),timestampEnd:m.toString(),responseCode:p.status,success:!0,error:null,url:g,method:C.method||"GET",retryWithoutTraceId:u,parentSpanId:r.getCurrentFunctionSpanId()}),p}catch(u){const m=Date.now();r.getConfig().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${g}, Error: ${u}, Duration: ${m-a}ms`)}}:r.getConfig().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}patchHttp(e,n){if(r.getConfig().sfDebug&&console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."),!G||typeof G.request!="function")return void(r.getConfig().sfDebug&&console.log("[RequestInterceptor] HTTP/HTTPS not available."));const i=G.request.bind(G),o=G.request.bind(G);G.request=function(s,l){let a;try{if(typeof s=="string"){const c=new URL(s);a={protocol:c.protocol||U,hostname:c.hostname,path:c.pathname+c.search,headers:{}}}else s instanceof URL?a={protocol:s.protocol||U,hostname:s.hostname,path:s.pathname+s.search,headers:{}}:(a={...s},a.protocol||(a.protocol=U));if(a.headers){const c=`${a.protocol}//${a.hostname}`;this.addTracingHeaders(a.headers,c),this.captureFirstUserLines(e)}else r.getConfig().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.")}catch(c){throw r.getConfig().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTP request options:",c),c}let g=!1;return i(a,c=>{const d=`${a.protocol}//${a.hostname}`;if(a.headers&&this.shouldPropagateHeaders(new URL(d).hostname)&&z.includes(c.statusCode||0)){a.hostname;const u={...a,headers:{...a.headers}};delete u.headers[this.HEADER_TRACING],i(u,l),g=!0,this.captureFirstUserLines(e,10,g)}const{sessionId:I,pageVisitId:C,requestId:p}=this.extractIdsFromTraceHeader(a.headers);n.doSend({apiKey:r.getConfig().apiKey,requestId:p,pageVisitId:C,recordingSessionId:I,serviceUuid:r.getConfig().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:c.statusCode||0,success:!!c.statusCode&&c.statusCode<400,error:null,url:d,method:a.method||"GET",retryWithoutTraceId:g,parentSpanId:r.getCurrentFunctionSpanId()}),l?.(c)})},G.request=function(s,l){let a;try{if(typeof s=="string"){const c=new URL(s);a={protocol:c.protocol||E,hostname:c.hostname,path:c.pathname+c.search,headers:{}}}else s instanceof URL?a={protocol:s.protocol||E,hostname:s.hostname,path:s.pathname+s.search,headers:{}}:(a={...s},a.protocol||(a.protocol=E));if(a.headers){const c=`${a.protocol}//${a.hostname}`;this.addTracingHeaders(a.headers,c)}else r.getConfig().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.")}catch(c){throw r.getConfig().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTPS request options:",c),c}let g=!1;return o(a,c=>{const d=`${a.protocol}//${a.hostname}`;if(a.headers&&this.shouldPropagateHeaders(new URL(d).hostname)&&z.includes(c.statusCode||0)){const u={...a,headers:{...a.headers}};delete u.headers[this.HEADER_TRACING],o(u,l),g=!0,this.captureFirstUserLines(e,10,g)}const{sessionId:I,pageVisitId:C,requestId:p}=this.extractIdsFromTraceHeader(a.headers);n.doSend({apiKey:r.getConfig().apiKey,requestId:p,pageVisitId:C,recordingSessionId:I,serviceUuid:r.getConfig().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:c.statusCode||0,success:!!c.statusCode&&c.statusCode<400,error:null,url:d,method:a.method||"GET",retryWithoutTraceId:g,parentSpanId:r.getCurrentFunctionSpanId()}),l?.(c)})},r.getConfig().sfDebug&&console.log("✅ HTTP and HTTPS request methods patched globally.")}tryPatch(e,n){try{require.resolve(n),e(),console.log(`[RequestInterceptor] Patched ${n}`)}catch(i){console.warn(`[RequestInterceptor] Could not patch ${n}: ${i.message}`)}}getExcludedDomains(){return[...this.contextManager.getExcludedDomains()]}}class Ye extends x{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const e=`
|
|
126
126
|
${this.queryType} ${this.operationName}(
|
|
127
127
|
$apiKey: String!,
|
|
128
128
|
$serviceUuid: String!,
|
|
@@ -142,6 +142,6 @@
|
|
|
142
142
|
gitSha: $gitSha,
|
|
143
143
|
)
|
|
144
144
|
}
|
|
145
|
-
`,n=this.getVariables({serviceIdentifier:r.getConfig().serviceIdentifier,serviceVersion:r.getConfig().serviceVersion,serviceAdditionalMetadata:r.getConfig().serviceAdditionalMetadata,gitSha:r.getConfig().gitSha||""});r.nonBlockingPost(this.endpoint,this.operationName,e,n)}}class
|
|
146
|
-
📊 Function Span:`,{function:`${
|
|
147
|
-
`;X.appendFileSync(s,I,"utf-8")}catch(s){console.error("[FuncSpan] Error writing to JSONL file:",s)}if(n&&console.log("[FuncSpan] Sending function span to transmitter:",i),process.env.SF_FUNCSPAN_SKIP_BACKEND!=="true")try{(
|
|
145
|
+
`,n=this.getVariables({serviceIdentifier:r.getConfig().serviceIdentifier,serviceVersion:r.getConfig().serviceVersion,serviceAdditionalMetadata:r.getConfig().serviceAdditionalMetadata,gitSha:r.getConfig().gitSha||""});r.nonBlockingPost(this.endpoint,this.operationName,e,n)}}class Re{constructor(e=[process.cwd()],n=!1){f(this,"rootPaths");f(this,"fileConfigs",new Map);f(this,"functionConfigs",new Map);f(this,"directoryConfigs",new Map);f(this,"hasSailfishFiles",!1);f(this,"debug");this.rootPaths=e,this.debug=n||process.env.SF_DEBUG==="true"}async loadAllConfigs(){this.debug&&console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:",this.rootPaths);const e=[];for(const n of this.rootPaths)k.existsSync(n)?await this._walkDirectory(n,e):this.debug&&console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${n}`);e.length>0?(this.hasSailfishFiles=!0,this.debug&&(console.log(`[FuncSpan ConfigLoader] Found ${e.length} .sailfish files:`),e.forEach(n=>console.log(`[FuncSpan ConfigLoader] - ${n}`)))):this.debug&&console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");for(const n of e)await this._loadConfigFile(n);await this._resolveInheritance(),this.debug&&console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`)}getConfig(e,n){const i=this.hasSailfishFiles?r.getEnvConfig():r.getDefaultConfig(),o=this._getDirectoryConfig(e),s=S.normalize(e),l=this.fileConfigs.get(s)||{};let a={};if(n){const g=this.functionConfigs.get(s);g&&(a=g.get(n)||{})}return r.mergeConfigs(i,o,l,a)}async _walkDirectory(e,n){try{const i=k.readdirSync(e,{withFileTypes:!0});for(const o of i){const s=S.join(e,o.name);o.isFile()&&o.name===".sailfish"?n.push(s):o.name==="node_modules"||o.isDirectory()&&o.name.startsWith(".")&&o.name!==".sailfish"||o.isDirectory()&&await this._walkDirectory(s,n)}}catch(i){this.debug&&console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`,i)}}async _loadConfigFile(e){try{const n=k.readFileSync(e,"utf-8"),i=S.dirname(e);let o=null;try{o=JSON.parse(n)}catch{try{o=require("js-yaml").load(n)}catch(s){return void(this.debug&&console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`,s))}}if(!o)return;o.default&&this.directoryConfigs.set(i,o.default),o.files&&await this._expandFileGlobs(i,o.files,o.default||{}),o.functions&&this._storeFunctionConfigs(i,o.functions,o.default||{}),this.debug&&(console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`),console.log(`[FuncSpan ConfigLoader] Directory: ${i}`),console.log(`[FuncSpan ConfigLoader] Has default: ${!!o.default}`),console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(o.files||{}).length}`),console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(o.functions||{}).length}`))}catch(n){this.debug&&console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`,n)}}async _expandFileGlobs(e,n,i){for(const[o,s]of Object.entries(n))try{const l=S.join(e,o),a=await Ae.glob(l,{absolute:!0,nodir:!0,ignore:["**/node_modules/**","**/.git/**"]});this.debug&&console.log(`[FuncSpan ConfigLoader] Pattern '${o}' matched ${a.length} files`);for(const g of a){const c=S.normalize(g),d=r.mergeConfigs(i,s);this.fileConfigs.set(c,d),this.debug&&a.length<=5&&console.log(`[FuncSpan ConfigLoader] - ${g}`)}}catch(l){this.debug&&console.error(`[FuncSpan ConfigLoader] Error expanding glob '${o}':`,l)}}_storeFunctionConfigs(e,n,i){for(const[o,s]of Object.entries(n)){const l=o.split("::");if(l.length!==2){this.debug&&console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${o}' (expected format: 'file.ts::functionName')`);continue}const[a,g]=l,c=S.normalize(S.join(e,a));this.functionConfigs.has(c)||this.functionConfigs.set(c,new Map);const d=this.functionConfigs.get(c),I=r.mergeConfigs(i,s);d.set(g,I),this.debug&&console.log(`[FuncSpan ConfigLoader] Function config: ${c}::${g}`)}}async _resolveInheritance(){}_getDirectoryConfig(e){let n=S.dirname(S.normalize(e));const i=[];for(;n&&n!==S.dirname(n);){const o=this.directoryConfigs.get(n);o&&i.unshift(o),n=S.dirname(n)}return i.reduce((o,s)=>r.mergeConfigs(o,s),{})}}let w=null;async function oe(t,e){w=new Re(t,e),await w.loadAllConfigs()}function ie(t,e){return w?w.getConfig(t,e):(process.env.SF_DEBUG==="true"&&console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"),r.getEnvConfig())}function re(){return w!==null}const Xe=["readFile","writeFile","appendFile","readdir","stat","lstat","fstat","access","open","close","read","write","chmod","mkdir","rmdir","unlink","rename"],se=["lookup","resolve","resolve4","resolve6","resolveAny","resolveMx","resolveNs","resolveTxt","reverse"],Je=["pbkdf2","randomBytes","scrypt","generateKeyPair"],Ke=["gzip","gunzip","deflate","inflate","deflateRaw","inflateRaw","brotliCompress","brotliDecompress"];let ae=!1;function _e(t){if(typeof t!="string")return!1;const e=process.env.SF_FUNCSPAN_JSONL_FILE;if(e&&t.includes(e))return!0;const n=process.env.SF_WORKER_POOL_JSONL_FILE;return!(!n||!t.includes(n))}let ce=!1;function ge(t){if(typeof t!="string")return!1;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0;try{const e=process.env.API_GRAPHQL_ENDPOINT;if(e&&t===new URL(e).hostname)return!0}catch{}return!1}function ke(){if(!ce)try{let t;if(typeof require>"u")return void(process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));try{t=require("node:dns")}catch(e){return void(process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] Failed to require dns module:",e))}if(t.__sf_worker_pool_patched__)return;Object.defineProperty(t,"__sf_worker_pool_patched__",{value:!0,enumerable:!1,writable:!1,configurable:!1});for(const e of se)if(typeof t[e]=="function"){const n=t[e];t[e]=function(...i){return ge(i[0])?n.apply(this,i):typeof i[i.length-1]=="function"?r.captureWorkerPoolOperation("dns",e,n,i,this):n.apply(this,i)},Object.defineProperty(t[e],"name",{value:e,writable:!1})}(function(e){if(!e.promises)return void(process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] dns.promises not available, skipping"));if(!e.promises.__sf_worker_pool_patched__){Object.defineProperty(e.promises,"__sf_worker_pool_patched__",{value:!0,enumerable:!1,writable:!1,configurable:!1});for(const n of se)if(typeof e.promises[n]=="function"){const i=e.promises[n];e.promises[n]=function(...o){return ge(o[0])?i.apply(this,o):r.captureWorkerPoolPromiseOperation("dns",n,i,o,this)},Object.defineProperty(e.promises[n],"name",{value:n,writable:!1})}process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] dns.promises module patched successfully")}})(t),ce=!0,process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] dns module patched successfully")}catch(t){console.error("[WorkerPool] Error patching dns module:",t)}}let le=!1,de=!1,P=!1;function Ie(){if(P)return;const t=process.env.SF_DEBUG==="true";t&&console.log("[WorkerPool] Initializing worker pool patching..."),r.isModuleTrackingEnabled("fs")&&(t&&console.log("[WorkerPool] Patching fs module..."),(function(){if(!ae)try{const e=require("node:fs");if(e.__sf_worker_pool_patched__)return;Object.defineProperty(e,"__sf_worker_pool_patched__",{value:!0,enumerable:!1,writable:!1,configurable:!1});for(const n of Xe)if(typeof e[n]=="function"){const i=e[n];e[n]=function(...o){return _e(o[0])?i.apply(this,o):typeof o[o.length-1]=="function"?r.captureWorkerPoolOperation("fs",n,i,o,this):i.apply(this,o)},Object.defineProperty(e[n],"name",{value:n,writable:!1})}ae=!0,process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] fs module patched successfully")}catch(e){console.error("[WorkerPool] Error patching fs module:",e)}})()),r.isModuleTrackingEnabled("dns")&&(t&&console.log("[WorkerPool] Patching dns module..."),ke()),r.isModuleTrackingEnabled("crypto")&&(t&&console.log("[WorkerPool] Patching crypto module..."),(function(){if(!le)try{const e=require("node:crypto");if(e.__sf_worker_pool_patched__)return;Object.defineProperty(e,"__sf_worker_pool_patched__",{value:!0,enumerable:!1,writable:!1,configurable:!1});for(const n of Je)if(typeof e[n]=="function"){const i=e[n];e[n]=function(...o){return typeof o[o.length-1]=="function"?r.captureWorkerPoolOperation("crypto",n,i,o,this):i.apply(this,o)},Object.defineProperty(e[n],"name",{value:n,writable:!1})}le=!0,process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] crypto module patched successfully")}catch(e){console.error("[WorkerPool] Error patching crypto module:",e)}})()),r.isModuleTrackingEnabled("zlib")&&(t&&console.log("[WorkerPool] Patching zlib module..."),(function(){if(!de)try{const e=require("node:zlib");if(e.__sf_worker_pool_patched__)return;Object.defineProperty(e,"__sf_worker_pool_patched__",{value:!0,enumerable:!1,writable:!1,configurable:!1});for(const n of Ke)if(typeof e[n]=="function"){const i=e[n];e[n]=function(...o){return typeof o[o.length-1]=="function"?r.captureWorkerPoolOperation("zlib",n,i,o,this):i.apply(this,o)},Object.defineProperty(e[n],"name",{value:n,writable:!1})}de=!0,process.env.SF_DEBUG==="true"&&console.log("[WorkerPool] zlib module patched successfully")}catch(e){console.error("[WorkerPool] Error patching zlib module:",e)}})()),P=!0,t&&console.log("[WorkerPool] Worker pool patching initialized")}function ue(){return P}let L=!1,$=!1,D=null;function H(t){const e=r.getGlobalConfigUnsafe(),n=e?.sfDebug||!1;n&&console.log("[FuncSpan] captureSpanData called for:",{function:t.functionName,file:t.filePath,duration:`${t.duration}ms`,async:t.async,error:t.error,spanId:t.spanId});const i={functionName:t.functionName,filePath:t.filePath,metadata:t.metadata,args:t.args,result:t.result,error:t.error,duration:t.duration,durationNs:t.durationNs,async:t.async,spanId:t.spanId,parentSpanId:t.parentSpanId};process.env.SF_FUNCSPAN_CONSOLE_OUTPUT==="true"&&console.log(`
|
|
146
|
+
📊 Function Span:`,{function:`${t.functionName} (${t.filePath}:${t.metadata.line}:${t.metadata.column})`,duration:`${t.duration.toFixed(2)}ms`,arguments:t.args,result:t.error?`Error: ${t.error}`:t.result,spanId:t.spanId,parentSpanId:t.parentSpanId||"none"});const o=process.env.SF_FUNCSPAN_JSONL_FILE;if(o)try{const s=o==="true"||o==="1"?"funcspans.jsonl":o,l=Date.now(),a=process.hrtime.bigint(),g=BigInt(t.startTimeNs),c=Number(a-g)/1e6,d=new Date(l-c).toISOString(),I=JSON.stringify({timestamp:d,functionName:t.functionName,filePath:t.filePath,line:t.metadata.line,column:t.metadata.column,duration:t.duration,durationNs:t.durationNs,startTimeNs:t.startTimeNs,arguments:t.args,returnValue:t.error?{error:String(t.error)}:t.result,spanId:t.spanId,parentSpanId:t.parentSpanId,async:t.async,pid:t.pid,threadId:t.threadId})+`
|
|
147
|
+
`;X.appendFileSync(s,I,"utf-8")}catch(s){console.error("[FuncSpan] Error writing to JSONL file:",s)}if(n&&console.log("[FuncSpan] Sending function span to transmitter:",i),process.env.SF_FUNCSPAN_SKIP_BACKEND!=="true")try{(D||(D=new r.FunctionSpanTransmitter),D).send([i]),n&&console.log("[FuncSpan] Function span sent successfully")}catch(s){n&&console.error("[FuncSpan] Error sending function span:",s)}}exports.ContextManager=r.ContextManager,exports.clearFuncspanOverride=r.clearFuncspanOverride,exports.getCurrentFunctionSpanId=r.getCurrentFunctionSpanId,exports.getDefaultConfig=r.getDefaultConfig,exports.getEnvConfig=r.getEnvConfig,exports.getFuncspanOverride=r.getFuncspanOverride,exports.parseHeaderOverride=r.parseHeaderOverride,exports.runWithContext=r.runWithContext,exports.setFuncspanOverride=r.setFuncspanOverride,exports.transformFunctionSpans=O.transformFunctionSpans,exports.addOrUpdateMetadata=function(t,e={},n,i=!1){const o=r.getConfig();new M(o.apiKey).addOrUpdateMetadata(t,e,n,i)},exports.captureFunctionSpan=function(t,e,n,i){const o=function(...s){const l=r.getGlobalConfigUnsafe(),a=l?.sfDebug||!1;a&&console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${n}::${e}`);const g=(function(m,h){const Z=r.getFuncspanOverride();if(Z){const b=r.parseHeaderOverride(Z);if(b)return process.env.SF_DEBUG==="true"&&console.log(`[FuncSpan] Using HTTP header override for ${m}::${h}`),b}try{return ie(m,h)}catch{return{sample_rate:process.env.SF_FUNCSPAN_SAMPLE_RATE?parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE):1,capture_arguments:!0,capture_return_value:!0,arg_limit_mb:1,return_limit_mb:1,enable_sampling:!1,autocapture_all_child_functions:!1,capture_sf_veritas:!1,parse_json_strings:!1}}})(n,e);if(a&&console.log(`[FuncSpan] Config for ${n}::${e}:`,g),g.enable_sampling&&g.sample_rate<1&&Math.random()>g.sample_rate)return a&&console.log(`[FuncSpan] Skipping ${e} due to sampling`),t.apply(this,s);if(g.sample_rate===0)return a&&console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`),t.apply(this,s);a&&console.log(`[FuncSpan] Capturing function span for ${e}`);const c=r.ContextManager.getInstance(),d=c.getCurrentFunctionSpanId(),I=r.v4();c.setCurrentFunctionSpanId(I);const C=process.hrtime.bigint(),p=Date.now();let u=null;g.capture_arguments&&(u={},i.paramNames.forEach((m,h)=>{h<s.length&&(u[m]=s[h])}),u&&g.arg_limit_mb>0&&(u=r.truncateToLimit(u,g.arg_limit_mb)));try{const m=t.apply(this,s);if(m&&typeof m.then=="function")return d?c.setCurrentFunctionSpanId(d):c.clearCurrentFunctionSpanId(),m.then(A=>{const v=process.hrtime.bigint(),J=Date.now(),K=Number(v-C);let j=null;return g.capture_return_value&&g.return_limit_mb>0&&(j=r.truncateToLimit(A,g.return_limit_mb)),H({functionName:e,filePath:n,metadata:i,args:u,result:j,error:null,duration:J-p,durationNs:K,startTimeNs:C.toString(),async:!0,spanId:I,parentSpanId:d,pid:process.pid,threadId:N.threadId}),A},A=>{const v=process.hrtime.bigint(),J=Date.now(),K=Number(v-C);throw H({functionName:e,filePath:n,metadata:i,args:u,result:null,error:A?.message||String(A),duration:J-p,durationNs:K,startTimeNs:C.toString(),async:!0,spanId:I,parentSpanId:d,pid:process.pid,threadId:N.threadId}),A});const h=process.hrtime.bigint(),Z=Date.now(),b=Number(h-C);let y=null;return g.capture_return_value&&g.return_limit_mb>0&&(y=r.truncateToLimit(m,g.return_limit_mb)),H({functionName:e,filePath:n,metadata:i,args:u,result:y,error:null,duration:Z-p,durationNs:b,startTimeNs:C.toString(),async:!1,spanId:I,parentSpanId:d,pid:process.pid,threadId:N.threadId}),d?c.setCurrentFunctionSpanId(d):c.clearCurrentFunctionSpanId(),m}catch(m){const h=process.hrtime.bigint(),Z=Date.now(),b=Number(h-C);throw H({functionName:e,filePath:n,metadata:i,args:u,result:null,error:m?.message||String(m),duration:Z-p,durationNs:b,startTimeNs:C.toString(),async:!1,spanId:I,parentSpanId:d,pid:process.pid,threadId:N.threadId}),d?c.setCurrentFunctionSpanId(d):c.clearCurrentFunctionSpanId(),m}};Object.defineProperty(o,"name",{value:e,writable:!1});for(const s in t)t.hasOwnProperty(s)&&(o[s]=t[s]);return o},exports.getGlobalConfig=ie,exports.identify=function(t,e,n,i=!1){const o=r.getConfig();new M(o.apiKey).identify(t,e,n,i)},exports.initializeConfigLoader=oe,exports.initializeWorkerPoolPatching=Ie,exports.isConfigLoaderInitialized=re,exports.isSetupInterceptorsInitialized=function(){return L},exports.isWorkerPoolInitialized=ue,exports.setupInterceptors=function(t){if($)console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");else if(!L){$=!0;try{if(!t||!t.apiKey){const o=`The required API Key is not provided: ${JSON.stringify(t)}`;console.error(o)}const{config:e}=r.getOrCreateConfig(t);if(e.sfDebug&&console.log("Updated configuration after applying options:",e),!e.apiKey||!e.apiGraphqlEndpoint){const o=`The required config is not provided: ${JSON.stringify(e)}`;throw console.error(o),new Error(o)}re()||oe(void 0,e.sfDebug).catch(o=>{e.sfDebug&&console.error("[FuncSpan] Failed to initialize config loader:",o)}),process.env.SF_WORKER_POOL_DISABLED==="true"?e.sfDebug&&console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)"):ue()||(Ie(),e.sfDebug&&console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));const n=new x;n.setServiceUUID(e.serviceUUID),(function(o){function s(I,C){o.setOperationName("CollectLogs"),o.doSend([C,I])}const l=console.log.bind(console),a=console.error.bind(console),g=console.warn.bind(console),c=console.info.bind(console),d=console.debug.bind(console);console.log=(...I)=>{s("INFO",I.join(" ")),l(...I)},console.error=(...I)=>{s("ERROR",I.join(" ")),a(...I)},console.warn=(...I)=>{s("WARN",I.join(" ")),g(...I)},console.info=(...I)=>{s("INFO",I.join(" ")),c(...I)},r.getConfig().logLevel==="DEBUG"&&(console.debug=(...I)=>{s("DEBUG",I.join(" ")),d(...I)})})(n),(function(o=[]){const s=new He(o);new Fe().doSend(s.getExcludedDomains());const l=new we,a=new Ve;s.patchFetch(l,a),s.patchHttp(l,a)})(e.domainsToNotPropagateHeadersTo);const i=new ve;i.setServiceUUID(e.serviceUUID),Se(i),Ne(),new Ye().send(),L=!0,e.sfDebug&&console.log("[setupInterceptors] ✅ Initialization complete")}finally{$=!1}}};
|