@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.
Files changed (220) hide show
  1. package/dist/add-4ME2KTJQ.js +84 -0
  2. package/dist/add-4ME2KTJQ.js.map +7 -0
  3. package/dist/build-4BGA4IZE.js +3 -0
  4. package/dist/build-4BGA4IZE.js.map +7 -0
  5. package/dist/chunk-57XALM2W.js +2 -0
  6. package/dist/chunk-57XALM2W.js.map +7 -0
  7. package/dist/chunk-5DLLJX5F.js +11 -0
  8. package/dist/chunk-5DLLJX5F.js.map +7 -0
  9. package/dist/chunk-5WC5D4WL.js +2 -0
  10. package/dist/chunk-5WC5D4WL.js.map +7 -0
  11. package/dist/chunk-BSCZOMV4.js +2 -0
  12. package/dist/chunk-BSCZOMV4.js.map +7 -0
  13. package/dist/chunk-BZY2AIPV.js +57 -0
  14. package/dist/chunk-BZY2AIPV.js.map +7 -0
  15. package/dist/chunk-D2K5XPNJ.js +2 -0
  16. package/dist/chunk-D2K5XPNJ.js.map +7 -0
  17. package/dist/chunk-F3EZ4KS3.js +2 -0
  18. package/dist/chunk-F3EZ4KS3.js.map +7 -0
  19. package/dist/chunk-G3VNV5Z6.js +33 -0
  20. package/dist/chunk-G3VNV5Z6.js.map +7 -0
  21. package/dist/chunk-GA7AL463.js +24 -0
  22. package/dist/chunk-GA7AL463.js.map +7 -0
  23. package/dist/chunk-GOBNB5VT.js +2 -0
  24. package/dist/chunk-GOBNB5VT.js.map +7 -0
  25. package/dist/chunk-HKBXEZNF.js +2 -0
  26. package/dist/chunk-HKBXEZNF.js.map +7 -0
  27. package/{lib/commands/push.js → dist/chunk-IKJVXTZK.js} +7 -48
  28. package/dist/chunk-IKJVXTZK.js.map +7 -0
  29. package/dist/chunk-KGSSHEEC.js +17 -0
  30. package/dist/chunk-KGSSHEEC.js.map +7 -0
  31. package/dist/chunk-KXK37C5D.js +183 -0
  32. package/dist/chunk-KXK37C5D.js.map +7 -0
  33. package/dist/chunk-NJIDVM2C.js +27 -0
  34. package/dist/chunk-NJIDVM2C.js.map +7 -0
  35. package/dist/chunk-Q5N5L6H3.js +6 -0
  36. package/dist/chunk-Q5N5L6H3.js.map +7 -0
  37. package/dist/chunk-QEVWPU3D.js +8 -0
  38. package/dist/chunk-QEVWPU3D.js.map +7 -0
  39. package/dist/chunk-X36GM74C.js +2 -0
  40. package/dist/chunk-X36GM74C.js.map +7 -0
  41. package/dist/chunk-YRP2UZ2I.js +126 -0
  42. package/dist/chunk-YRP2UZ2I.js.map +7 -0
  43. package/dist/deploy-6HOBYPE6.js +30 -0
  44. package/dist/deploy-6HOBYPE6.js.map +7 -0
  45. package/dist/dev-M3WDGK4D.js +57 -0
  46. package/dist/dev-M3WDGK4D.js.map +7 -0
  47. package/dist/esm-BL3OM5UJ.js +33 -0
  48. package/dist/esm-BL3OM5UJ.js.map +7 -0
  49. package/dist/list-725RHWD5.js +11 -0
  50. package/dist/list-725RHWD5.js.map +7 -0
  51. package/dist/login-I4RGMDLE.js +2 -0
  52. package/dist/login-I4RGMDLE.js.map +7 -0
  53. package/dist/logout-UZBACOIX.js +7 -0
  54. package/dist/logout-UZBACOIX.js.map +7 -0
  55. package/dist/main.js +45 -0
  56. package/dist/main.js.map +7 -0
  57. package/dist/open-GWKGQQG3.js +74 -0
  58. package/dist/open-GWKGQQG3.js.map +7 -0
  59. package/{lib/commands/pull.js → dist/pull-7C5A65KB.js} +7 -48
  60. package/dist/pull-7C5A65KB.js.map +7 -0
  61. package/dist/push-LPUIR4EO.js +2 -0
  62. package/dist/push-LPUIR4EO.js.map +7 -0
  63. package/dist/status-DFKKSRVB.js +14 -0
  64. package/dist/status-DFKKSRVB.js.map +7 -0
  65. package/dist/version-JD42JXWY.js +11 -0
  66. package/dist/version-JD42JXWY.js.map +7 -0
  67. package/dist/whoami-I23R6HOG.js +7 -0
  68. package/dist/whoami-I23R6HOG.js.map +7 -0
  69. package/package.json +73 -75
  70. package/lib/__generated__/graphql.js +0 -78
  71. package/lib/__generated__/graphql.js.map +0 -1
  72. package/lib/commands/add.js +0 -385
  73. package/lib/commands/add.js.map +0 -1
  74. package/lib/commands/deploy.js +0 -287
  75. package/lib/commands/deploy.js.map +0 -1
  76. package/lib/commands/dev.js +0 -374
  77. package/lib/commands/dev.js.map +0 -1
  78. package/lib/commands/list.js +0 -47
  79. package/lib/commands/list.js.map +0 -1
  80. package/lib/commands/login.js +0 -93
  81. package/lib/commands/login.js.map +0 -1
  82. package/lib/commands/logout.js +0 -20
  83. package/lib/commands/logout.js.map +0 -1
  84. package/lib/commands/open.js +0 -159
  85. package/lib/commands/open.js.map +0 -1
  86. package/lib/commands/pull.js.map +0 -1
  87. package/lib/commands/push.js.map +0 -1
  88. package/lib/commands/root.js +0 -110
  89. package/lib/commands/root.js.map +0 -1
  90. package/lib/commands/status.js +0 -56
  91. package/lib/commands/status.js.map +0 -1
  92. package/lib/commands/version.js +0 -18
  93. package/lib/commands/version.js.map +0 -1
  94. package/lib/commands/whoami.js +0 -23
  95. package/lib/commands/whoami.js.map +0 -1
  96. package/lib/ggt.js +0 -65
  97. package/lib/ggt.js.map +0 -1
  98. package/lib/main.js +0 -5
  99. package/lib/main.js.map +0 -1
  100. package/lib/services/app/api/api.js +0 -191
  101. package/lib/services/app/api/api.js.map +0 -1
  102. package/lib/services/app/api/operation.js +0 -23
  103. package/lib/services/app/api/operation.js.map +0 -1
  104. package/lib/services/app/app.js +0 -95
  105. package/lib/services/app/app.js.map +0 -1
  106. package/lib/services/app/arg.js +0 -28
  107. package/lib/services/app/arg.js.map +0 -1
  108. package/lib/services/app/client.js +0 -182
  109. package/lib/services/app/client.js.map +0 -1
  110. package/lib/services/app/edit/edit.js +0 -191
  111. package/lib/services/app/edit/edit.js.map +0 -1
  112. package/lib/services/app/edit/operation.js +0 -155
  113. package/lib/services/app/edit/operation.js.map +0 -1
  114. package/lib/services/app/error.js +0 -65
  115. package/lib/services/app/error.js.map +0 -1
  116. package/lib/services/command/arg.js +0 -55
  117. package/lib/services/command/arg.js.map +0 -1
  118. package/lib/services/command/command.js +0 -47
  119. package/lib/services/command/command.js.map +0 -1
  120. package/lib/services/command/context.js +0 -209
  121. package/lib/services/command/context.js.map +0 -1
  122. package/lib/services/config/config.js +0 -133
  123. package/lib/services/config/config.js.map +0 -1
  124. package/lib/services/config/env.js +0 -22
  125. package/lib/services/config/env.js.map +0 -1
  126. package/lib/services/config/package-json.js +0 -9
  127. package/lib/services/config/package-json.js.map +0 -1
  128. package/lib/services/filesync/changes.js +0 -134
  129. package/lib/services/filesync/changes.js.map +0 -1
  130. package/lib/services/filesync/conflicts.js +0 -140
  131. package/lib/services/filesync/conflicts.js.map +0 -1
  132. package/lib/services/filesync/directory.js +0 -269
  133. package/lib/services/filesync/directory.js.map +0 -1
  134. package/lib/services/filesync/error.js +0 -137
  135. package/lib/services/filesync/error.js.map +0 -1
  136. package/lib/services/filesync/file.js +0 -3
  137. package/lib/services/filesync/file.js.map +0 -1
  138. package/lib/services/filesync/filesync.js +0 -791
  139. package/lib/services/filesync/filesync.js.map +0 -1
  140. package/lib/services/filesync/hashes.js +0 -172
  141. package/lib/services/filesync/hashes.js.map +0 -1
  142. package/lib/services/filesync/strategy.js +0 -59
  143. package/lib/services/filesync/strategy.js.map +0 -1
  144. package/lib/services/filesync/sync-json.js +0 -475
  145. package/lib/services/filesync/sync-json.js.map +0 -1
  146. package/lib/services/http/auth.js +0 -70
  147. package/lib/services/http/auth.js.map +0 -1
  148. package/lib/services/http/http.js +0 -136
  149. package/lib/services/http/http.js.map +0 -1
  150. package/lib/services/output/confirm.js +0 -149
  151. package/lib/services/output/confirm.js.map +0 -1
  152. package/lib/services/output/footer.js +0 -22
  153. package/lib/services/output/footer.js.map +0 -1
  154. package/lib/services/output/log/field.js +0 -3
  155. package/lib/services/output/log/field.js.map +0 -1
  156. package/lib/services/output/log/format/format.js +0 -8
  157. package/lib/services/output/log/format/format.js.map +0 -1
  158. package/lib/services/output/log/format/json.js +0 -37
  159. package/lib/services/output/log/format/json.js.map +0 -1
  160. package/lib/services/output/log/format/pretty.js +0 -158
  161. package/lib/services/output/log/format/pretty.js.map +0 -1
  162. package/lib/services/output/log/level.js +0 -41
  163. package/lib/services/output/log/level.js.map +0 -1
  164. package/lib/services/output/log/logger.js +0 -53
  165. package/lib/services/output/log/logger.js.map +0 -1
  166. package/lib/services/output/log/structured.js +0 -52
  167. package/lib/services/output/log/structured.js.map +0 -1
  168. package/lib/services/output/notify.js +0 -27
  169. package/lib/services/output/notify.js.map +0 -1
  170. package/lib/services/output/output.js +0 -197
  171. package/lib/services/output/output.js.map +0 -1
  172. package/lib/services/output/print.js +0 -31
  173. package/lib/services/output/print.js.map +0 -1
  174. package/lib/services/output/problems.js +0 -84
  175. package/lib/services/output/problems.js.map +0 -1
  176. package/lib/services/output/prompt.js +0 -185
  177. package/lib/services/output/prompt.js.map +0 -1
  178. package/lib/services/output/report.js +0 -190
  179. package/lib/services/output/report.js.map +0 -1
  180. package/lib/services/output/select.js +0 -198
  181. package/lib/services/output/select.js.map +0 -1
  182. package/lib/services/output/spinner.js +0 -141
  183. package/lib/services/output/spinner.js.map +0 -1
  184. package/lib/services/output/sprint.js +0 -44
  185. package/lib/services/output/sprint.js.map +0 -1
  186. package/lib/services/output/symbols.js +0 -23
  187. package/lib/services/output/symbols.js.map +0 -1
  188. package/lib/services/output/table.js +0 -98
  189. package/lib/services/output/table.js.map +0 -1
  190. package/lib/services/output/timestamp.js +0 -12
  191. package/lib/services/output/timestamp.js.map +0 -1
  192. package/lib/services/output/update.js +0 -99
  193. package/lib/services/output/update.js.map +0 -1
  194. package/lib/services/user/session.js +0 -54
  195. package/lib/services/user/session.js.map +0 -1
  196. package/lib/services/user/user.js +0 -76
  197. package/lib/services/user/user.js.map +0 -1
  198. package/lib/services/util/assert.js +0 -11
  199. package/lib/services/util/assert.js.map +0 -1
  200. package/lib/services/util/boolean.js +0 -15
  201. package/lib/services/util/boolean.js.map +0 -1
  202. package/lib/services/util/collection.js +0 -38
  203. package/lib/services/util/collection.js.map +0 -1
  204. package/lib/services/util/function.js +0 -153
  205. package/lib/services/util/function.js.map +0 -1
  206. package/lib/services/util/is.js +0 -97
  207. package/lib/services/util/is.js.map +0 -1
  208. package/lib/services/util/json.js +0 -33
  209. package/lib/services/util/json.js.map +0 -1
  210. package/lib/services/util/number.js +0 -27
  211. package/lib/services/util/number.js.map +0 -1
  212. package/lib/services/util/object.js +0 -104
  213. package/lib/services/util/object.js.map +0 -1
  214. package/lib/services/util/paths.js +0 -36
  215. package/lib/services/util/paths.js.map +0 -1
  216. package/lib/services/util/promise.js +0 -74
  217. package/lib/services/util/promise.js.map +0 -1
  218. package/lib/services/util/types.js +0 -5
  219. package/lib/services/util/types.js.map +0 -1
  220. 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 /api/graphql
