@lilbox/contracts 0.0.0-stage → 0.0.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,78 @@
1
+ // app.yaml, the manifest (01 §11.3), published as JSON Schema at dist/schemas/app.schema.json.
2
+ //
3
+ // The schema accepts every documented field, including phase-2 ones (database, runtime: container,
4
+ // scale.min ≥ 1), so a manifest written today stays valid later. `check` reports a field the account's plan or the
5
+ // current phase can't honour as an issue; it is never a schema error.
6
+ import { z } from "zod";
7
+ import { AppName, EnvName } from "./common.js";
8
+ /** Durations as in app.yaml: "30s", "15m", "2h", "7d". */
9
+ export const Duration = z.string().regex(/^\d+(ms|s|m|h|d)$/, 'a duration like "30s", "15m" or "7d"');
10
+ export const Size = z.enum(["nano", "small", "medium", "large"]).meta({
11
+ description: "nano .25 vCPU/.5 GB · small .5/1 · medium 1/2 · large 2/4. On serverless, sets memory.",
12
+ });
13
+ export const CAPABILITY_CODES = [
14
+ "work_after_response",
15
+ "in_process_scheduler",
16
+ "queue_consumer",
17
+ "websockets",
18
+ "writes_outside_tmp",
19
+ "needs_root",
20
+ "long_requests",
21
+ "large_bodies",
22
+ "always_on",
23
+ "slow_boot",
24
+ ];
25
+ export const CapabilityCode = z.enum(CAPABILITY_CODES).meta({ description: "A runtime capability an app may need (05 §7.3)." });
26
+ export const CronEntry = z.object({
27
+ schedule: z.string().min(9).max(100).meta({ description: 'Cron expression in UTC, e.g. "*/30 * * * *".' }),
28
+ path: z.string().regex(/^\/[^\s]*$/).meta({ description: "Path that receives a signed POST (X-Lilbox-Signature)." }),
29
+ timeout: Duration.default("60s").optional(),
30
+ });
31
+ export const Manifest = z
32
+ .object({
33
+ version: z.literal(1),
34
+ name: AppName.optional().meta({ description: "Defaults to the app the manifest is deployed to." }),
35
+ build: z
36
+ .object({
37
+ dockerfile: z.string().default("Dockerfile").optional(),
38
+ context: z.string().default(".").optional(),
39
+ builder: z.enum(["dockerfile", "auto"]).default("dockerfile").optional().meta({ description: "auto = buildpacks (later)." }),
40
+ args: z.record(EnvName, z.string()).optional(),
41
+ })
42
+ .optional(),
43
+ run: z
44
+ .object({
45
+ port: z.number().int().min(1).max(65535).default(8080).optional().meta({ description: "Also exported as $PORT." }),
46
+ health: z
47
+ .object({ path: z.string().regex(/^\//).default("/").optional(), timeout: Duration.default("2s").optional() })
48
+ .optional(),
49
+ size: Size.default("nano").optional(),
50
+ request_timeout: Duration.optional(),
51
+ max_body: z.string().regex(/^\d+(KB|MB)$/).optional(),
52
+ })
53
+ .optional(),
54
+ scale: z
55
+ .object({
56
+ min: z.number().int().min(0).max(20).default(0).optional().meta({ description: "0 = scale to zero. ≥1 = always on (Pro)." }),
57
+ max: z.number().int().min(1).max(100).default(3).optional(),
58
+ idle_timeout: Duration.optional(),
59
+ })
60
+ .optional(),
61
+ region: z.enum(["us-east"]).default("us-east").optional(),
62
+ runtime: z.enum(["auto", "serverless", "container"]).default("auto").optional().meta({
63
+ description: "serverless (Lambda, every plan) · container (Fargate, Pro) · auto lets plan choose.",
64
+ }),
65
+ needs: z.array(CapabilityCode).optional().meta({ description: "Capabilities the app declares it needs. Always wins over detection." }),
66
+ env: z.record(EnvName, z.string()).optional().meta({ description: "Plain config. Secrets go through set_secret, never here." }),
67
+ secrets: z.array(EnvName).optional().meta({ description: "Names of secrets the app expects. Values are set with set_secret." }),
68
+ cron: z.array(CronEntry).max(20).optional().meta({ description: "Platform cron: signed POSTs to the app on a schedule." }),
69
+ release: z
70
+ .object({ migrate: z.array(z.string()).optional(), seed: z.array(z.string()).optional() })
71
+ .optional(),
72
+ // Phase 2 fields: accepted now, reported by plan as unavailable.
73
+ database: z
74
+ .object({ postgres: z.object({ tier: z.enum(["shared", "dedicated"]).default("shared").optional(), version: z.string().optional() }) })
75
+ .optional()
76
+ .meta({ description: "Managed Postgres (coming soon). Until then, bring your own and set DATABASE_URL as a secret." }),
77
+ })
78
+ .meta({ id: "Manifest", title: "lilbox app.yaml" });