Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70711 Main by @UppaJung
Browse files Browse the repository at this point in the history
  • Loading branch information
UppaJung authored Sep 29, 2024
1 parent ad6f7ca commit 4f67852
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
40 changes: 37 additions & 3 deletions types/har-format/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,40 @@ export interface Chunk {
bytes: number;
ts: number;
}
/**
* _non-standard_
*
* This object describes the initiator of a request (the location of the
* code that issued the request) and is used to populate the Entry's
* non-standard `_initiator` field.
*/
export interface Initiator {
/**
* presumably equivalent to _initiator_type
*
* values "parser" and "other" have been observed in Chrome's HARs
*/
"type": string;
/**
* The URL of the code file in which the code that issued the
* request represented by the Entry (this object's parent) resides.
* This would otherwise be the string in the Entry's `_initiator` field.
*/
"url"?: string | null | undefined;
/**
* The line number of the code that issued the request represented
* by the Entry to which this Initiator object has been attached.
*/
"lineNumber"?: number | null | undefined;
/**
* The column number of the code that issued the request.
*/
"column"?: number | null | undefined;
/**
* The detail information that would be in `_initiator_detail`.
*/
"detail"?: string | null | undefined;
}
/**
* This object represents an array with all exported HTTP requests. Sorting
* entries by `startedDateTime` (starting from the oldest) is preferred way how
Expand Down Expand Up @@ -421,15 +455,15 @@ export interface Entry {
/** _non-standard_ */
_index?: number | null | undefined;
/** _non-standard_ */
_initiator?: string | null | undefined;
_initiator?: Initiator | string | null | undefined;
/** _non-standard_ */
_initiator_column?: string | null | undefined;
_initiator_column?: number | null | undefined;
/** _non-standard_ */
_initiator_detail?: string | null | undefined;
/** _non-standard_ */
_initiator_function?: string | null | undefined;
/** _non-standard_ */
_initiator_line?: string | null | undefined;
_initiator_line?: number | null | undefined;
/** _non-standard_ */
_initiator_type?: string | null | undefined;
/** _non-standard_ */
Expand Down
17 changes: 17 additions & 0 deletions types/har-format/test/har-format-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ const paramsPostData: harFormat.PostData = {
],
};

// An initiator object in a HAR generated by Chrome 128.0.6613.138
// by loading wikipedia.org
const _initiatorVerbose: { _initiator: harFormat.Initiator } = {
"_initiator": {
"type": "parser",
"url": "https://www.wikipedia.org/",
"lineNumber": 30,
},
};
// An initiator object generated by Chrome for a request returned from
// disk cache ("_fromCache": disk)
const _initiatorMinimal: { _initiator: harFormat.Initiator } = {
"_initiator": {
"type": "other",
},
};

// @ts-expect-error
const missingPostData: harFormat.PostData = {
mimeType: "text/plain",
Expand Down

0 comments on commit 4f67852

Please sign in to comment.