@stacksjs/ts-cloud 0.7.88 → 0.7.90

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 (56) hide show
  1. package/dist/bin/cli.js +127 -127
  2. package/dist/bin/dashboard-server.js +377 -377
  3. package/dist/bin/stacks-scheduler.js +1 -0
  4. package/dist/{chunk-ypp2f27t.js → chunk-gcehnzty.js} +2 -1
  5. package/dist/{chunk-99zbsqs4.js → chunk-hcdewpt6.js} +40 -20
  6. package/dist/deploy/index.js +2 -2
  7. package/dist/deploy/telemetry-collection.d.ts +6 -0
  8. package/dist/drivers/index.js +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/ui/account/automation.html +4 -4
  11. package/dist/ui/applications/compose.html +4 -4
  12. package/dist/ui/applications/new.html +2 -2
  13. package/dist/ui/data/backups.html +4 -4
  14. package/dist/ui/data/services.html +4 -4
  15. package/dist/ui/data/volumes.html +4 -4
  16. package/dist/ui/index.html +4 -4
  17. package/dist/ui/integrations.html +2 -2
  18. package/dist/ui/operations/alerts.html +4 -4
  19. package/dist/ui/operations/configuration.html +4 -4
  20. package/dist/ui/operations/jobs.html +4 -4
  21. package/dist/ui/operations/maintenance.html +3 -3
  22. package/dist/ui/operations/observability.html +4 -4
  23. package/dist/ui/operations/previews.html +4 -4
  24. package/dist/ui/operations/queue.html +4 -4
  25. package/dist/ui/operations/regions.html +4 -4
  26. package/dist/ui/operations/releases.html +4 -4
  27. package/dist/ui/operations/workloads.html +3 -3
  28. package/dist/ui/security.html +2 -2
  29. package/dist/ui/server/actions.html +4 -4
  30. package/dist/ui/server/activity.html +2 -2
  31. package/dist/ui/server/capacity.html +4 -4
  32. package/dist/ui/server/database.html +4 -4
  33. package/dist/ui/server/deployments.html +4 -4
  34. package/dist/ui/server/diagnostics.html +2 -2
  35. package/dist/ui/server/firewall.html +3 -3
  36. package/dist/ui/server/fleet.html +4 -4
  37. package/dist/ui/server/logs.html +4 -4
  38. package/dist/ui/server/metrics.html +3 -3
  39. package/dist/ui/server/services.html +2 -2
  40. package/dist/ui/server/sites.html +4 -4
  41. package/dist/ui/server/ssh-keys.html +4 -4
  42. package/dist/ui/server/team.html +4 -4
  43. package/dist/ui/server/terminal.html +2 -2
  44. package/dist/ui/serverless/alarms.html +4 -4
  45. package/dist/ui/serverless/assets.html +2 -2
  46. package/dist/ui/serverless/cost.html +2 -2
  47. package/dist/ui/serverless/data.html +4 -4
  48. package/dist/ui/serverless/firewall.html +2 -2
  49. package/dist/ui/serverless/functions.html +4 -4
  50. package/dist/ui/serverless/logs.html +4 -4
  51. package/dist/ui/serverless/metrics.html +2 -2
  52. package/dist/ui/serverless/queues.html +4 -4
  53. package/dist/ui/serverless/secrets.html +4 -4
  54. package/dist/ui/serverless/traces.html +4 -4
  55. package/dist/ui/serverless.html +3 -3
  56. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ import{existsSync as t}from"node:fs";import{resolve as c}from"node:path";import s from"node:process";import{pathToFileURL as n}from"node:url";s.env.APP_ENV||="production";s.env.NODE_ENV||="production";async function i(){let e=["storage/framework/core/actions/src/schedule/run.ts","node_modules/@stacksjs/actions/src/schedule/run.ts","node_modules/@stacksjs/actions/dist/schedule/run.js","node_modules/@stacksjs/actions/dist/src/schedule/run.js"].map((r)=>c(s.cwd(),r)).find(t);if(!e)throw Error("Stacks scheduler action was not found in the active release");await import(n(e).href)}i().catch((o)=>{console.error(o),s.exitCode=1});
