@datadog/esbuild-plugin 3.4.0-dev.1 → 3.4.0

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.
@@ -0,0 +1 @@
1
+ import t from"node:module";const e="is blocked when running backend functions locally.",n="It may work in production; run `dev:verify` (`npx datadog-apps dev --verify`) to check it on the real runtime. Rules: https://github.com/DataDog/build-plugins/tree/master/packages/plugins/apps#local-execution",o=`Loading a native addon ${e} ${n}`,i=`This operation ${e} ${n}`,r=new Map([["ChildProcess",`Spawning a subprocess ${e} ${n}`],["WorkerThreads",`Starting a worker thread ${e} ${n}`],["FileSystemWrite",`Writing outside the call's temp dirs ${e} ${n}`],["FileSystemRead",`Reading outside the folders a call can read ${e} ${n}`],["Inspector",i],["WASI",i],["Net",i],["Addons",i]]);function s(t){if(!process.permission)return t;try{const e=t instanceof Error?function(t){const e="code"in t?t.code:void 0;if("ERR_DLOPEN_DISABLED"===e)return o;if("ERR_ACCESS_DENIED"!==e||!("permission"in t))return;const n=String(t.permission),s="resource"in t?t.resource:void 0;if(""===n&&""===s)return`${i} Refused: ${t.message}`;const a=r.get(n);if(void 0===a)return;return n.startsWith("FileSystem")&&"string"==typeof s&&s?`${a} Refused: ${s}`:a}(t):void 0;if(!(t instanceof Error)||void 0===e)return t;const n=new Error(e),s=("string"==typeof t.stack?t.stack.split("\n"):[]).filter((t=>t.startsWith(" at ")));return n.stack=[`Error: ${e}`,...s].join("\n"),n}catch{return t}}function a(t){try{return t instanceof Error?t.message:String(t)}catch{return`A thrown ${typeof t} that can't be converted to a string`}}function c(t){return"object"==typeof t&&null!==t}function u(t){throw t}class l extends Error{constructor(t,e){super(t),this.detail=e}}async function d(t){try{return await t()}catch(t){const{message:e,detail:n}=function(t){try{if(t instanceof Error){const e="string"==typeof t.stack?t.stack:String(t);return{message:String(t.message),detail:e}}const e=String(t);return{message:e,detail:e}}catch{const e=a(t);return{message:e,detail:e}}}(t);throw new l(e,n)}}function p(t,e){if(Object.prototype.hasOwnProperty.call(t,"allowedConnectionIds"))throw new Error(`Action ${e} must not declare its own allowedConnectionIds in inputs — this function's own allowlist already governs which connections it can use.`)}function f(t,e=[]){return new Proxy((function(){}),{get(n,o){if("then"===o||"toJSON"===o)return;const i=e.concat(String(o));return f(t,i)},async apply(n,o,i){const r=e.join(".");0===i.length&&u(`No arguments provided to action $.Actions.${r}`);const s=c(i[0])?i[0]:{};return t(`com.datadoghq.${r}`,s,`$.Actions.${r}`)}})}class y extends Error{}function h(t,e){let n;try{let o=!0;n=JSON.stringify(t,(function(t,n){const i=o;if(o=!1,null!==n&&"object"==typeof n&&Object.getOwnPropertySymbols(n).length>0)throw new y(`${e} contains a Symbol-keyed property${t?` (at "${t}")`:""}, which JSON.stringify silently drops instead of serializing — use a plain JSON-compatible value instead.`);if(n instanceof Map||n instanceof Set)throw new y(`${e} contains a ${n.constructor.name}${t?` (at "${t}")`:""}, which JSON.stringify silently flattens to "{}" instead of serializing its entries — use a plain array or object instead.`);if("number"==typeof n&&!Number.isFinite(n))throw new y(`${e} contains ${n}${t?` (at "${t}")`:""}, which JSON.stringify silently converts to "null" instead of throwing — use a finite number instead.`);if(!i&&void 0===n&&Array.isArray(this))throw new y(`${e} contains undefined inside an array (at index ${t}), which JSON.stringify silently converts to null instead of dropping it — use null explicitly instead.`);if(!i&&("function"==typeof n||"symbol"==typeof n)&&Array.isArray(this))throw new y(`${e} contains a ${typeof n} inside an array (at index ${t}), which JSON.stringify silently converts to null instead of dropping it — use null explicitly instead.`);if(!(i||"function"!=typeof n&&"symbol"!=typeof n||Array.isArray(this)))throw new y(`${e} contains a ${typeof n} (at "${t}"), which JSON.stringify silently drops instead of serializing — use a plain JSON-compatible value instead.`);return n}))}catch(t){if(t instanceof y)throw t;throw new Error(`${e} can't be serialized to JSON: ${t instanceof Error?t.message:String(t)}`)}if(void 0!==n)return JSON.parse(n);if(void 0!==t)throw new Error(`${e} is a ${typeof t} value, which JSON.stringify silently drops instead of serializing — use a plain JSON-compatible value instead.`)}const g=process.send?.bind(process);let m=0;const w=new Map,$=new Map;function v(t){return new Promise(((e,n)=>{g?g(t,void 0,void 0,(t=>t?n(t):e())):n(new Error("Local execution child process has no IPC channel."))}))}function b(t,e,n){return new Promise(((o,i)=>{t.set(e,{resolve:o,reject:i}),v(n).catch((n=>{t.delete(e),i(n)}))}))}function S(t){const e=++m;return b(w,e,{type:"invoke",id:e,payload:t})}async function k(t,e,n){const{inputs:o,connectionId:i}=function(t,e){const{inputs:n,connectionId:o}=t;return"object"==typeof n&&n||u(`First argument to action ${e} must have an inputs field that is an object`),p(n,e),{inputs:n,connectionId:o}}(e,n),r=function(t,e){const n=`Inputs to action ${e}`,o=h(t,n);if(!c(o)||Array.isArray(o))throw new Error(`${n} must be a plain object after JSON round-tripping, but a custom toJSON() changed its top-level shape to ${Array.isArray(o)?"an array":null===o?"null":typeof o} — return a plain JSON-compatible object instead.`);return o}(o,n);p(r,n);const s=++m;return b($,s,{type:"action",id:s,actionId:t,description:n,inputs:r,...void 0===i?{}:{connectionId:i}})}function E(e){if("start"===e.type)(async function(e){let n;try{const o=await async function(e){const{ModuleRunner:n,ESModulesEvaluator:o,createNodeImportMeta:i}=await import(e.moduleRunnerUrl);Reflect.set(globalThis,"$",void 0);const r=new o,a={transport:{invoke:S},hmr:!1,...(!("permission"in process)||"registerHooks"in t)&&{createImportMeta:i}},u=new n(a,r),l=await u.import(e.entryUrl),p=l[e.functionName];if("function"!=typeof p)throw new Error(`"${e.functionName}" is not a function exported from ${e.entryPath}`);const y={...e.runtimeContext,backendFunctionArgs:e.args,Actions:f(k)};Reflect.set(globalThis,"$",y),await async function(t,e,n){if(e.actionCatalogInstalled){const e=await t.import("@datadog/action-catalog/action-execution"),{setExecuteActionImplementation:n}=e;"function"==typeof n&&n(((t,e)=>k(t,c(e)?e:{},`"${t}"`)))}if(e.appsBackendInstalled){const[e,o]=await Promise.all([t.import("@datadog/apps-backend/runtime/jsFunctionWithActions"),t.import("@datadog/apps-backend/runtime")]),{buildRuntimeFromJsFunctionWithActions:i}=e,{setBackend:r}=o;if("function"==typeof i&&"function"==typeof r){r(i(n))}}}(u,e,y),await v({type:"loaded"});const g=await d((async()=>{try{return await p(...e.args)}catch(t){throw s(t)}})),m=(w=e.functionName,`Local execution of "${w}"'s return value`);var w;return h(g,m)}(e);n={type:"result",data:o}}catch(t){const e=s(t);n={type:"error",message:a(e),...e instanceof l&&{detail:e.detail}}}const o=O(process.stdout,N,e.flushTimeoutMs),i=O(process.stderr,A,e.flushTimeoutMs);await Promise.all([o,i]),await v(n)})(e.config).catch((()=>{}));else if("invoke-result"===e.type)w.get(e.id)?.resolve(e.response),w.delete(e.id);else if("action-result"===e.type){const t=$.get(e.id);if($.delete(e.id),e.ok)t?.resolve(e.value);else{const n=e.thrownString?e.message:new Error(e.message);t?.reject(n)}}}const N=process.stdout.write,A=process.stderr.write;function O(t,e,n){return new Promise((o=>{const i=setTimeout(o,n);Reflect.apply(e,t,["",()=>{clearTimeout(i),o()}])}))}process.on("disconnect",(()=>process.exit(1))),process.on("message",(t=>{(function(t){return!!c(t)&&("start"===t.type?c(t.config):"invoke-result"===t.type?"number"==typeof t.id:"action-result"===t.type&&"number"==typeof t.id&&(!0===t.ok||!1===t.ok&&"string"==typeof t.message))})(t)&&E(t)}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datadog/esbuild-plugin",
3
3
  "packageManager": "yarn@4.0.2",
4
- "version": "3.4.0-dev.1",
4
+ "version": "3.4.0",
5
5
  "license": "MIT",
6
6
  "author": "Datadog",
7
7
  "description": "Datadog ESBuild Plugin",
@@ -53,7 +53,7 @@
53
53
  "watch": "yarn build --watch"
54
54
  },
55
55
  "dependencies": {
56
- "@datadog/js-instrumentation-wasm": "1.0.8",
56
+ "@datadog/js-instrumentation-wasm": "1.1.0",
57
57
  "@jridgewell/remapping": "2.3.5",
58
58
  "async-retry": "1.3.3",
59
59
  "chalk": "2.3.1",
@@ -65,10 +65,10 @@
65
65
  "magic-string": "0.30.21",
66
66
  "outdent": "0.8.0",
67
67
  "p-queue": "6.6.2",
68
- "picomatch": "4.0.3",
68
+ "picomatch": "4.0.7",
69
69
  "pretty-bytes": "5.6.0",
70
- "rollup": "4.45.1",
71
- "simple-git": "3.36.0",
70
+ "semver": "7.7.2",
71
+ "simple-git": "4.0.2",
72
72
  "unplugin": "2.3.11"
73
73
  },
74
74
  "devDependencies": {
@@ -87,7 +87,7 @@
87
87
  "@types/babel__preset-env": "^7",
88
88
  "dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
89
89
  "esbuild": "0.25.8",
90
- "rollup": "4.45.1",
90
+ "rollup": "4.60.4",
91
91
  "rollup-plugin-esbuild": "6.1.1",
92
92
  "typescript": "5.4.3"
93
93
  },
@@ -107,6 +107,5 @@
107
107
  "@babel/types": {
108
108
  "optional": true
109
109
  }
110
- },
111
- "stableVersion": "3.3.0"
110
+ }
112
111
  }