@readme/httpsnippet 7.0.1 → 7.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.
Files changed (36) hide show
  1. package/dist/chunk-BCCGHMCJ.mjs +18 -0
  2. package/dist/chunk-BCCGHMCJ.mjs.map +1 -0
  3. package/dist/{chunk-XPUGYZ4Y.mjs → chunk-DTZD7L6R.mjs} +3 -62
  4. package/dist/chunk-DTZD7L6R.mjs.map +1 -0
  5. package/dist/chunk-UEOS42PC.mjs +63 -0
  6. package/dist/chunk-UEOS42PC.mjs.map +1 -0
  7. package/dist/helpers/code-builder.d.mts +51 -0
  8. package/dist/helpers/code-builder.d.ts +51 -0
  9. package/dist/helpers/code-builder.js +65 -0
  10. package/dist/helpers/code-builder.js.map +1 -0
  11. package/dist/helpers/code-builder.mjs +3 -0
  12. package/dist/helpers/reducer.d.mts +7 -0
  13. package/dist/helpers/reducer.d.ts +7 -0
  14. package/dist/helpers/reducer.js +20 -0
  15. package/dist/helpers/reducer.js.map +1 -0
  16. package/dist/helpers/reducer.mjs +3 -0
  17. package/dist/helpers/reducer.mjs.map +1 -0
  18. package/dist/{index-acc66e3d.d.ts → index-27be831e.d.ts} +2 -15
  19. package/dist/index-e612cd58.d.ts +154 -0
  20. package/dist/index.d.mts +3 -1
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.js +1 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +4 -17
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/targets/{targets.d.mts → index.d.mts} +3 -1
  27. package/dist/targets/{targets.d.ts → index.d.ts} +3 -1
  28. package/dist/targets/{targets.js → index.js} +2 -2
  29. package/dist/targets/index.js.map +1 -0
  30. package/dist/targets/index.mjs +4 -0
  31. package/dist/targets/index.mjs.map +1 -0
  32. package/package.json +4 -4
  33. package/dist/chunk-XPUGYZ4Y.mjs.map +0 -1
  34. package/dist/targets/targets.js.map +0 -1
  35. package/dist/targets/targets.mjs +0 -3
  36. /package/dist/{targets/targets.mjs.map → helpers/code-builder.mjs.map} +0 -0
