@void/platform 0.20.1 → 0.20.2

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 (32) hide show
  1. package/README.md +10 -1
  2. package/dist/email-protocol.d.mts +48 -0
  3. package/dist/email-protocol.mjs +278 -0
  4. package/dist/index.d.mts +152 -13
  5. package/dist/index.mjs +346 -20
  6. package/dist/installer.d.mts +4 -2
  7. package/dist/installer.mjs +13 -4
  8. package/dist/runtime/api/README.md +1 -1
  9. package/dist/runtime/api/index.js +67382 -54178
  10. package/dist/runtime/api/index.js.map +4 -4
  11. package/dist/runtime/dispatch/README.md +1 -1
  12. package/dist/runtime/dispatch/index.js +26 -8
  13. package/dist/runtime/dispatch/index.js.map +2 -2
  14. package/dist/runtime/drizzle/0041_military_beyonder.sql +119 -0
  15. package/dist/runtime/drizzle/0042_dark_the_anarchist.sql +1 -0
  16. package/dist/runtime/drizzle/0043_nostalgic_meggan.sql +21 -0
  17. package/dist/runtime/drizzle/0044_smart_mentor.sql +15 -0
  18. package/dist/runtime/drizzle/0045_platform_settings.sql +5 -0
  19. package/dist/runtime/drizzle/0046_email_domains_platform_credential.sql +8 -0
  20. package/dist/runtime/drizzle/0047_email_gateway.sql +226 -0
  21. package/dist/runtime/drizzle/0048_project_teams.sql +133 -0
  22. package/dist/runtime/drizzle/compatibility.json +4 -0
  23. package/dist/runtime/drizzle/meta/_journal.json +56 -0
  24. package/dist/runtime/emailGateway/README.md +1 -0
  25. package/dist/runtime/emailGateway/index.js +5893 -0
  26. package/dist/runtime/emailGateway/index.js.map +8 -0
  27. package/dist/runtime/manifest.json +70 -11
  28. package/dist/runtime/proxy/README.md +1 -1
  29. package/dist/runtime/proxy/index.js +1629 -2242
  30. package/dist/runtime/proxy/index.js.map +4 -4
  31. package/dist/runtime/tail/README.md +1 -1
  32. package/package.json +5 -1
