@manot40/genql-cli 1.0.0 β 1.0.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.
- package/LICENSE +21 -21
- package/README.md +41 -41
- package/dist/chunk-CIPSg9SW.mjs +31 -0
- package/dist/cli-truncate-D3wAEQfN.mjs +155 -0
- package/dist/cli.mjs +4248 -8
- package/dist/get-east-asian-width-BRiQxJA0.mjs +24 -0
- package/dist/index.mjs +1 -1
- package/dist/log-update-ByzxNOMZ.mjs +432 -0
- package/dist/main-D79GNEz7.mjs +4937 -0
- package/dist/runtime/createClient.ts +3 -2
- package/dist/slice-ansi-jJmCsHqC.mjs +282 -0
- package/dist/wrap-ansi-CNamFguB.mjs +3 -0
- package/dist/wrap-ansi-CUNel7aF.mjs +359 -0
- package/package.json +23 -28
- package/dist/cli.d.mts +0 -9
- package/dist/index.d.mts +0 -19
- package/dist/main-BVWRj669.mjs +0 -798
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Tommaso De Rossi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Tommaso De Rossi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
13
|
> [!IMPORTANT]
|
|
14
|
-
> Genql is building a cloud platform to automate SDK generation in multiple languages, docs website with examples, changelog website and more.
|
|
14
|
+
> Genql is building a cloud platform to automate SDK generation in multiple languages, docs website with examples, changelog website and more.
|
|
15
15
|
> Fill [this form](https://tally.so/r/mK1GWM) if you are interested!
|
|
16
16
|
|
|
17
17
|
Read the [quick start guide](https://genql.dev/docs) to generate your client and start writing queries.
|
|
@@ -20,14 +20,14 @@ You can stay up to date with the latest changes subscribing to the [Genql change
|
|
|
20
20
|
|
|
21
21
|
**Features**
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
23
|
+
- β
Type completion & Type validation
|
|
24
|
+
- π No dependencies (not even graphql)
|
|
25
|
+
- β‘οΈ [Can easily fetch all scalar fields in a type](https://genql.dev/docs/usage/fetch-all-fields-on-a-type)
|
|
26
|
+
- π [Works with any client (Apollo, Relay, etc)](https://genql.dev/docs/usage/integrate-with-other-graphql-clients)
|
|
27
|
+
- π₯ [Support for Subscriptions](https://genql.dev/docs/usage/subscriptions)
|
|
28
|
+
- π [Built in batching support](https://genql.dev/docs/usage/batching-queries)
|
|
29
|
+
- βοΈ [Easy migrate existing GraphQL queries to Genql code](https://genql.dev/converter)
|
|
30
|
+
- π Works in browser, Node, Deno, Cloudflare workers, Bun and more
|
|
31
31
|
|
|
32
32
|
## Example
|
|
33
33
|
|
|
@@ -43,43 +43,43 @@ genql --schema ./schema.graphql --output ./generated
|
|
|
43
43
|
Then you can use your client as follow
|
|
44
44
|
|
|
45
45
|
```js
|
|
46
|
-
import { createClient, everything } from './generated'
|
|
47
|
-
const client = createClient()
|
|
46
|
+
import { createClient, everything } from './generated';
|
|
47
|
+
const client = createClient();
|
|
48
48
|
|
|
49
49
|
client
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
name: true,
|
|
61
|
-
code: true,
|
|
62
|
-
nestedField: {
|
|
63
|
-
// fetch all scalar fields
|
|
64
|
-
__scalar: true,
|
|
65
|
-
},
|
|
50
|
+
.query({
|
|
51
|
+
countries: {
|
|
52
|
+
// pass arguments to the query
|
|
53
|
+
__args: {
|
|
54
|
+
filter: {
|
|
55
|
+
currency: {
|
|
56
|
+
eq: 'EUR',
|
|
57
|
+
},
|
|
66
58
|
},
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
},
|
|
60
|
+
name: true,
|
|
61
|
+
code: true,
|
|
62
|
+
nestedField: {
|
|
63
|
+
// fetch all scalar fields
|
|
64
|
+
__scalar: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
.then(console.log);
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
The code above will fetch the graphql query below
|
|
72
72
|
|
|
73
73
|
```graphql
|
|
74
74
|
query {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
75
|
+
countries(filter: { currency: { eq: "EUR" } }) {
|
|
76
|
+
name
|
|
77
|
+
code
|
|
78
|
+
nestedField {
|
|
79
|
+
scalarField1
|
|
80
|
+
scalarField2
|
|
82
81
|
}
|
|
82
|
+
}
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -87,11 +87,11 @@ query {
|
|
|
87
87
|
|
|
88
88
|
Genql has a lot of benefits over writing graphql queries by hand:
|
|
89
89
|
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
90
|
+
- Writing queries is faster thanks to TypeScript auto completion
|
|
91
|
+
- You can safely update your schema and be sure your queries are still valid
|
|
92
|
+
- You can fetch all scalar fields in a type with `__scalar: true`
|
|
93
|
+
- No `graphql` package dependency, no runtime parsing of queries
|
|
94
|
+
- You have to generate the client only after your schema changes, not after every query change
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { __toESM as n, __commonJSMin as t };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { t as eastAsianWidth } from "./get-east-asian-width-BRiQxJA0.mjs";
|
|
2
|
+
import { t as sliceAnsi } from "./slice-ansi-jJmCsHqC.mjs";
|
|
3
|
+
|
|
4
|
+
//#region node_modules/cli-truncate/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
5
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
6
|
+
return new RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`, onlyFirst ? void 0 : "g");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region node_modules/cli-truncate/node_modules/string-width/node_modules/strip-ansi/index.js
|
|
11
|
+
const regex = ansiRegex();
|
|
12
|
+
function stripAnsi(string) {
|
|
13
|
+
if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
14
|
+
return string.replace(regex, "");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/cli-truncate/node_modules/string-width/index.js
|
|
19
|
+
/**
|
|
20
|
+
Logic:
|
|
21
|
+
- Segment graphemes to match how terminals render clusters.
|
|
22
|
+
- Width rules:
|
|
23
|
+
1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.
|
|
24
|
+
2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
|
|
25
|
+
3. Otherwise use East Asian Width of the clusterβs first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
|
|
26
|
+
*/
|
|
27
|
+
const segmenter = new Intl.Segmenter();
|
|
28
|
+
const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
|
|
29
|
+
const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
|
|
30
|
+
const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
31
|
+
function baseVisible(segment) {
|
|
32
|
+
return segment.replace(leadingNonPrintingRegex, "");
|
|
33
|
+
}
|
|
34
|
+
function isZeroWidthCluster(segment) {
|
|
35
|
+
return zeroWidthClusterRegex.test(segment);
|
|
36
|
+
}
|
|
37
|
+
function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
|
|
38
|
+
let extra = 0;
|
|
39
|
+
if (segment.length > 1) {
|
|
40
|
+
for (const char of segment.slice(1)) if (char >= "οΌ" && char <= "οΏ―") extra += eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);
|
|
41
|
+
}
|
|
42
|
+
return extra;
|
|
43
|
+
}
|
|
44
|
+
function stringWidth(input, options = {}) {
|
|
45
|
+
if (typeof input !== "string" || input.length === 0) return 0;
|
|
46
|
+
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
47
|
+
let string = input;
|
|
48
|
+
if (!countAnsiEscapeCodes) string = stripAnsi(string);
|
|
49
|
+
if (string.length === 0) return 0;
|
|
50
|
+
let width = 0;
|
|
51
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
52
|
+
for (const { segment } of segmenter.segment(string)) {
|
|
53
|
+
if (isZeroWidthCluster(segment)) continue;
|
|
54
|
+
if (rgiEmojiRegex.test(segment)) {
|
|
55
|
+
width += 2;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const codePoint = baseVisible(segment).codePointAt(0);
|
|
59
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
60
|
+
width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
|
|
61
|
+
}
|
|
62
|
+
return width;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region node_modules/cli-truncate/index.js
|
|
67
|
+
function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
|
|
68
|
+
if (string.charAt(wantedIndex) === " ") return wantedIndex;
|
|
69
|
+
const direction = shouldSearchRight ? 1 : -1;
|
|
70
|
+
for (let index = 0; index <= 3; index++) {
|
|
71
|
+
const finalIndex = wantedIndex + index * direction;
|
|
72
|
+
if (string.charAt(finalIndex) === " ") return finalIndex;
|
|
73
|
+
}
|
|
74
|
+
return wantedIndex;
|
|
75
|
+
}
|
|
76
|
+
function cliTruncate(text, columns, options = {}) {
|
|
77
|
+
const { position = "end", space = false, preferTruncationOnSpace = false } = options;
|
|
78
|
+
let { truncationCharacter = "β¦" } = options;
|
|
79
|
+
if (typeof text !== "string") throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
|
|
80
|
+
if (typeof columns !== "number") throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
|
|
81
|
+
if (columns < 1) return "";
|
|
82
|
+
const length = stringWidth(text);
|
|
83
|
+
if (length <= columns) return text;
|
|
84
|
+
if (columns === 1) return truncationCharacter;
|
|
85
|
+
const ANSI = {
|
|
86
|
+
ESC: 27,
|
|
87
|
+
LEFT_BRACKET: 91,
|
|
88
|
+
LETTER_M: 109
|
|
89
|
+
};
|
|
90
|
+
const isSgrParameter = (code) => code >= 48 && code <= 57 || code === 59;
|
|
91
|
+
function leadingSgrSpanEndIndex(string) {
|
|
92
|
+
let index = 0;
|
|
93
|
+
while (index + 2 < string.length && string.codePointAt(index) === ANSI.ESC && string.codePointAt(index + 1) === ANSI.LEFT_BRACKET) {
|
|
94
|
+
let j = index + 2;
|
|
95
|
+
while (j < string.length && isSgrParameter(string.codePointAt(j))) j++;
|
|
96
|
+
if (j < string.length && string.codePointAt(j) === ANSI.LETTER_M) {
|
|
97
|
+
index = j + 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
return index;
|
|
103
|
+
}
|
|
104
|
+
function trailingSgrSpanStartIndex(string) {
|
|
105
|
+
let start = string.length;
|
|
106
|
+
while (start > 1 && string.codePointAt(start - 1) === ANSI.LETTER_M) {
|
|
107
|
+
let j = start - 2;
|
|
108
|
+
while (j >= 0 && isSgrParameter(string.codePointAt(j))) j--;
|
|
109
|
+
if (j >= 1 && string.codePointAt(j - 1) === ANSI.ESC && string.codePointAt(j) === ANSI.LEFT_BRACKET) {
|
|
110
|
+
start = j - 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return start;
|
|
116
|
+
}
|
|
117
|
+
function appendWithInheritedStyleFromEnd(visible, suffix) {
|
|
118
|
+
const start = trailingSgrSpanStartIndex(visible);
|
|
119
|
+
if (start === visible.length) return visible + suffix;
|
|
120
|
+
return visible.slice(0, start) + suffix + visible.slice(start);
|
|
121
|
+
}
|
|
122
|
+
function prependWithInheritedStyleFromStart(prefix, visible) {
|
|
123
|
+
const end = leadingSgrSpanEndIndex(visible);
|
|
124
|
+
if (end === 0) return prefix + visible;
|
|
125
|
+
return visible.slice(0, end) + prefix + visible.slice(end);
|
|
126
|
+
}
|
|
127
|
+
if (position === "start") {
|
|
128
|
+
if (preferTruncationOnSpace) {
|
|
129
|
+
const right$1 = sliceAnsi(text, getIndexOfNearestSpace(text, length - columns + 1, true), length).trim();
|
|
130
|
+
return prependWithInheritedStyleFromStart(truncationCharacter, right$1);
|
|
131
|
+
}
|
|
132
|
+
if (space) truncationCharacter += " ";
|
|
133
|
+
const right = sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
|
|
134
|
+
return prependWithInheritedStyleFromStart(truncationCharacter, right);
|
|
135
|
+
}
|
|
136
|
+
if (position === "middle") {
|
|
137
|
+
if (space) truncationCharacter = ` ${truncationCharacter} `;
|
|
138
|
+
const half = Math.floor(columns / 2);
|
|
139
|
+
if (preferTruncationOnSpace) {
|
|
140
|
+
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
|
|
141
|
+
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
|
|
142
|
+
return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
|
|
143
|
+
}
|
|
144
|
+
return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length);
|
|
145
|
+
}
|
|
146
|
+
if (position === "end") {
|
|
147
|
+
if (preferTruncationOnSpace) return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, getIndexOfNearestSpace(text, columns - 1)), truncationCharacter);
|
|
148
|
+
if (space) truncationCharacter = ` ${truncationCharacter}`;
|
|
149
|
+
return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)), truncationCharacter);
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { cliTruncate as default };
|