@scalar/snippetz 0.2.20 → 0.3.1

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 (118) hide show
  1. package/dist/clients.d.ts.map +1 -1
  2. package/dist/clients.js +2 -1
  3. package/dist/clients.js.map +2 -2
  4. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts.map +1 -1
  5. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js +37 -8
  6. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js.map +2 -2
  7. package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts.map +1 -1
  8. package/dist/httpsnippet-lite/esm/targets/go/native/client.js +76 -30
  9. package/dist/httpsnippet-lite/esm/targets/go/native/client.js.map +2 -2
  10. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts.map +1 -1
  11. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js +25 -9
  12. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js.map +2 -2
  13. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts.map +1 -1
  14. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js +25 -9
  15. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js.map +2 -2
  16. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts.map +1 -1
  17. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js +11 -0
  18. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js.map +2 -2
  19. package/dist/plugins/js/axios/index.d.ts +1 -1
  20. package/dist/plugins/js/axios/index.d.ts.map +1 -1
  21. package/dist/plugins/js/axios/index.js +4 -1
  22. package/dist/plugins/js/axios/index.js.map +2 -2
  23. package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
  24. package/dist/plugins/js/fetch/fetch.js +30 -9
  25. package/dist/plugins/js/fetch/fetch.js.map +2 -2
  26. package/dist/plugins/js/fetch/index.d.ts +1 -1
  27. package/dist/plugins/js/fetch/index.d.ts.map +1 -1
  28. package/dist/plugins/js/fetch/index.js +4 -1
  29. package/dist/plugins/js/fetch/index.js.map +2 -2
  30. package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
  31. package/dist/plugins/js/ofetch/ofetch.js +1 -10
  32. package/dist/plugins/js/ofetch/ofetch.js.map +2 -2
  33. package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
  34. package/dist/plugins/node/fetch/fetch.js +37 -9
  35. package/dist/plugins/node/fetch/fetch.js.map +2 -2
  36. package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
  37. package/dist/plugins/node/ofetch/ofetch.js +1 -10
  38. package/dist/plugins/node/ofetch/ofetch.js.map +2 -2
  39. package/dist/plugins/node/undici/undici.d.ts.map +1 -1
  40. package/dist/plugins/node/undici/undici.js +4 -6
  41. package/dist/plugins/node/undici/undici.js.map +2 -2
  42. package/dist/plugins/python/httpx/async.d.ts +6 -0
  43. package/dist/plugins/python/httpx/async.d.ts.map +1 -0
  44. package/dist/plugins/python/httpx/async.js +16 -0
  45. package/dist/plugins/python/httpx/async.js.map +7 -0
  46. package/dist/plugins/python/httpx/index.d.ts +3 -0
  47. package/dist/plugins/python/httpx/index.d.ts.map +1 -0
  48. package/dist/plugins/python/httpx/index.js +3 -0
  49. package/dist/plugins/python/httpx/index.js.map +7 -0
  50. package/dist/plugins/python/httpx/sync.d.ts +6 -0
  51. package/dist/plugins/python/httpx/sync.d.ts.map +1 -0
  52. package/dist/plugins/python/httpx/sync.js +13 -0
  53. package/dist/plugins/python/httpx/sync.js.map +7 -0
  54. package/dist/plugins/python/requests/requests.d.ts.map +1 -1
  55. package/dist/plugins/python/requests/requests.js +2 -92
  56. package/dist/plugins/python/requests/requests.js.map +2 -2
  57. package/dist/plugins/python/requestsLike.d.ts +3 -0
  58. package/dist/plugins/python/requestsLike.d.ts.map +1 -0
  59. package/dist/plugins/python/requestsLike.js +120 -0
  60. package/dist/plugins/python/requestsLike.js.map +7 -0
  61. package/dist/snippetz.d.ts +1 -1
  62. package/dist/utils/create-search-params.d.ts +4 -0
  63. package/dist/utils/create-search-params.d.ts.map +1 -0
  64. package/dist/utils/create-search-params.js +11 -0
  65. package/dist/utils/create-search-params.js.map +7 -0
  66. package/dist/utils/index.d.ts +0 -1
  67. package/dist/utils/index.d.ts.map +1 -1
  68. package/dist/utils/index.js +0 -1
  69. package/dist/utils/index.js.map +2 -2
  70. package/dist/utils/objectToString.d.ts +8 -0
  71. package/dist/utils/objectToString.d.ts.map +1 -1
  72. package/dist/utils/objectToString.js +20 -15
  73. package/dist/utils/objectToString.js.map +2 -2
  74. package/package.json +10 -5
  75. package/dist/plugins/c/libcurl/libcurl.test.js +0 -200
  76. package/dist/plugins/c/libcurl/libcurl.test.js.map +0 -7
  77. package/dist/plugins/clojure/clj_http/clj_http.test.js +0 -151
  78. package/dist/plugins/clojure/clj_http/clj_http.test.js.map +0 -7
  79. package/dist/plugins/dart/http/http.test.js +0 -550
  80. package/dist/plugins/dart/http/http.test.js.map +0 -7
  81. package/dist/plugins/go/native/native.test.js +0 -367
  82. package/dist/plugins/go/native/native.test.js.map +0 -7
  83. package/dist/plugins/http/http11/http11.test.js +0 -175
  84. package/dist/plugins/http/http11/http11.test.js.map +0 -7
  85. package/dist/plugins/js/fetch/fetch.test.js +0 -111
  86. package/dist/plugins/js/fetch/fetch.test.js.map +0 -7
  87. package/dist/plugins/js/ofetch/ofetch.test.js +0 -123
  88. package/dist/plugins/js/ofetch/ofetch.test.js.map +0 -7
  89. package/dist/plugins/node/fetch/fetch.test.js +0 -111
  90. package/dist/plugins/node/fetch/fetch.test.js.map +0 -7
  91. package/dist/plugins/node/ofetch/ofetch.test.js +0 -123
  92. package/dist/plugins/node/ofetch/ofetch.test.js.map +0 -7
  93. package/dist/plugins/node/undici/undici.test.js +0 -133
  94. package/dist/plugins/node/undici/undici.test.js.map +0 -7
  95. package/dist/plugins/php/curl/curl.test.js +0 -564
  96. package/dist/plugins/php/curl/curl.test.js.map +0 -7
  97. package/dist/plugins/php/guzzle/guzzle.test.js +0 -546
  98. package/dist/plugins/php/guzzle/guzzle.test.js.map +0 -7
  99. package/dist/plugins/python/requests/requests.test.js +0 -390
  100. package/dist/plugins/python/requests/requests.test.js.map +0 -7
  101. package/dist/plugins/ruby/native/native.test.js +0 -240
  102. package/dist/plugins/ruby/native/native.test.js.map +0 -7
  103. package/dist/plugins/shell/curl/curl.test.js +0 -427
  104. package/dist/plugins/shell/curl/curl.test.js.map +0 -7
  105. package/dist/plugins/shell/httpie/httpie.test.js +0 -113
  106. package/dist/plugins/shell/httpie/httpie.test.js.map +0 -7
  107. package/dist/plugins/shell/wget/wget.test.js +0 -143
  108. package/dist/plugins/shell/wget/wget.test.js.map +0 -7
  109. package/dist/plugins/swift/nsurlsession/nsurlsession.test.js +0 -344
  110. package/dist/plugins/swift/nsurlsession/nsurlsession.test.js.map +0 -7
  111. package/dist/snippetz.test.js +0 -79
  112. package/dist/snippetz.test.js.map +0 -7
  113. package/dist/utils/arrayToObject.d.ts +0 -8
  114. package/dist/utils/arrayToObject.d.ts.map +0 -1
  115. package/dist/utils/arrayToObject.js +0 -10
  116. package/dist/utils/arrayToObject.js.map +0 -7
  117. package/dist/utils/convertWithHttpSnippetLite.test.js +0 -106
  118. package/dist/utils/convertWithHttpSnippetLite.test.js.map +0 -7