@@ -0,0 +1,119 @@
1
+ CREATE TABLE "platform_auth_attempts" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "connection_id" text NOT NULL,
4
+ "revision" integer NOT NULL,
5
+ "generation" integer NOT NULL,
6
+ "purpose" text NOT NULL,
7
+ "browser_hash" text NOT NULL,
8
+ "context" jsonb NOT NULL,
9
+ "expires_at" timestamp NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "platform_auth_bootstrap" (
13
+ "singleton" boolean PRIMARY KEY DEFAULT true NOT NULL,
14
+ "installation_id" text NOT NULL,
15
+ "credential_hash" text NOT NULL,
16
+ "connection_id" text NOT NULL,
17
+ "expires_at" timestamp NOT NULL,
18
+ "consumed_at" timestamp,
19
+ CONSTRAINT "platform_auth_bootstrap_singleton" CHECK ("platform_auth_bootstrap"."singleton" = true)
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE TABLE "platform_auth_settings" (
23
+ "singleton" boolean PRIMARY KEY DEFAULT true NOT NULL,
24
+ "revision" integer DEFAULT 1 NOT NULL,
25
+ "admission" jsonb NOT NULL,
26
+ "protection" jsonb,
27
+ "session_seconds" integer DEFAULT 2592000 NOT NULL,
28
+ "sessions_required" boolean DEFAULT false NOT NULL,
29
+ "created_at" timestamp DEFAULT now() NOT NULL,
30
+ CONSTRAINT "platform_auth_settings_singleton" CHECK ("platform_auth_settings"."singleton" = true),
31
+ CONSTRAINT "platform_auth_settings_revision" CHECK ("platform_auth_settings"."revision" > 0),
32
+ CONSTRAINT "platform_auth_settings_session_seconds" CHECK ("platform_auth_settings"."session_seconds" BETWEEN 300 AND 2592000)
33
+ );
34
+ --> statement-breakpoint
35
+ CREATE TABLE "platform_company_identities" (
36
+ "user_id" text NOT NULL,
37
+ "issuer" text NOT NULL,
38
+ "subject" text NOT NULL,
39
+ CONSTRAINT "platform_company_identities_issuer_subject_pk" PRIMARY KEY("issuer","subject")
40
+ );
41
+ --> statement-breakpoint
42
+ CREATE TABLE "platform_human_sessions" (
43
+ "id" text PRIMARY KEY NOT NULL,
44
+ "user_id" text NOT NULL,
45
+ "connection_id" text NOT NULL,
46
+ "generation" integer NOT NULL,
47
+ "audience" text NOT NULL,
48
+ "access_issuer" text,
49
+ "access_subject" text,
50
+ "expires_at" timestamp NOT NULL,
51
+ "revoked_at" timestamp,
52
+ "created_at" timestamp DEFAULT now() NOT NULL,
53
+ CONSTRAINT "platform_human_sessions_audience" CHECK ("platform_human_sessions"."audience" IN ('api', 'admin')),
54
+ CONSTRAINT "platform_human_sessions_access_identity" CHECK (("platform_human_sessions"."access_issuer" IS NULL) = ("platform_human_sessions"."access_subject" IS NULL))
55
+ );
56
+ --> statement-breakpoint
57
+ CREATE TABLE "platform_login_connections" (
58
+ "id" text PRIMARY KEY NOT NULL,
59
+ "kind" text NOT NULL,
60
+ "enabled" boolean DEFAULT false NOT NULL,
61
+ "active_revision" integer,
62
+ "revision" integer DEFAULT 1 NOT NULL,
63
+ "generation" integer DEFAULT 1 NOT NULL,
64
+ "created_at" timestamp DEFAULT now() NOT NULL,
65
+ CONSTRAINT "platform_login_connections_kind" CHECK ("platform_login_connections"."kind" IN ('github', 'google', 'oidc', 'cloudflare-access')),
66
+ CONSTRAINT "platform_login_connections_revision" CHECK ("platform_login_connections"."revision" > 0 AND "platform_login_connections"."generation" > 0),
67
+ CONSTRAINT "platform_login_connections_active_revision" CHECK ("platform_login_connections"."active_revision" IS NULL OR "platform_login_connections"."active_revision" BETWEEN 1 AND "platform_login_connections"."revision"),
68
+ CONSTRAINT "platform_login_connections_enabled" CHECK (NOT "platform_login_connections"."enabled" OR "platform_login_connections"."active_revision" IS NOT NULL)
69
+ );
70
+ --> statement-breakpoint
71
+ CREATE TABLE "platform_login_identities" (
72
+ "id" text PRIMARY KEY NOT NULL,
73
+ "user_id" text NOT NULL,
74
+ "connection_id" text NOT NULL,
75
+ "issuer" text NOT NULL,
76
+ "subject" text NOT NULL,
77
+ "last_authenticated_at" timestamp DEFAULT now() NOT NULL,
78
+ "created_at" timestamp DEFAULT now() NOT NULL
79
+ );
80
+ --> statement-breakpoint
81
+ CREATE TABLE "platform_login_revisions" (
82
+ "connection_id" text NOT NULL,
83
+ "revision" integer NOT NULL,
84
+ "configuration" jsonb NOT NULL,
85
+ "secret" jsonb NOT NULL,
86
+ "created_at" timestamp DEFAULT now() NOT NULL,
87
+ CONSTRAINT "platform_login_revisions_connection_id_revision_pk" PRIMARY KEY("connection_id","revision")
88
+ );
89
+ --> statement-breakpoint
90
+ CREATE TABLE "platform_login_tests" (
91
+ "id" text PRIMARY KEY NOT NULL,
92
+ "user_id" text NOT NULL,
93
+ "connection_id" text NOT NULL,
94
+ "revision" integer NOT NULL,
95
+ "issuer" text NOT NULL,
96
+ "subject" text NOT NULL,
97
+ "expires_at" timestamp NOT NULL
98
+ );
99
+ --> statement-breakpoint
100
+ ALTER TABLE "operator_sessions" ADD COLUMN "human_session_id" text;--> statement-breakpoint
101
+ ALTER TABLE "platform_auth_attempts" ADD CONSTRAINT "platform_auth_attempts_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
102
+ ALTER TABLE "platform_auth_bootstrap" ADD CONSTRAINT "platform_auth_bootstrap_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
103
+ ALTER TABLE "platform_company_identities" ADD CONSTRAINT "platform_company_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
104
+ ALTER TABLE "platform_human_sessions" ADD CONSTRAINT "platform_human_sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
105
+ ALTER TABLE "platform_human_sessions" ADD CONSTRAINT "platform_human_sessions_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
106
+ ALTER TABLE "platform_login_identities" ADD CONSTRAINT "platform_login_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
107
+ ALTER TABLE "platform_login_identities" ADD CONSTRAINT "platform_login_identities_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
108
+ ALTER TABLE "platform_login_revisions" ADD CONSTRAINT "platform_login_revisions_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
109
+ ALTER TABLE "platform_login_tests" ADD CONSTRAINT "platform_login_tests_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
110
+ ALTER TABLE "platform_login_tests" ADD CONSTRAINT "platform_login_tests_connection_id_platform_login_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."platform_login_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
111
+ CREATE INDEX "platform_auth_attempts_expiry" ON "platform_auth_attempts" USING btree ("expires_at");--> statement-breakpoint
112
+ CREATE UNIQUE INDEX "platform_company_identity_user" ON "platform_company_identities" USING btree ("issuer","user_id");--> statement-breakpoint
113
+ CREATE INDEX "platform_human_sessions_connection" ON "platform_human_sessions" USING btree ("connection_id");--> statement-breakpoint
114
+ CREATE INDEX "platform_human_sessions_user" ON "platform_human_sessions" USING btree ("user_id");--> statement-breakpoint
115
+ CREATE INDEX "platform_human_sessions_expiry" ON "platform_human_sessions" USING btree ("expires_at");--> statement-breakpoint
116
+ CREATE UNIQUE INDEX "platform_login_identity_subject" ON "platform_login_identities" USING btree ("connection_id","issuer","subject");--> statement-breakpoint
117
+ CREATE UNIQUE INDEX "platform_login_identity_user" ON "platform_login_identities" USING btree ("connection_id","user_id");--> statement-breakpoint
118
+ CREATE INDEX "platform_login_tests_expiry" ON "platform_login_tests" USING btree ("expires_at");--> statement-breakpoint
119
+ ALTER TABLE "operator_sessions" ADD CONSTRAINT "operator_sessions_human_session_id_platform_human_sessions_id_fk" FOREIGN KEY ("human_session_id") REFERENCES "public"."platform_human_sessions"("id") ON DELETE cascade ON UPDATE no action;
@@ -0,0 +1 @@
1
+ ALTER TABLE "platform_login_tests" ADD COLUMN "login" text DEFAULT '' NOT NULL;
@@ -0,0 +1,21 @@
1
+ ALTER TABLE "platform_auth_attempts" ALTER COLUMN "expires_at" SET DATA TYPE timestamp with time zone USING "expires_at" AT TIME ZONE 'UTC';--> statement-breakpoint
2
+ ALTER TABLE "platform_auth_bootstrap" ALTER COLUMN "expires_at" SET DATA TYPE timestamp with time zone USING "expires_at" AT TIME ZONE 'UTC';--> statement-breakpoint
3
+ ALTER TABLE "platform_auth_bootstrap" ALTER COLUMN "consumed_at" SET DATA TYPE timestamp with time zone USING "consumed_at" AT TIME ZONE 'UTC';--> statement-breakpoint
4
+ ALTER TABLE "platform_auth_settings" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone USING "created_at" AT TIME ZONE 'UTC';--> statement-breakpoint
5
+ ALTER TABLE "platform_auth_settings" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
6
+ ALTER TABLE "platform_human_sessions" ALTER COLUMN "expires_at" SET DATA TYPE timestamp with time zone USING "expires_at" AT TIME ZONE 'UTC';--> statement-breakpoint
7
+ ALTER TABLE "platform_human_sessions" ALTER COLUMN "revoked_at" SET DATA TYPE timestamp with time zone USING "revoked_at" AT TIME ZONE 'UTC';--> statement-breakpoint
8
+ ALTER TABLE "platform_human_sessions" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone USING "created_at" AT TIME ZONE 'UTC';--> statement-breakpoint
9
+ ALTER TABLE "platform_human_sessions" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
10
+ ALTER TABLE "platform_login_connections" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone USING "created_at" AT TIME ZONE 'UTC';--> statement-breakpoint
11
+ ALTER TABLE "platform_login_connections" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
12
+ ALTER TABLE "platform_login_identities" ALTER COLUMN "last_authenticated_at" SET DATA TYPE timestamp with time zone USING "last_authenticated_at" AT TIME ZONE 'UTC';--> statement-breakpoint
13
+ ALTER TABLE "platform_login_identities" ALTER COLUMN "last_authenticated_at" SET DEFAULT now();--> statement-breakpoint
14
+ ALTER TABLE "platform_login_identities" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone USING "created_at" AT TIME ZONE 'UTC';--> statement-breakpoint
15
+ ALTER TABLE "platform_login_identities" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
16
+ ALTER TABLE "platform_login_revisions" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone USING "created_at" AT TIME ZONE 'UTC';--> statement-breakpoint
17
+ ALTER TABLE "platform_login_revisions" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
18
+ ALTER TABLE "platform_login_tests" ALTER COLUMN "expires_at" SET DATA TYPE timestamp with time zone USING "expires_at" AT TIME ZONE 'UTC';--> statement-breakpoint
19
+ ALTER TABLE "platform_auth_bootstrap" ADD COLUMN "request_hash" text DEFAULT '' NOT NULL;--> statement-breakpoint
20
+ ALTER TABLE "platform_auth_bootstrap" ADD COLUMN "claim_hash" text;--> statement-breakpoint
21
+ ALTER TABLE "platform_auth_bootstrap" ADD COLUMN "pending_identity" jsonb;
@@ -0,0 +1,15 @@
1
+ CREATE TABLE "project_deploy_credentials" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "project_id" text NOT NULL,
4
+ "issued_by" text NOT NULL,
5
+ "name" text NOT NULL,
6
+ "expires_at" timestamp with time zone NOT NULL,
7
+ "revoked_at" timestamp with time zone,
8
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
9
+ CONSTRAINT "project_deploy_credentials_name" CHECK (length("project_deploy_credentials"."name") BETWEEN 1 AND 80)
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "project_deploy_credentials" ADD CONSTRAINT "project_deploy_credentials_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
13
+ ALTER TABLE "project_deploy_credentials" ADD CONSTRAINT "project_deploy_credentials_issued_by_users_id_fk" FOREIGN KEY ("issued_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
14
+ CREATE INDEX "project_deploy_credentials_project" ON "project_deploy_credentials" USING btree ("project_id","created_at");--> statement-breakpoint
15
+ CREATE INDEX "project_deploy_credentials_expiry" ON "project_deploy_credentials" USING btree ("expires_at");
@@ -0,0 +1,5 @@
1
+ CREATE TABLE "platform_settings" (
2
+ "key" text PRIMARY KEY NOT NULL,
3
+ "value" jsonb NOT NULL,
4
+ "updated_at" timestamp DEFAULT now() NOT NULL
5
+ );
@@ -0,0 +1,8 @@
1
+ ALTER TABLE "email_domains" DROP CONSTRAINT "email_domains_credential_kind_check";--> statement-breakpoint
2
+ ALTER TABLE "email_domains" ALTER COLUMN "token_ciphertext" DROP NOT NULL;--> statement-breakpoint
3
+ ALTER TABLE "email_domains" ALTER COLUMN "token_iv" DROP NOT NULL;--> statement-breakpoint
4
+ ALTER TABLE "email_domains" ALTER COLUMN "token_key_version" DROP NOT NULL;--> statement-breakpoint
5
+ ALTER TABLE "email_domains" ADD COLUMN "managed_by" text DEFAULT 'owner' NOT NULL;--> statement-breakpoint
6
+ ALTER TABLE "email_domains" ADD CONSTRAINT "email_domains_platform_token_check" CHECK (("email_domains"."credential_kind" = 'platform' AND "email_domains"."token_ciphertext" IS NULL AND "email_domains"."token_iv" IS NULL AND "email_domains"."token_key_version" IS NULL) OR ("email_domains"."credential_kind" <> 'platform' AND "email_domains"."token_ciphertext" IS NOT NULL AND "email_domains"."token_iv" IS NOT NULL AND "email_domains"."token_key_version" IS NOT NULL));--> statement-breakpoint
7
+ ALTER TABLE "email_domains" ADD CONSTRAINT "email_domains_managed_by_check" CHECK ("email_domains"."managed_by" IN ('owner', 'admin'));--> statement-breakpoint
8
+ ALTER TABLE "email_domains" ADD CONSTRAINT "email_domains_credential_kind_check" CHECK ("email_domains"."credential_kind" IN ('oauth_grant', 'api_token', 'platform'));
@@ -0,0 +1,226 @@
1
+ CREATE TABLE "email_cache_outbox" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "installation_id" text NOT NULL,
4
+ "resource_kind" text NOT NULL,
5
+ "resource_id" text NOT NULL,
6
+ "version" integer NOT NULL,
7
+ "payload" jsonb,
8
+ "published_at" timestamp with time zone,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "email_credentials" (
13
+ "id" text PRIMARY KEY NOT NULL,
14
+ "installation_id" text NOT NULL,
15
+ "managed_by" text NOT NULL,
16
+ "manager_user_id" text,
17
+ "kind" text NOT NULL,
18
+ "account_id" text NOT NULL,
19
+ "zone_id" text NOT NULL,
20
+ "ciphertext" text,
21
+ "iv" text,
22
+ "key_version" text,
23
+ "token_id" text,
24
+ "expires_on" timestamp with time zone,
25
+ "generation" integer DEFAULT 1 NOT NULL,
26
+ "status" text DEFAULT 'healthy' NOT NULL,
27
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
28
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
29
+ CONSTRAINT "email_credentials_material_check" CHECK (("email_credentials"."kind" = 'platform' AND "email_credentials"."ciphertext" IS NULL AND "email_credentials"."iv" IS NULL AND "email_credentials"."key_version" IS NULL) OR ("email_credentials"."kind" = 'api_token' AND "email_credentials"."ciphertext" IS NOT NULL AND "email_credentials"."iv" IS NOT NULL AND "email_credentials"."key_version" IS NOT NULL))
30
+ );
31
+ --> statement-breakpoint
32
+ CREATE TABLE "email_domain_routes" (
33
+ "id" text PRIMARY KEY NOT NULL,
34
+ "domain" text NOT NULL,
35
+ "connection_id" text NOT NULL,
36
+ "project_id" text,
37
+ "addressing" text NOT NULL,
38
+ "managed_by" text NOT NULL,
39
+ "assigned_by_user_id" text,
40
+ "desired_state" text DEFAULT 'active' NOT NULL,
41
+ "inbound_status" text DEFAULT 'pending' NOT NULL,
42
+ "inbound_reason" text,
43
+ "inbound_observed_at" timestamp with time zone,
44
+ "outbound_status" text DEFAULT 'pending' NOT NULL,
45
+ "outbound_reason" text,
46
+ "outbound_observed_at" timestamp with time zone,
47
+ "desired_generation" integer DEFAULT 1 NOT NULL,
48
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
49
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
50
+ CONSTRAINT "email_domain_routes_assignment_check" CHECK (("email_domain_routes"."addressing" = 'custom' AND "email_domain_routes"."project_id" IS NOT NULL) OR ("email_domain_routes"."addressing" = 'shared' AND "email_domain_routes"."project_id" IS NULL))
51
+ );
52
+ --> statement-breakpoint
53
+ CREATE TABLE "email_operation_steps" (
54
+ "id" text PRIMARY KEY NOT NULL,
55
+ "operation_id" text NOT NULL,
56
+ "ordinal" integer NOT NULL,
57
+ "kind" text NOT NULL,
58
+ "resource_identity" text NOT NULL,
59
+ "request_digest" text NOT NULL,
60
+ "attempt" integer DEFAULT 0 NOT NULL,
61
+ "status" text DEFAULT 'pending' NOT NULL,
62
+ "outcome" jsonb,
63
+ "failure_code" text,
64
+ "failure_detail" text,
65
+ "started_at" timestamp with time zone,
66
+ "finished_at" timestamp with time zone
67
+ );
68
+ --> statement-breakpoint
69
+ CREATE TABLE "email_operations" (
70
+ "id" text PRIMARY KEY NOT NULL,
71
+ "installation_id" text NOT NULL,
72
+ "connection_id" text NOT NULL,
73
+ "route_id" text,
74
+ "route_generation" integer,
75
+ "actor_kind" text NOT NULL,
76
+ "actor_user_id" text,
77
+ "actor_scope" text NOT NULL,
78
+ "kind" text NOT NULL,
79
+ "idempotency_key" text NOT NULL,
80
+ "request_digest" text NOT NULL,
81
+ "desired_generation" integer NOT NULL,
82
+ "status" text DEFAULT 'pending' NOT NULL,
83
+ "current_step" text,
84
+ "failure_code" text,
85
+ "failure_detail" text,
86
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
87
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
88
+ );
89
+ --> statement-breakpoint
90
+ CREATE TABLE "email_zone_connections" (
91
+ "id" text PRIMARY KEY NOT NULL,
92
+ "installation_id" text NOT NULL,
93
+ "account_id" text NOT NULL,
94
+ "zone_id" text NOT NULL,
95
+ "zone_name" text NOT NULL,
96
+ "managed_by" text NOT NULL,
97
+ "manager_user_id" text,
98
+ "credential_id" text,
99
+ "ingress_worker_name" text NOT NULL,
100
+ "ingress_version" integer,
101
+ "desired_generation" integer DEFAULT 1 NOT NULL,
102
+ "active_secret_generation" integer DEFAULT 0 NOT NULL,
103
+ "staged_secret_generation" integer,
104
+ "secret_ciphertext" text NOT NULL,
105
+ "secret_iv" text NOT NULL,
106
+ "secret_key_version" text NOT NULL,
107
+ "staged_secret_ciphertext" text,
108
+ "staged_secret_iv" text,
109
+ "staged_secret_key_version" text,
110
+ "previous_secret_hash" text,
111
+ "previous_secret_until" timestamp with time zone,
112
+ "inbound_status" text DEFAULT 'pending' NOT NULL,
113
+ "inbound_reason" text,
114
+ "inbound_observed_at" timestamp with time zone,
115
+ "management_status" text DEFAULT 'probe_failed' NOT NULL,
116
+ "management_reason" text,
117
+ "management_observed_at" timestamp with time zone,
118
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
119
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
120
+ CONSTRAINT "email_zone_connections_manager_check" CHECK (("email_zone_connections"."managed_by" = 'owner' AND "email_zone_connections"."manager_user_id" IS NOT NULL) OR ("email_zone_connections"."managed_by" = 'admin'))
121
+ );
122
+ --> statement-breakpoint
123
+ CREATE TABLE "email_action_recipients" (
124
+ "id" text PRIMARY KEY NOT NULL,
125
+ "action_id" text NOT NULL,
126
+ "project_id" text NOT NULL,
127
+ "recipient" text NOT NULL,
128
+ "state" text NOT NULL,
129
+ "error_code" text,
130
+ "provider_reference" text,
131
+ "reserved_at" timestamp with time zone,
132
+ "attempt_started_at" timestamp with time zone,
133
+ "completed_at" timestamp with time zone,
134
+ CONSTRAINT "email_action_recipients_action_recipient_uq" UNIQUE("action_id","recipient"),
135
+ CONSTRAINT "email_action_recipients_state_check" CHECK ("email_action_recipients"."state" IN ('rejected', 'reserved', 'attempt_started', 'provider_accepted', 'failed', 'outcome_unknown', 'cancelled'))
136
+ );
137
+ --> statement-breakpoint
138
+ CREATE TABLE "email_actions" (
139
+ "id" text PRIMARY KEY NOT NULL,
140
+ "project_id" text NOT NULL,
141
+ "sender_domain" text NOT NULL,
142
+ "receipt_id" text,
143
+ "kind" text NOT NULL,
144
+ "idempotency_key" text NOT NULL,
145
+ "payload_digest" text NOT NULL,
146
+ "transport" text NOT NULL,
147
+ "policy_version" integer NOT NULL,
148
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
149
+ CONSTRAINT "email_actions_project_key_uq" UNIQUE("project_id","idempotency_key"),
150
+ CONSTRAINT "email_actions_kind_check" CHECK ("email_actions"."kind" IN ('direct', 'forward', 'reply'))
151
+ );
152
+ --> statement-breakpoint
153
+ CREATE TABLE "email_monthly_usage" (
154
+ "project_id" text NOT NULL,
155
+ "month" text NOT NULL,
156
+ "recipient_attempts" integer DEFAULT 0 NOT NULL,
157
+ "inbound_receipts" integer DEFAULT 0 NOT NULL,
158
+ CONSTRAINT "email_monthly_usage_project_month_uq" UNIQUE("project_id","month"),
159
+ CONSTRAINT "email_monthly_usage_nonnegative_check" CHECK ("email_monthly_usage"."recipient_attempts" >= 0),
160
+ CONSTRAINT "email_monthly_usage_inbound_nonnegative_check" CHECK ("email_monthly_usage"."inbound_receipts" >= 0)
161
+ );
162
+ --> statement-breakpoint
163
+ CREATE TABLE "email_project_controls" (
164
+ "project_id" text PRIMARY KEY NOT NULL,
165
+ "monthly_limit" integer DEFAULT 200 NOT NULL,
166
+ "burst_limit" integer DEFAULT 10 NOT NULL,
167
+ "suspended_at" timestamp with time zone,
168
+ "version" integer DEFAULT 1 NOT NULL
169
+ );
170
+ --> statement-breakpoint
171
+ CREATE TABLE "email_receipts" (
172
+ "id" text PRIMARY KEY NOT NULL,
173
+ "project_id" text NOT NULL,
174
+ "status" text DEFAULT 'received' NOT NULL,
175
+ "payload_digest" text,
176
+ "final_reject" boolean,
177
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
178
+ );
179
+ --> statement-breakpoint
180
+ CREATE TABLE "email_unresolved_attempts" (
181
+ "id" text PRIMARY KEY NOT NULL,
182
+ "project_id" text NOT NULL,
183
+ "sender_domain" text NOT NULL,
184
+ "started_at" timestamp with time zone NOT NULL
185
+ );
186
+ --> statement-breakpoint
187
+ ALTER TABLE "email_domain_routes" ADD CONSTRAINT "email_domain_routes_connection_id_email_zone_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."email_zone_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
188
+ ALTER TABLE "email_operation_steps" ADD CONSTRAINT "email_operation_steps_operation_id_email_operations_id_fk" FOREIGN KEY ("operation_id") REFERENCES "public"."email_operations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
189
+ ALTER TABLE "email_operations" ADD CONSTRAINT "email_operations_connection_id_email_zone_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."email_zone_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
190
+ ALTER TABLE "email_operations" ADD CONSTRAINT "email_operations_route_id_email_domain_routes_id_fk" FOREIGN KEY ("route_id") REFERENCES "public"."email_domain_routes"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
191
+ ALTER TABLE "email_action_recipients" ADD CONSTRAINT "email_action_recipients_action_id_email_actions_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."email_actions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
192
+ ALTER TABLE "email_actions" ADD CONSTRAINT "email_actions_receipt_id_email_receipts_id_fk" FOREIGN KEY ("receipt_id") REFERENCES "public"."email_receipts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
193
+ ALTER TABLE "email_project_controls" ADD CONSTRAINT "email_project_controls_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
194
+ CREATE UNIQUE INDEX "email_cache_outbox_version_uq" ON "email_cache_outbox" USING btree ("resource_kind","resource_id","version");--> statement-breakpoint
195
+ CREATE INDEX "email_cache_outbox_pending_idx" ON "email_cache_outbox" USING btree ("published_at","created_at");--> statement-breakpoint
196
+ CREATE INDEX "email_credentials_scope_idx" ON "email_credentials" USING btree ("installation_id","account_id","zone_id");--> statement-breakpoint
197
+ CREATE UNIQUE INDEX "email_domain_routes_domain_uq" ON "email_domain_routes" USING btree ("domain");--> statement-breakpoint
198
+ CREATE INDEX "email_domain_routes_connection_idx" ON "email_domain_routes" USING btree ("connection_id");--> statement-breakpoint
199
+ CREATE INDEX "email_domain_routes_project_idx" ON "email_domain_routes" USING btree ("project_id");--> statement-breakpoint
200
+ CREATE UNIQUE INDEX "email_operation_steps_order_uq" ON "email_operation_steps" USING btree ("operation_id","ordinal");--> statement-breakpoint
201
+ CREATE UNIQUE INDEX "email_operations_key_uq" ON "email_operations" USING btree ("installation_id","actor_scope","idempotency_key");--> statement-breakpoint
202
+ CREATE INDEX "email_operations_work_idx" ON "email_operations" USING btree ("status","updated_at");--> statement-breakpoint
203
+ CREATE INDEX "email_operations_connection_idx" ON "email_operations" USING btree ("connection_id");--> statement-breakpoint
204
+ CREATE UNIQUE INDEX "email_zone_connections_zone_uq" ON "email_zone_connections" USING btree ("installation_id","account_id","zone_id");--> statement-breakpoint
205
+ CREATE UNIQUE INDEX "email_zone_connections_ingress_uq" ON "email_zone_connections" USING btree ("account_id","ingress_worker_name");--> statement-breakpoint
206
+ CREATE INDEX "email_zone_connections_manager_idx" ON "email_zone_connections" USING btree ("manager_user_id");--> statement-breakpoint
207
+ CREATE INDEX "idx_email_action_recipients_project_reserved" ON "email_action_recipients" USING btree ("project_id","reserved_at");--> statement-breakpoint
208
+ CREATE INDEX "idx_email_action_recipients_expiring" ON "email_action_recipients" USING btree ("reserved_at") WHERE "email_action_recipients"."state" = 'reserved';--> statement-breakpoint
209
+ CREATE INDEX "idx_email_actions_project_created" ON "email_actions" USING btree ("project_id","created_at");--> statement-breakpoint
210
+ CREATE INDEX "idx_email_receipts_project_created" ON "email_receipts" USING btree ("project_id","created_at");--> statement-breakpoint
211
+ CREATE INDEX "idx_email_unresolved_attempts_project" ON "email_unresolved_attempts" USING btree ("project_id");--> statement-breakpoint
212
+ CREATE INDEX "idx_email_unresolved_attempts_domain" ON "email_unresolved_attempts" USING btree ("sender_domain");
213
+ --> statement-breakpoint
214
+ CREATE TABLE "email_destination_cleanups" (
215
+ "cf_destination_id" text PRIMARY KEY NOT NULL,
216
+ "status" text DEFAULT 'pending' NOT NULL,
217
+ "attempts" integer DEFAULT 0 NOT NULL,
218
+ "next_attempt_at" timestamp with time zone DEFAULT now() NOT NULL,
219
+ "lease_started_at" timestamp with time zone,
220
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
221
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
222
+ CONSTRAINT "email_destination_cleanups_status_check" CHECK ("email_destination_cleanups"."status" IN ('pending', 'deleting', 'completed')),
223
+ CONSTRAINT "email_destination_cleanups_attempts_check" CHECK ("email_destination_cleanups"."attempts" >= 0)
224
+ );
225
+ --> statement-breakpoint
226
+ CREATE INDEX "idx_email_destination_cleanups_due" ON "email_destination_cleanups" USING btree ("status","next_attempt_at","updated_at");
@@ -0,0 +1,133 @@
1
+ CREATE TABLE "project_access_events" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "project_id" text NOT NULL,
4
+ "actor_user_id" text NOT NULL,
5
+ "subject_user_id" text,
6
+ "invitation_email_snapshot" text,
7
+ "previous_role" text,
8
+ "new_role" text,
9
+ "action" text NOT NULL,
10
+ "created_at" timestamp DEFAULT now() NOT NULL,
11
+ CONSTRAINT "project_access_events_previous_role_check" CHECK ("project_access_events"."previous_role" IS NULL OR "project_access_events"."previous_role" IN ('reader', 'collaborator', 'admin')),
12
+ CONSTRAINT "project_access_events_new_role_check" CHECK ("project_access_events"."new_role" IS NULL OR "project_access_events"."new_role" IN ('reader', 'collaborator', 'admin')),
13
+ CONSTRAINT "project_access_events_action_check" CHECK ("project_access_events"."action" IN ('invited', 'invitation_resent', 'accepted', 'declined', 'invitation_revoked', 'role_changed', 'member_removed', 'left'))
14
+ );
15
+ --> statement-breakpoint
16
+ CREATE TABLE "project_invitations" (
17
+ "id" text PRIMARY KEY NOT NULL,
18
+ "project_id" text NOT NULL,
19
+ "target_user_id" text NOT NULL,
20
+ "target_email_snapshot" text NOT NULL,
21
+ "role" text NOT NULL,
22
+ "status" text DEFAULT 'pending' NOT NULL,
23
+ "invited_by_user_id" text NOT NULL,
24
+ "accepted_by_user_id" text,
25
+ "created_at" timestamp DEFAULT now() NOT NULL,
26
+ "expires_at" timestamp NOT NULL,
27
+ "accepted_at" timestamp,
28
+ "revoked_at" timestamp,
29
+ "revoked_by_user_id" text,
30
+ CONSTRAINT "project_invitations_role_check" CHECK ("project_invitations"."role" IN ('reader', 'collaborator', 'admin')),
31
+ CONSTRAINT "project_invitations_status_check" CHECK ("project_invitations"."status" IN ('pending', 'accepted', 'declined', 'revoked', 'expired'))
32
+ );
33
+ --> statement-breakpoint
34
+ CREATE TABLE "project_members" (
35
+ "project_id" text NOT NULL,
36
+ "user_id" text NOT NULL,
37
+ "role" text NOT NULL,
38
+ "added_by_user_id" text,
39
+ "created_at" timestamp DEFAULT now() NOT NULL,
40
+ "updated_at" timestamp DEFAULT now() NOT NULL,
41
+ CONSTRAINT "project_members_project_id_user_id_pk" PRIMARY KEY("project_id","user_id"),
42
+ CONSTRAINT "project_members_role_check" CHECK ("project_members"."role" IN ('reader', 'collaborator', 'admin'))
43
+ );
44
+ --> statement-breakpoint
45
+ CREATE TABLE "project_ownership_periods" (
46
+ "id" text PRIMARY KEY NOT NULL,
47
+ "project_id" text NOT NULL,
48
+ "owner_user_id" text NOT NULL,
49
+ "starts_at" timestamp NOT NULL,
50
+ "ends_at" timestamp,
51
+ "changed_by_user_id" text,
52
+ CONSTRAINT "project_ownership_periods_time_check" CHECK ("project_ownership_periods"."ends_at" IS NULL OR "project_ownership_periods"."ends_at" >= "project_ownership_periods"."starts_at")
53
+ );
54
+ --> statement-breakpoint
55
+ ALTER TABLE "deployments" ADD COLUMN "billing_user_id" text;--> statement-breakpoint
56
+ ALTER TABLE "deployments" ADD COLUMN "initiated_by_user_id" text;--> statement-breakpoint
57
+ CREATE UNIQUE INDEX "idx_project_ownership_periods_open" ON "project_ownership_periods" USING btree ("project_id") WHERE "project_ownership_periods"."ends_at" IS NULL;--> statement-breakpoint
58
+ CREATE FUNCTION "void_set_missing_deployment_billing_user_id"()
59
+ RETURNS trigger
60
+ LANGUAGE plpgsql
61
+ AS $$
62
+ BEGIN
63
+ IF NEW."billing_user_id" IS NULL THEN
64
+ SELECT "project"."user_id"
65
+ INTO NEW."billing_user_id"
66
+ FROM "public"."projects" AS "project"
67
+ WHERE "project"."id" = NEW."project_id";
68
+ END IF;
69
+ RETURN NEW;
70
+ END;
71
+ $$;--> statement-breakpoint
72
+ CREATE TRIGGER "deployments_set_missing_billing_user_id"
73
+ BEFORE INSERT ON "deployments"
74
+ FOR EACH ROW
75
+ WHEN (NEW."billing_user_id" IS NULL)
76
+ EXECUTE FUNCTION "void_set_missing_deployment_billing_user_id"();--> statement-breakpoint
77
+ CREATE FUNCTION "void_create_initial_project_ownership_period"()
78
+ RETURNS trigger
79
+ LANGUAGE plpgsql
80
+ AS $$
81
+ BEGIN
82
+ INSERT INTO "public"."project_ownership_periods" (
83
+ "id",
84
+ "project_id",
85
+ "owner_user_id",
86
+ "starts_at"
87
+ )
88
+ VALUES (
89
+ 'pown_' || NEW."id",
90
+ NEW."id",
91
+ NEW."user_id",
92
+ NEW."created_at"
93
+ )
94
+ ON CONFLICT DO NOTHING;
95
+ RETURN NEW;
96
+ END;
97
+ $$;--> statement-breakpoint
98
+ CREATE TRIGGER "projects_create_initial_ownership_period"
99
+ AFTER INSERT ON "projects"
100
+ FOR EACH ROW
101
+ EXECUTE FUNCTION "void_create_initial_project_ownership_period"();--> statement-breakpoint
102
+ UPDATE "deployments" AS "deployment"
103
+ SET "billing_user_id" = "project"."user_id"
104
+ FROM "projects" AS "project"
105
+ WHERE "deployment"."project_id" = "project"."id"
106
+ AND "deployment"."billing_user_id" IS NULL;--> statement-breakpoint
107
+ INSERT INTO "project_ownership_periods" (
108
+ "id",
109
+ "project_id",
110
+ "owner_user_id",
111
+ "starts_at"
112
+ )
113
+ SELECT
114
+ 'pown_' || "project"."id",
115
+ "project"."id",
116
+ "project"."user_id",
117
+ "project"."created_at"
118
+ FROM "projects" AS "project"
119
+ ON CONFLICT DO NOTHING;--> statement-breakpoint
120
+ ALTER TABLE "project_access_events" ADD CONSTRAINT "project_access_events_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
121
+ ALTER TABLE "project_invitations" ADD CONSTRAINT "project_invitations_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
122
+ ALTER TABLE "project_invitations" ADD CONSTRAINT "project_invitations_target_user_id_users_id_fk" FOREIGN KEY ("target_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
123
+ ALTER TABLE "project_members" ADD CONSTRAINT "project_members_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
124
+ ALTER TABLE "project_members" ADD CONSTRAINT "project_members_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
125
+ ALTER TABLE "project_ownership_periods" ADD CONSTRAINT "project_ownership_periods_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
126
+ CREATE INDEX "idx_project_access_events_project_created" ON "project_access_events" USING btree ("project_id","created_at");--> statement-breakpoint
127
+ CREATE INDEX "idx_project_access_events_subject_created" ON "project_access_events" USING btree ("subject_user_id","created_at");--> statement-breakpoint
128
+ CREATE INDEX "idx_project_invitations_project_status" ON "project_invitations" USING btree ("project_id","status");--> statement-breakpoint
129
+ CREATE INDEX "idx_project_invitations_target_status" ON "project_invitations" USING btree ("target_user_id","status");--> statement-breakpoint
130
+ CREATE UNIQUE INDEX "idx_project_invitations_pending_target" ON "project_invitations" USING btree ("project_id","target_user_id") WHERE "project_invitations"."status" = 'pending';--> statement-breakpoint
131
+ CREATE INDEX "idx_project_members_user_project" ON "project_members" USING btree ("user_id","project_id");--> statement-breakpoint
132
+ CREATE INDEX "idx_project_ownership_periods_owner_time" ON "project_ownership_periods" USING btree ("owner_user_id","starts_at","ends_at");--> statement-breakpoint
133
+ CREATE INDEX "idx_project_ownership_periods_project_time" ON "project_ownership_periods" USING btree ("project_id","starts_at");
@@ -21,6 +21,10 @@
21
21
  {
22
22
  "platformVersion": "0.10.14",
23
23
  "schemaDigest": "3dbf4c31d4bc97a11edca35c59b34ffad1f072df0ad7174d69e2de1057e2610b"
24
+ },
25
+ {
26
+ "platformVersion": "0.20.1",
27
+ "schemaDigest": "6de871d9524b082bba675d0d653ade45f95206895a962fea2b9be4b85d486313"
24
28
  }
25
29
  ]
26
30
  }