@@ -0,0 +1,63 @@
1
+ // src/helpers/code-builder.ts
2
+ var DEFAULT_INDENTATION_CHARACTER = "";
3
+ var DEFAULT_LINE_JOIN = "\n";
4
+ var CodeBuilder = class {
5
+ /**
6
+ * Helper object to format and aggragate lines of code.
7
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
8
+ */
9
+ constructor({ indent, join } = {}) {
10
+ this.postProcessors = [];
11
+ this.code = [];
12
+ this.indentationCharacter = DEFAULT_INDENTATION_CHARACTER;
13
+ this.lineJoin = DEFAULT_LINE_JOIN;
14
+ /**
15
+ * Add given indentation level to given line of code
16
+ */
17
+ this.indentLine = (line, indentationLevel = 0) => {
18
+ const indent = this.indentationCharacter.repeat(indentationLevel);
19
+ return `${indent}${line}`;
20
+ };
21
+ /**
22
+ * Add the line at the beginning of the current lines
23
+ */
24
+ this.unshift = (line, indentationLevel) => {
25
+ const newLine = this.indentLine(line, indentationLevel);
26
+ this.code.unshift(newLine);
27
+ };
28
+ /**
29
+ * Add the line at the end of the current lines
30
+ */
31
+ this.push = (line, indentationLevel) => {
32
+ const newLine = this.indentLine(line, indentationLevel);
33
+ this.code.push(newLine);
34
+ };
35
+ /**
36
+ * Add an empty line at the end of current lines
37
+ */
38
+ this.blank = () => {
39
+ this.code.push("");
40
+ };
41
+ /**
42
+ * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
43
+ */
44
+ this.join = () => {
45
+ const unreplacedCode = this.code.join(this.lineJoin);
46
+ const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);
47
+ return replacedOutput;
48
+ };
49
+ /**
50
+ * 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.
51
+ * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
52
+ */
53
+ this.addPostProcessor = (postProcessor) => {
54
+ this.postProcessors = [...this.postProcessors, postProcessor];
55
+ };
56
+ this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
57
+ this.lineJoin = join ?? DEFAULT_LINE_JOIN;
58
+ }
59
+ };
60
+
61
+ export { CodeBuilder };
62
+ //# sourceMappingURL=out.js.map
63
+ //# sourceMappingURL=chunk-UEOS42PC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/code-builder.ts"],"names":[],"mappings":";AAAA,IAAM,gCAAgC;AACtC,IAAM,oBAAoB;AAkBnB,IAAM,cAAN,MAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAavB,YAAY,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAG;AAZvD,0BAAkC,CAAC;AAEnC,gBAAiB,CAAC;AAElB,gCAA+B;AAE/B,oBAAW;AAcX;AAAA;AAAA;AAAA,sBAAa,CAAC,MAAc,mBAAmB,MAAM;AACnD,YAAM,SAAS,KAAK,qBAAqB,OAAO,gBAAgB;AAChE,aAAO,GAAG,MAAM,GAAG,IAAI;AAAA,IACzB;AAKA;AAAA;AAAA;AAAA,mBAAU,CAAC,MAAc,qBAA8B;AACrD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,QAAQ,OAAO;AAAA,IAC3B;AAKA;AAAA;AAAA;AAAA,gBAAO,CAAC,MAAc,qBAA8B;AAClD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,KAAK,OAAO;AAAA,IACxB;AAKA;AAAA;AAAA;AAAA,iBAAQ,MAAM;AACZ,WAAK,KAAK,KAAK,EAAE;AAAA,IACnB;AAKA;AAAA;AAAA;AAAA,gBAAO,MAAM;AACX,YAAM,iBAAiB,KAAK,KAAK,KAAK,KAAK,QAAQ;AACnD,YAAM,iBAAiB,KAAK,eAAe,OAAO,CAAC,aAAa,aAAa,SAAS,WAAW,GAAG,cAAc;AAClH,aAAO;AAAA,IACT;AAMA;AAAA;AAAA;AAAA;AAAA,4BAAmB,CAAC,kBAAiC;AACnD,WAAK,iBAAiB,CAAC,GAAG,KAAK,gBAAgB,aAAa;AAAA,IAC9D;AAlDE,SAAK,uBAAuB,UAAU;AACtC,SAAK,WAAW,QAAQ;AAAA,EAC1B;AAiDF","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"]}
@@ -0,0 +1,51 @@
1
+ type PostProcessor = (unreplacedCode: string) => string;
2
+ interface CodeBuilderOptions {
3
+ /**
4
+ * Desired indentation character for aggregated lines of code
5
+ * @default ''
6
+ */
7
+ indent?: string;
8
+ /**
9
+ * Desired character to join each line of code
10
+ * @default \n
11
+ */
12
+ join?: string;
13
+ }
14
+ declare class CodeBuilder {
15
+ postProcessors: PostProcessor[];
16
+ code: string[];
17
+ indentationCharacter: string;
18
+ lineJoin: string;
19
+ /**
20
+ * Helper object to format and aggragate lines of code.
21
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
22
+ */
23
+ constructor({ indent, join }?: CodeBuilderOptions);
24
+ /**
25
+ * Add given indentation level to given line of code
26
+ */
27
+ indentLine: (line: string, indentationLevel?: number) => string;
28
+ /**
29
+ * Add the line at the beginning of the current lines
30
+ */
31
+ unshift: (line: string, indentationLevel?: number) => void;
32
+ /**
33
+ * Add the line at the end of the current lines
34
+ */
35
+ push: (line: string, indentationLevel?: number) => void;
36
+ /**
37
+ * Add an empty line at the end of current lines
38
+ */
39
+ blank: () => void;
40
+ /**
41
+ * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
42
+ */
43
+ join: () => string;
44
+ /**
45
+ * 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.
46
+ * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
47
+ */
48
+ addPostProcessor: (postProcessor: PostProcessor) => void;
49
+ }
50
+
51
+ export { CodeBuilder, CodeBuilderOptions, PostProcessor };
@@ -0,0 +1,51 @@
1
+ type PostProcessor = (unreplacedCode: string) => string;
2
+ interface CodeBuilderOptions {
3
+ /**
4
+ * Desired indentation character for aggregated lines of code
5
+ * @default ''
6
+ */
7
+ indent?: string;
8
+ /**
9
+ * Desired character to join each line of code
10
+ * @default \n
11
+ */
12
+ join?: string;
13
+ }
14
+ declare class CodeBuilder {
15
+ postProcessors: PostProcessor[];
16
+ code: string[];
17
+ indentationCharacter: string;
18
+ lineJoin: string;
19
+ /**
20
+ * Helper object to format and aggragate lines of code.
21
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
22
+ */
23
+ constructor({ indent, join }?: CodeBuilderOptions);
24
+ /**
25
+ * Add given indentation level to given line of code
26
+ */
27
+ indentLine: (line: string, indentationLevel?: number) => string;
28
+ /**
29
+ * Add the line at the beginning of the current lines
30
+ */
31
+ unshift: (line: string, indentationLevel?: number) => void;
32
+ /**
33
+ * Add the line at the end of the current lines
34
+ */
35
+ push: (line: string, indentationLevel?: number) => void;
36
+ /**
37
+ * Add an empty line at the end of current lines
38
+ */
39
+ blank: () => void;
40
+ /**
41
+ * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
42
+ */
43
+ join: () => string;
44
+ /**
45
+ * 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.
46
+ * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
47
+ */
48
+ addPostProcessor: (postProcessor: PostProcessor) => void;
49
+ }
50
+
51
+ export { CodeBuilder, CodeBuilderOptions, PostProcessor };
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ // src/helpers/code-builder.ts
4
+ var DEFAULT_INDENTATION_CHARACTER = "";
5
+ var DEFAULT_LINE_JOIN = "\n";
6
+ var CodeBuilder = class {
7
+ /**
8
+ * Helper object to format and aggragate lines of code.
9
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
10
+ */
11
+ constructor({ indent, join } = {}) {
12
+ this.postProcessors = [];
13
+ this.code = [];
14
+ this.indentationCharacter = DEFAULT_INDENTATION_CHARACTER;
15
+ this.lineJoin = DEFAULT_LINE_JOIN;
16
+ /**
17
+ * Add given indentation level to given line of code
18
+ */
19
+ this.indentLine = (line, indentationLevel = 0) => {
20
+ const indent = this.indentationCharacter.repeat(indentationLevel);
21
+ return `${indent}${line}`;
22
+ };
23
+ /**
24
+ * Add the line at the beginning of the current lines
25
+ */
26
+ this.unshift = (line, indentationLevel) => {
27
+ const newLine = this.indentLine(line, indentationLevel);
28
+ this.code.unshift(newLine);
29
+ };
30
+ /**
31
+ * Add the line at the end of the current lines
32
+ */
33
+ this.push = (line, indentationLevel) => {
34
+ const newLine = this.indentLine(line, indentationLevel);
35
+ this.code.push(newLine);
36
+ };
37
+ /**
38
+ * Add an empty line at the end of current lines
39
+ */
40
+ this.blank = () => {
41
+ this.code.push("");
42
+ };
43
+ /**
44
+ * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
45
+ */
46
+ this.join = () => {
47
+ const unreplacedCode = this.code.join(this.lineJoin);
48
+ const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);
49
+ return replacedOutput;
50
+ };
51
+ /**
52
+ * 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.
53
+ * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
54
+ */
55
+ this.addPostProcessor = (postProcessor) => {
56
+ this.postProcessors = [...this.postProcessors, postProcessor];
57
+ };
58
+ this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
59
+ this.lineJoin = join ?? DEFAULT_LINE_JOIN;
60
+ }
61
+ };
62
+
63
+ exports.CodeBuilder = CodeBuilder;
64
+ //# sourceMappingURL=out.js.map
65
+ //# sourceMappingURL=code-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/helpers/code-builder.ts"],"names":[],"mappings":";AAAA,IAAM,gCAAgC;AACtC,IAAM,oBAAoB;AAkBnB,IAAM,cAAN,MAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAavB,YAAY,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAG;AAZvD,0BAAkC,CAAC;AAEnC,gBAAiB,CAAC;AAElB,gCAA+B;AAE/B,oBAAW;AAcX;AAAA;AAAA;AAAA,sBAAa,CAAC,MAAc,mBAAmB,MAAM;AACnD,YAAM,SAAS,KAAK,qBAAqB,OAAO,gBAAgB;AAChE,aAAO,GAAG,MAAM,GAAG,IAAI;AAAA,IACzB;AAKA;AAAA;AAAA;AAAA,mBAAU,CAAC,MAAc,qBAA8B;AACrD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,QAAQ,OAAO;AAAA,IAC3B;AAKA;AAAA;AAAA;AAAA,gBAAO,CAAC,MAAc,qBAA8B;AAClD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,KAAK,OAAO;AAAA,IACxB;AAKA;AAAA;AAAA;AAAA,iBAAQ,MAAM;AACZ,WAAK,KAAK,KAAK,EAAE;AAAA,IACnB;AAKA;AAAA;AAAA;AAAA,gBAAO,MAAM;AACX,YAAM,iBAAiB,KAAK,KAAK,KAAK,KAAK,QAAQ;AACnD,YAAM,iBAAiB,KAAK,eAAe,OAAO,CAAC,aAAa,aAAa,SAAS,WAAW,GAAG,cAAc;AAClH,aAAO;AAAA,IACT;AAMA;AAAA;AAAA;AAAA;AAAA,4BAAmB,CAAC,kBAAiC;AACnD,WAAK,iBAAiB,CAAC,GAAG,KAAK,gBAAgB,aAAa;AAAA,IAC9D;AAlDE,SAAK,uBAAuB,UAAU;AACtC,SAAK,WAAW,QAAQ;AAAA,EAC1B;AAiDF","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"]}
@@ -0,0 +1,3 @@
1
+ export { CodeBuilder } from '../chunk-UEOS42PC.mjs';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=code-builder.mjs.map
@@ -0,0 +1,7 @@
1
+ type ReducedHelperObject = Record<string, string[] | string>;
2
+ declare const reducer: <T extends {
3
+ name: string;
4
+ value: string;
5
+ }>(accumulator: ReducedHelperObject, pair: T) => ReducedHelperObject;
6
+
7
+ export { ReducedHelperObject, reducer };
@@ -0,0 +1,7 @@
1
+ type ReducedHelperObject = Record<string, string[] | string>;
2
+ declare const reducer: <T extends {
3
+ name: string;
4
+ value: string;
5
+ }>(accumulator: ReducedHelperObject, pair: T) => ReducedHelperObject;
6
+
7
+ export { ReducedHelperObject, reducer };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ // src/helpers/reducer.ts
4
+ var reducer = (accumulator, pair) => {
5
+ const currentValue = accumulator[pair.name];
6
+ if (currentValue === void 0) {
7
+ accumulator[pair.name] = pair.value;
8
+ return accumulator;
9
+ }
10
+ if (Array.isArray(currentValue)) {
11
+ currentValue.push(pair.value);
12
+ return accumulator;
13
+ }
14
+ accumulator[pair.name] = [currentValue, pair.value];
15
+ return accumulator;
16
+ };
17
+
18
+ exports.reducer = reducer;
19
+ //# sourceMappingURL=out.js.map
20
+ //# sourceMappingURL=reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/helpers/reducer.ts"],"names":[],"mappings":";AAEO,IAAM,UAAU,CAA4C,aAAkC,SAAY;AAC/G,QAAM,eAAe,YAAY,KAAK,IAAI;AAC1C,MAAI,iBAAiB,QAAW;AAC9B,gBAAY,KAAK,IAAI,IAAI,KAAK;AAC9B,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,YAAY,GAAG;AAC/B,iBAAa,KAAK,KAAK,KAAK;AAC5B,WAAO;AAAA,EACT;AAGA,cAAY,KAAK,IAAI,IAAI,CAAC,cAAc,KAAK,KAAK;AAClD,SAAO;AACT","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"]}
@@ -0,0 +1,3 @@
1
+ export { reducer } from '../chunk-BCCGHMCJ.mjs';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=reducer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,23 +1,10 @@
1
1
  import * as har_format from 'har-format';
