@scalar/snippetz 0.2.11 → 0.2.13

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 (42) hide show
  1. package/dist/httpsnippet-lite/esm/helpers/escape.js +7 -7
  2. package/dist/httpsnippet-lite/esm/helpers/url.d.ts.map +1 -1
  3. package/dist/httpsnippet-lite/esm/targets/javascript/fetch/client.d.ts.map +1 -1
  4. package/dist/httpsnippet-lite/esm/targets/node/fetch/client.d.ts.map +1 -1
  5. package/dist/httpsnippet-lite/esm/targets/php/guzzle/client.d.ts.map +1 -1
  6. package/dist/httpsnippet-lite/esm/targets/php/guzzle/client.js +2 -4
  7. package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/plugins/dart/http/http.d.ts.map +1 -1
  10. package/dist/plugins/dart/http/http.js +8 -10
  11. package/dist/plugins/http/http11/http11.d.ts.map +1 -1
  12. package/dist/plugins/http/http11/http11.js +94 -5
  13. package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
  14. package/dist/plugins/js/fetch/fetch.js +3 -9
  15. package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
  16. package/dist/plugins/js/ofetch/ofetch.js +3 -9
  17. package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
  18. package/dist/plugins/node/fetch/fetch.js +3 -9
  19. package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
  20. package/dist/plugins/node/ofetch/ofetch.js +3 -9
  21. package/dist/plugins/node/undici/undici.d.ts.map +1 -1
  22. package/dist/plugins/node/undici/undici.js +3 -9
  23. package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
  24. package/dist/plugins/shell/curl/curl.js +2 -4
  25. package/dist/snippetz.d.ts.map +1 -1
  26. package/dist/snippetz.js +1 -3
  27. package/dist/types/index.d.ts +2 -37
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/index.js +41 -0
  30. package/dist/utils/convertWithHttpSnippetLite.d.ts.map +1 -1
  31. package/dist/utils/objectToString.d.ts.map +1 -1
  32. package/dist/utils/objectToString.js +2 -4
  33. package/package.json +6 -4
  34. package/dist/httpsnippet-lite/esm/httpsnippet.d.ts +0 -10
  35. package/dist/httpsnippet-lite/esm/httpsnippet.d.ts.map +0 -1
  36. package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.d.ts +0 -22
  37. package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.d.ts.map +0 -1
  38. package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.js +0 -77
  39. package/dist/httpsnippet-lite/esm/targets/http/target.d.ts +0 -27
  40. package/dist/httpsnippet-lite/esm/targets/http/target.d.ts.map +0 -1
  41. package/dist/httpsnippet-lite/esm/targets/targets.d.ts +0 -731
  42. package/dist/httpsnippet-lite/esm/targets/targets.d.ts.map +0 -1
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/scalar/scalar.git",
10
10
  "directory": "packages/snippetz"
11
11
  },
12
- "version": "0.2.11",
12
+ "version": "0.2.13",
13
13
  "engines": {
14
14
  "node": ">=18"
15
15
  },
@@ -218,14 +218,16 @@
218
218
  "devDependencies": {
219
219
  "@types/har-format": "^1.2.15",
220
220
  "vite": "^5.4.10",
221
- "@scalar/build-tooling": "0.1.12"
221
+ "@scalar/build-tooling": "0.1.13"
222
222
  },
