@devkong/cli 0.0.67-alpha.4 → 0.0.67-alpha.6

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.
package/index.js CHANGED
@@ -63094,12 +63094,12 @@ var ManagementClient = class {
63094
63094
  const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/aliases");
63095
63095
  return (await axios_default.get(url2, await this.requestConfigProvider())).data;
63096
63096
  }
63097
- async getAuditLog(objectType2, objectId) {
63097
+ async getAuditLog(objectType2, objectId, createdAfter) {
63098
63098
  const url2 = joinUrlAndPath(this.baseUrl, "v1/audit");
63099
63099
  const config = await this.requestConfigProvider();
63100
63100
  const response = await axios_default.get(url2, {
63101
63101
  ...config,
63102
- params: { ...config.params, objectType: objectType2, objectId }
63102
+ params: { ...config.params, objectType: objectType2, objectId, createdAfter }
63103
63103
  });
63104
63104
  return response.data;
63105
63105
  }
@@ -63432,7 +63432,7 @@ var PublishVersionCommand = class {
63432
63432
 
63433
63433
  // packages/kong-cli/src/common/deployment.ts
63434
63434
  var DEPLOY_SUCCESS_ACTIONS = /* @__PURE__ */ new Set(["deployment completed"]);
63435
- var DEPLOY_FAILURE_ACTIONS = /* @__PURE__ */ new Set(["deployment failed", "save deployment details"]);
63435
+ var DEPLOY_FAILURE_ACTIONS = /* @__PURE__ */ new Set(["deployment failed"]);
63436
63436
  function isFailureEvent(event) {
63437
63437
  return event.eventType === "error" || DEPLOY_FAILURE_ACTIONS.has(event.action);
63438
63438
  }
@@ -63453,8 +63453,12 @@ function analyzeDeployment(events) {
63453
63453
  }
63454
63454
  async function getDeploymentLog(management, query) {
63455
63455
  const [aliasEvents, baseEvents] = await Promise.all([
63456
- management.getAuditLog(query.objectType, `${query.basedOnId}-${query.aliasName}`),
63457
- management.getAuditLog(query.objectType, query.basedOnId)
63456
+ management.getAuditLog(
63457
+ query.objectType,
63458
+ `${query.basedOnId}-${query.aliasName}`,
63459
+ query.createdAfter
63460
+ ),
63461
+ management.getAuditLog(query.objectType, query.basedOnId, query.createdAfter)
63458
63462
  ]);
63459
63463
  return [...aliasEvents, ...baseEvents].sort((a, b) => b.created.localeCompare(a.created));
63460
63464
  }
@@ -63516,6 +63520,26 @@ function validateName(value) {
63516
63520
  );
63517
63521
  }
63518
63522
  }
