@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 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/user/user.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport z from \"zod\";\nimport { login } from \"../../commands/login.js\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { loadAuthHeaders, swallowUnauthorized } from \"../http/auth.js\";\nimport { http } from \"../http/http.js\";\nimport { confirm } from \"../output/confirm.js\";\nimport { println } from \"../output/print.js\";\n\nconst User = z.object({\n id: z.union([z.string(), z.number()]).transform(Number),\n name: z.string().nullish(),\n email: z.string(),\n});\n\nexport type User = z.infer<typeof User>;\n\n/**\n * Retrieves the currently logged in user from Gadgets API.\n *\n * @returns A Promise that resolves to a User object representing the\n * current user, or undefined if the user is not authenticated.\n */\nexport const getUser = async (ctx: Context): Promise<User | undefined> => {\n if (ctx.user) {\n return ctx.user;\n }\n\n const headers = loadAuthHeaders();\n\n if (!headers) {\n return undefined;\n }\n\n try {\n const json = await http({\n context: { ctx },\n url: `https://${config.domains.services}/auth/api/current-user`,\n headers: { ...headers },\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n ctx.user = User.parse(json);\n ctx.log.info(\"loaded user\");\n\n return ctx.user;\n } catch (error) {\n swallowUnauthorized(ctx, error);\n return undefined;\n }\n};\n\n/**\n * Retrieves the current user or prompts the user to log in if not\n * already logged in.\n *\n * @param ctx - The current context.\n * @returns A Promise that resolves to the current user.\n */\nexport const getUserOrLogin = async (ctx: Context): Promise<User> => {\n let user = await getUser(ctx);\n if (user) {\n return user;\n }\n\n ctx.log.info(\"prompting user to log in\");\n\n println({ ensureEmptyLineAbove: true })`\n You must be logged in to use \"ggt ${ctx.command}\".\n `;\n\n await confirm({ ensureEmptyLineAbove: true })(\"Would you like to log in?\");\n\n await login(ctx);\n\n user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n return user;\n};\n"],"names":["assert","z","login","config","loadAuthHeaders","swallowUnauthorized","http","confirm","println","User","object","id","union","string","number","transform","Number","name","nullish","email","getUser","ctx","user","headers","undefined","json","context","url","domains","services","responseType","resolveBodyOnly","parse","log","info","error","getUserOrLogin","ensureEmptyLineAbove","command"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,cAAc;AACjC,OAAOC,OAAO,MAAM;AACpB,SAASC,KAAK,QAAQ,0BAA0B;AAEhD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,kBAAkB;AACvE,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,OAAO,QAAQ,qBAAqB;AAE7C,MAAMC,OAAOR,EAAES,MAAM,CAAC;IACpBC,IAAIV,EAAEW,KAAK,CAAC;QAACX,EAAEY,MAAM;QAAIZ,EAAEa,MAAM;KAAG,EAAEC,SAAS,CAACC;IAChDC,MAAMhB,EAAEY,MAAM,GAAGK,OAAO;IACxBC,OAAOlB,EAAEY,MAAM;AACjB;AAIA;;;;;CAKC,GACD,OAAO,MAAMO,UAAU,OAAOC;IAC5B,IAAIA,IAAIC,IAAI,EAAE;QACZ,OAAOD,IAAIC,IAAI;IACjB;IAEA,MAAMC,UAAUnB;IAEhB,IAAI,CAACmB,SAAS;QACZ,OAAOC;IACT;IAEA,IAAI;QACF,MAAMC,OAAO,MAAMnB,KAAK;YACtBoB,SAAS;gBAAEL;YAAI;YACfM,KAAK,CAAC,QAAQ,EAAExB,OAAOyB,OAAO,CAACC,QAAQ,CAAC,sBAAsB,CAAC;YAC/DN,SAAS;gBAAE,GAAGA,OAAO;YAAC;YACtBO,cAAc;YACdC,iBAAiB;QACnB;QAEAV,IAAIC,IAAI,GAAGb,KAAKuB,KAAK,CAACP;QACtBJ,IAAIY,GAAG,CAACC,IAAI,CAAC;QAEb,OAAOb,IAAIC,IAAI;IACjB,EAAE,OAAOa,OAAO;QACd9B,oBAAoBgB,KAAKc;QACzB,OAAOX;IACT;AACF,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMY,iBAAiB,OAAOf;IACnC,IAAIC,OAAO,MAAMF,QAAQC;IACzB,IAAIC,MAAM;QACR,OAAOA;IACT;IAEAD,IAAIY,GAAG,CAACC,IAAI,CAAC;IAEb1B,QAAQ;QAAE6B,sBAAsB;IAAK,EAAE,CAAC;sCACJ,EAAEhB,IAAIiB,OAAO,CAAC;EAClD,CAAC;IAED,MAAM/B,QAAQ;QAAE8B,sBAAsB;IAAK,GAAG;IAE9C,MAAMnC,MAAMmB;IAEZC,OAAO,MAAMF,QAAQC;IACrBrB,OAAOsB,MAAM;IAEb,OAAOA;AACT,EAAE"}
@@ -1,11 +0,0 @@
1
- /* eslint-disable func-style */ /**
2
- * Throws an error indicating that the code should be unreachable.
3
- *
4
- * @param expr - An optional expression to include in the error message.
5
- * @throws - Always throws an error with the message "Unreachable code: {expr}".
6
- */ export function unreachable(expr) {
7
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
8
- throw new Error(`Unreachable code: ${expr}`);
9
- }
10
-
11
- //# sourceMappingURL=assert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/assert.ts"],"sourcesContent":["/* eslint-disable func-style */\n\n/**\n * Throws an error indicating that the code should be unreachable.\n *\n * @param expr - An optional expression to include in the error message.\n * @throws - Always throws an error with the message \"Unreachable code: {expr}\".\n */\nexport function unreachable(expr?: unknown): never {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unreachable code: ${expr}`);\n}\n"],"names":["unreachable","expr","Error"],"rangeMappings":";;;;;;;;","mappings":"AAAA,6BAA6B,GAE7B;;;;;CAKC,GACD,OAAO,SAASA,YAAYC,IAAc;IACxC,4EAA4E;IAC5E,MAAM,IAAIC,MAAM,CAAC,kBAAkB,EAAED,KAAK,CAAC;AAC7C"}
@@ -1,15 +0,0 @@
1
- import { MemoFirstArg, memo } from "./function.js";
2
- /**
3
- * Parses a string value and returns a boolean value.
4
- *
5
- * @param value - The string value to parse.
6
- * @returns A boolean value representing the parsed value.
7
- */ export const parseBoolean = memo(MemoFirstArg, (value)=>{
8
- value ??= "";
9
- return [
10
- "true",
11
- "1"
12
- ].includes(value.trim().toLowerCase());
13
- });
14
-
15
- //# sourceMappingURL=boolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/boolean.ts"],"sourcesContent":["import { MemoFirstArg, memo } from \"./function.js\";\n\n/**\n * Parses a string value and returns a boolean value.\n *\n * @param value - The string value to parse.\n * @returns A boolean value representing the parsed value.\n */\nexport const parseBoolean = memo(MemoFirstArg, (value: string | null | undefined): boolean => {\n value ??= \"\";\n return [\"true\", \"1\"].includes(value.trim().toLowerCase());\n});\n"],"names":["MemoFirstArg","memo","parseBoolean","value","includes","trim","toLowerCase"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,SAASA,YAAY,EAAEC,IAAI,QAAQ,gBAAgB;AAEnD;;;;;CAKC,GACD,OAAO,MAAMC,eAAeD,KAAKD,cAAc,CAACG;IAC9CA,UAAU;IACV,OAAO;QAAC;QAAQ;KAAI,CAACC,QAAQ,CAACD,MAAME,IAAI,GAAGC,WAAW;AACxD,GAAG"}
@@ -1,38 +0,0 @@
1
- import levenshtein from "fast-levenshtein";
2
- import assert from "node:assert";
3
- /**
4
- * Returns a new array with all falsy values removed. The values
5
- * `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsy.
6
- *
7
- * @param array - The array to compact.
8
- * @returns A new array with all falsy values removed.
9
- */ export const compact = (array)=>{
10
- return array.filter((value)=>Boolean(value));
11
- };
12
- /**
13
- * Returns a new array with all duplicate elements removed.
14
- *
15
- * @param array - The array to remove duplicates from.
16
- * @returns A new array with all duplicate elements removed.
17
- */ export const uniq = (array)=>{
18
- return [
19
- ...new Set(array)
20
- ];
21
- };
22
- /**
23
- * Sorts an array of strings based on their similarity to a given input
24
- * string. The closest match is returned as the first element, followed
25
- * by the sorted array.
26
- *
27
- * @param input - The input string to compare against.
28
- * @param options - The array of strings to be sorted.
29
- * @returns An array with the closest match as the first element,
30
- * followed by the sorted array.
31
- */ export const sortBySimilar = (input, options)=>{
32
- assert(options.length > 0, "options must not be empty");
33
- return [
34
- ...options
35
- ].sort((a, b)=>levenshtein.get(a, input) - levenshtein.get(b, input));
36
- };
37
-
38
- //# sourceMappingURL=collection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/collection.ts"],"sourcesContent":["import levenshtein from \"fast-levenshtein\";\nimport assert from \"node:assert\";\n\n/**\n * Returns a new array with all falsy values removed. The values\n * `false`, `null`, `0`, `\"\"`, `undefined`, and `NaN` are falsy.\n *\n * @param array - The array to compact.\n * @returns A new array with all falsy values removed.\n */\nexport const compact = <T>(array: T[]): NonNullable<T>[] => {\n return array.filter((value): value is NonNullable<T> => Boolean(value));\n};\n\n/**\n * Returns a new array with all duplicate elements removed.\n *\n * @param array - The array to remove duplicates from.\n * @returns A new array with all duplicate elements removed.\n */\nexport const uniq = <T>(array: T[]): T[] => {\n return [...new Set(array)];\n};\n\n/**\n * Sorts an array of strings based on their similarity to a given input\n * string. The closest match is returned as the first element, followed\n * by the sorted array.\n *\n * @param input - The input string to compare against.\n * @param options - The array of strings to be sorted.\n * @returns An array with the closest match as the first element,\n * followed by the sorted array.\n */\nexport const sortBySimilar = (input: string, options: readonly string[]): [closest: string, ...sorted: string[]] => {\n assert(options.length > 0, \"options must not be empty\");\n return [...options].sort((a, b) => levenshtein.get(a, input) - levenshtein.get(b, input)) as [string, ...string[]];\n};\n"],"names":["levenshtein","assert","compact","array","filter","value","Boolean","uniq","Set","sortBySimilar","input","options","length","sort","a","b","get"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,iBAAiB,mBAAmB;AAC3C,OAAOC,YAAY,cAAc;AAEjC;;;;;;CAMC,GACD,OAAO,MAAMC,UAAU,CAAIC;IACzB,OAAOA,MAAMC,MAAM,CAAC,CAACC,QAAmCC,QAAQD;AAClE,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,OAAO,CAAIJ;IACtB,OAAO;WAAI,IAAIK,IAAIL;KAAO;AAC5B,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,MAAMM,gBAAgB,CAACC,OAAeC;IAC3CV,OAAOU,QAAQC,MAAM,GAAG,GAAG;IAC3B,OAAO;WAAID;KAAQ,CAACE,IAAI,CAAC,CAACC,GAAGC,IAAMf,YAAYgB,GAAG,CAACF,GAAGJ,SAASV,YAAYgB,GAAG,CAACD,GAAGL;AACpF,EAAE"}
@@ -1,153 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable func-style */ import mimicFunction from "mimic-function";
2
- import assert from "node:assert";
3
- import { isFunction } from "./is.js";
4
- const memoizedFns = new Set();
5
- /**
6
- * A function that returns an empty string.
7
- *
8
- * Used as the default key function for {@linkcode memo}.
9
- */ export const MemoFirstCall = ()=>"";
10
- /**
11
- * A function that returns the first argument as a string.
12
- */ export const MemoFirstArg = (...args)=>String(args[0]);
13
- /**
14
- * A function that returns all arguments as a string.
15
- *
16
- * Useful for memoizing functions that accept a variable number of
17
- * arguments.
18
- */ export const MemoAllArgs = (...args)=>args.map(String).join(":");
19
- // eslint-disable-next-line jsdoc/require-jsdoc
20
- export function memo(fnOrKeyFn, fn) {
21
- let keyFn;
22
- if (fn) {
23
- keyFn = fnOrKeyFn;
24
- } else {
25
- fn = fnOrKeyFn;
26
- keyFn = MemoFirstArg;
27
- }
28
- const cache = new Map();
29
- const memoized = (...args)=>{
30
- const key = keyFn(...args);
31
- if (cache.has(key)) {
32
- return cache.get(key);
33
- }
34
- assert(fn, "fn shouldn't be undefined");
35
- const result = fn(...args);
36
- cache.set(key, result);
37
- return result;
38
- };
39
- memoized.clear = cache.clear.bind(cache);
40
- memoizedFns.add(memoized);
41
- mimicFunction(memoized, fn);
42
- return memoized;
43
- }
44
- /**
45
- * Clears the cache of all memoized functions.
46
- */ export const clearMemoized = ()=>{
47
- for (const memoized of memoizedFns){
48
- memoized.clear();
49
- }
50
- };
51
- /**
52
- * Creates a debounced function that delays invoking the provided
53
- * function until after `delayMS` milliseconds have elapsed since the
54
- * last time it was invoked.
55
- *
56
- * @param delayMS - The number of milliseconds to delay.
57
- * @param fn - The function to be debounced.
58
- * @returns A debounced version of the provided function.
59
- */ export const debounce = (delayMS, fn)=>{
60
- let timerId;
61
- let upcomingCall;
62
- const debounced = (...args)=>{
63
- upcomingCall = ()=>{
64
- upcomingCall = undefined;
65
- timerId = undefined;
66
- fn(...args);
67
- };
68
- clearTimeout(timerId);
69
- timerId = setTimeout(upcomingCall, delayMS);
70
- };
71
- debounced.flush = ()=>{
72
- if (upcomingCall) {
73
- upcomingCall();
74
- }
75
- };
76
- mimicFunction(debounced, fn);
77
- return debounced;
78
- };
79
- /**
80
- * Creates a debounced function that delays invoking the provided
81
- * function until after `delayMS` milliseconds have elapsed since the
82
- * last time it was invoked.
83
- *
84
- * @param delayMS - The number of milliseconds to delay.
85
- * @param fn - The function to be debounced.
86
- * @returns A debounced version of the provided function.
87
- */ export const debounceAsync = (delayMS, fn)=>{
88
- let timerId;
89
- let nextCall;
90
- let pendingPromise;
91
- const debouncedAsync = (...args)=>{
92
- nextCall = ()=>{
93
- nextCall = undefined;
94
- timerId = undefined;
95
- if (pendingPromise) {
96
- pendingPromise = pendingPromise.then(()=>fn(...args)).catch(noop).finally(()=>pendingPromise = undefined);
97
- } else {
98
- pendingPromise = fn(...args).catch(noop).finally(()=>pendingPromise = undefined);
99
- }
100
- return pendingPromise;
101
- };
102
- clearTimeout(timerId);
103
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
104
- timerId = setTimeout(nextCall, delayMS);
105
- };
106
- debouncedAsync.flush = async ()=>{
107
- if (nextCall) {
108
- await nextCall();
109
- }
110
- };
111
- mimicFunction(debouncedAsync, fn);
112
- return debouncedAsync;
113
- };
114
- /**
115
- * Wraps a value in a thunk (a function that returns a value). If the
116
- * value is already a function, it is returned as is.
117
- *
118
- * @param val - The value or function to wrap.
119
- * @returns A function that returns the value.
120
- */ export const thunk = (val)=>{
121
- if (isFunction(val)) {
122
- return val;
123
- }
124
- return ()=>val;
125
- };
126
- /**
127
- * Unwraps a value from a thunk (a function that returns a value). If the
128
- * value is not a function, it is returned as is.
129
- *
130
- * @param value - The value or thunk to unwrap.
131
- * @returns The unwrapped value.
132
- */ export const unthunk = (value, ...args)=>{
133
- if (isFunction(value)) {
134
- return value(...args);
135
- }
136
- return value;
137
- };
138
- /**
139
- * A function that does nothing and returns nothing.
140
- */ // eslint-disable-next-line @typescript-eslint/no-empty-function
141
- export const noop = (..._args)=>{};
142
- /**
143
- * A function that does nothing and returns `this`.
144
- */ export const noopThis = function(..._args) {
145
- return this;
146
- };
147
- /**
148
- * A function that does nothing and returns a function that does nothing.
149
- */ export const noopNoop = (..._args)=>{
150
- return noop;
151
- };
152
-
153
- //# sourceMappingURL=function.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/function.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable func-style */\nimport mimicFunction from \"mimic-function\";\nimport assert from \"node:assert\";\nimport type { SetReturnType } from \"type-fest\";\nimport { isFunction } from \"./is.js\";\nimport { type AnyFunction } from \"./types.js\";\n\nconst memoizedFns = new Set<MemoizedFn>();\n\n/**\n * A function that has been wrapped by {@linkcode memo}.\n */\nexport type MemoizedFn<Fn extends AnyFunction = AnyFunction> = Fn & {\n /**\n * Clears the cache of the memoized function.\n */\n clear: () => void;\n};\n\n/**\n * A function that returns an empty string.\n *\n * Used as the default key function for {@linkcode memo}.\n */\nexport const MemoFirstCall = (): string => \"\";\n\n/**\n * A function that returns the first argument as a string.\n */\nexport const MemoFirstArg = (...args: any[]): string => String(args[0]);\n\n/**\n * A function that returns all arguments as a string.\n *\n * Useful for memoizing functions that accept a variable number of\n * arguments.\n */\nexport const MemoAllArgs = (...args: any[]): string => args.map(String).join(\":\");\n\n/**\n * Creates a memoized version of the provided function.\n *\n * The memoized function caches the result of the first call and returns\n * the cached result for all subsequent calls.\n *\n * @param fn - The function to memoize.\n * @see MemoFirstCall\n */\nexport function memo<Fn extends AnyFunction>(fn: Fn): MemoizedFn<Fn>;\n\n/**\n * Creates a memoized version of the provided function.\n *\n * The memoized function caches the results of previous calls and\n * returns the cached result when the key returned by `keyFn` matches\n * a previous call.\n *\n * @param keyFn - A function that returns a key for the arguments.\n * @param fn - The function to memoize.\n */\nexport function memo<Fn extends AnyFunction, KeyFn extends (...args: Parameters<Fn>) => string>(keyFn: KeyFn, fn: Fn): MemoizedFn<Fn>;\n\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function memo<Fn extends AnyFunction, KeyFn extends (...args: Parameters<Fn>) => string>(\n fnOrKeyFn: Fn | KeyFn,\n fn?: Fn,\n): MemoizedFn<Fn> {\n let keyFn: KeyFn;\n if (fn) {\n keyFn = fnOrKeyFn as KeyFn;\n } else {\n fn = fnOrKeyFn as Fn;\n keyFn = MemoFirstArg as unknown as KeyFn;\n }\n\n const cache = new Map<string, unknown>();\n\n const memoized = ((...args: Parameters<Fn>) => {\n const key = keyFn(...args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n\n assert(fn, \"fn shouldn't be undefined\");\n const result = fn(...args);\n cache.set(key, result);\n\n return result;\n }) as MemoizedFn<Fn>;\n\n memoized.clear = cache.clear.bind(cache);\n\n memoizedFns.add(memoized);\n\n mimicFunction(memoized, fn);\n\n return memoized;\n}\n\n/**\n * Clears the cache of all memoized functions.\n */\nexport const clearMemoized = (): void => {\n for (const memoized of memoizedFns) {\n memoized.clear();\n }\n};\n\n/**\n * A function that has been wrapped by {@linkcode debounce}.\n */\nexport type DebouncedFunc<Fn extends (...args: unknown[]) => void> = Fn & {\n /**\n * Invokes the function if it is waiting to stop being called.\n */\n flush: () => void;\n};\n\n/**\n * Creates a debounced function that delays invoking the provided\n * function until after `delayMS` milliseconds have elapsed since the\n * last time it was invoked.\n *\n * @param delayMS - The number of milliseconds to delay.\n * @param fn - The function to be debounced.\n * @returns A debounced version of the provided function.\n */\nexport const debounce = <F extends (...args: unknown[]) => void>(delayMS: number, fn: F): DebouncedFunc<F> => {\n let timerId: NodeJS.Timeout | undefined;\n let upcomingCall: (() => void) | undefined;\n\n const debounced = ((...args) => {\n upcomingCall = () => {\n upcomingCall = undefined;\n timerId = undefined;\n fn(...args);\n };\n\n clearTimeout(timerId);\n timerId = setTimeout(upcomingCall, delayMS);\n }) as DebouncedFunc<F>;\n\n debounced.flush = () => {\n if (upcomingCall) {\n upcomingCall();\n }\n };\n\n mimicFunction(debounced, fn);\n\n return debounced;\n};\n\n/**\n * A function that has been wrapped by {@linkcode debounce}.\n */\nexport type DebouncedAsyncFunc<Fn extends (...args: unknown[]) => Promise<void>> = SetReturnType<Fn, void> & {\n /**\n * Invokes the function if it is waiting to stop being called.\n */\n flush: () => Promise<void>;\n};\n\n/**\n * Creates a debounced function that delays invoking the provided\n * function until after `delayMS` milliseconds have elapsed since the\n * last time it was invoked.\n *\n * @param delayMS - The number of milliseconds to delay.\n * @param fn - The function to be debounced.\n * @returns A debounced version of the provided function.\n */\nexport const debounceAsync = <F extends (...args: unknown[]) => Promise<void>>(delayMS: number, fn: F): DebouncedAsyncFunc<F> => {\n let timerId: NodeJS.Timeout | undefined;\n let nextCall: (() => Promise<void>) | undefined;\n let pendingPromise: Promise<void> | undefined;\n\n const debouncedAsync = ((...args) => {\n nextCall = () => {\n nextCall = undefined;\n timerId = undefined;\n\n if (pendingPromise) {\n pendingPromise = pendingPromise\n .then(() => fn(...args))\n .catch(noop)\n .finally(() => (pendingPromise = undefined));\n } else {\n pendingPromise = fn(...args)\n .catch(noop)\n .finally(() => (pendingPromise = undefined));\n }\n\n return pendingPromise;\n };\n\n clearTimeout(timerId);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n timerId = setTimeout(nextCall, delayMS);\n }) as DebouncedAsyncFunc<F>;\n\n debouncedAsync.flush = async () => {\n if (nextCall) {\n await nextCall();\n }\n };\n\n mimicFunction(debouncedAsync, fn);\n\n return debouncedAsync;\n};\n\n/**\n * Either a value or a function that returns a value.\n */\nexport type Thunk<T, Args extends any[] = []> = T | ((...args: Args) => T);\n\n/**\n * Wraps a value in a thunk (a function that returns a value). If the\n * value is already a function, it is returned as is.\n *\n * @param val - The value or function to wrap.\n * @returns A function that returns the value.\n */\nexport const thunk = <T>(val: T | (() => T)): (() => T) => {\n if (isFunction(val)) {\n return val;\n }\n return () => val;\n};\n\n/**\n * Unwraps a value from a thunk (a function that returns a value). If the\n * value is not a function, it is returned as is.\n *\n * @param value - The value or thunk to unwrap.\n * @returns The unwrapped value.\n */\nexport const unthunk = <T, Args extends any[]>(value: Thunk<T, Args>, ...args: Args): T => {\n if (isFunction(value)) {\n return value(...args);\n }\n return value;\n};\n\n/**\n * A function that does nothing and returns nothing.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport const noop = (..._args: any[]): void => {};\n\n/**\n * A function that does nothing and returns `this`.\n */\nexport const noopThis = function <T>(this: T, ..._args: any[]): T {\n return this;\n};\n\n/**\n * A function that does nothing and returns a function that does nothing.\n */\nexport const noopNoop = (..._args: any[]): typeof noop => {\n return noop;\n};\n"],"names":["mimicFunction","assert","isFunction","memoizedFns","Set","MemoFirstCall","MemoFirstArg","args","String","MemoAllArgs","map","join","memo","fnOrKeyFn","fn","keyFn","cache","Map","memoized","key","has","get","result","set","clear","bind","add","clearMemoized","debounce","delayMS","timerId","upcomingCall","debounced","undefined","clearTimeout","setTimeout","flush","debounceAsync","nextCall","pendingPromise","debouncedAsync","then","catch","noop","finally","thunk","val","unthunk","value","_args","noopThis","noopNoop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,qDAAqD,GACrD,6BAA6B,GAC7B,OAAOA,mBAAmB,iBAAiB;AAC3C,OAAOC,YAAY,cAAc;AAEjC,SAASC,UAAU,QAAQ,UAAU;AAGrC,MAAMC,cAAc,IAAIC;AAYxB;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,IAAc,GAAG;AAE9C;;CAEC,GACD,OAAO,MAAMC,eAAe,CAAC,GAAGC,OAAwBC,OAAOD,IAAI,CAAC,EAAE,EAAE;AAExE;;;;;CAKC,GACD,OAAO,MAAME,cAAc,CAAC,GAAGF,OAAwBA,KAAKG,GAAG,CAACF,QAAQG,IAAI,CAAC,KAAK;AAyBlF,+CAA+C;AAC/C,OAAO,SAASC,KACdC,SAAqB,EACrBC,EAAO;IAEP,IAAIC;IACJ,IAAID,IAAI;QACNC,QAAQF;IACV,OAAO;QACLC,KAAKD;QACLE,QAAQT;IACV;IAEA,MAAMU,QAAQ,IAAIC;IAElB,MAAMC,WAAY,CAAC,GAAGX;QACpB,MAAMY,MAAMJ,SAASR;QACrB,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AAUK,WAAWG,UAAUT;IACjC;IAEAW,eAAeJ,KAAK,GAAG;QACrB,IAAIE,UAAU;YACZ,MAAMA;QACR;IACF;IAEAtC,cAAcwC,gBAAgB1B;IAE9B,OAAO0B;AACT,EAAE;AAOF;;;;;;CAMC,GACD,OAAO,MAAMK,QAAQ,CAAIC;IACvB,IAAI5C,WAAW4C,MAAM;QACnB,OAAOA;IACT;IACA,OAAO,IAAMA;AACf,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMC,UAAU,CAAwBC,OAAuB,GAAGzC;IACvE,IAAIL,WAAW8C,QAAQ;QACrB,OAAOA,SAASzC;IAClB;IACA,OAAOyC;AACT,EAAE;AAEF;;CAEC,GACD,gEAAgE;AAChE,OAAO,MAAML,OAAO,CAAC,GAAGM,SAAwB,EAAE;AAElD;;CAEC,GACD,OAAO,MAAMC,WAAW,SAAsB,GAAGD,KAAY;IAC3D,OAAO,IAAI;AACb,EAAE;AAEF;;CAEC,GACD,OAAO,MAAME,WAAW,CAAC,GAAGF;IAC1B,OAAON;AACT,EAAE"}
@@ -1,97 +0,0 @@
1
- import { z } from "zod";
2
- export const isNil = (val)=>{
3
- return val === null || val === undefined;
4
- };
5
- export const isString = (val)=>{
6
- return typeof val === "string";
7
- };
8
- export const isObject = (val)=>{
9
- return typeof val === "object" && val !== null;
10
- };
11
- export const isArray = Array.isArray;
12
- // eslint-disable-next-line @typescript-eslint/ban-types
13
- export const isFunction = (val)=>{
14
- return typeof val === "function";
15
- };
16
- export const isError = (val)=>{
17
- return val instanceof Error;
18
- };
19
- export const isCloseEvent = (e)=>{
20
- return z.object({
21
- type: z.string(),
22
- code: z.number(),
23
- reason: z.string(),
24
- wasClean: z.boolean()
25
- }).safeParse(e).success;
26
- };
27
- export const isErrorEvent = (e)=>{
28
- return z.object({
29
- type: z.string(),
30
- message: z.string(),
31
- error: z.any()
32
- }).safeParse(e).success;
33
- };
34
- export const isGraphQLResult = (val)=>{
35
- return z.union([
36
- z.object({
37
- data: z.record(z.unknown())
38
- }),
39
- z.object({
40
- errors: z.array(z.object({
41
- message: z.string()
42
- }))
43
- }),
44
- z.object({
45
- data: z.record(z.unknown()),
46
- errors: z.array(z.object({
47
- message: z.string()
48
- }))
49
- })
50
- ]).safeParse(val).success;
51
- };
52
- export const isGraphQLErrors = (e)=>{
53
- return z.array(z.object({
54
- message: z.string(),
55
- extensions: z.record(z.unknown()).nullish().transform((ext)=>ext ?? {})
56
- })).min(1).safeParse(e).success;
57
- };
58
- export const isNever = (value)=>{
59
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
60
- throw new Error(`Unexpected value: ${value}`);
61
- };
62
- export const isAbortError = (error)=>{
63
- return error instanceof Error && error.name === "AbortError" || error instanceof Event && error.type === "abort";
64
- };
65
- export const isENOENTError = (error)=>{
66
- return isObject(error) && "code" in error && error.code === "ENOENT";
67
- };
68
- export const isENOTEMPTYError = (error)=>{
69
- return isObject(error) && "code" in error && error.code === "ENOTEMPTY";
70
- };
71
- export const isENOTDIRError = (error)=>{
72
- return isObject(error) && "code" in error && error.code === "ENOTDIR";
73
- };
74
- export const isEEXISTError = (error)=>{
75
- return isObject(error) && "code" in error && error.code === "EEXIST";
76
- };
77
- export const isJavaScriptFile = (filepath)=>{
78
- return [
79
- ".js",
80
- ".jsx",
81
- ".cjs",
82
- ".mjs"
83
- ].some((ext)=>filepath.endsWith(ext));
84
- };
85
- export const isTypeScriptFile = (filepath)=>{
86
- return [
87
- ".ts",
88
- ".tsx",
89
- ".cts",
90
- ".mts"
91
- ].some((ext)=>filepath.endsWith(ext) && !filepath.endsWith(".d.ts"));
92
- };
93
- export const isGellyFile = (filepath)=>{
94
- return filepath.endsWith(".gelly");
95
- };
96
-
97
- //# sourceMappingURL=is.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/is.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLError } from \"graphql\";\nimport type { SetOptional } from \"type-fest\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport { z } from \"zod\";\n\nexport const isNil = (val: unknown): val is null | undefined => {\n return val === null || val === undefined;\n};\n\nexport const isString = (val: unknown): val is string => {\n return typeof val === \"string\";\n};\n\nexport const isObject = (val: unknown): val is object => {\n return typeof val === \"object\" && val !== null;\n};\n\nexport const isArray = Array.isArray;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isFunction = (val: unknown): val is Function => {\n return typeof val === \"function\";\n};\n\nexport const isError = (val: unknown): val is Error => {\n return val instanceof Error;\n};\n\nexport const isCloseEvent = (e: unknown): e is SetOptional<CloseEvent, \"target\"> => {\n return z.object({ type: z.string(), code: z.number(), reason: z.string(), wasClean: z.boolean() }).safeParse(e).success;\n};\n\nexport const isErrorEvent = (e: unknown): e is SetOptional<ErrorEvent, \"target\"> => {\n return z.object({ type: z.string(), message: z.string(), error: z.any() }).safeParse(e).success;\n};\n\nexport const isGraphQLResult = (val: unknown): val is ExecutionResult => {\n return z\n .union([\n z.object({ data: z.record(z.unknown()) }),\n z.object({ errors: z.array(z.object({ message: z.string() })) }),\n z.object({\n data: z.record(z.unknown()),\n errors: z.array(z.object({ message: z.string() })),\n }),\n ])\n .safeParse(val).success;\n};\n\nexport const isGraphQLErrors = (e: unknown): e is readonly GraphQLError[] => {\n return z\n .array(\n z.object({\n message: z.string(),\n extensions: z\n .record(z.unknown())\n .nullish()\n .transform((ext) => ext ?? {}),\n }),\n )\n .min(1)\n .safeParse(e).success;\n};\n\nexport const isNever = (value: never): never => {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unexpected value: ${value}`);\n};\n\nexport const isAbortError = (error: unknown): error is Error | Event => {\n return (error instanceof Error && error.name === \"AbortError\") || (error instanceof Event && error.type === \"abort\");\n};\n\nexport const isENOENTError = (error: unknown): error is { code: \"ENOENT\" } => {\n return isObject(error) && \"code\" in error && error.code === \"ENOENT\";\n};\n\nexport const isENOTEMPTYError = (error: unknown): error is { code: \"ENOTEMPTY\" } => {\n return isObject(error) && \"code\" in error && error.code === \"ENOTEMPTY\";\n};\n\nexport const isENOTDIRError = (error: unknown): error is { code: \"ENOTDIR\" } => {\n return isObject(error) && \"code\" in error && error.code === \"ENOTDIR\";\n};\n\nexport const isEEXISTError = (error: unknown): error is { code: \"EEXIST\" } => {\n return isObject(error) && \"code\" in error && error.code === \"EEXIST\";\n};\n\nexport const isJavaScriptFile = (filepath: string): boolean => {\n return [\".js\", \".jsx\", \".cjs\", \".mjs\"].some((ext) => filepath.endsWith(ext));\n};\n\nexport const isTypeScriptFile = (filepath: string): boolean => {\n return [\".ts\", \".tsx\", \".cts\", \".mts\"].some((ext) => filepath.endsWith(ext) && !filepath.endsWith(\".d.ts\"));\n};\n\nexport const isGellyFile = (filepath: string): boolean => {\n return filepath.endsWith(\".gelly\");\n};\n"],"names":["z","isNil","val","undefined","isString","isObject","isArray","Array","isFunction","isError","Error","isCloseEvent","e","object","type","string","code","number","reason","wasClean","boolean","safeParse","success","isErrorEvent","message","error","any","isGraphQLResult","union","data","record","unknown","errors","array","isGraphQLErrors","extensions","nullish","transform","ext","min","isNever","value","isAbortError","name","Event","isENOENTError","isENOTEMPTYError","isENOTDIRError","isEEXISTError","isJavaScriptFile","filepath","some","endsWith","isTypeScriptFile","isGellyFile"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,QAAQ,CAACC;IACpB,OAAOA,QAAQ,QAAQA,QAAQC;AACjC,EAAE;AAEF,OAAO,MAAMC,WAAW,CAACF;IACvB,OAAO,OAAOA,QAAQ;AACxB,EAAE;AAEF,OAAO,MAAMG,WAAW,CAACH;IACvB,OAAO,OAAOA,QAAQ,YAAYA,QAAQ;AAC5C,EAAE;AAEF,OAAO,MAAMI,UAAUC,MAAMD,OAAO,CAAC;AAErC,wD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E,QAAQ,CAAC;AAC3B,EAAE"}
@@ -1,33 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/consistent-type-definitions */ const bigintToJSON = function() {
2
- return String(this);
3
- };
4
- const mapToJSON = function() {
5
- return Object.fromEntries(this);
6
- };
7
- const setToJSON = function() {
8
- return Array.from(this);
9
- };
10
- export const installJsonExtensions = ()=>{
11
- if (!Object.prototype.hasOwnProperty.call(BigInt, "toJSON")) {
12
- BigInt.prototype.toJSON = bigintToJSON;
13
- }
14
- if (!Object.prototype.hasOwnProperty.call(Map, "toJSON")) {
15
- Map.prototype.toJSON = mapToJSON;
16
- }
17
- if (!Object.prototype.hasOwnProperty.call(Set, "toJSON")) {
18
- Set.prototype.toJSON = setToJSON;
19
- }
20
- };
21
- export const uninstallJsonExtensions = ()=>{
22
- if (BigInt.prototype.toJSON === bigintToJSON) {
23
- delete BigInt.prototype.toJSON;
24
- }
25
- if (Map.prototype.toJSON === mapToJSON) {
26
- delete Map.prototype.toJSON;
27
- }
28
- if (Set.prototype.toJSON === setToJSON) {
29
- delete Set.prototype.toJSON;
30
- }
31
- };
32
-
33
- //# sourceMappingURL=json.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/json.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/consistent-type-definitions */\n\ndeclare global {\n interface BigInt {\n toJSON?(): string;\n }\n interface Map<K, V> {\n toJSON?(): Record<string, V>;\n }\n interface Set<T> {\n toJSON?(): T[];\n }\n}\n\nconst bigintToJSON = function (this: bigint): string {\n return String(this);\n};\n\nconst mapToJSON = function <K, V>(this: Map<K, V>): Record<string, V> {\n return Object.fromEntries(this);\n};\n\nconst setToJSON = function <T>(this: Set<T>): T[] {\n return Array.from(this);\n};\n\nexport const installJsonExtensions = (): void => {\n if (!Object.prototype.hasOwnProperty.call(BigInt, \"toJSON\")) {\n BigInt.prototype.toJSON = bigintToJSON;\n }\n\n if (!Object.prototype.hasOwnProperty.call(Map, \"toJSON\")) {\n Map.prototype.toJSON = mapToJSON;\n }\n\n if (!Object.prototype.hasOwnProperty.call(Set, \"toJSON\")) {\n Set.prototype.toJSON = setToJSON;\n }\n};\n\nexport const uninstallJsonExtensions = (): void => {\n if (BigInt.prototype.toJSON === bigintToJSON) {\n delete BigInt.prototype.toJSON;\n }\n\n if (Map.prototype.toJSON === mapToJSON) {\n delete Map.prototype.toJSON;\n }\n\n if (Set.prototype.toJSON === setToJSON) {\n delete Set.prototype.toJSON;\n }\n};\n"],"names":["bigintToJSON","String","mapToJSON","Object","fromEntries","setToJSON","Array","from","installJsonExtensions","prototype","hasOwnProperty","call","BigInt","toJSON","Map","Set","uninstallJsonExtensions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oDAAoD,GACpD,sDAAsD,GACtD,iEAAiE,GAcjE,MAAMA,eAAe;IACnB,OAAOC,OAAO,IAAI;AACpB;AAEA,MAAMC,YAAY;IAChB,OAAOC,OAAOC,WAAW,CAAC,IAAI;AAChC;AAEA,MAAMC,YAAY;IAChB,OAAOC,MAAMC,IAAI,CAAC,IAAI;AACxB;AAEA,OAAO,MAAMC,wBAAwB;IACnC,IAAI,CAACL,OAAOM,SAAS,CAACC,cAAc,CAACC,IAAI,CAACC,QAAQ,WAAW;QAC3DA,OAAOH,SAAS,CAACI,MAAM,GAAGb;IAC5B;IAEA,IAAI,CAACG,OAAOM,SAAS,CAACC,cAAc,CAACC,IAAI,CAACG,KAAK,WAAW;QACxDA,IAAIL,SAAS,CAACI,MAAM,GAAGX;IACzB;IAEA,IAAI,CAACC,OAAOM,SAAS,CAACC,cAAc,CAACC,IAAI,CAACI,KAAK,WAAW;QACxDA,IAAIN,SAAS,CAACI,MAAM,GAAGR;IACzB;AACF,EAAE;AAEF,OAAO,MAAMW,0BAA0B;IACrC,IAAIJ,OAAOH,SAAS,CAACI,MAAM,KAAKb,cAAc;QAC5C,OAAOY,OAAOH,SAAS,CAACI,MAAM;IAChC;IAEA,IAAIC,IAAIL,SAAS,CAACI,MAAM,KAAKX,WAAW;QACtC,OAAOY,IAAIL,SAAS,CAACI,MAAM;IAC7B;IAEA,IAAIE,IAAIN,SAAS,CAACI,MAAM,KAAKR,WAAW;QACtC,OAAOU,IAAIN,SAAS,CAACI,MAAM;IAC7B;AACF,EAAE"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Parses a string value into a number. If the value is an invalid
3
- * number it returns {@linkcode defaultValue}.
4
- *
5
- * @param value - The string value to parse.
6
- * @returns The parsed number.
7
- */ export const parseNumber = (value, defaultValue = 0)=>{
8
- value ??= "";
9
- const parsed = Number.parseFloat(value);
10
- return Number.isNaN(parsed) ? defaultValue : parsed;
11
- };
12
- /**
13
- * Ensures that a number is within a given range.
14
- *
15
- * If the number is less than the minimum value, the minimum value is returned.
16
- * If the number is greater than the maximum value, the maximum value is returned.
17
- * Otherwise, the number is returned as is.
18
- *
19
- * @param value - The value to be clamped.
20
- * @param min - The minimum value of the range.
21
- * @param max - The maximum value of the range.
22
- * @returns The clamped value.
23
- */ export const clamp = (value, min, max)=>{
24
- return Math.max(min, Math.min(max, value));
25
- };
26
-
27
- //# sourceMappingURL=number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/number.ts"],"sourcesContent":["/**\n * Parses a string value into a number. If the value is an invalid\n * number it returns {@linkcode defaultValue}.\n *\n * @param value - The string value to parse.\n * @returns The parsed number.\n */\nexport const parseNumber = (value: string | null | undefined, defaultValue = 0): number => {\n value ??= \"\";\n const parsed = Number.parseFloat(value);\n return Number.isNaN(parsed) ? defaultValue : parsed;\n};\n\n/**\n * Ensures that a number is within a given range.\n *\n * If the number is less than the minimum value, the minimum value is returned.\n * If the number is greater than the maximum value, the maximum value is returned.\n * Otherwise, the number is returned as is.\n *\n * @param value - The value to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n * @returns The clamped value.\n */\nexport const clamp = (value: number, min: number, max: number): number => {\n return Math.max(min, Math.min(max, value));\n};\n"],"names":["parseNumber","value","defaultValue","parsed","Number","parseFloat","isNaN","clamp","min","max","Math"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,cAAc,CAACC,OAAkCC,eAAe,CAAC;IAC5ED,UAAU;IACV,MAAME,SAASC,OAAOC,UAAU,CAACJ;IACjC,OAAOG,OAAOE,KAAK,CAACH,UAAUD,eAAeC;AAC/C,EAAE;AAEF;;;;;;;;;;;CAWC,GACD,OAAO,MAAMI,QAAQ,CAACN,OAAeO,KAAaC;IAChD,OAAOC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKR;AACrC,EAAE"}
@@ -1,104 +0,0 @@
1
- import cleanStack from "clean-stack";
2
- import { RequestError } from "got";
3
- import { inspect } from "node:util";
4
- import { serializeError as baseSerializeError } from "serialize-error";
5
- import { workspaceRoot } from "./paths.js";
6
- /**
7
- * Returns a new object with the properties of the input object merged
8
- * with the properties of the defaults object. If a property exists in
9
- * both objects, the property of the input object will be used.
10
- *
11
- * @param input - The input object to merge with the defaults object.
12
- * @param defaults - The defaults object to merge with the input object.
13
- * @returns A new object with the properties of the input object merged
14
- * with the properties of the defaults object.
15
- */ export const defaults = (input, defaults)=>{
16
- const result = {
17
- ...input
18
- };
19
- for (const [key, defaultValue] of Object.entries(defaults)){
20
- if (!result[key]) {
21
- result[key] = defaultValue;
22
- }
23
- }
24
- return result;
25
- };
26
- /**
27
- * Creates a new object with only the specified properties of the
28
- * original object.
29
- *
30
- * @param object - The original object to pick properties from.
31
- * @param keys - The keys of the properties to pick.
32
- * @returns A new object with only the specified properties of the
33
- * original object.
34
- */ export const pick = (object, keys)=>{
35
- const result = {};
36
- for (const key of keys){
37
- result[key] = object[key];
38
- }
39
- return result;
40
- };
41
- /**
42
- * Returns a new object with the specified keys omitted.
43
- *
44
- * @param record - The input object.
45
- * @param keys - The keys to omit.
46
- * @returns A new object with the specified keys omitted.
47
- */ export const omit = (record, keys)=>{
48
- const result = {
49
- ...record
50
- };
51
- for (const key of keys){
52
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
53
- delete result[key];
54
- }
55
- return result;
56
- };
57
- /**
58
- * Maps the values of an object to a new set of values using the
59
- * provided function.
60
- *
61
- * @param obj - The input object to map.
62
- * @param fn - The function to apply to each value in the input object.
63
- * @returns A new object with the same keys as the input object, but
64
- * with the values mapped to new values using the provided function.
65
- */ export const mapValues = (obj, fn)=>{
66
- const result = {};
67
- for (const [key, value] of Object.entries(obj)){
68
- result[key] = fn(value);
69
- }
70
- return result;
71
- };
72
- /**
73
- * Universal Error object to json blob serializer.
74
- *
75
- * Wraps `serialize-error` with some handy stuff, like special support
76
- * for Got HTTP errors
77
- */ export const serializeError = (error)=>{
78
- if (Array.isArray(error)) {
79
- error = error[0];
80
- }
81
- let serialized = baseSerializeError(error);
82
- if (typeof serialized == "string") {
83
- serialized = {
84
- message: serialized
85
- };
86
- }
87
- if (serialized.stack) {
88
- serialized.stack = cleanStack(serialized.stack, {
89
- pretty: true,
90
- basePath: workspaceRoot
91
- }).replaceAll(/file:\/\/\//g, "");
92
- }
93
- if (error instanceof RequestError) {
94
- serialized["timings"] = undefined;
95
- serialized["options"] = {
96
- method: error.options.method,
97
- url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url
98
- };
99
- serialized["responseBody"] = inspect(error.response?.body);
100
- }
101
- return serialized;
102
- };
103
-
104
- //# sourceMappingURL=object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/object.ts"],"sourcesContent":["import cleanStack from \"clean-stack\";\nimport { RequestError } from \"got\";\nimport { inspect } from \"node:util\";\nimport { serializeError as baseSerializeError, type ErrorObject } from \"serialize-error\";\nimport type { Simplify } from \"type-fest\";\nimport { workspaceRoot } from \"./paths.js\";\n\n/**\n * Returns a new object with the properties of the input object merged\n * with the properties of the defaults object. If a property exists in\n * both objects, the property of the input object will be used.\n *\n * @param input - The input object to merge with the defaults object.\n * @param defaults - The defaults object to merge with the input object.\n * @returns A new object with the properties of the input object merged\n * with the properties of the defaults object.\n */\nexport const defaults = <Input extends Record<string, unknown>, Defaults extends Partial<Input>>(\n input: Input | null | undefined,\n defaults: Defaults,\n): Simplify<Defaults & Input> => {\n const result = { ...input };\n for (const [key, defaultValue] of Object.entries(defaults)) {\n if (!result[key]) {\n result[key] = defaultValue;\n }\n }\n return result as Simplify<Defaults & Input>;\n};\n\n/**\n * Creates a new object with only the specified properties of the\n * original object.\n *\n * @param object - The original object to pick properties from.\n * @param keys - The keys of the properties to pick.\n * @returns A new object with only the specified properties of the\n * original object.\n */\nexport const pick = <T extends Record<string, unknown>, K extends keyof T>(object: T, keys: readonly K[]): Pick<T, K> => {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n result[key] = object[key];\n }\n return result;\n};\n\n/**\n * Returns a new object with the specified keys omitted.\n *\n * @param record - The input object.\n * @param keys - The keys to omit.\n * @returns A new object with the specified keys omitted.\n */\nexport const omit = <T extends Record<string, unknown>, K extends keyof T>(record: T, keys: readonly K[]): Omit<T, K> => {\n const result = { ...record };\n for (const key of keys) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete result[key];\n }\n return result;\n};\n\n/**\n * Maps the values of an object to a new set of values using the\n * provided function.\n *\n * @param obj - The input object to map.\n * @param fn - The function to apply to each value in the input object.\n * @returns A new object with the same keys as the input object, but\n * with the values mapped to new values using the provided function.\n */\nexport const mapValues = <Key extends string | number | symbol, Value, MappedValue>(\n obj: Record<Key, Value>,\n fn: (value: Value) => MappedValue,\n): Record<Key, MappedValue> => {\n const result = {} as Record<Key, MappedValue>;\n for (const [key, value] of Object.entries(obj)) {\n result[key as Key] = fn(value as Value);\n }\n return result;\n};\n\n/**\n * Universal Error object to json blob serializer.\n *\n * Wraps `serialize-error` with some handy stuff, like special support\n * for Got HTTP errors\n */\nexport const serializeError = (error: unknown): ErrorObject => {\n if (Array.isArray(error)) {\n error = error[0];\n }\n\n let serialized = baseSerializeError(error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (serialized.stack) {\n serialized.stack = cleanStack(serialized.stack, { pretty: true, basePath: workspaceRoot }).replaceAll(/file:\\/\\/\\//g, \"\");\n }\n\n if (error instanceof RequestError) {\n serialized[\"timings\"] = undefined;\n serialized[\"options\"] = {\n method: error.options.method,\n url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url,\n };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n};\n"],"names":["cleanStack","RequestError","inspect","serializeError","baseSerializeError","workspaceRoot","defaults","input","result","key","defaultValue","Object","entries","pick","object","keys","omit","record","mapValues","obj","fn","value","error","Array","isArray","serialized","message","stack","pretty","basePath","replaceAll","undefined","method","options","url","URL","toJSON","response","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAc;AACrC,SAASC,YAAY,QAAQ,MAAM;AACnC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,kBAAkBC,kBAAkB,QAA0B,kBAAkB;AAEzF,SAASC,aAAa,QAAQ,aAAa;AAE3C;;;;;;;;;CASC,GACD,OAAO,MAAMC,WAAW,CACtBC,OACAD;IAEA,MAAME,SAAS;QAAE,GAAGD,KAAK;IAAC;IAC1B,KAAK,MAAM,CAACE,KAAKC,aAAa,IAAIC,OAAOC,OAAO,CAACN,UAAW;QAC1D,IAAI,CAACE,MAAM,CAACC,IAAI,EAAE;YAChBD,MAAM,CAACC,IAAI,GAAGC;QAChB;IACF;IACA,OAAOF;AACT,EAAE;AAEF;;;;;;;;CAQC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M,KAAKd,MAAMW,OAAO,CAACC,GAAG;QACxF;QACAT,UAAU,CAAC,eAAe,GAAGvB,QAAQoB,MAAMe,QAAQ,EAAEC;IACvD;IAEA,OAAOb;AACT,EAAE"}
@@ -1,36 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- /**
4
- * Returns the filename of the current module.
5
- *
6
- * @returns The filename of the current module.
7
- */ export const thisFilename = ()=>fileURLToPath(import.meta.url);
8
- /**
9
- * Returns the directory name of the current module.
10
- *
11
- * @returns The directory name of the current module.
12
- */ export const thisDirname = ()=>path.dirname(thisFilename());
13
- /**
14
- * Returns a path relative to the current module.
15
- *
16
- * @param segments - The segments of the path.
17
- * @returns The path relative to the current module.
18
- */ export const relativeToThisFile = (...segments)=>path.join(thisDirname(), ...segments);
19
- /**
20
- * The root directory of the ggt package.
21
- */ export const workspaceRoot = relativeToThisFile("../../../");
22
- /**
23
- * Returns an absolute path within the ggt package.
24
- *
25
- * @param segments - The segments of the path to join.
26
- * @returns The absolute path to the file or directory.
27
- */ export const workspacePath = (...segments)=>path.join(workspaceRoot, ...segments);
28
- /**
29
- * Returns an absolute path within the `assets` directory of the ggt
30
- * package.
31
- *
32
- * @param segments - The segments of the path to join.
33
- * @returns The absolute path to the file or directory.
34
- */ export const assetsPath = (...segments)=>workspacePath("assets", ...segments);
35
-
36
- //# sourceMappingURL=paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/services/util/paths.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Returns the filename of the current module.\n *\n * @returns The filename of the current module.\n */\nexport const thisFilename = (): string => fileURLToPath(import.meta.url);\n\n/**\n * Returns the directory name of the current module.\n *\n * @returns The directory name of the current module.\n */\nexport const thisDirname = (): string => path.dirname(thisFilename());\n\n/**\n * Returns a path relative to the current module.\n *\n * @param segments - The segments of the path.\n * @returns The path relative to the current module.\n */\nexport const relativeToThisFile = (...segments: string[]): string => path.join(thisDirname(), ...segments);\n\n/**\n * The root directory of the ggt package.\n */\nexport const workspaceRoot = relativeToThisFile(\"../../../\");\n\n/**\n * Returns an absolute path within the ggt package.\n *\n * @param segments - The segments of the path to join.\n * @returns The absolute path to the file or directory.\n */\nexport const workspacePath = (...segments: string[]): string => path.join(workspaceRoot, ...segments);\n\n/**\n * Returns an absolute path within the `assets` directory of the ggt\n * package.\n *\n * @param segments - The segments of the path to join.\n * @returns The absolute path to the file or directory.\n */\nexport const assetsPath = (...segments: string[]): string => workspacePath(\"assets\", ...segments);\n"],"names":["path","fileURLToPath","thisFilename","url","thisDirname","dirname","relativeToThisFile","segments","join","workspaceRoot","workspacePath","assetsPath"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AAEzC;;;;CAIC,GACD,OAAO,MAAMC,eAAe,IAAcD,cAAc,YAAYE,GAAG,EAAE;AAEzE;;;;CAIC,GACD,OAAO,MAAMC,cAAc,IAAcJ,KAAKK,OAAO,CAACH,gBAAgB;AAEtE;;;;;CAKC,GACD,OAAO,MAAMI,qBAAqB,CAAC,GAAGC,WAA+BP,KAAKQ,IAAI,CAACJ,kBAAkBG,UAAU;AAE3G;;CAEC,GACD,OAAO,MAAME,gBAAgBH,mBAAmB,aAAa;AAE7D;;;;;CAKC,GACD,OAAO,MAAMI,gBAAgB,CAAC,GAAGH,WAA+BP,KAAKQ,IAAI,CAACC,kBAAkBF,UAAU;AAEtG;;;;;;CAMC,GACD,OAAO,MAAMI,aAAa,CAAC,GAAGJ,WAA+BG,cAAc,aAAaH,UAAU"}