@readme/httpsnippet 11.0.0 → 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,6 +1,160 @@
1
- import '../helpers/code-builder.cjs';
2
- export { c as Client, C as ClientId, a as ClientInfo, d as ClientPlugin, b as Converter, E as Extension, f as Target, T as TargetId, e as TargetInfo, j as addClientPlugin, g as addTarget, k as addTargetClient, h as isClient, i as isTarget, t as targets } from '../index-CM3ebXTM.cjs';
3
- import 'type-fest';
4
- import 'har-format';
5
- import '../helpers/reducer.cjs';
6
- import 'node:url';
1
+ import { UrlWithParsedQuery } from 'node:url';
2
+ import { Request as Request$1, PostDataCommon, Param } from 'har-format';
3
+ import { Merge } from 'type-fest';
4
+ import { CodeBuilderOptions } from '../helpers/code-builder.cjs';
5
+ import { ReducedHelperObject } from '../helpers/reducer.cjs';
6
+
7
+ type TargetId = keyof typeof targets;
8
+ type ClientId = string;
9
+ interface ClientInfo<T extends Record<string, any> = Record<string, any>> {
10
+ /**
11
+ * A description of the client.
12
+ *
13
+ * @example Promise based HTTP client for the browser and node.js
14
+ */
15
+ description: string;
16
+ /**
17
+ * The default file extension for the client.
18
+ *
19
+ * @example `.js`
20
+ */
21
+ extname: Extension;
22
+ /**
23
+ * Retrieve or generate a command to install the client.
24
+ *
25
+ * @example () => 'npm install axios --save';
26
+ */
27
+ installation?: Converter<T>;
28
+ /**
29
+ * A unique identifier for the client.
30
+ *
31
+ * This should be a string that is unique to the client for the given target.
32
+ *
33
+ * @example `axios`
34
+ */
35
+ key: ClientId;
36
+ /**
37
+ * A link to the documentation or homepage of the client.
38
+ *
39
+ * @example https://github.com/axios/axios
40
+ */
41
+ link: string;
42
+ /**
43
+ * The formatted name of the client.
44
+ *
45
+ * @example Axios
46
+ */
47
+ title: string;
48
+ }
49
+ type Converter<T extends Record<string, any>> = (request: Request, options?: Merge<CodeBuilderOptions, T>) => string;
50
+ interface Client<T extends Record<string, any> = Record<string, any>> {
51
+ convert: Converter<T>;
52
+ info: ClientInfo<T>;
53
+ }
54
+ interface ClientPlugin<T extends Record<string, any> = Record<string, any>> {
55
+ client: Client<T>;
56
+ target: TargetId;
57
+ }
58
+ type Extension = `.${string}` | null;
59
+ interface TargetInfo {
60
+ cli?: string;
61
+ default: string;
62
+ key: TargetId;
63
+ title: string;
64
+ }
65
+ interface Target {
66
+ clientsById: Record<ClientId, Client>;
67
+ info: TargetInfo;
68
+ }
69
+ type supportedTargets = 'c' | 'clojure' | 'csharp' | 'go' | 'http' | 'java' | 'javascript' | 'json' | 'kotlin' | 'node' | 'objc' | 'ocaml' | 'php' | 'powershell' | 'python' | 'r' | 'ruby' | 'shell' | 'swift';
70
+ declare const targets: Record<supportedTargets, Target>;
71
+ declare const isTarget: (target: Target) => target is Target;
72
+ declare const addTarget: (target: Target) => void;
73
+ declare const isClient: (client: Client) => client is Client;
74
+ declare const addClientPlugin: (plugin: ClientPlugin) => void;
75
+ declare const addTargetClient: (targetId: TargetId, client: Client) => void;
76
+
77
+ interface AvailableTarget extends TargetInfo {
78
+ clients: ClientInfo[];
79
+ }
80
+ declare const availableTargets: () => AvailableTarget[];
81
+ declare const extname: (targetId: TargetId, clientId: ClientId) => "" | `.${string}`;
82
+
83
+ /** biome-ignore-all lint/performance/noBarrelFile: This doesn't really have the aspects of being a barrel file. */
84
+
85
+ /** 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.
86
+ *
87
+ * 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/).
88
+ *
89
+ * 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`.
90
+ */
91
+ type PostDataBase = PostDataCommon & {
92
+ params?: Param[];
93
+ text?: string;
94
+ };
95
+
96
+ type HarRequest = Omit<Request$1, 'postData'> & {
97
+ postData: PostDataBase;
98
+ };
99
+ interface RequestExtras {
100
+ allHeaders: ReducedHelperObject;
101
+ cookiesObj: ReducedHelperObject;
102
+ fullUrl: string;
103
+ headersObj: ReducedHelperObject;
104
+ postData: PostDataBase & {
105
+ boundary?: string;
106
+ jsonObj?: ReducedHelperObject;
107
+ paramsObj?: ReducedHelperObject;
108
+ };
109
+ queryObj: ReducedHelperObject;
110
+ uriObj: UrlWithParsedQuery;
111
+ }
112
+ type Request = HarRequest & RequestExtras;
113
+ interface Entry {
114
+ request: Partial<HarRequest>;
115
+ }
116
+ interface HarEntry {
117
+ log: {
118
+ creator: {
119
+ name: string;
120
+ version: string;
121
+ };
122
+ entries: Entry[];
123
+ version: string;
124
+ };
125
+ }
126
+ type Options = Merge<CodeBuilderOptions, Record<string, any>>;
127
+ interface HTTPSnippetOptions {
128
+ harIsAlreadyEncoded?: boolean;
129
+ }
130
+ declare class HTTPSnippet {
131
+ initCalled: boolean;
132
+ entries: Entry[];
133
+ requests: Request[];
134
+ options: HTTPSnippetOptions;
135
+ constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
136
+ init(): HTTPSnippet;
137
+ prepare(harRequest: HarRequest, options: HTTPSnippetOptions): Request & {
138
+ allHeaders: Record<string, string[] | string>;
139
+ fullUrl: string;
140
+ url: string;
141
+ uriObj: {
142
+ query: ReducedHelperObject;
143
+ search: string;
144
+ path: string | null;
145
+ auth: string | null;
146
+ hash: string | null;
147
+ host: string | null;
148
+ hostname: string | null;
149
+ href: string;
150
+ pathname: string | null;
151
+ protocol: string | null;
152
+ slashes: boolean | null;
153
+ port: string | null;
154
+ };
155
+ };
156
+ convert(targetId: TargetId, clientId?: ClientId, options?: Options): (string | false)[];
157
+ installation(targetId: TargetId, clientId?: ClientId, options?: Options): (string | false)[];
158
+ }
159
+
160
+ export { type Client, type ClientId, type ClientInfo, type ClientPlugin, type Converter, type Extension, type HarRequest as H, type Options as O, type RequestExtras as R, type Target, type TargetId, type TargetInfo, type Request as a, addClientPlugin, addTarget, addTargetClient, type HTTPSnippetOptions as b, HTTPSnippet as c, availableTargets as d, extname as e, isClient, isTarget, targets };
@@ -1,6 +1,160 @@
1
- import '../helpers/code-builder.js';
2
- export { c as Client, C as ClientId, a as ClientInfo, d as ClientPlugin, b as Converter, E as Extension, f as Target, T as TargetId, e as TargetInfo, j as addClientPlugin, g as addTarget, k as addTargetClient, h as isClient, i as isTarget, t as targets } from '../index-Bi-oJSCB.js';
3
- import 'type-fest';
4
- import 'har-format';
5
- import '../helpers/reducer.js';
6
- import 'node:url';
1
+ import { UrlWithParsedQuery } from 'node:url';
2
+ import { Request as Request$1, PostDataCommon, Param } from 'har-format';
3
+ import { Merge } from 'type-fest';
4
+ import { CodeBuilderOptions } from '../helpers/code-builder.js';
5
+ import { ReducedHelperObject } from '../helpers/reducer.js';
6
+
7
+ type TargetId = keyof typeof targets;
8
+ type ClientId = string;
9
+ interface ClientInfo<T extends Record<string, any> = Record<string, any>> {
10
+ /**
11
+ * A description of the client.
12
+ *
13
+ * @example Promise based HTTP client for the browser and node.js
14
+ */
15
+ description: string;
16
+ /**
17
+ * The default file extension for the client.
18
+ *
19
+ * @example `.js`
20
+ */
21
+ extname: Extension;
22
+ /**
23
+ * Retrieve or generate a command to install the client.
24
+ *
25
+ * @example () => 'npm install axios --save';
26
+ */
27
+ installation?: Converter<T>;
28
+ /**
29
+ * A unique identifier for the client.
30
+ *
31
+ * This should be a string that is unique to the client for the given target.
32
+ *
33
+ * @example `axios`
34
+ */
35
+ key: ClientId;
36
+ /**
37
+ * A link to the documentation or homepage of the client.
38
+ *
39
+ * @example https://github.com/axios/axios
40
+ */
41
+ link: string;
42
+ /**
43
+ * The formatted name of the client.
44
+ *
45
+ * @example Axios
46
+ */
47
+ title: string;
48
+ }
49
+ type Converter<T extends Record<string, any>> = (request: Request, options?: Merge<CodeBuilderOptions, T>) => string;
50
+ interface Client<T extends Record<string, any> = Record<string, any>> {
51
+ convert: Converter<T>;
52
+ info: ClientInfo<T>;
53
+ }
54
+ interface ClientPlugin<T extends Record<string, any> = Record<string, any>> {
55
+ client: Client<T>;
56
+ target: TargetId;
57
+ }
58
+ type Extension = `.${string}` | null;
59
+ interface TargetInfo {
60
+ cli?: string;
61
+ default: string;
62
+ key: TargetId;
63
+ title: string;
64
+ }
65
+ interface Target {
66
+ clientsById: Record<ClientId, Client>;
67
+ info: TargetInfo;
68
+ }
69
+ type supportedTargets = 'c' | 'clojure' | 'csharp' | 'go' | 'http' | 'java' | 'javascript' | 'json' | 'kotlin' | 'node' | 'objc' | 'ocaml' | 'php' | 'powershell' | 'python' | 'r' | 'ruby' | 'shell' | 'swift';
70
+ declare const targets: Record<supportedTargets, Target>;
71
+ declare const isTarget: (target: Target) => target is Target;
72
+ declare const addTarget: (target: Target) => void;
73
+ declare const isClient: (client: Client) => client is Client;
74
+ declare const addClientPlugin: (plugin: ClientPlugin) => void;
75
+ declare const addTargetClient: (targetId: TargetId, client: Client) => void;
76
+
77
+ interface AvailableTarget extends TargetInfo {
78
+ clients: ClientInfo[];
79
+ }
80
+ declare const availableTargets: () => AvailableTarget[];
81
+ declare const extname: (targetId: TargetId, clientId: ClientId) => "" | `.${string}`;
82
+
83
+ /** biome-ignore-all lint/performance/noBarrelFile: This doesn't really have the aspects of being a barrel file. */
84
+
85
+ /** 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.
86
+ *
87
+ * 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/).
88
+ *
89
+ * 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`.
90
+ */
91
+ type PostDataBase = PostDataCommon & {
92
+ params?: Param[];
93
+ text?: string;
94
+ };
95
+
96
+ type HarRequest = Omit<Request$1, 'postData'> & {
97
+ postData: PostDataBase;
98
+ };
99
+ interface RequestExtras {
100
+ allHeaders: ReducedHelperObject;
101
+ cookiesObj: ReducedHelperObject;
102
+ fullUrl: string;
103
+ headersObj: ReducedHelperObject;
104
+ postData: PostDataBase & {
105
+ boundary?: string;
106
+ jsonObj?: ReducedHelperObject;
107
+ paramsObj?: ReducedHelperObject;
108
+ };
109
+ queryObj: ReducedHelperObject;
110
+ uriObj: UrlWithParsedQuery;
111
+ }
112
+ type Request = HarRequest & RequestExtras;
113
+ interface Entry {
114
+ request: Partial<HarRequest>;
115
+ }
116
+ interface HarEntry {
117
+ log: {
118
+ creator: {
119
+ name: string;
120
+ version: string;
121
+ };
122
+ entries: Entry[];
123
+ version: string;
124
+ };
125
+ }
126
+ type Options = Merge<CodeBuilderOptions, Record<string, any>>;
127
+ interface HTTPSnippetOptions {
128
+ harIsAlreadyEncoded?: boolean;
129
+ }
130
+ declare class HTTPSnippet {
131
+ initCalled: boolean;
132
+ entries: Entry[];
133
+ requests: Request[];
134
+ options: HTTPSnippetOptions;
135
+ constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
136
+ init(): HTTPSnippet;
137
+ prepare(harRequest: HarRequest, options: HTTPSnippetOptions): Request & {
138
+ allHeaders: Record<string, string[] | string>;
139
+ fullUrl: string;
140
+ url: string;
141
+ uriObj: {
142
+ query: ReducedHelperObject;
143
+ search: string;
144
+ path: string | null;
145
+ auth: string | null;
146
+ hash: string | null;
147
+ host: string | null;
148
+ hostname: string | null;
149
+ href: string;
150
+ pathname: string | null;
151
+ protocol: string | null;
152
+ slashes: boolean | null;
153
+ port: string | null;
154
+ };
155
+ };
156
+ convert(targetId: TargetId, clientId?: ClientId, options?: Options): (string | false)[];
157
+ installation(targetId: TargetId, clientId?: ClientId, options?: Options): (string | false)[];
158
+ }
159
+
160
+ export { type Client, type ClientId, type ClientInfo, type ClientPlugin, type Converter, type Extension, type HarRequest as H, type Options as O, type RequestExtras as R, type Target, type TargetId, type TargetInfo, type Request as a, addClientPlugin, addTarget, addTargetClient, type HTTPSnippetOptions as b, HTTPSnippet as c, availableTargets as d, extname as e, isClient, isTarget, targets };
@@ -1,4 +1,4 @@
1
- export { addClientPlugin, addTarget, addTargetClient, isClient, isTarget, targets } from '../chunk-452Q5GGQ.js';
2
- import '../chunk-Y7NI4MMY.js';
1
+ export { addClientPlugin, addTarget, addTargetClient, isClient, isTarget, targets } from '../chunk-EFUQ6POB.js';
2
+ import '../chunk-6B3J3CUI.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readme/httpsnippet",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "HTTP Request snippet generator for *most* languages",
5
5
  "homepage": "https://github.com/readmeio/httpsnippet",
