From d93b4fa048ecd980880dfb9666b268186fc92b7b Mon Sep 17 00:00:00 2001 From: Wojtek Majewski Date: Mon, 10 Nov 2025 18:34:42 +0100 Subject: [PATCH] feat: demo - prepare final deployment --- apps/demo/supabase/config.toml | 11 -- .../functions/test_flow_worker/.npmrc | 3 - .../functions/test_flow_worker/deno.json | 15 --- .../functions/test_flow_worker/deno.lock | 118 ------------------ .../functions/test_flow_worker/index.ts | 4 - .../functions/test_flow_worker/test_flow.ts | 6 - .../20251031133804_demo_anon_permissions.sql | 2 + .../20251031142456_create_test_flow_flow.sql | 2 - ...031200000_cleanup_orphaned_pgmq_queues.sql | 32 +++++ 9 files changed, 34 insertions(+), 159 deletions(-) delete mode 100644 apps/demo/supabase/functions/test_flow_worker/.npmrc delete mode 100644 apps/demo/supabase/functions/test_flow_worker/deno.json delete mode 100644 apps/demo/supabase/functions/test_flow_worker/deno.lock delete mode 100644 apps/demo/supabase/functions/test_flow_worker/index.ts delete mode 100644 apps/demo/supabase/functions/test_flow_worker/test_flow.ts delete mode 100644 apps/demo/supabase/migrations/20251031142456_create_test_flow_flow.sql create mode 100644 apps/demo/supabase/migrations/20251031200000_cleanup_orphaned_pgmq_queues.sql diff --git a/apps/demo/supabase/config.toml b/apps/demo/supabase/config.toml index 97b5f6009..a96eee3ef 100644 --- a/apps/demo/supabase/config.toml +++ b/apps/demo/supabase/config.toml @@ -348,17 +348,6 @@ s3_access_key = "env(S3_ACCESS_KEY)" # Configures AWS_SECRET_ACCESS_KEY for S3 bucket s3_secret_key = "env(S3_SECRET_KEY)" -[functions.test_flow_worker] -enabled = true -verify_jwt = false -import_map = "./functions/test_flow_worker/deno.json" -# Uncomment to specify a custom file path to the entrypoint. -# Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx -entrypoint = "./functions/test_flow_worker/index.ts" -# Specifies static files to be bundled with the function. Supports glob patterns. -# For example, if you want to serve static HTML pages in your function: -# static_files = [ "./functions/test_flow_worker/*.html" ] - [functions.article_flow_worker] enabled = true verify_jwt = false diff --git a/apps/demo/supabase/functions/test_flow_worker/.npmrc b/apps/demo/supabase/functions/test_flow_worker/.npmrc deleted file mode 100644 index 48c638863..000000000 --- a/apps/demo/supabase/functions/test_flow_worker/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -# Configuration for private npm package dependencies -# For more information on using private registries with Edge Functions, see: -# https://supabase.com/docs/guides/functions/import-maps#importing-from-private-registries diff --git a/apps/demo/supabase/functions/test_flow_worker/deno.json b/apps/demo/supabase/functions/test_flow_worker/deno.json deleted file mode 100644 index b7a100606..000000000 --- a/apps/demo/supabase/functions/test_flow_worker/deno.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "imports": { - "@pgflow/core": "../_vendor/@pgflow/core/index.ts", - "@pgflow/core/": "../_vendor/@pgflow/core/", - "@pgflow/dsl": "../_vendor/@pgflow/dsl/index.ts", - "@pgflow/dsl/": "../_vendor/@pgflow/dsl/", - "@pgflow/dsl/supabase": "../_vendor/@pgflow/dsl/src/supabase.ts", - "@pgflow/edge-worker": "../_vendor/@pgflow/edge-worker/index.ts", - "@pgflow/edge-worker/": "../_vendor/@pgflow/edge-worker/", - "@pgflow/edge-worker/_internal": "../_vendor/@pgflow/edge-worker/_internal.ts", - "postgres": "npm:postgres@3.4.5", - "@henrygd/queue": "jsr:@henrygd/queue@^1.0.7", - "@supabase/supabase-js": "jsr:@supabase/supabase-js@^2.49.4" - } -} diff --git a/apps/demo/supabase/functions/test_flow_worker/deno.lock b/apps/demo/supabase/functions/test_flow_worker/deno.lock deleted file mode 100644 index 0a49da32d..000000000 --- a/apps/demo/supabase/functions/test_flow_worker/deno.lock +++ /dev/null @@ -1,118 +0,0 @@ -{ - "version": "3", - "packages": { - "specifiers": { - "jsr:@henrygd/queue@^1.0.7": "jsr:@henrygd/queue@1.0.7", - "jsr:@supabase/supabase-js@^2.49.4": "jsr:@supabase/supabase-js@2.58.0", - "npm:@supabase/auth-js@2.72.0": "npm:@supabase/auth-js@2.72.0", - "npm:@supabase/functions-js@2.5.0": "npm:@supabase/functions-js@2.5.0", - "npm:@supabase/node-fetch@2.6.15": "npm:@supabase/node-fetch@2.6.15", - "npm:@supabase/postgrest-js@1.21.4": "npm:@supabase/postgrest-js@1.21.4", - "npm:@supabase/realtime-js@2.15.5": "npm:@supabase/realtime-js@2.15.5", - "npm:@supabase/storage-js@2.12.2": "npm:@supabase/storage-js@2.12.2", - "npm:postgres@3.4.5": "npm:postgres@3.4.5" - }, - "jsr": { - "@henrygd/queue@1.0.7": { - "integrity": "98cade132744bb420957c5413393f76eb8ba7261826f026c8a89a562b8fa2961" - }, - "@supabase/supabase-js@2.58.0": { - "integrity": "4d04e72e9f632b451ac7d1a84de0b85249c0097fdf06253f371c1f0a23e62c87", - "dependencies": [ - "npm:@supabase/auth-js@2.72.0", - "npm:@supabase/functions-js@2.5.0", - "npm:@supabase/node-fetch@2.6.15", - "npm:@supabase/postgrest-js@1.21.4", - "npm:@supabase/realtime-js@2.15.5", - "npm:@supabase/storage-js@2.12.2" - ] - } - }, - "npm": { - "@supabase/auth-js@2.72.0": { - "integrity": "sha512-4+bnUrtTDK1YD0/FCx2YtMiQH5FGu9Jlf4IQi5kcqRwRwqp2ey39V61nHNdH86jm3DIzz0aZKiWfTW8qXk1swQ==", - "dependencies": { - "@supabase/node-fetch": "@supabase/node-fetch@2.6.15" - } - }, - "@supabase/functions-js@2.5.0": { - "integrity": "sha512-SXBx6Jvp+MOBekeKFu+G11YLYPeVeGQl23eYyAG9+Ro0pQ1aIP0UZNIBxHKNHqxzR0L0n6gysNr2KT3841NATw==", - "dependencies": { - "@supabase/node-fetch": "@supabase/node-fetch@2.6.15" - } - }, - "@supabase/node-fetch@2.6.15": { - "integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==", - "dependencies": { - "whatwg-url": "whatwg-url@5.0.0" - } - }, - "@supabase/postgrest-js@1.21.4": { - "integrity": "sha512-TxZCIjxk6/dP9abAi89VQbWWMBbybpGWyvmIzTd79OeravM13OjR/YEYeyUOPcM1C3QyvXkvPZhUfItvmhY1IQ==", - "dependencies": { - "@supabase/node-fetch": "@supabase/node-fetch@2.6.15" - } - }, - "@supabase/realtime-js@2.15.5": { - "integrity": "sha512-/Rs5Vqu9jejRD8ZeuaWXebdkH+J7V6VySbCZ/zQM93Ta5y3mAmocjioa/nzlB6qvFmyylUgKVS1KpE212t30OA==", - "dependencies": { - "@supabase/node-fetch": "@supabase/node-fetch@2.6.15", - "@types/phoenix": "@types/phoenix@1.6.6", - "@types/ws": "@types/ws@8.18.1", - "ws": "ws@8.18.3" - } - }, - "@supabase/storage-js@2.12.2": { - "integrity": "sha512-SiySHxi3q7gia7NBYpsYRu8gyI0NhFwSORMxbZIxJ/zAVkN6QpwDRan158CJ+UdzD4WB/rQMAGRqIJQP+7ccAQ==", - "dependencies": { - "@supabase/node-fetch": "@supabase/node-fetch@2.6.15" - } - }, - "@types/node@18.16.19": { - "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", - "dependencies": {} - }, - "@types/phoenix@1.6.6": { - "integrity": "sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==", - "dependencies": {} - }, - "@types/ws@8.18.1": { - "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", - "dependencies": { - "@types/node": "@types/node@18.16.19" - } - }, - "postgres@3.4.5": { - "integrity": "sha512-cDWgoah1Gez9rN3H4165peY9qfpEo+SA61oQv65O3cRUE1pOEoJWwddwcqKE8XZYjbblOJlYDlLV4h67HrEVDg==", - "dependencies": {} - }, - "tr46@0.0.3": { - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dependencies": {} - }, - "webidl-conversions@3.0.1": { - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dependencies": {} - }, - "whatwg-url@5.0.0": { - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "tr46@0.0.3", - "webidl-conversions": "webidl-conversions@3.0.1" - } - }, - "ws@8.18.3": { - "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", - "dependencies": {} - } - } - }, - "remote": {}, - "workspace": { - "dependencies": [ - "jsr:@henrygd/queue@^1.0.7", - "jsr:@supabase/supabase-js@^2.49.4", - "npm:postgres@3.4.5" - ] - } -} diff --git a/apps/demo/supabase/functions/test_flow_worker/index.ts b/apps/demo/supabase/functions/test_flow_worker/index.ts deleted file mode 100644 index 47f163928..000000000 --- a/apps/demo/supabase/functions/test_flow_worker/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { EdgeWorker } from '@pgflow/edge-worker'; -import TestFlow from './test_flow.ts'; - -EdgeWorker.start(TestFlow); diff --git a/apps/demo/supabase/functions/test_flow_worker/test_flow.ts b/apps/demo/supabase/functions/test_flow_worker/test_flow.ts deleted file mode 100644 index e8d638547..000000000 --- a/apps/demo/supabase/functions/test_flow_worker/test_flow.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Flow } from '@pgflow/dsl'; - -export default new Flow<{ message: string }>({ slug: 'test_flow' }).step( - { slug: 'greet' }, - (input) => `Hello, ${input.run.message}!` -); diff --git a/apps/demo/supabase/migrations/20251031133804_demo_anon_permissions.sql b/apps/demo/supabase/migrations/20251031133804_demo_anon_permissions.sql index 384f0cd7f..f6b3a91b8 100644 --- a/apps/demo/supabase/migrations/20251031133804_demo_anon_permissions.sql +++ b/apps/demo/supabase/migrations/20251031133804_demo_anon_permissions.sql @@ -7,7 +7,9 @@ GRANT SELECT ON pgflow.flows TO anon; GRANT SELECT ON pgflow.runs TO anon; GRANT SELECT ON pgflow.steps TO anon; GRANT SELECT ON pgflow.step_states TO anon; +GRANT SELECT ON pgflow.step_tasks TO anon; GRANT SELECT ON pgflow.deps TO anon; +GRANT SELECT ON pgflow.workers TO anon; -- Enable real-time for anon role ALTER PUBLICATION supabase_realtime ADD TABLE pgflow.runs; diff --git a/apps/demo/supabase/migrations/20251031142456_create_test_flow_flow.sql b/apps/demo/supabase/migrations/20251031142456_create_test_flow_flow.sql deleted file mode 100644 index fd7e400a9..000000000 --- a/apps/demo/supabase/migrations/20251031142456_create_test_flow_flow.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT pgflow.create_flow('test_flow'); -SELECT pgflow.add_step('test_flow', 'greet'); diff --git a/apps/demo/supabase/migrations/20251031200000_cleanup_orphaned_pgmq_queues.sql b/apps/demo/supabase/migrations/20251031200000_cleanup_orphaned_pgmq_queues.sql new file mode 100644 index 000000000..2db9252ce --- /dev/null +++ b/apps/demo/supabase/migrations/20251031200000_cleanup_orphaned_pgmq_queues.sql @@ -0,0 +1,32 @@ +-- Cleanup any orphaned pgmq queues from incomplete resets +-- This ensures a clean slate before flow migrations run + +DO $$ +DECLARE + queue_record RECORD; +BEGIN + -- Drop any existing queues that might be orphaned + -- This handles the case where DROP EXTENSION pgmq didn't cascade properly + FOR queue_record IN + SELECT queue_name + FROM pgmq.list_queues() + LOOP + -- Use pgmq's built-in drop function to safely remove the queue + PERFORM pgmq.drop_queue(queue_record.queue_name); + + RAISE NOTICE 'Dropped orphaned queue: %', queue_record.queue_name; + END LOOP; + + -- Also drop any orphaned sequences that might exist without tables + FOR queue_record IN + SELECT sequence_name + FROM information_schema.sequences + WHERE sequence_schema = 'pgmq' + AND sequence_name LIKE 'q_%_msg_id_seq' + LOOP + EXECUTE format('DROP SEQUENCE IF EXISTS pgmq.%I CASCADE', queue_record.sequence_name); + + RAISE NOTICE 'Dropped orphaned sequence: %', queue_record.sequence_name; + END LOOP; + +END $$;