@sectui/operations 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/args.d.ts +8 -0
- package/dist/args.js +47 -0
- package/dist/args.js.map +1 -0
- package/dist/cli-flags.d.ts +7 -0
- package/dist/cli-flags.js +28 -0
- package/dist/cli-flags.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +185 -0
- package/dist/cli.js.map +1 -0
- package/dist/completions.d.ts +3 -0
- package/dist/completions.js +113 -0
- package/dist/completions.js.map +1 -0
- package/dist/display.d.ts +4 -0
- package/dist/display.js +29 -0
- package/dist/display.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/operation.d.ts +64 -0
- package/dist/operation.js +5 -0
- package/dist/operation.js.map +1 -0
- package/dist/operations/base/alphabets.d.ts +28 -0
- package/dist/operations/base/alphabets.js +27 -0
- package/dist/operations/base/alphabets.js.map +1 -0
- package/dist/operations/base/base32.d.ts +33 -0
- package/dist/operations/base/base32.js +85 -0
- package/dist/operations/base/base32.js.map +1 -0
- package/dist/operations/base/base58.d.ts +34 -0
- package/dist/operations/base/base58.js +43 -0
- package/dist/operations/base/base58.js.map +1 -0
- package/dist/operations/base/base62.d.ts +28 -0
- package/dist/operations/base/base62.js +43 -0
- package/dist/operations/base/base62.js.map +1 -0
- package/dist/operations/base/base64.d.ts +19 -0
- package/dist/operations/base/base64.js +72 -0
- package/dist/operations/base/base64.js.map +1 -0
- package/dist/operations/base/base64url.d.ts +15 -0
- package/dist/operations/base/base64url.js +44 -0
- package/dist/operations/base/base64url.js.map +1 -0
- package/dist/operations/base/big-number.d.ts +6 -0
- package/dist/operations/base/big-number.js +54 -0
- package/dist/operations/base/big-number.js.map +1 -0
- package/dist/operations/color/hex-to-rgb.d.ts +14 -0
- package/dist/operations/color/hex-to-rgb.js +41 -0
- package/dist/operations/color/hex-to-rgb.js.map +1 -0
- package/dist/operations/data/json-format.d.ts +20 -0
- package/dist/operations/data/json-format.js +33 -0
- package/dist/operations/data/json-format.js.map +1 -0
- package/dist/operations/data/json.d.ts +20 -0
- package/dist/operations/data/json.js +59 -0
- package/dist/operations/data/json.js.map +1 -0
- package/dist/operations/data/yaml.d.ts +21 -0
- package/dist/operations/data/yaml.js +54 -0
- package/dist/operations/data/yaml.js.map +1 -0
- package/dist/operations/extract/extract.d.ts +55 -0
- package/dist/operations/extract/extract.js +129 -0
- package/dist/operations/extract/extract.js.map +1 -0
- package/dist/operations/hash/bcrypt.d.ts +16 -0
- package/dist/operations/hash/bcrypt.js +45 -0
- package/dist/operations/hash/bcrypt.js.map +1 -0
- package/dist/operations/hash/hashes.d.ts +10 -0
- package/dist/operations/hash/hashes.js +29 -0
- package/dist/operations/hash/hashes.js.map +1 -0
- package/dist/operations/hex/from-hex.d.ts +1 -0
- package/dist/operations/hex/from-hex.js +31 -0
- package/dist/operations/hex/from-hex.js.map +1 -0
- package/dist/operations/hex/to-hex.d.ts +31 -0
- package/dist/operations/hex/to-hex.js +44 -0
- package/dist/operations/hex/to-hex.js.map +1 -0
- package/dist/operations/html/entities.d.ts +2 -0
- package/dist/operations/html/entities.js +69 -0
- package/dist/operations/html/entities.js.map +1 -0
- package/dist/operations/html/html-decode.d.ts +1 -0
- package/dist/operations/html/html-decode.js +36 -0
- package/dist/operations/html/html-decode.js.map +1 -0
- package/dist/operations/html/html-encode.d.ts +8 -0
- package/dist/operations/html/html-encode.js +30 -0
- package/dist/operations/html/html-encode.js.map +1 -0
- package/dist/operations/text/case.d.ts +14 -0
- package/dist/operations/text/case.js +85 -0
- package/dist/operations/text/case.js.map +1 -0
- package/dist/operations/text/count.d.ts +19 -0
- package/dist/operations/text/count.js +59 -0
- package/dist/operations/text/count.js.map +1 -0
- package/dist/operations/text/line-operations.d.ts +48 -0
- package/dist/operations/text/line-operations.js +134 -0
- package/dist/operations/text/line-operations.js.map +1 -0
- package/dist/operations/text/lines.d.ts +13 -0
- package/dist/operations/text/lines.js +22 -0
- package/dist/operations/text/lines.js.map +1 -0
- package/dist/operations/text/text-operations.d.ts +37 -0
- package/dist/operations/text/text-operations.js +79 -0
- package/dist/operations/text/text-operations.js.map +1 -0
- package/dist/operations/url/url-decode.d.ts +8 -0
- package/dist/operations/url/url-decode.js +56 -0
- package/dist/operations/url/url-decode.js.map +1 -0
- package/dist/operations/url/url-encode.d.ts +8 -0
- package/dist/operations/url/url-encode.js +37 -0
- package/dist/operations/url/url-encode.js.map +1 -0
- package/dist/registry.d.ts +395 -0
- package/dist/registry.js +131 -0
- package/dist/registry.js.map +1 -0
- package/dist/template.d.ts +23 -0
- package/dist/template.js +198 -0
- package/dist/template.js.map +1 -0
- package/package.json +67 -4
- package/src/args.ts +47 -0
- package/src/cli-flags.ts +29 -0
- package/src/cli.ts +189 -0
- package/src/completions.ts +129 -0
- package/src/display.ts +29 -0
- package/src/errors.ts +6 -0
- package/src/index.ts +4 -0
- package/src/operation.ts +62 -0
- package/src/operations/base/alphabets.ts +33 -0
- package/src/operations/base/base32.ts +84 -0
- package/src/operations/base/base58.ts +45 -0
- package/src/operations/base/base62.ts +44 -0
- package/src/operations/base/base64.ts +76 -0
- package/src/operations/base/base64url.ts +45 -0
- package/src/operations/base/big-number.ts +54 -0
- package/src/operations/color/hex-to-rgb.ts +42 -0
- package/src/operations/data/json-format.ts +33 -0
- package/src/operations/data/json.ts +53 -0
- package/src/operations/data/yaml.ts +56 -0
- package/src/operations/extract/extract.ts +135 -0
- package/src/operations/hash/bcrypt.ts +44 -0
- package/src/operations/hash/hashes.ts +64 -0
- package/src/operations/hex/from-hex.ts +31 -0
- package/src/operations/hex/to-hex.ts +46 -0
- package/src/operations/html/entities.ts +71 -0
- package/src/operations/html/html-decode.ts +36 -0
- package/src/operations/html/html-encode.ts +31 -0
- package/src/operations/text/case.ts +140 -0
- package/src/operations/text/count.ts +61 -0
- package/src/operations/text/line-operations.ts +144 -0
- package/src/operations/text/lines.ts +22 -0
- package/src/operations/text/text-operations.ts +85 -0
- package/src/operations/url/url-decode.ts +55 -0
- package/src/operations/url/url-encode.ts +38 -0
- package/src/registry.ts +152 -0
- package/src/template.ts +214 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import type { ArgValues, Operation } from "./operation.ts";
|
|
2
|
+
/** Every new operation must be registered here. */
|
|
3
|
+
export declare const operations: readonly [Operation<"to-base64", {
|
|
4
|
+
readonly padding: {
|
|
5
|
+
readonly type: "boolean";
|
|
6
|
+
readonly name: "Padding (=)";
|
|
7
|
+
readonly default: true;
|
|
8
|
+
};
|
|
9
|
+
}, "from-base64">, Operation<"from-base64", {
|
|
10
|
+
readonly strict: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
readonly name: "Strict mode";
|
|
13
|
+
readonly description: "Fail on non-alphabet characters and invalid padding instead of ignoring them.";
|
|
14
|
+
readonly default: false;
|
|
15
|
+
};
|
|
16
|
+
}, "to-base64">, Operation<"to-base64url", {
|
|
17
|
+
readonly padding: {
|
|
18
|
+
readonly type: "boolean";
|
|
19
|
+
readonly name: "Padding (=)";
|
|
20
|
+
readonly default: false;
|
|
21
|
+
};
|
|
22
|
+
}, "from-base64url">, Operation<"from-base64url", {
|
|
23
|
+
readonly strict: {
|
|
24
|
+
readonly type: "boolean";
|
|
25
|
+
readonly name: "Strict mode";
|
|
26
|
+
readonly description: "Fail on non-alphabet characters and invalid padding instead of ignoring them.";
|
|
27
|
+
readonly default: false;
|
|
28
|
+
};
|
|
29
|
+
}, "to-base64url">, Operation<"to-base32", {
|
|
30
|
+
readonly alphabet: {
|
|
31
|
+
readonly type: "select";
|
|
32
|
+
readonly name: "Alphabet";
|
|
33
|
+
readonly options: readonly [{
|
|
34
|
+
readonly value: "base32";
|
|
35
|
+
readonly label: "Standard (RFC 4648): A-Z2-7=";
|
|
36
|
+
}, {
|
|
37
|
+
readonly value: "base32hex";
|
|
38
|
+
readonly label: "Extended hex (RFC 4648 §7): 0-9A-V=";
|
|
39
|
+
}];
|
|
40
|
+
readonly default: "base32";
|
|
41
|
+
};
|
|
42
|
+
readonly padding: {
|
|
43
|
+
readonly type: "boolean";
|
|
44
|
+
readonly name: "Padding (=)";
|
|
45
|
+
readonly default: true;
|
|
46
|
+
};
|
|
47
|
+
}, "from-base32">, Operation<"from-base32", {
|
|
48
|
+
readonly alphabet: {
|
|
49
|
+
readonly type: "select";
|
|
50
|
+
readonly name: "Alphabet";
|
|
51
|
+
readonly options: readonly [{
|
|
52
|
+
readonly value: "base32";
|
|
53
|
+
readonly label: "Standard (RFC 4648): A-Z2-7=";
|
|
54
|
+
}, {
|
|
55
|
+
readonly value: "base32hex";
|
|
56
|
+
readonly label: "Extended hex (RFC 4648 §7): 0-9A-V=";
|
|
57
|
+
}];
|
|
58
|
+
readonly default: "base32";
|
|
59
|
+
};
|
|
60
|
+
}, "to-base32">, Operation<"to-base58", {
|
|
61
|
+
readonly alphabet: {
|
|
62
|
+
readonly type: "select";
|
|
63
|
+
readonly name: "Alphabet";
|
|
64
|
+
readonly options: readonly [{
|
|
65
|
+
readonly value: "bitcoin";
|
|
66
|
+
readonly label: "Bitcoin: 1-9A-HJ-NP-Za-km-z";
|
|
67
|
+
}, {
|
|
68
|
+
readonly value: "flickr";
|
|
69
|
+
readonly label: "Flickr: 1-9a-km-zA-HJ-NP-Z";
|
|
70
|
+
}, {
|
|
71
|
+
readonly value: "ripple";
|
|
72
|
+
readonly label: "Ripple: rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
|
|
73
|
+
}];
|
|
74
|
+
readonly default: "bitcoin";
|
|
75
|
+
};
|
|
76
|
+
}, "from-base58">, Operation<"from-base58", {
|
|
77
|
+
readonly alphabet: {
|
|
78
|
+
readonly type: "select";
|
|
79
|
+
readonly name: "Alphabet";
|
|
80
|
+
readonly options: readonly [{
|
|
81
|
+
readonly value: "bitcoin";
|
|
82
|
+
readonly label: "Bitcoin: 1-9A-HJ-NP-Za-km-z";
|
|
83
|
+
}, {
|
|
84
|
+
readonly value: "flickr";
|
|
85
|
+
readonly label: "Flickr: 1-9a-km-zA-HJ-NP-Z";
|
|
86
|
+
}, {
|
|
87
|
+
readonly value: "ripple";
|
|
88
|
+
readonly label: "Ripple: rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
|
|
89
|
+
}];
|
|
90
|
+
readonly default: "bitcoin";
|
|
91
|
+
};
|
|
92
|
+
}, "to-base58">, Operation<"to-base62", {
|
|
93
|
+
readonly alphabet: {
|
|
94
|
+
readonly type: "select";
|
|
95
|
+
readonly name: "Alphabet";
|
|
96
|
+
readonly options: readonly [{
|
|
97
|
+
readonly value: "0-9A-Za-z";
|
|
98
|
+
readonly label: "Digits, uppercase, lowercase (GMP)";
|
|
99
|
+
}, {
|
|
100
|
+
readonly value: "0-9a-zA-Z";
|
|
101
|
+
readonly label: "Digits, lowercase, uppercase";
|
|
102
|
+
}];
|
|
103
|
+
readonly default: "0-9A-Za-z";
|
|
104
|
+
};
|
|
105
|
+
}, "from-base62">, Operation<"from-base62", {
|
|
106
|
+
readonly alphabet: {
|
|
107
|
+
readonly type: "select";
|
|
108
|
+
readonly name: "Alphabet";
|
|
109
|
+
readonly options: readonly [{
|
|
110
|
+
readonly value: "0-9A-Za-z";
|
|
111
|
+
readonly label: "Digits, uppercase, lowercase (GMP)";
|
|
112
|
+
}, {
|
|
113
|
+
readonly value: "0-9a-zA-Z";
|
|
114
|
+
readonly label: "Digits, lowercase, uppercase";
|
|
115
|
+
}];
|
|
116
|
+
readonly default: "0-9A-Za-z";
|
|
117
|
+
};
|
|
118
|
+
}, "to-base62">, Operation<"to-hex", {
|
|
119
|
+
readonly delimiter: {
|
|
120
|
+
readonly type: "select";
|
|
121
|
+
readonly name: "Delimiter";
|
|
122
|
+
readonly options: readonly [{
|
|
123
|
+
readonly value: "none";
|
|
124
|
+
readonly label: "None: 68656c6c6f";
|
|
125
|
+
}, {
|
|
126
|
+
readonly value: "space";
|
|
127
|
+
readonly label: "Space: 68 65 6c 6c 6f";
|
|
128
|
+
}, {
|
|
129
|
+
readonly value: "colon";
|
|
130
|
+
readonly label: "Colon: 68:65:6c:6c:6f";
|
|
131
|
+
}, {
|
|
132
|
+
readonly value: "comma";
|
|
133
|
+
readonly label: "Comma: 68,65,6c,6c,6f";
|
|
134
|
+
}, {
|
|
135
|
+
readonly value: "escape";
|
|
136
|
+
readonly label: "Escape sequences: \\x68\\x65\\x6c\\x6c\\x6f";
|
|
137
|
+
}, {
|
|
138
|
+
readonly value: "0x";
|
|
139
|
+
readonly label: "C array: 0x68, 0x65, 0x6c, 0x6c, 0x6f";
|
|
140
|
+
}];
|
|
141
|
+
readonly default: "none";
|
|
142
|
+
};
|
|
143
|
+
readonly uppercase: {
|
|
144
|
+
readonly type: "boolean";
|
|
145
|
+
readonly name: "Uppercase";
|
|
146
|
+
readonly default: false;
|
|
147
|
+
};
|
|
148
|
+
}, "from-hex">, Operation<"from-hex", {}, "to-hex">, Operation<"url-encode", {
|
|
149
|
+
readonly encodeAll: {
|
|
150
|
+
readonly type: "boolean";
|
|
151
|
+
readonly name: "Encode all special chars";
|
|
152
|
+
readonly description: "Also encode reserved characters such as / ? & = (like encodeURIComponent).";
|
|
153
|
+
readonly default: false;
|
|
154
|
+
};
|
|
155
|
+
}, "url-decode">, Operation<"url-decode", {
|
|
156
|
+
readonly plusAsSpace: {
|
|
157
|
+
readonly type: "boolean";
|
|
158
|
+
readonly name: "Treat \"+\" as space";
|
|
159
|
+
readonly description: "HTML form behavior (application/x-www-form-urlencoded).";
|
|
160
|
+
readonly default: true;
|
|
161
|
+
};
|
|
162
|
+
}, "url-encode">, Operation<"html-encode", {
|
|
163
|
+
readonly encodeNonAscii: {
|
|
164
|
+
readonly type: "boolean";
|
|
165
|
+
readonly name: "Encode non-ASCII characters";
|
|
166
|
+
readonly description: "Also write characters outside ASCII as numeric entities, e.g. é as é.";
|
|
167
|
+
readonly default: false;
|
|
168
|
+
};
|
|
169
|
+
}, "html-decode">, Operation<"html-decode", {}, "html-encode">, Operation<"md5", {}, never>, Operation<"sha1", {}, never>, Operation<"sha224", {}, never>, Operation<"sha256", {}, never>, Operation<"sha384", {}, never>, Operation<"sha512", {}, never>, Operation<"sha3-224", {}, never>, Operation<"sha3-256", {}, never>, Operation<"sha3-384", {}, never>, Operation<"sha3-512", {}, never>, Operation<"bcrypt", {
|
|
170
|
+
readonly rounds: {
|
|
171
|
+
readonly type: "number";
|
|
172
|
+
readonly name: "Cost";
|
|
173
|
+
readonly description: "Log2 of the number of rounds: each step doubles the computing time.";
|
|
174
|
+
readonly min: 4;
|
|
175
|
+
readonly max: 31;
|
|
176
|
+
readonly default: 10;
|
|
177
|
+
};
|
|
178
|
+
readonly salt: {
|
|
179
|
+
readonly type: "string";
|
|
180
|
+
readonly name: "Salt";
|
|
181
|
+
readonly description: "22 characters from ./A-Za-z0-9. Leave empty for a random salt.";
|
|
182
|
+
readonly default: "";
|
|
183
|
+
};
|
|
184
|
+
}, never>, Operation<"json-format", {
|
|
185
|
+
readonly indent: {
|
|
186
|
+
readonly type: "select";
|
|
187
|
+
readonly name: "Indentation";
|
|
188
|
+
readonly options: readonly [{
|
|
189
|
+
readonly value: "2";
|
|
190
|
+
readonly label: "2 spaces";
|
|
191
|
+
}, {
|
|
192
|
+
readonly value: "4";
|
|
193
|
+
readonly label: "4 spaces";
|
|
194
|
+
}, {
|
|
195
|
+
readonly value: "tab";
|
|
196
|
+
readonly label: "Tab";
|
|
197
|
+
}, {
|
|
198
|
+
readonly value: "minify";
|
|
199
|
+
readonly label: "None, on a single line";
|
|
200
|
+
}];
|
|
201
|
+
readonly default: "2";
|
|
202
|
+
};
|
|
203
|
+
}, never>, Operation<"json-to-yaml", {}, "yaml-to-json">, Operation<"yaml-to-json", {
|
|
204
|
+
readonly indent: {
|
|
205
|
+
readonly type: "select";
|
|
206
|
+
readonly name: "Indentation";
|
|
207
|
+
readonly options: readonly [{
|
|
208
|
+
readonly value: "2";
|
|
209
|
+
readonly label: "2 spaces";
|
|
210
|
+
}, {
|
|
211
|
+
readonly value: "4";
|
|
212
|
+
readonly label: "4 spaces";
|
|
213
|
+
}, {
|
|
214
|
+
readonly value: "tab";
|
|
215
|
+
readonly label: "Tab";
|
|
216
|
+
}, {
|
|
217
|
+
readonly value: "minify";
|
|
218
|
+
readonly label: "None, on a single line";
|
|
219
|
+
}];
|
|
220
|
+
readonly default: "2";
|
|
221
|
+
};
|
|
222
|
+
}, "json-to-yaml">, Operation<"hex-to-rgb", {
|
|
223
|
+
readonly format: {
|
|
224
|
+
readonly type: "select";
|
|
225
|
+
readonly name: "Format";
|
|
226
|
+
readonly options: readonly [{
|
|
227
|
+
readonly value: "css";
|
|
228
|
+
readonly label: "CSS: rgb(255, 136, 0) or rgba(255, 136, 0, 0.5)";
|
|
229
|
+
}, {
|
|
230
|
+
readonly value: "values";
|
|
231
|
+
readonly label: "Values: 255, 136, 0";
|
|
232
|
+
}];
|
|
233
|
+
readonly default: "css";
|
|
234
|
+
};
|
|
235
|
+
}, never>, Operation<"to-lower-case", {}, never>, Operation<"to-upper-case", {}, never>, Operation<"to-title-case", {}, never>, Operation<"to-camel-case", {}, never>, Operation<"to-pascal-case", {}, never>, Operation<"to-snake-case", {}, never>, Operation<"to-kebab-case", {}, never>, Operation<"to-slug", {
|
|
236
|
+
readonly separator: {
|
|
237
|
+
readonly type: "string";
|
|
238
|
+
readonly name: "Separator";
|
|
239
|
+
readonly default: "-";
|
|
240
|
+
};
|
|
241
|
+
}, never>, Operation<"sort-lines", {
|
|
242
|
+
readonly reverse: {
|
|
243
|
+
readonly type: "boolean";
|
|
244
|
+
readonly name: "Reverse";
|
|
245
|
+
readonly description: "Sort in descending order.";
|
|
246
|
+
readonly default: false;
|
|
247
|
+
};
|
|
248
|
+
readonly ignoreCase: {
|
|
249
|
+
readonly type: "boolean";
|
|
250
|
+
readonly name: "Ignore case";
|
|
251
|
+
readonly default: false;
|
|
252
|
+
};
|
|
253
|
+
readonly natural: {
|
|
254
|
+
readonly type: "boolean";
|
|
255
|
+
readonly name: "Natural order";
|
|
256
|
+
readonly description: "Compare numbers by value (\"2\" before \"10\") and letters alphabetically (\"a\" before \"B\").";
|
|
257
|
+
readonly default: false;
|
|
258
|
+
};
|
|
259
|
+
}, never>, Operation<"shuffle-lines", {
|
|
260
|
+
readonly seed: {
|
|
261
|
+
readonly type: "string";
|
|
262
|
+
readonly name: "Seed";
|
|
263
|
+
readonly description: "Gives the same order every time for the same seed and input. Leave empty for a random order.";
|
|
264
|
+
readonly default: "";
|
|
265
|
+
};
|
|
266
|
+
}, never>, Operation<"unique-lines", {
|
|
267
|
+
readonly ignoreCase: {
|
|
268
|
+
readonly type: "boolean";
|
|
269
|
+
readonly name: "Ignore case";
|
|
270
|
+
readonly default: false;
|
|
271
|
+
};
|
|
272
|
+
}, never>, Operation<"reverse-lines", {}, never>, Operation<"add-line-numbers", {
|
|
273
|
+
readonly start: {
|
|
274
|
+
readonly type: "number";
|
|
275
|
+
readonly name: "First number";
|
|
276
|
+
readonly default: 1;
|
|
277
|
+
};
|
|
278
|
+
readonly separator: {
|
|
279
|
+
readonly type: "string";
|
|
280
|
+
readonly name: "Separator";
|
|
281
|
+
readonly description: "Placed between the number and the line.";
|
|
282
|
+
readonly default: " ";
|
|
283
|
+
};
|
|
284
|
+
}, never>, Operation<"reverse-text", {}, never>, Operation<"remove-newlines", {
|
|
285
|
+
readonly replacement: {
|
|
286
|
+
readonly type: "string";
|
|
287
|
+
readonly name: "Replacement";
|
|
288
|
+
readonly default: "";
|
|
289
|
+
};
|
|
290
|
+
}, never>, Operation<"remove-whitespace", {
|
|
291
|
+
readonly keepNewlines: {
|
|
292
|
+
readonly type: "boolean";
|
|
293
|
+
readonly name: "Keep line breaks";
|
|
294
|
+
readonly default: false;
|
|
295
|
+
};
|
|
296
|
+
}, never>, Operation<"escape-quotes", {
|
|
297
|
+
readonly quotes: {
|
|
298
|
+
readonly type: "select";
|
|
299
|
+
readonly name: "Quotes";
|
|
300
|
+
readonly options: readonly [{
|
|
301
|
+
readonly value: "double";
|
|
302
|
+
readonly label: 'Double quotes (")';
|
|
303
|
+
}, {
|
|
304
|
+
readonly value: "single";
|
|
305
|
+
readonly label: "Single quotes (')";
|
|
306
|
+
}, {
|
|
307
|
+
readonly value: "both";
|
|
308
|
+
readonly label: "Both";
|
|
309
|
+
}];
|
|
310
|
+
readonly default: "double";
|
|
311
|
+
};
|
|
312
|
+
readonly escapeBackslashes: {
|
|
313
|
+
readonly type: "boolean";
|
|
314
|
+
readonly name: "Escape backslashes";
|
|
315
|
+
readonly default: true;
|
|
316
|
+
};
|
|
317
|
+
}, never>, Operation<"count-chars", {
|
|
318
|
+
readonly unit: {
|
|
319
|
+
readonly type: "select";
|
|
320
|
+
readonly name: "Unit";
|
|
321
|
+
readonly options: readonly [{
|
|
322
|
+
readonly value: "graphemes";
|
|
323
|
+
readonly label: "Characters as displayed (é and 👍🏽 count as 1)";
|
|
324
|
+
}, {
|
|
325
|
+
readonly value: "codepoints";
|
|
326
|
+
readonly label: "Unicode code points";
|
|
327
|
+
}, {
|
|
328
|
+
readonly value: "bytes";
|
|
329
|
+
readonly label: "Bytes";
|
|
330
|
+
}];
|
|
331
|
+
readonly default: "graphemes";
|
|
332
|
+
};
|
|
333
|
+
}, never>, Operation<"count-lines", {}, never>, Operation<"count-words", {}, never>, Operation<"extract-ips", {
|
|
334
|
+
readonly unique: {
|
|
335
|
+
readonly type: "boolean";
|
|
336
|
+
readonly name: "Unique";
|
|
337
|
+
readonly description: "Only list each value once.";
|
|
338
|
+
readonly default: false;
|
|
339
|
+
};
|
|
340
|
+
readonly sort: {
|
|
341
|
+
readonly type: "boolean";
|
|
342
|
+
readonly name: "Sort";
|
|
343
|
+
readonly default: false;
|
|
344
|
+
};
|
|
345
|
+
readonly version: {
|
|
346
|
+
readonly type: "select";
|
|
347
|
+
readonly name: "Version";
|
|
348
|
+
readonly options: readonly [{
|
|
349
|
+
readonly value: "both";
|
|
350
|
+
readonly label: "IPv4 and IPv6";
|
|
351
|
+
}, {
|
|
352
|
+
readonly value: "ipv4";
|
|
353
|
+
readonly label: "IPv4 only";
|
|
354
|
+
}, {
|
|
355
|
+
readonly value: "ipv6";
|
|
356
|
+
readonly label: "IPv6 only";
|
|
357
|
+
}];
|
|
358
|
+
readonly default: "both";
|
|
359
|
+
};
|
|
360
|
+
}, never>, Operation<"extract-emails", {
|
|
361
|
+
readonly unique: {
|
|
362
|
+
readonly type: "boolean";
|
|
363
|
+
readonly name: "Unique";
|
|
364
|
+
readonly description: "Only list each value once.";
|
|
365
|
+
readonly default: false;
|
|
366
|
+
};
|
|
367
|
+
readonly sort: {
|
|
368
|
+
readonly type: "boolean";
|
|
369
|
+
readonly name: "Sort";
|
|
370
|
+
readonly default: false;
|
|
371
|
+
};
|
|
372
|
+
}, never>, Operation<"extract-urls", {
|
|
373
|
+
readonly unique: {
|
|
374
|
+
readonly type: "boolean";
|
|
375
|
+
readonly name: "Unique";
|
|
376
|
+
readonly description: "Only list each value once.";
|
|
377
|
+
readonly default: false;
|
|
378
|
+
};
|
|
379
|
+
readonly sort: {
|
|
380
|
+
readonly type: "boolean";
|
|
381
|
+
readonly name: "Sort";
|
|
382
|
+
readonly default: false;
|
|
383
|
+
};
|
|
384
|
+
}, never>];
|
|
385
|
+
type AnyOperation = (typeof operations)[number];
|
|
386
|
+
export type OperationId = AnyOperation["id"];
|
|
387
|
+
export type ArgsOf<Id extends OperationId> = ArgValues<Extract<AnyOperation, {
|
|
388
|
+
id: Id;
|
|
389
|
+
}>["args"]>;
|
|
390
|
+
export declare function isOperationId(id: string): id is OperationId;
|
|
391
|
+
export declare function getOperation(id: OperationId): Operation;
|
|
392
|
+
/** Throws an `OperationError` tagged with the operation id when the input or arguments are invalid. */
|
|
393
|
+
export declare function run<Id extends OperationId>(id: Id, input: Uint8Array | string, args?: Partial<ArgsOf<Id>>): Uint8Array;
|
|
394
|
+
export declare function runText<Id extends OperationId>(id: Id, input: Uint8Array | string, args?: Partial<ArgsOf<Id>>): string;
|
|
395
|
+
export {};
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { checkArg } from "./args.js";
|
|
2
|
+
import { OperationError } from "./errors.js";
|
|
3
|
+
import { fromBase32, toBase32 } from "./operations/base/base32.js";
|
|
4
|
+
import { fromBase58, toBase58 } from "./operations/base/base58.js";
|
|
5
|
+
import { fromBase62, toBase62 } from "./operations/base/base62.js";
|
|
6
|
+
import { fromBase64, toBase64 } from "./operations/base/base64.js";
|
|
7
|
+
import { fromBase64url, toBase64url } from "./operations/base/base64url.js";
|
|
8
|
+
import { hexToRgb } from "./operations/color/hex-to-rgb.js";
|
|
9
|
+
import { jsonFormat } from "./operations/data/json-format.js";
|
|
10
|
+
import { jsonToYaml, yamlToJson } from "./operations/data/yaml.js";
|
|
11
|
+
import { extractEmails, extractIps, extractUrls } from "./operations/extract/extract.js";
|
|
12
|
+
import { bcrypt } from "./operations/hash/bcrypt.js";
|
|
13
|
+
import { md5, sha1, sha224, sha256, sha384, sha3_224, sha3_256, sha3_384, sha3_512, sha512 } from "./operations/hash/hashes.js";
|
|
14
|
+
import { fromHex } from "./operations/hex/from-hex.js";
|
|
15
|
+
import { toHex } from "./operations/hex/to-hex.js";
|
|
16
|
+
import { htmlDecode } from "./operations/html/html-decode.js";
|
|
17
|
+
import { htmlEncode } from "./operations/html/html-encode.js";
|
|
18
|
+
import { toCamelCase, toKebabCase, toLowerCase, toPascalCase, toSlug, toSnakeCase, toTitleCase, toUpperCase, } from "./operations/text/case.js";
|
|
19
|
+
import { countChars, countLines, countWords } from "./operations/text/count.js";
|
|
20
|
+
import { addLineNumbers, reverseLines, shuffleLines, sortLines, uniqueLines } from "./operations/text/line-operations.js";
|
|
21
|
+
import { escapeQuotes, removeNewlines, removeWhitespace, reverseText } from "./operations/text/text-operations.js";
|
|
22
|
+
import { urlDecode } from "./operations/url/url-decode.js";
|
|
23
|
+
import { urlEncode } from "./operations/url/url-encode.js";
|
|
24
|
+
/** Every new operation must be registered here. */
|
|
25
|
+
export const operations = [
|
|
26
|
+
// Encoding
|
|
27
|
+
toBase64,
|
|
28
|
+
fromBase64,
|
|
29
|
+
toBase64url,
|
|
30
|
+
fromBase64url,
|
|
31
|
+
toBase32,
|
|
32
|
+
fromBase32,
|
|
33
|
+
toBase58,
|
|
34
|
+
fromBase58,
|
|
35
|
+
toBase62,
|
|
36
|
+
fromBase62,
|
|
37
|
+
toHex,
|
|
38
|
+
fromHex,
|
|
39
|
+
urlEncode,
|
|
40
|
+
urlDecode,
|
|
41
|
+
htmlEncode,
|
|
42
|
+
htmlDecode,
|
|
43
|
+
// Hashing
|
|
44
|
+
md5,
|
|
45
|
+
sha1,
|
|
46
|
+
sha224,
|
|
47
|
+
sha256,
|
|
48
|
+
sha384,
|
|
49
|
+
sha512,
|
|
50
|
+
sha3_224,
|
|
51
|
+
sha3_256,
|
|
52
|
+
sha3_384,
|
|
53
|
+
sha3_512,
|
|
54
|
+
bcrypt,
|
|
55
|
+
// Data format
|
|
56
|
+
jsonFormat,
|
|
57
|
+
jsonToYaml,
|
|
58
|
+
yamlToJson,
|
|
59
|
+
hexToRgb,
|
|
60
|
+
// Text
|
|
61
|
+
toLowerCase,
|
|
62
|
+
toUpperCase,
|
|
63
|
+
toTitleCase,
|
|
64
|
+
toCamelCase,
|
|
65
|
+
toPascalCase,
|
|
66
|
+
toSnakeCase,
|
|
67
|
+
toKebabCase,
|
|
68
|
+
toSlug,
|
|
69
|
+
sortLines,
|
|
70
|
+
shuffleLines,
|
|
71
|
+
uniqueLines,
|
|
72
|
+
reverseLines,
|
|
73
|
+
addLineNumbers,
|
|
74
|
+
reverseText,
|
|
75
|
+
removeNewlines,
|
|
76
|
+
removeWhitespace,
|
|
77
|
+
escapeQuotes,
|
|
78
|
+
countChars,
|
|
79
|
+
countLines,
|
|
80
|
+
countWords,
|
|
81
|
+
// Extractors
|
|
82
|
+
extractIps,
|
|
83
|
+
extractEmails,
|
|
84
|
+
extractUrls,
|
|
85
|
+
];
|
|
86
|
+
const inversesExist = true;
|
|
87
|
+
void inversesExist;
|
|
88
|
+
const byId = new Map(operations.map((op) => [op.id, op]));
|
|
89
|
+
export function isOperationId(id) {
|
|
90
|
+
return byId.has(id);
|
|
91
|
+
}
|
|
92
|
+
export function getOperation(id) {
|
|
93
|
+
return byId.get(id);
|
|
94
|
+
}
|
|
95
|
+
function resolveArgs(op, args) {
|
|
96
|
+
for (const key of Object.keys(args)) {
|
|
97
|
+
if (!Object.hasOwn(op.args, key)) {
|
|
98
|
+
const expected = Object.keys(op.args).join(", ") || "none";
|
|
99
|
+
throw new OperationError(`Unknown argument "${key}" (expected: ${expected})`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const resolved = {};
|
|
103
|
+
for (const [key, def] of Object.entries(op.args)) {
|
|
104
|
+
const value = args[key] ?? def.default;
|
|
105
|
+
try {
|
|
106
|
+
checkArg(def, key, value);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw new OperationError(error.message);
|
|
110
|
+
}
|
|
111
|
+
resolved[key] = value;
|
|
112
|
+
}
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
/** Throws an `OperationError` tagged with the operation id when the input or arguments are invalid. */
|
|
116
|
+
export function run(id, input, args = {}) {
|
|
117
|
+
const op = getOperation(id);
|
|
118
|
+
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
119
|
+
try {
|
|
120
|
+
return op.run(bytes, resolveArgs(op, args));
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const wrapped = error instanceof OperationError ? error : new OperationError(error.message, { cause: error });
|
|
124
|
+
wrapped.operation = id;
|
|
125
|
+
throw wrapped;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export function runText(id, input, args = {}) {
|
|
129
|
+
return new TextDecoder().decode(run(id, input, args));
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAChI,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,UAAU,E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;
|
|
5
|
+
} | {
|
|
6
|
+
type: "op";
|
|
7
|
+
id: OperationId;
|
|
8
|
+
args: Record<string, unknown>;
|
|
9
|
+
children: TemplateNode[];
|
|
10
|
+
start: number;
|
|
11
|
+
};
|
|
12
|
+
export declare class TemplateError extends Error {
|
|
13
|
+
name: string;
|
|
14
|
+
/** 1-based line and column of `position`. */
|
|
15
|
+
readonly line: number;
|
|
16
|
+
readonly column: number;
|
|
17
|
+
/** Offset in the source. */
|
|
18
|
+
readonly position: number;
|
|
19
|
+
constructor(message: string, source: string, position: number);
|
|
20
|
+
}
|
|
21
|
+
export declare function parse(source: string): TemplateNode[];
|
|
22
|
+
export declare function renderBytes(source: string): Uint8Array;
|
|
23
|
+
export declare function render(source: string): string;
|