Skip to content

Commit

Permalink
Use matching middleware as context in ai req generation (#214)
Browse files Browse the repository at this point in the history
* Add some helpers for finding potential matching middleware for current path

* Introduce concept of registrationOrder in app routes table

* Use an actual primary key on app routes table and implement less than ideal updating logic to accomodate having lots of middleware in the table

* Sort active routes by registration order

* Refactor to use findAllSmartRouterMatches

* Propagate middleware to ai when present

* Do all probed route updating in a transaction and sort routes in the routes panel in their registration order

* Remove tab

* Add some safeguards so we do not add middleware context to non-service routes

* Fix type error in match.test.ts

* Use validated payload for inference route

* Format

* Fix type error

* Fix error from WebhoncBadge in the browser console

* Update studio/src/pages/RequestorPage/reducer/reducer.ts
  • Loading branch information
brettimus authored Sep 2, 2024
1 parent fb5ed87 commit 6958617
Show file tree
Hide file tree
Showing 25 changed files with 1,425 additions and 125 deletions.
1 change: 1 addition & 0 deletions api/drizzle/0012_deep_junta.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `app_routes` ADD `registration_order` integer DEFAULT -1;
28 changes: 28 additions & 0 deletions api/drizzle/0013_futuristic_snowbird.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
We want to delete PRIMARY KEY(handler_type,method,path,route_origin) from 'app_routes' table
SQLite does not supportprimary key deletion from existing table
We can do it in 3 steps with drizzle orm:
- create new mirror table table without pk, rename current table to old_table, generate SQL
- migrate old data from one table to another
- delete old_table in schema, generate sql
*/
ALTER TABLE `app_routes` RENAME TO `old_app_routes`;
--> statement-breakpoint
CREATE TABLE `app_routes` (
`id` integer PRIMARY KEY AUTOINCREMENT,
`path` TEXT,
`method` TEXT,
`handler` TEXT,
`handler_type` TEXT,
`currentlyRegistered` INTEGER DEFAULT false,
`registration_order` INTEGER DEFAULT -1,
`route_origin` TEXT DEFAULT 'discovered',
`openapi_spec` TEXT,
`request_type` TEXT DEFAULT 'http'
);
--> statement-breakpoint
INSERT INTO `app_routes` (`path`, `method`, `handler`, `handler_type`, `currentlyRegistered`, `registration_order`, `route_origin`, `openapi_spec`, `request_type`)
SELECT `path`, `method`, `handler`, `handler_type`, `currentlyRegistered`, `registration_order`, `route_origin`, `openapi_spec`, `request_type`
FROM `old_app_routes`;
--> statement-breakpoint
DROP TABLE `old_app_routes`;
Loading

0 comments on commit 6958617

Please sign in to comment.