@ericminassian/platform-core 0.4.1 → 0.5.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 (49) hide show
  1. package/dist/api.d.ts +89 -231
  2. package/dist/api.js +49 -92
  3. package/dist/api.js.map +1 -1
  4. package/dist/config.d.ts +0 -2
  5. package/dist/config.js.map +1 -1
  6. package/dist/constants.d.ts +0 -17
  7. package/dist/constants.js +0 -17
  8. package/dist/constants.js.map +1 -1
  9. package/dist/explore.d.ts +35 -33
  10. package/dist/explore.js +32 -32
  11. package/dist/explore.js.map +1 -1
  12. package/dist/index.d.ts +0 -1
  13. package/dist/index.js +0 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/jobs.d.ts +1 -1
  16. package/dist/jobs.js +1 -1
  17. package/dist/manifest.d.ts +10 -47
  18. package/dist/manifest.js +7 -15
  19. package/dist/manifest.js.map +1 -1
  20. package/dist/naming.d.ts +7 -23
  21. package/dist/naming.js +7 -23
  22. package/dist/naming.js.map +1 -1
  23. package/dist/platform-api.d.ts +3996 -4466
  24. package/dist/platform-api.js +19 -36
  25. package/dist/platform-api.js.map +1 -1
  26. package/dist/runtime-config.d.ts +0 -20
  27. package/dist/runtime-config.js.map +1 -1
  28. package/dist/telemetry.d.ts +40 -25
  29. package/dist/telemetry.js +55 -17
  30. package/dist/telemetry.js.map +1 -1
  31. package/dist/web-compute.js +2 -1
  32. package/dist/web-compute.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/api.ts +57 -110
  35. package/src/config.ts +0 -2
  36. package/src/constants.ts +0 -19
  37. package/src/explore.ts +31 -31
  38. package/src/index.ts +0 -1
  39. package/src/jobs.ts +1 -1
  40. package/src/manifest.ts +15 -48
  41. package/src/naming.ts +7 -25
  42. package/src/platform-api.ts +25 -38
  43. package/src/runtime-config.ts +0 -21
  44. package/src/telemetry.ts +57 -17
  45. package/src/web-compute.ts +3 -1
  46. package/dist/compute.d.ts +0 -52
  47. package/dist/compute.js +0 -65
  48. package/dist/compute.js.map +0 -1
  49. package/src/compute.ts +0 -86
package/src/api.ts CHANGED
@@ -20,10 +20,19 @@ const optional = Schema.optional;
20
20
  // Records
21
21
  // ---------------------------------------------------------------------------
22
22
 
