@trayai/tray-sync-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/LICENSE.md +182 -0
  2. package/README.md +167 -0
  3. package/dist/api/errors.js +29 -0
  4. package/dist/api/trayClient.js +69 -0
  5. package/dist/cli.js +32 -0
  6. package/dist/commands/auth.js +103 -0
  7. package/dist/commands/env.js +534 -0
  8. package/dist/commands/init.js +115 -0
  9. package/dist/commands/project.js +175 -0
  10. package/dist/commands/promote.js +289 -0
  11. package/dist/commands/pull.js +379 -0
  12. package/dist/commands/status.js +126 -0
  13. package/dist/config/credentials.js +10 -0
  14. package/dist/config/environments.js +10 -0
  15. package/dist/config/io.js +36 -0
  16. package/dist/config/mappings.js +9 -0
  17. package/dist/config/paths.js +33 -0
  18. package/dist/config/projectConfig.js +16 -0
  19. package/dist/config/pullProgress.js +9 -0
  20. package/dist/config/state.js +9 -0
  21. package/dist/config/trayYaml.js +9 -0
  22. package/dist/config/types.js +21 -0
  23. package/dist/config/yaml.js +22 -0
  24. package/dist/lib/authDiscovery.js +76 -0
  25. package/dist/lib/checksum.js +5 -0
  26. package/dist/lib/exportStructure.js +23 -0
  27. package/dist/lib/outputFormat.js +12 -0
  28. package/dist/lib/pathContainment.js +37 -0
  29. package/dist/lib/promoteExecute.js +8 -0
  30. package/dist/lib/promoteReconstruct.js +35 -0
  31. package/dist/lib/promoteReport.js +44 -0
  32. package/dist/lib/promoteTarget.js +129 -0
  33. package/dist/lib/region.js +26 -0
  34. package/dist/lib/regionDisplay.js +11 -0
  35. package/dist/lib/regionParsing.js +12 -0
  36. package/dist/lib/scriptExtraction.js +46 -0
  37. package/dist/lib/slug.js +14 -0
  38. package/dist/lib/tokenResolution.js +19 -0
  39. package/dist/lib/uuid.js +5 -0
  40. package/dist/views/env/env.js +89 -0
  41. package/dist/views/env/shared.js +7 -0
  42. package/dist/views/init/init.js +17 -0
  43. package/dist/views/project/project.js +35 -0
  44. package/dist/views/project/shared.js +4 -0
  45. package/dist/views/promote/promote.js +44 -0
  46. package/dist/views/promote/shared.js +4 -0
  47. package/dist/views/pull/pull.js +31 -0
  48. package/dist/views/pull/shared.js +4 -0
  49. package/dist/views/shared.js +8 -0
  50. package/dist/views/status/shared.js +20 -0
  51. package/dist/views/status/status.js +23 -0
  52. package/node_modules/commander/LICENSE +22 -0
  53. package/node_modules/commander/Readme.md +1172 -0
  54. package/node_modules/commander/index.js +21 -0
  55. package/node_modules/commander/lib/argument.js +147 -0
  56. package/node_modules/commander/lib/command.js +2790 -0
  57. package/node_modules/commander/lib/error.js +36 -0
  58. package/node_modules/commander/lib/help.js +731 -0
  59. package/node_modules/commander/lib/option.js +377 -0
  60. package/node_modules/commander/lib/suggestSimilar.js +99 -0
  61. package/node_modules/commander/package-support.json +19 -0
  62. package/node_modules/commander/package.json +64 -0
  63. package/node_modules/commander/typings/index.d.ts +1113 -0
  64. package/node_modules/yaml/LICENSE +13 -0
  65. package/node_modules/yaml/README.md +172 -0
  66. package/node_modules/yaml/bin.mjs +11 -0
  67. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  68. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  69. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  70. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  71. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  72. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  73. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  74. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  75. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  76. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  77. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
  78. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  79. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  80. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  81. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  82. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  83. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  84. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  85. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  86. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  87. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  88. package/node_modules/yaml/browser/dist/errors.js +57 -0
  89. package/node_modules/yaml/browser/dist/index.js +17 -0
  90. package/node_modules/yaml/browser/dist/log.js +11 -0
  91. package/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
  92. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  93. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  94. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  95. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  96. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  97. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  98. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  99. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  100. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  101. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  102. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  103. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  104. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  105. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  106. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  107. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  108. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  109. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  110. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  111. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  112. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  113. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  114. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  115. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  116. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  117. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  118. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  119. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  120. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  121. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  122. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  123. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  124. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  125. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  126. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  127. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  128. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  129. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  130. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  131. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  132. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  133. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  134. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  135. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  136. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  137. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  138. package/node_modules/yaml/browser/dist/util.js +11 -0
  139. package/node_modules/yaml/browser/dist/visit.js +233 -0
  140. package/node_modules/yaml/browser/index.js +5 -0
  141. package/node_modules/yaml/browser/package.json +3 -0
  142. package/node_modules/yaml/dist/cli.d.ts +8 -0
  143. package/node_modules/yaml/dist/cli.mjs +201 -0
  144. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  145. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  146. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  147. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  148. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  149. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  150. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  151. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  152. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  153. package/node_modules/yaml/dist/compose/composer.js +224 -0
  154. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  155. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  156. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  157. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  158. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  159. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  160. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  161. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  162. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  163. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  164. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  165. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  166. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  167. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  168. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  169. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  170. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  171. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  172. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  173. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  174. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  175. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  176. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  177. package/node_modules/yaml/dist/doc/Document.js +337 -0
  178. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  179. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  180. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  181. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  182. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  183. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  184. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  185. package/node_modules/yaml/dist/doc/directives.js +178 -0
  186. package/node_modules/yaml/dist/errors.d.ts +21 -0
  187. package/node_modules/yaml/dist/errors.js +62 -0
  188. package/node_modules/yaml/dist/index.d.ts +25 -0
  189. package/node_modules/yaml/dist/index.js +50 -0
  190. package/node_modules/yaml/dist/log.d.ts +3 -0
  191. package/node_modules/yaml/dist/log.js +19 -0
  192. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  193. package/node_modules/yaml/dist/nodes/Alias.js +118 -0
  194. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  195. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  196. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  197. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  198. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  199. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  200. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  201. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  202. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  203. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  204. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  205. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  206. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  207. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  208. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  209. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  210. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  211. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  212. package/node_modules/yaml/dist/options.d.ts +350 -0
  213. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  214. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  215. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  216. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  217. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  218. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  219. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  220. package/node_modules/yaml/dist/parse/cst.js +112 -0
  221. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  222. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  223. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  224. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  225. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  226. package/node_modules/yaml/dist/parse/parser.js +980 -0
  227. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  228. package/node_modules/yaml/dist/public-api.js +107 -0
  229. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  230. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  231. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  232. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  233. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  234. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  235. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  236. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  237. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  238. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  239. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  240. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  241. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  242. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  243. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  244. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  245. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  246. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  247. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  248. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  249. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  250. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  251. package/node_modules/yaml/dist/schema/tags.js +99 -0
  252. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  253. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  254. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  255. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  256. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  257. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  258. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  259. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  260. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  261. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  262. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  263. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  264. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  265. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  266. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  267. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  268. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  269. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  270. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  271. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  272. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  273. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  274. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  275. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  276. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  277. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  278. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  279. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  280. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  281. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  282. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  283. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  284. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  285. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  286. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  287. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  288. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  289. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  290. package/node_modules/yaml/dist/test-events.js +134 -0
  291. package/node_modules/yaml/dist/util.d.ts +16 -0
  292. package/node_modules/yaml/dist/util.js +28 -0
  293. package/node_modules/yaml/dist/visit.d.ts +102 -0
  294. package/node_modules/yaml/dist/visit.js +236 -0
  295. package/node_modules/yaml/package.json +97 -0
  296. package/node_modules/yaml/util.js +2 -0
  297. package/package.json +42 -0
