@opengeni/db 0.28.1 → 0.31.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.
- package/dist/attached-browser-devices.d.ts +42 -0
- package/dist/attempt-tool-catalogs.d.ts +16 -0
- package/dist/browser-auth.d.ts +91 -0
- package/dist/browser-identities.d.ts +128 -0
- package/dist/browser-sessions.d.ts +272 -0
- package/dist/browser-state-artifacts.d.ts +17 -0
- package/dist/capability-components.d.ts +37 -0
- package/dist/capability-integrations.d.ts +192 -0
- package/dist/chunk-F5FT7BEZ.js +3535 -0
- package/dist/chunk-F5FT7BEZ.js.map +1 -0
- package/dist/chunk-ISI2TIUG.js +639 -0
- package/dist/chunk-ISI2TIUG.js.map +1 -0
- package/dist/chunk-MWDVXQOL.js +11639 -0
- package/dist/chunk-MWDVXQOL.js.map +1 -0
- package/dist/chunk-NBE6CHRI.js +955 -0
- package/dist/chunk-NBE6CHRI.js.map +1 -0
- package/dist/{chunk-DBS5HPEW.js → chunk-YHZXQ7HP.js} +760 -11
- package/dist/chunk-YHZXQ7HP.js.map +1 -0
- package/dist/codemode-operations.d.ts +117 -0
- package/dist/codex-token-resolver.d.ts +2 -2
- package/dist/company-profile-schema.d.ts +798 -0
- package/dist/company-profile.d.ts +268 -0
- package/dist/computer-sessions.d.ts +109 -0
- package/dist/connection-token-resolver.d.ts +9 -4
- package/dist/database.d.ts +52 -3
- package/dist/editable-artifact-durable-export.d.ts +153 -0
- package/dist/editable-artifact-durable-export.js +788 -0
- package/dist/editable-artifact-durable-export.js.map +1 -0
- package/dist/editable-artifact-materialization.d.ts +123 -0
- package/dist/editable-artifacts-schema.d.ts +4152 -0
- package/dist/editable-artifacts.d.ts +610 -0
- package/dist/editable-artifacts.js +26 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/environment-crypto.d.ts +8 -4
- package/dist/generated-images.d.ts +139 -0
- package/dist/index.d.ts +958 -126
- package/dist/index.js +31204 -12172
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +51 -4
- package/dist/integration-bindings.d.ts +70 -0
- package/dist/integration-features.d.ts +99 -0
- package/dist/interaction-revisions.d.ts +3 -0
- package/dist/interaction-schema.d.ts +5372 -0
- package/dist/knowledge-source-sync-schema.d.ts +1679 -0
- package/dist/knowledge-source-sync.d.ts +274 -0
- package/dist/lossless-columns.d.ts +58 -0
- package/dist/lossless-json.d.ts +39 -0
- package/dist/memory-domain.d.ts +3 -6
- package/dist/memory-governance.d.ts +2 -2
- package/dist/memory-slack-delivery.d.ts +101 -0
- package/dist/new-session-drafts.d.ts +2 -2
- package/dist/pack-components.d.ts +76 -0
- package/dist/pack-installations.d.ts +86 -0
- package/dist/persistence-errors.d.ts +7 -14
- package/dist/plugin-packages.d.ts +126 -0
- package/dist/preference-registry.d.ts +1 -1
- package/dist/provision-roles.d.ts +9 -1
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +18 -6
- package/dist/schema.d.ts +19122 -8731
- package/dist/schema.js +173 -1
- package/dist/scoped-knowledge.d.ts +97 -1
- package/dist/session-control.d.ts +4 -4
- package/dist/session-queue-commands.d.ts +19 -11
- package/dist/session-realtime-context.d.ts +2 -2
- package/dist/session-realtime-ledger.d.ts +4 -4
- package/dist/session-realtime-mirror.d.ts +2 -2
- package/dist/session-realtime-state.d.ts +1 -1
- package/dist/session-realtime-terminal.d.ts +8 -1
- package/dist/session-realtime.d.ts +7 -7
- package/dist/session-tool-call-settlement.d.ts +1 -1
- package/dist/slack-user-link-access.d.ts +54 -0
- package/dist/transcription-recordings-schema.d.ts +44 -6
- package/dist/transcription-recordings.d.ts +3 -3
- package/dist/turn-initiator.d.ts +2 -2
- package/dist/video-generation.d.ts +216 -0
- package/dist/video-generation.js +66 -0
- package/dist/video-generation.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +1 -1
- package/dist/workspace-instruction-policies.d.ts +1 -1
- package/dist/workspace-learning-policy-schema.d.ts +932 -0
- package/dist/workspace-learning-policy.d.ts +161 -0
- package/drizzle/0065_enrollment_credential_generation.sql +10 -0
- package/drizzle/0140_retained_screenshot_artifacts.sql +192 -0
- package/drizzle/0176_lossless_canonical_json.sql +975 -0
- package/drizzle/0177_session_events_workspace_turn_type_index.sql +5 -0
- package/drizzle/0178_permissioned_secret_reads.sql +14 -0
- package/drizzle/0179_slack_private_shortcut_delivery_gate.sql +85 -0
- package/drizzle/0180_retained_screenshot_lifecycle_fences.sql +273 -0
- package/drizzle/0181_connected_machine_removal.sql +52 -0
- package/drizzle/0182_connected_machine_remove_session_default.sql +77 -0
- package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
- package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
- package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
- package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
- package/drizzle/0187_generated_image_artifacts.sql +173 -0
- package/drizzle/0188_image_generation_retention_failure.sql +25 -0
- package/drizzle/0189_retained_session_image_formats.sql +13 -0
- package/drizzle/0190_timeline_annotations.sql +31 -0
- package/drizzle/0191_editable_artifact_engine.sql +3853 -0
- package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
- package/drizzle/0193_editable_artifact_authorization.sql +190 -0
- package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
- package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
- package/drizzle/0196_rig_provider_images.sql +152 -0
- package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
- package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
- package/drizzle/0199_workspace_learning_policy.sql +980 -0
- package/drizzle/0201_company_profile_authority.sql +849 -0
- package/drizzle/0202_document_index_checkpoints.sql +85 -0
- package/drizzle/0203_durable_video_generation.sql +353 -0
- package/drizzle/0204_video_generation_funding.sql +44 -0
- package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
- package/drizzle/0206_browser_sessions.sql +646 -0
- package/drizzle/0207_browser_identities.sql +379 -0
- package/drizzle/0208_attached_browser_devices.sql +165 -0
- package/drizzle/0209_computer_sessions.sql +575 -0
- package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
- package/drizzle/0211_editable_artifact_session_links.sql +58 -0
- package/drizzle/0212_slack_installation_bindings.sql +348 -0
- package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
- package/drizzle/0214_session_activity_commit_gate.sql +262 -0
- package/drizzle/0215_capabilities_platform.sql +980 -0
- package/drizzle/0216_pack_component_ownership.sql +235 -0
- package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
- package/package.json +18 -5
- package/src/attached-browser-devices.ts +371 -0
- package/src/attempt-tool-catalogs.ts +131 -0
- package/src/browser-auth.ts +1896 -0
- package/src/browser-identities.ts +1168 -0
- package/src/browser-sessions.ts +2005 -0
- package/src/browser-state-artifacts.ts +59 -0
- package/src/capability-components.ts +166 -0
- package/src/capability-integrations.ts +1663 -0
- package/src/codemode-operations.ts +674 -0
- package/src/company-profile-schema.ts +143 -0
- package/src/company-profile.ts +968 -0
- package/src/computer-sessions.ts +1130 -0
- package/src/connection-token-resolver.ts +270 -25
- package/src/database.ts +434 -24
- package/src/editable-artifact-durable-export.ts +1201 -0
- package/src/editable-artifact-materialization.ts +893 -0
- package/src/editable-artifacts-schema.ts +879 -0
- package/src/editable-artifacts.ts +5404 -0
- package/src/environment-crypto.ts +22 -9
- package/src/generated-images.ts +740 -0
- package/src/index.ts +10117 -2730
- package/src/insights.ts +160 -13
- package/src/integration-bindings.ts +455 -0
- package/src/integration-features.ts +859 -0
- package/src/interaction-revisions.ts +40 -0
- package/src/interaction-schema.ts +1303 -0
- package/src/knowledge-source-sync-schema.ts +192 -0
- package/src/knowledge-source-sync.ts +1922 -0
- package/src/lossless-columns.ts +35 -0
- package/src/lossless-json.ts +322 -0
- package/src/memory-domain.ts +5 -44
- package/src/memory-slack-delivery.ts +801 -0
- package/src/pack-components.ts +954 -0
- package/src/pack-installations.ts +929 -0
- package/src/persistence-errors.ts +26 -34
- package/src/plugin-packages.ts +1186 -0
- package/src/provision-roles.ts +302 -1
- package/src/runtime-posture-cli.ts +9 -0
- package/src/runtime-posture.ts +514 -5
- package/src/schema.ts +5177 -2957
- package/src/scoped-knowledge-schema.ts +1 -1
- package/src/scoped-knowledge.ts +655 -3
- package/src/session-control.ts +133 -81
- package/src/session-queue-commands.ts +511 -247
- package/src/session-realtime-context.ts +20 -7
- package/src/session-realtime-ledger.ts +32 -10
- package/src/session-realtime-mirror.ts +4 -2
- package/src/session-realtime-terminal.ts +89 -21
- package/src/session-realtime.ts +10 -9
- package/src/session-tool-call-settlement.ts +38 -15
- package/src/slack-user-link-access.ts +702 -0
- package/src/transcription-recordings-schema.ts +5 -2
- package/src/transcription-recordings.ts +70 -40
- package/src/video-generation.ts +1452 -0
- package/src/workspace-learning-policy-schema.ts +139 -0
- package/src/workspace-learning-policy.ts +595 -0
- package/dist/chunk-DBS5HPEW.js.map +0 -1
- package/dist/chunk-HT5T62CC.js +0 -6803
- package/dist/chunk-HT5T62CC.js.map +0 -1
- package/dist/event-payload-sanitizer.d.ts +0 -32
- package/src/event-payload-sanitizer.ts +0 -377
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Canonical browser authentication, network-route, and human-intervention
|
|
3
|
+
-- resources. No credential value is stored outside the existing connections table.
|
|
4
|
+
SET LOCAL lock_timeout = '5s';
|
|
5
|
+
SET LOCAL statement_timeout = '30s';
|
|
6
|
+
|
|
7
|
+
CREATE TABLE "network_routes" (
|
|
8
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
9
|
+
"account_id" uuid NOT NULL,
|
|
10
|
+
"workspace_id" uuid NOT NULL,
|
|
11
|
+
"name" text NOT NULL,
|
|
12
|
+
"status" text NOT NULL DEFAULT 'active',
|
|
13
|
+
"configuration" jsonb NOT NULL,
|
|
14
|
+
"consistency" jsonb NOT NULL,
|
|
15
|
+
"version" bigint NOT NULL DEFAULT 1,
|
|
16
|
+
"create_operation_id" uuid NOT NULL,
|
|
17
|
+
"created_by_subject_id" text NOT NULL,
|
|
18
|
+
"updated_by_subject_id" text NOT NULL,
|
|
19
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
20
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
21
|
+
CONSTRAINT "network_routes_workspace_account_fk"
|
|
22
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
23
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT "network_routes_status_check" CHECK ("status" IN ('active', 'archived')),
|
|
25
|
+
CONSTRAINT "network_routes_values_check" CHECK (
|
|
26
|
+
octet_length("name") BETWEEN 1 AND 200
|
|
27
|
+
AND "name" = btrim("name")
|
|
28
|
+
AND jsonb_typeof("configuration") = 'object'
|
|
29
|
+
AND octet_length("configuration"::text) BETWEEN 2 AND 65536
|
|
30
|
+
AND jsonb_typeof("consistency") = 'object'
|
|
31
|
+
AND octet_length("consistency"::text) BETWEEN 2 AND 65536
|
|
32
|
+
AND "version" > 0
|
|
33
|
+
AND octet_length("created_by_subject_id") BETWEEN 1 AND 1024
|
|
34
|
+
AND octet_length("updated_by_subject_id") BETWEEN 1 AND 1024
|
|
35
|
+
),
|
|
36
|
+
CONSTRAINT "network_routes_workspace_id_uq" UNIQUE ("workspace_id", "id"),
|
|
37
|
+
CONSTRAINT "network_routes_workspace_create_operation_uq"
|
|
38
|
+
UNIQUE ("workspace_id", "create_operation_id")
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE UNIQUE INDEX "network_routes_workspace_active_name_uq"
|
|
42
|
+
ON "network_routes" ("workspace_id", lower("name")) WHERE "status" = 'active';
|
|
43
|
+
CREATE INDEX "network_routes_workspace_status_updated_idx"
|
|
44
|
+
ON "network_routes" ("workspace_id", "status", "updated_at", "id");
|
|
45
|
+
|
|
46
|
+
CREATE TABLE "site_auth_connections" (
|
|
47
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
48
|
+
"account_id" uuid NOT NULL,
|
|
49
|
+
"workspace_id" uuid NOT NULL,
|
|
50
|
+
"name" text NOT NULL,
|
|
51
|
+
"account_label" text NOT NULL,
|
|
52
|
+
"status" text NOT NULL DEFAULT 'active',
|
|
53
|
+
"origins" jsonb NOT NULL,
|
|
54
|
+
"login_url" text,
|
|
55
|
+
"verification_url_prefixes" jsonb NOT NULL,
|
|
56
|
+
"authorities" jsonb NOT NULL,
|
|
57
|
+
"methods" jsonb NOT NULL,
|
|
58
|
+
"preferred_identity_id" uuid,
|
|
59
|
+
"preferred_placement" jsonb,
|
|
60
|
+
"preferred_network_route_id" uuid,
|
|
61
|
+
"health_policy" jsonb NOT NULL,
|
|
62
|
+
"verification_state" text NOT NULL DEFAULT 'unknown',
|
|
63
|
+
"last_verified_at" timestamptz,
|
|
64
|
+
"last_verified_url" text,
|
|
65
|
+
"repair_code" text,
|
|
66
|
+
"version" bigint NOT NULL DEFAULT 1,
|
|
67
|
+
"create_operation_id" uuid NOT NULL,
|
|
68
|
+
"created_by_subject_id" text NOT NULL,
|
|
69
|
+
"updated_by_subject_id" text NOT NULL,
|
|
70
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
71
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
72
|
+
CONSTRAINT "site_auth_connections_workspace_account_fk"
|
|
73
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
74
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
75
|
+
CONSTRAINT "site_auth_connections_identity_fk"
|
|
76
|
+
FOREIGN KEY ("workspace_id", "preferred_identity_id")
|
|
77
|
+
REFERENCES "browser_identities"("workspace_id", "id") ON DELETE SET NULL ("preferred_identity_id"),
|
|
78
|
+
CONSTRAINT "site_auth_connections_network_route_fk"
|
|
79
|
+
FOREIGN KEY ("workspace_id", "preferred_network_route_id")
|
|
80
|
+
REFERENCES "network_routes"("workspace_id", "id") ON DELETE SET NULL ("preferred_network_route_id"),
|
|
81
|
+
CONSTRAINT "site_auth_connections_status_check" CHECK ("status" IN ('active', 'archived')),
|
|
82
|
+
CONSTRAINT "site_auth_connections_verification_state_check"
|
|
83
|
+
CHECK ("verification_state" IN ('unknown', 'verified', 'needs_repair', 'failed')),
|
|
84
|
+
CONSTRAINT "site_auth_connections_values_check" CHECK (
|
|
85
|
+
octet_length("name") BETWEEN 1 AND 200
|
|
86
|
+
AND "name" = btrim("name")
|
|
87
|
+
AND octet_length("account_label") BETWEEN 1 AND 200
|
|
88
|
+
AND "account_label" = btrim("account_label")
|
|
89
|
+
AND jsonb_typeof("origins") = 'array'
|
|
90
|
+
AND octet_length("origins"::text) BETWEEN 3 AND 65536
|
|
91
|
+
AND ("login_url" IS NULL OR octet_length("login_url") BETWEEN 1 AND 16384)
|
|
92
|
+
AND jsonb_typeof("verification_url_prefixes") = 'array'
|
|
93
|
+
AND octet_length("verification_url_prefixes"::text) BETWEEN 2 AND 65536
|
|
94
|
+
AND jsonb_typeof("authorities") = 'array'
|
|
95
|
+
AND octet_length("authorities"::text) BETWEEN 3 AND 65536
|
|
96
|
+
AND jsonb_typeof("methods") = 'array'
|
|
97
|
+
AND octet_length("methods"::text) BETWEEN 3 AND 65536
|
|
98
|
+
AND ("preferred_placement" IS NULL OR (
|
|
99
|
+
jsonb_typeof("preferred_placement") = 'object'
|
|
100
|
+
AND octet_length("preferred_placement"::text) BETWEEN 2 AND 65536
|
|
101
|
+
))
|
|
102
|
+
AND jsonb_typeof("health_policy") = 'object'
|
|
103
|
+
AND octet_length("health_policy"::text) BETWEEN 2 AND 65536
|
|
104
|
+
AND ("last_verified_url" IS NULL OR octet_length("last_verified_url") BETWEEN 1 AND 16384)
|
|
105
|
+
AND ("repair_code" IS NULL OR octet_length("repair_code") BETWEEN 1 AND 512)
|
|
106
|
+
AND "version" > 0
|
|
107
|
+
AND octet_length("created_by_subject_id") BETWEEN 1 AND 1024
|
|
108
|
+
AND octet_length("updated_by_subject_id") BETWEEN 1 AND 1024
|
|
109
|
+
),
|
|
110
|
+
CONSTRAINT "site_auth_connections_verification_check" CHECK (
|
|
111
|
+
(
|
|
112
|
+
"verification_state" = 'verified'
|
|
113
|
+
AND "last_verified_at" IS NOT NULL
|
|
114
|
+
AND "last_verified_url" IS NOT NULL
|
|
115
|
+
AND "repair_code" IS NULL
|
|
116
|
+
) OR (
|
|
117
|
+
"verification_state" = 'unknown'
|
|
118
|
+
AND "last_verified_at" IS NULL
|
|
119
|
+
AND "last_verified_url" IS NULL
|
|
120
|
+
AND "repair_code" IS NULL
|
|
121
|
+
) OR (
|
|
122
|
+
"verification_state" IN ('needs_repair', 'failed')
|
|
123
|
+
AND "repair_code" IS NOT NULL
|
|
124
|
+
)
|
|
125
|
+
),
|
|
126
|
+
CONSTRAINT "site_auth_connections_workspace_id_uq" UNIQUE ("workspace_id", "id"),
|
|
127
|
+
CONSTRAINT "site_auth_connections_workspace_create_operation_uq"
|
|
128
|
+
UNIQUE ("workspace_id", "create_operation_id")
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
CREATE UNIQUE INDEX "site_auth_connections_workspace_active_name_uq"
|
|
132
|
+
ON "site_auth_connections" ("workspace_id", lower("name")) WHERE "status" = 'active';
|
|
133
|
+
CREATE INDEX "site_auth_connections_workspace_status_updated_idx"
|
|
134
|
+
ON "site_auth_connections" ("workspace_id", "status", "updated_at", "id");
|
|
135
|
+
|
|
136
|
+
ALTER TABLE "browser_sessions"
|
|
137
|
+
ADD CONSTRAINT "browser_sessions_network_route_fk"
|
|
138
|
+
FOREIGN KEY ("workspace_id", "network_route_id")
|
|
139
|
+
REFERENCES "network_routes"("workspace_id", "id") ON DELETE RESTRICT;
|
|
140
|
+
|
|
141
|
+
CREATE TABLE "auth_runs" (
|
|
142
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
143
|
+
"account_id" uuid NOT NULL,
|
|
144
|
+
"workspace_id" uuid NOT NULL,
|
|
145
|
+
"site_auth_connection_id" uuid NOT NULL,
|
|
146
|
+
"browser_session_id" uuid NOT NULL,
|
|
147
|
+
"target_id" text NOT NULL,
|
|
148
|
+
"controller_generation" text NOT NULL,
|
|
149
|
+
"target_generation" text NOT NULL,
|
|
150
|
+
"document_generation" text,
|
|
151
|
+
"method_id" text,
|
|
152
|
+
"authority_id" text,
|
|
153
|
+
"state" text NOT NULL DEFAULT 'discovering',
|
|
154
|
+
"choices" jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
155
|
+
"pending_fields" jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
156
|
+
"external_action" jsonb,
|
|
157
|
+
"intervention_id" uuid,
|
|
158
|
+
"verified_url" text,
|
|
159
|
+
"failure_code" text,
|
|
160
|
+
"version" bigint NOT NULL DEFAULT 1,
|
|
161
|
+
"operation_id" uuid NOT NULL,
|
|
162
|
+
"created_by_subject_id" text NOT NULL,
|
|
163
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
164
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
165
|
+
"settled_at" timestamptz,
|
|
166
|
+
CONSTRAINT "auth_runs_workspace_account_fk"
|
|
167
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
168
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
169
|
+
CONSTRAINT "auth_runs_site_auth_connection_fk"
|
|
170
|
+
FOREIGN KEY ("workspace_id", "site_auth_connection_id")
|
|
171
|
+
REFERENCES "site_auth_connections"("workspace_id", "id") ON DELETE RESTRICT,
|
|
172
|
+
CONSTRAINT "auth_runs_browser_session_fk"
|
|
173
|
+
FOREIGN KEY ("workspace_id", "browser_session_id")
|
|
174
|
+
REFERENCES "browser_sessions"("workspace_id", "id") ON DELETE CASCADE,
|
|
175
|
+
CONSTRAINT "auth_runs_state_check" CHECK (
|
|
176
|
+
"state" IN (
|
|
177
|
+
'discovering', 'awaiting_choice', 'awaiting_secret', 'awaiting_external_action',
|
|
178
|
+
'working', 'verified', 'failed', 'cancelled'
|
|
179
|
+
)
|
|
180
|
+
),
|
|
181
|
+
CONSTRAINT "auth_runs_values_check" CHECK (
|
|
182
|
+
octet_length("target_id") BETWEEN 1 AND 512
|
|
183
|
+
AND octet_length("controller_generation") BETWEEN 1 AND 256
|
|
184
|
+
AND octet_length("target_generation") BETWEEN 1 AND 256
|
|
185
|
+
AND ("document_generation" IS NULL OR octet_length("document_generation") BETWEEN 1 AND 256)
|
|
186
|
+
AND ("method_id" IS NULL OR octet_length("method_id") BETWEEN 1 AND 512)
|
|
187
|
+
AND ("authority_id" IS NULL OR octet_length("authority_id") BETWEEN 1 AND 512)
|
|
188
|
+
AND jsonb_typeof("choices") = 'array'
|
|
189
|
+
AND octet_length("choices"::text) BETWEEN 2 AND 65536
|
|
190
|
+
AND jsonb_typeof("pending_fields") = 'array'
|
|
191
|
+
AND octet_length("pending_fields"::text) BETWEEN 2 AND 65536
|
|
192
|
+
AND ("external_action" IS NULL OR (
|
|
193
|
+
jsonb_typeof("external_action") = 'object'
|
|
194
|
+
AND octet_length("external_action"::text) BETWEEN 2 AND 65536
|
|
195
|
+
))
|
|
196
|
+
AND ("verified_url" IS NULL OR octet_length("verified_url") BETWEEN 1 AND 16384)
|
|
197
|
+
AND ("failure_code" IS NULL OR octet_length("failure_code") BETWEEN 1 AND 512)
|
|
198
|
+
AND "version" > 0
|
|
199
|
+
AND octet_length("created_by_subject_id") BETWEEN 1 AND 1024
|
|
200
|
+
),
|
|
201
|
+
CONSTRAINT "auth_runs_lifecycle_check" CHECK (
|
|
202
|
+
(
|
|
203
|
+
"state" = 'verified'
|
|
204
|
+
AND "verified_url" IS NOT NULL
|
|
205
|
+
AND "failure_code" IS NULL
|
|
206
|
+
AND "settled_at" IS NOT NULL
|
|
207
|
+
) OR (
|
|
208
|
+
"state" = 'failed'
|
|
209
|
+
AND "verified_url" IS NULL
|
|
210
|
+
AND "failure_code" IS NOT NULL
|
|
211
|
+
AND "settled_at" IS NOT NULL
|
|
212
|
+
) OR (
|
|
213
|
+
"state" = 'cancelled'
|
|
214
|
+
AND "verified_url" IS NULL
|
|
215
|
+
AND "settled_at" IS NOT NULL
|
|
216
|
+
) OR (
|
|
217
|
+
"state" NOT IN ('verified', 'failed', 'cancelled')
|
|
218
|
+
AND "verified_url" IS NULL
|
|
219
|
+
AND "failure_code" IS NULL
|
|
220
|
+
AND "settled_at" IS NULL
|
|
221
|
+
)
|
|
222
|
+
),
|
|
223
|
+
CONSTRAINT "auth_runs_projection_check" CHECK (
|
|
224
|
+
("state" = 'awaiting_choice') = (jsonb_array_length("choices") > 0)
|
|
225
|
+
AND ("state" = 'awaiting_secret') = (jsonb_array_length("pending_fields") > 0)
|
|
226
|
+
AND ("state" = 'awaiting_external_action') = ("external_action" IS NOT NULL)
|
|
227
|
+
AND ("state" = 'failed') = ("failure_code" IS NOT NULL)
|
|
228
|
+
),
|
|
229
|
+
CONSTRAINT "auth_runs_workspace_id_uq" UNIQUE ("workspace_id", "id"),
|
|
230
|
+
CONSTRAINT "auth_runs_workspace_operation_uq" UNIQUE ("workspace_id", "operation_id")
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
CREATE INDEX "auth_runs_browser_history_idx"
|
|
234
|
+
ON "auth_runs" ("workspace_id", "browser_session_id", "created_at");
|
|
235
|
+
CREATE INDEX "auth_runs_site_history_idx"
|
|
236
|
+
ON "auth_runs" ("workspace_id", "site_auth_connection_id", "created_at");
|
|
237
|
+
CREATE UNIQUE INDEX "auth_runs_active_browser_target_uq"
|
|
238
|
+
ON "auth_runs" ("workspace_id", "browser_session_id", "target_id")
|
|
239
|
+
WHERE "settled_at" IS NULL;
|
|
240
|
+
|
|
241
|
+
CREATE TABLE "interaction_interventions" (
|
|
242
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
243
|
+
"account_id" uuid NOT NULL,
|
|
244
|
+
"workspace_id" uuid NOT NULL,
|
|
245
|
+
"resource_kind" text NOT NULL,
|
|
246
|
+
"resource_id" uuid NOT NULL,
|
|
247
|
+
"target_id" text NOT NULL,
|
|
248
|
+
"controller_generation" text NOT NULL,
|
|
249
|
+
"target_generation" text NOT NULL,
|
|
250
|
+
"document_generation" text,
|
|
251
|
+
"kind" text NOT NULL,
|
|
252
|
+
"reason" text NOT NULL,
|
|
253
|
+
"status" text NOT NULL DEFAULT 'open',
|
|
254
|
+
"auth_run_id" uuid,
|
|
255
|
+
"originating_session_id" uuid NOT NULL,
|
|
256
|
+
"originating_turn_id" uuid,
|
|
257
|
+
"originating_attempt_id" uuid,
|
|
258
|
+
"originating_tool_operation_id" uuid,
|
|
259
|
+
"response_actor_subject_id" text,
|
|
260
|
+
"version" bigint NOT NULL DEFAULT 1,
|
|
261
|
+
"operation_id" uuid NOT NULL,
|
|
262
|
+
"expires_at" timestamptz NOT NULL,
|
|
263
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
264
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
265
|
+
"settled_at" timestamptz,
|
|
266
|
+
CONSTRAINT "interaction_interventions_workspace_account_fk"
|
|
267
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
268
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
269
|
+
CONSTRAINT "interaction_interventions_auth_run_fk"
|
|
270
|
+
FOREIGN KEY ("workspace_id", "auth_run_id")
|
|
271
|
+
REFERENCES "auth_runs"("workspace_id", "id") ON DELETE SET NULL ("auth_run_id"),
|
|
272
|
+
CONSTRAINT "interaction_interventions_session_fk"
|
|
273
|
+
FOREIGN KEY ("workspace_id", "originating_session_id")
|
|
274
|
+
REFERENCES "sessions"("workspace_id", "id") ON DELETE CASCADE,
|
|
275
|
+
CONSTRAINT "interaction_interventions_turn_fk"
|
|
276
|
+
FOREIGN KEY ("workspace_id", "originating_turn_id")
|
|
277
|
+
REFERENCES "session_turns"("workspace_id", "id") ON DELETE SET NULL ("originating_turn_id"),
|
|
278
|
+
CONSTRAINT "interaction_interventions_attempt_fk"
|
|
279
|
+
FOREIGN KEY ("workspace_id", "originating_attempt_id")
|
|
280
|
+
REFERENCES "session_turn_attempts"("workspace_id", "id") ON DELETE SET NULL ("originating_attempt_id"),
|
|
281
|
+
CONSTRAINT "interaction_interventions_resource_kind_check"
|
|
282
|
+
CHECK ("resource_kind" IN ('browser_session', 'computer_session')),
|
|
283
|
+
CONSTRAINT "interaction_interventions_kind_check"
|
|
284
|
+
CHECK ("kind" IN ('manual_login', 'mfa', 'external_action', 'confirmation', 'other')),
|
|
285
|
+
CONSTRAINT "interaction_interventions_status_check"
|
|
286
|
+
CHECK ("status" IN ('open', 'completed', 'dismissed', 'expired', 'cancelled')),
|
|
287
|
+
CONSTRAINT "interaction_interventions_values_check" CHECK (
|
|
288
|
+
octet_length("target_id") BETWEEN 1 AND 512
|
|
289
|
+
AND octet_length("controller_generation") BETWEEN 1 AND 256
|
|
290
|
+
AND octet_length("target_generation") BETWEEN 1 AND 256
|
|
291
|
+
AND ("document_generation" IS NULL OR octet_length("document_generation") BETWEEN 1 AND 256)
|
|
292
|
+
AND octet_length("reason") BETWEEN 1 AND 2048
|
|
293
|
+
AND "reason" = btrim("reason")
|
|
294
|
+
AND ("originating_attempt_id" IS NULL OR "originating_turn_id" IS NOT NULL)
|
|
295
|
+
AND ("originating_tool_operation_id" IS NULL OR "originating_attempt_id" IS NOT NULL)
|
|
296
|
+
AND ("response_actor_subject_id" IS NULL OR octet_length("response_actor_subject_id") BETWEEN 1 AND 1024)
|
|
297
|
+
AND "version" > 0
|
|
298
|
+
),
|
|
299
|
+
CONSTRAINT "interaction_interventions_lifecycle_check" CHECK (
|
|
300
|
+
(
|
|
301
|
+
"status" = 'open'
|
|
302
|
+
AND "response_actor_subject_id" IS NULL
|
|
303
|
+
AND "settled_at" IS NULL
|
|
304
|
+
) OR (
|
|
305
|
+
"status" <> 'open'
|
|
306
|
+
AND "settled_at" IS NOT NULL
|
|
307
|
+
)
|
|
308
|
+
),
|
|
309
|
+
CONSTRAINT "interaction_interventions_workspace_id_uq" UNIQUE ("workspace_id", "id"),
|
|
310
|
+
CONSTRAINT "interaction_interventions_workspace_operation_uq"
|
|
311
|
+
UNIQUE ("workspace_id", "operation_id")
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
CREATE INDEX "interaction_interventions_open_resource_idx"
|
|
315
|
+
ON "interaction_interventions"
|
|
316
|
+
("workspace_id", "resource_kind", "resource_id", "status", "created_at");
|
|
317
|
+
CREATE UNIQUE INDEX "interaction_interventions_open_target_kind_uq"
|
|
318
|
+
ON "interaction_interventions"
|
|
319
|
+
("workspace_id", "resource_kind", "resource_id", "target_id", "kind")
|
|
320
|
+
WHERE "status" = 'open';
|
|
321
|
+
CREATE UNIQUE INDEX "interaction_interventions_open_auth_run_uq"
|
|
322
|
+
ON "interaction_interventions" ("workspace_id", "auth_run_id")
|
|
323
|
+
WHERE "status" = 'open' AND "auth_run_id" IS NOT NULL;
|
|
324
|
+
|
|
325
|
+
ALTER TABLE "auth_runs"
|
|
326
|
+
ADD CONSTRAINT "auth_runs_intervention_fk"
|
|
327
|
+
FOREIGN KEY ("workspace_id", "intervention_id")
|
|
328
|
+
REFERENCES "interaction_interventions"("workspace_id", "id")
|
|
329
|
+
ON DELETE SET NULL ("intervention_id");
|
|
330
|
+
|
|
331
|
+
CREATE TABLE "interaction_resource_operations" (
|
|
332
|
+
"operation_id" uuid PRIMARY KEY,
|
|
333
|
+
"account_id" uuid NOT NULL,
|
|
334
|
+
"workspace_id" uuid NOT NULL,
|
|
335
|
+
"resource_kind" text NOT NULL,
|
|
336
|
+
"resource_id" uuid NOT NULL,
|
|
337
|
+
"kind" text NOT NULL,
|
|
338
|
+
"request_digest" text NOT NULL,
|
|
339
|
+
"state" text NOT NULL DEFAULT 'completed',
|
|
340
|
+
"result_version" bigint,
|
|
341
|
+
"result" jsonb,
|
|
342
|
+
"error_code" text,
|
|
343
|
+
"actor_subject_id" text NOT NULL,
|
|
344
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
345
|
+
"settled_at" timestamptz,
|
|
346
|
+
CONSTRAINT "interaction_resource_operations_workspace_account_fk"
|
|
347
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
348
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
349
|
+
CONSTRAINT "interaction_resource_operations_resource_kind_check"
|
|
350
|
+
CHECK ("resource_kind" IN ('network_route', 'site_auth_connection', 'auth_run', 'intervention')),
|
|
351
|
+
CONSTRAINT "interaction_resource_operations_kind_check"
|
|
352
|
+
CHECK ("kind" IN ('create', 'update', 'start', 'report', 'protected_fill', 'verify', 'resolve')),
|
|
353
|
+
CONSTRAINT "interaction_resource_operations_state_check"
|
|
354
|
+
CHECK ("state" IN ('prepared', 'dispatched', 'completed', 'failed', 'outcome_unknown')),
|
|
355
|
+
CONSTRAINT "interaction_resource_operations_values_check" CHECK (
|
|
356
|
+
"request_digest" ~ '^[0-9a-f]{64}$'
|
|
357
|
+
AND ("result_version" IS NULL OR "result_version" > 0)
|
|
358
|
+
AND ("result" IS NULL OR (
|
|
359
|
+
jsonb_typeof("result") = 'object'
|
|
360
|
+
AND octet_length("result"::text) BETWEEN 2 AND 262144
|
|
361
|
+
))
|
|
362
|
+
AND ("error_code" IS NULL OR octet_length("error_code") BETWEEN 1 AND 512)
|
|
363
|
+
AND octet_length("actor_subject_id") BETWEEN 1 AND 1024
|
|
364
|
+
),
|
|
365
|
+
CONSTRAINT "interaction_resource_operations_lifecycle_check" CHECK (
|
|
366
|
+
(
|
|
367
|
+
"state" = 'completed'
|
|
368
|
+
AND "result_version" IS NOT NULL
|
|
369
|
+
AND "result" IS NOT NULL
|
|
370
|
+
AND "error_code" IS NULL
|
|
371
|
+
AND "settled_at" IS NOT NULL
|
|
372
|
+
) OR (
|
|
373
|
+
"state" IN ('failed', 'outcome_unknown')
|
|
374
|
+
AND "result_version" IS NULL
|
|
375
|
+
AND "result" IS NULL
|
|
376
|
+
AND "error_code" IS NOT NULL
|
|
377
|
+
AND "settled_at" IS NOT NULL
|
|
378
|
+
) OR (
|
|
379
|
+
"state" IN ('prepared', 'dispatched')
|
|
380
|
+
AND "result_version" IS NULL
|
|
381
|
+
AND "result" IS NULL
|
|
382
|
+
AND "error_code" IS NULL
|
|
383
|
+
AND "settled_at" IS NULL
|
|
384
|
+
)
|
|
385
|
+
),
|
|
386
|
+
CONSTRAINT "interaction_resource_operations_workspace_operation_uq"
|
|
387
|
+
UNIQUE ("workspace_id", "operation_id")
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
CREATE INDEX "interaction_resource_operations_resource_history_idx"
|
|
391
|
+
ON "interaction_resource_operations"
|
|
392
|
+
("workspace_id", "resource_kind", "resource_id", "created_at");
|
|
393
|
+
|
|
394
|
+
ALTER TABLE "network_routes" ENABLE ROW LEVEL SECURITY;
|
|
395
|
+
ALTER TABLE "network_routes" FORCE ROW LEVEL SECURITY;
|
|
396
|
+
CREATE POLICY workspace_isolation ON "network_routes"
|
|
397
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
398
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
399
|
+
|
|
400
|
+
ALTER TABLE "site_auth_connections" ENABLE ROW LEVEL SECURITY;
|
|
401
|
+
ALTER TABLE "site_auth_connections" FORCE ROW LEVEL SECURITY;
|
|
402
|
+
CREATE POLICY workspace_isolation ON "site_auth_connections"
|
|
403
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
404
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
405
|
+
|
|
406
|
+
ALTER TABLE "auth_runs" ENABLE ROW LEVEL SECURITY;
|
|
407
|
+
ALTER TABLE "auth_runs" FORCE ROW LEVEL SECURITY;
|
|
408
|
+
CREATE POLICY workspace_isolation ON "auth_runs"
|
|
409
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
410
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
411
|
+
|
|
412
|
+
ALTER TABLE "interaction_interventions" ENABLE ROW LEVEL SECURITY;
|
|
413
|
+
ALTER TABLE "interaction_interventions" FORCE ROW LEVEL SECURITY;
|
|
414
|
+
CREATE POLICY workspace_isolation ON "interaction_interventions"
|
|
415
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
416
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
417
|
+
|
|
418
|
+
ALTER TABLE "interaction_resource_operations" ENABLE ROW LEVEL SECURITY;
|
|
419
|
+
ALTER TABLE "interaction_resource_operations" FORCE ROW LEVEL SECURITY;
|
|
420
|
+
CREATE POLICY workspace_isolation ON "interaction_resource_operations"
|
|
421
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
422
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
423
|
+
|
|
424
|
+
DO $grants$
|
|
425
|
+
DECLARE target_schema text := current_schema();
|
|
426
|
+
BEGIN
|
|
427
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
428
|
+
EXECUTE format(
|
|
429
|
+
'REVOKE ALL ON TABLE %I.network_routes, %I.site_auth_connections, %I.auth_runs, %I.interaction_interventions, %I.interaction_resource_operations FROM opengeni_app',
|
|
430
|
+
target_schema, target_schema, target_schema, target_schema, target_schema
|
|
431
|
+
);
|
|
432
|
+
EXECUTE format(
|
|
433
|
+
'GRANT SELECT, INSERT, UPDATE ON TABLE %I.network_routes, %I.site_auth_connections, %I.auth_runs, %I.interaction_interventions, %I.interaction_resource_operations TO opengeni_app',
|
|
434
|
+
target_schema, target_schema, target_schema, target_schema, target_schema
|
|
435
|
+
);
|
|
436
|
+
END IF;
|
|
437
|
+
END
|
|
438
|
+
$grants$;
|
|
439
|
+
|
|
440
|
+
RESET statement_timeout;
|
|
441
|
+
RESET lock_timeout;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Durable navigation links between a session and every editable artifact it uses.
|
|
3
|
+
SET LOCAL lock_timeout = '5s';
|
|
4
|
+
SET LOCAL statement_timeout = '30s';
|
|
5
|
+
|
|
6
|
+
CREATE TABLE "editable_artifact_session_links" (
|
|
7
|
+
"account_id" uuid NOT NULL,
|
|
8
|
+
"workspace_id" uuid NOT NULL,
|
|
9
|
+
"session_id" uuid NOT NULL,
|
|
10
|
+
"artifact_id" text NOT NULL,
|
|
11
|
+
"first_used_at" timestamptz NOT NULL DEFAULT now(),
|
|
12
|
+
"last_used_at" timestamptz NOT NULL DEFAULT now(),
|
|
13
|
+
CONSTRAINT "editable_artifact_session_links_pk"
|
|
14
|
+
PRIMARY KEY ("account_id", "workspace_id", "session_id", "artifact_id"),
|
|
15
|
+
CONSTRAINT "editable_artifact_session_links_workspace_fk"
|
|
16
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
17
|
+
REFERENCES "workspaces"("id", "account_id") ON DELETE CASCADE,
|
|
18
|
+
CONSTRAINT "editable_artifact_session_links_session_fk"
|
|
19
|
+
FOREIGN KEY ("workspace_id", "session_id")
|
|
20
|
+
REFERENCES "sessions"("workspace_id", "id") ON DELETE CASCADE,
|
|
21
|
+
CONSTRAINT "editable_artifact_session_links_artifact_fk"
|
|
22
|
+
FOREIGN KEY ("account_id", "workspace_id", "artifact_id")
|
|
23
|
+
REFERENCES "editable_artifacts"("account_id", "workspace_id", "id") ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT "editable_artifact_session_links_artifact_id_chk" CHECK (
|
|
25
|
+
"artifact_id" ~ '^[0-9a-f]{32}$' AND "artifact_id" !~ '^0+$'
|
|
26
|
+
),
|
|
27
|
+
CONSTRAINT "editable_artifact_session_links_time_chk" CHECK (
|
|
28
|
+
"last_used_at" >= "first_used_at"
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE INDEX "editable_artifact_session_links_session_timeline_idx"
|
|
33
|
+
ON "editable_artifact_session_links" ("workspace_id", "session_id", "last_used_at" DESC, "artifact_id");
|
|
34
|
+
|
|
35
|
+
ALTER TABLE "editable_artifact_session_links" ENABLE ROW LEVEL SECURITY;
|
|
36
|
+
ALTER TABLE "editable_artifact_session_links" FORCE ROW LEVEL SECURITY;
|
|
37
|
+
CREATE POLICY workspace_isolation ON "editable_artifact_session_links"
|
|
38
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
39
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
40
|
+
|
|
41
|
+
DO $grants$
|
|
42
|
+
DECLARE target_schema text := current_schema();
|
|
43
|
+
BEGIN
|
|
44
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
45
|
+
EXECUTE format(
|
|
46
|
+
'REVOKE ALL ON TABLE %I.editable_artifact_session_links FROM opengeni_app',
|
|
47
|
+
target_schema
|
|
48
|
+
);
|
|
49
|
+
EXECUTE format(
|
|
50
|
+
'GRANT SELECT, INSERT, UPDATE ON TABLE %I.editable_artifact_session_links TO opengeni_app',
|
|
51
|
+
target_schema
|
|
52
|
+
);
|
|
53
|
+
END IF;
|
|
54
|
+
END;
|
|
55
|
+
$grants$;
|
|
56
|
+
|
|
57
|
+
RESET statement_timeout;
|
|
58
|
+
RESET lock_timeout;
|