@hsuite/smart-engines-cli 1.2.0 → 1.4.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 (109) hide show
  1. package/README.md +272 -58
  2. package/dist/_lib/attestation.d.ts +45 -0
  3. package/dist/_lib/attestation.d.ts.map +1 -0
  4. package/dist/_lib/attestation.js +76 -0
  5. package/dist/_lib/attestation.js.map +1 -0
  6. package/dist/_lib/baas.d.ts +147 -0
  7. package/dist/_lib/baas.d.ts.map +1 -0
  8. package/dist/_lib/baas.js +260 -0
  9. package/dist/_lib/baas.js.map +1 -0
  10. package/dist/_lib/cluster.d.ts +6 -6
  11. package/dist/_lib/cluster.js +6 -6
  12. package/dist/_lib/deploy-manifest.d.ts +69 -0
  13. package/dist/_lib/deploy-manifest.d.ts.map +1 -0
  14. package/dist/_lib/deploy-manifest.js +87 -0
  15. package/dist/_lib/deploy-manifest.js.map +1 -0
  16. package/dist/_lib/docker.d.ts +82 -0
  17. package/dist/_lib/docker.d.ts.map +1 -0
  18. package/dist/_lib/docker.js +164 -0
  19. package/dist/_lib/docker.js.map +1 -0
  20. package/dist/_lib/faucet-client.d.ts +64 -0
  21. package/dist/_lib/faucet-client.d.ts.map +1 -0
  22. package/dist/_lib/faucet-client.js +92 -0
  23. package/dist/_lib/faucet-client.js.map +1 -0
  24. package/dist/_lib/framework.d.ts +59 -0
  25. package/dist/_lib/framework.d.ts.map +1 -0
  26. package/dist/_lib/framework.js +149 -0
  27. package/dist/_lib/framework.js.map +1 -0
  28. package/dist/_lib/frontend-guard.d.ts +13 -0
  29. package/dist/_lib/frontend-guard.d.ts.map +1 -0
  30. package/dist/_lib/frontend-guard.js +41 -0
  31. package/dist/_lib/frontend-guard.js.map +1 -0
  32. package/dist/_lib/registry-fanout.d.ts +114 -0
  33. package/dist/_lib/registry-fanout.d.ts.map +1 -0
  34. package/dist/_lib/registry-fanout.js +435 -0
  35. package/dist/_lib/registry-fanout.js.map +1 -0
  36. package/dist/_lib/runtime-env.d.ts +126 -0
  37. package/dist/_lib/runtime-env.d.ts.map +1 -0
  38. package/dist/_lib/runtime-env.js +172 -0
  39. package/dist/_lib/runtime-env.js.map +1 -0
  40. package/dist/_lib/subscription-client.d.ts +129 -18
  41. package/dist/_lib/subscription-client.d.ts.map +1 -1
  42. package/dist/_lib/subscription-client.js +268 -40
  43. package/dist/_lib/subscription-client.js.map +1 -1
  44. package/dist/_lib/subscription-env.d.ts +35 -0
  45. package/dist/_lib/subscription-env.d.ts.map +1 -1
  46. package/dist/_lib/subscription-env.js +46 -2
  47. package/dist/_lib/subscription-env.js.map +1 -1
  48. package/dist/commands/app-lifecycle.d.ts +36 -0
  49. package/dist/commands/app-lifecycle.d.ts.map +1 -0
  50. package/dist/commands/app-lifecycle.js +145 -0
  51. package/dist/commands/app-lifecycle.js.map +1 -0
  52. package/dist/commands/ci.d.ts +45 -0
  53. package/dist/commands/ci.d.ts.map +1 -0
  54. package/dist/commands/ci.js +174 -0
  55. package/dist/commands/ci.js.map +1 -0
  56. package/dist/commands/deploy-manifest.d.ts +11 -0
  57. package/dist/commands/deploy-manifest.d.ts.map +1 -0
  58. package/dist/commands/deploy-manifest.js +17 -0
  59. package/dist/commands/deploy-manifest.js.map +1 -0
  60. package/dist/commands/deploy.d.ts +70 -11
  61. package/dist/commands/deploy.d.ts.map +1 -1
  62. package/dist/commands/deploy.js +263 -150
  63. package/dist/commands/deploy.js.map +1 -1
  64. package/dist/commands/downgrade.js +1 -1
  65. package/dist/commands/downgrade.js.map +1 -1
  66. package/dist/commands/faucet.d.ts +78 -0
  67. package/dist/commands/faucet.d.ts.map +1 -0
  68. package/dist/commands/faucet.js +184 -0
  69. package/dist/commands/faucet.js.map +1 -0
  70. package/dist/commands/governance.js +1 -1
  71. package/dist/commands/governance.js.map +1 -1
  72. package/dist/commands/hist-balance.d.ts +1 -1
  73. package/dist/commands/hist-balance.js +1 -1
  74. package/dist/commands/init.js +1 -1
  75. package/dist/commands/list.d.ts +22 -0
  76. package/dist/commands/list.d.ts.map +1 -0
  77. package/dist/commands/list.js +81 -0
  78. package/dist/commands/list.js.map +1 -0
  79. package/dist/commands/personhood.js +2 -2
  80. package/dist/commands/personhood.js.map +1 -1
  81. package/dist/commands/redeploy.d.ts +62 -0
  82. package/dist/commands/redeploy.d.ts.map +1 -0
  83. package/dist/commands/redeploy.js +310 -0
  84. package/dist/commands/redeploy.js.map +1 -0
  85. package/dist/commands/status.d.ts +51 -0
  86. package/dist/commands/status.d.ts.map +1 -0
  87. package/dist/commands/status.js +138 -0
  88. package/dist/commands/status.js.map +1 -0
  89. package/dist/commands/subscribe.d.ts +94 -17
  90. package/dist/commands/subscribe.d.ts.map +1 -1
  91. package/dist/commands/subscribe.js +450 -81
  92. package/dist/commands/subscribe.js.map +1 -1
  93. package/dist/commands/transactions.d.ts +60 -0
  94. package/dist/commands/transactions.d.ts.map +1 -0
  95. package/dist/commands/transactions.js +101 -0
  96. package/dist/commands/transactions.js.map +1 -0
  97. package/dist/commands/update.d.ts +40 -0
  98. package/dist/commands/update.d.ts.map +1 -0
  99. package/dist/commands/update.js +114 -0
  100. package/dist/commands/update.js.map +1 -0
  101. package/dist/commands/verify.d.ts +10 -19
  102. package/dist/commands/verify.d.ts.map +1 -1
  103. package/dist/commands/verify.js +14 -23
  104. package/dist/commands/verify.js.map +1 -1
  105. package/dist/index.d.ts +12 -3
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +32 -3
  108. package/dist/index.js.map +1 -1
  109. package/package.json +11 -4
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.redeployCommand = void 0;
40
+ exports.runRedeploy = runRedeploy;
41
+ /**
42
+ * `hsuite redeploy` — redeploy an EXISTING smart-app (same appId, fresh push
43
+ * creds, a new image tag and/or a new frontend bundle).
44
+ *
45
+ * Mirrors `deploy` but re-binds to an EXISTING app instead of forking a new one:
46
+ * - resolves the target appId (flag → DEPLOYED_APP_ID) and authenticates as
47
+ * the subscription identity (SUBSCRIPTION_APP_ID → target). Auth is by XRPL
48
+ * wallet; the bound appId is only client context (the host authorizes by
49
+ * wallet → developerWallet ownership of the target appId).
50
+ * - calls `reissuePushCredentials(appId)` for fresh single-use push creds —
51
+ * NOT `init`, which would mint a brand-new app + DKG entity + paid
52
+ * subscription on every run (~20 XRP/run + a new appId each time).
53
+ * - `--tag` overrides the manifest's `backend.tag`.
54
+ *
55
+ * The manifest is the ONE canonical shape (backend required, frontend optional):
56
+ * redeploy always rebuilds + pushes the backend image and re-uploads the SPA
57
+ * bundle when a `frontend` block is present, then `deploy()`s.
58
+ *
59
+ * Same trusted-deploy attestation as `deploy` (the host's deploy policy is
60
+ * hardened-by-default).
61
+ */
62
+ const commander_1 = require("commander");
63
+ const chalk_1 = __importDefault(require("chalk"));
64
+ const fs_1 = require("fs");
65
+ const path_1 = require("path");
66
+ const os_1 = require("os");
67
+ const env_1 = require("../_lib/env");
68
+ const subscription_env_1 = require("../_lib/subscription-env");
69
+ const runtime_env_1 = require("../_lib/runtime-env");
70
+ const cluster_1 = require("../_lib/cluster");
71
+ const framework_1 = require("../_lib/framework");
72
+ const baas_1 = require("../_lib/baas");
73
+ const registry_fanout_1 = require("../_lib/registry-fanout");
74
+ const attestation_1 = require("../_lib/attestation");
75
+ const deploy_manifest_1 = require("../_lib/deploy-manifest");
76
+ const frontend_guard_1 = require("../_lib/frontend-guard");
77
+ const status_1 = require("./status");
78
+ /** Pure orchestration body — exported for unit tests. */
79
+ async function runRedeploy(opts) {
80
+ const manifest = (0, deploy_manifest_1.parseManifest)(opts.manifestPath);
81
+ const env = (0, env_1.readEnv)(opts.envPath);
82
+ const b = manifest.backend;
83
+ const tag = opts.tag ?? b.tag;
84
+ const detection = (0, framework_1.detectFramework)(opts.projectDir);
85
+ const sdkVersion = (0, framework_1.resolveSdkVersion)(opts.projectDir, detection);
86
+ // Auth IDENTITY (subscription) ≠ management TARGET (deployed app). The
87
+ // deployed app holds no subscription, so authenticate as the developer's
88
+ // subscription identity; the reissue below operates on the deployed appId.
89
+ // Auth is by XRPL wallet — the bound appId is only client context; the host
90
+ // authorizes by wallet → developerWallet ownership of the target appId.
91
+ // (Under mint-first/deploy-last `SUBSCRIPTION_APP_ID == DEPLOYED_APP_ID`, so
92
+ // these usually resolve to the same id; the split is retained because a
93
+ // developer MAY pass a distinct deployed --app-id.)
94
+ const subscriptionAppId = (0, subscription_env_1.requireSubscriptionAppId)(env, {
95
+ subscriptionAppId: opts.subscriptionAppId,
96
+ });
97
+ // Resolve the EXISTING app to redeploy: explicit flag → DEPLOYED_APP_ID.
98
+ // No subscription fallback — the subscription is the auth identity above, not
99
+ // a deploy target; a subscribe-but-never-deployed state has nothing to redeploy.
100
+ const appId = opts.appId ?? env.get('DEPLOYED_APP_ID');
101
+ if (!appId) {
102
+ throw new Error('No app to redeploy. Pass --app-id <id> or run `hsuite deploy` first (sets DEPLOYED_APP_ID).');
103
+ }
104
+ const client = await (0, baas_1.connectAndAuth)({
105
+ gateway: opts.gateway,
106
+ env,
107
+ appId: subscriptionAppId,
108
+ clientFactory: opts.clientFactory,
109
+ });
110
+ // Reissue ephemeral push creds for the EXISTING app — no fork, no new entity,
111
+ // no new subscription. Hits `POST /apps/:appId/credentials/reissue` (the
112
+ // dedicated redeploy route, distinct from deploy's `credentials/push`): the
113
+ // host asserts ownership + an ACTIVE subscription, refuses SUSPENDED apps, and
114
+ // (idempotently) rotates the per-app Harbor push robot.
115
+ const creds = await client.deployment.reissuePushCredentials(appId);
116
+ console.log(chalk_1.default.gray(` push creds reissued: appId=${creds.appId} registry=${creds.registry.repository}`));
117
+ if (!tag)
118
+ throw new Error('a backend redeploy needs a tag (manifest.backend.tag or --tag)');
119
+ // Captures the pushed image's `sha256:<64hex>` manifest digest — the
120
+ // attestation binds to THIS, not the tag-form ref (the host requires it ===
121
+ // the digest Harbor serves for the tag).
122
+ const imageDigest = (0, baas_1.buildAndPush)({
123
+ registry: creds.registry,
124
+ tag,
125
+ context: (0, path_1.resolve)(b.context ?? '.'),
126
+ dockerfile: b.dockerfile ?? 'Dockerfile',
127
+ platform: b.platform,
128
+ build: b.build,
129
+ skipBuild: opts.skipBuild,
130
+ skipPush: opts.skipPush,
131
+ dockerHost: opts.dockerHost,
132
+ name: manifest.name,
133
+ runFn: opts.runFn,
134
+ });
135
+ console.log(chalk_1.default.gray(` pushed: ${creds.registry.repository}:${tag} (${imageDigest})`));
136
+ // Fan the pushed image out to EVERY cluster Harbor before reconciling — the
137
+ // federated registry host round-robins, so the single push landed on one
138
+ // cluster. Blocks (throws → exit 1) unless every cluster serves the digest.
139
+ if (!opts.skipDistribute) {
140
+ await (0, registry_fanout_1.fanOutPushedImage)({
141
+ registry: creds.registry,
142
+ tag,
143
+ digest: imageDigest,
144
+ log: (m) => console.log(chalk_1.default.gray(m)),
145
+ });
146
+ }
147
+ // Relative `frontend.dir`/`bundlePath` (and the frontend build hook) resolve
148
+ // against the smart-app root — `backend.context` when present, else
149
+ // `--project` — NOT the CLI's process.cwd(). (Same cwd class as the backend
150
+ // build: a bare `public` must mean `<smart-app>/public`.)
151
+ const baseDir = (0, path_1.resolve)(b.context ?? opts.projectDir);
152
+ let bundleSha256 = '';
153
+ if (manifest.frontend) {
154
+ const bundlePath = await resolveFrontendBundle(manifest, baseDir, opts.runFn);
155
+ const bundle = await fs_1.promises.readFile(bundlePath);
156
+ const upload = await client.deployment.uploadFrontend(appId, bundle);
157
+ bundleSha256 = upload.bundleSha256;
158
+ console.log(chalk_1.default.gray(` frontend: sha256=${bundleSha256.slice(0, 12)}…`));
159
+ }
160
+ // Forward the developer's `.env.local` runtime creds into the deployed
161
+ // customer-env (issue #1564) — same as `deploy`. `manifest.backend.env` wins
162
+ // for explicit non-secret overrides; secrets ride from `.env.local`. Resolved
163
+ // BEFORE the attestation-seed check so a credential-less redeploy fails with
164
+ // the specific #1564 remedy. FAILS LOUD unless `--allow-open-mode` (which then
165
+ // withholds the seed from the container while still signing locally).
166
+ const runtimeEnv = (0, runtime_env_1.resolveRuntimeEnv)({
167
+ env,
168
+ manifestEnv: b.env,
169
+ allowOpenMode: opts.allowOpenMode,
170
+ warn: (m) => console.warn(chalk_1.default.yellow(` ⚠ ${m}`)),
171
+ });
172
+ console.log(chalk_1.default.gray(` runtime env: ${Object.keys(runtimeEnv).length} vars forwarded from ${opts.envPath} + manifest` +
173
+ (runtimeEnv.XRPL_SEED ? ' (cluster mode)' : ' (open mode)')));
174
+ // The host's hardened deploy policy requires a signed attestation, so the seed
175
+ // is needed to SIGN regardless of open/cluster mode.
176
+ const seed = env.get('XRPL_SEED');
177
+ if (!seed)
178
+ throw new Error('XRPL_SEED required to sign the build attestation');
179
+ const signed = (0, attestation_1.assembleAndSign)({
180
+ appId,
181
+ developerWallet: env.get('XRPL_ADDRESS') ?? '',
182
+ developerChain: 'xrpl',
183
+ framework: detection.framework,
184
+ sdkVersion,
185
+ // The pushed image's `sha256:<64hex>` registry manifest digest (captured
186
+ // by buildAndPush) — bound with strict equality by the host, so it MUST
187
+ // be the digest, not the tag-form ref the gate would reject.
188
+ imageDigest,
189
+ bundleSha256,
190
+ cliVersion: (0, attestation_1.readCliVersion)(),
191
+ }, seed);
192
+ const url = await deployBackend(client, appId, manifest, tag, signed, runtimeEnv, opts.strategy);
193
+ // Block until the runtime settles (default on) — see deploy.ts for rationale.
194
+ if (opts.wait !== false) {
195
+ const status = await (0, status_1.waitForRunning)(client, appId, {
196
+ intervalMs: opts.waitIntervalMs,
197
+ maxPolls: opts.waitMaxPolls,
198
+ sleep: opts.sleep,
199
+ });
200
+ console.log(chalk_1.default.gray(` runtime: ${status.runtime?.runtimeState ?? status.state}`));
201
+ if (status.runtime?.runtimeState === 'FAILED') {
202
+ throw new Error(`redeploy reached FAILED runtime for ${appId}` +
203
+ (status.runtime?.lastError ? `: ${status.runtime.lastError}` : ''));
204
+ }
205
+ }
206
+ return { appId, url };
207
+ }
208
+ /**
209
+ * Resolve the frontend bundle to a tarball path: `bundlePath` wins; otherwise
210
+ * tar `dir` (running its optional `build` first) into a temp `.tar`.
211
+ *
212
+ * `baseDir` is the smart-app root (`backend.context` / `--project`); relative
213
+ * `dir`/`bundlePath` resolve against it, NOT the CLI's process.cwd(), and the
214
+ * optional pre-build hook runs with `cwd` set to the resolved `dir`.
215
+ */
216
+ async function resolveFrontendBundle(manifest, baseDir, runFn) {
217
+ const f = manifest.frontend;
218
+ if (f.bundlePath) {
219
+ const p = (0, path_1.resolve)(baseDir, f.bundlePath);
220
+ if (!(0, fs_1.existsSync)(p))
221
+ throw new Error(`frontend bundle not found: ${p}`);
222
+ return p;
223
+ }
224
+ const dir = (0, path_1.resolve)(baseDir, f.dir);
225
+ if (!(0, fs_1.existsSync)(dir))
226
+ throw new Error(`frontend dir not found: ${dir}`);
227
+ // Optional pre-build (e.g. `ng build`) — run via the injected seam IN `dir`
228
+ // (a real chdir; `PWD` alone does not move the child's working directory).
229
+ if (f.build) {
230
+ const run = runFn ?? (await Promise.resolve().then(() => __importStar(require('child_process')))).execFileSync;
231
+ run('sh', ['-c', f.build], {
232
+ stdio: 'inherit',
233
+ cwd: dir,
234
+ env: { ...process.env, PWD: dir },
235
+ });
236
+ }
237
+ // Fail-closed: never re-ship a bundle that still carries unfilled
238
+ // REPLACE_BEFORE_DEPLOY placeholders (shared with `deploy`). See frontend-guard.
239
+ await (0, frontend_guard_1.assertNoDeploySentinels)(dir);
240
+ const out = (0, path_1.join)((0, os_1.tmpdir)(), `hsuite-frontend-${Date.now()}.tar`);
241
+ return (0, baas_1.tarFrontend)({ dir, out, runFn });
242
+ }
243
+ async function deployBackend(client, appId, manifest, tag, attestation, runtimeEnv, strategy) {
244
+ const b = manifest.backend;
245
+ const body = {
246
+ tag,
247
+ port: b.port,
248
+ replicas: b.replicas ?? 1,
249
+ degree: manifest.degree,
250
+ // Resolved runtime env — `.env.local` runtime creds merged with
251
+ // `manifest.backend.env` (manifest wins) — NOT `manifest.backend.env` alone
252
+ // (issue #1564). Mirrored into the PQC-encrypted customer-env Secret.
253
+ env: runtimeEnv,
254
+ resources: b.limits,
255
+ ...(strategy ? { strategy } : {}),
256
+ attestation,
257
+ };
258
+ const res = await client.deployment.deploy(appId, body);
259
+ return res.url;
260
+ }
261
+ exports.redeployCommand = new commander_1.Command('redeploy')
262
+ .description('Redeploy an existing smart-app (same appId, new tag and/or frontend bundle)')
263
+ .requiredOption('--manifest <file>', 'JSON manifest path')
264
+ .option('--env <file>', 'Env file with auth creds', '.env.local')
265
+ .option('--project <dir>', 'Smart-app project root (for SDK/framework detection)', '.')
266
+ .option('--gateway <url>', 'Smart-engines gateway URL', cluster_1.DEFAULT_GATEWAY)
267
+ .option('--app-id <id>', 'Existing deployed appId to redeploy (else DEPLOYED_APP_ID)')
268
+ .option('--subscription-app-id <id>', 'Subscription appId to authenticate as (else SUBSCRIPTION_APP_ID)')
269
+ .option('--tag <tag>', 'Override the backend image tag (else manifest.backend.tag)')
270
+ .option('--strategy <strategy>', 'Update strategy: rolling | recreate')
271
+ .option('--docker-host <host>', 'DOCKER_HOST for the build/push (defaults to $DOCKER_HOST)')
272
+ .option('--skip-build', 'Skip `docker build`', false)
273
+ .option('--skip-push', 'Skip `docker push`', false)
274
+ .option('--skip-distribute', 'Skip the multi-cluster image fan-out (single-cluster / dev registry)', false)
275
+ .option('--allow-open-mode', 'Allow an intentional zero-cred / open-mode redeploy (no XRPL_SEED forwarded). Default: a credential-less redeploy FAILS LOUD (#1564).', false)
276
+ .option('--no-wait', 'Do not block until the runtime settles — exit as soon as deploy() is accepted (default: wait for RUNNING/FAILED)')
277
+ .action(async (opts) => {
278
+ console.log(chalk_1.default.bold.cyan('\n hsuite redeploy\n'));
279
+ let result;
280
+ try {
281
+ result = await runRedeploy({
282
+ manifestPath: opts.manifest,
283
+ envPath: opts.env,
284
+ gateway: opts.gateway,
285
+ projectDir: opts.project,
286
+ appId: opts.appId,
287
+ subscriptionAppId: opts.subscriptionAppId,
288
+ tag: opts.tag,
289
+ strategy: opts.strategy,
290
+ dockerHost: opts.dockerHost ?? process.env.DOCKER_HOST,
291
+ skipBuild: opts.skipBuild,
292
+ skipPush: opts.skipPush,
293
+ skipDistribute: opts.skipDistribute,
294
+ allowOpenMode: opts.allowOpenMode,
295
+ wait: opts.wait,
296
+ });
297
+ }
298
+ catch (err) {
299
+ if (err instanceof framework_1.NoSdkError) {
300
+ console.error(chalk_1.default.red(`\n ✗ ${err.message}\n`));
301
+ }
302
+ else {
303
+ console.error(chalk_1.default.red(`\n ✗ ${err.message}\n`));
304
+ }
305
+ process.exit(1);
306
+ }
307
+ (0, env_1.upsertEnv)(opts.env, { DEPLOYED_APP_ID: result.appId });
308
+ console.log(chalk_1.default.bold.green(`\n ✓ redeployed: ${result.url}\n`));
309
+ });
310
+ //# sourceMappingURL=redeploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redeploy.js","sourceRoot":"","sources":["../../src/commands/redeploy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,kCAwJC;AAxOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,yCAAoC;AACpC,kDAA0B;AAC1B,2BAAgD;AAChD,+BAAqC;AACrC,2BAA4B;AAI5B,qCAAiD;AACjD,+DAAoE;AACpE,qDAAwD;AACxD,6CAAkD;AAClD,iDAAmF;AACnF,uCAAqF;AACrF,6DAA4D;AAC5D,qDAA8F;AAC9F,6DAAuE;AACvE,2DAAiE;AACjE,qCAA0C;AAwC1C,yDAAyD;AAClD,KAAK,UAAU,WAAW,CAAC,IAAkB;IAClD,MAAM,QAAQ,GAAG,IAAA,+BAAa,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,IAAA,aAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC;IAE9B,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAEjE,uEAAuE;IACvE,yEAAyE;IACzE,2EAA2E;IAC3E,4EAA4E;IAC5E,wEAAwE;IACxE,6EAA6E;IAC7E,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,iBAAiB,GAAG,IAAA,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e,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `hsuite status` — live lifecycle + runtime status of a deployed app.
3
+ *
4
+ * Renders `state` (PENDING_SUBSCRIPTION | ACTIVE | SUSPENDED | RETIRED) plus the
5
+ * runtime sub-view (runtimeState / replicas / lastError) when present. `--json`
6
+ * prints the raw `BaasRuntimeStatus`; `--watch` polls until the runtime reaches
7
+ * a terminal state (RUNNING / FAILED) or the app is no longer ACTIVE.
8
+ */
9
+ import { Command } from 'commander';
10
+ import type { BaasClient, BaasRuntimeStatus } from '@hsuite/smart-engines-sdk';
11
+ import { connectAndAuth } from '../_lib/baas';
12
+ export type StatusOpts = {
13
+ envPath: string;
14
+ gateway: string;
15
+ /** Management TARGET — the deployed app to inspect. */
16
+ appId?: string;
17
+ /** Auth IDENTITY — the developer's subscription appId. */
18
+ subscriptionAppId?: string;
19
+ watch?: boolean;
20
+ /** Poll interval (ms) for --watch. Default 5000. */
21
+ watchIntervalMs?: number;
22
+ /** Max --watch polls before giving up. Default 60 (~5 min at 5s). */
23
+ watchMaxPolls?: number;
24
+ clientFactory?: Parameters<typeof connectAndAuth>[0]['clientFactory'];
25
+ /** Injectable sleep for tests. Defaults to setTimeout. */
26
+ sleep?: (ms: number) => Promise<void>;
27
+ };
28
+ /** A runtime is "settled" once it can no longer transition on its own. */
29
+ export declare function isTerminal(s: BaasRuntimeStatus): boolean;
30
+ /**
31
+ * Poll a deployed app's runtime until it settles (RUNNING / FAILED /
32
+ * NOT_DEPLOYED, or the app is no longer ACTIVE) or the poll budget is exhausted.
33
+ * Shared by `hsuite deploy --wait` / `redeploy --wait` so a deploy blocks until
34
+ * the runtime actually converges instead of printing a URL that isn't live yet.
35
+ * Never throws on a FAILED runtime — returns the final status so the caller
36
+ * decides the exit code.
37
+ */
38
+ export declare function waitForRunning(client: BaasClient, appId: string, opts?: {
39
+ intervalMs?: number;
40
+ maxPolls?: number;
41
+ sleep?: (ms: number) => Promise<void>;
42
+ }): Promise<BaasRuntimeStatus>;
43
+ /**
44
+ * Pure orchestration body — exported for unit tests. Returns the final
45
+ * `BaasRuntimeStatus` (after watching, when `--watch`).
46
+ */
47
+ export declare function runStatus(opts: StatusOpts): Promise<BaasRuntimeStatus>;
48
+ /** Human-readable one-block render of a status. */
49
+ export declare function renderStatus(status: BaasRuntimeStatus): string;
50
+ export declare const statusCommand: Command;
51
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK/E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IACtE,0DAA0D;IAC1D,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAGxD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAO,GAC3F,OAAO,CAAC,iBAAiB,CAAC,CAY5B;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+B5E;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAgB9D;AAED,eAAO,MAAM,aAAa,SAgCtB,CAAC"}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.statusCommand = void 0;
7
+ exports.isTerminal = isTerminal;
8
+ exports.waitForRunning = waitForRunning;
9
+ exports.runStatus = runStatus;
10
+ exports.renderStatus = renderStatus;
11
+ /**
12
+ * `hsuite status` — live lifecycle + runtime status of a deployed app.
13
+ *
14
+ * Renders `state` (PENDING_SUBSCRIPTION | ACTIVE | SUSPENDED | RETIRED) plus the
15
+ * runtime sub-view (runtimeState / replicas / lastError) when present. `--json`
16
+ * prints the raw `BaasRuntimeStatus`; `--watch` polls until the runtime reaches
17
+ * a terminal state (RUNNING / FAILED) or the app is no longer ACTIVE.
18
+ */
19
+ const commander_1 = require("commander");
20
+ const chalk_1 = __importDefault(require("chalk"));
21
+ const env_1 = require("../_lib/env");
22
+ const subscription_env_1 = require("../_lib/subscription-env");
23
+ const cluster_1 = require("../_lib/cluster");
24
+ const baas_1 = require("../_lib/baas");
25
+ /** A runtime is "settled" once it can no longer transition on its own. */
26
+ function isTerminal(s) {
27
+ const rs = s.runtime?.runtimeState;
28
+ return s.state !== 'ACTIVE' || rs === 'RUNNING' || rs === 'FAILED' || rs === 'NOT_DEPLOYED';
29
+ }
30
+ /**
31
+ * Poll a deployed app's runtime until it settles (RUNNING / FAILED /
32
+ * NOT_DEPLOYED, or the app is no longer ACTIVE) or the poll budget is exhausted.
33
+ * Shared by `hsuite deploy --wait` / `redeploy --wait` so a deploy blocks until
34
+ * the runtime actually converges instead of printing a URL that isn't live yet.
35
+ * Never throws on a FAILED runtime — returns the final status so the caller
36
+ * decides the exit code.
37
+ */
38
+ async function waitForRunning(client, appId, opts = {}) {
39
+ const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
40
+ const interval = opts.intervalMs ?? 5000;
41
+ const maxPolls = opts.maxPolls ?? 60;
42
+ let status = await client.deployment.status(appId);
43
+ let polls = 0;
44
+ while (!isTerminal(status) && polls < maxPolls) {
45
+ await sleep(interval);
46
+ status = await client.deployment.status(appId);
47
+ polls++;
48
+ }
49
+ return status;
50
+ }
51
+ /**
52
+ * Pure orchestration body — exported for unit tests. Returns the final
53
+ * `BaasRuntimeStatus` (after watching, when `--watch`).
54
+ */
55
+ async function runStatus(opts) {
56
+ const env = (0, env_1.readEnv)(opts.envPath);
57
+ // Auth IDENTITY (subscription) ≠ management TARGET (deployed app). The host
58
+ // gates /api/v3/baas/auth/* on the authenticated appId's subscription; the deployed
59
+ // app holds none, so we authenticate as the developer's subscription and
60
+ // pass the deployed app as the call target.
61
+ const appId = (0, subscription_env_1.requireAppId)(env, { appId: opts.appId });
62
+ const subscriptionAppId = (0, subscription_env_1.requireSubscriptionAppId)(env, {
63
+ subscriptionAppId: opts.subscriptionAppId,
64
+ });
65
+ const client = await (0, baas_1.connectAndAuth)({
66
+ gateway: opts.gateway,
67
+ env,
68
+ appId: subscriptionAppId,
69
+ clientFactory: opts.clientFactory,
70
+ });
71
+ let status = await client.deployment.status(appId);
72
+ if (opts.watch) {
73
+ const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
74
+ const interval = opts.watchIntervalMs ?? 5000;
75
+ const maxPolls = opts.watchMaxPolls ?? 60;
76
+ let polls = 0;
77
+ while (!isTerminal(status) && polls < maxPolls) {
78
+ await sleep(interval);
79
+ status = await client.deployment.status(appId);
80
+ polls++;
81
+ }
82
+ }
83
+ return status;
84
+ }
85
+ /** Human-readable one-block render of a status. */
86
+ function renderStatus(status) {
87
+ const lines = [
88
+ ` appId: ${status.appId}`,
89
+ ` state: ${status.state}`,
90
+ ];
91
+ if (status.runtime) {
92
+ lines.push(` runtimeState: ${status.runtime.runtimeState}`);
93
+ lines.push(` replicas: ${status.runtime.replicas}`);
94
+ if (status.runtime.image)
95
+ lines.push(` image: ${status.runtime.image}`);
96
+ if (status.runtime.lastReconciledAt)
97
+ lines.push(` reconciled: ${status.runtime.lastReconciledAt}`);
98
+ if (status.runtime.lastError)
99
+ lines.push(` lastError: ${status.runtime.lastError}`);
100
+ }
101
+ else {
102
+ lines.push(' runtime: (not deployed)');
103
+ }
104
+ return lines.join('\n');
105
+ }
106
+ exports.statusCommand = new commander_1.Command('status')
107
+ .description('Show a deployed app’s lifecycle + runtime status')
108
+ .option('--env <file>', 'Env file with auth creds', '.env.local')
109
+ .option('--gateway <url>', 'Smart-engines gateway URL', cluster_1.DEFAULT_GATEWAY)
110
+ .option('--app-id <id>', 'App to inspect (else DEPLOYED_APP_ID / SUBSCRIPTION_APP_ID)')
111
+ .option('--subscription-app-id <id>', 'Subscription appId to authenticate as (else SUBSCRIPTION_APP_ID)')
112
+ .option('--watch', 'Poll until the runtime settles (RUNNING / FAILED)', false)
113
+ .option('--json', 'Print the raw status JSON', false)
114
+ .action(async (opts) => {
115
+ if (!opts.json)
116
+ console.log(chalk_1.default.bold.cyan('\n hsuite status\n'));
117
+ let status;
118
+ try {
119
+ status = await runStatus({
120
+ envPath: opts.env,
121
+ gateway: opts.gateway,
122
+ appId: opts.appId,
123
+ subscriptionAppId: opts.subscriptionAppId,
124
+ watch: opts.watch,
125
+ });
126
+ }
127
+ catch (err) {
128
+ console.error(chalk_1.default.red(`\n ✗ ${err.message}\n`));
129
+ process.exit(1);
130
+ }
131
+ if (opts.json) {
132
+ process.stdout.write(JSON.stringify(status, null, 2) + '\n');
133
+ return;
134
+ }
135
+ console.log(renderStatus(status));
136
+ console.log('');
137
+ });
138
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;;;;;AAmCA,gCAGC;AAUD,wCAgBC;AAMD,8BA+BC;AAGD,oCAgBC;AAxHD;;;;;;;GAOG;AACH,yCAAoC;AACpC,kDAA0B;AAG1B,qCAAsC;AACtC,+DAAkF;AAClF,6CAAkD;AAClD,uCAA8C;AAmB9C,0EAA0E;AAC1E,SAAgB,UAAU,CAAC,CAAoB;IAC7C,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC;IACnC,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,cAAc,CAAC;AAC9F,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,MAAkB,EAClB,KAAa,EACb,OAA0F,EAAE;IAE5F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACzC,MAAM,Q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