223
223
  "scripts": {
224
224
  "build": "scalar-build-rollup",
225
225
  "build:playground": "cd ./playground && pnpm build",
226
226
  "dev": "cd ./playground && pnpm dev",
227
- "lint:check": "eslint .",
228
- "lint:fix": "eslint . --fix",
227
+ "format": "scalar-format",
228
+ "format:check": "scalar-format-check",
229
+ "lint:check": "scalar-lint-check",
230
+ "lint:fix": "scalar-lint-fix",
229
231
  "test": "vitest",
230
232
  "types:build": "scalar-types-build",
231
233
  "types:check": "scalar-types-check"
@@ -1,10 +0,0 @@
1
- export { CodeBuilder } from './helpers/code-builder.js';
2
- export { availableTargets, extname } from './helpers/utils.js';
3
- export { isClient, isTarget } from './targets/targets.js';
4
- export { addTarget, addTargetClient, isValidTargetId, } from './targets/targets.js';
5
- export declare class HTTPSnippet {
6
- constructor(input: any);
7
- prepare(harRequest: any): Promise<any>;
8
- convert(targetId: any, clientId: any, options: any): Promise<any>;
9
- }
10
- //# sourceMappingURL=httpsnippet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"httpsnippet.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/esm/httpsnippet.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EACL,SAAS,EACT,eAAe,EACf,eAAe,GAChB,MAAM,sBAAsB,CAAA;AAW7B,qBAAa,WAAW;gBACV,KAAK,KAAA;IAmCX,OAAO,CAAC,UAAU,KAAA;IAsJlB,OAAO,CAAC,QAAQ,KAAA,EAAE,QAAQ,KAAA,EAAE,OAAO,KAAA;CAc1C"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Request follows the request message format in accordance to RFC 7230, Section 3.
3
- * Each section is prepended with the RFC and section number.
4
- * See more at https://tools.ietf.org/html/rfc7230#section-3.
5
- */
6
- export declare const http11: {
7
- info: {
8
- key: string;
9
- title: string;
10
- link: string;
11
- description: string;
12
- };
13
- convert: ({ method, fullUrl, uriObj, httpVersion, allHeaders, postData }: {
14
- method: any;
15
- fullUrl: any;
16
- uriObj: any;
17
- httpVersion: any;
18
- allHeaders: any;
19
- postData: any;
20
- }, options: any) => string;
21
- };
22
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/http/http1.1/client.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CA4DlB,CAAA"}
@@ -1,77 +0,0 @@
1
- import { CodeBuilder } from '../../../helpers/code-builder.js';
2
-
3
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- // @ts-nocheck
5
- /**
6
- * @description
7
- * HTTP code snippet generator to generate raw HTTP/1.1 request strings,
8
- * in accordance to the RFC 7230 (and RFC 7231) specifications.
9
- *
10
- * @author
11
- * @irvinlim
12
- *
13
- * For any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
14
- */
15
- const CRLF = '\r\n';
16
- /**
17
- * Request follows the request message format in accordance to RFC 7230, Section 3.
18
- * Each section is prepended with the RFC and section number.
19
- * See more at https://tools.ietf.org/html/rfc7230#section-3.
20
- */
21
- const http11 = {
22
- info: {
23
- key: 'http1.1',
24
- title: 'HTTP/1.1',
25
- link: 'https://tools.ietf.org/html/rfc7230',
26
- description: 'HTTP/1.1 request string in accordance with RFC 7230',
27
- },
28
- convert: ({ method, fullUrl, uriObj, httpVersion, allHeaders, postData }, options) => {
29
- const opts = {
30
- absoluteURI: false,
31
- autoContentLength: true,
32
- autoHost: true,
33
- ...options,
34
- };
35
- // RFC 7230 Section 3. Message Format
36
- // All lines have no indentation, and should be terminated with CRLF.
37
- const { blank, push, join } = new CodeBuilder({ indent: '', join: CRLF });
38
- // RFC 7230 Section 5.3. Request Target
39
- // Determines if the Request-Line should use 'absolute-form' or 'origin-form'.
40
- // Basically it means whether the "http://domain.com" will prepend the full url.
41
- const requestUrl = opts.absoluteURI ? fullUrl : uriObj.path;
42
- // RFC 7230 Section 3.1.1. Request-Line
43
- push(`${method} ${requestUrl} ${httpVersion}`);
44
- const headerKeys = Object.keys(allHeaders);
45
- // RFC 7231 Section 5. Header Fields
46
- headerKeys.forEach((key) => {
47
- // Capitalize header keys, even though it's not required by the spec.
48
- const keyCapitalized = key
49
- .toLowerCase()
50
- .replace(/(^|-)(\w)/g, (input) => input.toUpperCase());
51
- push(`${keyCapitalized}: ${allHeaders[key]}`);
52
- });
53
- // RFC 7230 Section 5.4. Host
54
- // Automatically set Host header if option is on and on header already exists.
55
- if (opts.autoHost && !headerKeys.includes('host')) {
56
- push(`Host: ${uriObj.host}`);
57
- }
58
- // RFC 7230 Section 3.3.3. Message Body Length
59
- // Automatically set Content-Length header if option is on, postData is present and no header already exists.
60
- if (opts.autoContentLength &&
61
- (postData === null || postData === void 0 ? void 0 : postData.text) &&
62
- !headerKeys.includes('content-length')) {
63
- push(`Content-Length: ${postData.text.length}`);
64
- }
65
- // Add extra line after header section.
66
- blank();
67
- // Separate header section and message body section.
68
- const headerSection = join();
69
- // RFC 7230 Section 3.3. Message Body
70
- const messageBody = (postData === null || postData === void 0 ? void 0 : postData.text) || '';
71
- // RFC 7230 Section 3. Message Format
72
- // Extra CRLF separating the headers from the body.
73
- return `${headerSection}${CRLF}${messageBody}`;
74
- },
75
- };
76
-
77
- export { http11 };
@@ -1,27 +0,0 @@
1
- export declare const http: {
2
- info: {
3
- key: string;
4
- title: string;
5
- extname: null;
6
- default: string;
7
- };
8
- clientsById: {
9
- 'http1.1': {
10
- info: {
11
- key: string;
12
- title: string;
13
- link: string;
14
- description: string;
15
- };
16
- convert: ({ method, fullUrl, uriObj, httpVersion, allHeaders, postData }: {
17
- method: any;
18
- fullUrl: any;
19
- uriObj: any;
20
- httpVersion: any;
21
- allHeaders: any;
22
- postData: any;
23
- }, options: any) => string;
24
- };
25
- };
26
- };
27
- //# sourceMappingURL=target.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/http/target.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;CAUhB,CAAA"}