@@ -0,0 +1,22 @@
1
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse, stringify } from "yaml";
4
+ export async function readYaml(filePath) {
5
+ let raw;
6
+ try {
7
+ raw = await readFile(filePath, "utf8");
8
+ }
9
+ catch (err) {
10
+ if (err.code === "ENOENT")
11
+ return undefined;
12
+ throw err;
13
+ }
14
+ return parse(raw);
15
+ }
16
+ export async function writeYaml(filePath, data) {
17
+ await mkdir(path.dirname(filePath), { recursive: true });
18
+ const tmpPath = `${filePath}.tmp-${process.pid}`;
19
+ await writeFile(tmpPath, stringify(data), "utf8");
20
+ await rename(tmpPath, filePath);
21
+ }
22
+ //# sourceMappingURL=yaml.js.map
@@ -0,0 +1,76 @@
1
+ import { createHash } from "node:crypto";
2
+ import { urlsForRegion } from "./region.js";
3
+ const GET_AUTHENTICATIONS_QUERY = `
4
+ query GetAuthenticationsPrivate(
5
+ $first: Int, $last: Int, $after: String, $before: String,
6
+ $name: String, $workspaceIds: [String!], $serviceId: String
7
+ ) {
8
+ viewer {
9
+ userAuthentications(
10
+ last: $last, first: $first, after: $after, before: $before,
11
+ criteria: { name: $name, workspaceIds: $workspaceIds, serviceId: $serviceId }
12
+ ) {
13
+ edges { node {
14
+ id, name, created, group,
15
+ creator { id }
16
+ service { name, version }
17
+ } }
18
+ pageInfo { hasNextPage, endCursor }
19
+ }
20
+ }
21
+ }
22
+ `;
23
+ export async function listWorkspaceAuthentications(client, region, workspaceId) {
24
+ const weaverUrl = urlsForRegion(region).weaverUrl;
25
+ const authentications = [];
26
+ let after;
27
+ for (;;) {
28
+ const data = (await client.graphql(GET_AUTHENTICATIONS_QUERY, { workspaceIds: [workspaceId], first: 50, after }, weaverUrl));
29
+ for (const { node } of data.viewer.userAuthentications.edges) {
30
+ authentications.push({
31
+ id: node.id,
32
+ name: node.name,
33
+ created: node.created,
34
+ group: node.group,
35
+ creatorId: node.creator.id,
36
+ service: node.service,
37
+ });
38
+ }
39
+ const { hasNextPage, endCursor } = data.viewer.userAuthentications.pageInfo;
40
+ if (!hasNextPage || !endCursor)
41
+ break;
42
+ after = endCursor;
43
+ }
44
+ return { authentications };
45
+ }
46
+ export function computeAuthGroup(title, serviceName, serviceVersion) {
47
+ const bytes = Buffer.from(`${serviceName}:${serviceVersion}:${title}`, "utf8");
48
+ const hash = createHash("md5").update(bytes).digest();
49
+ hash[6] = (hash[6] & 0x0f) | 0x30;
50
+ hash[8] = (hash[8] & 0x3f) | 0x80;
51
+ const hex = hash.toString("hex");
52
+ return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)].join("-");
53
+ }
54
+ export const AuthCandidateMatchKinds = {
55
+ EXACT: "exact",
56
+ SAME_SERVICE: "same_service",
57
+ };
58
+ export function matchAuthCandidates(requirement, authentications) {
59
+ const requirementGroup = computeAuthGroup(requirement.title, requirement.service.name, requirement.service.version);
60
+ const exact = [];
61
+ const sameService = [];
62
+ for (const auth of authentications) {
63
+ if (auth.group === requirementGroup) {
64
+ exact.push({ ...auth, matchKind: AuthCandidateMatchKinds.EXACT });
65
+ }
66
+ else if (auth.service.name === requirement.service.name &&
67
+ auth.service.version === requirement.service.version) {
68
+ sameService.push({ ...auth, matchKind: AuthCandidateMatchKinds.SAME_SERVICE });
69
+ }
70
+ }
71
+ return [...exact, ...sameService];
72
+ }
73
+ export function prioritizeAuths(candidates) {
74
+ return candidates;
75
+ }
76
+ //# sourceMappingURL=authDiscovery.js.map
@@ -0,0 +1,5 @@
1
+ import { createHash } from "node:crypto";
2
+ export function sha256(content) {
3
+ return `sha256:${createHash("sha256").update(content, "utf8").digest("hex")}`;
4
+ }
5
+ //# sourceMappingURL=checksum.js.map
@@ -0,0 +1,23 @@
1
+ import { IncompatibleApiError } from "../api/errors.js";
2
+ export function entityDisplayName(entity) {
3
+ return entity.name ?? entity.title ?? "";
4
+ }
5
+ export function parseExportStructure(raw) {
6
+ if (typeof raw !== "object" || raw === null) {
7
+ throw new IncompatibleApiError("exportProject: response is not an object");
8
+ }
9
+ const candidate = raw;
10
+ if (!Array.isArray(candidate.projects) || candidate.projects.length === 0) {
11
+ throw new IncompatibleApiError("exportProject: missing or empty projects[]");
12
+ }
13
+ if (!Array.isArray(candidate.workflows)) {
14
+ throw new IncompatibleApiError("exportProject: missing workflows[]");
15
+ }
16
+ for (const key of ["data_tables", "vector_tables", "agents", "apim_operations"]) {
17
+ if (candidate[key] !== undefined && !Array.isArray(candidate[key])) {
18
+ throw new IncompatibleApiError(`exportProject: ${key} is present but not an array`);
19
+ }
20
+ }
21
+ return candidate;
22
+ }
23
+ //# sourceMappingURL=exportStructure.js.map
@@ -0,0 +1,12 @@
1
+ import { InvalidArgumentError } from "commander";
2
+ export const OutputFormats = {
3
+ HUMAN: "human",
4
+ JSON: "json",
5
+ };
6
+ export function parseFormat(value) {
7
+ if (value !== OutputFormats.HUMAN && value !== OutputFormats.JSON) {
8
+ throw new InvalidArgumentError(`--format must be one of: ${OutputFormats.HUMAN}, ${OutputFormats.JSON}`);
9
+ }
10
+ return value;
11
+ }
12
+ //# sourceMappingURL=outputFormat.js.map
@@ -0,0 +1,37 @@
1
+ import path from "node:path";
2
+ import { lstat } from "node:fs/promises";
3
+ export function resolveContained(rootDir, relativePath) {
4
+ const root = path.resolve(rootDir);
5
+ const resolved = path.resolve(root, relativePath);
6
+ if (resolved !== root && !resolved.startsWith(root + path.sep)) {
7
+ throw new Error(`path escapes project root: "${relativePath}" resolves outside "${root}"`);
8
+ }
9
+ return resolved;
10
+ }
11
+ export async function assertNoSymlinkInPath(rootDir, resolvedPath) {
12
+ const root = path.resolve(rootDir);
13
+ const relative = path.relative(root, resolvedPath);
14
+ const segments = relative === "" ? [] : relative.split(path.sep);
15
+ let current = root;
16
+ for (const segment of segments) {
17
+ current = path.join(current, segment);
18
+ let stats;
19
+ try {
20
+ stats = await lstat(current);
21
+ }
22
+ catch (err) {
23
+ if (err.code === "ENOENT")
24
+ return;
25
+ throw err;
26
+ }
27
+ if (stats.isSymbolicLink()) {
28
+ throw new Error(`path contains a symlink: "${current}" is a symlink (rejected under "${root}")`);
29
+ }
30
+ }
31
+ }
32
+ export async function resolveContainedSafe(rootDir, relativePath) {
33
+ const resolved = resolveContained(rootDir, relativePath);
34
+ await assertNoSymlinkInPath(rootDir, resolved);
35
+ return resolved;
36
+ }
37
+ //# sourceMappingURL=pathContainment.js.map
@@ -0,0 +1,8 @@
1
+ import { toRequestBody } from "./promoteTarget.js";
2
+ export async function previewImport(client, targetProjectId, payload) {
3
+ return (await client.request("POST", `/v1/projects/${targetProjectId}/imports/previews`, toRequestBody(payload)));
4
+ }
5
+ export async function importProject(client, targetProjectId, payload) {
6
+ return (await client.request("POST", `/v1/projects/${targetProjectId}/imports`, toRequestBody(payload)));
7
+ }
8
+ //# sourceMappingURL=promoteExecute.js.map
@@ -0,0 +1,35 @@
1
+ import { resolveContainedSafe } from "./pathContainment.js";
2
+ async function readEntityFile(readFile, projectDirPath, resourcePath) {
3
+ const resolvedPath = await resolveContainedSafe(projectDirPath, resourcePath);
4
+ const content = await readFile(resolvedPath);
5
+ return JSON.parse(content);
6
+ }
7
+ async function readOrderedEntities(readFile, projectDirPath, state, orderKey) {
8
+ const ids = state.order[orderKey];
9
+ const entities = [];
10
+ for (const id of ids) {
11
+ const resource = state.resources[id];
12
+ if (!resource) {
13
+ throw new Error(`state.json.order.${orderKey} references "${id}", but state.json.resources has no entry for it.`);
14
+ }
15
+ entities.push(await readEntityFile(readFile, projectDirPath, resource.path));
16
+ }
17
+ return entities;
18
+ }
19
+ export async function reconstructExportStructure(deps, projectDirPath, state) {
20
+ const projectJsonPath = await resolveContainedSafe(projectDirPath, "project.json");
21
+ const project = JSON.parse(await deps.readFile(projectJsonPath));
22
+ const exportStructure = {
23
+ tray_export_version: state.tray_export_version,
24
+ export_type: "project",
25
+ projects: [project],
26
+ workflows: await readOrderedEntities(deps.readFile, projectDirPath, state, "workflows"),
27
+ data_tables: await readOrderedEntities(deps.readFile, projectDirPath, state, "data_tables"),
28
+ vector_tables: await readOrderedEntities(deps.readFile, projectDirPath, state, "vector_tables"),
29
+ agents: await readOrderedEntities(deps.readFile, projectDirPath, state, "agents"),
30
+ apim_operations: await readOrderedEntities(deps.readFile, projectDirPath, state, "apim_operations"),
31
+ solution: null,
32
+ };
33
+ return JSON.stringify(exportStructure);
34
+ }
35
+ //# sourceMappingURL=promoteReconstruct.js.map
@@ -0,0 +1,44 @@
1
+ export const ChangeKinds = {
2
+ CREATED: "created",
3
+ UPDATED: "updated",
4
+ REMOVED: "removed",
5
+ };
6
+ export function toProjectImportImpact(projectName, projectId, impact) {
7
+ const { workflows, config } = impact;
8
+ return {
9
+ projectName,
10
+ projectId,
11
+ workflows: [
12
+ ...workflows.created.map((w) => ({ name: w.name, id: w.id, kind: ChangeKinds.CREATED })),
13
+ ...workflows.updated.map((w) => ({ name: w.name, id: w.id, kind: ChangeKinds.UPDATED })),
14
+ ...workflows.removed.map((w) => ({ name: w.name, id: w.id, kind: ChangeKinds.REMOVED })),
15
+ ],
16
+ config: [
17
+ ...config.created.map((c) => ({ name: c.key, kind: ChangeKinds.CREATED })),
18
+ ...config.updated.map((c) => ({ name: c.key, kind: ChangeKinds.UPDATED })),
19
+ ...config.removed.map((c) => ({ name: c.key, kind: ChangeKinds.REMOVED })),
20
+ ],
21
+ };
22
+ }
23
+ export function printProjectImportImpact(stdout, impact) {
24
+ stdout(`${impact.projectName} (${impact.projectId})`);
25
+ if (impact.workflows.length === 0) {
26
+ stdout(" workflows: no changes");
27
+ }
28
+ else {
29
+ stdout(" workflows:");
30
+ for (const w of impact.workflows) {
31
+ stdout(` ${w.kind}: ${w.name}${w.id ? ` (${w.id})` : ""}`);
32
+ }
33
+ }
34
+ if (impact.config.length === 0) {
35
+ stdout(" config: no changes");
36
+ }
37
+ else {
38
+ stdout(" config:");
39
+ for (const c of impact.config) {
40
+ stdout(` ${c.kind}: ${c.name}`);
41
+ }
42
+ }
43
+ }
44
+ //# sourceMappingURL=promoteReport.js.map
@@ -0,0 +1,129 @@
1
+ import { readProjectMappings, writeProjectMappings } from "../config/mappings.js";
2
+ import { projectMappingsPath } from "../config/paths.js";
3
+ import { reconstructExportStructure } from "./promoteReconstruct.js";
4
+ import { isUuid } from "./uuid.js";
5
+ function emptyMapping() {
6
+ return { target_project_id: "", authentications: {}, config: {}, connectors: [], services: [] };
7
+ }
8
+ export async function resolveTargetProjectId(client, options) {
9
+ const mappingsFile = (await readProjectMappings(options.projectDirPath)) ?? { version: 1, environments: {} };
10
+ const mapping = mappingsFile.environments[options.envName] ?? emptyMapping();
11
+ if (mapping.target_project_id) {
12
+ return { status: "resolved", targetProjectId: mapping.target_project_id, mapping };
13
+ }
14
+ if (!options.autoCreateProjects) {
15
+ if (!mappingsFile.environments[options.envName]) {
16
+ mappingsFile.environments[options.envName] = mapping;
17
+ await writeProjectMappings(options.projectDirPath, mappingsFile);
18
+ }
19
+ return { status: "missing", mappingsPath: projectMappingsPath(options.projectDirPath) };
20
+ }
21
+ const targetProjectId = await createProject(client, {
22
+ workspaceId: options.targetWorkspaceId,
23
+ name: options.sourceProjectName,
24
+ });
25
+ const updatedMapping = { ...mapping, target_project_id: targetProjectId };
26
+ mappingsFile.environments[options.envName] = updatedMapping;
27
+ await writeProjectMappings(options.projectDirPath, mappingsFile);
28
+ return { status: "resolved", targetProjectId, mapping: updatedMapping };
29
+ }
30
+ export function toRequestBody(payload) {
31
+ return { ...payload, exportedProjectJson: JSON.parse(payload.exportedProjectJson) };
32
+ }
33
+ export function assembleImportPayload(mapping, exportedProjectJson) {
34
+ return {
35
+ exportedProjectJson,
36
+ authenticationResolution: Object.entries(mapping.authentications).map(([authExportId, authenticationId]) => ({ authExportId, authenticationId })),
37
+ configOverride: mapping.config,
38
+ connectorMapping: mapping.connectors,
39
+ serviceMapping: mapping.services,
40
+ };
41
+ }
42
+ export async function createProject(client, options) {
43
+ const result = (await client.request("POST", "/v2/projects", {
44
+ workspaceId: options.workspaceId,
45
+ name: options.name,
46
+ description: options.description ?? "",
47
+ tags: [],
48
+ workflows: [],
49
+ }));
50
+ return result.id;
51
+ }
52
+ export async function getImportRequirements(client, targetProjectId, payload) {
53
+ return (await client.request("POST", `/v1/projects/${targetProjectId}/imports/requirements`, toRequestBody({
54
+ exportedProjectJson: payload.exportedProjectJson,
55
+ connectorMapping: payload.connectorMapping,
56
+ serviceMapping: payload.serviceMapping,
57
+ })));
58
+ }
59
+ export function findUnresolvedRequirements(requirements, mappedAuthentications = {}) {
60
+ return {
61
+ unresolvedAuthentications: requirements.authenticationsRequirements
62
+ .filter((auth) => {
63
+ if (auth.resolvedAuthentication)
64
+ return false;
65
+ const mapped = mappedAuthentications[auth.authExportId];
66
+ return !(mapped !== undefined && isUuid(mapped));
67
+ })
68
+ .map((auth) => ({ authExportId: auth.authExportId, title: auth.title, service: auth.service })),
69
+ hasNewConfigKeys: requirements.newConfigKeys,
70
+ };
71
+ }
72
+ export function isFullyResolved(unresolved) {
73
+ return unresolved.unresolvedAuthentications.length === 0 && !unresolved.hasNewConfigKeys;
74
+ }
75
+ export const MISSING_TARGET_AUTHENTICATION = "MISSING_TARGET_AUTHENTICATION";
76
+ export async function scaffoldUnresolvedAuthentications(projectDirPath, envName, unresolved) {
77
+ if (unresolved.unresolvedAuthentications.length === 0) {
78
+ return;
79
+ }
80
+ const mappingsFile = (await readProjectMappings(projectDirPath)) ?? { version: 1, environments: {} };
81
+ const mapping = mappingsFile.environments[envName] ?? emptyMapping();
82
+ let changed = false;
83
+ for (const auth of unresolved.unresolvedAuthentications) {
84
+ if (!(auth.authExportId in mapping.authentications)) {
85
+ mapping.authentications[auth.authExportId] = MISSING_TARGET_AUTHENTICATION;
86
+ changed = true;
87
+ }
88
+ }
89
+ if (changed) {
90
+ mappingsFile.environments[envName] = mapping;
91
+ await writeProjectMappings(projectDirPath, mappingsFile);
92
+ }
93
+ }
94
+ export function validateAuthenticationMappings(mapping) {
95
+ return Object.entries(mapping.authentications)
96
+ .filter(([, authenticationId]) => !isUuid(authenticationId))
97
+ .map(([authExportId, value]) => ({ authExportId, value }));
98
+ }
99
+ export async function resolveProjectRequirements(client, deps, options) {
100
+ const targetResolution = await resolveTargetProjectId(client, {
101
+ projectDirPath: options.projectDirPath,
102
+ envName: options.envName,
103
+ targetWorkspaceId: options.targetWorkspaceId,
104
+ sourceProjectName: options.sourceProjectName,
105
+ autoCreateProjects: options.autoCreateProjects,
106
+ });
107
+ if (targetResolution.status === "missing") {
108
+ return { status: "no_target_project_mapped", mappingsPath: targetResolution.mappingsPath };
109
+ }
110
+ if (options.validateAuthMappings ?? true) {
111
+ const invalidAuthMappings = validateAuthenticationMappings(targetResolution.mapping);
112
+ if (invalidAuthMappings.length > 0) {
113
+ return { status: "invalid_auth_mappings", invalidAuthMappings };
114
+ }
115
+ }
116
+ const exportedProjectJson = await reconstructExportStructure(deps, options.projectDirPath, options.state);
117
+ const payload = assembleImportPayload(targetResolution.mapping, exportedProjectJson);
118
+ const requirements = await getImportRequirements(client, targetResolution.targetProjectId, payload);
119
+ const unresolved = findUnresolvedRequirements(requirements, targetResolution.mapping.authentications);
120
+ return {
121
+ status: "resolved",
122
+ targetProjectId: targetResolution.targetProjectId,
123
+ mapping: targetResolution.mapping,
124
+ exportedProjectJson,
125
+ payload,
126
+ unresolved,
127
+ };
128
+ }
129
+ //# sourceMappingURL=promoteTarget.js.map
@@ -0,0 +1,26 @@
1
+ import { Regions } from "../config/types.js";
2
+ const REGIONS = Object.values(Regions);
3
+ function buildRegionUrls(region) {
4
+ const domain = region === Regions.US1 ? "tray.io" : `${region}.tray.io`;
5
+ return {
6
+ apiBaseUrl: `https://api.${domain}`,
7
+ graphqlUrl: `https://${domain}/graphql`,
8
+ weaverUrl: `https://weaver.${domain}`,
9
+ };
10
+ }
11
+ const REGION_URLS = Object.fromEntries(REGIONS.map((region) => [region, buildRegionUrls(region)]));
12
+ export function urlsForRegion(region) {
13
+ return REGION_URLS[region];
14
+ }
15
+ export const ALLOWED_HOSTS = new Set(Object.values(REGION_URLS).flatMap(({ apiBaseUrl, graphqlUrl, weaverUrl }) => [apiBaseUrl, graphqlUrl, weaverUrl].map((url) => new URL(url).host)));
16
+ export function isAllowedUrl(url) {
17
+ let parsed;
18
+ try {
19
+ parsed = new URL(url);
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ return parsed.protocol === "https:" && ALLOWED_HOSTS.has(parsed.host);
25
+ }
26
+ //# sourceMappingURL=region.js.map
@@ -0,0 +1,11 @@
1
+ const REGION_LABELS = {
2
+ us1: "USA",
3
+ eu1: "EMEA",
4
+ ap1: "APAC",
5
+ ap2: "JPN",
6
+ staging: "Staging",
7
+ };
8
+ export function describeRegion(region) {
9
+ return `${region} (${REGION_LABELS[region]})`;
10
+ }
11
+ //# sourceMappingURL=regionDisplay.js.map
@@ -0,0 +1,12 @@
1
+ import { InvalidArgumentError } from "commander";
2
+ import { Regions } from "../config/types.js";
3
+ import { describeRegion } from "./regionDisplay.js";
4
+ export const REGIONS = Object.values(Regions);
5
+ export const PUBLIC_REGIONS = REGIONS.filter((region) => region !== Regions.STAGING);
6
+ export function parseRegion(value) {
7
+ if (!REGIONS.includes(value)) {
8
+ throw new InvalidArgumentError(`region must be one of: ${PUBLIC_REGIONS.map(describeRegion).join(", ")}`);
9
+ }
10
+ return value;
11
+ }
12
+ //# sourceMappingURL=regionParsing.js.map
@@ -0,0 +1,46 @@
1
+ import { slugify } from "./slug.js";
2
+ const CONNECTORS = {
3
+ "python-script": { extension: "py", commentPrefix: "#" },
4
+ script: { extension: "js", commentPrefix: "//" },
5
+ };
6
+ function banner(commentPrefix, workflowJsonPath, stepKey) {
7
+ return (`${commentPrefix} --- extracted by tray-sync-cli; edits here do NOT sync back to Tray ---\n` +
8
+ `${commentPrefix} Source of truth: ${workflowJsonPath} (steps["${stepKey}"].properties.script.value)\n`);
9
+ }
10
+ export function extractScripts(workflow) {
11
+ const steps = workflow.steps;
12
+ if (typeof steps !== "object" || steps === null) {
13
+ return [];
14
+ }
15
+ const extracted = [];
16
+ for (const [stepKey, step] of Object.entries(steps)) {
17
+ if (typeof step !== "object" || step === null)
18
+ continue;
19
+ const connector = step.connector;
20
+ const connectorName = typeof connector === "object" && connector !== null
21
+ ? connector.name
22
+ : undefined;
23
+ if (typeof connectorName !== "string")
24
+ continue;
25
+ const language = CONNECTORS[connectorName];
26
+ if (!language)
27
+ continue;
28
+ const properties = step.properties;
29
+ if (typeof properties !== "object" || properties === null)
30
+ continue;
31
+ const script = properties.script;
32
+ if (typeof script !== "object" || script === null)
33
+ continue;
34
+ const value = script.value;
35
+ if (typeof value !== "string")
36
+ continue;
37
+ const title = typeof step.title === "string"
38
+ ? step.title
39
+ : "";
40
+ const fileName = `${slugify(stepKey)}--${slugify(title)}.${language.extension}`;
41
+ const content = `${banner(language.commentPrefix, "../workflow.json", stepKey)}\n${value}\n`;
42
+ extracted.push({ stepKey, fileName, content });
43
+ }
44
+ return extracted;
45
+ }
46
+ //# sourceMappingURL=scriptExtraction.js.map
@@ -0,0 +1,14 @@
1
+ const MAX_SLUG_LENGTH = 40;
2
+ export function slugify(name) {
3
+ const slug = name
4
+ .toLowerCase()
5
+ .replace(/[^a-z0-9]+/g, "-")
6
+ .replace(/^-+|-+$/g, "")
7
+ .slice(0, MAX_SLUG_LENGTH)
8
+ .replace(/-+$/, "");
9
+ return slug === "" ? "unnamed" : slug;
10
+ }
11
+ export function entityDirName(uuid, name) {
12
+ return `${uuid}--${slugify(name)}`;
13
+ }
14
+ //# sourceMappingURL=slug.js.map
@@ -0,0 +1,19 @@
1
+ const SOURCES_DESCRIPTION = "--token flag, ~/.tray/credentials.json, TRAY_API_TOKEN_<ENV>, or TRAY_API_TOKEN";
2
+ export function resolveToken(options) {
3
+ const { tokenFlag, credentials, workspaceId, envName, env = process.env } = options;
4
+ if (tokenFlag)
5
+ return tokenFlag;
6
+ const credentialsToken = credentials.workspaces[workspaceId]?.token;
7
+ if (credentialsToken)
8
+ return credentialsToken;
9
+ if (envName) {
10
+ const envVarName = `TRAY_API_TOKEN_${envName.toUpperCase().replace(/-/g, "_")}`;
11
+ const envToken = env[envVarName];
12
+ if (envToken)
13
+ return envToken;
14
+ }
15
+ if (env.TRAY_API_TOKEN)
16
+ return env.TRAY_API_TOKEN;
17
+ throw new Error(`No Tray API token found for workspace "${workspaceId}". Provide one via: ${SOURCES_DESCRIPTION}.`);
18
+ }
19
+ //# sourceMappingURL=tokenResolution.js.map
@@ -0,0 +1,5 @@
1
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2
+ export function isUuid(value) {
3
+ return UUID_RE.test(value);
4
+ }
5
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1,89 @@
1
+ export function printInvalidEnvName(stderr, nameRe, name) {
2
+ stderr(`Environment name must match ${nameRe}: "${name}"`);
3
+ }
4
+ export function printEnvAlreadyExists(stderr, name) {
5
+ stderr(`Environment "${name}" already exists. Run \`tray env remove\` first to replace it.`);
6
+ }
7
+ export function printAddedEnvironment(stdout, name, regionDescription, workspaceId) {
8
+ stdout(`Added environment "${name}" (${regionDescription}, workspace ${workspaceId}).`);
9
+ }
10
+ export function printTokenNotSaved(stderr, workspaceId) {
11
+ stderr(`⚠️ --token was NOT saved: credentials.json already has a token for workspace ${workspaceId}, and the existing one was kept.\n` +
12
+ ` Re-run this same \`tray env add\` command with --force-token to replace it with the --token you just provided.`);
13
+ }
14
+ export function printNoTokenSkippingConnectivity(stdout) {
15
+ stdout("No token available — skipping connectivity check.");
16
+ }
17
+ export function printConnectivityCheck(stdout, description) {
18
+ stdout(`Connectivity check: ${description}`);
19
+ }
20
+ export function printTrayYamlNotFound(stderr) {
21
+ stderr("tray.yaml not found. Run `tray init` first.");
22
+ }
23
+ export function printSourceEnvHeader(stdout) {
24
+ stdout("SOURCE ENV:");
25
+ }
26
+ export function printSourceEnvLine(stdout, regionDescription, workspaceId, connectivityDescription) {
27
+ stdout(` source (${regionDescription}, workspace ${workspaceId}): ${connectivityDescription}`);
28
+ }
29
+ export function printTargetEnvHeader(stdout) {
30
+ stdout("");
31
+ stdout("TARGET ENV:");
32
+ }
33
+ export function printNoTargetEnvironments(stdout) {
34
+ stdout(" No target environments configured.");
35
+ }
36
+ export function printTargetEnvLine(stdout, name, regionDescription, workspaceId, connectivityDescription) {
37
+ stdout(` ${name} (${regionDescription}, workspace ${workspaceId}): ${connectivityDescription}`);
38
+ }
39
+ export function printEnvNotConfigured(stdout, name) {
40
+ stdout(`Environment "${name}" is not configured. Nothing to remove.`);
41
+ }
42
+ export function printRemovedEnvironment(stdout, name) {
43
+ stdout(`Removed environment "${name}" from environments.json.`);
44
+ }
45
+ export function printRemovedMapping(stdout, name, dirName) {
46
+ stdout(`Removed "${name}" mapping from ${dirName}/mappings.json.`);
47
+ }
48
+ export function printRemovedCredentials(stdout, workspaceId) {
49
+ stdout(`Removed credentials for workspace ${workspaceId}.`);
50
+ }
51
+ export function printEnvResolveProjectFullyResolved(stdout, projectId, sourceProjectName) {
52
+ stdout(`${sourceProjectName} (${projectId}): fully resolved, nothing to do`);
53
+ }
54
+ export function printEnvResolveProjectError(stdout, projectId, sourceProjectName, error) {
55
+ stdout(`${sourceProjectName} (${projectId}):`);
56
+ if (error.reason === "no_target_project_mapped") {
57
+ stdout(` no target project mapped yet — see ${error.mappingsPath}`);
58
+ return;
59
+ }
60
+ if (error.reason === "project_error") {
61
+ const target = error.targetProjectId ? ` (target project ${error.targetProjectId})` : "";
62
+ stdout(` ${error.message}${target}`);
63
+ return;
64
+ }
65
+ stdout(` invalid authentication mappings:`);
66
+ for (const invalid of error.invalidAuthMappings) {
67
+ stdout(` ${invalid.authExportId}: "${invalid.value}" is not a valid target authentication id`);
68
+ }
69
+ }
70
+ export function printEnvResolveProject(stdout, project) {
71
+ stdout(`${project.sourceProjectName} (${project.projectId}):`);
72
+ for (const auth of project.autoResolvedAuthentications) {
73
+ stdout(` auto-resolved: ${auth.title} -> "${auth.chosen.name}" (id: ${auth.chosen.id}, ${auth.chosen.matchKind} match), written to mappings.json`);
74
+ }
75
+ for (const auth of project.unresolvedAuthentications) {
76
+ stdout(` unresolved: ${auth.title} (${auth.service.name} v${auth.service.version})`);
77
+ if (auth.candidates.length === 0) {
78
+ stdout(` no candidates found in the target workspace`);
79
+ }
80
+ for (const candidate of auth.candidates) {
81
+ stdout(` candidate (${candidate.matchKind}): "${candidate.name}" (id: ${candidate.id}, created ${candidate.created})`);
82
+ }
83
+ stdout(` to resolve: set mappings.json's environments.<env>.authentications["${auth.authExportId}"] to a target auth id${auth.candidates.length > 0 ? ", or re-run with --auto-resolve to pick the top candidate automatically" : ""}`);
84
+ }
85
+ if (project.hasNewConfigKeys) {
86
+ stdout(` new config keys require mapping — see mappings.json's config entry`);
87
+ }
88
+ }
89
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1,7 @@
1
+ export function printEnvListJson(stdout, data) {
2
+ stdout(JSON.stringify(data));
3
+ }
4
+ export function printEnvResolveResultJson(stdout, result) {
5
+ stdout(JSON.stringify(result));
6
+ }
7
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1,17 @@
1
+ export function printTrayYamlAlreadyExists(stderr) {
2
+ stderr("tray.yaml already exists in this directory. Refusing to overwrite.");
3
+ }
4
+ export function printTokenNotSaved(stderr, workspaceId, region) {
5
+ stderr(`⚠️ --token was NOT saved: credentials.json already has a token for workspace ${workspaceId}, and the existing one was kept.\n` +
6
+ ` tray.yaml has already been written, so \`tray init\` can't be re-run here — use \`tray env add <name> --region ${region} --workspace-id ${workspaceId} --token <token> --force-token\` to replace it, or edit ~/.tray/credentials.json directly.`);
7
+ }
8
+ export function printNoTokenSkippingConnectivityAndPull(stdout) {
9
+ stdout("No token available — skipping connectivity check and pull.");
10
+ }
11
+ export function printConnectivityCheckSucceeded(stdout) {
12
+ stdout("Connectivity check: ✓");
13
+ }
14
+ export function printConnectivityCheckFailed(stdout, message) {
15
+ stdout(`Connectivity check: ✗ (${message})`);
16
+ }
17
+ //# sourceMappingURL=init.js.map