@datadog/rspack-plugin 3.4.0-dev.0 → 3.4.0-dev.6328

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 e=["datadoghq.com","us3.datadoghq.com","us5.datadoghq.com","datadoghq.eu","ddog-gov.com","us2.ddog-gov.com","ap1.datadoghq.com","ap2.datadoghq.com","uk1.datadoghq.com","datad0g.com"],n=new Set(["api","app"]);function t(e){return null!==e&&"object"==typeof e}let o=0;function r(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();o+=1;const e=Math.random().toString(36).slice(2);return`req-${Date.now()}-${o}-${e}`}function a(t){let o;try{o=new URL(t)}catch{return!1}const r=o.hostname.endsWith(".")?o.hostname.slice(0,-1):o.hostname;return"https:"===o.protocol&&""===o.port&&void 0!==(t=>{if("string"!=typeof t)return;const o=(e=>(e.trim().replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").split(/[/?#]/)[0]??"").trim().toLowerCase())(t),r=e.find((e=>e===o));if(r)return{site:r};const a=e.filter((e=>o.endsWith(`.${e}`)));if(!a.length)return;const i=a.reduce(((e,n)=>n.length>e.length?n:e)),s=o.slice(0,o.length-i.length-1);return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)?n.has(s)?{site:i}:{site:i,subdomain:s}:void 0})(r)}let i,s,c=0,d=!1,u=!1;function l(e){var n;e.source===window.parent&&(t(n=e.data)&&"type"in n&&("app-builder:pong"===n.type||"app-builder:run-query:response"===n.type))&&(i=e.origin,window.removeEventListener("message",l),s?.end())}async function p(e){const n=window.location.ancestorOrigins;return n?n[0]:(e&&await function(){if(void 0!==s)return s.answered;window.addEventListener("message",l);let e=()=>{};const n=new Promise((n=>{e=n})),t=setTimeout(a,2e3);function o(){clearTimeout(t),s=void 0,e()}function a(){c+=1,o()}s={answered:n,end:o};const i={type:"app-builder:ping",requestId:r()};try{window.parent.postMessage(i,"*")}catch{a()}return n}(),i)}function g(e,n){console.warn(`[dd-apps] Sending "${e}" without its dev server bundle: ${n}`)}async function f(e){const n={functionName:e},o=JSON.stringify(n),r=new AbortController,a=setTimeout((()=>{const e=new Error("timed out after 60000ms");r.abort(e)}),6e4);try{const e=await fetch("/__dd/debugBundle",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o,signal:r.signal});if(!e.ok){const n=await async function(e){const n=`HTTP ${e.status}`;try{const o=await e.json();return t(o)&&"error"in o&&"string"==typeof o.error?`${n}: ${o.error}`:n}catch{return n}}(e);return{failure:n}}const n=await e.json();return t(i=n)&&"code"in i&&"string"==typeof i.code&&i.code.length>0&&"allowedConnectionIds"in i&&Array.isArray(i.allowedConnectionIds)&&i.allowedConnectionIds.every((e=>"string"==typeof e))?{bundle:{code:n.code,allowedConnectionIds:n.allowedConnectionIds}}:{failure:"the dev server response is not a bundle"}}catch(e){return{failure:e instanceof Error?e.message:String(e)}}finally{clearTimeout(a)}var i}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async e=>{const n=!window.location.ancestorOrigins&&window.parent!==window&&void 0===i&&c<2,t=n?f(e):void 0,o=await p(n);if(void 0===o&&n&&function(e){d||(d=!0,g(e,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(e),"null"===o&&function(e){u||(u=!0,g(e,'the parent page has an opaque origin ("null"), so it can\'t be confirmed as a Datadog page'))}(e),void 0===o||!a(o))return{};const r=await(t??f(e));return"failure"in r?(g(e,r.failure),{targetOrigin:o}):{targetOrigin:o,bundle:r.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 n extends Error{constructor(n,t,e){super(n),this.functionName=t,this.statusCode=e,this.name="BackendFunctionError"}}const t=async(t,e)=>{const r={functionName:t,args:e};let o,i;try{o=await fetch("/__dd/executeAction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch(e){throw new n(`Network error while executing backend function "${t}": ${e instanceof Error?e.message:String(e)}`,t)}if(!o.ok){let e=`Backend function "${t}" failed with status ${o.status}`;try{const n=await o.text(),t=function(n){try{const t=JSON.parse(n);if("object"==typeof t&&null!==t&&"success"in t&&!1===t.success&&"error"in t&&"string"==typeof t.error&&""!==t.error)return t.error}catch{return}}(n);void 0!==t?e=t:n&&(e+=`: ${n}`)}catch{}throw new n(e,t,o.status)}try{i=await o.json()}catch(e){throw new n(`Failed to parse response from backend function "${t}": ${e instanceof Error?e.message:String(e)}`,t,o.status)}if(!i.success)throw new n(`Backend function "${t}" returned an error: ${i.error}`,t,o.status);return i.result.data};function e(n){return null!==n&&"object"==typeof n}function r(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e]);return t}let o=0;const i=33e4;function c(n){if(!e(n))return;const t="allowedConnectionIds"in n?n.allowedConnectionIds:void 0,o={code:"code"in n?n.code:void 0,allowedConnectionIds:Array.isArray(t)?r(t):void 0};return e(i=o)&&"code"in i&&"string"==typeof i.code&&i.code.length>0&&"allowedConnectionIds"in i&&Array.isArray(i.allowedConnectionIds)&&i.allowedConnectionIds.every((n=>"string"==typeof n))?o:void 0;var i}function s(n){try{if(!e(n))return{};const t="targetOrigin"in n?n.targetOrigin:void 0;if(!function(n){if("string"!=typeof n)return!1;try{return new URL(n).origin===n}catch{return!1}}(t))return{};const r=c("bundle"in n?n.bundle:void 0);return void 0===r?{targetOrigin:t}:{targetOrigin:t,bundle:r}}catch{return{}}}function u(t,r,{targetOrigin:c,bundle:s}){const u=function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();o+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${o}-${n}`}();return new Promise(((o,a)=>{let d;function f(){window.removeEventListener("message",l),clearTimeout(d)}function l(r){const i=r.data;if(!function(n){return n.source===window.parent&&(void 0===c||n.origin===c)}(r)||!function(n,t){return e(n)&&"type"in n&&"app-builder:run-query:response"===n.type&&"requestId"in n&&n.requestId===t}(i,u))return;if(f(),!0===i.success&&e(i.result))return void o(i.result.data);const s="error"in i?i.error:void 0,d=new n("string"==typeof s?s:`Backend function "${t}" failed`,t);a(d)}window.addEventListener("message",l),d=setTimeout((()=>{f(),a(new n(`Backend function "${t}" timed out waiting for response`,t))}),i);const w={type:"app-builder:run-query",requestId:u,queryName:t,args:r,...s&&{bundle:s}};try{window.parent.postMessage(w,c??"*")}catch(n){f(),a(n)}}))}const a=(n,t)=>{const e=function(){try{return Reflect.get(globalThis,"DD_APPS_PREPARE_CALL")}catch{return}}();if("function"!=typeof e)return u(n,t,{});let r;const o=new Promise((n=>{r=setTimeout((()=>n({})),i)})),c=Promise.resolve().then((()=>e(n))).catch((()=>({})));return Promise.race([c,o]).then((e=>{clearTimeout(r);const o=s(e);return u(n,t,o)}))};function d(){return function(){try{return"undefined"!=typeof window&&window.parent!==window}catch{return!0}}()?a:t}globalThis.DD_APPS_RUNTIME={executeBackendFunction:async function(n,t){return d()(n,t)}};
@@ -22,11 +22,33 @@ type LongPollingOptions = {
22
22
  */
23
23
  timeoutMs?: number;
24
24
  };
25
+ type AppsParameterSchema = {
26
+ name: string;
27
+ type: "STRING" | "NUMBER" | "BOOLEAN";
28
+ defaultValue: string | number | boolean;
29
+ label?: string;
30
+ description?: string;
31
+ enum?: readonly string[];
32
+ };
33
+ type AppsParameters = {
34
+ readonly schema: readonly AppsParameterSchema[];
35
+ };
25
36
  type AppsOptions = {
26
37
  enable?: boolean;
27
38
  include?: string[];
39
+ /**
40
+ * Tags to add to the app, e.g. `team:my-team`. The package also carries a `surface:<id>` tag
41
+ * for each surface declared by an `@datadog/apps-frontend` input the app uses.
42
+ */
43
+ tags?: string[];
28
44
  /** Controls how the dev server retries the Datadog long-poll execution endpoint. */
29
45
  longPolling?: LongPollingOptions;
46
+ /**
47
+ * Overrides the parameters found in app code. By default the build reads
48
+ * every `defineDatadogAppParameters({...})` call, so this is only needed
49
+ * for declarations the build cannot read.
50
+ */
51
+ parameters?: AppsParameters;
30
52
  };
31
53
  declare const CONFIG_KEY: "apps";
32
54
  declare const PLUGIN_NAME: PluginName;
@@ -42,6 +64,7 @@ type SourcemapsUploadOptions = {
42
64
  };
43
65
  type DebugIdSourcemapsOptions = SourcemapsUploadOptions & {
44
66
  debugId: true;
67
+ experimentalDuplicateCheck?: boolean;
45
68
  minifiedPathPrefix?: never;
46
69
  releaseVersion?: never;
47
70
  service?: never;
@@ -50,7 +73,7 @@ type ServiceVersionSourcemapsOptions = SourcemapsUploadOptions & {
50
73
  debugId?: false;
51
74
  minifiedPathPrefix: MinifiedPathPrefix;
52
75
  releaseVersion?: string;
53
- service: string;
76
+ service?: string;
54
77
  };
55
78
  type SourcemapsOptions = DebugIdSourcemapsOptions | ServiceVersionSourcemapsOptions;
56
79
  type ErrorTrackingOptions = {
@@ -90,6 +113,9 @@ type LiveDebuggerOptions = {
90
113
  };
91
114
  type LiveDebuggerOptionsWithDefaults = {
92
115
  version: string | undefined;
116
+ service: string | undefined;
117
+ enableGit: boolean;
118
+ debugId: boolean;
93
119
  include: (string | RegExp)[];
94
120
  exclude: (string | RegExp)[];
95
121
  fileExtensions: FileExtensions;
@@ -5112,7 +5138,7 @@ type DebugIdSourceCodeContextOptions = {
5112
5138
  };
5113
5139
  type ServiceVersionSourceCodeContextOptions = {
5114
5140
  debugId?: false;
5115
- service: string;
5141
+ service?: string;
5116
5142
  version?: string;
5117
5143
  };
5118
5144
  type SourceCodeContextOptions = DebugIdSourceCodeContextOptions | ServiceVersionSourceCodeContextOptions;
@@ -5155,6 +5181,7 @@ declare const SITES: readonly [
5155
5181
  "us2.ddog-gov.com",
5156
5182
  "ap1.datadoghq.com",
5157
5183
  "ap2.datadoghq.com",
5184
+ "uk1.datadoghq.com",
5158
5185
  "datad0g.com"
5159
5186
  ];
5160
5187
  type Assign<A, B> = Omit<A, keyof B> & B;
@@ -5225,6 +5252,7 @@ type Timer = {
5225
5252
  };
5226
5253
  type BuildMetadata = {
5227
5254
  name?: string;
5255
+ service?: string;
5228
5256
  version?: string;
5229
5257
  };
5230
5258
  type BuildReport = {
@@ -5317,10 +5345,14 @@ type GlobalContext = {
5317
5345
  env: GlobalData["env"];
5318
5346
  getLogger: GetLogger;
5319
5347
  git?: RepositoryData;
5348
+ gitPending: boolean;
5349
+ gitReady: Promise<void>;
5320
5350
  hook: TriggerHook<void>;
5321
5351
  inject: (item: ToInjectItem) => void;
5322
5352
  markArtifactsPending: () => void;
5323
5353
  markArtifactsReady: (error?: unknown) => void;
5354
+ markGitPending: () => void;
5355
+ markGitReady: () => void;
5324
5356
  pluginNames: string[];
5325
5357
  plugins: (PluginOptions | CustomPluginOptions)[];
5326
5358
  queue: (promise: Promise<any>) => void;
@@ -5391,12 +5423,14 @@ type SourcemapsUploadEnabledOptions = {
5391
5423
  upload: true;
5392
5424
  bailOnError?: boolean;
5393
5425
  dryRun?: boolean;
5426
+ experimentalDuplicateCheck?: boolean;
5394
5427
  maxConcurrency?: number;
5395
5428
  };
5396
5429
  type SourcemapsInjectionOnlyOptions = {
5397
5430
  upload?: false;
5398
5431
  bailOnError?: never;
5399
5432
  dryRun?: never;
5433
+ experimentalDuplicateCheck?: never;
5400
5434
  maxConcurrency?: never;
5401
5435
  };
5402
5436
  type SourcemapsOptions$1 = {
@@ -5410,6 +5444,8 @@ interface Options extends BaseOptions {
5410
5444
  [CONFIG_KEY$4]?: OutputOptions;
5411
5445
  [rum.CONFIG_KEY]?: RumOptions;
5412
5446
  sourcemaps?: SourcemapsOptions$1;
5447
+ /** Repository URL used in Git metadata instead of the detected remote URL. */
5448
+ gitRepositoryUrl?: string;
5413
5449
  customPlugins?: GetCustomPlugins;
5414
5450
  }
5415
5451
  type OptionsWithDefaults = Assign<Assign<Options, Required<BaseOptions>>, {