fjall 0.95.0 → 0.99.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 (228) hide show
  1. package/bin/.bundled +3 -3
  2. package/bin/.metafile.json +7569 -4226
  3. package/bin/assets/generators/application/generator.js +1 -1
  4. package/bin/assets/generators/compute/generator.js +1 -1
  5. package/bin/assets/generators/compute/service/generator.js +1 -1
  6. package/bin/assets/generators/database/generator.js +1 -1
  7. package/bin/assets/generators/domain/generator.js +2 -2
  8. package/bin/assets/generators/organisation/files/organisation/infrastructure.ts +8 -2
  9. package/bin/assets/generators/shared/files/cdk.json +1 -1
  10. package/bin/assets/generators/shared/files/package.json +8 -7
  11. package/bin/assets/generators/shared/files/tsconfig.json +5 -4
  12. package/bin/assets/generators/utils/integrationTestUtils.d.ts +9 -0
  13. package/bin/assets/generators/utils/integrationTestUtils.js +4 -2
  14. package/bin/assets/generators/utils/planning/generatorHelpers.js +2 -2
  15. package/bin/assets/src/util/__tests__/fjallApiClientTestHelpers.d.ts +9 -0
  16. package/bin/assets/src/util/__tests__/fjallApiClientTestHelpers.js +1 -0
  17. package/bin/assets/src/util/__tests__/outputTestHelpers.d.ts +9 -0
  18. package/bin/assets/src/util/__tests__/outputTestHelpers.js +1 -0
  19. package/bin/assets/src/util/agent/__tests__/toonTestHelpers.d.ts +91 -0
  20. package/bin/assets/src/util/agent/__tests__/toonTestHelpers.js +1 -0
  21. package/bin/assets/src/util/agent/actionRequired.d.ts +60 -0
  22. package/bin/assets/src/util/agent/actionRequired.js +1 -0
  23. package/bin/assets/src/util/agent/agentCallbacks.d.ts +21 -0
  24. package/bin/assets/src/util/agent/agentCallbacks.js +1 -0
  25. package/bin/assets/src/util/agent/agentInit.d.ts +17 -0
  26. package/bin/assets/src/util/agent/agentInit.js +288 -0
  27. package/bin/assets/src/util/agent/agentOutput.d.ts +61 -0
  28. package/bin/assets/src/util/agent/agentOutput.js +8 -0
  29. package/bin/assets/src/util/agent/budget.d.ts +19 -0
  30. package/bin/assets/src/util/agent/budget.js +4 -0
  31. package/bin/assets/src/util/agent/detectAgent.d.ts +51 -0
  32. package/bin/assets/src/util/agent/detectAgent.js +1 -0
  33. package/bin/assets/src/util/agent/errorCodeMap.d.ts +16 -0
  34. package/bin/assets/src/util/agent/errorCodeMap.js +1 -0
  35. package/bin/assets/src/util/agent/errorCodes.d.ts +48 -0
  36. package/bin/assets/src/util/agent/errorCodes.js +1 -0
  37. package/bin/assets/src/util/agent/fieldSelection.d.ts +22 -0
  38. package/bin/assets/src/util/agent/fieldSelection.js +1 -0
  39. package/bin/assets/src/util/agent/getSurface.d.ts +27 -0
  40. package/bin/assets/src/util/agent/getSurface.js +1 -0
  41. package/bin/assets/src/util/agent/index.d.ts +27 -0
  42. package/bin/assets/src/util/agent/index.js +1 -0
  43. package/bin/assets/src/util/agent/mcpProtocolEmit.d.ts +31 -0
  44. package/bin/assets/src/util/agent/mcpProtocolEmit.js +2 -0
  45. package/bin/assets/src/util/agent/schemas/appsSchemas.d.ts +18 -0
  46. package/bin/assets/src/util/agent/schemas/appsSchemas.js +1 -0
  47. package/bin/assets/src/util/agent/schemas/assetSchemas.d.ts +13 -0
  48. package/bin/assets/src/util/agent/schemas/assetSchemas.js +1 -0
  49. package/bin/assets/src/util/agent/schemas/awsSchemas.d.ts +5 -0
  50. package/bin/assets/src/util/agent/schemas/awsSchemas.js +1 -0
  51. package/bin/assets/src/util/agent/schemas/deploySchemas.d.ts +8 -0
  52. package/bin/assets/src/util/agent/schemas/deploySchemas.js +1 -0
  53. package/bin/assets/src/util/agent/schemas/index.d.ts +10 -0
  54. package/bin/assets/src/util/agent/schemas/index.js +1 -0
  55. package/bin/assets/src/util/agent/schemas/infraSchemas.d.ts +45 -0
  56. package/bin/assets/src/util/agent/schemas/infraSchemas.js +1 -0
  57. package/bin/assets/src/util/agent/schemas/secretsSchemas.d.ts +13 -0
  58. package/bin/assets/src/util/agent/schemas/secretsSchemas.js +1 -0
  59. package/bin/assets/src/util/agent/schemas/types.d.ts +98 -0
  60. package/bin/assets/src/util/agent/schemas/types.js +0 -0
  61. package/bin/assets/src/util/agent/schemas/userSchemas.d.ts +21 -0
  62. package/bin/assets/src/util/agent/schemas/userSchemas.js +1 -0
  63. package/bin/assets/src/util/agent/sessionHooks.d.ts +47 -0
  64. package/bin/assets/src/util/agent/sessionHooks.js +6 -0
  65. package/bin/assets/src/util/agent/streaming.d.ts +51 -0
  66. package/bin/assets/src/util/agent/streaming.js +1 -0
  67. package/bin/assets/src/util/agent/suggestionEntries/coreEntries.d.ts +2 -0
  68. package/bin/assets/src/util/agent/suggestionEntries/coreEntries.js +1 -0
  69. package/bin/assets/src/util/agent/suggestionEntries/identityEntries.d.ts +2 -0
  70. package/bin/assets/src/util/agent/suggestionEntries/identityEntries.js +1 -0
  71. package/bin/assets/src/util/agent/suggestionEntries/index.d.ts +3 -0
  72. package/bin/assets/src/util/agent/suggestionEntries/index.js +1 -0
  73. package/bin/assets/src/util/agent/suggestionEntries/infraEntries.d.ts +2 -0
  74. package/bin/assets/src/util/agent/suggestionEntries/infraEntries.js +1 -0
  75. package/bin/assets/src/util/agent/suggestionEntries/observabilityEntries.d.ts +2 -0
  76. package/bin/assets/src/util/agent/suggestionEntries/observabilityEntries.js +1 -0
  77. package/bin/assets/src/util/agent/suggestionEntries/secretsEntries.d.ts +2 -0
  78. package/bin/assets/src/util/agent/suggestionEntries/secretsEntries.js +1 -0
  79. package/bin/assets/src/util/agent/suggestionEntries/types.d.ts +17 -0
  80. package/bin/assets/src/util/agent/suggestionEntries/types.js +1 -0
  81. package/bin/assets/src/util/agent/suggestions.d.ts +30 -0
  82. package/bin/assets/src/util/agent/suggestions.js +1 -0
  83. package/bin/assets/src/util/agent/tokenScopes.d.ts +24 -0
  84. package/bin/assets/src/util/agent/tokenScopes.js +1 -0
  85. package/bin/assets/src/util/agent/toonFormatter.d.ts +55 -0
  86. package/bin/assets/src/util/agent/toonFormatter.js +14 -0
  87. package/bin/assets/src/util/api/Credentials.d.ts +13 -0
  88. package/bin/assets/src/util/api/Credentials.js +1 -0
  89. package/bin/assets/src/util/api/FjallApiClient.d.ts +33 -0
  90. package/bin/assets/src/util/api/FjallApiClient.js +1 -0
  91. package/bin/assets/src/util/api/FjallApiClient.types.d.ts +375 -0
  92. package/bin/assets/src/util/api/FjallApiClient.types.js +1 -0
  93. package/bin/assets/src/util/api/FjallApiClientBase.d.ts +13 -0
  94. package/bin/assets/src/util/api/FjallApiClientBase.js +1 -0
  95. package/bin/assets/src/util/api/FjallApiClientDeviceCode.d.ts +13 -0
  96. package/bin/assets/src/util/api/FjallApiClientDeviceCode.js +1 -0
  97. package/bin/assets/src/util/api/FjallApiClientErrors.d.ts +5 -0
  98. package/bin/assets/src/util/api/FjallApiClientErrors.js +1 -0
  99. package/bin/assets/src/util/api/FjallApiClientResources.d.ts +45 -0
  100. package/bin/assets/src/util/api/FjallApiClientResources.js +1 -0
  101. package/bin/assets/src/util/api/index.d.ts +7 -0
  102. package/bin/assets/src/util/api/index.js +1 -0
  103. package/bin/assets/src/util/api/resolveApiKey.d.ts +1 -0
  104. package/bin/assets/src/util/api/resolveApiKey.js +1 -0
  105. package/bin/assets/src/util/api/scaffoldNotification.d.ts +2 -0
  106. package/bin/assets/src/util/api/scaffoldNotification.js +1 -0
  107. package/bin/assets/src/util/awsCleanup.d.ts +9 -0
  108. package/bin/assets/src/util/awsCleanup.js +1 -0
  109. package/bin/assets/src/util/awsTags.d.ts +19 -0
  110. package/bin/assets/src/util/awsTags.js +1 -0
  111. package/bin/assets/src/util/buildxEventAdapter.d.ts +20 -0
  112. package/bin/assets/src/util/buildxEventAdapter.js +1 -0
  113. package/bin/assets/src/util/caseConversion.d.ts +1 -0
  114. package/bin/assets/src/util/caseConversion.js +1 -0
  115. package/bin/assets/src/util/codemod/emitCliTelemetry.d.ts +32 -0
  116. package/bin/assets/src/util/codemod/emitCliTelemetry.js +1 -0
  117. package/bin/assets/src/util/codemod/exitCodes.d.ts +11 -0
  118. package/bin/assets/src/util/codemod/exitCodes.js +1 -0
  119. package/bin/assets/src/util/codemod/index.d.ts +3 -0
  120. package/bin/assets/src/util/codemod/index.js +1 -0
  121. package/bin/assets/src/util/codemod/renderCodemod.d.ts +5 -0
  122. package/bin/assets/src/util/codemod/renderCodemod.js +1 -0
  123. package/bin/assets/src/util/codemod/stepLabels.d.ts +11 -0
  124. package/bin/assets/src/util/codemod/stepLabels.js +1 -0
  125. package/bin/assets/src/util/colourUtils.d.ts +21 -0
  126. package/bin/assets/src/util/colourUtils.js +1 -0
  127. package/bin/assets/src/util/commandErrorHandler.d.ts +16 -0
  128. package/bin/assets/src/util/commandErrorHandler.js +1 -0
  129. package/bin/assets/src/util/commandResult.d.ts +63 -0
  130. package/bin/assets/src/util/commandResult.js +1 -0
  131. package/bin/assets/src/util/concurrency.d.ts +35 -0
  132. package/bin/assets/src/util/concurrency.js +1 -0
  133. package/bin/assets/src/util/deploymentEvents.d.ts +155 -0
  134. package/bin/assets/src/util/deploymentEvents.js +1 -0
  135. package/bin/assets/src/util/errorDisplay.d.ts +4 -0
  136. package/bin/assets/src/util/errorDisplay.js +2 -0
  137. package/bin/assets/src/util/errorUtils.d.ts +1 -0
  138. package/bin/assets/src/util/errorUtils.js +1 -0
  139. package/bin/assets/src/util/executionMode.d.ts +18 -0
  140. package/bin/assets/src/util/executionMode.js +1 -0
  141. package/bin/assets/src/util/formatDeltaValue.d.ts +1 -0
  142. package/bin/assets/src/util/formatDeltaValue.js +1 -0
  143. package/bin/assets/src/util/formatDuration.d.ts +1 -0
  144. package/bin/assets/src/util/formatDuration.js +1 -0
  145. package/bin/assets/src/util/formatRelativeTime.d.ts +1 -0
  146. package/bin/assets/src/util/formatRelativeTime.js +1 -0
  147. package/bin/assets/src/util/fuzzyMatch.d.ts +38 -0
  148. package/bin/assets/src/util/fuzzyMatch.js +1 -0
  149. package/bin/assets/src/util/gitDetection.d.ts +8 -0
  150. package/bin/assets/src/util/gitDetection.js +1 -0
  151. package/bin/assets/src/util/index.d.ts +50 -0
  152. package/bin/assets/src/util/index.js +1 -0
  153. package/bin/assets/src/util/log.d.ts +29 -0
  154. package/bin/assets/src/util/log.js +4 -0
  155. package/bin/assets/src/util/logger/CorrelatedLogger.d.ts +15 -0
  156. package/bin/assets/src/util/logger/CorrelatedLogger.js +1 -0
  157. package/bin/assets/src/util/logger/DeploymentLogger.d.ts +33 -0
  158. package/bin/assets/src/util/logger/DeploymentLogger.js +2 -0
  159. package/bin/assets/src/util/logger/FileRotator.d.ts +17 -0
  160. package/bin/assets/src/util/logger/FileRotator.js +1 -0
  161. package/bin/assets/src/util/logger/LogFileWriter.d.ts +54 -0
  162. package/bin/assets/src/util/logger/LogFileWriter.js +4 -0
  163. package/bin/assets/src/util/logger/Logger.d.ts +43 -0
  164. package/bin/assets/src/util/logger/Logger.js +1 -0
  165. package/bin/assets/src/util/logger/index.d.ts +15 -0
  166. package/bin/assets/src/util/logger/index.js +2 -0
  167. package/bin/assets/src/util/logger/logDir.d.ts +5 -0
  168. package/bin/assets/src/util/logger/logDir.js +1 -0
  169. package/bin/assets/src/util/logger/types.d.ts +48 -0
  170. package/bin/assets/src/util/logger/types.js +1 -0
  171. package/bin/assets/src/util/nonInteractive/index.d.ts +3 -0
  172. package/bin/assets/src/util/nonInteractive/index.js +1 -0
  173. package/bin/assets/src/util/nonInteractive/nonInteractiveCallbacks.d.ts +18 -0
  174. package/bin/assets/src/util/nonInteractive/nonInteractiveCallbacks.js +1 -0
  175. package/bin/assets/src/util/nonInteractive/nonInteractiveCascadeOutput.d.ts +51 -0
  176. package/bin/assets/src/util/nonInteractive/nonInteractiveCascadeOutput.js +1 -0
  177. package/bin/assets/src/util/nonInteractive/nonInteractiveLabels.d.ts +23 -0
  178. package/bin/assets/src/util/nonInteractive/nonInteractiveLabels.js +1 -0
  179. package/bin/assets/src/util/nonInteractive/nonInteractiveOutput.d.ts +128 -0
  180. package/bin/assets/src/util/nonInteractive/nonInteractiveOutput.js +4 -0
  181. package/bin/assets/src/util/nonInteractive/nonInteractiveSummaryOutput.d.ts +29 -0
  182. package/bin/assets/src/util/nonInteractive/nonInteractiveSummaryOutput.js +3 -0
  183. package/bin/assets/src/util/organisationStructure.d.ts +9 -0
  184. package/bin/assets/src/util/organisationStructure.js +1 -0
  185. package/bin/assets/src/util/parseTakeOption.d.ts +1 -0
  186. package/bin/assets/src/util/parseTakeOption.js +1 -0
  187. package/bin/assets/src/util/passwordValidation.d.ts +22 -0
  188. package/bin/assets/src/util/passwordValidation.js +1 -0
  189. package/bin/assets/src/util/pathHelpers.d.ts +19 -0
  190. package/bin/assets/src/util/pathHelpers.js +1 -0
  191. package/bin/assets/src/util/patternDetection.d.ts +7 -0
  192. package/bin/assets/src/util/patternDetection.js +1 -0
  193. package/bin/assets/src/util/promptYesNo.d.ts +5 -0
  194. package/bin/assets/src/util/promptYesNo.js +1 -0
  195. package/bin/assets/src/util/readStdin.d.ts +9 -0
  196. package/bin/assets/src/util/readStdin.js +1 -0
  197. package/bin/assets/src/util/secretsUtils.d.ts +155 -0
  198. package/bin/assets/src/util/secretsUtils.js +3 -0
  199. package/bin/assets/src/util/signalCleanup.d.ts +13 -0
  200. package/bin/assets/src/util/signalCleanup.js +4 -0
  201. package/bin/assets/src/util/stripAnsi.d.ts +2 -0
  202. package/bin/assets/src/util/stripAnsi.js +1 -0
  203. package/bin/assets/src/util/synchronizedOutput.d.ts +26 -0
  204. package/bin/assets/src/util/synchronizedOutput.js +1 -0
  205. package/bin/assets/src/util/targetDetection.d.ts +27 -0
  206. package/bin/assets/src/util/targetDetection.js +1 -0
  207. package/bin/assets/src/util/targetHelpers.d.ts +20 -0
  208. package/bin/assets/src/util/targetHelpers.js +1 -0
  209. package/bin/assets/src/util/terminalCapabilities.d.ts +21 -0
  210. package/bin/assets/src/util/terminalCapabilities.js +1 -0
  211. package/bin/assets/src/util/terminalEscapes.d.ts +29 -0
  212. package/bin/assets/src/util/terminalEscapes.js +1 -0
  213. package/bin/assets/src/util/terminalFocus.d.ts +33 -0
  214. package/bin/assets/src/util/terminalFocus.js +1 -0
  215. package/bin/assets/src/util/theme.d.ts +80 -0
  216. package/bin/assets/src/util/theme.js +1 -0
  217. package/bin/assets/src/util/truncateMiddle.d.ts +9 -0
  218. package/bin/assets/src/util/truncateMiddle.js +1 -0
  219. package/bin/assets/src/util/typeGuards.d.ts +5 -0
  220. package/bin/assets/src/util/typeGuards.js +1 -0
  221. package/bin/assets/src/util/uiRouter.d.ts +13 -0
  222. package/bin/assets/src/util/uiRouter.js +1 -0
  223. package/bin/assets/src/util/urlHelpers.d.ts +4 -0
  224. package/bin/assets/src/util/urlHelpers.js +1 -0
  225. package/bin/assets/src/util/versionDisplay.d.ts +5 -0
  226. package/bin/assets/src/util/versionDisplay.js +1 -0
  227. package/bin/fjall.bundle.js +761 -550
  228. package/package.json +38 -35