2
2
  import { Request as Request$1, PostDataCommon, Param } from 'har-format';
3
+ import { ReducedHelperObject } from './helpers/reducer.mjs';
3
4
  import { UrlWithParsedQuery } from 'node:url';
5
+ import { CodeBuilderOptions } from './helpers/code-builder.mjs';
4
6
  import { Merge } from 'type-fest';
5
7
 
6
- type ReducedHelperObject = Record<string, string[] | string>;
7
-
8
- interface CodeBuilderOptions {
9
- /**
10
- * Desired indentation character for aggregated lines of code
11
- * @default ''
12
- */
13
- indent?: string;
14
- /**
15
- * Desired character to join each line of code
16
- * @default \n
17
- */
18
- join?: string;
19
- }
20
-
21
8
  type TargetId = keyof typeof targets;
22
9
  type ClientId = string;
23
10
  interface ClientInfo {
@@ -0,0 +1,154 @@
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 { UrlWithParsedQuery } from 'node:url';
5
+ import { CodeBuilderOptions } from './helpers/code-builder.js';
6
+ import { Merge } from 'type-fest';
7
+
8
+ type TargetId = keyof typeof targets;
9
+ type ClientId = string;
10
+ interface ClientInfo {
11
+ description: string;
12
+ key: ClientId;
13
+ link: string;
14
+ title: string;
15
+ }
16
+ type Converter<T extends Record<string, any>> = (request: Request, options?: Merge<CodeBuilderOptions, T>) => string;
17
+ interface Client<T extends Record<string, any> = Record<string, any>> {
18
+ convert: Converter<T>;
19
+ info: ClientInfo;
20
+ }
21
+ type Extension = `.${string}` | null;
22
+ interface TargetInfo {
23
+ cli?: string;
24
+ default: string;
25
+ extname: Extension;
26
+ key: TargetId;
27
+ title: string;
28
+ }
29
+ interface Target {
30
+ clientsById: Record<ClientId, Client>;
31
+ info: TargetInfo;
32
+ }
33
+ declare const targets: {
34
+ c: Target;
35
+ clojure: Target;
36
+ csharp: Target;
37
+ go: Target;
38
+ http: Target;
39
+ java: Target;
40
+ javascript: Target;
41
+ json: Target;
42
+ kotlin: Target;
43
+ node: Target;
44
+ objc: Target;
45
+ ocaml: Target;
46
+ php: Target;
47
+ powershell: Target;
48
+ python: Target;
49
+ r: Target;
50
+ ruby: Target;
51
+ shell: Target;
52
+ swift: Target;
53
+ };
54
+ declare const isTarget: (target: Target) => target is Target;
55
+ declare const addTarget: (target: Target) => void;
56
+ declare const isClient: (client: Client) => client is Client<Record<string, any>>;
57
+ declare const addTargetClient: (targetId: TargetId, client: Client) => void;
58
+
59
+ interface AvailableTarget extends TargetInfo {
60
+ clients: ClientInfo[];
61
+ }
62
+ declare const availableTargets: () => AvailableTarget[];
63
+ declare const extname: (targetId: TargetId) => "" | `.${string}`;
64
+
65
+ /** 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.
66
+ *
67
+ * 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/).
68
+ *
69
+ * 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`.
70
+ */
71
+ type PostDataBase = PostDataCommon & {
72
+ params?: Param[];
73
+ text?: string;
74
+ };
75
+ type HarRequest = Omit<Request$1, 'postData'> & {
76
+ postData: PostDataBase;
77
+ };
78
+ interface RequestExtras {
79
+ allHeaders: ReducedHelperObject;
80
+ cookiesObj: ReducedHelperObject;
81
+ fullUrl: string;
82
+ headersObj: ReducedHelperObject;
83
+ postData: PostDataBase & {
84
+ boundary?: string;
85
+ jsonObj?: ReducedHelperObject;
86
+ paramsObj?: ReducedHelperObject;
87
+ };
88
+ queryObj: ReducedHelperObject;
89
+ uriObj: UrlWithParsedQuery;
90
+ }
91
+ type Request = HarRequest & RequestExtras;
92
+ interface Entry {
93
+ request: Partial<HarRequest>;
94
+ }
95
+ interface HarEntry {
96
+ log: {
97
+ creator: {
98
+ name: string;
99
+ version: string;
100
+ };
101
+ entries: Entry[];
102
+ version: string;
103
+ };
104
+ }
105
+ interface HTTPSnippetOptions {
106
+ harIsAlreadyEncoded?: boolean;
107
+ }
108
+ declare class HTTPSnippet {
109
+ requests: Request[];
110
+ constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
111
+ prepare: (harRequest: HarRequest, options: HTTPSnippetOptions) => {
112
+ allHeaders: {
113
+ [x: string]: string | string[];
114
+ };
115
+ fullUrl: string;
116
+ url: string;
117
+ uriObj: {
118
+ query: ReducedHelperObject;
119
+ search: string;
120
+ path: string | null;
121
+ auth: string | null;
122
+ hash: string | null;
123
+ host: string | null;
124
+ hostname: string | null;
125
+ href: string;
126
+ pathname: string | null;
127
+ protocol: string | null;
128
+ slashes: boolean | null;
129
+ port: string | null;
130
+ };
131
+ method: string;
132
+ httpVersion: string;
133
+ cookies: har_format.Cookie[];
134
+ headers: har_format.Header[];
135
+ queryString: har_format.QueryString[];
136
+ headersSize: number;
137
+ bodySize: number;
138
+ comment?: string | undefined;
139
+ postData: PostDataCommon & {
140
+ params?: Param[] | undefined;
141
+ text?: string | undefined;
142
+ } & {
143
+ boundary?: string | undefined;
144
+ jsonObj?: ReducedHelperObject | undefined;
145
+ paramsObj?: ReducedHelperObject | undefined;
146
+ };
147
+ cookiesObj: ReducedHelperObject;
148
+ headersObj: ReducedHelperObject;
149
+ queryObj: ReducedHelperObject;
150
+ };
151
+ convert: (targetId: TargetId, clientId?: ClientId, options?: any) => string | false | string[];
152
+ }
153
+
154
+ export { ClientId as C, Extension as E, HarRequest as H, RequestExtras as R, TargetId as T, ClientInfo as a, Converter as b, Client as c, TargetInfo as d, Target as e, addTarget as f, isClient as g, addTargetClient as h, isTarget as i, Request as j, HTTPSnippetOptions as k, HTTPSnippet as l, availableTargets as m, extname as n, targets as t };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import 'har-format';
2
- export { l as HTTPSnippet, k as HTTPSnippetOptions, H as HarRequest, j as Request, R as RequestExtras, f as addTarget, h as addTargetClient, m as availableTargets, n as extname } from './index-acc66e3d.js';
2
+ import './helpers/reducer.mjs';
3
+ export { l as HTTPSnippet, k as HTTPSnippetOptions, H as HarRequest, j as Request, R as RequestExtras, f as addTarget, h as addTargetClient, m as availableTargets, n as extname } from './index-27be831e.js';
3
4
  import 'node:url';
5
+ import './helpers/code-builder.mjs';
4
6
  import 'type-fest';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import 'har-format';
2
- export { l as HTTPSnippet, k as HTTPSnippetOptions, H as HarRequest, j as Request, R as RequestExtras, f as addTarget, h as addTargetClient, m as availableTargets, n as extname } from './index-acc66e3d.js';
2
+ import './helpers/reducer.js';
3
+ export { l as HTTPSnippet, k as HTTPSnippetOptions, H as HarRequest, j as Request, R as RequestExtras, f as addTarget, h as addTargetClient, m as availableTargets, n as extname } from './index-e612cd58.js';
3
4
  import 'node:url';
5
+ import './helpers/code-builder.js';
4
6
  import 'type-fest';
package/dist/index.js CHANGED
@@ -3427,7 +3427,7 @@ var swift = {
3427
3427
  }
3428
3428
  };
3429
3429
 
3430
- // src/targets/targets.ts
3430
+ // src/targets/index.ts
3431
3431
  var targets = {
3432
3432
  c,
3433
3433
  clojure,