@@ -239,6 +239,62 @@
239
239
  "when": 1789678291923,
240
240
  "tag": "0040_productive_vector",
241
241
  "breakpoints": true
242
+ },
243
+ {
244
+ "idx": 41,
245
+ "version": "7",
246
+ "when": 1789700256261,
247
+ "tag": "0041_military_beyonder",
248
+ "breakpoints": true
249
+ },
250
+ {
251
+ "idx": 42,
252
+ "version": "7",
253
+ "when": 1789703423189,
254
+ "tag": "0042_dark_the_anarchist",
255
+ "breakpoints": true
256
+ },
257
+ {
258
+ "idx": 43,
259
+ "version": "7",
260
+ "when": 1789705129808,
261
+ "tag": "0043_nostalgic_meggan",
262
+ "breakpoints": true
263
+ },
264
+ {
265
+ "idx": 44,
266
+ "version": "7",
267
+ "when": 1789719174762,
268
+ "tag": "0044_smart_mentor",
269
+ "breakpoints": true
270
+ },
271
+ {
272
+ "idx": 45,
273
+ "version": "7",
274
+ "when": 1789733718999,
275
+ "tag": "0045_platform_settings",
276
+ "breakpoints": true
277
+ },
278
+ {
279
+ "idx": 46,
280
+ "version": "7",
281
+ "when": 1789733775150,
282
+ "tag": "0046_email_domains_platform_credential",
283
+ "breakpoints": true
284
+ },
285
+ {
286
+ "idx": 47,
287
+ "version": "7",
288
+ "when": 1789749117331,
289
+ "tag": "0047_email_gateway",
290
+ "breakpoints": true
291
+ },
292
+ {
293
+ "idx": 48,
294
+ "version": "7",
295
+ "when": 1789920262096,
296
+ "tag": "0048_project_teams",
297
+ "breakpoints": true
242
298
  }
243
299
  ]
244
300
  }
@@ -0,0 +1 @@
1
+ This folder contains the built output assets for the worker "void-runtime-build-email-gateway" generated at 2026-09-22T17:31:15.068Z.