@@ -0,0 +1 @@
1
+ const r={"apps list":["read"],"apps describe":["read"],"apps create":["write"],status:["read"],deploy:["deploy"],destroy:["destroy"],build:["deploy"],"secrets list":["secrets:read"],"secrets get":["secrets:read"],"secrets set":["secrets:write"],"secrets delete":["secrets:write"],"secrets import":["secrets:write"],"secrets export":["secrets:read"],"secrets exec":["secrets:read"],connect:["write"],login:["read"],list:["read"],add:["write"],remove:["write"],modify:["write"],undo:["write"],validate:["read"],history:["read"],tunnel:["read"],"target list":["read"],"target get":["read"],"target set":["write"],"domain list":["read"],"domain verify":["read"],"domain export":["read"],"domain import":["write"],"create domain":["write"],"create account":["write"],"create org":["write"],restore:["write"],import:["write"],sync:["write"],"user list":["read"],"user create":["admin"],"user destroy":["admin"],"user associate":["admin"],"user dissociate":["admin"],"token create":["admin"],"token list":["read"],"token revoke":["admin"],"costs show":["read"],"metrics show":["read"],"compliance fix":["read"],"deploy diff":["read"],"deploy logs":["read"],"aws exec":["read"]};function t(e){return r[e]}export{r as COMMAND_SCOPES,t as getRequiredScopes};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Centralised TOON rendering wrapper for AXI agent output. This is the ONLY
3
+ * file in the codebase that imports from `@toon-format/toon`. All TOON
4
+ * rendering is funnelled here so the library can be swapped without touching
5
+ * callers.
6
+ *
7
+ * Masking is NOT this file's responsibility — the AgentOutputWriter masks
8
+ * before calling the formatter. The formatter renders whatever it receives.
9
+ */
10
+ import type { AgentError, ActionRequired, StreamEvent, TabularSchema } from "./schemas/types.js";
11
+ export declare const BLOCK_SEPARATOR = "---";
12
+ /**
13
+ * Render a single object as TOON key-value pairs.
14
+ * Empty objects produce an empty string.
15
+ */
16
+ export declare function renderObject(obj: unknown): string;
17
+ /**
18
+ * Render a tabular array with header row and optional aggregates.
19
+ *
20
+ * Each item is projected through `schema.project()` to guarantee uniform
21
+ * flat rows, which triggers TOON's tabular encoding path.
22
+ */
23
+ export declare function renderList<T>(items: readonly T[], schema: TabularSchema<T>, meta?: {
24
+ entity: string;
25
+ aggregates?: Record<string, number | string>;
26
+ }): string;
27
+ /**
28
+ * Render a structured error block. Uses manual rendering (not `encode()`)
29
+ * because AXI format has `error:` as a top-level key, not wrapped in an
30
+ * object.
31
+ */
32
+ export declare function renderError(error: AgentError): string;
33
+ /**
34
+ * Render an action-required block. Manual rendering like error, plus
35
+ * optional `choices[N]:` and details.
36
+ */
37
+ export declare function renderActionRequired(action: ActionRequired): string;
38
+ /**
39
+ * Render help lines manually. TOON would inline scalar arrays as
40
+ * `help[3]: a,b,c` on one line, but AXI requires each help line on its
41
+ * own indented row.
42
+ */
43
+ export declare function renderHelp(lines: readonly string[]): string;
44
+ /**
45
+ * Render a single streaming event.
46
+ *
47
+ * - Primitive value: `<operation>.<field>: <value>`
48
+ * - Object/array value: delegate to `encode()`
49
+ */
50
+ export declare function renderEvent(event: StreamEvent): string;
51
+ /**
52
+ * Join multiple rendered blocks with the block separator.
53
+ * Empty strings are filtered out. Result ends with exactly one newline.
54
+ */
55
+ export declare function joinBlocks(blocks: readonly string[]): string;
@@ -0,0 +1,14 @@
1
+ import{encode as o}from"@toon-format/toon";const p="---";function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}function c(e){return o(e)}function $(e){return f(e)?o(e):""}function m(e,n,t){const i=t?.entity??"items",r=e.map(u=>n.project(u)),d={[i]:r,...t?.aggregates??{}};return o(d)}function y(e){const n=[];if(n.push(`error: ${s(e.message)}`),n.push(`code: ${e.code}`),e.userActionRequired!==void 0&&n.push(`userActionRequired: ${e.userActionRequired}`),e.details!==void 0&&Object.keys(e.details).length>0){const i=c(e.details).split(`
2
+ `).map(r=>` ${r}`).join(`
3
+ `);n.push("details:"),n.push(i)}return n.join(`
4
+ `)}function j(e){const n=[];if(n.push(`action: ${s(e.action)}`),n.push(`message: ${s(e.message)}`),n.push(`userActionRequired: ${e.userActionRequired}`),e.choices!==void 0&&e.choices.length>0){n.push(`choices[${e.choices.length}]:`);for(const t of e.choices)n.push(` ${t}`)}if(e.details!==void 0&&Object.keys(e.details).length>0){const i=c(e.details).split(`
5
+ `).map(r=>` ${r}`).join(`
6
+ `);n.push("details:"),n.push(i)}return n.join(`
7
+ `)}function a(e){const n=`help[${e.length}]:`;if(e.length===0)return n;const t=e.map(i=>` ${i}`);return[n,...t].join(`
8
+ `)}function A(e){const n=`${e.operation}.${e.field}`;return h(e.value)?`${n}: ${l(e.value)}
9
+ `:o({[n]:e.value})+`
10
+ `}function R(e){const n=e.filter(i=>i.length>0);if(n.length===0)return"";const t=n.join(`
11
+ ${p}
12
+ `);return t.endsWith(`
13
+ `)?t:t+`
14
+ `}function h(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function l(e){return e===null?"null":typeof e=="string"?s(e):String(e)}function s(e){return e.includes(":")||e.includes(",")||e.includes('"')?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}export{p as BLOCK_SEPARATOR,R as joinBlocks,j as renderActionRequired,y as renderError,A as renderEvent,a as renderHelp,m as renderList,$ as renderObject};
@@ -0,0 +1,13 @@
1
+ export default class Credentials {
2
+ apiKey: string | null;
3
+ constructor(apiKey?: string);
4
+ setApiKey(value: string): void;
5
+ toObject(): {
6
+ apiKey: string | null;
7
+ };
8
+ saveCredentials(): void;
9
+ static directoryPath(): string;
10
+ static filePath(): string;
11
+ static loadCredentials(): Credentials | null;
12
+ private static loadCredentialFile;
13
+ }
@@ -0,0 +1 @@
1
+ import*as r from"fs";import{homedir as p}from"os";import{join as a}from"path";import{getErrorMessage as s}from"../errorUtils.js";import{logger as c}from"../logger/index.js";import{maskSensitiveOutput as l}from"@fjall/util";function u(n){return typeof n=="object"&&n!==null&&"apiKey"in n&&typeof n.apiKey=="string"}class e{apiKey;constructor(t){this.apiKey=t||null}setApiKey(t){this.apiKey=t}toObject(){return{apiKey:this.apiKey}}saveCredentials(){const t=e.directoryPath();r.mkdirSync(t,{recursive:!0,mode:448});const i=e.filePath(),o=`${i}.tmp`,d=JSON.stringify(this.toObject(),null,2);r.writeFileSync(o,d,{mode:384}),r.renameSync(o,i)}static directoryPath(){return a(p(),".fjall")}static filePath(){return a(e.directoryPath(),"auth.json")}static loadCredentials(){try{const t=e.loadCredentialFile();if(!t)return null;const i=JSON.parse(t),o=u(i)?i.apiKey:void 0;return new e(o)}catch(t){return c.warn("Credentials","Unable to parse credential file",{error:l(s(t))}),null}}static loadCredentialFile(){try{return r.accessSync(e.filePath(),r.constants.R_OK|r.constants.W_OK),r.readFileSync(e.filePath(),{encoding:"utf8"})}catch(t){return c.debug("Credentials","Could not read credentials file",{error:l(s(t))}),null}}}export{e as default};
@@ -0,0 +1,33 @@
1
+ import { type Result } from "../../types/Result.js";
2
+ import type { ApiError } from "../../types/errors/ApiError.js";
3
+ import { FjallApiClientResources } from "./FjallApiClientResources.js";
4
+ import { type Entitlements, type OrganisationConfigResponse, type OrganisationConfigPayload, type MessageResponse, type GetIdentityResponse, type ConnectionStatusResponse, type RegisterQuickCreateResponse, type VerifyAwsAccountPayload, type VerifyAwsAccountResponse, type RegisterRepositoryPayload, type RegisterRepositoryResponse, type UpdateOrganisationMetadataPayload } from "./FjallApiClient.types.js";
5
+ import type { ConnectionInfo } from "../../services/connect/types.js";
6
+ export type { Entitlements } from "./FjallApiClient.types.js";
7
+ export declare class FjallApiClient extends FjallApiClientResources {
8
+ /** In-memory cache for entitlements (per-client; CLI commands typically use a single client per invocation) */
9
+ private cachedEntitlements;
10
+ validateApiKey(verbose?: boolean): Promise<Result<boolean, ApiError>>;
11
+ getOrganisationConfig(): Promise<Result<OrganisationConfigResponse, ApiError>>;
12
+ putOrganisationConfig(payload: OrganisationConfigPayload): Promise<Result<{
13
+ success: boolean;
14
+ message: string;
15
+ }, ApiError>>;
16
+ markScaffolded(): Promise<Result<{
17
+ success: boolean;
18
+ }, ApiError>>;
19
+ updateOrganisationMetadata(organisationId: string, metadata: UpdateOrganisationMetadataPayload): Promise<Result<MessageResponse, ApiError>>;
20
+ getIdentity(): Promise<Result<GetIdentityResponse, ApiError>>;
21
+ getEntitlements(): Promise<Result<Entitlements, ApiError>>;
22
+ getOidcToken(accountId?: string, environment?: string): Promise<Result<{
23
+ token: string;
24
+ }, ApiError>>;
25
+ getConnectionStatus(externalId: string): Promise<Result<ConnectionStatusResponse, ApiError>>;
26
+ getConnectedAccounts(): Promise<Result<{
27
+ accounts: ConnectionInfo[];
28
+ }, ApiError>>;
29
+ registerQuickCreate(region?: string, environment?: string): Promise<Result<RegisterQuickCreateResponse, ApiError>>;
30
+ verifyAwsAccount(payload: VerifyAwsAccountPayload): Promise<Result<VerifyAwsAccountResponse, ApiError>>;
31
+ registerRepository(payload: RegisterRepositoryPayload): Promise<Result<RegisterRepositoryResponse, ApiError>>;
32
+ static fromCredentials(baseUrl?: string): FjallApiClient | null;
33
+ }
@@ -0,0 +1 @@
1
+ import{resolveApiKey as a}from"./resolveApiKey.js";import{success as n,failure as o}from"../../types/Result.js";import{logger as i}from"../logger/index.js";import{FjallApiClientResources as u}from"./FjallApiClientResources.js";class r extends u{cachedEntitlements=null;async validateApiKey(e=!1){const t="/api/applications";e&&(i.debug("API",`Making GET request to: ${this.baseUrl}${t}`),i.debug("API","Authorization header: Bearer ****"));const s=await this.apiRequest("get",t,void 0,{timeout:1e4});return e&&(s.success?i.debug("API","Response status: 200"):i.debug("API","Error occurred during API validation",{errorType:s.error.errorType,statusCode:s.error.statusCode,message:s.error.message})),s.success?n(!0):o(s.error)}async getOrganisationConfig(){return this.apiRequest("get","/api/organisation-config")}async putOrganisationConfig(e){return this.apiRequest("put","/api/organisation-config",e)}async markScaffolded(){return this.apiRequest("post","/api/organisations/mark-scaffolded")}async updateOrganisationMetadata(e,t){return this.apiRequest("put",`/api/organisations/${encodeURIComponent(e)}`,t)}async getIdentity(){return this.apiRequest("get","/api/identity")}async getEntitlements(){if(this.cachedEntitlements)return n(this.cachedEntitlements);const e=await this.apiRequest("get","/api/entitlements");return e.success&&(this.cachedEntitlements=e.data),e}async getOidcToken(e,t){return this.apiRequest("post","/api/oidc/token",{...e!==void 0&&{accountId:e},...t!==void 0&&{environment:t}})}async getConnectionStatus(e){return this.apiRequest("get",`/api/connections/status?externalId=${encodeURIComponent(e)}`)}async getConnectedAccounts(){return this.apiRequest("get","/api/connections/list")}async registerQuickCreate(e,t){return this.apiRequest("post","/api/connections/quick-create",{...e!==void 0&&{region:e},...t!==void 0&&{environment:t}})}async verifyAwsAccount(e){return this.apiRequest("post","/api/aws-accounts/verify",e)}async registerRepository(e){return this.apiRequest("post","/api/repositories/register",e)}static fromCredentials(e){const t=a();return t?new r(t,e):null}}export{r as FjallApiClient};
@@ -0,0 +1,375 @@
1
+ import type { ProviderAccount } from "@fjall/deploy-core";
2
+ export declare const USER_AGENT: string;
3
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
4
+ export declare const DEFAULT_BASE_URL: string;
5
+ export interface DeviceCodeResponse {
6
+ deviceCode: string;
7
+ userCode: string;
8
+ verificationUri: string;
9
+ expiresIn: number;
10
+ interval: number;
11
+ }
12
+ export interface DeviceTokenResponse {
13
+ status: "pending" | "complete";
14
+ apiKey?: string;
15
+ organisationId?: string;
16
+ organisationName?: string;
17
+ email?: string;
18
+ }
19
+ export interface CreateApplicationPayload {
20
+ name: string;
21
+ description?: string;
22
+ template?: Array<{
23
+ path: string;
24
+ contents: string;
25
+ }>;
26
+ }
27
+ export interface CreateApplicationResponse {
28
+ application: {
29
+ id: string;
30
+ name: string;
31
+ description?: string;
32
+ organisationId: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ };
36
+ activity: {
37
+ id: string;
38
+ applicationId: string;
39
+ type: string;
40
+ data: Record<string, unknown>;
41
+ createdAt: string;
42
+ };
43
+ }
44
+ export interface CreateActivityPayload {
45
+ type: string;
46
+ data?: Record<string, unknown>;
47
+ }
48
+ export interface CreateActivityResponse {
49
+ activity: {
50
+ id: string;
51
+ applicationId: string;
52
+ type: string;
53
+ data: Record<string, unknown>;
54
+ createdAt: string;
55
+ };
56
+ }
57
+ export interface OrganisationConfigResponse {
58
+ primaryRegion: string | null;
59
+ secondaryRegions: string[];
60
+ disasterRecoveryRegion: string | null;
61
+ providerAccounts: ProviderAccount[];
62
+ ssoSessions: Record<string, {
63
+ ssoRegion: string;
64
+ ssoStartUrl: string;
65
+ }>;
66
+ rootOidcRoleArn: string | null;
67
+ allowCodemodLlmFallback: boolean;
68
+ }
69
+ export interface OrganisationConfigPayload {
70
+ primaryRegion?: string;
71
+ secondaryRegions?: string[];
72
+ disasterRecoveryRegion?: string;
73
+ providerAccounts?: ProviderAccount[];
74
+ ssoSessions?: Record<string, {
75
+ ssoRegion: string;
76
+ ssoStartUrl: string;
77
+ }>;
78
+ rootOidcRoleArn?: string;
79
+ }
80
+ export interface MessageResponse {
81
+ message: string;
82
+ }
83
+ /**
84
+ * Minimal application summary returned by `GET /api/applications`.
85
+ *
86
+ * Cross-repo shared contract — the webapp route
87
+ * `app/routes/api/applications/index.ts` returns this shape (plus extra
88
+ * Prisma fields we do not consume). If either surface drifts, the
89
+ * structural assertion in `__tests__/FjallApiClient.listApps.test.ts`
90
+ * fails at typecheck.
91
+ */
92
+ export interface AppSummary {
93
+ id: string;
94
+ name: string;
95
+ vpcCidr: string | null;
96
+ connectedAwsAccountId: string | null;
97
+ }
98
+ export interface ListAppsResponse {
99
+ applications: AppSummary[];
100
+ nextCursor?: string;
101
+ }
102
+ export type { Entitlements } from "@fjall/deploy-core";
103
+ export interface CreateTokenPayload {
104
+ name: string;
105
+ scopes: string[];
106
+ resourceConstraints?: {
107
+ applicationIds?: string[];
108
+ environmentNames?: string[];
109
+ accountIds?: string[];
110
+ };
111
+ expiresAt: string;
112
+ sourceTag?: string;
113
+ }
114
+ export interface CreateTokenResponse {
115
+ id: string;
116
+ token: string;
117
+ tokenPrefix: string;
118
+ name: string;
119
+ scopes: string[];
120
+ resourceConstraints: Record<string, unknown>;
121
+ sourceTag: string | null;
122
+ expiresAt: string;
123
+ organisationId: string;
124
+ }
125
+ export interface TokenSummary {
126
+ id: string;
127
+ name: string;
128
+ tokenPrefix: string;
129
+ scopes: string[];
130
+ resourceConstraints: Record<string, unknown>;
131
+ sourceTag: string | null;
132
+ expiresAt: string;
133
+ createdAt: string;
134
+ revokedAt: string | null;
135
+ revokedReason: string | null;
136
+ lastUsedAt: string | null;
137
+ usageCount: number;
138
+ deniedCount: number;
139
+ createdById: string;
140
+ createdBy: string | null;
141
+ }
142
+ export interface TokenListResponse {
143
+ tokens: TokenSummary[];
144
+ }
145
+ export interface TokenSelfResponse {
146
+ id: string;
147
+ kind: "scoped" | "legacy";
148
+ name?: string;
149
+ tokenPrefix?: string;
150
+ scopes: string[];
151
+ resourceConstraints?: Record<string, unknown>;
152
+ sourceTag?: string | null;
153
+ expiresAt?: string;
154
+ organisationId: string;
155
+ }
156
+ export interface TokenRevokeResponse {
157
+ ok: boolean;
158
+ message: string;
159
+ }
160
+ export interface AssetSummary {
161
+ id: string;
162
+ organizationId: string;
163
+ assetIdentifier: string;
164
+ name: string;
165
+ provider: string;
166
+ type: string;
167
+ region: string | null;
168
+ status: string;
169
+ iacStatus: string | null;
170
+ accountId: string | null;
171
+ applicationId: string | null;
172
+ estimatedMonthlyCost: string | null;
173
+ lastSeenAt: string | null;
174
+ _count?: {
175
+ complianceIssues: number;
176
+ };
177
+ }
178
+ export interface AssetDetail extends AssetSummary {
179
+ environment: string | null;
180
+ tags: Record<string, unknown> | null;
181
+ iacInfo: Record<string, unknown> | null;
182
+ assetCreatedAt: string | null;
183
+ assetModifiedAt: string | null;
184
+ createdAt: string;
185
+ updatedAt: string;
186
+ }
187
+ export interface ComplianceIssueSummary {
188
+ id: string;
189
+ ruleId: string;
190
+ title: string;
191
+ severity: string;
192
+ status: string;
193
+ detectedAt: string;
194
+ lastSeenAt: string;
195
+ }
196
+ export interface AssetListResponse {
197
+ assets: AssetSummary[];
198
+ nextCursor?: string;
199
+ }
200
+ export interface AssetDetailResponse {
201
+ asset: AssetDetail;
202
+ }
203
+ export interface AssetComplianceResponse {
204
+ issues: ComplianceIssueSummary[];
205
+ }
206
+ /**
207
+ * Costs response. Shape varies by mode (summary | forecast | breakdown | app).
208
+ * Consumers should serialise the full payload rather than access specific
209
+ * fields — the API is the source of truth for structure.
210
+ */
211
+ export interface CostsResponse {
212
+ mode?: "summary" | "forecast" | "breakdown" | "app";
213
+ amount_usd?: number;
214
+ applicationId?: string;
215
+ days?: number;
216
+ forecastDays?: number;
217
+ breakdown?: Array<Record<string, unknown>>;
218
+ forecast?: Array<Record<string, unknown>>;
219
+ [key: string]: unknown;
220
+ }
221
+ export interface GetCostsQuery {
222
+ mode?: string;
223
+ applicationId?: string;
224
+ days?: number;
225
+ forecastDays?: number;
226
+ }
227
+ /**
228
+ * App metrics response. Rows-shaped array for most modes, object for
229
+ * summary. Extra fields are preserved for forward compatibility.
230
+ */
231
+ export type AppMetricsResponse = Array<Record<string, unknown>> | {
232
+ mode?: "summary" | "requests" | "errors" | "latency";
233
+ rows?: Array<Record<string, unknown>>;
234
+ [key: string]: unknown;
235
+ };
236
+ export interface GetAppMetricsQuery {
237
+ mode?: string;
238
+ applicationId?: string;
239
+ hours?: number;
240
+ limit?: number;
241
+ }
242
+ export interface DeploymentSummary {
243
+ id: string;
244
+ status?: string;
245
+ startedAt?: string;
246
+ finishedAt?: string;
247
+ durationMs?: number;
248
+ commitSha?: string;
249
+ [key: string]: unknown;
250
+ }
251
+ export interface DeploymentCompareResponse {
252
+ deploymentA: DeploymentSummary;
253
+ deploymentB: DeploymentSummary;
254
+ metricDeltas?: Record<string, unknown> | null;
255
+ [key: string]: unknown;
256
+ }
257
+ export interface DeploymentAnalysisResponse {
258
+ deploymentId?: string;
259
+ summary?: string;
260
+ errors?: Array<Record<string, unknown>>;
261
+ warnings?: Array<Record<string, unknown>>;
262
+ [key: string]: unknown;
263
+ }
264
+ export interface ComplianceSuggestion {
265
+ ruleId?: string;
266
+ title?: string;
267
+ severity?: string;
268
+ suggestion?: string;
269
+ [key: string]: unknown;
270
+ }
271
+ export interface ComplianceSuggestionsResponse {
272
+ domain?: string;
273
+ suggestions?: ComplianceSuggestion[];
274
+ [key: string]: unknown;
275
+ }
276
+ export interface GetComplianceSuggestionsQuery {
277
+ domain: string;
278
+ applicationId?: string;
279
+ issueId?: string;
280
+ }
281
+ export interface CreateDeploymentPayload {
282
+ target: string;
283
+ deploymentType: string;
284
+ applicationId?: string;
285
+ connectedAwsAccountId?: string;
286
+ awsAccountId?: string;
287
+ source?: string;
288
+ commitSha?: string;
289
+ branch?: string;
290
+ operation?: "deploy" | "destroy";
291
+ }
292
+ export interface CreateDeploymentResponse {
293
+ deployment: {
294
+ id: string;
295
+ status: string;
296
+ };
297
+ }
298
+ export interface UpdateDeploymentStatusPayload {
299
+ status: string;
300
+ errorMessage?: string;
301
+ }
302
+ export interface ApplicationMetadataResource {
303
+ name: string;
304
+ arn: string;
305
+ type: "Compute" | "Database" | "Storage" | "Pattern";
306
+ metadata: Record<string, unknown>;
307
+ }
308
+ export interface UpdateApplicationMetadataPayload {
309
+ awsAccountId: string;
310
+ awsRegion: string;
311
+ monitoringRoleArn: string;
312
+ resources: ApplicationMetadataResource[];
313
+ }
314
+ export interface UpdateApplicationTemplateResource {
315
+ resource_type: string;
316
+ name: string;
317
+ stack_name: string;
318
+ }
319
+ export interface UpdateOrganisationMetadataPayload {
320
+ monitoringRoleArn?: string;
321
+ monitoringRoleExternalId?: string;
322
+ awsAccountId?: string;
323
+ }
324
+ export interface GetIdentityResponse {
325
+ organisationId: string;
326
+ organisationName: string;
327
+ }
328
+ export interface ConnectionStatusResponse {
329
+ status: "pending" | "active" | "scanning" | "error";
330
+ roleArn?: string;
331
+ accountId?: string;
332
+ }
333
+ export interface RegisterQuickCreateResponse {
334
+ quickCreateUrl: string;
335
+ externalId: string;
336
+ }
337
+ export interface VerifyAwsAccountPayload {
338
+ awsAccountId: string;
339
+ accountName: string;
340
+ }
341
+ export interface VerifyAwsAccountResponse {
342
+ success: boolean;
343
+ message: string;
344
+ account?: Record<string, unknown>;
345
+ }
346
+ export interface RegisterRepositoryPayload {
347
+ remoteUrl: string;
348
+ branch?: string;
349
+ }
350
+ export interface RegisterRepositoryResponse {
351
+ registered: boolean;
352
+ repository?: {
353
+ id: string;
354
+ fullName: string;
355
+ provider: string;
356
+ purpose: string;
357
+ };
358
+ }
359
+ export interface PatchApplicationConfigPathResponse {
360
+ application: {
361
+ id: string;
362
+ configPath: string;
363
+ };
364
+ }
365
+ export interface LinkApplicationRepositoryResponse {
366
+ application: {
367
+ id: string;
368
+ repositoryId: string;
369
+ configPath: string | null;
370
+ repository: {
371
+ fullName: string;
372
+ provider: string;
373
+ };
374
+ };
375
+ }
@@ -0,0 +1 @@
1
+ import{platform as e,arch as n}from"os";import r from"../../../package.json"with{type:"json"};const p=`fjall-cli/${r.version} node/${process.versions.node} ${e()}/${n()}`,i=3e4,o=process.env.FJALL_API_URL,c=o!==void 0&&o!==""?o:"https://fjall.io";export{c as DEFAULT_BASE_URL,i as DEFAULT_TIMEOUT_MS,p as USER_AGENT};
@@ -0,0 +1,13 @@
1
+ import { type AxiosRequestConfig } from "axios";
2
+ import { type Result } from "../../types/Result.js";
3
+ import { ApiError } from "../../types/errors/ApiError.js";
4
+ export declare class FjallApiClientBase {
5
+ protected baseUrl: string;
6
+ protected apiKey: string;
7
+ constructor(apiKey: string, baseUrl?: string);
8
+ getBaseUrl(): string;
9
+ private getHeaders;
10
+ private extractResponseError;
11
+ private handleError;
12
+ protected apiRequest<T>(method: "get" | "post" | "put" | "patch" | "delete", endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<Result<T, ApiError>>;
13
+ }
@@ -0,0 +1 @@
1
+ import a,{AxiosError as p}from"axios";import{maskSensitiveOutput as d}from"@fjall/util";import{success as f,failure as l}from"../../types/Result.js";import{ApiError as u}from"../../types/errors/ApiError.js";import{buildApiError as m}from"./FjallApiClientErrors.js";import{USER_AGENT as h,DEFAULT_TIMEOUT_MS as E,DEFAULT_BASE_URL as g}from"./FjallApiClient.types.js";class x{baseUrl;apiKey;constructor(t,r=g){this.apiKey=t,this.baseUrl=r}getBaseUrl(){return this.baseUrl}getHeaders(){return{"Content-Type":"application/json","User-Agent":h,Authorization:`Bearer ${this.apiKey}`}}extractResponseError(t){const r=t.response?.data;if(typeof r!="object"||r===null||!("error"in r))return;const e=r.error;if(typeof e=="string")return e;if(typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string")return e.message;if("message"in r&&typeof r.message=="string")return r.message}handleError(t,r){if(t instanceof p){if(t.response?.status===401){const e=this.extractResponseError(t),s=e!==void 0?d(e):void 0;return new u(s??"Invalid API key or unauthorised","not_authenticated",r,401,t)}if(t.response?.status===403){const e=this.extractResponseError(t),s=e!==void 0?d(e):void 0;return new u(s??"Permission denied","permission_denied",r,403,t)}if(t.response?.status===404){const e=this.extractResponseError(t),s=e!==void 0?d(e):void 0,n=t.config?.method?.toUpperCase()??"UNKNOWN",o=t.config?.url?new URL(t.config.url,"http://localhost").pathname:"unknown";return new u(`Resource not found: ${n} ${o}${s?` - ${s}`:""}`,"not_found",r,404,t)}if(t.response?.status===409){const e=this.extractResponseError(t),s=e!==void 0?d(e):void 0;return new u(s??"Resource already exists","conflict",r,409,t)}if(t.response?.status===429){const e=t.response.headers?.["retry-after"],s=e!=null?parseInt(String(e),10):NaN,n=Number.isFinite(s)&&s>=0?s:void 0;return new u(`Rate limited. Please try again${n!==void 0?` in ${n}s`:" later"}.`,"rate_limited",r,429,t,!0,n)}}return m(t,r,this.baseUrl)}async apiRequest(t,r,e,s){try{const n=`${this.baseUrl}${r}`,o={...s,timeout:s?.timeout??E,headers:{...this.getHeaders(),...s?.headers}};let i;switch(t){case"get":i=await a.get(n,o);break;case"post":i=await a.post(n,e,o);break;case"put":i=await a.put(n,e,o);break;case"patch":i=await a.patch(n,e,o);break;case"delete":i=await a.delete(n,{...o,...e!==void 0&&{data:e}});break;default:{const c=t;throw new Error(`Unsupported HTTP method: ${c}`)}}return f(i.data)}catch(n){return l(this.handleError(n,r))}}}export{x as FjallApiClientBase};
@@ -0,0 +1,13 @@
1
+ import { type Result } from "../../types/Result.js";
2
+ import type { ApiError } from "../../types/errors/ApiError.js";
3
+ import { type DeviceCodeResponse, type DeviceTokenResponse } from "./FjallApiClient.types.js";
4
+ /**
5
+ * Initiate a device-code authentication flow.
6
+ * Standalone because no API key exists yet at this point.
7
+ */
8
+ export declare function initiateDeviceCode(baseUrl?: string): Promise<Result<DeviceCodeResponse, ApiError>>;
9
+ /**
10
+ * Poll for device-code token completion.
11
+ * Standalone because no API key exists yet at this point.
12
+ */
13
+ export declare function pollDeviceToken(deviceCode: string, baseUrl?: string): Promise<Result<DeviceTokenResponse, ApiError>>;
@@ -0,0 +1 @@
1
+ import i from"axios";import{success as s,failure as a}from"../../types/Result.js";import{USER_AGENT as c,DEFAULT_TIMEOUT_MS as p,DEFAULT_BASE_URL as d}from"./FjallApiClient.types.js";import{buildApiError as u}from"./FjallApiClientErrors.js";async function f(r){const o=r??d,t="/api/device/code";try{const e=await i.post(`${o}${t}`,{},{timeout:p,headers:{"Content-Type":"application/json","User-Agent":c}});return s(e.data)}catch(e){return a(u(e,t,o))}}async function A(r,o){const t=o??d,e="/api/device/token";try{const n=await i.post(`${t}${e}`,{deviceCode:r},{timeout:p,headers:{"Content-Type":"application/json","User-Agent":c}});return s(n.data)}catch(n){return a(u(n,e,t))}}export{f as initiateDeviceCode,A as pollDeviceToken};
@@ -0,0 +1,5 @@
1
+ import { ApiError } from "../../types/errors/ApiError.js";
2
+ /**
3
+ * Shared error handling for both authenticated and unauthenticated API requests.
4
+ */
5
+ export declare function buildApiError(err: unknown, endpoint: string, baseUrl: string): ApiError;
@@ -0,0 +1 @@
1
+ import{AxiosError as u}from"axios";import{ApiError as o}from"../../types/errors/ApiError.js";import{getErrorMessage as A}from"../errorUtils.js";import{maskSensitiveOutput as a}from"@fjall/util";const E=2e3;function c(e){const s=a(JSON.stringify(e));return s.length>E?s.slice(0,E)+"\u2026":s}function m(e,s,n){if(e instanceof u){const r=a(e.message);if(e.response?.status&&e.response.status>=500)return new o(`Server error: ${r}${e.response?.data?` - ${c(e.response.data)}`:""}`,"server_error",s,e.response.status,e);const i=["ECONNREFUSED","ETIMEDOUT","ECONNABORTED","ENETUNREACH","EHOSTUNREACH"];if(e.code&&i.includes(e.code)){let t;switch(e.code){case"ECONNREFUSED":t=`Cannot connect to API server at ${n}. Is the server running?`;break;case"ETIMEDOUT":case"ECONNABORTED":t=`Connection timeout to ${n}. Please check your network connection.`;break;case"ENETUNREACH":case"EHOSTUNREACH":t=`Network unreachable. Cannot connect to ${n}.`;break;default:t=`Network error: Cannot connect to API server at ${n}`}return new o(t,"network_error",s,void 0,e,!0)}return e.response?.data?new o(`API request failed: ${r} - ${c(e.response.data)}`,"api_error",s,e.response?.status,e):new o(`API request failed: ${r}`,"api_error",s,e.response?.status,e)}return new o(`Unexpected error: ${a(A(e))}`,"unknown",s)}export{m as buildApiError};
@@ -0,0 +1,45 @@
1
+ import { type Result } from "../../types/Result.js";
2
+ import type { ApiError } from "../../types/errors/ApiError.js";
3
+ import { FjallApiClientBase } from "./FjallApiClientBase.js";
4
+ import { type DeploymentProgressEvent } from "../deploymentEvents.js";
5
+ import { type CreateApplicationPayload, type CreateApplicationResponse, type CreateActivityPayload, type CreateActivityResponse, type MessageResponse, type CreateTokenPayload, type CreateTokenResponse, type TokenSummary, type TokenListResponse, type TokenSelfResponse, type TokenRevokeResponse, type AssetListResponse, type AssetDetailResponse, type AssetComplianceResponse, type CostsResponse, type GetCostsQuery, type AppMetricsResponse, type GetAppMetricsQuery, type DeploymentCompareResponse, type DeploymentAnalysisResponse, type ComplianceSuggestionsResponse, type GetComplianceSuggestionsQuery, type AppSummary, type CreateDeploymentPayload, type CreateDeploymentResponse, type UpdateDeploymentStatusPayload, type UpdateApplicationMetadataPayload, type UpdateApplicationTemplateResource, type PatchApplicationConfigPathResponse, type LinkApplicationRepositoryResponse } from "./FjallApiClient.types.js";
6
+ export declare class FjallApiClientResources extends FjallApiClientBase {
7
+ createApplication(payload: CreateApplicationPayload): Promise<Result<CreateApplicationResponse, ApiError>>;
8
+ createActivity(applicationId: string, payload: CreateActivityPayload): Promise<Result<CreateActivityResponse, ApiError>>;
9
+ getApplicationByName(name: string): Promise<Result<{
10
+ application: AppSummary;
11
+ }, ApiError>>;
12
+ getApplicationsByAccountIds(ids: string[]): Promise<Result<AppSummary[], ApiError>>;
13
+ getApplication(applicationId: string): Promise<Result<{
14
+ application: Record<string, unknown>;
15
+ }, ApiError>>;
16
+ updateApplicationMetadata(applicationId: string, metadata: UpdateApplicationMetadataPayload): Promise<Result<MessageResponse, ApiError>>;
17
+ updateApplicationTemplate(applicationId: string, template: string, resources: UpdateApplicationTemplateResource[]): Promise<Result<MessageResponse, ApiError>>;
18
+ listApps(): Promise<Result<AppSummary[], ApiError>>;
19
+ patchApplicationConfigPath(applicationId: string, configPath: string): Promise<Result<PatchApplicationConfigPathResponse, ApiError>>;
20
+ linkApplicationRepository(applicationId: string, repositoryId: string, configPath?: string): Promise<Result<LinkApplicationRepositoryResponse, ApiError>>;
21
+ createDeployment(payload: CreateDeploymentPayload): Promise<Result<CreateDeploymentResponse, ApiError>>;
22
+ updateDeploymentStatus(deploymentId: string, payload: UpdateDeploymentStatusPayload): Promise<Result<{
23
+ success: boolean;
24
+ }, ApiError>>;
25
+ pushDeploymentEvents(deploymentId: string, events: DeploymentProgressEvent[]): Promise<Result<{
26
+ received: number;
27
+ }, ApiError>>;
28
+ compareDeployments(deploymentIdA: string, deploymentIdB: string): Promise<Result<DeploymentCompareResponse, ApiError>>;
29
+ getDeploymentAnalysis(deploymentId: string): Promise<Result<DeploymentAnalysisResponse, ApiError>>;
30
+ createToken(payload: CreateTokenPayload): Promise<Result<CreateTokenResponse, ApiError>>;
31
+ listTokens(): Promise<Result<TokenListResponse, ApiError>>;
32
+ getToken(id: string): Promise<Result<TokenSummary, ApiError>>;
33
+ getSelfToken(): Promise<Result<TokenSelfResponse, ApiError>>;
34
+ revokeToken(id: string, reason?: string): Promise<Result<TokenRevokeResponse, ApiError>>;
35
+ listAssets(options?: {
36
+ cursor?: string;
37
+ take?: number;
38
+ includeDeleted?: boolean;
39
+ }): Promise<Result<AssetListResponse, ApiError>>;
40
+ getAsset(assetId: string): Promise<Result<AssetDetailResponse, ApiError>>;
41
+ getAssetCompliance(assetId: string): Promise<Result<AssetComplianceResponse, ApiError>>;
42
+ getCosts(query: GetCostsQuery): Promise<Result<CostsResponse, ApiError>>;
43
+ getAppMetrics(query: GetAppMetricsQuery): Promise<Result<AppMetricsResponse, ApiError>>;
44
+ getComplianceSuggestions(query: GetComplianceSuggestionsQuery): Promise<Result<ComplianceSuggestionsResponse, ApiError>>;
45
+ }
@@ -0,0 +1 @@
1
+ import{success as o,failure as p}from"../../types/Result.js";import{logger as u}from"../logger/index.js";import{FjallApiClientBase as d}from"./FjallApiClientBase.js";const a="/api/applications",i="/api/tokens";function n(c,e){const t=`/api/applications/${encodeURIComponent(c)}`;return e?`${t}/${e}`:t}class h extends d{async createApplication(e){return this.apiRequest("post",a,e)}async createActivity(e,t){return this.apiRequest("post",n(e,"activity"),t)}async getApplicationByName(e){return this.apiRequest("get",`${a}?name=${encodeURIComponent(e)}`)}async getApplicationsByAccountIds(e){const t=new URLSearchParams({accountIds:e.join(",")}),s=await this.apiRequest("get",`${a}?${t.toString()}`);return s.success?o(s.data.applications):p(s.error)}async getApplication(e){return this.apiRequest("get",n(e))}async updateApplicationMetadata(e,t){const s=n(e,"metadata");return u.debug("API",`PUT ${this.baseUrl}${s}`),this.apiRequest("put",s,t)}async updateApplicationTemplate(e,t,s){return this.apiRequest("put",n(e,"template"),{template:t,resources:s})}async listApps(){const e=await this.apiRequest("get",a);return e.success?o(e.data.applications):p(e.error)}async patchApplicationConfigPath(e,t){return this.apiRequest("patch",n(e),{configPath:t})}async linkApplicationRepository(e,t,s){return this.apiRequest("put",n(e,"repository"),{repositoryId:t,...s!==void 0&&{configPath:s}})}async createDeployment(e){return this.apiRequest("post","/api/deployments",{target:e.target,deploymentType:e.deploymentType,...e.applicationId!==void 0&&{applicationId:e.applicationId},...e.connectedAwsAccountId!==void 0&&{connectedAwsAccountId:e.connectedAwsAccountId},...e.awsAccountId!==void 0&&{awsAccountId:e.awsAccountId},...e.source!==void 0&&{source:e.source},...e.commitSha!==void 0&&{commitSha:e.commitSha},...e.branch!==void 0&&{branch:e.branch},...e.operation!==void 0&&{operation:e.operation}})}async updateDeploymentStatus(e,t){return this.apiRequest("put",`/api/deployments/${encodeURIComponent(e)}/status`,{status:t.status,...t.errorMessage!==void 0&&{errorMessage:t.errorMessage}})}async pushDeploymentEvents(e,t){return this.apiRequest("post",`/api/deployments/${encodeURIComponent(e)}/events`,{events:t})}async compareDeployments(e,t){const s=new URLSearchParams({deploymentIdA:e,deploymentIdB:t});return this.apiRequest("get",`/api/deployments/compare?${s.toString()}`)}async getDeploymentAnalysis(e){return this.apiRequest("get",`/api/deployments/${encodeURIComponent(e)}/analyse`)}async createToken(e){return this.apiRequest("post",i,e)}async listTokens(){return this.apiRequest("get",i)}async getToken(e){return this.apiRequest("get",`${i}/${encodeURIComponent(e)}`)}async getSelfToken(){return this.apiRequest("get",`${i}/self`)}async revokeToken(e,t){return this.apiRequest("delete",`${i}/${encodeURIComponent(e)}`,t!==void 0?{reason:t}:void 0)}async listAssets(e){const t=new URLSearchParams;e?.cursor&&t.set("cursor",e.cursor),e?.take!==void 0&&t.set("take",String(e.take)),e?.includeDeleted&&t.set("includeDeleted","true");const s=t.toString(),r=`/api/assets${s?`?${s}`:""}`;return this.apiRequest("get",r)}async getAsset(e){return this.apiRequest("get",`/api/assets/${encodeURIComponent(e)}`)}async getAssetCompliance(e){return this.apiRequest("get",`/api/assets/${encodeURIComponent(e)}/compliance`)}async getCosts(e){const t=new URLSearchParams;e.mode&&t.set("mode",e.mode),e.applicationId&&t.set("applicationId",e.applicationId),e.days!==void 0&&t.set("days",String(e.days)),e.forecastDays!==void 0&&t.set("forecastDays",String(e.forecastDays));const s=t.toString();return this.apiRequest("get",`/api/costs${s?`?${s}`:""}`)}async getAppMetrics(e){const t=new URLSearchParams;e.mode&&t.set("mode",e.mode),e.applicationId&&t.set("applicationId",e.applicationId),e.hours!==void 0&&t.set("hours",String(e.hours)),e.limit!==void 0&&t.set("limit",String(e.limit));const s=t.toString();return this.apiRequest("get",`/api/app-metrics${s?`?${s}`:""}`)}async getComplianceSuggestions(e){const t=new URLSearchParams({domain:e.domain});return e.applicationId&&t.set("applicationId",e.applicationId),e.issueId&&t.set("issueId",e.issueId),this.apiRequest("get",`/api/compliance/suggestions?${t.toString()}`)}}export{h as FjallApiClientResources};
@@ -0,0 +1,7 @@
1
+ export { FjallApiClient } from "./FjallApiClient.js";
2
+ export type { DeviceCodeResponse, DeviceTokenResponse, Entitlements, CreateApplicationPayload, CreateApplicationResponse, CreateActivityPayload, CreateActivityResponse, OrganisationConfigResponse, OrganisationConfigPayload, MessageResponse } from "./FjallApiClient.types.js";
3
+ export { default as Credentials } from "./Credentials.js";
4
+ export { resolveApiKey } from "./resolveApiKey.js";
5
+ export { buildApiError } from "./FjallApiClientErrors.js";
6
+ export { initiateDeviceCode, pollDeviceToken } from "./FjallApiClientDeviceCode.js";
7
+ export { notifyScaffoldComplete } from "./scaffoldNotification.js";
@@ -0,0 +1 @@
1
+ import{FjallApiClient as r}from"./FjallApiClient.js";import{default as i}from"./Credentials.js";import{resolveApiKey as p}from"./resolveApiKey.js";import{buildApiError as m}from"./FjallApiClientErrors.js";import{initiateDeviceCode as x,pollDeviceToken as d}from"./FjallApiClientDeviceCode.js";import{notifyScaffoldComplete as C}from"./scaffoldNotification.js";export{i as Credentials,r as FjallApiClient,m as buildApiError,x as initiateDeviceCode,C as notifyScaffoldComplete,d as pollDeviceToken,p as resolveApiKey};
@@ -0,0 +1 @@
1
+ export declare function resolveApiKey(): string | undefined;
@@ -0,0 +1 @@
1
+ import r from"./Credentials.js";function t(){const e=process.env.FJALL_API_KEY;if(e)return e;const n=r.loadCredentials();if(n?.apiKey)return n.apiKey}export{t as resolveApiKey};
@@ -0,0 +1,2 @@
1
+ /** Best-effort notification that account scaffolding is complete. */
2
+ export declare function notifyScaffoldComplete(): Promise<void>;