@gadgetinc/ggt 1.0.3 → 1.0.5
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/dist/add-4ME2KTJQ.js +84 -0
- package/dist/add-4ME2KTJQ.js.map +7 -0
- package/dist/build-4BGA4IZE.js +3 -0
- package/dist/build-4BGA4IZE.js.map +7 -0
- package/dist/chunk-57XALM2W.js +2 -0
- package/dist/chunk-57XALM2W.js.map +7 -0
- package/dist/chunk-5DLLJX5F.js +11 -0
- package/dist/chunk-5DLLJX5F.js.map +7 -0
- package/dist/chunk-5WC5D4WL.js +2 -0
- package/dist/chunk-5WC5D4WL.js.map +7 -0
- package/dist/chunk-BSCZOMV4.js +2 -0
- package/dist/chunk-BSCZOMV4.js.map +7 -0
- package/dist/chunk-BZY2AIPV.js +57 -0
- package/dist/chunk-BZY2AIPV.js.map +7 -0
- package/dist/chunk-D2K5XPNJ.js +2 -0
- package/dist/chunk-D2K5XPNJ.js.map +7 -0
- package/dist/chunk-F3EZ4KS3.js +2 -0
- package/dist/chunk-F3EZ4KS3.js.map +7 -0
- package/dist/chunk-G3VNV5Z6.js +33 -0
- package/dist/chunk-G3VNV5Z6.js.map +7 -0
- package/dist/chunk-GA7AL463.js +24 -0
- package/dist/chunk-GA7AL463.js.map +7 -0
- package/dist/chunk-GOBNB5VT.js +2 -0
- package/dist/chunk-GOBNB5VT.js.map +7 -0
- package/dist/chunk-HKBXEZNF.js +2 -0
- package/dist/chunk-HKBXEZNF.js.map +7 -0
- package/{lib/commands/push.js → dist/chunk-IKJVXTZK.js} +7 -48
- package/dist/chunk-IKJVXTZK.js.map +7 -0
- package/dist/chunk-KGSSHEEC.js +17 -0
- package/dist/chunk-KGSSHEEC.js.map +7 -0
- package/dist/chunk-KXK37C5D.js +183 -0
- package/dist/chunk-KXK37C5D.js.map +7 -0
- package/dist/chunk-NJIDVM2C.js +27 -0
- package/dist/chunk-NJIDVM2C.js.map +7 -0
- package/dist/chunk-Q5N5L6H3.js +6 -0
- package/dist/chunk-Q5N5L6H3.js.map +7 -0
- package/dist/chunk-QEVWPU3D.js +8 -0
- package/dist/chunk-QEVWPU3D.js.map +7 -0
- package/dist/chunk-X36GM74C.js +2 -0
- package/dist/chunk-X36GM74C.js.map +7 -0
- package/dist/chunk-YRP2UZ2I.js +126 -0
- package/dist/chunk-YRP2UZ2I.js.map +7 -0
- package/dist/deploy-6HOBYPE6.js +30 -0
- package/dist/deploy-6HOBYPE6.js.map +7 -0
- package/dist/dev-M3WDGK4D.js +57 -0
- package/dist/dev-M3WDGK4D.js.map +7 -0
- package/dist/esm-BL3OM5UJ.js +33 -0
- package/dist/esm-BL3OM5UJ.js.map +7 -0
- package/dist/list-725RHWD5.js +11 -0
- package/dist/list-725RHWD5.js.map +7 -0
- package/dist/login-I4RGMDLE.js +2 -0
- package/dist/login-I4RGMDLE.js.map +7 -0
- package/dist/logout-UZBACOIX.js +7 -0
- package/dist/logout-UZBACOIX.js.map +7 -0
- package/dist/main.js +45 -0
- package/dist/main.js.map +7 -0
- package/dist/open-GWKGQQG3.js +74 -0
- package/dist/open-GWKGQQG3.js.map +7 -0
- package/{lib/commands/pull.js → dist/pull-7C5A65KB.js} +7 -48
- package/dist/pull-7C5A65KB.js.map +7 -0
- package/dist/push-LPUIR4EO.js +2 -0
- package/dist/push-LPUIR4EO.js.map +7 -0
- package/dist/status-DFKKSRVB.js +14 -0
- package/dist/status-DFKKSRVB.js.map +7 -0
- package/dist/version-JD42JXWY.js +11 -0
- package/dist/version-JD42JXWY.js.map +7 -0
- package/dist/whoami-I23R6HOG.js +7 -0
- package/dist/whoami-I23R6HOG.js.map +7 -0
- package/package.json +73 -75
- package/lib/__generated__/graphql.js +0 -78
- package/lib/__generated__/graphql.js.map +0 -1
- package/lib/commands/add.js +0 -385
- package/lib/commands/add.js.map +0 -1
- package/lib/commands/deploy.js +0 -287
- package/lib/commands/deploy.js.map +0 -1
- package/lib/commands/dev.js +0 -374
- package/lib/commands/dev.js.map +0 -1
- package/lib/commands/list.js +0 -47
- package/lib/commands/list.js.map +0 -1
- package/lib/commands/login.js +0 -93
- package/lib/commands/login.js.map +0 -1
- package/lib/commands/logout.js +0 -20
- package/lib/commands/logout.js.map +0 -1
- package/lib/commands/open.js +0 -159
- package/lib/commands/open.js.map +0 -1
- package/lib/commands/pull.js.map +0 -1
- package/lib/commands/push.js.map +0 -1
- package/lib/commands/root.js +0 -110
- package/lib/commands/root.js.map +0 -1
- package/lib/commands/status.js +0 -56
- package/lib/commands/status.js.map +0 -1
- package/lib/commands/version.js +0 -18
- package/lib/commands/version.js.map +0 -1
- package/lib/commands/whoami.js +0 -23
- package/lib/commands/whoami.js.map +0 -1
- package/lib/ggt.js +0 -65
- package/lib/ggt.js.map +0 -1
- package/lib/main.js +0 -5
- package/lib/main.js.map +0 -1
- package/lib/services/app/api/api.js +0 -191
- package/lib/services/app/api/api.js.map +0 -1
- package/lib/services/app/api/operation.js +0 -23
- package/lib/services/app/api/operation.js.map +0 -1
- package/lib/services/app/app.js +0 -95
- package/lib/services/app/app.js.map +0 -1
- package/lib/services/app/arg.js +0 -28
- package/lib/services/app/arg.js.map +0 -1
- package/lib/services/app/client.js +0 -182
- package/lib/services/app/client.js.map +0 -1
- package/lib/services/app/edit/edit.js +0 -191
- package/lib/services/app/edit/edit.js.map +0 -1
- package/lib/services/app/edit/operation.js +0 -155
- package/lib/services/app/edit/operation.js.map +0 -1
- package/lib/services/app/error.js +0 -65
- package/lib/services/app/error.js.map +0 -1
- package/lib/services/command/arg.js +0 -55
- package/lib/services/command/arg.js.map +0 -1
- package/lib/services/command/command.js +0 -47
- package/lib/services/command/command.js.map +0 -1
- package/lib/services/command/context.js +0 -209
- package/lib/services/command/context.js.map +0 -1
- package/lib/services/config/config.js +0 -133
- package/lib/services/config/config.js.map +0 -1
- package/lib/services/config/env.js +0 -22
- package/lib/services/config/env.js.map +0 -1
- package/lib/services/config/package-json.js +0 -9
- package/lib/services/config/package-json.js.map +0 -1
- package/lib/services/filesync/changes.js +0 -134
- package/lib/services/filesync/changes.js.map +0 -1
- package/lib/services/filesync/conflicts.js +0 -140
- package/lib/services/filesync/conflicts.js.map +0 -1
- package/lib/services/filesync/directory.js +0 -269
- package/lib/services/filesync/directory.js.map +0 -1
- package/lib/services/filesync/error.js +0 -137
- package/lib/services/filesync/error.js.map +0 -1
- package/lib/services/filesync/file.js +0 -3
- package/lib/services/filesync/file.js.map +0 -1
- package/lib/services/filesync/filesync.js +0 -791
- package/lib/services/filesync/filesync.js.map +0 -1
- package/lib/services/filesync/hashes.js +0 -172
- package/lib/services/filesync/hashes.js.map +0 -1
- package/lib/services/filesync/strategy.js +0 -59
- package/lib/services/filesync/strategy.js.map +0 -1
- package/lib/services/filesync/sync-json.js +0 -475
- package/lib/services/filesync/sync-json.js.map +0 -1
- package/lib/services/http/auth.js +0 -70
- package/lib/services/http/auth.js.map +0 -1
- package/lib/services/http/http.js +0 -136
- package/lib/services/http/http.js.map +0 -1
- package/lib/services/output/confirm.js +0 -149
- package/lib/services/output/confirm.js.map +0 -1
- package/lib/services/output/footer.js +0 -22
- package/lib/services/output/footer.js.map +0 -1
- package/lib/services/output/log/field.js +0 -3
- package/lib/services/output/log/field.js.map +0 -1
- package/lib/services/output/log/format/format.js +0 -8
- package/lib/services/output/log/format/format.js.map +0 -1
- package/lib/services/output/log/format/json.js +0 -37
- package/lib/services/output/log/format/json.js.map +0 -1
- package/lib/services/output/log/format/pretty.js +0 -158
- package/lib/services/output/log/format/pretty.js.map +0 -1
- package/lib/services/output/log/level.js +0 -41
- package/lib/services/output/log/level.js.map +0 -1
- package/lib/services/output/log/logger.js +0 -53
- package/lib/services/output/log/logger.js.map +0 -1
- package/lib/services/output/log/structured.js +0 -52
- package/lib/services/output/log/structured.js.map +0 -1
- package/lib/services/output/notify.js +0 -27
- package/lib/services/output/notify.js.map +0 -1
- package/lib/services/output/output.js +0 -197
- package/lib/services/output/output.js.map +0 -1
- package/lib/services/output/print.js +0 -31
- package/lib/services/output/print.js.map +0 -1
- package/lib/services/output/problems.js +0 -84
- package/lib/services/output/problems.js.map +0 -1
- package/lib/services/output/prompt.js +0 -185
- package/lib/services/output/prompt.js.map +0 -1
- package/lib/services/output/report.js +0 -190
- package/lib/services/output/report.js.map +0 -1
- package/lib/services/output/select.js +0 -198
- package/lib/services/output/select.js.map +0 -1
- package/lib/services/output/spinner.js +0 -141
- package/lib/services/output/spinner.js.map +0 -1
- package/lib/services/output/sprint.js +0 -44
- package/lib/services/output/sprint.js.map +0 -1
- package/lib/services/output/symbols.js +0 -23
- package/lib/services/output/symbols.js.map +0 -1
- package/lib/services/output/table.js +0 -98
- package/lib/services/output/table.js.map +0 -1
- package/lib/services/output/timestamp.js +0 -12
- package/lib/services/output/timestamp.js.map +0 -1
- package/lib/services/output/update.js +0 -99
- package/lib/services/output/update.js.map +0 -1
- package/lib/services/user/session.js +0 -54
- package/lib/services/user/session.js.map +0 -1
- package/lib/services/user/user.js +0 -76
- package/lib/services/user/user.js.map +0 -1
- package/lib/services/util/assert.js +0 -11
- package/lib/services/util/assert.js.map +0 -1
- package/lib/services/util/boolean.js +0 -15
- package/lib/services/util/boolean.js.map +0 -1
- package/lib/services/util/collection.js +0 -38
- package/lib/services/util/collection.js.map +0 -1
- package/lib/services/util/function.js +0 -153
- package/lib/services/util/function.js.map +0 -1
- package/lib/services/util/is.js +0 -97
- package/lib/services/util/is.js.map +0 -1
- package/lib/services/util/json.js +0 -33
- package/lib/services/util/json.js.map +0 -1
- package/lib/services/util/number.js +0 -27
- package/lib/services/util/number.js.map +0 -1
- package/lib/services/util/object.js +0 -104
- package/lib/services/util/object.js.map +0 -1
- package/lib/services/util/paths.js +0 -36
- package/lib/services/util/paths.js.map +0 -1
- package/lib/services/util/promise.js +0 -74
- package/lib/services/util/promise.js.map +0 -1
- package/lib/services/util/types.js +0 -5
- package/lib/services/util/types.js.map +0 -1
- package/npm-shrinkwrap.json +0 -29512
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
|
|
2
|
-
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
|
|
3
|
-
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
|
|
4
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
5
|
-
import assert from "node:assert";
|
|
6
|
-
import { unthunk } from "../../util/function.js";
|
|
7
|
-
import { Client } from "../client.js";
|
|
8
|
-
import { ClientError } from "../error.js";
|
|
9
|
-
var /**
|
|
10
|
-
* The client used to make requests to Gadget's /edit/api/graphql
|
|
11
|
-
* endpoint.
|
|
12
|
-
*/ _client = /*#__PURE__*/ new WeakMap();
|
|
13
|
-
export class Edit {
|
|
14
|
-
/**
|
|
15
|
-
* Execute a GraphQL query.
|
|
16
|
-
*
|
|
17
|
-
* @param request - The query and variables to send to the server.
|
|
18
|
-
* @param request.query - The GraphQL query to execute.
|
|
19
|
-
* @param request.variables - The variables to send to the server.
|
|
20
|
-
* @param request.http - {@linkcode HttpOptions} to pass to http.
|
|
21
|
-
* @returns The data returned by the server.
|
|
22
|
-
*/ async query({ query, variables, ...options }) {
|
|
23
|
-
const name = query.match(/query (\w+)/)?.[1];
|
|
24
|
-
assert(name, "query name not found");
|
|
25
|
-
const ctx = this.ctx.child({
|
|
26
|
-
fields: {
|
|
27
|
-
edit: {
|
|
28
|
-
query: name
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
devFields: {
|
|
32
|
-
edit: {
|
|
33
|
-
query: name,
|
|
34
|
-
variables: unthunk(variables)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
ctx.log.info("executing graphql query");
|
|
39
|
-
const response = await _class_private_field_get(this, _client).execute(ctx, {
|
|
40
|
-
operation: query,
|
|
41
|
-
variables,
|
|
42
|
-
...options,
|
|
43
|
-
http: {
|
|
44
|
-
retry: {
|
|
45
|
-
// queries _should_ be idempotent, so automatically retry them
|
|
46
|
-
methods: [
|
|
47
|
-
"POST"
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
...options.http
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
if (response.errors) {
|
|
54
|
-
throw new ClientError(query, response.errors);
|
|
55
|
-
}
|
|
56
|
-
if (!response.data) {
|
|
57
|
-
throw new ClientError(query, "Query response did not contain data");
|
|
58
|
-
}
|
|
59
|
-
return response.data;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Execute a GraphQL mutation.
|
|
63
|
-
*
|
|
64
|
-
* @param request - The query and variables to send to the server.
|
|
65
|
-
* @param request.mutation - The GraphQL mutation to execute.
|
|
66
|
-
* @param request.variables - The variables to send to the server.
|
|
67
|
-
* @param request.http - {@linkcode HttpOptions} to pass to http.
|
|
68
|
-
* @returns The data returned by the server.
|
|
69
|
-
*/ async mutate({ mutation, variables, ...options }) {
|
|
70
|
-
const name = mutation.match(/mutation (\w+)/)?.[1];
|
|
71
|
-
assert(name, "mutation name not found");
|
|
72
|
-
const ctx = this.ctx.child({
|
|
73
|
-
fields: {
|
|
74
|
-
edit: {
|
|
75
|
-
mutation: name
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
devFields: {
|
|
79
|
-
edit: {
|
|
80
|
-
mutation: name,
|
|
81
|
-
variables: unthunk(variables)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
ctx.log.info("executing graphql mutation");
|
|
86
|
-
const response = await _class_private_field_get(this, _client).execute(ctx, {
|
|
87
|
-
operation: mutation,
|
|
88
|
-
variables,
|
|
89
|
-
...options
|
|
90
|
-
});
|
|
91
|
-
if (response.errors) {
|
|
92
|
-
throw new ClientError(mutation, response.errors);
|
|
93
|
-
}
|
|
94
|
-
if (!response.data) {
|
|
95
|
-
throw new ClientError(mutation, "Mutation response did not contain data");
|
|
96
|
-
}
|
|
97
|
-
return response.data;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Subscribe to a GraphQL subscription.
|
|
101
|
-
*
|
|
102
|
-
* @param options - The query and variables to send to the server.
|
|
103
|
-
* @param options.subscription - The GraphQL subscription to subscribe to.
|
|
104
|
-
* @param options.variables - The variables to send to the server.
|
|
105
|
-
* @param options.onData - A callback that will be called when data is received from the server.
|
|
106
|
-
* @param options.onError - A callback that will be called when an error is received from the server.
|
|
107
|
-
* @param options.onComplete - A callback that will be called when the subscription ends.
|
|
108
|
-
* @returns A function to unsubscribe from the subscription.
|
|
109
|
-
*/ subscribe({ onData, ...options }) {
|
|
110
|
-
const name = options.subscription.match(/subscription (\w+)/)?.[1];
|
|
111
|
-
assert(name, "subscription name not found");
|
|
112
|
-
let ctx = this.ctx.child({
|
|
113
|
-
fields: {
|
|
114
|
-
edit: {
|
|
115
|
-
subscription: name
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
devFields: {
|
|
119
|
-
edit: {
|
|
120
|
-
subscription: name,
|
|
121
|
-
variables: unthunk(options.variables)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
const onResponse = async (response)=>{
|
|
126
|
-
if (response.errors) {
|
|
127
|
-
unsubscribe();
|
|
128
|
-
await options.onError(new ClientError(options.subscription, response.errors));
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (!response.data) {
|
|
132
|
-
unsubscribe();
|
|
133
|
-
await options.onError(new ClientError(options.subscription, "Subscription response did not contain data"));
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
await onData(response.data);
|
|
137
|
-
};
|
|
138
|
-
ctx.log.info("subscribing to graphql subscription");
|
|
139
|
-
let unsubscribe = _class_private_field_get(this, _client).subscribe(ctx, {
|
|
140
|
-
...options,
|
|
141
|
-
onResponse
|
|
142
|
-
});
|
|
143
|
-
return {
|
|
144
|
-
unsubscribe,
|
|
145
|
-
resubscribe: (variables)=>{
|
|
146
|
-
unsubscribe();
|
|
147
|
-
if (variables !== undefined) {
|
|
148
|
-
options.variables = variables;
|
|
149
|
-
}
|
|
150
|
-
ctx = this.ctx.child({
|
|
151
|
-
fields: {
|
|
152
|
-
edit: {
|
|
153
|
-
subscription: name
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
devFields: {
|
|
157
|
-
edit: {
|
|
158
|
-
subscription: name,
|
|
159
|
-
variables: unthunk(options.variables)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
ctx.log.info("re-subscribing to graphql subscription");
|
|
164
|
-
unsubscribe = _class_private_field_get(this, _client).subscribe(ctx, {
|
|
165
|
-
...options,
|
|
166
|
-
onResponse
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Close the client.
|
|
173
|
-
*/ async dispose() {
|
|
174
|
-
await _class_private_field_get(this, _client).dispose();
|
|
175
|
-
}
|
|
176
|
-
constructor(ctx){
|
|
177
|
-
/**
|
|
178
|
-
* The {@linkcode Context} that was used to create this instance.
|
|
179
|
-
*/ _define_property(this, "ctx", void 0);
|
|
180
|
-
_class_private_field_init(this, _client, {
|
|
181
|
-
writable: true,
|
|
182
|
-
value: void 0
|
|
183
|
-
});
|
|
184
|
-
this.ctx = ctx.child({
|
|
185
|
-
name: "edit"
|
|
186
|
-
});
|
|
187
|
-
_class_private_field_set(this, _client, new Client(this.ctx, "/edit/api/graphql"));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/app/edit/edit.ts"],"sourcesContent":["import type { ExecutionResult } from \"graphql-ws\";\nimport assert from \"node:assert\";\nimport type { Promisable } from \"type-fest\";\nimport type { Context } from \"../../command/context.js\";\nimport { type HttpOptions } from \"../../http/http.js\";\nimport { unthunk, type Thunk } from \"../../util/function.js\";\nimport { Client } from \"../client.js\";\nimport { ClientError } from \"../error.js\";\nimport type { GraphQLMutation, GraphQLQuery, GraphQLSubscription } from \"./operation.js\";\n\nexport class Edit {\n /**\n * The {@linkcode Context} that was used to create this instance.\n */\n readonly ctx: Context;\n\n /**\n * The client used to make requests to Gadget's /edit/api/graphql\n * endpoint.\n */\n #client: Client;\n\n constructor(ctx: Context) {\n this.ctx = ctx.child({ name: \"edit\" });\n this.#client = new Client(this.ctx, \"/edit/api/graphql\");\n }\n\n /**\n * Execute a GraphQL query.\n *\n * @param request - The query and variables to send to the server.\n * @param request.query - The GraphQL query to execute.\n * @param request.variables - The variables to send to the server.\n * @param request.http - {@linkcode HttpOptions} to pass to http.\n * @returns The data returned by the server.\n */\n async query<Query extends GraphQLQuery>({\n query,\n variables,\n ...options\n }: {\n query: Query;\n variables?: Thunk<Query[\"Variables\"]> | null;\n http?: HttpOptions;\n }): Promise<Query[\"Data\"]> {\n const name = query.match(/query (\\w+)/)?.[1];\n assert(name, \"query name not found\");\n\n const ctx = this.ctx.child({\n fields: { edit: { query: name } },\n devFields: { edit: { query: name, variables: unthunk(variables) } },\n });\n\n ctx.log.info(\"executing graphql query\");\n const response = await this.#client.execute(ctx, {\n operation: query,\n variables,\n ...options,\n http: {\n retry: {\n // queries _should_ be idempotent, so automatically retry them\n methods: [\"POST\"],\n },\n ...options.http,\n },\n });\n\n if (response.errors) {\n throw new ClientError(query, response.errors);\n }\n\n if (!response.data) {\n throw new ClientError(query, \"Query response did not contain data\");\n }\n\n return response.data;\n }\n\n /**\n * Execute a GraphQL mutation.\n *\n * @param request - The query and variables to send to the server.\n * @param request.mutation - The GraphQL mutation to execute.\n * @param request.variables - The variables to send to the server.\n * @param request.http - {@linkcode HttpOptions} to pass to http.\n * @returns The data returned by the server.\n */\n async mutate<Mutation extends GraphQLMutation>({\n mutation,\n variables,\n ...options\n }: {\n mutation: Mutation;\n variables?: Thunk<Mutation[\"Variables\"]> | null;\n http?: HttpOptions;\n }): Promise<Mutation[\"Data\"]> {\n const name = mutation.match(/mutation (\\w+)/)?.[1];\n assert(name, \"mutation name not found\");\n\n const ctx = this.ctx.child({\n fields: { edit: { mutation: name } },\n devFields: { edit: { mutation: name, variables: unthunk(variables) } },\n });\n\n ctx.log.info(\"executing graphql mutation\");\n const response = await this.#client.execute(ctx, { operation: mutation, variables, ...options });\n\n if (response.errors) {\n throw new ClientError(mutation, response.errors);\n }\n\n if (!response.data) {\n throw new ClientError(mutation, \"Mutation response did not contain data\");\n }\n\n return response.data;\n }\n\n /**\n * Subscribe to a GraphQL subscription.\n *\n * @param options - The query and variables to send to the server.\n * @param options.subscription - The GraphQL subscription to subscribe to.\n * @param options.variables - The variables to send to the server.\n * @param options.onData - A callback that will be called when data is received from the server.\n * @param options.onError - A callback that will be called when an error is received from the server.\n * @param options.onComplete - A callback that will be called when the subscription ends.\n * @returns A function to unsubscribe from the subscription.\n */\n subscribe<Subscription extends GraphQLSubscription>({\n onData,\n ...options\n }: {\n subscription: Subscription;\n variables?: Thunk<Subscription[\"Variables\"]> | null;\n onData: (data: Subscription[\"Data\"]) => Promisable<void>;\n onError: (error: ClientError) => Promisable<void>;\n onComplete?: () => Promisable<void>;\n }): EditSubscription<Subscription> {\n const name = options.subscription.match(/subscription (\\w+)/)?.[1];\n assert(name, \"subscription name not found\");\n\n let ctx = this.ctx.child({\n fields: { edit: { subscription: name } },\n devFields: { edit: { subscription: name, variables: unthunk(options.variables) } },\n });\n\n const onResponse = async (response: ExecutionResult<Subscription[\"Data\"], Subscription[\"Extensions\"]>): Promise<void> => {\n if (response.errors) {\n unsubscribe();\n await options.onError(new ClientError(options.subscription, response.errors));\n return;\n }\n\n if (!response.data) {\n unsubscribe();\n await options.onError(new ClientError(options.subscription, \"Subscription response did not contain data\"));\n return;\n }\n\n await onData(response.data);\n };\n\n ctx.log.info(\"subscribing to graphql subscription\");\n let unsubscribe = this.#client.subscribe(ctx, { ...options, onResponse });\n\n return {\n unsubscribe,\n resubscribe: (variables) => {\n unsubscribe();\n\n if (variables !== undefined) {\n options.variables = variables;\n }\n\n ctx = this.ctx.child({\n fields: { edit: { subscription: name } },\n devFields: { edit: { subscription: name, variables: unthunk(options.variables) } },\n });\n\n ctx.log.info(\"re-subscribing to graphql subscription\");\n unsubscribe = this.#client.subscribe(ctx, { ...options, onResponse });\n },\n };\n }\n\n /**\n * Close the client.\n */\n async dispose(): Promise<void> {\n await this.#client.dispose();\n }\n}\n\n/**\n * An object that can be used to unsubscribe and resubscribe to an\n * ongoing Edit GraphQL subscription.\n */\nexport type EditSubscription<Subscription extends GraphQLSubscription> = {\n /**\n * Unsubscribe from the subscription.\n */\n unsubscribe(): void;\n\n /**\n * Resubscribe to the subscription.\n */\n resubscribe(variables?: Thunk<Subscription[\"Variables\"]> | null): void;\n};\n"],"names":["assert","unthunk","Client","ClientError","Edit","query","variables","options","name","match","ctx","child","fields","edit","devFields","log","info","response","client","execute","operation","http","retry","methods","errors","data","mutate","mutation","subscribe","onData","subscription","onResponse","unsubscribe","onError","resubscribe","undefined","dispose","constructor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;AACA,OAAOA,YAAY,cAAc;AAIjC,SAASC,OAAO,QAAoB,yBAAyB;AAC7D,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,WAAW,QAAQ,cAAc;IASxC;;;GAGC,GACD;AAVF,OAAO,MAAMC;IAiBX;;;;;;;;GAQC,GACD,MAAMC,MAAkC,EACtCA,KAAK,EACLC,SAAS,EACT,GAAGC,SAKJ,EAA0B;QACzB,MAAMC,OAAOH,MAAMI,KAAK,CAAC,gBAAgB,CAAC,EAAE;QAC5CT,OAAOQ,MAAM;QAEb,MAAME,MAAM,IAAI,CAACA,GAA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AM;4BAAEiB,cAActB;4BAAMF,WAAWL,QAAQM,QAAQD,SAAS;wBAAE;oBAAE;gBACnF;gBAEAI,IAAIK,GAAG,CAACC,IAAI,CAAC;gBACbgB,cAAc,yBAAA,IAAI,EAAEd,SAAOU,SAAS,CAAClB,KAAK;oBAAE,GAAGH,OAAO;oBAAEwB;gBAAW;YACrE;QACF;IACF;IAEA;;GAEC,GACD,MAAMK,UAAyB;QAC7B,MAAM,yBAAA,IAAI,EAAElB,SAAOkB,OAAO;IAC5B;IAzKAC,YAAY3B,GAAY,CAAE;QAX1B;;GAEC,GACD,uBAASA,OAAT,KAAA;QAMA,gCAAA;;mBAAA,KAAA;;QAGE,IAAI,CAACA,GAAG,GAAGA,IAAIC,KAAK,CAAC;YAAEH,MAAM;QAAO;uCAC9BU,SAAS,IAAIhB,OAAO,IAAI,CAACQ,GAAG,EAAE;IACtC;AAuKF"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { sprint } from "../../output/sprint.js";
|
|
2
|
-
export const REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION = sprint(/* GraphQL */ `
|
|
3
|
-
subscription RemoteFileSyncEvents($localFilesVersion: String!) {
|
|
4
|
-
remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {
|
|
5
|
-
remoteFilesVersion
|
|
6
|
-
changed {
|
|
7
|
-
path
|
|
8
|
-
mode
|
|
9
|
-
content
|
|
10
|
-
encoding
|
|
11
|
-
}
|
|
12
|
-
deleted {
|
|
13
|
-
path
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`);
|
|
18
|
-
export const REMOTE_FILES_VERSION_QUERY = sprint(/* GraphQL */ `
|
|
19
|
-
query RemoteFilesVersion {
|
|
20
|
-
remoteFilesVersion
|
|
21
|
-
}
|
|
22
|
-
`);
|
|
23
|
-
export const PUBLISH_FILE_SYNC_EVENTS_MUTATION = sprint(/* GraphQL */ `
|
|
24
|
-
mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
|
|
25
|
-
publishFileSyncEvents(input: $input) {
|
|
26
|
-
remoteFilesVersion
|
|
27
|
-
problems {
|
|
28
|
-
level
|
|
29
|
-
message
|
|
30
|
-
path
|
|
31
|
-
type
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`);
|
|
36
|
-
export const FILE_SYNC_FILES_QUERY = sprint(/* GraphQL */ `
|
|
37
|
-
query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {
|
|
38
|
-
fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {
|
|
39
|
-
filesVersion
|
|
40
|
-
files {
|
|
41
|
-
path
|
|
42
|
-
mode
|
|
43
|
-
content
|
|
44
|
-
encoding
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`);
|
|
49
|
-
export const FILE_SYNC_HASHES_QUERY = sprint(/* GraphQL */ `
|
|
50
|
-
query FileSyncHashes($filesVersion: String) {
|
|
51
|
-
fileSyncHashes(filesVersion: $filesVersion) {
|
|
52
|
-
filesVersion
|
|
53
|
-
hashes
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
`);
|
|
57
|
-
export const FILE_SYNC_COMPARISON_HASHES_QUERY = sprint(/* GraphQL */ `
|
|
58
|
-
query FileSyncComparisonHashes($filesVersion: String!) {
|
|
59
|
-
fileSyncComparisonHashes(filesVersion: $filesVersion) {
|
|
60
|
-
filesVersionHashes {
|
|
61
|
-
filesVersion
|
|
62
|
-
hashes
|
|
63
|
-
}
|
|
64
|
-
latestFilesVersionHashes {
|
|
65
|
-
filesVersion
|
|
66
|
-
hashes
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
`);
|
|
71
|
-
export const PUBLISH_STATUS_SUBSCRIPTION = sprint(/* GraphQL */ `
|
|
72
|
-
subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean) {
|
|
73
|
-
publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges) {
|
|
74
|
-
publishStarted
|
|
75
|
-
remoteFilesVersion
|
|
76
|
-
progress
|
|
77
|
-
issues {
|
|
78
|
-
severity
|
|
79
|
-
message
|
|
80
|
-
node {
|
|
81
|
-
type
|
|
82
|
-
key
|
|
83
|
-
apiIdentifier
|
|
84
|
-
name
|
|
85
|
-
fieldType
|
|
86
|
-
parentKey
|
|
87
|
-
parentApiIdentifier
|
|
88
|
-
}
|
|
89
|
-
nodeLabels {
|
|
90
|
-
type
|
|
91
|
-
identifier
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
status {
|
|
95
|
-
code
|
|
96
|
-
message
|
|
97
|
-
output
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`);
|
|
102
|
-
export const CREATE_MODEL_MUTATION = sprint(/* GraphQL */ `
|
|
103
|
-
mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {
|
|
104
|
-
createModel(path: $path, fields: $fields) {
|
|
105
|
-
remoteFilesVersion
|
|
106
|
-
changed {
|
|
107
|
-
path
|
|
108
|
-
mode
|
|
109
|
-
content
|
|
110
|
-
encoding
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
`);
|
|
115
|
-
export const CREATE_ACTION_MUTATION = sprint(/* GraphQL */ `
|
|
116
|
-
mutation createAction($path: String!) {
|
|
117
|
-
createAction(path: $path) {
|
|
118
|
-
remoteFilesVersion
|
|
119
|
-
changed {
|
|
120
|
-
path
|
|
121
|
-
mode
|
|
122
|
-
content
|
|
123
|
-
encoding
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
`);
|
|
128
|
-
export const CREATE_ROUTE_MUTATION = sprint(/* GraphQL */ `
|
|
129
|
-
mutation createRoute($method: String!, $path: String!) {
|
|
130
|
-
createRoute(method: $method, path: $path) {
|
|
131
|
-
remoteFilesVersion
|
|
132
|
-
changed {
|
|
133
|
-
path
|
|
134
|
-
mode
|
|
135
|
-
content
|
|
136
|
-
encoding
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
`);
|
|
141
|
-
export const CREATE_MODEL_FIELDS_MUTATION = sprint(/* GraphQL */ `
|
|
142
|
-
mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {
|
|
143
|
-
createModelFields(path: $path, fields: $fields) {
|
|
144
|
-
remoteFilesVersion
|
|
145
|
-
changed {
|
|
146
|
-
path
|
|
147
|
-
mode
|
|
148
|
-
content
|
|
149
|
-
encoding
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
`);
|
|
154
|
-
|
|
155
|
-
//# sourceMappingURL=operation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/app/edit/operation.ts"],"sourcesContent":["import type { ExecutionResult } from \"graphql-ws\";\nimport type { JsonObject } from \"type-fest\";\nimport type {\n CreateActionMutation,\n CreateActionMutationVariables,\n CreateModelFieldsMutation,\n CreateModelMutation,\n CreateModelMutationVariables,\n CreateRouteMutation,\n CreateRouteMutationVariables,\n FileSyncComparisonHashesQuery,\n FileSyncComparisonHashesQueryVariables,\n FileSyncFilesQuery,\n FileSyncFilesQueryVariables,\n FileSyncHashesQuery,\n FileSyncHashesQueryVariables,\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables,\n PublishStatusSubscription,\n PublishStatusSubscriptionVariables,\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables,\n RemoteFilesVersionQuery,\n RemoteFilesVersionQueryVariables,\n} from \"../../../__generated__/graphql.js\";\nimport { sprint } from \"../../output/sprint.js\";\n\n/**\n * A GraphQL query with its associated types.\n *\n * At runtime, this is just a string.\n */\nexport type GraphQLQuery<\n Data extends JsonObject = JsonObject,\n Variables extends JsonObject = JsonObject,\n Extensions extends JsonObject = JsonObject,\n Response extends ExecutionResult<Data, Extensions> = ExecutionResult<Data, Extensions>,\n> = string & {\n type: \"query\";\n Data: Data;\n Variables: Variables;\n Extensions: Extensions;\n Response: Response;\n};\n\n/**\n * A GraphQL mutation with its associated types.\n *\n * At runtime, this is just a string.\n */\nexport type GraphQLMutation<\n Data extends JsonObject = JsonObject,\n Variables extends JsonObject = JsonObject,\n Extensions extends JsonObject = JsonObject,\n Response extends ExecutionResult<Data, Extensions> = ExecutionResult<Data, Extensions>,\n> = string & {\n type: \"mutation\";\n Data: Data;\n Variables: Variables;\n Extensions: Extensions;\n Response: Response;\n};\n\n/**\n * A GraphQL subscription with its associated types.\n *\n * At runtime, this is just a string.\n */\nexport type GraphQLSubscription<\n Data extends JsonObject = JsonObject,\n Variables extends JsonObject = JsonObject,\n Extensions extends JsonObject = JsonObject,\n Response extends ExecutionResult<Data, Extensions> = ExecutionResult<Data, Extensions>,\n> = string & {\n type: \"subscription\";\n Data: Data;\n Variables: Variables;\n Extensions: Extensions;\n Response: Response;\n};\n\nexport const REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION = sprint(/* GraphQL */ `\n subscription RemoteFileSyncEvents($localFilesVersion: String!) {\n remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\n }\n deleted {\n path\n }\n }\n }\n`) as GraphQLSubscription<RemoteFileSyncEventsSubscription, RemoteFileSyncEventsSubscriptionVariables>;\n\nexport type REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION = typeof REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION;\n\nexport const REMOTE_FILES_VERSION_QUERY = sprint(/* GraphQL */ `\n query RemoteFilesVersion {\n remoteFilesVersion\n }\n`) as GraphQLQuery<RemoteFilesVersionQuery, RemoteFilesVersionQueryVariables>;\n\nexport type REMOTE_FILES_VERSION_QUERY = typeof REMOTE_FILES_VERSION_QUERY;\n\nexport const PUBLISH_FILE_SYNC_EVENTS_MUTATION = sprint(/* GraphQL */ `\n mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {\n publishFileSyncEvents(input: $input) {\n remoteFilesVersion\n problems {\n level\n message\n path\n type\n }\n }\n }\n`) as GraphQLMutation<PublishFileSyncEventsMutation, PublishFileSyncEventsMutationVariables>;\n\nexport type PUBLISH_FILE_SYNC_EVENTS_MUTATION = typeof PUBLISH_FILE_SYNC_EVENTS_MUTATION;\n\nexport const FILE_SYNC_FILES_QUERY = sprint(/* GraphQL */ `\n query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {\n fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {\n filesVersion\n files {\n path\n mode\n content\n encoding\n }\n }\n }\n`) as GraphQLQuery<FileSyncFilesQuery, FileSyncFilesQueryVariables>;\n\nexport type FILE_SYNC_FILES_QUERY = typeof FILE_SYNC_FILES_QUERY;\n\nexport const FILE_SYNC_HASHES_QUERY = sprint(/* GraphQL */ `\n query FileSyncHashes($filesVersion: String) {\n fileSyncHashes(filesVersion: $filesVersion) {\n filesVersion\n hashes\n }\n }\n`) as GraphQLQuery<FileSyncHashesQuery, FileSyncHashesQueryVariables>;\n\nexport type FILE_SYNC_HASHES_QUERY = typeof FILE_SYNC_HASHES_QUERY;\n\nexport const FILE_SYNC_COMPARISON_HASHES_QUERY = sprint(/* GraphQL */ `\n query FileSyncComparisonHashes($filesVersion: String!) {\n fileSyncComparisonHashes(filesVersion: $filesVersion) {\n filesVersionHashes {\n filesVersion\n hashes\n }\n latestFilesVersionHashes {\n filesVersion\n hashes\n }\n }\n }\n`) as GraphQLQuery<FileSyncComparisonHashesQuery, FileSyncComparisonHashesQueryVariables>;\n\nexport type FILE_SYNC_COMPARISON_HASHES_QUERY = typeof FILE_SYNC_COMPARISON_HASHES_QUERY;\n\nexport const PUBLISH_STATUS_SUBSCRIPTION = sprint(/* GraphQL */ `\n subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean) {\n publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges) {\n publishStarted\n remoteFilesVersion\n progress\n issues {\n severity\n message\n node {\n type\n key\n apiIdentifier\n name\n fieldType\n parentKey\n parentApiIdentifier\n }\n nodeLabels {\n type\n identifier\n }\n }\n status {\n code\n message\n output\n }\n }\n }\n`) as GraphQLSubscription<PublishStatusSubscription, PublishStatusSubscriptionVariables>;\n\nexport type PUBLISH_STATUS_SUBSCRIPTION = typeof PUBLISH_STATUS_SUBSCRIPTION;\n\nexport const CREATE_MODEL_MUTATION = sprint(/* GraphQL */ `\n mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {\n createModel(path: $path, fields: $fields) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\n }\n }\n }\n`) as GraphQLMutation<CreateModelMutation, CreateModelMutationVariables>;\n\nexport type CREATE_MODEL_MUTATION = typeof CREATE_MODEL_MUTATION;\n\nexport const CREATE_ACTION_MUTATION = sprint(/* GraphQL */ `\n mutation createAction($path: String!) {\n createAction(path: $path) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\n }\n }\n }\n`) as GraphQLMutation<CreateActionMutation, CreateActionMutationVariables>;\n\nexport type CREATE_ACTION_MUTATION = typeof CREATE_ACTION_MUTATION;\n\nexport const CREATE_ROUTE_MUTATION = sprint(/* GraphQL */ `\n mutation createRoute($method: String!, $path: String!) {\n createRoute(method: $method, path: $path) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\n }\n }\n }\n`) as GraphQLMutation<CreateRouteMutation, CreateRouteMutationVariables>;\n\nexport type CREATE_ROUTE_MUTATION = typeof CREATE_ROUTE_MUTATION;\n\nexport const CREATE_MODEL_FIELDS_MUTATION = sprint(/* GraphQL */ `\n mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {\n createModelFields(path: $path, fields: $fields) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\n }\n }\n }\n`) as GraphQLMutation<CreateModelFieldsMutation, CreateModelMutationVariables>;\n\nexport type CREATE_MODEL_FIELDS_MUTATION = typeof CREATE_MODEL_FIELDS_MUTATION;\n"],"names":["sprint","REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION","REMOTE_FILES_VERSION_QUERY","PUBLISH_FILE_SYNC_EVENTS_MUTATION","FILE_SYNC_FILES_QUERY","FILE_SYNC_HASHES_QUERY","FILE_SYNC_COMPARISON_HASHES_QUERY","PUBLISH_STATUS_SUBSCRIPTION","CREATE_MODEL_MUTATION","CREATE_ACTION_MUTATION","CREATE_ROUTE_MUTATION","CREATE_MODEL_FIELDS_MUTATION"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAyBA,SAASA,MAAM,QAAQ,yBAAyB;AAwDhD,OAAO,MAAMC,uCAAuCD,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;;;;AAe1E,CAAC,EAAsG;AAIvG,OAAO,MAAME,6BAA6BF,OAAO,WAAW,GAAG,CAAC;;;;AAIhE,CAAC,EAA6E;AAI9E,OAAO,MAAMG,oCAAoCH,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAYvE,CAAC,EAA4F;AAI7F,OAAO,MAAMI,wBAAwBJ,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAY3D,CAAC,EAAmE;AAIpE,OAAO,MAAMK,yBAAyBL,OAAO,WAAW,GAAG,CAAC;;;;;;;AAO5D,CAAC,EAAqE;AAItE,OAAO,MAAMM,oCAAoCN,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;;AAavE,CAAC,EAAyF;AAI1F,OAAO,MAAMO,8BAA8BP,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BjE,CAAC,EAAwF;AAIzF,OAAO,MAAMQ,wBAAwBR,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAY3D,CAAC,EAAwE;AAIzE,OAAO,MAAMS,yBAAyBT,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAY5D,CAAC,EAA0E;AAI3E,OAAO,MAAMU,wBAAwBV,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAY3D,CAAC,EAAwE;AAIzE,OAAO,MAAMW,+BAA+BX,OAAO,WAAW,GAAG,CAAC;;;;;;;;;;;;AAYlE,CAAC,EAA8E"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import assert from "node:assert";
|
|
3
|
-
import pluralize from "pluralize";
|
|
4
|
-
import { GGTError, IsBug } from "../output/report.js";
|
|
5
|
-
import { sprint } from "../output/sprint.js";
|
|
6
|
-
import { uniq } from "../util/collection.js";
|
|
7
|
-
import { isCloseEvent, isError, isErrorEvent, isGraphQLErrors, isString } from "../util/is.js";
|
|
8
|
-
import { serializeError } from "../util/object.js";
|
|
9
|
-
export class ClientError extends GGTError {
|
|
10
|
-
render() {
|
|
11
|
-
let body = "";
|
|
12
|
-
switch(true){
|
|
13
|
-
case isGraphQLErrors(this.cause):
|
|
14
|
-
{
|
|
15
|
-
const errors = uniq(this.cause.map((x)=>x.message));
|
|
16
|
-
body = sprint`
|
|
17
|
-
Gadget responded with the following ${pluralize("error", errors.length, false)}:
|
|
18
|
-
|
|
19
|
-
• ${errors.join("\n • ")}
|
|
20
|
-
`;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
case isCloseEvent(this.cause):
|
|
24
|
-
body = "The connection to Gadget closed unexpectedly.";
|
|
25
|
-
break;
|
|
26
|
-
case isErrorEvent(this.cause) || isError(this.cause):
|
|
27
|
-
body = this.cause.message;
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
body = this.cause;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
return this.message + "\n\n" + body;
|
|
34
|
-
}
|
|
35
|
-
constructor(request, cause){
|
|
36
|
-
super("An error occurred while communicating with Gadget");
|
|
37
|
-
_define_property(this, "request", void 0);
|
|
38
|
-
_define_property(this, "isBug", void 0);
|
|
39
|
-
_define_property(this, "cause", void 0);
|
|
40
|
-
this.request = request;
|
|
41
|
-
this.isBug = IsBug.MAYBE;
|
|
42
|
-
// ErrorEvent and CloseEvent aren't serializable, so we reconstruct
|
|
43
|
-
// them into an object. We discard the `target` property because
|
|
44
|
-
// it's large and not that useful
|
|
45
|
-
if (isErrorEvent(cause)) {
|
|
46
|
-
this.cause = {
|
|
47
|
-
type: cause.type,
|
|
48
|
-
message: cause.message,
|
|
49
|
-
error: serializeError(cause.error)
|
|
50
|
-
};
|
|
51
|
-
} else if (isCloseEvent(cause)) {
|
|
52
|
-
this.cause = {
|
|
53
|
-
type: cause.type,
|
|
54
|
-
code: cause.code,
|
|
55
|
-
reason: cause.reason,
|
|
56
|
-
wasClean: cause.wasClean
|
|
57
|
-
};
|
|
58
|
-
} else {
|
|
59
|
-
assert(isString(cause) || isError(cause) || isGraphQLErrors(cause), "cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent");
|
|
60
|
-
this.cause = cause;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/app/error.ts"],"sourcesContent":["import type { GraphQLError } from \"graphql\";\nimport assert from \"node:assert\";\nimport pluralize from \"pluralize\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport { GGTError, IsBug } from \"../output/report.js\";\nimport { sprint } from \"../output/sprint.js\";\nimport { uniq } from \"../util/collection.js\";\nimport { isCloseEvent, isError, isErrorEvent, isGraphQLErrors, isString } from \"../util/is.js\";\nimport { serializeError } from \"../util/object.js\";\nimport type { GraphQLMutation, GraphQLQuery, GraphQLSubscription } from \"./edit/operation.js\";\n\nexport class ClientError extends GGTError {\n isBug = IsBug.MAYBE;\n\n override cause: string | Error | readonly GraphQLError[] | CloseEvent | ErrorEvent;\n\n constructor(\n readonly request: GraphQLQuery | GraphQLMutation | GraphQLSubscription,\n cause: unknown,\n ) {\n super(\"An error occurred while communicating with Gadget\");\n\n // ErrorEvent and CloseEvent aren't serializable, so we reconstruct\n // them into an object. We discard the `target` property because\n // it's large and not that useful\n if (isErrorEvent(cause)) {\n this.cause = {\n type: cause.type,\n message: cause.message,\n error: serializeError(cause.error),\n } as ErrorEvent;\n } else if (isCloseEvent(cause)) {\n this.cause = {\n type: cause.type,\n code: cause.code,\n reason: cause.reason,\n wasClean: cause.wasClean,\n } as CloseEvent;\n } else {\n assert(\n isString(cause) || isError(cause) || isGraphQLErrors(cause),\n \"cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent\",\n );\n this.cause = cause;\n }\n }\n\n override render(): string {\n let body = \"\";\n\n switch (true) {\n case isGraphQLErrors(this.cause): {\n const errors = uniq(this.cause.map((x) => x.message));\n body = sprint`\n Gadget responded with the following ${pluralize(\"error\", errors.length, false)}:\n\n • ${errors.join(\"\\n • \")}\n `;\n break;\n }\n case isCloseEvent(this.cause):\n body = \"The connection to Gadget closed unexpectedly.\";\n break;\n case isErrorEvent(this.cause) || isError(this.cause):\n body = this.cause.message;\n break;\n default:\n body = this.cause;\n break;\n }\n\n return this.message + \"\\n\\n\" + body;\n }\n}\n"],"names":["assert","pluralize","GGTError","IsBug","sprint","uniq","isCloseEvent","isError","isErrorEvent","isGraphQLErrors","isString","serializeError","ClientError","render","body","cause","errors","map","x","message","length","join","constructor","request","isBug","MAYBE","type","error","code","reason","wasClean"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,OAAOA,YAAY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;gBACtBQ,OAAOhB,eAAeI,MAAMY,KAAK;YACnC;QACF,OAAO,IAAIrB,aAAaS,QAAQ;YAC9B,IAAI,CAACA,KAAK,GAAG;gBACXW,MAAMX,MAAMW,IAAI;gBAChBE,MAAMb,MAAMa,IAAI;gBAChBC,QAAQd,MAAMc,MAAM;gBACpBC,UAAUf,MAAMe,QAAQ;YAC1B;QACF,OAAO;YACL9B,OACEU,SAASK,UAAUR,QAAQQ,UAAUN,gBAAgBM,QACrD;YAEF,IAAI,CAACA,KAAK,GAAGA;QACf;IACF;AA4BF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import arg from "arg";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { GGTError, IsBug, UnexpectedError } from "../output/report.js";
|
|
5
|
-
import { symbol } from "../output/symbols.js";
|
|
6
|
-
import { isNil } from "../util/is.js";
|
|
7
|
-
export const parseArgs = (args, options)=>{
|
|
8
|
-
const spec = {};
|
|
9
|
-
const defaultValues = {};
|
|
10
|
-
for (const [key, value] of Object.entries(args)){
|
|
11
|
-
if (!("type" in value)) {
|
|
12
|
-
spec[key] = value;
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
spec[key] = value.type;
|
|
16
|
-
defaultValues[key] = value.default;
|
|
17
|
-
if (value.alias) {
|
|
18
|
-
for (const alias of Array.isArray(value.alias) ? value.alias : [
|
|
19
|
-
value.alias
|
|
20
|
-
]){
|
|
21
|
-
spec[alias] = key;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const parsed = arg(spec, options);
|
|
27
|
-
for (const [key, value] of Object.entries(defaultValues)){
|
|
28
|
-
if (isNil(parsed[key])) {
|
|
29
|
-
parsed[key] = value;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return parsed;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (error instanceof arg.ArgError) {
|
|
35
|
-
// convert arg.ArgError to GGTError
|
|
36
|
-
// eslint-disable-next-line no-ex-assign
|
|
37
|
-
error = new ArgError(error.message);
|
|
38
|
-
}
|
|
39
|
-
if (error instanceof GGTError) {
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
throw new UnexpectedError(error);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
export class ArgError extends GGTError {
|
|
46
|
-
render() {
|
|
47
|
-
return `${chalk.redBright(symbol.cross)} ` + this.message;
|
|
48
|
-
}
|
|
49
|
-
constructor(...args){
|
|
50
|
-
super(...args);
|
|
51
|
-
_define_property(this, "isBug", IsBug.NO);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=arg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/command/arg.ts"],"sourcesContent":["import arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { Simplify } from \"type-fest\";\nimport { GGTError, IsBug, UnexpectedError } from \"../output/report.js\";\nimport { symbol } from \"../output/symbols.js\";\nimport { isNil } from \"../util/is.js\";\n\nexport type ArgsDefinition = Record<string, ArgDefinition>;\n\ntype ArgDefinition<Handler extends arg.Handler = arg.Handler> =\n | Handler\n | {\n type: Handler;\n alias?: string | string[];\n default?: ReturnType<Handler>;\n };\n\nexport type ParseArgsOptions = {\n /**\n * A list of arguments to parse.\n */\n argv?: string[];\n\n /**\n * When permissive set to `true`, arg will push any unknown arguments\n * onto the \"extra\" argument array (`ctx.args._`) instead of throwing\n * an error about an unknown flag.\n *\n * @default false\n */\n permissive?: boolean;\n\n /**\n * When stopAtPositional is set to true, context will stop parsing at\n * the first positional argument.\n *\n * @default false\n */\n stopAtPositional?: boolean;\n};\n\nexport const parseArgs = <Args extends ArgsDefinition>(args: Args, options?: arg.Options): ArgsDefinitionResult<Args> => {\n const spec: arg.Spec = {};\n const defaultValues: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (!(\"type\" in value)) {\n spec[key] = value;\n continue;\n }\n\n spec[key] = value.type;\n defaultValues[key] = value.default;\n\n if (value.alias) {\n for (const alias of Array.isArray(value.alias) ? value.alias : [value.alias]) {\n spec[alias] = key;\n }\n }\n }\n\n try {\n const parsed = arg(spec, options);\n for (const [key, value] of Object.entries(defaultValues)) {\n if (isNil(parsed[key])) {\n parsed[key] = value as never;\n }\n }\n return parsed as ArgsDefinitionResult<Args>;\n } catch (error: unknown) {\n if (error instanceof arg.ArgError) {\n // convert arg.ArgError to GGTError\n // eslint-disable-next-line no-ex-assign\n error = new ArgError(error.message);\n }\n if (error instanceof GGTError) {\n throw error;\n }\n throw new UnexpectedError(error);\n }\n};\n\nexport class ArgError extends GGTError {\n isBug = IsBug.NO;\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} ` + this.message;\n }\n}\n\n/**\n * Turns this:\n * ```ts\n * type Args = {\n * \"--string\": { type: String; alias: \"s\" };\n * \"--number\": { type: Number; default: 42 };\n * };\n * ```\n *\n * Into this:\n * ```ts\n * type Result = {\n * \"--string\": string | undefined;\n * \"--number\": number;\n * };\n * ```\n */\nexport type ArgsDefinitionResult<Args extends ArgsDefinition, Keys extends keyof Args = keyof Args> = Simplify<{\n [Key in Keys]: Args[Key] extends ArgDefinition<infer Handler>\n ? Args[Key] extends { default: unknown }\n ? NonNullable<ReturnType<Handler>>\n : ReturnType<Handler> | undefined\n : never;\n}> & { _: string[] };\n"],"names":["arg","chalk","GGTError","IsBug","UnexpectedError","symbol","isNil","parseArgs","args","options","spec","defaultValues","key","value","Object","entries","type","default","alias","Array","isArray","parsed","error","ArgError","message","render","redBright","cross","isBug","NO"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAAS,MAAM;AACtB,OAAOC,WAAW,QAAQ;AAE1B,SAASC,QAAQ,EAAEC,KAAK,EAAEC,e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IAAI,CAACH,OAAO;IAC3D;;;QAJAI,uBAAAA,SAAQzB,MAAM0B,EAAE;;AAKlB"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { config } from "../config/config.js";
|
|
4
|
-
import { relativeToThisFile } from "../util/paths.js";
|
|
5
|
-
/**
|
|
6
|
-
* The list of available commands.
|
|
7
|
-
*
|
|
8
|
-
* 1. Every command corresponds to a file inside of src/commands/
|
|
9
|
-
* 2. The order determines the order of commands in the README
|
|
10
|
-
*/ export const Commands = [
|
|
11
|
-
"dev",
|
|
12
|
-
"deploy",
|
|
13
|
-
"status",
|
|
14
|
-
"push",
|
|
15
|
-
"pull",
|
|
16
|
-
"add",
|
|
17
|
-
"open",
|
|
18
|
-
"list",
|
|
19
|
-
"login",
|
|
20
|
-
"logout",
|
|
21
|
-
"whoami",
|
|
22
|
-
"version"
|
|
23
|
-
];
|
|
24
|
-
/**
|
|
25
|
-
* Checks if a string is a valid command.
|
|
26
|
-
*
|
|
27
|
-
* @param command - The string to check
|
|
28
|
-
* @returns Whether the string is a valid command
|
|
29
|
-
*/ export const isAvailableCommand = (command)=>{
|
|
30
|
-
return Commands.includes(command);
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Imports a command module.
|
|
34
|
-
*
|
|
35
|
-
* @param cmd - The command to import
|
|
36
|
-
* @see {@linkcode CommandModule}
|
|
37
|
-
*/ export const importCommand = async (cmd)=>{
|
|
38
|
-
assert(isAvailableCommand(cmd), `invalid command: ${cmd}`);
|
|
39
|
-
let commandPath = relativeToThisFile(`../../commands/${cmd}.js`);
|
|
40
|
-
if (config.windows) {
|
|
41
|
-
// https://github.com/nodejs/node/issues/31710
|
|
42
|
-
commandPath = pathToFileURL(commandPath).toString();
|
|
43
|
-
}
|
|
44
|
-
return await import(commandPath);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/command/command.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport { pathToFileURL } from \"node:url\";\nimport type { EmptyObject, Promisable } from \"type-fest\";\nimport type { RootArgs } from \"../../commands/root.js\";\nimport { config } from \"../config/config.js\";\nimport { relativeToThisFile } from \"../util/paths.js\";\nimport type { ArgsDefinition } from \"./arg.js\";\nimport type { Context } from \"./context.js\";\n\n/**\n * The list of available commands.\n *\n * 1. Every command corresponds to a file inside of src/commands/\n * 2. The order determines the order of commands in the README\n */\nexport const Commands = [\"dev\", \"deploy\", \"status\", \"push\", \"pull\", \"add\", \"open\", \"list\", \"login\", \"logout\", \"whoami\", \"version\"] as const;\n\n/**\n * One of the commands in {@link Commands}.\n */\nexport type AvailableCommand = (typeof Commands)[number];\n\n/**\n * Checks if a string is a valid command.\n *\n * @param command - The string to check\n * @returns Whether the string is a valid command\n */\nexport const isAvailableCommand = (command: string): command is AvailableCommand => {\n return Commands.includes(command as AvailableCommand);\n};\n\n/**\n * A command module is a file in the src/commands/ directory.\n */\nexport type CommandModule<Args extends ArgsDefinition = EmptyObject, ParentArgs extends ArgsDefinition = RootArgs> = {\n /**\n * The command's {@link ArgsDefinition args}.\n */\n args?: Args;\n\n /**\n * The command's {@link Usage usage}.\n */\n usage: Usage;\n\n /**\n * The command's {@link Command command}.\n *\n * TODO: rename this to `run`.\n */\n command: Command<Args, ParentArgs>;\n};\n\n/**\n * A {@linkcode Command command}'s usage is a function that returns a\n * string describing how to use the command. The function receives its\n * parent command's context.\n */\nexport type Usage = (ctx: Context) => string;\n\n/**\n * The function that is run when the command is called.\n *\n * @param ctx - A {@linkcode Context} with the command's {@linkcode Args} and {@linkcode ParentArgs}.\n */\nexport type Command<Args extends ArgsDefinition = EmptyObject, ParentArgs extends ArgsDefinition = RootArgs> = (\n ctx: Context<Args, ParentArgs>,\n) => Promisable<void>;\n\n/**\n * Imports a command module.\n *\n * @param cmd - The command to import\n * @see {@linkcode CommandModule}\n */\nexport const importCommand = async (cmd: AvailableCommand): Promise<CommandModule> => {\n assert(isAvailableCommand(cmd), `invalid command: ${cmd}`);\n let commandPath = relativeToThisFile(`../../commands/${cmd}.js`);\n if (config.windows) {\n // https://github.com/nodejs/node/issues/31710\n commandPath = pathToFileURL(commandPath).toString();\n }\n return (await import(commandPath)) as CommandModule;\n};\n"],"names":["assert","pathToFileURL","config","relativeToThisFile","Commands","isAvailableCommand","command","includes","importCommand","cmd","commandPath","windows","toString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,cAAc;AACjC,SAASC,aAAa,QAAQ,WAAW;AAGzC,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,kBAAkB,QAAQ,mBAAmB;AAItD;;;;;CAKC,GACD,OAAO,MAAMC,WAAW;IAAC;IAAO;IAAU;IAAU;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;IAAS;IAAU;IAAU;CAAU,CAAU;AAO5I;;;;;CAKC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,OAAOF,SAASG,QAAQ,CAACD;AAC3B,EAAE;AAwCF;;;;;CAKC,GACD,OAAO,MAAME,gBAAgB,OAAOC;IAClCT,OAAOK,mBAAmBI,MAAM,CAAC,iBAAiB,EAAEA,IAAI,CAAC;IACzD,IAAIC,cAAcP,mBAAmB,CAAC,eAAe,EAAEM,IAAI,GAAG,CAAC;IAC/D,IAAIP,OAAOS,OAAO,EAAE;QAClB,8CAA8C;QAC9CD,cAAcT,cAAcS,aAAaE,QAAQ;IACnD;IACA,OAAQ,MAAM,MAAM,CAACF;AACvB,EAAE"}
|