pax8-cta 0.1.0

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 (224) hide show
  1. package/LICENSE +200 -0
  2. package/README.md +659 -0
  3. package/demo-data/solutions/ProductQADemo_1_0_0_2_managed.zip +0 -0
  4. package/dist/commands/analyze.d.ts +28 -0
  5. package/dist/commands/analyze.d.ts.map +1 -0
  6. package/dist/commands/analyze.js +571 -0
  7. package/dist/commands/analyze.js.map +1 -0
  8. package/dist/commands/auth.d.ts +18 -0
  9. package/dist/commands/auth.d.ts.map +1 -0
  10. package/dist/commands/auth.js +171 -0
  11. package/dist/commands/auth.js.map +1 -0
  12. package/dist/commands/config.d.ts +34 -0
  13. package/dist/commands/config.d.ts.map +1 -0
  14. package/dist/commands/config.js +299 -0
  15. package/dist/commands/config.js.map +1 -0
  16. package/dist/commands/demo.d.ts +33 -0
  17. package/dist/commands/demo.d.ts.map +1 -0
  18. package/dist/commands/demo.js +362 -0
  19. package/dist/commands/demo.js.map +1 -0
  20. package/dist/commands/deploy.d.ts +18 -0
  21. package/dist/commands/deploy.d.ts.map +1 -0
  22. package/dist/commands/deploy.js +1186 -0
  23. package/dist/commands/deploy.js.map +1 -0
  24. package/dist/commands/deployments/helpers.d.ts +68 -0
  25. package/dist/commands/deployments/helpers.d.ts.map +1 -0
  26. package/dist/commands/deployments/helpers.js +414 -0
  27. package/dist/commands/deployments/helpers.js.map +1 -0
  28. package/dist/commands/deployments/index.d.ts +24 -0
  29. package/dist/commands/deployments/index.d.ts.map +1 -0
  30. package/dist/commands/deployments/index.js +47 -0
  31. package/dist/commands/deployments/index.js.map +1 -0
  32. package/dist/commands/deployments/list.d.ts +18 -0
  33. package/dist/commands/deployments/list.d.ts.map +1 -0
  34. package/dist/commands/deployments/list.js +97 -0
  35. package/dist/commands/deployments/list.js.map +1 -0
  36. package/dist/commands/deployments/show.d.ts +18 -0
  37. package/dist/commands/deployments/show.d.ts.map +1 -0
  38. package/dist/commands/deployments/show.js +81 -0
  39. package/dist/commands/deployments/show.js.map +1 -0
  40. package/dist/commands/deployments/undo.d.ts +18 -0
  41. package/dist/commands/deployments/undo.d.ts.map +1 -0
  42. package/dist/commands/deployments/undo.js +295 -0
  43. package/dist/commands/deployments/undo.js.map +1 -0
  44. package/dist/commands/export.d.ts +18 -0
  45. package/dist/commands/export.d.ts.map +1 -0
  46. package/dist/commands/export.js +133 -0
  47. package/dist/commands/export.js.map +1 -0
  48. package/dist/commands/import.d.ts +18 -0
  49. package/dist/commands/import.d.ts.map +1 -0
  50. package/dist/commands/import.js +129 -0
  51. package/dist/commands/import.js.map +1 -0
  52. package/dist/commands/init-config.d.ts +26 -0
  53. package/dist/commands/init-config.d.ts.map +1 -0
  54. package/dist/commands/init-config.js +123 -0
  55. package/dist/commands/init-config.js.map +1 -0
  56. package/dist/commands/init-validation.d.ts +47 -0
  57. package/dist/commands/init-validation.d.ts.map +1 -0
  58. package/dist/commands/init-validation.js +339 -0
  59. package/dist/commands/init-validation.js.map +1 -0
  60. package/dist/commands/init-wizard.d.ts +25 -0
  61. package/dist/commands/init-wizard.d.ts.map +1 -0
  62. package/dist/commands/init-wizard.js +433 -0
  63. package/dist/commands/init-wizard.js.map +1 -0
  64. package/dist/commands/init.d.ts +18 -0
  65. package/dist/commands/init.d.ts.map +1 -0
  66. package/dist/commands/init.js +46 -0
  67. package/dist/commands/init.js.map +1 -0
  68. package/dist/commands/resolve-url.d.ts +18 -0
  69. package/dist/commands/resolve-url.d.ts.map +1 -0
  70. package/dist/commands/resolve-url.js +126 -0
  71. package/dist/commands/resolve-url.js.map +1 -0
  72. package/dist/commands/setup.d.ts +18 -0
  73. package/dist/commands/setup.d.ts.map +1 -0
  74. package/dist/commands/setup.js +239 -0
  75. package/dist/commands/setup.js.map +1 -0
  76. package/dist/commands/solutions/drift-analysis.d.ts +73 -0
  77. package/dist/commands/solutions/drift-analysis.d.ts.map +1 -0
  78. package/dist/commands/solutions/drift-analysis.js +416 -0
  79. package/dist/commands/solutions/drift-analysis.js.map +1 -0
  80. package/dist/commands/solutions/drift.d.ts +32 -0
  81. package/dist/commands/solutions/drift.d.ts.map +1 -0
  82. package/dist/commands/solutions/drift.js +641 -0
  83. package/dist/commands/solutions/drift.js.map +1 -0
  84. package/dist/commands/solutions/fix-planner.d.ts +48 -0
  85. package/dist/commands/solutions/fix-planner.d.ts.map +1 -0
  86. package/dist/commands/solutions/fix-planner.js +43 -0
  87. package/dist/commands/solutions/fix-planner.js.map +1 -0
  88. package/dist/commands/solutions/helpers.d.ts +35 -0
  89. package/dist/commands/solutions/helpers.d.ts.map +1 -0
  90. package/dist/commands/solutions/helpers.js +54 -0
  91. package/dist/commands/solutions/helpers.js.map +1 -0
  92. package/dist/commands/solutions/index.d.ts +18 -0
  93. package/dist/commands/solutions/index.d.ts.map +1 -0
  94. package/dist/commands/solutions/index.js +30 -0
  95. package/dist/commands/solutions/index.js.map +1 -0
  96. package/dist/commands/solutions/list.d.ts +18 -0
  97. package/dist/commands/solutions/list.d.ts.map +1 -0
  98. package/dist/commands/solutions/list.js +174 -0
  99. package/dist/commands/solutions/list.js.map +1 -0
  100. package/dist/commands/solutions/remove.d.ts +18 -0
  101. package/dist/commands/solutions/remove.d.ts.map +1 -0
  102. package/dist/commands/solutions/remove.js +137 -0
  103. package/dist/commands/solutions/remove.js.map +1 -0
  104. package/dist/commands/solutions/risk-calculator.d.ts +33 -0
  105. package/dist/commands/solutions/risk-calculator.d.ts.map +1 -0
  106. package/dist/commands/solutions/risk-calculator.js +79 -0
  107. package/dist/commands/solutions/risk-calculator.js.map +1 -0
  108. package/dist/commands/solutions/show.d.ts +18 -0
  109. package/dist/commands/solutions/show.d.ts.map +1 -0
  110. package/dist/commands/solutions/show.js +165 -0
  111. package/dist/commands/solutions/show.js.map +1 -0
  112. package/dist/commands/status.d.ts +18 -0
  113. package/dist/commands/status.d.ts.map +1 -0
  114. package/dist/commands/status.js +573 -0
  115. package/dist/commands/status.js.map +1 -0
  116. package/dist/commands/telemetry.d.ts +18 -0
  117. package/dist/commands/telemetry.d.ts.map +1 -0
  118. package/dist/commands/telemetry.js +85 -0
  119. package/dist/commands/telemetry.js.map +1 -0
  120. package/dist/commands/tenants/health.d.ts +18 -0
  121. package/dist/commands/tenants/health.d.ts.map +1 -0
  122. package/dist/commands/tenants/health.js +172 -0
  123. package/dist/commands/tenants/health.js.map +1 -0
  124. package/dist/commands/tenants/helpers.d.ts +44 -0
  125. package/dist/commands/tenants/helpers.d.ts.map +1 -0
  126. package/dist/commands/tenants/helpers.js +72 -0
  127. package/dist/commands/tenants/helpers.js.map +1 -0
  128. package/dist/commands/tenants/index.d.ts +19 -0
  129. package/dist/commands/tenants/index.d.ts.map +1 -0
  130. package/dist/commands/tenants/index.js +39 -0
  131. package/dist/commands/tenants/index.js.map +1 -0
  132. package/dist/commands/tenants/inspect.d.ts +18 -0
  133. package/dist/commands/tenants/inspect.d.ts.map +1 -0
  134. package/dist/commands/tenants/inspect.js +176 -0
  135. package/dist/commands/tenants/inspect.js.map +1 -0
  136. package/dist/commands/tenants/list.d.ts +18 -0
  137. package/dist/commands/tenants/list.d.ts.map +1 -0
  138. package/dist/commands/tenants/list.js +144 -0
  139. package/dist/commands/tenants/list.js.map +1 -0
  140. package/dist/commands/tenants/manage.d.ts +20 -0
  141. package/dist/commands/tenants/manage.d.ts.map +1 -0
  142. package/dist/commands/tenants/manage.js +206 -0
  143. package/dist/commands/tenants/manage.js.map +1 -0
  144. package/dist/commands/tenants/show.d.ts +18 -0
  145. package/dist/commands/tenants/show.d.ts.map +1 -0
  146. package/dist/commands/tenants/show.js +191 -0
  147. package/dist/commands/tenants/show.js.map +1 -0
  148. package/dist/commands/validate.d.ts +18 -0
  149. package/dist/commands/validate.d.ts.map +1 -0
  150. package/dist/commands/validate.js +536 -0
  151. package/dist/commands/validate.js.map +1 -0
  152. package/dist/index.d.ts +19 -0
  153. package/dist/index.d.ts.map +1 -0
  154. package/dist/index.js +258 -0
  155. package/dist/index.js.map +1 -0
  156. package/dist/lib/auth.d.ts +51 -0
  157. package/dist/lib/auth.d.ts.map +1 -0
  158. package/dist/lib/auth.js +153 -0
  159. package/dist/lib/auth.js.map +1 -0
  160. package/dist/lib/banner.d.ts +19 -0
  161. package/dist/lib/banner.d.ts.map +1 -0
  162. package/dist/lib/banner.js +78 -0
  163. package/dist/lib/banner.js.map +1 -0
  164. package/dist/lib/command-wrapper.d.ts +56 -0
  165. package/dist/lib/command-wrapper.d.ts.map +1 -0
  166. package/dist/lib/command-wrapper.js +71 -0
  167. package/dist/lib/command-wrapper.js.map +1 -0
  168. package/dist/lib/credentials.d.ts +56 -0
  169. package/dist/lib/credentials.d.ts.map +1 -0
  170. package/dist/lib/credentials.js +146 -0
  171. package/dist/lib/credentials.js.map +1 -0
  172. package/dist/lib/demo-banner.d.ts +15 -0
  173. package/dist/lib/demo-banner.d.ts.map +1 -0
  174. package/dist/lib/demo-banner.js +33 -0
  175. package/dist/lib/demo-banner.js.map +1 -0
  176. package/dist/lib/error-handler.d.ts +51 -0
  177. package/dist/lib/error-handler.d.ts.map +1 -0
  178. package/dist/lib/error-handler.js +458 -0
  179. package/dist/lib/error-handler.js.map +1 -0
  180. package/dist/lib/errors.d.ts +61 -0
  181. package/dist/lib/errors.d.ts.map +1 -0
  182. package/dist/lib/errors.js +168 -0
  183. package/dist/lib/errors.js.map +1 -0
  184. package/dist/lib/formatters.d.ts +55 -0
  185. package/dist/lib/formatters.d.ts.map +1 -0
  186. package/dist/lib/formatters.js +163 -0
  187. package/dist/lib/formatters.js.map +1 -0
  188. package/dist/lib/graph-client.d.ts +74 -0
  189. package/dist/lib/graph-client.d.ts.map +1 -0
  190. package/dist/lib/graph-client.js +231 -0
  191. package/dist/lib/graph-client.js.map +1 -0
  192. package/dist/lib/input.d.ts +22 -0
  193. package/dist/lib/input.d.ts.map +1 -0
  194. package/dist/lib/input.js +120 -0
  195. package/dist/lib/input.js.map +1 -0
  196. package/dist/lib/interactive-wizard.d.ts +26 -0
  197. package/dist/lib/interactive-wizard.d.ts.map +1 -0
  198. package/dist/lib/interactive-wizard.js +550 -0
  199. package/dist/lib/interactive-wizard.js.map +1 -0
  200. package/dist/lib/oss-surface.d.ts +21 -0
  201. package/dist/lib/oss-surface.d.ts.map +1 -0
  202. package/dist/lib/oss-surface.js +29 -0
  203. package/dist/lib/oss-surface.js.map +1 -0
  204. package/dist/lib/output.d.ts +74 -0
  205. package/dist/lib/output.d.ts.map +1 -0
  206. package/dist/lib/output.js +156 -0
  207. package/dist/lib/output.js.map +1 -0
  208. package/dist/lib/picker.d.ts +75 -0
  209. package/dist/lib/picker.d.ts.map +1 -0
  210. package/dist/lib/picker.js +115 -0
  211. package/dist/lib/picker.js.map +1 -0
  212. package/dist/lib/repl.d.ts +19 -0
  213. package/dist/lib/repl.d.ts.map +1 -0
  214. package/dist/lib/repl.js +158 -0
  215. package/dist/lib/repl.js.map +1 -0
  216. package/dist/lib/spinner.d.ts +41 -0
  217. package/dist/lib/spinner.d.ts.map +1 -0
  218. package/dist/lib/spinner.js +126 -0
  219. package/dist/lib/spinner.js.map +1 -0
  220. package/dist/lib/telemetry.d.ts +96 -0
  221. package/dist/lib/telemetry.d.ts.map +1 -0
  222. package/dist/lib/telemetry.js +367 -0
  223. package/dist/lib/telemetry.js.map +1 -0
  224. package/package.json +68 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { resolve } from "node:path";