11
- * endpoint.
12
- */ _client = /*#__PURE__*/ new WeakMap();
13
- export class Api {
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: "api"
186
- });
187
- _class_private_field_set(this, _client, new Client(this.ctx, "/api/graphql"));
188
- }
189
- }
190
-
191
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/services/app/api/api.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 type { GraphQLMutation, GraphQLQuery, GraphQLSubscription } from \"../edit/operation.js\";\nimport { ClientError } from \"../error.js\";\n\nexport class Api {\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 /api/graphql\n * endpoint.\n */\n #client: Client;\n\n constructor(ctx: Context) {\n this.ctx = ctx.child({ name: \"api\" });\n this.#client = new Client(this.ctx, \"/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","Api","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;AAEtC,SAASC,WAAW,QAAQ,cAAc;IAQxC;;;GAGC,GACD;AAVF,OAAO,MAAMC;IAiBX;;;;;;;;GAQC,GACD,MAAMC,MAAkC,EACtCA,KAAK,EACLC,SAAS,EACT,GAAGC,SA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I,MAAM,IAAI,CAACA,GAAG,CAACC,KAAK,CAAC;oBACnBC,QAAQ;wBAAEC,MAAM;4BAAEiB,cAActB;wBAAK;oBAAE;oBACvCM,WAAW;wBAAED,MAAM;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;QAAM;uCAC7BU,SAAS,IAAIhB,OAAO,IAAI,CAACQ,GAAG,EAAE;IACtC;AAuKF"}
@@ -1,23 +0,0 @@
1
- import { sprint } from "../../output/sprint.js";
2
- export const GADGET_META_MODELS_QUERY = sprint(/* GraphQL */ `
3
- query GadgetMetaModels {
4
- gadgetMeta {
5
- models {
6
- apiIdentifier
7
- namespace
8
- }
9
- }
10
- }
11
- `);
12
- export const GADGET_GLOBAL_ACTIONS_QUERY = sprint(/* GraphQL */ `
13
- query GadgetMetaGlobalActions {
14
- gadgetMeta {
15
- globalActions {
16
- apiIdentifier
17
- namespace
18
- }
19
- }
20
- }
21
- `);
22
-
23
- //# sourceMappingURL=operation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/services/app/api/operation.ts"],"sourcesContent":["import type {\n GadgetMetaGlobalActionsQuery,\n GadgetMetaGlobalActionsQueryVariables,\n GadgetMetaModelsQuery,\n GadgetMetaModelsQueryVariables,\n} from \"../../../__generated__/graphql.js\";\nimport { sprint } from \"../../output/sprint.js\";\nimport type { GraphQLQuery } from \"../edit/operation.js\";\n\nexport const GADGET_META_MODELS_QUERY = sprint(/* GraphQL */ `\n query GadgetMetaModels {\n gadgetMeta {\n models {\n apiIdentifier\n namespace\n }\n }\n }\n`) as GraphQLQuery<GadgetMetaModelsQuery, GadgetMetaModelsQueryVariables>;\n\nexport const GADGET_GLOBAL_ACTIONS_QUERY = sprint(/* GraphQL */ `\n query GadgetMetaGlobalActions {\n gadgetMeta {\n globalActions {\n apiIdentifier\n namespace\n }\n }\n }\n`) as GraphQLQuery<GadgetMetaGlobalActionsQuery, GadgetMetaGlobalActionsQueryVariables>;\n"],"names":["sprint","GADGET_META_MODELS_QUERY","GADGET_GLOBAL_ACTIONS_QUERY"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,MAAM,QAAQ,yBAAyB;AAGhD,OAAO,MAAMC,2BAA2BD,OAAO,WAAW,GAAG,CAAC;;;;;;;;;AAS9D,CAAC,EAAyE;AAE1E,OAAO,MAAME,8BAA8BF,OAAO,WAAW,GAAG,CAAC;;;;;;;;;AASjE,CAAC,EAAuF"}
@@ -1,95 +0,0 @@
1
- import assert from "node:assert";
2
- import { z } from "zod";
3
- import { config } from "../config/config.js";
4
- import { loadAuthHeaders } from "../http/auth.js";
5
- import { http } from "../http/http.js";
6
- import { Api } from "./api/api.js";
7
- import { GADGET_GLOBAL_ACTIONS_QUERY, GADGET_META_MODELS_QUERY } from "./api/operation.js";
8
- export const EnvironmentType = Object.freeze({
9
- Development: "development",
10
- Production: "production",
11
- Test: "test"
12
- });
13
- export const Environment = z.object({
14
- id: z.union([
15
- z.string(),
16
- z.number(),
17
- z.bigint()
18
- ]).transform((v)=>BigInt(v)),
19
- name: z.string().transform((name)=>name.toLowerCase()),
20
- type: z.nativeEnum(EnvironmentType)
21
- });
22
- export const Application = z.object({
23
- id: z.union([
24
- z.string(),
25
- z.number(),
26
- z.bigint()
27
- ]).transform((v)=>BigInt(v)),
28
- slug: z.string(),
29
- primaryDomain: z.string(),
30
- hasSplitEnvironments: z.boolean(),
31
- multiEnvironmentEnabled: z.boolean(),
32
- environments: z.array(Environment)
33
- });
34
- export const ModelApiIdentifier = z.object({
35
- apiIdentifier: z.string(),
36
- namespace: z.nullable(z.array(z.string())).optional()
37
- });
38
- export const GlobalActionApiIdentifier = z.object({
39
- apiIdentifier: z.string(),
40
- namespace: z.nullable(z.array(z.string())).optional()
41
- });
42
- /**
43
- * Retrieves a list of apps for the given user. If the user is not
44
- * logged in, an empty array is returned instead.
45
- *
46
- * @param ctx - The current context.
47
- * @returns A promise that resolves to an array of Application objects.
48
- */ // TODO: cache this
49
- export const getApps = async (ctx)=>{
50
- const headers = loadAuthHeaders();
51
- if (!headers) {
52
- return [];
53
- }
54
- assert(ctx.user, "must get user before getting apps");
55
- const json = await http({
56
- context: {
57
- ctx
58
- },
59
- url: `https://${config.domains.services}/auth/api/apps`,
60
- headers: {
61
- ...headers
62
- },
63
- responseType: "json",
64
- resolveBodyOnly: true
65
- });
66
- return z.array(Application).parse(json);
67
- };
68
- export const getModels = async (ctx)=>{
69
- const headers = loadAuthHeaders();
70
- if (!headers) {
71
- return [];
72
- }
73
- assert(ctx.user, "must get user before getting models");
74
- const api = new Api(ctx);
75
- const { gadgetMeta } = await api.query({
76
- query: GADGET_META_MODELS_QUERY
77
- });
78
- return gadgetMeta.models;
79
- };
80
- export const getGlobalActions = async (ctx)=>{
81
- const headers = loadAuthHeaders();
82
- if (!headers) {
83
- return [];
84
- }
85
- assert(ctx.user, "must get user before getting models");
86
- const api = new Api(ctx);
87
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
88
- const { gadgetMeta } = await api.query({
89
- query: GADGET_GLOBAL_ACTIONS_QUERY
90
- });
91
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
92
- return gadgetMeta.globalActions;
93
- };
94
-
95
- //# sourceMappingURL=app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/app/app.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport { z } from \"zod\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { loadAuthHeaders } from \"../http/auth.js\";\nimport { http } from \"../http/http.js\";\nimport { Api } from \"./api/api.js\";\nimport { GADGET_GLOBAL_ACTIONS_QUERY, GADGET_META_MODELS_QUERY } from \"./api/operation.js\";\n\nexport const EnvironmentType = Object.freeze({\n Development: \"development\",\n Production: \"production\",\n Test: \"test\",\n});\n\nexport type EnvironmentType = keyof typeof EnvironmentType;\n\nexport const Environment = z.object({\n id: z.union([z.string(), z.number(), z.bigint()]).transform((v) => BigInt(v)),\n name: z.string().transform((name) => name.toLowerCase()),\n type: z.nativeEnum(EnvironmentType),\n});\n\nexport type Environment = z.infer<typeof Environment>;\n\nexport const Application = z.object({\n id: z.union([z.string(), z.number(), z.bigint()]).transform((v) => BigInt(v)),\n slug: z.string(),\n primaryDomain: z.string(),\n hasSplitEnvironments: z.boolean(),\n multiEnvironmentEnabled: z.boolean(),\n environments: z.array(Environment),\n});\n\nexport type Application = z.infer<typeof Application>;\n\nexport const ModelApiIdentifier = z.object({\n apiIdentifier: z.string(),\n namespace: z.nullable(z.array(z.string())).optional(),\n});\n\nexport type ModelApiIdentifier = z.infer<typeof ModelApiIdentifier>;\n\nexport const GlobalActionApiIdentifier = z.object({\n apiIdentifier: z.string(),\n namespace: z.nullable(z.array(z.string())).optional(),\n});\n\nexport type GlobalActionApiIdentifier = z.infer<typeof GlobalActionApiIdentifier>;\n\n/**\n * Retrieves a list of apps for the given user. If the user is not\n * logged in, an empty array is returned instead.\n *\n * @param ctx - The current context.\n * @returns A promise that resolves to an array of Application objects.\n */\n// TODO: cache this\nexport const getApps = async (ctx: Context): Promise<Application[]> => {\n const headers = loadAuthHeaders();\n if (!headers) {\n return [];\n }\n\n assert(ctx.user, \"must get user before getting apps\");\n\n const json = await http({\n context: { ctx },\n url: `https://${config.domains.services}/auth/api/apps`,\n headers: { ...headers },\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n return z.array(Application).parse(json);\n};\n\nexport const getModels = async (ctx: Context): Promise<ModelApiIdentifier[] | []> => {\n const headers = loadAuthHeaders();\n if (!headers) {\n return [];\n }\n\n assert(ctx.user, \"must get user before getting models\");\n\n const api = new Api(ctx);\n const { gadgetMeta } = await api.query({ query: GADGET_META_MODELS_QUERY });\n return gadgetMeta.models;\n};\n\nexport const getGlobalActions = async (ctx: Context): Promise<GlobalActionApiIdentifier[] | []> => {\n const headers = loadAuthHeaders();\n if (!headers) {\n return [];\n }\n\n assert(ctx.user, \"must get user before getting models\");\n\n const api = new Api(ctx);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { gadgetMeta } = await api.query({ query: GADGET_GLOBAL_ACTIONS_QUERY });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return gadgetMeta.globalActions;\n};\n"],"names":["assert","z","config","loadAuthHeaders","http","Api","GADGET_GLOBAL_ACTIONS_QUERY","GADGET_META_MODELS_QUERY","EnvironmentType","Object","freeze","Development","Production","Test","Environment","object","id","union","string","number","bigint","transform","v","BigInt","name","toLowerCase","type","nativeEnum","Application","slug","primaryDomain","hasSplitEnvironments","boolean","multiEnvironmentEnabled","environments","array","ModelApiIdentifier","apiIdentifier","namespace","nullable","optional","GlobalActionApiIdentifier","getApps","ctx","headers","user","json","context","url","domains","services","responseType","resolveBodyOnly","parse","getModels","api","gadgetMeta","query","models","getGlobalActions","globalActions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,cAAc;AACjC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,eAAe,QAAQ,kBAAkB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EAAEiB,MAAM,KAAKsB,QAAQ;AACrD,GAAG;AAIH;;;;;;CAMC,GACD,mBAAmB;AACnB,OAAO,MAAME,UAAU,OAAOC;IAC5B,MAAMC,UAAUzC;IAChB,IAAI,CAACyC,SAAS;QACZ,OAAO,EAAE;IACX;IAEA5C,OAAO2C,IAAIE,IAAI,EAAE;IAEjB,MAAMC,OAAO,MAAM1C,KAAK;QACtB2C,SAAS;YAAEJ;QAAI;QACfK,KAAK,CAAC,QAAQ,EAAE9C,OAAO+C,OAAO,CAACC,QAAQ,CAAC,cAAc,CAAC;QACvDN,SAAS;YAAE,GAAGA,OAAO;QAAC;QACtBO,cAAc;QACdC,iBAAiB;IACnB;IAEA,OAAOnD,EAAEkC,KAAK,CAACP,aAAayB,KAAK,CAACP;AACpC,EAAE;AAEF,OAAO,MAAMQ,YAAY,OAAOX;IAC9B,MAAMC,UAAUzC;IAChB,IAAI,CAACyC,SAAS;QACZ,OAAO,EAAE;IACX;IAEA5C,OAAO2C,IAAIE,IAAI,EAAE;IAEjB,MAAMU,MAAM,IAAIlD,IAAIsC;IACpB,MAAM,EAAEa,UAAU,EAAE,GAAG,MAAMD,IAAIE,KAAK,CAAC;QAAEA,OAAOlD;IAAyB;IACzE,OAAOiD,WAAWE,MAAM;AAC1B,EAAE;AAEF,OAAO,MAAMC,mBAAmB,OAAOhB;IACrC,MAAMC,UAAUzC;IAChB,IAAI,CAACyC,SAAS;QACZ,OAAO,EAAE;IACX;IAEA5C,OAAO2C,IAAIE,IAAI,EAAE;IAEjB,MAAMU,MAAM,IAAIlD,IAAIsC;IACpB,mEAAmE;IACnE,MAAM,EAAEa,UAAU,EAAE,GAAG,MAAMD,IAAIE,KAAK,CAAC;QAAEA,OAAOnD;IAA4B;IAE5E,2GAA2G;IAC3G,OAAOkD,WAAWI,aAAa;AACjC,EAAE"}
@@ -1,28 +0,0 @@
1
- import { ArgError } from "../command/arg.js";
2
- import { sprint } from "../output/sprint.js";
3
- /**
4
- * Parses the value of an application argument (-a/--app) and returns
5
- * the application's slug.
6
- *
7
- * @param value - The value of the argument.
8
- * @param name - The name of the argument. e.g. "-a" or "--app".
9
- * @returns The application's slug.
10
- * @throws {ArgError} If the value is not a valid slug or URL.
11
- */ export const AppArg = (value, name)=>{
12
- const slug = RegExp("^(https:\\/\\/)?(?<slug>[\\w-]+?)(--development)?(\\..*)?$").exec(value)?.groups?.["slug"];
13
- if (slug) {
14
- return slug;
15
- }
16
- throw new ArgError(sprint`
17
- ${name} must be the application's {bold slug} or {bold URL}
18
-
19
- {bold EXAMPLES:}
20
- ${name} my-app
21
- ${name} my-app.gadget.app
22
- ${name} https://my-app.gadget.app
23
- ${name} https://my-app.gadget.app/edit
24
- ${name} https://my-app--development.gadget.app/edit
25
- `);
26
- };
27
-
28
- //# sourceMappingURL=arg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/app/arg.ts"],"sourcesContent":["import { ArgError } from \"../command/arg.js\";\nimport { sprint } from \"../output/sprint.js\";\n\n/**\n * Parses the value of an application argument (-a/--app) and returns\n * the application's slug.\n *\n * @param value - The value of the argument.\n * @param name - The name of the argument. e.g. \"-a\" or \"--app\".\n * @returns The application's slug.\n * @throws {ArgError} If the value is not a valid slug or URL.\n */\nexport const AppArg = (value: string, name: string): string => {\n const slug = /^(https:\\/\\/)?(?<slug>[\\w-]+?)(--development)?(\\..*)?$/.exec(value)?.groups?.[\"slug\"];\n if (slug) {\n return slug;\n }\n\n throw new ArgError(\n sprint`\n ${name} must be the application's {bold slug} or {bold URL}\n\n {bold EXAMPLES:}\n ${name} my-app\n ${name} my-app.gadget.app\n ${name} https://my-app.gadget.app\n ${name} https://my-app.gadget.app/edit\n ${name} https://my-app--development.gadget.app/edit\n `,\n );\n};\n"],"names":["ArgError","sprint","AppArg","value","name","slug","exec","groups"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,QAAQ,sBAAsB;AAE7C;;;;;;;;CAQC,GACD,OAAO,MAAMC,SAAS,CAACC,OAAeC;IACpC,MAAMC,OAAO,qEAAyDC,IAAI,CAACH,QAAQI,QAAQ,CAAC,OAAO;IACnG,IAAIF,MAAM;QACR,OAAOA;IACT;IAEA,MAAM,IAAIL,SACRC,MAAM,CAAC;MACL,EAAEG,KAAK;;;QAGL,EAAEA,KAAK;QACP,EAAEA,KAAK;QACP,EAAEA,KAAK;QACP,EAAEA,KAAK;QACP,EAAEA,KAAK;IACX,CAAC;AAEL,EAAE"}
@@ -1,182 +0,0 @@
1
- import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
- import { createClient } from "graphql-ws";
3
- import assert from "node:assert";
4
- import PQueue from "p-queue";
5
- import WebSocket from "ws";
6
- import { config } from "../config/config.js";
7
- import { loadAuthHeaders } from "../http/auth.js";
8
- import { http } from "../http/http.js";
9
- import { noop, unthunk } from "../util/function.js";
10
- import { isObject } from "../util/is.js";
11
- import { ClientError } from "./error.js";
12
- var ConnectionStatus;
13
- (function(ConnectionStatus) {
14
- ConnectionStatus[ConnectionStatus["CONNECTED"] = 0] = "CONNECTED";
15
- ConnectionStatus[ConnectionStatus["DISCONNECTED"] = 1] = "DISCONNECTED";
16
- ConnectionStatus[ConnectionStatus["RECONNECTING"] = 2] = "RECONNECTING";
17
- })(ConnectionStatus || (ConnectionStatus = {}));
18
- /**
19
- * Client is a GraphQL client connected to a Gadget application's
20
- * given endpoint.
21
- */ export class Client {
22
- /**
23
- * Subscribe to a GraphQL subscription.
24
- */ subscribe(ctx, { subscription, variables, onResponse, onError: optionsOnError, onComplete = noop }) {
25
- let request = {
26
- query: subscription,
27
- variables: unthunk(variables)
28
- };
29
- const removeConnectedListener = this._graphqlWsClient.on("connected", ()=>{
30
- if (this.status === 2) {
31
- request = {
32
- query: subscription,
33
- variables: unthunk(variables)
34
- };
35
- ctx.log.info("re-subscribing to graphql subscription");
36
- }
37
- });
38
- const queue = new PQueue({
39
- concurrency: 1
40
- });
41
- const onError = (error)=>optionsOnError(new ClientError(subscription, error));
42
- const unsubscribe = this._graphqlWsClient.subscribe(request, {
43
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
44
- next: (response)=>queue.add(()=>onResponse(response)).catch(onError),
45
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
46
- error: (error)=>queue.add(()=>onError(error)),
47
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
48
- complete: ()=>queue.add(()=>onComplete()).catch(onError)
49
- });
50
- return ()=>{
51
- removeConnectedListener();
52
- unsubscribe();
53
- };
54
- }
55
- /**
56
- * Execute a GraphQL query or mutation.
57
- */ async execute(ctx, request) {
58
- assert(ctx.app, "missing app when executing GraphQL query");
59
- assert(ctx.env, "missing env when executing GraphQL query");
60
- const headers = loadAuthHeaders();
61
- assert(headers, "missing headers when executing GraphQL request");
62
- let subdomain = ctx.app.slug;
63
- if (ctx.app.multiEnvironmentEnabled) {
64
- subdomain += `--${ctx.env.name}`;
65
- } else if (ctx.app.hasSplitEnvironments) {
66
- subdomain += "--development";
67
- }
68
- try {
69
- const json = await http({
70
- context: {
71
- ctx
72
- },
73
- method: "POST",
74
- url: `https://${subdomain}.${config.domains.app}${this.endpoint}`,
75
- headers: {
76
- ...headers,
77
- "x-gadget-environment": ctx.env.name
78
- },
79
- json: {
80
- query: request.operation,
81
- variables: unthunk(request.variables)
82
- },
83
- responseType: "json",
84
- resolveBodyOnly: true,
85
- throwHttpErrors: false,
86
- ...request.http
87
- });
88
- if (!isObject(json) || !("data" in json) && !("errors" in json)) {
89
- ctx.log.error("received invalid graphql response", {
90
- error: json
91
- });
92
- throw json;
93
- }
94
- return json;
95
- } catch (error) {
96
- throw new ClientError(request.operation, error);
97
- }
98
- }
99
- /**
100
- * Close the connection to the server.
101
- */ async dispose() {
102
- await this._graphqlWsClient.dispose();
103
- }
104
- constructor(ctx, endpoint){
105
- // assume the client is going to connect
106
- _define_property(this, "status", 0);
107
- _define_property(this, "ctx", void 0);
108
- _define_property(this, "endpoint", void 0);
109
- _define_property(this, "_graphqlWsClient", void 0);
110
- this.ctx = ctx.child({
111
- name: "client"
112
- });
113
- assert(ctx.app, "app must be set on Client context");
114
- assert(ctx.env, "env must be set on Client context");
115
- this.endpoint = endpoint;
116
- this._graphqlWsClient = createClient({
117
- url: `wss://${ctx.app.slug}.${config.domains.app}/edit/api/graphql-ws`,
118
- shouldRetry: ()=>true,
119
- connectionParams: {
120
- environment: ctx.env.name
121
- },
122
- webSocketImpl: class extends WebSocket {
123
- constructor(address, protocols, wsOptions){
124
- // this cookie should be available since we were given an app which requires a cookie to load
125
- const headers = loadAuthHeaders();
126
- assert(headers, "missing headers when connecting to GraphQL API");
127
- super(address, protocols, {
128
- signal: ctx.signal,
129
- ...wsOptions,
130
- headers: {
131
- ...wsOptions?.headers,
132
- "user-agent": config.versionFull,
133
- ...headers
134
- }
135
- });
136
- }
137
- },
138
- on: {
139
- connecting: ()=>{
140
- switch(this.status){
141
- case 1:
142
- this.status = 2;
143
- this.ctx.log.info("reconnecting");
144
- break;
145
- case 2:
146
- this.ctx.log.info("retrying");
147
- break;
148
- default:
149
- this.ctx.log.debug("connecting");
150
- break;
151
- }
152
- },
153
- connected: ()=>{
154
- if (this.status === 2) {
155
- this.ctx.log.info("reconnected");
156
- } else {
157
- this.ctx.log.debug("connected");
158
- }
159
- // let the other on connected listeners see what status we're in
160
- setImmediate(()=>this.status = 0);
161
- },
162
- closed: ()=>{
163
- this.status = 1;
164
- this.ctx.log.debug("disconnected");
165
- },
166
- error: (error)=>{
167
- if (this.status === 2) {
168
- this.ctx.log.error("failed to reconnect", {
169
- error
170
- });
171
- } else {
172
- this.ctx.log.error("connection error", {
173
- error
174
- });
175
- }
176
- }
177
- }
178
- });
179
- }
180
- }
181
-
182
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/app/client.ts"],"sourcesContent":["import type { ExecutionResult } from \"graphql-ws\";\nimport { createClient } from \"graphql-ws\";\nimport assert from \"node:assert\";\nimport type { ClientRequestArgs } from \"node:http\";\nimport PQueue from \"p-queue\";\nimport type { Promisable } from \"type-fest\";\nimport WebSocket from \"ws\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { loadAuthHeaders } from \"../http/auth.js\";\nimport { http, type HttpOptions } from \"../http/http.js\";\nimport { noop, unthunk, type Thunk } from \"../util/function.js\";\nimport { isObject } from \"../util/is.js\";\nimport type { GraphQLMutation, GraphQLQuery, GraphQLSubscription } from \"./edit/operation.js\";\nimport { ClientError } from \"./error.js\";\n\nenum ConnectionStatus {\n CONNECTED,\n DISCONNECTED,\n RECONNECTING,\n}\n\n/**\n * Client is a GraphQL client connected to a Gadget application's\n * given endpoint.\n */\nexport class Client {\n // assume the client is going to connect\n status = ConnectionStatus.CONNECTED;\n\n readonly ctx: Context;\n\n readonly endpoint: string;\n\n private _graphqlWsClient: ReturnType<typeof createClient>;\n\n constructor(ctx: Context, endpoint: string) {\n this.ctx = ctx.child({ name: \"client\" });\n assert(ctx.app, \"app must be set on Client context\");\n assert(ctx.env, \"env must be set on Client context\");\n\n this.endpoint = endpoint;\n\n this._graphqlWsClient = createClient({\n url: `wss://${ctx.app.slug}.${config.domains.app}/edit/api/graphql-ws`,\n shouldRetry: () => true,\n connectionParams: {\n environment: ctx.env.name,\n },\n webSocketImpl: class extends WebSocket {\n constructor(address: string | URL, protocols?: string | string[], wsOptions?: WebSocket.ClientOptions | ClientRequestArgs) {\n // this cookie should be available since we were given an app which requires a cookie to load\n const headers = loadAuthHeaders();\n\n assert(headers, \"missing headers when connecting to GraphQL API\");\n\n super(address, protocols, {\n signal: ctx.signal,\n ...wsOptions,\n headers: {\n ...wsOptions?.headers,\n \"user-agent\": config.versionFull,\n ...headers,\n },\n });\n }\n },\n on: {\n connecting: () => {\n switch (this.status) {\n case ConnectionStatus.DISCONNECTED:\n this.status = ConnectionStatus.RECONNECTING;\n this.ctx.log.info(\"reconnecting\");\n break;\n case ConnectionStatus.RECONNECTING:\n this.ctx.log.info(\"retrying\");\n break;\n default:\n this.ctx.log.debug(\"connecting\");\n break;\n }\n },\n connected: () => {\n if (this.status === ConnectionStatus.RECONNECTING) {\n this.ctx.log.info(\"reconnected\");\n } else {\n this.ctx.log.debug(\"connected\");\n }\n\n // let the other on connected listeners see what status we're in\n setImmediate(() => (this.status = ConnectionStatus.CONNECTED));\n },\n closed: () => {\n this.status = ConnectionStatus.DISCONNECTED;\n this.ctx.log.debug(\"disconnected\");\n },\n error: (error) => {\n if (this.status === ConnectionStatus.RECONNECTING) {\n this.ctx.log.error(\"failed to reconnect\", { error });\n } else {\n this.ctx.log.error(\"connection error\", { error });\n }\n },\n },\n });\n }\n\n /**\n * Subscribe to a GraphQL subscription.\n */\n subscribe<Subscription extends GraphQLSubscription>(\n ctx: Context,\n {\n subscription,\n variables,\n onResponse,\n onError: optionsOnError,\n onComplete = noop,\n }: {\n subscription: Subscription;\n variables?: Thunk<Subscription[\"Variables\"]> | null;\n onResponse: (response: ExecutionResult<Subscription[\"Data\"], Subscription[\"Extensions\"]>) => Promisable<void>;\n onError: (error: ClientError) => Promisable<void>;\n onComplete?: () => Promisable<void>;\n },\n ): () => void {\n let request = { query: subscription, variables: unthunk(variables) };\n\n const removeConnectedListener = this._graphqlWsClient.on(\"connected\", () => {\n if (this.status === ConnectionStatus.RECONNECTING) {\n request = { query: subscription, variables: unthunk(variables) };\n ctx.log.info(\"re-subscribing to graphql subscription\");\n }\n });\n\n const queue = new PQueue({ concurrency: 1 });\n const onError = (error: unknown): Promisable<void> => optionsOnError(new ClientError(subscription, error));\n\n const unsubscribe = this._graphqlWsClient.subscribe<Subscription[\"Data\"], Subscription[\"Extensions\"]>(request, {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n next: (response) => queue.add(() => onResponse(response)).catch(onError),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n error: (error) => queue.add(() => onError(error)),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n complete: () => queue.add(() => onComplete()).catch(onError),\n });\n\n return () => {\n removeConnectedListener();\n unsubscribe();\n };\n }\n\n /**\n * Execute a GraphQL query or mutation.\n */\n async execute<Operation extends GraphQLQuery | GraphQLMutation>(\n ctx: Context,\n request: {\n operation: Operation;\n variables?: Thunk<Operation[\"Variables\"]> | null;\n http?: HttpOptions;\n },\n ): Promise<ExecutionResult<Operation[\"Data\"], Operation[\"Extensions\"]>> {\n assert(ctx.app, \"missing app when executing GraphQL query\");\n assert(ctx.env, \"missing env when executing GraphQL query\");\n\n const headers = loadAuthHeaders();\n assert(headers, \"missing headers when executing GraphQL request\");\n\n let subdomain = ctx.app.slug;\n if (ctx.app.multiEnvironmentEnabled) {\n subdomain += `--${ctx.env.name}`;\n } else if (ctx.app.hasSplitEnvironments) {\n subdomain += \"--development\";\n }\n\n try {\n const json = await http({\n context: { ctx },\n method: \"POST\",\n url: `https://${subdomain}.${config.domains.app}${this.endpoint}`,\n headers: { ...headers, \"x-gadget-environment\": ctx.env.name },\n json: { query: request.operation, variables: unthunk(request.variables) },\n responseType: \"json\",\n resolveBodyOnly: true,\n throwHttpErrors: false,\n ...request.http,\n });\n\n if (!isObject(json) || (!(\"data\" in json) && !(\"errors\" in json))) {\n ctx.log.error(\"received invalid graphql response\", { error: json });\n throw json;\n }\n\n return json as Operation[\"Response\"];\n } catch (error) {\n throw new ClientError(request.operation, error);\n }\n }\n\n /**\n * Close the connection to the server.\n */\n async dispose(): Promise<void> {\n await this._graphqlWsClient.dispose();\n }\n}\n"],"names":["createClient","assert","PQueue","WebSocket","config","loadAuthHeaders","http","noop","unthunk","isObject","ClientError","ConnectionStatus","Client","subscribe","ctx","subscription","variables","onResponse","onError","optionsOnError","onComplete","request","query","removeConnectedListener","_graphqlWsClient","on","status","log","info","queue","concurrency","error","unsubscribe","next","response","add","catch","complete","execute","app","env","headers","subdomain","slug","multiEnvironmentEnabled","name","hasSplitEnvironments","json","context","method","url","domains","endpoint","operation","responseType","resolveBodyOnly","throwHttpErrors","dispose","constructor","child","shouldRetry","connectionParams","environment","webSocketImpl","address","protocols","wsOptions","signal","versionFull","connecting","debug","connected","setImmediate","closed"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SAASA,YAAY,QAAQ,aAAa;AAC1C,OAAOC,YAAY,cAAc;AAEjC,OAAOC,YAAY,UAAU;AAE7B,OAAOC,eAAe,KAAK;AAE3B,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,IAAI,QAA0B,kBAAkB;AACzD,SAASC,IAAI,EAAEC,OAAO,QAAoB,sBAAsB;AAChE,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,SAASC,WAAW,QAAQ,aAAa;;UAEpCC;;;;GAAAA,qBAAAA;AAML;;;CAGC,GACD,OAAO,MAAMC;IAiFX;;GAEC,GACDC,UACEC,GAAY,EACZ,EACEC,YAAY,EACZC,SAAS,EACTC,UAAU,EACVC,SAASC,cAAc,EACvBC,aAAab,IAAI,EAOlB,EACW;QACZ,IAAIc,UAAU;YAAEC,OAAOP;YAAcC,WAAWR,QAAQQ;QAAW;QAEnE,MAAMO,0BAA0B,IAAI,CAACC,gBAAgB,CAACC,EAAE,CAAC,aAAa;YACpE,IAAI,IAAI,CAACC,MAAM,QAAoC;gBACjDL,UAAU;oBAAEC,OAAOP;oBAAcC,WAAWR,QAAQQ;gBAAW;gBAC/DF,IAAIa,GAAG,CAACC,IAAI,CAAC;YACf;QACF;QAEA,MAAMC,QAAQ,IAAI3B,OAAO;YAAE4B,aAAa;QAAE;QAC1C,MAAMZ,UAAU,CAACa,QAAqCZ,eAAe,IAAIT,YAA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