@spunto/build 0.3.1 → 0.4.1

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.
@@ -0,0 +1,68 @@
1
+ // The shapes a worker's environment is described by, and the shape it reports back in.
2
+ //
3
+ // These live here rather than in either product's ORM schema because the dependency runs the wrong
4
+ // way otherwise: a script generator needs to know what a feature is, and it cannot import a Drizzle
5
+ // table — let alone two, one on Postgres and one on SQLite. So the package owns the types, and each
6
+ // schema declares its JSON column with `$type<…>()` pointing at them.
7
+ //
8
+ // That makes them **versioned contract**. `SetupStatus` in particular is what a shell script writes
9
+ // into a file inside a container and a control plane reads back out minutes later: changing it is a
10
+ // migration, not an edit. It already was one — this file just gives it somewhere to be written down.
11
+
12
+ /** A devcontainer feature as a project selects it. */
13
+ export type ProjectFeature = {
14
+ id: string
15
+ /** Set for a hand-typed OCI ref that isn't in the catalog. */
16
+ ociRef?: string
17
+ /** Filename of an install script the platform ships itself, instead of an OCI ref. */
18
+ localScript?: string
19
+ options?: Record<string, string>
20
+ }
21
+
22
+ /** A repository cloned into a worker's workspace. */
23
+ export type Repository = {
24
+ id: string
25
+ /** `git` = cloned from a raw URL with the project's deploy key, rather than through a forge app. */
26
+ provider: string
27
+ /** `owner/repo` for a forge, a human label for a raw URL. */
28
+ project: string
29
+ /** Directory under `/workspace`. */
30
+ workspacePath: string
31
+ /** Which forge-app installation grants access. Instance-scoped — never travels in a spec. */
32
+ installationId?: number
33
+ cloneUrl?: string
34
+ /** Absent/empty = the remote's default branch. We do not guess it. */
35
+ branch?: string
36
+ }
37
+
38
+ /** How far a repository's clone got. */
39
+ export type RepoSetupState = "pending" | "cloning" | "done" | "error"
40
+
41
+ /** How far a lifecycle command got. `null` = the project has none. */
42
+ export type LifecycleState = "pending" | "running" | "done" | "error" | null
43
+
44
+ /**
45
+ * What a worker reports about its own setup, written to `WORKER_STATUS_FILE` (`../naming`) by the
46
+ * generated setup script and read back by the control plane.
47
+ *
48
+ * `phase` is deliberately a flat enum rather than a state machine: the writer is a shell script,
49
+ * and the only thing it can do reliably is overwrite a field.
50
+ */
51
+ export type SetupStatus = {
52
+ phase: "initializing" | "credentials" | "dotfiles" | "cloning" | "lifecycle" | "ready" | "error"
53
+ repos: { name: string; state: RepoSetupState }[]
54
+ postCreate: LifecycleState
55
+ postStart: LifecycleState
56
+ error?: string
57
+ /**
58
+ * Per-phase start timestamps (ms epoch), stamped container-side at each transition. Keys are
59
+ * phase milestones in order: `initializing`, `credentials`, `shell`, `dotfiles`, `cloning`,
60
+ * `postCreate`, `postStart`, `ready`.
61
+ *
62
+ * Optional, and absent on older workers and hard crashes — so a reader derives a segment's
63
+ * duration as "next present milestone minus this one" rather than assuming the next key exists.
64
+ */
65
+ timings?: Record<string, number>
66
+ }
67
+
68
+ export type { BuildStep, BuildStepKind, BuildStepState } from "../steps/build-steps"