@@ -5219,6 +5219,7 @@ function resolveSiteFramework(site) {
5219
5219
  var PANTRY_ENV_EVAL = `eval "$(cd ${PANTRY_PROJECT_DIR} && pantry env 2>/dev/null)"`;
5220
5220
  var BUN_BIN = "/usr/local/bin/bun";
5221
5221
  var STACKS_CLI = "storage/framework/core/buddy/src/cli.ts";
5222
+ var STACKS_SCHEDULER = "node_modules/@stacksjs/ts-cloud/dist/bin/stacks-scheduler.js";
5222
5223
  var stacksDriver = {
5223
5224
  id: "stacks",
5224
5225
  wrapExec: (command) => command,
@@ -5229,7 +5230,7 @@ var stacksDriver = {
5229
5230
  NODE_ENV: "production"
5230
5231
  },
5231
5232
  schedulerMode: "daemon",
5232
- schedulerCommand: () => `${BUN_BIN} ${STACKS_CLI} schedule:run`,
5233
+ schedulerCommand: () => `${BUN_BIN} ${STACKS_SCHEDULER}`,
5233
5234
  queueWorkerCommand: (worker, { current }) => {
5234
5235
  const flags = [
5235
5236
  `--queue=${worker.queue || "default"}`,
@@ -45,7 +45,7 @@ import {
45
45
  resolveSiteKind,
46
46
  resolveUiSource,
47
47
  siteInstallBase
48
- } from "./chunk-ypp2f27t.js";
48
+ } from "./chunk-gcehnzty.js";
49
49
  import {
50
50
  artifactKey,
51
51
  buildCloudFormationTemplate,
@@ -42151,8 +42151,26 @@ class TelemetryCollectionCache {
42151
42151
  this.entries.delete(key2);
42152
42152
  }
42153
42153
  }
42154
+
42155
+ class TelemetryMaintenanceGate {
42156
+ now;
42157
+ lastRun = new Map;
42158
+ constructor(now = Date.now) {
42159
+ this.now = now;
42160
+ }
42161
+ shouldRun(key2, intervalMs, force = false) {
42162
+ const now = this.now();
42163
+ const lastRun = this.lastRun.get(key2);
42164
+ if (!force && lastRun != null && now - lastRun < intervalMs)
42165
+ return false;
42166
+ this.lastRun.set(key2, now);
42167
+ return true;
42168
+ }
42169
+ }
42154
42170
  var collectionCache = new TelemetryCollectionCache;
42171
+ var maintenanceGate = new TelemetryMaintenanceGate;
42155
42172
  var MAX_COLLECTED_LOGS = 2000;
42173
+ var RETENTION_MAINTENANCE_INTERVAL_MS = 60 * 60000;
42156
42174
  function retainedByPolicy(record3, policy3) {
42157
42175
  if (record3.kind === "log" && !policy3.collectLogs)
42158
42176
  return false;
@@ -42602,30 +42620,32 @@ async function collectNow(context) {
42602
42620
  } catch (error2) {
42603
42621
  errors.push({ source: "runtime", message: error2 instanceof Error ? error2.message : String(error2) });
42604
42622
  }
42605
- for (const event of context.controlPlane.listEvents({ projectId: context.projectId, limit: 1000 })) {
42606
- const payload2 = event.payload;
42607
- records.push({
42608
- ...scope2,
42609
- id: `telemetry:event:${event.id}`,
42610
- resourceId: event.resourceId,
42611
- kind: "event",
42612
- source: "control-plane",
42613
- name: event.type,
42614
- timestamp: event.createdAt,
42615
- level: event.level,
42616
- message: event.type,
42617
- deploymentId: event.operationId,
42618
- releaseId: typeof payload2.releaseId === "string" ? payload2.releaseId : undefined,
42619
- traceId: event.correlationId,
42620
- attributes: payload2
42621
- });
42622
- }
42623
+ if (!context.lightweight)
42624
+ for (const event of context.controlPlane.listEvents({ projectId: context.projectId, limit: 1000 })) {
42625
+ const payload2 = event.payload;
42626
+ records.push({
42627
+ ...scope2,
42628
+ id: `telemetry:event:${event.id}`,
42629
+ resourceId: event.resourceId,
42630
+ kind: "event",
42631
+ source: "control-plane",
42632
+ name: event.type,
42633
+ timestamp: event.createdAt,
42634
+ level: event.level,
42635
+ message: event.type,
42636
+ deploymentId: event.operationId,
42637
+ releaseId: typeof payload2.releaseId === "string" ? payload2.releaseId : undefined,
42638
+ traceId: event.correlationId,
42639
+ attributes: payload2
42640
+ });
42641
+ }
42623
42642
  const retained = records.filter((record3) => retainedByPolicy(record3, policy3)).map((record3) => ({
42624
42643
  ...record3,
42625
42644
  sampled: policy3.samplingRate < 1 && (record3.kind === "log" || record3.kind === "trace" || record3.kind === "request" || record3.name.startsWith("request."))
42626
42645
  }));
42627
42646
  const inserted = telemetry2.appendMany(retained).length;
42628
- telemetry2.enforceRetention(policy3, context.projectId);
42647
+ if (maintenanceGate.shouldRun(context.projectId, RETENTION_MAINTENANCE_INTERVAL_MS, !context.lightweight))
42648
+ telemetry2.enforceRetention(policy3, context.projectId);
42629
42649
  const statuses = telemetry2.status(context.projectId, context.environmentId, policy3.rawDays, policy3.samplingRate);
42630
42650
  for (const error2 of errors)
42631
42651
  if (!statuses.some((status) => status.source === error2.source))
@@ -30,7 +30,7 @@ import {
30
30
  synchronizeDashboardUsers,
31
31
  trackDashboardOperation,
32
32
  verifyStaticApiOrigin
33
- } from "../chunk-99zbsqs4.js";
33
+ } from "../chunk-hcdewpt6.js";
34
34
  import {
35
35
  deleteStaticSite,
36
36
  deployStaticSite,
@@ -70,7 +70,7 @@ import {
70
70
  siteInstallBase,
71
71
  validateDeploymentConfig,
72
72
  verifyAddressRecord
73
- } from "../chunk-ypp2f27t.js";
73
+ } from "../chunk-gcehnzty.js";
74
74
  import"../chunk-hmehkeqx.js";
75
75
  import"../chunk-7m60qnc8.js";
76
76
  import"../chunk-4cjrg98a.js";
@@ -11,6 +11,12 @@ export declare class TelemetryCollectionCache<T> {
11
11
  }>;
12
12
  invalidate(prefix: string): void;
13
13
  }
14
+ export declare class TelemetryMaintenanceGate {
15
+ private readonly now;
16
+ private readonly lastRun;
17
+ constructor(now?: () => number);
18
+ shouldRun(key: string, intervalMs: number, force?: boolean): boolean;
19
+ }
14
20
  export interface TelemetryCollectionResult {
15
21
  collected: number;
16
22
  cached: boolean;
@@ -68,7 +68,7 @@ import {
68
68
  waitForSsh,
69
69
  wrapCloudInitUserData,
70
70
  writeResizeCheckpoint
71
- } from "../chunk-ypp2f27t.js";
71
+ } from "../chunk-gcehnzty.js";
72
72
  import"../chunk-hmehkeqx.js";
73
73
  import"../chunk-7m60qnc8.js";
74
74
  import"../chunk-4cjrg98a.js";
package/dist/index.js CHANGED
@@ -283,7 +283,7 @@ import {
283
283
  volumeCapabilities,
284
284
  webhookEndpoint,
285
285
  zeroCapacity
286
- } from "./chunk-99zbsqs4.js";
286
+ } from "./chunk-hcdewpt6.js";
287
287
  import {
288
288
  deleteStaticSite,
289
289
  deployStaticSite,
@@ -403,7 +403,7 @@ import {
403
403
  waitForCloudInit,
404
404
  waitForSsh,
405
405
  wrapCloudInitUserData
406
- } from "./chunk-ypp2f27t.js";
406
+ } from "./chunk-gcehnzty.js";
407
407
  import {
408
408
  ABTestManager,
409
409
  AI,