63523
+ var DEPLOY_STEPS = [
63524
+ "start extension set alias",
63525
+ "create deployment",
63526
+ "health check",
63527
+ "save deployment details",
63528
+ "deployment completed"
63529
+ ];
63530
+ function createDeploySteps() {
63531
+ return DEPLOY_STEPS.map((action) => {
63532
+ const handlers = {
63533
+ resolve: () => void 0,
63534
+ reject: () => void 0
63535
+ };
63536
+ const done = new Promise((resolve2, reject) => {
63537
+ handlers.resolve = resolve2;
63538
+ handlers.reject = reject;
63539
+ });
63540
+ return { action, done, settle: (error) => error ? handlers.reject(error) : handlers.resolve() };
63541
+ });
63542
+ }
63519
63543
  var SetAliasCommand = class {
63520
63544
  constructor(profile) {
63521
63545
  this.profile = profile;
@@ -63525,6 +63549,7 @@ var SetAliasCommand = class {
63525
63549
  }
63526
63550
  async execute(aliasName, extensionVersion, timeoutSeconds) {
63527
63551
  validateName(aliasName);
63552
+ const startedAt = utcNow(DEFAULT_TIMEZONE);
63528
63553
  await new Listr(
63529
63554
  [
63530
63555
  {
@@ -63577,33 +63602,54 @@ var SetAliasCommand = class {
63577
63602
  },
63578
63603
  {
63579
63604
  title: "Wait for deployment",
63580
- task: async (ctx, task) => {
63605
+ // Render the known deployment steps as a checklist and tick each one
63606
+ // off as its audit event arrives. Polling runs alongside the subtask
63607
+ // list, settling a step per event and failing the rest on error; it
63608
+ // stops on the failed or "deployment completed" event (poll terminal).
63609
+ task: (ctx, task) => {
63610
+ const steps = createDeploySteps();
63611
+ const pending = new Map(steps.map((step) => [step.action, step]));
63581
63612
  const seen = /* @__PURE__ */ new Set();
63582
- const printNewEvents = (events) => {
63583
- for (const event of [...events].reverse()) {
63584
- const key = `${event.created}|${event.action}`;
63585
- if (seen.has(key)) {
63586
- continue;
63587
- }
63588
- seen.add(key);
63589
- task.output = `${event.eventType === "error" ? "\u2717" : "\u2713"} ${event.action}`;
63590
- }
63591
- };
63592
- const result = await pollDeployment(this.managementClient, {
63613
+ void pollDeployment(this.managementClient, {
63593
63614
  objectType: "EXTENSION_ALIAS",
63594
63615
  basedOnId: ctx.kongJson.id,
63595
63616
  aliasName,
63617
+ createdAfter: startedAt,
63596
63618
  timeoutSeconds,
63597
- onProgress: (progress) => printNewEvents(progress.events)
63619
+ onProgress: (progress) => {
63620
+ for (const event of [...progress.events].reverse()) {
63621
+ if (seen.has(event.action)) {
63622
+ continue;
63623
+ }
63624
+ seen.add(event.action);
63625
+ pending.get(event.action)?.settle();
63626
+ }
63627
+ }
63628
+ }).then((result) => {
63629
+ if (result.status === "failed") {
63630
+ const error = new AppError(deploymentErrorMessage(result.events));
63631
+ steps.forEach((step) => step.settle(error));
63632
+ } else if (result.timedOut) {
63633
+ const error = new AppError(
63634
+ `Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`
63635
+ );
63636
+ steps.forEach((step) => step.settle(error));
63637
+ } else {
63638
+ steps.forEach((step) => step.settle());
63639
+ }
63640
+ }).catch((error) => {
63641
+ const wrapped = error instanceof Error ? error : new AppError(String(error));
63642
+ steps.forEach((step) => step.settle(wrapped));
63598
63643
  });
63599
- if (result.status === "failed") {
63600
- throw new AppError(deploymentErrorMessage(result.events));
63601
- }
63602
- if (result.timedOut) {
63603
- task.output = `Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`;
63604
- }
63605
- },
63606
- rendererOptions: { bottomBar: Infinity, persistentOutput: true }
63644
+ return task.newListr(
63645
+ steps.map((step) => ({ title: step.action, task: () => step.done })),
63646
+ {
63647
+ concurrent: false,
63648
+ exitOnError: true,
63649
+ rendererOptions: { collapseSubtasks: false }
63650
+ }
63651
+ );
63652
+ }
63607
63653
  }
63608
63654
  ],
63609
63655
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.67-alpha.4",
3
+ "version": "0.0.67-alpha.6",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -12,6 +12,8 @@ export interface DeploymentQuery {
12
12
  objectType: DeployObjectType;
13
13
  basedOnId: string;
14
14
  aliasName: string;
15
+ /** Only fetch audit events created at/after this UTC timestamp (ISO-8601). */
16
+ createdAfter?: string;
15
17
  }
16
18
  export interface DeploymentResult {
17
19
  /**
@@ -11,5 +11,5 @@ export declare class ManagementClient {
11
11
  getExtensionSnapshot(extensionId: AppExtension["id"], extensionSnapshotVersion: AppSnapshot["version"]): Promise<Optional<AppSnapshotDetails>>;
12
12
  getExtensionSnapshotVersions(extensionId: AppExtension["id"]): Promise<AppSnapshot[]>;
13
13
  getExtensionSnapshotAliases(extensionId: AppExtension["id"]): Promise<AppExtensionAlias[]>;
14
- getAuditLog(objectType: DeployObjectType, objectId: string): Promise<AppAuditLog[]>;
14
+ getAuditLog(objectType: DeployObjectType, objectId: string, createdAfter?: string): Promise<AppAuditLog[]>;
15
15
  }