@@ -1,106 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { convertWithHttpSnippetLite } from "./convertWithHttpSnippetLite.js";
3
- describe("convertWithHttpSnippetLite", () => {
4
- it("converts a basic GET request", () => {
5
- const mockClient = {
6
- convert: (request) => JSON.stringify(request, null, 2)
7
- };
8
- const result = convertWithHttpSnippetLite(mockClient, {
9
- url: "https://api.example.com/users",
10
- method: "GET"
11
- });
12
- const parsed = JSON.parse(result);
13
- expect(parsed.method).toBe("GET");
14
- expect(parsed.url).toBe("https://api.example.com/users");
15
- expect(parsed.headers).toEqual([]);
16
- });
17
- it("handles query parameters", () => {
18
- const mockClient = {
19
- convert: (request) => JSON.stringify(request, null, 2)
20
- };
21
- const result = convertWithHttpSnippetLite(mockClient, {
22
- url: "https://api.example.com/search?q=test&page=1",
23
- method: "GET"
24
- });
25
- const parsed = JSON.parse(result);
26
- expect(parsed.queryObj).toEqual({
27
- q: "test",
28
- page: "1"
29
- });
30
- expect(parsed.queryString).toEqual([
31
- { name: "q", value: "test" },
32
- { name: "page", value: "1" }
33
- ]);
34
- });
35
- it("processes headers correctly", () => {
36
- const mockClient = {
37
- convert: (request) => JSON.stringify(request, null, 2)
38
- };
39
- const result = convertWithHttpSnippetLite(mockClient, {
40
- url: "https://api.example.com/data",
41
- method: "GET",
42
- headers: [
43
- { name: "Content-Type", value: "application/json" },
44
- { name: "Authorization", value: "Bearer token" }
45
- ]
46
- });
47
- const parsed = JSON.parse(result);
48
- expect(parsed.headersObj).toEqual({
49
- "Content-Type": "application/json",
50
- "Authorization": "Bearer token"
51
- });
52
- });
53
- it("handles POST requests with JSON body", () => {
54
- const mockClient = {
55
- convert: (request) => JSON.stringify(request, null, 2)
56
- };
57
- const result = convertWithHttpSnippetLite(mockClient, {
58
- url: "https://api.example.com/users",
59
- method: "POST",
60
- postData: {
61
- mimeType: "application/json",
62
- text: JSON.stringify({ name: "John", age: 30 })
63
- }
64
- });
65
- const parsed = JSON.parse(result);
66
- expect(parsed.method).toBe("POST");
67
- expect(parsed.postData.jsonObj).toEqual({
68
- name: "John",
69
- age: 30
70
- });
71
- });
72
- it("handles invalid JSON body gracefully", () => {
73
- const mockClient = {
74
- convert: (request) => JSON.stringify(request, null, 2)
75
- };
76
- const result = convertWithHttpSnippetLite(mockClient, {
77
- url: "https://api.example.com/users",
78
- method: "POST",
79
- postData: {
80
- mimeType: "application/json",
81
- text: "invalid json"
82
- }
83
- });
84
- const parsed = JSON.parse(result);
85
- expect(parsed.postData.jsonObj).toBeUndefined();
86
- });
87
- it("returns empty string if client.convert is not a function", () => {
88
- const mockClient = {};
89
- const result = convertWithHttpSnippetLite(mockClient, {
90
- url: "https://api.example.com/users",
91
- method: "GET"
92
- });
93
- expect(result).toBe("");
94
- });
95
- it("handles URLs with trailing slash correctly", () => {
96
- const mockClient = {
97
- convert: (request) => JSON.stringify(request, null, 2)
98
- };
99
- const result = convertWithHttpSnippetLite(mockClient, {
100
- url: "https://api.example.com/"
101
- });
102
- const parsed = JSON.parse(result);
103
- expect(parsed.url).toBe("https://api.example.com");
104
- });
105
- });
106
- //# sourceMappingURL=convertWithHttpSnippetLite.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/convertWithHttpSnippetLite.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport type { HarRequest } from '@scalar/types/snippetz'\nimport { convertWithHttpSnippetLite } from './convertWithHttpSnippetLite'\n\ndescribe('convertWithHttpSnippetLite', () => {\n it('converts a basic GET request', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/users',\n method: 'GET',\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.method).toBe('GET')\n expect(parsed.url).toBe('https://api.example.com/users')\n expect(parsed.headers).toEqual([])\n })\n\n it('handles query parameters', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/search?q=test&page=1',\n method: 'GET',\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.queryObj).toEqual({\n q: 'test',\n page: '1',\n })\n expect(parsed.queryString).toEqual([\n { name: 'q', value: 'test' },\n { name: 'page', value: '1' },\n ])\n })\n\n it('processes headers correctly', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/data',\n method: 'GET',\n headers: [\n { name: 'Content-Type', value: 'application/json' },\n { name: 'Authorization', value: 'Bearer token' },\n ],\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.headersObj).toEqual({\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer token',\n })\n })\n\n it('handles POST requests with JSON body', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/users',\n method: 'POST',\n postData: {\n mimeType: 'application/json',\n text: JSON.stringify({ name: 'John', age: 30 }),\n },\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.method).toBe('POST')\n expect(parsed.postData.jsonObj).toEqual({\n name: 'John',\n age: 30,\n })\n })\n\n it('handles invalid JSON body gracefully', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/users',\n method: 'POST',\n postData: {\n mimeType: 'application/json',\n text: 'invalid json',\n },\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.postData.jsonObj).toBeUndefined()\n })\n\n it('returns empty string if client.convert is not a function', () => {\n const mockClient = {}\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/users',\n method: 'GET',\n })\n\n expect(result).toBe('')\n })\n\n it('handles URLs with trailing slash correctly', () => {\n const mockClient = {\n convert: (request: HarRequest) => JSON.stringify(request, null, 2),\n }\n\n const result = convertWithHttpSnippetLite(mockClient, {\n url: 'https://api.example.com/',\n })\n\n const parsed = JSON.parse(result)\n expect(parsed.url).toBe('https://api.example.com')\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAGrC,SAAS,kCAAkC;AAE3C,SAAS,8BAA8B,MAAM;AAC3C,KAAG,gCAAgC,MAAM;AACvC,UAAM,aAAa;AAAA,MACjB,SAAS,CAAC,YAAwB,KAAK,UAAU,SAAS,MAAM,CAAC;AAAA,IACnE;AAEA,UAAM,SAAS,2BAA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