@readme/httpsnippet 10.1.1 → 11.1.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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/helpers/reducer.ts"],"names":[],"mappings":";AAEa,IAAA,OAAA,GAAU,CAA4C,WAAA,EAAkC,IAAY,KAAA;AAC/G,EAAM,MAAA,YAAA,GAAe,WAAY,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AAC1C,EAAA,IAAI,iBAAiB,KAAW,CAAA,EAAA;AAC9B,IAAY,WAAA,CAAA,IAAA,CAAK,IAAI,CAAA,GAAI,IAAK,CAAA,KAAA,CAAA;AAC9B,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AAGA,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,YAAY,CAAG,EAAA;AAC/B,IAAa,YAAA,CAAA,IAAA,CAAK,KAAK,KAAK,CAAA,CAAA;AAC5B,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AAGA,EAAA,WAAA,CAAY,KAAK,IAAI,CAAA,GAAI,CAAC,YAAA,EAAc,KAAK,KAAK,CAAA,CAAA;AAClD,EAAO,OAAA,WAAA,CAAA;AACT","file":"chunk-KT7MO6Z4.js","sourcesContent":["export type ReducedHelperObject = Record<string, string[] | string>;\n\nexport const reducer = <T extends { name: string; value: string }>(accumulator: ReducedHelperObject, pair: T) => {\n const currentValue = accumulator[pair.name];\n if (currentValue === undefined) {\n accumulator[pair.name] = pair.value;\n return accumulator;\n }\n\n // If we already have it as array just push the value\n if (Array.isArray(currentValue)) {\n currentValue.push(pair.value);\n return accumulator;\n }\n\n // convert to array since now we have more than one value for this key\n accumulator[pair.name] = [currentValue, pair.value];\n return accumulator;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/helpers/code-builder.ts"],"names":[],"mappings":";AAAA,IAAM,6BAAgC,GAAA,EAAA,CAAA;AACtC,IAAM,iBAAoB,GAAA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AA,KACnB,CAAA;AAKA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,IAAA,GAAO,MAAM;AACX,MAAA,MAAM,cAAiB,GAAA,IAAA,CAAK,IAAK,CAAA,IAAA,CAAK,KAAK,QAAQ,CAAA,CAAA;AACnD,MAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,cAAA,CAAe,MAAO,CAAA,CAAC,aAAa,QAAa,KAAA,QAAA,CAAS,WAAW,CAAA,EAAG,cAAc,CAAA,CAAA;AAClH,MAAO,OAAA,cAAA,CAAA;AAAA,KACT,CAAA;AAMA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,gBAAA,GAAmB,CAAC,aAAiC,KAAA;AACnD,MAAA,IAAA,CAAK,cAAiB,GAAA,CAAC,GAAG,IAAA,CAAK,gBAAgB,aAAa,CAAA,CAAA;AAAA,KAC9D,CAAA;AAlDE,IAAA,IAAA,CAAK,uBAAuB,MAAU,IAAA,6BAAA,CAAA;AACtC,IAAA,IAAA,CAAK,WAAW,IAAQ,IAAA,iBAAA,CAAA;AAAA,GAC1B;AAiDF","file":"chunk-Y7NI4MMY.js","sourcesContent":["const DEFAULT_INDENTATION_CHARACTER = '';\nconst DEFAULT_LINE_JOIN = '\\n';\n\nexport type PostProcessor = (unreplacedCode: string) => string;\n\nexport interface CodeBuilderOptions {\n /**\n * Desired indentation character for aggregated lines of code\n * @default ''\n */\n indent?: string;\n\n /**\n * Desired character to join each line of code\n * @default \\n\n */\n join?: string;\n}\n\nexport class CodeBuilder {\n postProcessors: PostProcessor[] = [];\n\n code: string[] = [];\n\n indentationCharacter: string = DEFAULT_INDENTATION_CHARACTER;\n\n lineJoin = DEFAULT_LINE_JOIN;\n\n /**\n * Helper object to format and aggragate lines of code.\n * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.\n */\n constructor({ indent, join }: CodeBuilderOptions = {}) {\n this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;\n this.lineJoin = join ?? DEFAULT_LINE_JOIN;\n }\n\n /**\n * Add given indentation level to given line of code\n */\n indentLine = (line: string, indentationLevel = 0) => {\n const indent = this.indentationCharacter.repeat(indentationLevel);\n return `${indent}${line}`;\n };\n\n /**\n * Add the line at the beginning of the current lines\n */\n unshift = (line: string, indentationLevel?: number) => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.unshift(newLine);\n };\n\n /**\n * Add the line at the end of the current lines\n */\n push = (line: string, indentationLevel?: number) => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.push(newLine);\n };\n\n /**\n * Add an empty line at the end of current lines\n */\n blank = () => {\n this.code.push('');\n };\n\n /**\n * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added\n */\n join = () => {\n const unreplacedCode = this.code.join(this.lineJoin);\n const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);\n return replacedOutput;\n };\n\n /**\n * Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.\n * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.\n */\n addPostProcessor = (postProcessor: PostProcessor) => {\n this.postProcessors = [...this.postProcessors, postProcessor];\n };\n}\n"]}
@@ -1,164 +0,0 @@
1
- import * as har_format from 'har-format';
2
- import { Request as Request$1, PostDataCommon, Param } from 'har-format';
3
- import { ReducedHelperObject } from './helpers/reducer.js';
4
- import { CodeBuilderOptions } from './helpers/code-builder.js';
5
- import { UrlWithParsedQuery } from 'node:url';
6
- import { Merge } from 'type-fest';
7
-
8
- type TargetId = keyof typeof targets;
9
- type ClientId = string;
10
- interface ClientInfo {
11
- description: string;
12
- extname: Extension;
13
- installation?: string;
14
- key: ClientId;
15
- link: string;
16
- title: string;
17
- }
18
- type Converter<T extends Record<string, any>> = (request: Request, options?: Merge<CodeBuilderOptions, T>) => string;
19
- interface Client<T extends Record<string, any> = Record<string, any>> {
20
- convert: Converter<T>;
21
- info: ClientInfo;
22
- }
23
- interface ClientPlugin<T extends Record<string, any> = Record<string, any>> {
24
- client: Client<T>;
25
- target: TargetId;
26
- }
27
- type Extension = `.${string}` | null;
28
- interface TargetInfo {
29
- cli?: string;
30
- default: string;
31
- key: TargetId;
32
- title: string;
33
- }
34
- interface Target {
35
- clientsById: Record<ClientId, Client>;
36
- info: TargetInfo;
37
- }
38
- declare const targets: {
39
- c: Target;
40
- clojure: Target;
41
- csharp: Target;
42
- go: Target;
43
- http: Target;
44
- java: Target;
45
- javascript: Target;
46
- json: Target;
47
- kotlin: Target;
48
- node: Target;
49
- objc: Target;
50
- ocaml: Target;
51
- php: Target;
52
- powershell: Target;
53
- python: Target;
54
- r: Target;
55
- ruby: Target;
56
- shell: Target;
57
- swift: Target;
58
- };
59
- declare const isTarget: (target: Target) => target is Target;
60
- declare const addTarget: (target: Target) => void;
61
- declare const isClient: (client: Client) => client is Client;
62
- declare const addClientPlugin: (plugin: ClientPlugin) => void;
63
- declare const addTargetClient: (targetId: TargetId, client: Client) => void;
64
-
65
- interface AvailableTarget extends TargetInfo {
66
- clients: ClientInfo[];
67
- }
68
- declare const availableTargets: () => AvailableTarget[];
69
- declare const extname: (targetId: TargetId, clientId: ClientId) => "" | `.${string}`;
70
-
71
- /** is this wrong? yes. according to the spec (http://www.softwareishard.com/blog/har-12-spec/#postData) it's technically wrong since `params` and `text` are (by the spec) mutually exclusive. However, in practice, this is not what is often the case.
72
- *
73
- * In general, this library takes a _descriptive_ rather than _perscriptive_ approach (see https://amyrey.web.unc.edu/classes/ling-101-online/tutorials/understanding-prescriptive-vs-descriptive-grammar/).
74
- *
75
- * Then, in addition to that, it really adds to complexity with TypeScript (TypeScript takes this constraint very very seriously) in a way that's not actually super useful. So, we treat this object as though it could have both or either of `params` and/or `text`.
76
- */
77
- type PostDataBase = PostDataCommon & {
78
- params?: Param[];
79
- text?: string;
80
- };
81
- type HarRequest = Omit<Request$1, 'postData'> & {
82
- postData: PostDataBase;
83
- };
84
- interface RequestExtras {
85
- allHeaders: ReducedHelperObject;
86
- cookiesObj: ReducedHelperObject;
87
- fullUrl: string;
88
- headersObj: ReducedHelperObject;
89
- postData: PostDataBase & {
90
- boundary?: string;
91
- jsonObj?: ReducedHelperObject;
92
- paramsObj?: ReducedHelperObject;
93
- };
94
- queryObj: ReducedHelperObject;
95
- uriObj: UrlWithParsedQuery;
96
- }
97
- type Request = HarRequest & RequestExtras;
98
- interface Entry {
99
- request: Partial<HarRequest>;
100
- }
101
- interface HarEntry {
102
- log: {
103
- creator: {
104
- name: string;
105
- version: string;
106
- };
107
- entries: Entry[];
108
- version: string;
109
- };
110
- }
111
- interface HTTPSnippetOptions {
112
- harIsAlreadyEncoded?: boolean;
113
- }
114
- declare class HTTPSnippet {
115
- initCalled: boolean;
116
- entries: Entry[];
117
- requests: Request[];
118
- options: HTTPSnippetOptions;
119
- constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
120
- init(): this;
121
- prepare(harRequest: HarRequest, options: HTTPSnippetOptions): {
122
- allHeaders: {
123
- [x: string]: string | string[];
124
- };
125
- fullUrl: string;
126
- url: string;
127
- uriObj: {
128
- query: ReducedHelperObject;
129
- search: string;
130
- path: string | null;
131
- auth: string | null;
132
- hash: string | null;
133
- host: string | null;
134
- hostname: string | null;
135
- href: string;
136
- pathname: string | null;
137
- protocol: string | null;
138
- slashes: boolean | null;
139
- port: string | null;
140
- };
141
- method: string;
142
- httpVersion: string;
143
- cookies: har_format.Cookie[];
144
- headers: har_format.Header[];
145
- queryString: har_format.QueryString[];
146
- headersSize: number;
147
- bodySize: number;
148
- comment?: string | undefined;
149
- postData: PostDataCommon & {
150
- params?: Param[];
151
- text?: string;
152
- } & {
153
- boundary?: string;
154
- jsonObj?: ReducedHelperObject;
155
- paramsObj?: ReducedHelperObject;
156
- };
157
- cookiesObj: ReducedHelperObject;
158
- headersObj: ReducedHelperObject;
159
- queryObj: ReducedHelperObject;
160
- };
161
- convert(targetId: TargetId, clientId?: ClientId, options?: any): false | string[];
162
- }
163
-
164
- export { type ClientId as C, type Extension as E, type HarRequest as H, type RequestExtras as R, type TargetId as T, type ClientInfo as a, type Converter as b, type Client as c, type ClientPlugin as d, type TargetInfo as e, type Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, type Request as l, type HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };
@@ -1,164 +0,0 @@
1
- import * as har_format from 'har-format';
2
- import { Request as Request$1, PostDataCommon, Param } from 'har-format';
3
- import { ReducedHelperObject } from './helpers/reducer.cjs';
4
- import { CodeBuilderOptions } from './helpers/code-builder.cjs';
5
- import { UrlWithParsedQuery } from 'node:url';
6
- import { Merge } from 'type-fest';
7
-
8
- type TargetId = keyof typeof targets;
9
- type ClientId = string;
10
- interface ClientInfo {
11
- description: string;
12
- extname: Extension;
13
- installation?: string;
14
- key: ClientId;
15
- link: string;
16
- title: string;
17
- }
18
- type Converter<T extends Record<string, any>> = (request: Request, options?: Merge<CodeBuilderOptions, T>) => string;
19
- interface Client<T extends Record<string, any> = Record<string, any>> {
20
- convert: Converter<T>;
21
- info: ClientInfo;
22
- }
23
- interface ClientPlugin<T extends Record<string, any> = Record<string, any>> {
24
- client: Client<T>;
25
- target: TargetId;
26
- }
27
- type Extension = `.${string}` | null;
28
- interface TargetInfo {
29
- cli?: string;
30
- default: string;
31
- key: TargetId;
32
- title: string;
33
- }
34
- interface Target {
35
- clientsById: Record<ClientId, Client>;
36
- info: TargetInfo;
37
- }
38
- declare const targets: {
39
- c: Target;
40
- clojure: Target;
41
- csharp: Target;
42
- go: Target;
43
- http: Target;
44
- java: Target;
45
- javascript: Target;
46
- json: Target;
47
- kotlin: Target;
48
- node: Target;
49
- objc: Target;
50
- ocaml: Target;
51
- php: Target;
52
- powershell: Target;
53
- python: Target;
54
- r: Target;
55
- ruby: Target;
56
- shell: Target;
57
- swift: Target;
58
- };
59
- declare const isTarget: (target: Target) => target is Target;
60
- declare const addTarget: (target: Target) => void;
61
- declare const isClient: (client: Client) => client is Client;
62
- declare const addClientPlugin: (plugin: ClientPlugin) => void;
63
- declare const addTargetClient: (targetId: TargetId, client: Client) => void;
64
-
65
- interface AvailableTarget extends TargetInfo {
66
- clients: ClientInfo[];
67
- }
68
- declare const availableTargets: () => AvailableTarget[];
69
- declare const extname: (targetId: TargetId, clientId: ClientId) => "" | `.${string}`;
70
-
71
- /** is this wrong? yes. according to the spec (http://www.softwareishard.com/blog/har-12-spec/#postData) it's technically wrong since `params` and `text` are (by the spec) mutually exclusive. However, in practice, this is not what is often the case.
72
- *
73
- * In general, this library takes a _descriptive_ rather than _perscriptive_ approach (see https://amyrey.web.unc.edu/classes/ling-101-online/tutorials/understanding-prescriptive-vs-descriptive-grammar/).
74
- *
75
- * Then, in addition to that, it really adds to complexity with TypeScript (TypeScript takes this constraint very very seriously) in a way that's not actually super useful. So, we treat this object as though it could have both or either of `params` and/or `text`.
76
- */
77
- type PostDataBase = PostDataCommon & {
78
- params?: Param[];
79
- text?: string;
80
- };
81
- type HarRequest = Omit<Request$1, 'postData'> & {
82
- postData: PostDataBase;
83
- };
84
- interface RequestExtras {
85
- allHeaders: ReducedHelperObject;
86
- cookiesObj: ReducedHelperObject;
87
- fullUrl: string;
88
- headersObj: ReducedHelperObject;
89
- postData: PostDataBase & {
90
- boundary?: string;
91
- jsonObj?: ReducedHelperObject;
92
- paramsObj?: ReducedHelperObject;
93
- };
94
- queryObj: ReducedHelperObject;
95
- uriObj: UrlWithParsedQuery;
96
- }
97
- type Request = HarRequest & RequestExtras;
98
- interface Entry {
99
- request: Partial<HarRequest>;
100
- }
101
- interface HarEntry {
102
- log: {
103
- creator: {
104
- name: string;
105
- version: string;
106
- };
107
- entries: Entry[];
108
- version: string;
109
- };
110
- }
111
- interface HTTPSnippetOptions {
112
- harIsAlreadyEncoded?: boolean;
113
- }
114
- declare class HTTPSnippet {
115
- initCalled: boolean;
116
- entries: Entry[];
117
- requests: Request[];
118
- options: HTTPSnippetOptions;
119
- constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
120
- init(): this;
121
- prepare(harRequest: HarRequest, options: HTTPSnippetOptions): {
122
- allHeaders: {
123
- [x: string]: string | string[];
124
- };
125
- fullUrl: string;
126
- url: string;
127
- uriObj: {
128
- query: ReducedHelperObject;
129
- search: string;
130
- path: string | null;
131
- auth: string | null;
132
- hash: string | null;
133
- host: string | null;
134
- hostname: string | null;
135
- href: string;
136
- pathname: string | null;
137
- protocol: string | null;
138
- slashes: boolean | null;
139
- port: string | null;
140
- };
141
- method: string;
142
- httpVersion: string;
143
- cookies: har_format.Cookie[];
144
- headers: har_format.Header[];
145
- queryString: har_format.QueryString[];
146
- headersSize: number;
147
- bodySize: number;
148
- comment?: string | undefined;
149
- postData: PostDataCommon & {
150
- params?: Param[];
151
- text?: string;
152
- } & {
153
- boundary?: string;
154
- jsonObj?: ReducedHelperObject;
155
- paramsObj?: ReducedHelperObject;
156
- };
157
- cookiesObj: ReducedHelperObject;
158
- headersObj: ReducedHelperObject;
159
- queryObj: ReducedHelperObject;
160
- };
161
- convert(targetId: TargetId, clientId?: ClientId, options?: any): false | string[];
162
- }
163
-
164
- export { type ClientId as C, type Extension as E, type HarRequest as H, type RequestExtras as R, type TargetId as T, type ClientInfo as a, type Converter as b, type Client as c, type ClientPlugin as d, type TargetInfo as e, type Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, type Request as l, type HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };