@datadog/vite-plugin 3.3.2-dev.1 → 3.3.2-dev.3

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
+ const n=["datadoghq.com","us3.datadoghq.com","us5.datadoghq.com","datadoghq.eu","ddog-gov.com","us2.ddog-gov.com","ap1.datadoghq.com","ap2.datadoghq.com","datad0g.com"];function e(n){return null!==n&&"object"==typeof n}let t=0;function o(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();t+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${t}-${n}`}function r(e){let t;try{t=new URL(e)}catch{return!1}const o=t.hostname.endsWith(".")?t.hostname.slice(0,-1):t.hostname;return"https:"===t.protocol&&""===t.port&&void 0!==(e=>{if("string"!=typeof e)return;const t=e.toLowerCase(),o=n.find((n=>n===t));if(o)return{site:o};const r=n.filter((n=>t.endsWith(`.${n}`)));if(!r.length)return;const i=r.reduce(((n,e)=>e.length>n.length?e:n)),a=t.slice(0,t.length-i.length-1);return a&&/^[a-z0-9-]+$/.test(a)?{site:i,subdomain:a}:void 0})(o)}let i,a,s=0,d=!1;function c(n){var t;n.source===window.parent&&(e(t=n.data)&&"type"in t&&("app-builder:pong"===t.type||"app-builder:run-query:response"===t.type))&&(i=n.origin,window.removeEventListener("message",c),a?.end())}async function u(n){const e=window.location.ancestorOrigins;return e?e[0]:(n&&await function(){if(void 0!==a)return a.answered;window.addEventListener("message",c);let n=()=>{};const e=new Promise((e=>{n=e})),t=setTimeout(i,2e3);function r(){clearTimeout(t),a=void 0,n()}function i(){s+=1,r()}a={answered:e,end:r};const d={type:"app-builder:ping",requestId:o()};try{window.parent.postMessage(d,"*")}catch{i()}return e}(),i)}function l(n,e){console.warn(`[dd-apps] Sending "${n}" without its dev server bundle: ${e}`)}async function g(n){const t={functionName:n},o=JSON.stringify(t),r=new AbortController,i=setTimeout((()=>{const n=new Error("timed out after 60000ms");r.abort(n)}),6e4);try{const n=await fetch("/__dd/debugBundle",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o,signal:r.signal});if(!n.ok){const t=await async function(n){const t=`HTTP ${n.status}`;try{const o=await n.json();return e(o)&&"error"in o&&"string"==typeof o.error?`${t}: ${o.error}`:t}catch{return t}}(n);return{failure:t}}const t=await n.json();return e(a=t)&&"code"in a&&"string"==typeof a.code&&a.code.length>0&&"allowedConnectionIds"in a&&Array.isArray(a.allowedConnectionIds)&&a.allowedConnectionIds.every((n=>"string"==typeof n))?{bundle:{code:t.code,allowedConnectionIds:t.allowedConnectionIds}}:{failure:"the dev server response is not a bundle"}}catch(n){return{failure:n instanceof Error?n.message:String(n)}}finally{clearTimeout(i)}var a}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async n=>{const e=!window.location.ancestorOrigins&&window.parent!==window&&void 0===i&&s<2,t=e?g(n):void 0,o=await u(e);if(void 0===o&&e&&function(n){d||(d=!0,l(n,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(n),void 0===o||!r(o))return{};const a=await(t??g(n));return"failure"in a?(l(n,a.failure),{targetOrigin:o}):{targetOrigin:o,bundle:a.bundle}}));
@@ -1 +1 @@
1
- class e extends Error{constructor(e,t,n){super(e),this.functionName=t,this.statusCode=n,this.name="BackendFunctionError"}}const t=async(t,n)=>{const r={functionName:t,args:n};let o,s;try{o=await fetch("/__dd/executeAction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch(n){throw new e(`Network error while executing backend function "${t}": ${n instanceof Error?n.message:String(n)}`,t)}if(!o.ok){let n=`Backend function "${t}" failed with status ${o.status}`;try{const e=await o.text();e&&(n+=`: ${e}`)}catch{}throw new e(n,t,o.status)}try{s=await o.json()}catch(n){throw new e(`Failed to parse response from backend function "${t}": ${n instanceof Error?n.message:String(n)}`,t,o.status)}if(!s.success)throw new e(`Backend function "${t}" returned an error: ${s.error}`,t,o.status);return s.result.data};let n=0;const r=(t,r)=>{const o="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():(n+=1,`req-${Date.now()}-${n}`);return new Promise(((n,s)=>{let a;function i(){window.removeEventListener("message",c),clearTimeout(a)}function c(r){if(!function(e,t){return null!==e&&"object"==typeof e&&"type"in e&&"app-builder:run-query:response"===e.type&&"requestId"in e&&e.requestId===t}(r.data,o))return;i();const a=r.data;a.success?n(a.result.data):s(new e(a.error??`Backend function "${t}" failed`,t))}window.addEventListener("message",c),a=setTimeout((()=>{i(),s(new e(`Backend function "${t}" timed out waiting for response`,t))}),12e4),window.parent.postMessage({type:"app-builder:run-query",requestId:o,queryName:t,args:r},"*")}))};function o(){return function(){try{return"undefined"!=typeof window&&window.parent!==window}catch{return!0}}()?r:t}globalThis.DD_APPS_RUNTIME={executeBackendFunction:async function(e,t){return o()(e,t)}};
1
+ class e extends Error{constructor(e,n,t){super(e),this.functionName=n,this.statusCode=t,this.name="BackendFunctionError"}}const n=async(n,t)=>{const r={functionName:n,args:t};let o,i;try{o=await fetch("/__dd/executeAction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch(t){throw new e(`Network error while executing backend function "${n}": ${t instanceof Error?t.message:String(t)}`,n)}if(!o.ok){let t=`Backend function "${n}" failed with status ${o.status}`;try{const e=await o.text();e&&(t+=`: ${e}`)}catch{}throw new e(t,n,o.status)}try{i=await o.json()}catch(t){throw new e(`Failed to parse response from backend function "${n}": ${t instanceof Error?t.message:String(t)}`,n,o.status)}if(!i.success)throw new e(`Backend function "${n}" returned an error: ${i.error}`,n,o.status);return i.result.data};function t(e){return null!==e&&"object"==typeof e}let r=0;const o=12e4;function i(e){if(!t(e))return;const n="allowedConnectionIds"in e?e.allowedConnectionIds:void 0,r={code:"code"in e?e.code:void 0,allowedConnectionIds:Array.isArray(n)?n.slice():void 0};return t(o=r)&&"code"in o&&"string"==typeof o.code&&o.code.length>0&&"allowedConnectionIds"in o&&Array.isArray(o.allowedConnectionIds)&&o.allowedConnectionIds.every((e=>"string"==typeof e))?r:void 0;var o}function c(e){try{if(!t(e))return{};const n="targetOrigin"in e?e.targetOrigin:void 0;if(!function(e){if("string"!=typeof e)return!1;try{return new URL(e).origin===e}catch{return!1}}(n))return{};const r=i("bundle"in e?e.bundle:void 0);return void 0===r?{targetOrigin:n}:{targetOrigin:n,bundle:r}}catch{return{}}}function s(n,i,{targetOrigin:c,bundle:s}){const a=function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();r+=1;const e=Math.random().toString(36).slice(2);return`req-${Date.now()}-${r}-${e}`}();return new Promise(((r,u)=>{let d;function f(){window.removeEventListener("message",l),clearTimeout(d)}function l(o){const i=o.data;if(o.source!==window.parent||!function(e,n){return t(e)&&"type"in e&&"app-builder:run-query:response"===e.type&&"requestId"in e&&e.requestId===n}(i,a))return;if(f(),!0===i.success&&t(i.result))return void r(i.result.data);const c="error"in i?i.error:void 0,s=new e("string"==typeof c?c:`Backend function "${n}" failed`,n);u(s)}window.addEventListener("message",l),d=setTimeout((()=>{f(),u(new e(`Backend function "${n}" timed out waiting for response`,n))}),o);const w={type:"app-builder:run-query",requestId:a,queryName:n,args:i,...s&&{bundle:s}};try{window.parent.postMessage(w,c??"*")}catch(e){f(),u(e)}}))}const a=(e,n)=>{const t=function(){try{return Reflect.get(globalThis,"DD_APPS_PREPARE_CALL")}catch{return}}();if("function"!=typeof t)return s(e,n,{});let r;const i=new Promise((e=>{r=setTimeout((()=>e({})),o)})),a=Promise.resolve().then((()=>t(e))).catch((()=>({})));return Promise.race([a,i]).then((t=>{clearTimeout(r);const o=c(t);return s(e,n,o)}))};function u(){return function(){try{return"undefined"!=typeof window&&window.parent!==window}catch{return!0}}()?a:n}globalThis.DD_APPS_RUNTIME={executeBackendFunction:async function(e,n){return u()(e,n)}};
@@ -23,6 +23,17 @@ type LongPollingOptions = {
23
23
  */
24
24
  timeoutMs?: number;
25
25
  };
26
+ type AppsParameterSchema = {
27
+ name: string;
28
+ type: "STRING" | "NUMBER" | "BOOLEAN";
29
+ defaultValue: string | number | boolean;
30
+ label?: string;
31
+ description?: string;
32
+ enum?: readonly string[];
33
+ };
34
+ type AppsParameters = {
35
+ readonly schema: readonly AppsParameterSchema[];
36
+ };
26
37
  type AppsOptions = {
27
38
  enable?: boolean;
28
39
  include?: string[];
@@ -33,6 +44,12 @@ type AppsOptions = {
33
44
  tags?: string[];
34
45
  /** Controls how the dev server retries the Datadog long-poll execution endpoint. */
35
46
  longPolling?: LongPollingOptions;
47
+ /**
48
+ * Overrides the parameters found in app code. By default the build reads
49
+ * every `defineDatadogAppParameters({...})` call, so this is only needed
50
+ * for declarations the build cannot read.
51
+ */
52
+ parameters?: AppsParameters;
36
53
  };
37
54
  declare const CONFIG_KEY: "apps";
38
55
  declare const PLUGIN_NAME: PluginName;
@@ -48,6 +65,7 @@ type SourcemapsUploadOptions = {
48
65
  };
49
66
  type DebugIdSourcemapsOptions = SourcemapsUploadOptions & {
50
67
  debugId: true;
68
+ experimentalDuplicateCheck?: boolean;
51
69
  minifiedPathPrefix?: never;
52
70
  releaseVersion?: never;
53
71
  service?: never;
@@ -5398,12 +5416,14 @@ type SourcemapsUploadEnabledOptions = {
5398
5416
  upload: true;
5399
5417
  bailOnError?: boolean;
5400
5418
  dryRun?: boolean;
5419
+ experimentalDuplicateCheck?: boolean;
5401
5420
  maxConcurrency?: number;
5402
5421
  };
5403
5422
  type SourcemapsInjectionOnlyOptions = {
5404
5423
  upload?: false;
5405
5424
  bailOnError?: never;
5406
5425
  dryRun?: never;
5426
+ experimentalDuplicateCheck?: never;
5407
5427
  maxConcurrency?: never;
5408
5428
  };
5409
5429
  type SourcemapsOptions$1 = {