@scalar/snippetz 0.2.4 → 0.2.6
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.
- package/README.md +3 -3
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/types.d.ts +30 -5
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.test-d.d.ts +2 -0
- package/dist/core/types.test-d.d.ts.map +1 -0
- package/dist/core/utils/arrayToObject.d.ts +6 -1
- package/dist/core/utils/arrayToObject.d.ts.map +1 -1
- package/dist/core/utils/arrayToObject.js +6 -1
- package/dist/core/utils/needsQuotes.d.ts +7 -0
- package/dist/core/utils/needsQuotes.d.ts.map +1 -0
- package/dist/core/utils/needsQuotes.js +10 -0
- package/dist/core/utils/objectToString.d.ts +5 -0
- package/dist/core/utils/objectToString.d.ts.map +1 -1
- package/dist/core/utils/objectToString.js +7 -2
- package/dist/plugins/js/fetch/fetch.d.ts +5 -2
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +63 -59
- package/dist/plugins/js/fetch/index.js +1 -1
- package/dist/plugins/js/ofetch/index.js +1 -1
- package/dist/plugins/js/ofetch/ofetch.d.ts +5 -2
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +70 -64
- package/dist/plugins/node/fetch/fetch.d.ts +5 -2
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +63 -59
- package/dist/plugins/node/fetch/index.js +1 -1
- package/dist/plugins/node/ofetch/index.js +1 -1
- package/dist/plugins/node/ofetch/ofetch.d.ts +5 -2
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +70 -64
- package/dist/plugins/node/undici/index.js +1 -1
- package/dist/plugins/node/undici/undici.d.ts +5 -2
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +63 -59
- package/dist/plugins/shell/curl/curl.d.ts +6 -0
- package/dist/plugins/shell/curl/curl.d.ts.map +1 -0
- package/dist/plugins/shell/curl/curl.js +105 -0
- package/dist/plugins/shell/curl/index.d.ts +2 -0
- package/dist/plugins/shell/curl/index.d.ts.map +1 -0
- package/dist/plugins/shell/curl/index.js +1 -0
- package/dist/snippetz.d.ts +9 -12
- package/dist/snippetz.d.ts.map +1 -1
- package/dist/snippetz.js +22 -22
- package/package.json +7 -2
- package/dist/core/utils/isKeyNeedsQuotes.d.ts +0 -2
- package/dist/core/utils/isKeyNeedsQuotes.d.ts.map +0 -1
- package/dist/core/utils/isKeyNeedsQuotes.js +0 -5
package/dist/snippetz.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { nodeUndici } from './plugins/node/undici/undici.js';
|
|
2
|
+
import { nodeFetch } from './plugins/node/fetch/fetch.js';
|
|
3
|
+
import { jsFetch } from './plugins/js/fetch/fetch.js';
|
|
4
|
+
import { jsOfetch } from './plugins/js/ofetch/ofetch.js';
|
|
5
|
+
import { nodeOfetch } from './plugins/node/ofetch/ofetch.js';
|
|
6
|
+
import { shellCurl } from './plugins/shell/curl/curl.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Generate code examples for HAR requests
|
|
9
10
|
*/
|
|
10
11
|
function snippetz() {
|
|
11
|
-
const plugins = [
|
|
12
|
+
const plugins = [
|
|
13
|
+
nodeUndici,
|
|
14
|
+
nodeFetch,
|
|
15
|
+
jsFetch,
|
|
16
|
+
jsOfetch,
|
|
17
|
+
nodeOfetch,
|
|
18
|
+
shellCurl,
|
|
19
|
+
];
|
|
12
20
|
return {
|
|
13
|
-
get(target, client
|
|
14
|
-
|
|
15
|
-
if (plugin) {
|
|
16
|
-
return plugin(request);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
code: '',
|
|
20
|
-
};
|
|
21
|
+
get(target, client) {
|
|
22
|
+
return this.findPlugin(target, client);
|
|
21
23
|
},
|
|
22
24
|
print(target, client, request) {
|
|
23
|
-
return this.get(target, client
|
|
25
|
+
return this.get(target, client)?.generate(request);
|
|
24
26
|
},
|
|
25
27
|
targets() {
|
|
26
28
|
return (plugins
|
|
27
29
|
// all targets
|
|
28
|
-
.map((plugin) => plugin
|
|
30
|
+
.map((plugin) => plugin.target)
|
|
29
31
|
// unique values
|
|
30
32
|
.filter((value, index, self) => self.indexOf(value) === index));
|
|
31
33
|
},
|
|
32
34
|
clients() {
|
|
33
|
-
return plugins.map((plugin) => plugin
|
|
35
|
+
return plugins.map((plugin) => plugin.client);
|
|
34
36
|
},
|
|
35
37
|
plugins() {
|
|
36
38
|
return plugins.map((plugin) => {
|
|
37
|
-
const details = plugin();
|
|
38
39
|
return {
|
|
39
|
-
target:
|
|
40
|
-
client:
|
|
40
|
+
target: plugin.target,
|
|
41
|
+
client: plugin.client,
|
|
41
42
|
};
|
|
42
43
|
});
|
|
43
44
|
},
|
|
44
45
|
findPlugin(target, client) {
|
|
45
46
|
return plugins.find((plugin) => {
|
|
46
|
-
|
|
47
|
-
return details.target === target && details.client === client;
|
|
47
|
+
return plugin.target === target && plugin.client === client;
|
|
48
48
|
});
|
|
49
49
|
},
|
|
50
50
|
hasPlugin(target, client) {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/scalar/scalar.git",
|
|
10
10
|
"directory": "packages/snippetz"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.6",
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=18"
|
|
15
15
|
},
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"default": "./dist/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./plugins/shell/curl": {
|
|
25
|
+
"import": "./dist/plugins/shell/curl/index.js",
|
|
26
|
+
"types": "./dist/plugins/shell/curl/index.d.ts",
|
|
27
|
+
"default": "./dist/plugins/shell/curl/index.js"
|
|
28
|
+
},
|
|
24
29
|
"./plugins/node/undici": {
|
|
25
30
|
"import": "./dist/plugins/node/undici/index.js",
|
|
26
31
|
"types": "./dist/plugins/node/undici/index.d.ts",
|
|
@@ -59,7 +64,7 @@
|
|
|
59
64
|
"module": "./dist/index.js",
|
|
60
65
|
"devDependencies": {
|
|
61
66
|
"@types/har-format": "^1.2.15",
|
|
62
|
-
"@scalar/build-tooling": "0.1.
|
|
67
|
+
"@scalar/build-tooling": "0.1.12"
|
|
63
68
|
},
|
|
64
69
|
"scripts": {
|
|
65
70
|
"build": "scalar-build-rollup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isKeyNeedsQuotes.d.ts","sourceRoot":"","sources":["../../../src/core/utils/isKeyNeedsQuotes.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,WAE3C"}
|