23
+ /** A GitHub repository's visibility, as its Actions OIDC tokens state it. */
24
+ export const RepoVisibility = Schema.Literals(['public', 'private', 'internal']);
25
+ export type RepoVisibility = typeof RepoVisibility.Type;
26
+
23
27
  export const AppRecord = Schema.Struct({
24
28
  name: Schema.String,
25
29
  /** GitHub `owner/name` allowed to deploy this app from CI. */
26
30
  repo: Schema.String,
31
+ /**
32
+ * The repo's visibility at its last CI deploy (absent before one): the
33
+ * public directory links a public repo. Changing `repo` forgets it.
34
+ */
35
+ repoVisibility: optional(RepoVisibility),
27
36
  description: optional(Schema.String),
28
37
  /** GitHub usernames who can manage the app (admins can manage everything). */
29
38
  owners: Schema.Array(Schema.String),
@@ -200,21 +209,59 @@ export const AppSummary = Schema.Struct({
200
209
  traffic: optional(Schema.Array(Schema.Finite)),
201
210
  /** The app's alert rules on every stage: how many there are and how many are firing. */
202
211
  alerts: optional(Schema.Struct({ total: Schema.Finite, alarm: Schema.Finite })),
212
+ /** Whether the public directory lists prod: its live deployment's `listed` (absent without one). */
213
+ listed: optional(Schema.Boolean),
203
214
  });
204
215
  export type AppSummary = typeof AppSummary.Type;
205
216
 
217
+ // ---------------------------------------------------------------------------
218
+ // Public directory
219
+ // ---------------------------------------------------------------------------
220
+
221
+ /** Days of traffic the public directory gives each app. */
222
+ export const PUBLIC_DIRECTORY_DAYS = 30;
223
+
224
+ /** An app in the public directory: its prod stage, as anyone may see it. */
225
+ export const PublicApp = Schema.Struct({
226
+ name: Schema.String,
227
+ /** The live deployment's `description` in plat.config.ts, else the app's own. */
228
+ description: optional(Schema.String),
229
+ url: Schema.String,
230
+ /** The GitHub repository's page, when the repo is public. */
231
+ source: optional(Schema.String),
232
+ /** When prod was first deployed. */
233
+ liveSince: Schema.String,
234
+ /** When the deployment prod serves went live (a compute switch keeps its build's time). */
235
+ lastDeployedAt: Schema.String,
236
+ /** Whether prod was up at the uptime pinger's last result; null before its first. */
237
+ up: Schema.NullOr(Schema.Boolean),
238
+ /** Pages the router served for prod's host on each of `days` (`isPageView`); today's so far. */
239
+ pageViews: Schema.Array(Schema.Finite),
240
+ /** Every request the router served for it on each of `days`: files, server and stores. */
241
+ requests: Schema.Array(Schema.Finite),
242
+ });
243
+ export type PublicApp = typeof PublicApp.Type;
244
+
245
+ /** Every app whose live prod deployment is `listed` (the default), by name. */
246
+ export const PublicAppsResponse = Schema.Struct({
247
+ generatedAt: Schema.String,
248
+ /** The UTC days the counts cover (`YYYY-MM-DD`), oldest first, ending today (so far). */
249
+ days: Schema.Array(Schema.String),
250
+ /**
251
+ * The first UTC day the router's access log counted (`YYYY-MM-DD`): days
252
+ * before it have no counts, rather than no traffic. Absent where the
253
+ * platform has no access log (`plat dev`).
254
+ */
255
+ countingSince: optional(Schema.String),
256
+ apps: Schema.Array(PublicApp),
257
+ });
258
+ export type PublicAppsResponse = typeof PublicAppsResponse.Type;
259
+
206
260
  // ---------------------------------------------------------------------------
207
261
  // Stages and deployments
208
262
  // ---------------------------------------------------------------------------
209
263
 
210
- /** `services.zip` holds `<service>/index.mjs` (+ `.map`) for each long-running service. */
211
- export const ArtifactFile = Schema.Literals([
212
- 'manifest.json',
213
- 'server.zip',
214
- 'worker.zip',
215
- 'static.zip',
216
- 'services.zip',
217
- ]);
264
+ export const ArtifactFile = Schema.Literals(['manifest.json', 'server.zip', 'worker.zip', 'static.zip']);
218
265
  export type ArtifactFile = typeof ArtifactFile.Type;
219
266
 
220
267
  export const PresignedPost = Schema.Struct({
@@ -248,7 +295,6 @@ export const CreateDeploymentResponse = Schema.Struct({
248
295
  'server.zip': optional(PresignedPost),
249
296
  'worker.zip': optional(PresignedPost),
250
297
  'static.zip': optional(PresignedPost),
251
- 'services.zip': optional(PresignedPost),
252
298
  }),
253
299
  });
254
300
  export type CreateDeploymentResponse = typeof CreateDeploymentResponse.Type;
@@ -310,7 +356,7 @@ export const RouteStats = Schema.Struct({
310
356
  });
311
357
  export type RouteStats = typeof RouteStats.Type;
312
358
 
313
- export const JobKind = Schema.Literals(['queue', 'event', 'cron', 'invoke', 'service']);
359
+ export const JobKind = Schema.Literals(['queue', 'event', 'cron', 'invoke']);
314
360
  export type JobKind = typeof JobKind.Type;
315
361
 
316
362
  export const JobStats = Schema.Struct({
@@ -558,7 +604,7 @@ export type ErrorGroup = typeof ErrorGroup.Type;
558
604
  export const UpdateErrorRequest = Schema.Struct({ status: ErrorStatus });
559
605
  export type UpdateErrorRequest = typeof UpdateErrorRequest.Type;
560
606
 
561
- /** Log stream of a line: `web`, `worker`, or `service:<name>` for a long-running service. */
607
+ /** Log stream of a line: `web` or `worker`. */
562
608
  export const LogStream = Schema.String;
563
609
  export type LogStream = typeof LogStream.Type;
564
610
 
@@ -722,28 +768,6 @@ export type UptimeTraffic = typeof UptimeTraffic.Type;
722
768
  export const UptimePoint = Schema.Union([UptimeCheck, UptimeTraffic]);
723
769
  export type UptimePoint = typeof UptimePoint.Type;
724
770
 
725
- /** Monthly cost of one container if it runs all month (`estimateContainerCost`). */
726
- export const MonthlyContainerCost = Schema.Struct({
727
- computeUsd: Schema.Finite,
728
- publicIpv4Usd: Schema.Finite,
729
- totalUsd: Schema.Finite,
730
- });
731
-
732
- /**
733
- * Something billed for as long as it runs, estimated from its size because
734
- * Cost Explorer lags a day and doesn't attribute every part of it to the
735
- * app (a container's public IPv4 address).
736
- */
737
- export const AlwaysOnCost = Schema.Struct({
738
- stage: Schema.String,
739
- kind: Schema.Literal('service'),
740
- name: Schema.String,
741
- /** `0.25 vCPU · 512 MB · Spot`. */
742
- detail: Schema.String,
743
- monthly: MonthlyContainerCost,
744
- });
745
- export type AlwaysOnCost = typeof AlwaysOnCost.Type;
746
-
747
771
  /** A non-preview stage's server: how it runs, and (prod) what each mode would cost. */
748
772
  export const StageCompute = Schema.Struct({
749
773
  stage: Schema.String,
@@ -760,8 +784,6 @@ export const CostResponse = Schema.Struct({
760
784
  currency: Schema.Literal('USD'),
761
785
  days: Schema.Array(Schema.Struct({ date: Schema.String, usd: Schema.Finite })),
762
786
  monthToDateUsd: Schema.Finite,
763
- /** Services of the app's non-preview stages (previews run theirs for minutes after a deploy). */
764
- alwaysOn: optional(Schema.Array(AlwaysOnCost)),
765
787
  /** Servers of the app's non-preview stages (previews run request mode). */
766
788
  compute: optional(Schema.Array(StageCompute)),
767
789
  });
@@ -834,80 +856,6 @@ export const UrlResponse = Schema.Struct({ url: Schema.String });
834
856
  export type UrlResponse = typeof UrlResponse.Type;
835
857
 
836
858
  export const CronRunResponse = Schema.Struct({ started: Schema.String });
837
-
838
- // ---------------------------------------------------------------------------
839
- // Long-running services
840
- // ---------------------------------------------------------------------------
841
-
842
- /**
843
- * - `running`: every desired task is up and the latest rollout finished
844
- * - `starting`: a rollout or replacement is under way
845
- * - `failing`: tasks keep stopping before they settle, or the last rollout failed
846
- * - `stopped`: scaled to zero (a preview past its minutes, or `plat services stop`)
847
- */
848
- export const ServiceState = Schema.Literals(['running', 'starting', 'failing', 'stopped']);
849
- export type ServiceState = typeof ServiceState.Type;
850
-
851
- export const ServiceInfo = Schema.Struct({
852
- name: Schema.String,
853
- /** Size and capacity the live deployment declares. */
854
- cpu: Schema.Finite,
855
- memoryMb: Schema.Finite,
856
- spot: Schema.Boolean,
857
- state: ServiceState,
858
- desired: Schema.Finite,
859
- running: Schema.Finite,
860
- pending: Schema.Finite,
861
- /** Deployment whose build the service runs. */
862
- deployment: optional(Schema.String),
863
- /** When the current task started. */
864
- startedAt: optional(Schema.String),
865
- /** When a preview's stop schedule scales it to zero. */
866
- stopsAt: optional(Schema.String),
867
- /** The task that stopped most recently (ECS keeps stopped tasks for about an hour). */
868
- lastStop: optional(
869
- Schema.Struct({ at: Schema.String, reason: Schema.String, exitCode: optional(Schema.Finite) }),
870
- ),
871
- /** Recent ECS service events, newest first. */
872
- events: Schema.Array(Schema.Struct({ at: Schema.String, message: Schema.String })),
873
- /** Containers started in the range: deploys, crashes, Spot replacements. */
874
- starts: Schema.Finite,
875
- /** Runs of `run` that failed and were rerun in the same container, in the range. */
876
- failedRuns: Schema.Finite,
877
- /** CPU and memory use, % of the task's size (ECS's per-service CloudWatch metrics). */
878
- points: Schema.Array(
879
- Schema.Struct({
880
- ts: Schema.String,
881
- cpu: Schema.NullOr(Schema.Finite),
882
- memory: Schema.NullOr(Schema.Finite),
883
- }),
884
- ),
885
- /** If it ran all month. */
886
- monthly: MonthlyContainerCost,
887
- });
888
- export type ServiceInfo = typeof ServiceInfo.Type;
889
-
890
- export const ServicesResponse = Schema.Struct({
891
- app: Schema.String,
892
- stage: Schema.String,
893
- res: Resolution,
894
- services: Schema.Array(ServiceInfo),
895
- });
896
- export type ServicesResponse = typeof ServicesResponse.Type;
897
-
898
- export const StartServiceRequest = Schema.Struct({
899
- /** Stop it again after this many minutes. Previews default to the service's `previewMinutes`. */
900
- minutes: optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1440 }))),
901
- });
902
- export type StartServiceRequest = typeof StartServiceRequest.Encoded;
903
-
904
- export const ServiceActionResponse = Schema.Struct({
905
- name: Schema.String,
906
- /** Tasks the service now asks for (1 running, 0 stopped). */
907
- desired: Schema.Finite,
908
- stopsAt: optional(Schema.String),
909
- });
910
- export type ServiceActionResponse = typeof ServiceActionResponse.Type;
911
859
  export type CronRunResponse = typeof CronRunResponse.Type;
912
860
 
913
861
  // ---------------------------------------------------------------------------
@@ -922,7 +870,6 @@ export const AdminOverview = Schema.Struct({
922
870
  emailsPerDay: Schema.Finite,
923
871
  edgeRequestsPerMinute: optional(Schema.Finite),
924
872
  edgeFloorAt: optional(Schema.Finite),
925
- servicesPerApp: Schema.Finite,
926
873
  }),
927
874
  apps: Schema.Finite,
928
875
  stages: Schema.Finite,
package/src/config.ts CHANGED
@@ -53,8 +53,6 @@ export interface PlatformConfig {
53
53
  * this rate. Set both or neither; without them there is no floor.
54
54
  */
55
55
  edgeFloorAt?: number;
56
- /** Long-running services one stage's plat.config.ts may declare: the one resource billed while idle. */
57
- servicesPerApp: number;
58
56
  };
59
57
  telemetry: { logRetentionDays: { prod: number; other: number } };
60
58
  }
package/src/constants.ts CHANGED
@@ -86,8 +86,6 @@ export const TAGS = {
86
86
  managed: 'platform:managed',
87
87
  app: 'platform:app',
88
88
  stage: 'platform:stage',
89
- /** On resources built per deployment (a service's task definition), so it can be found again. */
90
- deployment: 'platform:deployment',
91
89
  } as const;
92
90
 
93
91
  /** The production stage. Its host has no stage suffix. */
@@ -97,20 +95,3 @@ export const LOCAL_STAGE = 'local';
97
95
 
98
96
  /** Lambda runtime for Web Functions, request-mode servers and worker (Event) Functions. */
99
97
  export const NODE_RUNTIME = 'nodejs24.x';
100
-
101
- /**
102
- * Base of every container image the platform builds: Node.js 24 on Debian
103
- * slim, linux/arm64, pinned to one image manifest (not the multi-platform
104
- * index). The engine copies it from ECR Public into the platform's
105
- * repository the first time a deploy needs it, so bumping it is a deliberate
106
- * change: look up the arm64 entry of the tag's index and update both fields.
107
- */
108
- export const CONTAINER_BASE_IMAGE = {
109
- registry: 'public.ecr.aws',
110
- repository: 'docker/library/node',
111
- tag: '24-slim',
112
- digest: 'sha256:5f8fabfed57b75127de2f584593d67a9e8c90e6b0f65652871f9ef0f759c0299',
113
- } as const;
114
-
115
- /** Environment variable naming the service a container runs (`ais`). */
116
- export const SERVICE_ENV = 'PLATFORM_SERVICE';
package/src/explore.ts CHANGED
@@ -4,8 +4,10 @@
4
4
  * alert rules from it; the CLI sends it.
5
5
  *
6
6
  * Every metric is read from the rollups the telemetry processor writes
7
- * (`telemetryKeys`), except `realtime` and `service`, which come from
8
- * CloudWatch on demand and so can't be watched by alert rules.
7
+ * (`telemetryKeys`), except `realtime`, which comes from CloudWatch on
8
+ * demand and so can't be watched by alert rules. Neither can
9
+ * `page_views` and `edge_requests`: the router's access log they come from
10
+ * arrives up to an hour late.
9
11
  */
10
12
  import { Schema } from 'effect';
11
13
 
@@ -63,18 +65,21 @@ export function autoQueryResolution(
63
65
 
64
66
  /**
65
67
  * What a query measures:
66
- * - `requests`: HTTP requests (stage-wide, or of routes)
68
+ * - `requests`: HTTP requests (stage-wide, or of routes) the stage's server handled
69
+ * - `page_views`: pages the router served for the stage's host (`isPageView`)
70
+ * - `edge_requests`: every request the router served for it: files, server, stores
67
71
  * - `latency`: their duration
68
72
  * - `cold_starts`: requests served by a fresh server process
69
- * - `jobs`: queue, event, cron, invoke and service runs
73
+ * - `jobs`: queue, event, cron and invoke runs
70
74
  * - `job_duration`: their duration
71
75
  * - `custom`: the app's `Metrics.count`/`value` series
72
76
  * - `rate_limit`: `RateLimits` checks
73
77
  * - `realtime`: AppSync Events activity (CloudWatch)
74
- * - `service`: long-running services' CPU and memory (CloudWatch)
75
78
  */
76
79
  export const SeriesMetric = Schema.Literals([
77
80
  'requests',
81
+ 'page_views',
82
+ 'edge_requests',
78
83
  'latency',
79
84
  'cold_starts',
80
85
  'jobs',
@@ -82,7 +87,6 @@ export const SeriesMetric = Schema.Literals([
82
87
  'custom',
83
88
  'rate_limit',
84
89
  'realtime',
85
- 'service',
86
90
  ]);
87
91
  export type SeriesMetric = typeof SeriesMetric.Type;
88
92
 
@@ -93,7 +97,7 @@ export type SeriesMetric = typeof SeriesMetric.Type;
93
97
  * - `percent`: the share, 0–100, of the metric's events that match the
94
98
  * status or outcome filter, among all of them in the bucket (5xx % of
95
99
  * requests, failed % of runs, denied % of checks)
96
- * - `sum`, `avg`, `max`: of recorded values (custom metrics, realtime, service)
100
+ * - `sum`, `avg`, `max`: of recorded values (custom metrics, realtime)
97
101
  * - `p50`…`p99`: latency percentiles, from the rollups' fixed-bucket histograms
98
102
  * (each is the upper bound of the bucket holding it)
99
103
  * - `histogram`: every latency bucket's count, for heatmaps
@@ -129,15 +133,15 @@ const nonEmpty = Schema.String.check(Schema.isNonEmpty());
129
133
  export const SeriesFilter = Schema.Struct({
130
134
  /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
131
135
  routes: optional(Schema.Array(nonEmpty)),
132
- /** `requests` only. */
136
+ /** `requests` and `edge_requests` only. */
133
137
  status: optional(Schema.Array(StatusClass)),
134
138
  /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
135
139
  jobs: optional(Schema.Array(nonEmpty)),
136
- /** Custom metric names, rate limit names, or service names. */
140
+ /** Custom metric names or rate limit names. */
137
141
  names: optional(Schema.Array(nonEmpty)),
138
142
  /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
139
143
  outcome: optional(SeriesOutcome),
140
- /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
144
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`. */
141
145
  measure: optional(nonEmpty),
142
146
  });
143
147
  export type SeriesFilter = typeof SeriesFilter.Type;
@@ -155,6 +159,8 @@ export type SeriesQuery = typeof SeriesQuery.Type;
155
159
  /** The statistics each metric answers; the first is its default. */
156
160
  export const METRIC_STATS: Record<SeriesMetric, readonly SeriesStat[]> = {
157
161
  requests: ['count', 'rate', 'percent'],
162
+ page_views: ['count', 'rate'],
163
+ edge_requests: ['count', 'rate', 'percent'],
158
164
  latency: ['p95', 'p50', 'p90', 'p99', 'histogram'],
159
165
  cold_starts: ['count', 'percent'],
160
166
  jobs: ['count', 'rate', 'percent'],
@@ -162,12 +168,13 @@ export const METRIC_STATS: Record<SeriesMetric, readonly SeriesStat[]> = {
162
168
  custom: ['sum', 'avg', 'count', 'max'],
163
169
  rate_limit: ['count', 'percent'],
164
170
  realtime: ['sum'],
165
- service: ['avg', 'max'],
166
171
  };
167
172
 
168
173
  /** The dimensions each metric can be grouped by. */
169
174
  export const METRIC_GROUP_BY: Record<SeriesMetric, readonly SeriesGroupBy[]> = {
170
175
  requests: ['status', 'route'],
176
+ page_views: [],
177
+ edge_requests: ['status'],
171
178
  latency: ['route'],
172
179
  cold_starts: [],
173
180
  jobs: ['job', 'outcome'],
@@ -175,10 +182,9 @@ export const METRIC_GROUP_BY: Record<SeriesMetric, readonly SeriesGroupBy[]> = {
175
182
  custom: ['name'],
176
183
  rate_limit: ['name', 'outcome'],
177
184
  realtime: [],
178
- service: ['name'],
179
185
  };
180
186
 
181
- /** Metrics alert rules can watch: those read from rollups. */
187
+ /** Metrics alert rules can watch: those read from rollups written as their events happen. */
182
188
  export const ALERT_METRICS: readonly SeriesMetric[] = [
183
189
  'requests',
184
190
  'latency',
@@ -190,7 +196,6 @@ export const ALERT_METRICS: readonly SeriesMetric[] = [
190
196
  ];
191
197
 
192
198
  export const REALTIME_MEASURES = ['events', 'publishes', 'subscribes', 'errors'] as const;
193
- export const SERVICE_MEASURES = ['cpu', 'memory'] as const;
194
199
 
195
200
  /**
196
201
  * Why a query can't be answered, or undefined when it can. `alert` also
@@ -211,7 +216,9 @@ export function checkSeriesQuery(
211
216
  : `${q.metric} can't be grouped`;
212
217
  }
213
218
  const f = q.filter ?? {};
214
- if (f.status?.length && q.metric !== 'requests') return 'only requests filter by status';
219
+ if (f.status?.length && q.metric !== 'requests' && q.metric !== 'edge_requests') {
220
+ return 'only requests and edge requests filter by status';
221
+ }
215
222
  if (f.routes?.length && q.metric !== 'requests' && q.metric !== 'latency' && q.metric !== 'cold_starts') {
216
223
  return 'only requests, latency and cold starts filter by route';
217
224
  }
@@ -225,8 +232,8 @@ export function checkSeriesQuery(
225
232
  : `${q.metric} doesn't filter by outcome`;
226
233
  }
227
234
  }
228
- if (f.names?.length && q.metric !== 'custom' && q.metric !== 'rate_limit' && q.metric !== 'service') {
229
- return 'only custom metrics, rate limits and services filter by name';
235
+ if (f.names?.length && q.metric !== 'custom' && q.metric !== 'rate_limit') {
236
+ return 'only custom metrics and rate limits filter by name';
230
237
  }
231
238
  if (q.metric === 'custom' && !f.names?.length && q.groupBy !== 'name') {
232
239
  return 'a custom metric query names its metric, or groups by name';
@@ -234,12 +241,7 @@ export function checkSeriesQuery(
234
241
  if (q.metric === 'realtime' && !REALTIME_MEASURES.some((m) => m === f.measure)) {
235
242
  return `realtime measures one of ${REALTIME_MEASURES.join(', ')}`;
236
243
  }
237
- if (q.metric === 'service' && !SERVICE_MEASURES.some((m) => m === f.measure)) {
238
- return `service measures ${SERVICE_MEASURES.join(' or ')}`;
239
- }
240
- if (q.metric !== 'realtime' && q.metric !== 'service' && f.measure) {
241
- return 'only realtime and service queries take a measure';
242
- }
244
+ if (q.metric !== 'realtime' && f.measure) return 'only realtime queries take a measure';
243
245
  if (options.alert) {
244
246
  if (!ALERT_METRICS.includes(q.metric)) return `alert rules can't watch ${q.metric}`;
245
247
  if (q.stat === 'histogram') return 'alert rules watch one number, not a histogram';
@@ -265,13 +267,13 @@ const STAT_UNIT: Record<SeriesStat, string> = {
265
267
  };
266
268
 
267
269
  export function seriesUnit(q: Pick<SeriesQuery, 'metric' | 'stat' | 'filter'>): string {
268
- const unit = STAT_UNIT[q.stat];
269
- // Service CPU and memory are percentages of what the task reserved.
270
- return unit === 'count' && q.metric === 'service' ? 'percent' : unit;
270
+ return STAT_UNIT[q.stat];
271
271
  }
272
272
 
273
273
  const METRIC_NOUN: Record<SeriesMetric, string> = {
274
274
  requests: 'requests',
275
+ page_views: 'page views',
276
+ edge_requests: 'edge requests',
275
277
  latency: 'latency',
276
278
  cold_starts: 'cold starts',
277
279
  jobs: 'job runs',
@@ -279,7 +281,6 @@ const METRIC_NOUN: Record<SeriesMetric, string> = {
279
281
  custom: 'custom metric',
280
282
  rate_limit: 'rate limit checks',
281
283
  realtime: 'realtime',
282
- service: 'service',
283
284
  };
284
285
 
285
286
  /**
@@ -318,9 +319,6 @@ export function describeQuery(q: SeriesQuery): string {
318
319
  case 'realtime':
319
320
  head = `realtime ${f.measure ?? 'events'}`;
320
321
  break;
321
- case 'service':
322
- head = `${q.stat} ${f.measure ?? 'cpu'}${f.names?.length ? ` of ${f.names.join(', ')}` : ''}`;
323
- break;
324
322
  case 'rate_limit':
325
323
  head =
326
324
  q.stat === 'percent'
@@ -329,6 +327,8 @@ export function describeQuery(q: SeriesQuery): string {
329
327
  if (f.names?.length) head += ` (${f.names.join(', ')})`;
330
328
  break;
331
329
  case 'requests':
330
+ case 'page_views':
331
+ case 'edge_requests':
332
332
  case 'latency':
333
333
  case 'cold_starts':
334
334
  case 'jobs':
@@ -385,7 +385,7 @@ export type LogLevelName = typeof LogLevelName.Type;
385
385
  */
386
386
  export const LogFilters = Schema.Struct({
387
387
  levels: optional(Schema.Array(LogLevelName)),
388
- /** `web`, `worker` or `service:<name>`. */
388
+ /** `web` or `worker`. */
389
389
  streams: optional(Schema.Array(nonEmpty)),
390
390
  /** Route patterns (without the method), e.g. `/api/items/:id`. */
391
391
  routes: optional(Schema.Array(nonEmpty)),
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './api.ts';
2
2
  export * from './auth.ts';
3
3
  export * from './bindings.ts';
4
- export * from './compute.ts';
5
4
  export * from './config.ts';
6
5
  export * from './constants.ts';
7
6
  export * from './cron.ts';
package/src/jobs.ts CHANGED
@@ -70,7 +70,7 @@ export const handlerKey = (kind: HandlerKind, name: string): string => `${kind}:
70
70
  /**
71
71
  * Name of the one-shot schedule for a retry or delayed send (≤ 64 chars of
72
72
  * Scheduler's alphabet). It leads with `_`, which no cron key (a cron's own
73
- * schedule) or service stop schedule (`<key>--stop`) starts with, then the
73
+ * schedule) starts with, then the
74
74
  * kind and queue or cron key, so the console can count what's waiting per
75
75
  * queue with a name prefix. Event types can be long and contain `:`, so they
76
76
  * are hashed.
package/src/manifest.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Effect, Schema } from 'effect';
2
- import { FARGATE_CPUS, type FargateCpu, fargateSizeIssue } from './compute.ts';
3
2
  import { validateCron } from './cron.ts';
4
3
  import { EMAIL_DEFAULT_DAILY_LIMIT, EMAIL_NAME_MESSAGE, EMAIL_NAME_PATTERN } from './email.ts';
5
4
  import { DEFAULT_ATTEMPTS, MAX_ATTEMPTS } from './jobs.ts';
@@ -133,19 +132,6 @@ const StoreSchema = Schema.Struct({
133
132
  public: Schema.Boolean.pipe(orElse(false)),
134
133
  expireAfterDays: Schema.optional(intBetween(1, 3650)),
135
134
  });
136
- const ServiceSchema = Schema.Struct({
137
- entry: Schema.String,
138
- cpu: Schema.Literals(FARGATE_CPUS).pipe(orElse(0.25)),
139
- memoryMb: Schema.Int.pipe(orElse(512)),
140
- spot: Schema.Boolean.pipe(orElse(true)),
141
- previewMinutes: intBetween(0, 1440).pipe(orElse(30)),
142
- }).check(
143
- Schema.makeFilter((s) => {
144
- const issue = fargateSizeIssue(s.cpu, s.memoryMb);
145
- return issue ? [{ path: ['memoryMb'], issue }] : undefined;
146
- }),
147
- );
148
-
149
135
  const RealtimeSubscribeSchema = Schema.Literals(['public', 'signed-in']);
150
136
 
151
137
  const EmailSchema = Schema.Union([
@@ -171,6 +157,7 @@ export const ManifestSchema = Schema.Struct({
171
157
  Schema.isPattern(APP_NAME_PATTERN, { message: 'must be 3-30 chars of a-z, 0-9, single hyphens' }),
172
158
  ),
173
159
  description: Schema.optional(Schema.String.check(Schema.isMaxLength(200))),
160
+ listed: Schema.Boolean.pipe(orElse(true)),
174
161
  web: Schema.optional(WebSchema),
175
162
  worker: Schema.optional(WorkerSchema),
176
163
  auth: AuthSchema.pipe(orElse(false)),
@@ -191,7 +178,11 @@ export const ManifestSchema = Schema.Struct({
191
178
  env: recordOf(ENV_NAME_PATTERN, Schema.String).pipe(orElse({})),
192
179
  realtime: Schema.optional(RealtimeSchema),
193
180
  email: EmailSchema.pipe(orElse(false)),
194
- services: recordOf(RESOURCE_KEY_PATTERN, ServiceSchema, RESOURCE_KEY_MESSAGE).pipe(orElse({})),
181
+ // Long-running services ran on Fargate until 0.5.0. Each paid for its vCPU, memory and public
182
+ // IPv4 address all month, the only part of an app billed while idle.
183
+ services: removed(
184
+ 'removed in 0.5.0: hold a connection from a cron instead, listening for a while each run',
185
+ ),
195
186
  }).check(
196
187
  Schema.makeFilter((m) => {
197
188
  if (!m.realtime) return undefined;
@@ -336,34 +327,6 @@ export interface StoreConfig {
336
327
  expireAfterDays?: number;
337
328
  }
338
329
 
339
- /**
340
- * A long-running process: it holds connections open (WebSocket or
341
- * server-sent-event sources) and writes what it receives to the db, storage,
342
- * queues or realtime. One instance per stage, restarted when it crashes and
343
- * replaced on each deploy. Unlike everything else it is billed while it runs:
344
- * about $6 a month at the default size on Spot.
345
- */
346
- export interface ServiceConfig {
347
- /** Module whose default export is `defineService(...)` from `@ericminassian/platform`. */
348
- entry: string;
349
- /** vCPUs: 0.25 (default), 0.5, 1, 2 or 4. */
350
- cpu?: FargateCpu;
351
- /**
352
- * Memory in MB, one of the sizes Fargate pairs with `cpu`: 512, 1024 or
353
- * 2048 for 0.25 vCPU; 1024-4096 for 0.5; 2048-8192 for 1; 4096-16384 for 2;
354
- * 8192-30720 for 4 (steps of 1024). Default 512.
355
- */
356
- memoryMb?: number;
357
- /**
358
- * Run on Fargate Spot, about 70% cheaper. AWS may reclaim it with two
359
- * minutes' notice (the service gets SIGTERM) and the platform starts a
360
- * replacement. Default `true`.
361
- */
362
- spot?: boolean;
363
- /** Minutes a preview stage runs it after each deploy before stopping it; 0 means never. Default 30. */
364
- previewMinutes?: number;
365
- }
366
-
367
330
  /**
368
331
  * Live updates pushed to browsers. The server and worker publish; browsers
369
332
  * subscribe (they never publish). Events aren't stored: a browser that was
@@ -401,7 +364,13 @@ export interface EmailConfig {
401
364
  export interface AppConfig {
402
365
  /** 3-30 chars of a-z, 0-9 and single hyphens; also the app's host name. */
403
366
  name: string;
367
+ /** One line, up to 200 chars. The public directory shows it next to the app. */
404
368
  description?: string;
369
+ /**
370
+ * Whether the platform's public directory (`GET /v1/public/apps`) lists the
371
+ * prod stage, with its page views. Default true; `false` keeps the app out.
372
+ */
373
+ listed?: boolean;
405
374
  web?: WebConfig;
406
375
  /** Present automatically when any queue, event or cron exists. */
407
376
  worker?: WorkerConfig;
@@ -430,8 +399,6 @@ export interface AppConfig {
430
399
  realtime?: RealtimeConfig;
431
400
  /** Send email with the SDK's `Email` service: `true`, or `{ name, dailyLimit }`. */
432
401
  email?: boolean | EmailConfig;
433
- /** Long-running processes, e.g. stream ingest. Keys are 1-20 chars of a-z, 0-9 and hyphens. */
434
- services?: { readonly [name: string]: ServiceConfig };
435
402
  }
436
403
 
437
404
  /**
@@ -483,6 +450,8 @@ export function channel<Event>(): ChannelConfig<Event> {
483
450
  export const ResolvedManifest = Schema.Struct({
484
451
  name: Schema.String,
485
452
  description: Schema.optional(Schema.String),
453
+ /** Listed in the public directory (prod only). Deployments recorded before it existed were. */
454
+ listed: Schema.Boolean.pipe(orElse(true)),
486
455
  web: Schema.optional(WebSchema),
487
456
  /** Present when any queue, event subscription or cron exists. */
488
457
  worker: Schema.optional(WorkerSchema),
@@ -516,8 +485,6 @@ export const ResolvedManifest = Schema.Struct({
516
485
  ),
517
486
  /** Present when the stage sends email. `dailyLimit` is the declared one (prod's). */
518
487
  email: Schema.optional(Schema.Struct({ name: Schema.optional(Schema.String), dailyLimit: Schema.Finite })),
519
- /** Long-running services, with defaults applied. */
520
- services: Schema.Record(Schema.String, ServiceSchema).pipe(orElse({})),
521
488
  });
522
489
  export type ResolvedManifest = typeof ResolvedManifest.Type;
523
490
 
@@ -588,6 +555,7 @@ export function resolveManifest(m: Manifest): ResolvedManifest {
588
555
  return {
589
556
  name: m.name,
590
557
  ...(m.description ? { description: m.description } : {}),
558
+ listed: m.listed,
591
559
  ...(m.web ? { web: m.web } : {}),
592
560
  ...(worker ? { worker } : {}),
593
561
  auth,
@@ -604,7 +572,6 @@ export function resolveManifest(m: Manifest): ResolvedManifest {
604
572
  ? { realtime: { subscribe: m.realtime.subscribe, channels: Object.keys(m.realtime.channels) } }
605
573
  : {}),
606
574
  ...(email ? { email } : {}),
607
- services: m.services,
608
575
  };
609
576
  }
610
577