6
6
  "license": "MIT",
@@ -70,8 +70,9 @@
70
70
  "attw": "attw --pack --format table-flipped",
71
71
  "build": "tsup",
72
72
  "clean": "rm -rf dist/",
73
- "lint": "npm run lint:js && npm run prettier",
74
- "lint:js": "eslint . --ext .js,.cjs,.ts && prettier --check .",
73
+ "format": "npm run prettier:write && npx biome check --write",
74
+ "lint": "npm run lint:js && npm run prettier && tsc",
75
+ "lint:js": "biome check",
75
76
  "prebuild": "npm run clean",
76
77
  "prepack": "npm run build",
77
78
  "prettier": "prettier --check .",
@@ -79,24 +80,23 @@
79
80
  "test": "vitest run --coverage"
80
81
  },
81
82
  "dependencies": {
82
- "qs": "^6.11.2",
83
- "stringify-object": "^3.3.0"
83
+ "qs": "^6.15.0",
84
+ "stringify-object": "^3.3.0",
85
+ "type-fest": "^5.4.4"
84
86
  },
85
87
  "devDependencies": {
86
- "@readme/eslint-config": "^14.0.0",
87
- "@types/eslint": "^8.44.7",
88
+ "@biomejs/biome": "^2.4.4",
89
+ "@readme/standards": "^2.2.0",
88
90
  "@types/har-format": "^1.2.15",
89
- "@types/node": "^22.0.2",
91
+ "@types/node": "^25.3.0",
90
92
  "@types/qs": "^6.9.10",
91
93
  "@types/stringify-object": "^4.0.5",
92
- "@vitest/coverage-v8": "^2.0.5",
93
- "eslint": "^8.57.0",
94
+ "@vitest/coverage-v8": "^4.0.2",
94
95
  "prettier": "^3.0.3",
95
96
  "require-directory": "^2.1.1",
96
97
  "tsup": "^8.0.1",
97
- "type-fest": "^4.15.0",
98
- "typescript": "^5.4.4",
99
- "vitest": "^2.0.5"
98
+ "typescript": "^5.8.3",
99
+ "vitest": "^4.0.2"
100
100
  },
101
- "prettier": "@readme/eslint-config/prettier"
101
+ "prettier": "@readme/standards/prettier"
102
102
  }