17
+ import { filterTenantsByTags, isDemoMode as isDemoModeCore, loadConfig, } from "@pax8-cta/core";
18
+ import { getDemoTenants, isDemoModeEnabled } from "../commands/demo.js";
19
+ /**
20
+ * Check if demo mode is active from any source (CLI config, env var, or core).
21
+ * Consolidates the two checks (`isDemoModeEnabled() || isDemoModeCore()`) that
22
+ * were scattered across every command.
23
+ */
24
+ export function isDemo() {
25
+ return isDemoModeEnabled() || isDemoModeCore();
26
+ }
27
+ /**
28
+ * Execute `demoHandler` when demo mode is active, otherwise `realHandler`.
29
+ *
30
+ * Usage:
31
+ * ```ts
32
+ * .action(async (options) => {
33
+ * await withDemoMode(
34
+ * () => runDemo(options),
35
+ * () => runReal(options),
36
+ * );
37
+ * });
38
+ * ```
39
+ */
40
+ export async function withDemoMode(demoHandler, realHandler) {
41
+ if (isDemo()) {
42
+ return demoHandler();
43
+ }
44
+ return realHandler();
45
+ }
46
+ /**
47
+ * Resolve config once and branch by mode in a shared wrapper.
48
+ */
49
+ export async function withResolvedConfig(options, demoHandler, realHandler) {
50
+ if (isDemo()) {
51
+ return demoHandler();
52
+ }
53
+ const configPath = resolve(process.cwd(), options.config ?? "./config/tenants.yaml");
54
+ const config = await loadConfig(configPath);
55
+ return realHandler(config);
56
+ }
57
+ /**
58
+ * Resolve destinations once and pass the resolved context to command handlers.
59
+ */
60
+ export async function withResolvedDestinations(options, demoHandler, realHandler) {
61
+ if (isDemo()) {
62
+ return demoHandler(getDemoTenants(options));
63
+ }
64
+ const configPath = resolve(process.cwd(), options.config ?? "./config/tenants.yaml");
65
+ const config = await loadConfig(configPath);
66
+ const destinations = options.all
67
+ ? config.tenants.filter((tenant) => tenant.enabled)
68
+ : filterTenantsByTags(config, options.tag ?? []);
69
+ return realHandler({ config, destinations });
70
+ }
71
+ //# sourceMappingURL=command-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-wrapper.js","sourceRoot":"","sources":["../../src/lib/command-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO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UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG;QAC9B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;QACnD,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IAEnD,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Get stored secret from OS keychain
18
+ */
19
+ export declare function getStoredSecret(): Promise<string | null>;
20
+ /**
21
+ * Probe whether the OS keychain is available without revealing the secret.
22
+ *
23
+ * Useful for status / config commands that need to report whether a stored
24
+ * credential exists. Returns one of:
25
+ * - "set" — keychain available and a secret is stored
26
+ * - "not-set" — keychain available but no secret stored
27
+ * - "unavailable" — keytar not installed or keychain unreadable
28
+ *
29
+ * Never returns or logs the secret value.
30
+ */
31
+ export declare function probeStoredSecret(): Promise<"set" | "not-set" | "unavailable">;
32
+ /**
33
+ * Store secret in OS keychain
34
+ */
35
+ export declare function storeSecret(secret: string): Promise<void>;
36
+ /**
37
+ * Remove secret from OS keychain
38
+ */
39
+ export declare function deleteSecret(): Promise<void>;
40
+ /**
41
+ * Resolve the client secret using a single, well-defined fallback chain.
42
+ *
43
+ * Priority:
44
+ * 1. Environment variables (PARTNER_CLIENT_SECRET, then PAX8_CTA_CLIENT_SECRET).
45
+ * These are populated either by the shell environment or by the .env loader
46
+ * in index.ts — so .env file values are included here automatically.
47
+ * 2. OS keychain (stored via `pax8-cta auth login`).
48
+ *
49
+ * Every CLI command that needs a client secret MUST call this function
50
+ * rather than reading process.env directly.
51
+ *
52
+ * @returns The client secret
53
+ * @throws Error if secret not found in any location
54
+ */
55
+ export declare function getClientSecretWithFallback(): Promise<string>;
56
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/lib/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6BH;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAS9D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,KAAK,GAAG,SAAS,GAAG,aAAa,CAAC,CASpF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB/D;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlD;AAUD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAoBnE"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ const SERVICE_NAME = "pax8-cta";
17
+ const ACCOUNT_NAME = "client-secret";
18
+ async function getKeytar() {
19
+ try {
20
+ const mod = (await import("keytar"));
21
+ const keytar = (mod.default || mod);
22
+ if (typeof keytar.getPassword === "function" &&
23
+ typeof keytar.setPassword === "function" &&
24
+ typeof keytar.deletePassword === "function") {
25
+ return keytar;
26
+ }
27
+ return null;
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
33
+ /**
34
+ * Get stored secret from OS keychain
35
+ */
36
+ export async function getStoredSecret() {
37
+ try {
38
+ const keytar = await getKeytar();
39
+ if (!keytar)
40
+ return null;
41
+ return await keytar.getPassword(SERVICE_NAME, ACCOUNT_NAME);
42
+ }
43
+ catch {
44
+ // If keytar fails (e.g., on unsupported platforms), return null
45
+ return null;
46
+ }
47
+ }
48
+ /**
49
+ * Probe whether the OS keychain is available without revealing the secret.
50
+ *
51
+ * Useful for status / config commands that need to report whether a stored
52
+ * credential exists. Returns one of:
53
+ * - "set" — keychain available and a secret is stored
54
+ * - "not-set" — keychain available but no secret stored
55
+ * - "unavailable" — keytar not installed or keychain unreadable
56
+ *
57
+ * Never returns or logs the secret value.
58
+ */
59
+ export async function probeStoredSecret() {
60
+ const keytar = await getKeytar();
61
+ if (!keytar)
62
+ return "unavailable";
63
+ try {
64
+ const value = await keytar.getPassword(SERVICE_NAME, ACCOUNT_NAME);
65
+ return value ? "set" : "not-set";
66
+ }
67
+ catch {
68
+ return "unavailable";
69
+ }
70
+ }
71
+ /**
72
+ * Store secret in OS keychain
73
+ */
74
+ export async function storeSecret(secret) {
75
+ if (!secret || secret.trim().length === 0) {
76
+ throw new Error("Secret cannot be empty");
77
+ }
78
+ const keytar = await getKeytar();
79
+ if (!keytar) {
80
+ const hint = process.platform === "win32"
81
+ ? "OS keychain is unavailable (keytar not installed — requires Visual Studio Build Tools on Windows).\n Set the PARTNER_CLIENT_SECRET environment variable or add it to .env instead."
82
+ : "OS keychain is unavailable (keytar not installed).\n Set the PARTNER_CLIENT_SECRET environment variable or add it to .env instead.";
83
+ throw new Error(hint);
84
+ }
85
+ try {
86
+ await keytar.setPassword(SERVICE_NAME, ACCOUNT_NAME, secret);
87
+ }
88
+ catch (error) {
89
+ const msg = error instanceof Error ? error.message : String(error);
90
+ throw new Error(`Failed to store secret in keychain: ${msg}`);
91
+ }
92
+ }
93
+ /**
94
+ * Remove secret from OS keychain
95
+ */
96
+ export async function deleteSecret() {
97
+ try {
98
+ const keytar = await getKeytar();
99
+ if (!keytar)
100
+ return;
101
+ await keytar.deletePassword(SERVICE_NAME, ACCOUNT_NAME);
102
+ }
103
+ catch {
104
+ // Ignore errors when deleting (secret may not exist)
105
+ }
106
+ }
107
+ /**
108
+ * Canonical environment variable names checked for the client secret,
109
+ * in priority order. PARTNER_CLIENT_SECRET is the primary name used
110
+ * in .env files and documentation; PAX8_CTA_CLIENT_SECRET is kept as
111
+ * a supported alias for backwards compatibility.
112
+ */
113
+ const CLIENT_SECRET_ENV_VARS = ["PARTNER_CLIENT_SECRET", "PAX8_CTA_CLIENT_SECRET"];
114
+ /**
115
+ * Resolve the client secret using a single, well-defined fallback chain.
116
+ *
117
+ * Priority:
118
+ * 1. Environment variables (PARTNER_CLIENT_SECRET, then PAX8_CTA_CLIENT_SECRET).
119
+ * These are populated either by the shell environment or by the .env loader
120
+ * in index.ts — so .env file values are included here automatically.
121
+ * 2. OS keychain (stored via `pax8-cta auth login`).
122
+ *
123
+ * Every CLI command that needs a client secret MUST call this function
124
+ * rather than reading process.env directly.
125
+ *
126
+ * @returns The client secret
127
+ * @throws Error if secret not found in any location
128
+ */
129
+ export async function getClientSecretWithFallback() {
130
+ // 1. Check environment variables (covers both shell env and .env file)
131
+ for (const envVar of CLIENT_SECRET_ENV_VARS) {
132
+ const value = process.env[envVar];
133
+ if (value) {
134
+ return value;
135
+ }
136
+ }
137
+ // 2. Fall back to OS keychain
138
+ const keychainSecret = await getStoredSecret();
139
+ if (keychainSecret) {
140
+ return keychainSecret;
141
+ }
142
+ throw new Error(`Client secret not found. Either:\n` +
143
+ ` 1. Set the PARTNER_CLIENT_SECRET environment variable (or add it to .env), OR\n` +
144
+ ` 2. Store it securely using: auth login`);
145
+ }
146
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/lib/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,YAAY,GAAG,UAAU,CAAC;AAChC,MAAM,YAAY,GAAG,eAAe,CAAC;AASrC,KAAK,UAAU,SAAS;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,CAA8C,CAAC;QAClF,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAe,CAAC;QAClD,IACE,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU;YACxC,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU;YACxC,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU,EAC3C,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,MAAM,GA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G,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,CAAC,uBAAuB,EAAE,wBAAwB,CAAU,CAAC;AAE5F;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,uEAAuE;IACvE,KAAK,MAAM,MAAM,IAAI,sBAAsB,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,MAAM,cAAc,GAAG,MAAM,eAAe,EAAE,CAAC;IAC/C,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,oCAAoC;QAClC,mFAAmF;QACnF,0CAA0C,CAC7C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ */
10
+ export declare function showDemoBanner(): void;
11
+ /**
12
+ * Reset the once-per-process flag. For tests only.
13
+ */
14
+ export declare function resetDemoBannerForTests(): void;
15
+ //# sourceMappingURL=demo-banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-banner.d.ts","sourceRoot":"","sources":["../../src/lib/demo-banner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAeH,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ */
10
+ import chalk from "chalk";
11
+ import { isQuietMode } from "./spinner.js";
12
+ /**
13
+ * One-shot demo banner.
14
+ *
15
+ * In a long-lived process (the REPL especially) we don't want every
16
+ * command to repeat "⚠️ DEMO MODE - …" — once per process is enough
17
+ * to set context. Banners go to stderr so JSON / quiet stdout stays
18
+ * clean for tooling.
19
+ */
20
+ let bannerShown = false;
21
+ export function showDemoBanner() {
22
+ if (bannerShown || isQuietMode())
23
+ return;
24
+ bannerShown = true;
25
+ console.error(chalk.yellow("\n⚠️ DEMO MODE — using mock data\n"));
26
+ }
27
+ /**
28
+ * Reset the once-per-process flag. For tests only.
29
+ */
30
+ export function resetDemoBannerForTests() {
31
+ bannerShown = false;
32
+ }
33
+ //# sourceMappingURL=demo-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-banner.js","sourceRoot":"","sources":["../../src/lib/demo-banner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,MAAM,UAAU,cAAc;IAC5B,IAAI,WAAW,IAAI,WAAW,EAAE;QAAE,OAAO;IACzC,WAAW,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright 2024 Pax8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Structured CLI error with recovery guidance.
18
+ *
19
+ * This wraps any error (typed or untyped) into a presentation-friendly
20
+ * format with causes, recovery steps, and context for the CLI output.
21
+ */
22
+ export declare class CtaError extends Error {
23
+ readonly code: string;
24
+ readonly causes: string[];
25
+ readonly recovery: string[];
26
+ readonly context?: {
27
+ environmentUrl?: string;
28
+ tenantName?: string;
29
+ solutionName?: string;
30
+ clientId?: string;
31
+ } | undefined;
32
+ constructor(code: string, message: string, causes: string[], recovery: string[], context?: {
33
+ environmentUrl?: string;
34
+ tenantName?: string;
35
+ solutionName?: string;
36
+ clientId?: string;
37
+ } | undefined);
38
+ }
39
+ /**
40
+ * Maps any error to a structured CtaError with recovery guidance.
41
+ *
42
+ * 1. If the error is a typed CtaError from @pax8-cta/core, the
43
+ * error code is used to select the appropriate guidance (no regex).
44
+ * 2. Otherwise, falls back to regex matching on the error message.
45
+ */
46
+ export declare function formatError(error: unknown): CtaError;
47
+ /**
48
+ * Prints a formatted error message with recovery guidance
49
+ */
50
+ export declare function printError(error: CtaError): void;
51
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/lib/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6BH;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,MAAM;aAEZ,MAAM,EAAE,MAAM,EAAE;aAChB,QAAQ,EAAE,MAAM,EAAE;aAClB,OAAO,CAAC,EAAE;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;gBATe,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,YAAA;CAKJ;AA8eD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAWpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAyChD"}