chore: generate
This commit is contained in:
@@ -2,9 +2,7 @@
|
|||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "sqlite",
|
"dialect": "sqlite",
|
||||||
"id": "f25f9126-c7dc-4882-9ff4-af27e11d2da1",
|
"id": "f25f9126-c7dc-4882-9ff4-af27e11d2da1",
|
||||||
"prevIds": [
|
"prevIds": ["d1bfa125-b81e-4c61-9b6e-e74abf6e488f"],
|
||||||
"d1bfa125-b81e-4c61-9b6e-e74abf6e488f"
|
|
||||||
],
|
|
||||||
"ddl": [
|
"ddl": [
|
||||||
{
|
{
|
||||||
"name": "workspace",
|
"name": "workspace",
|
||||||
@@ -1493,13 +1491,9 @@
|
|||||||
"table": "session_share"
|
"table": "session_share"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["project_id"],
|
||||||
"project_id"
|
|
||||||
],
|
|
||||||
"tableTo": "project",
|
"tableTo": "project",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1508,13 +1502,9 @@
|
|||||||
"table": "workspace"
|
"table": "workspace"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["active_account_id"],
|
||||||
"active_account_id"
|
|
||||||
],
|
|
||||||
"tableTo": "account",
|
"tableTo": "account",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "SET NULL",
|
"onDelete": "SET NULL",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1523,13 +1513,9 @@
|
|||||||
"table": "account_state"
|
"table": "account_state"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["aggregate_id"],
|
||||||
"aggregate_id"
|
|
||||||
],
|
|
||||||
"tableTo": "event_sequence",
|
"tableTo": "event_sequence",
|
||||||
"columnsTo": [
|
"columnsTo": ["aggregate_id"],
|
||||||
"aggregate_id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1538,13 +1524,9 @@
|
|||||||
"table": "event"
|
"table": "event"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["project_id"],
|
||||||
"project_id"
|
|
||||||
],
|
|
||||||
"tableTo": "project",
|
"tableTo": "project",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1553,13 +1535,9 @@
|
|||||||
"table": "permission"
|
"table": "permission"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["project_id"],
|
||||||
"project_id"
|
|
||||||
],
|
|
||||||
"tableTo": "project",
|
"tableTo": "project",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1568,13 +1546,9 @@
|
|||||||
"table": "project_directory"
|
"table": "project_directory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1583,13 +1557,9 @@
|
|||||||
"table": "message"
|
"table": "message"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["message_id"],
|
||||||
"message_id"
|
|
||||||
],
|
|
||||||
"tableTo": "message",
|
"tableTo": "message",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1598,13 +1568,9 @@
|
|||||||
"table": "part"
|
"table": "part"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1613,13 +1579,9 @@
|
|||||||
"table": "session_context_epoch"
|
"table": "session_context_epoch"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1628,13 +1590,9 @@
|
|||||||
"table": "session_input"
|
"table": "session_input"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1643,13 +1601,9 @@
|
|||||||
"table": "session_message"
|
"table": "session_message"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["project_id"],
|
||||||
"project_id"
|
|
||||||
],
|
|
||||||
"tableTo": "project",
|
"tableTo": "project",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1658,13 +1612,9 @@
|
|||||||
"table": "session"
|
"table": "session"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1673,13 +1623,9 @@
|
|||||||
"table": "todo"
|
"table": "todo"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"tableTo": "session",
|
"tableTo": "session",
|
||||||
"columnsTo": [
|
"columnsTo": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"onUpdate": "NO ACTION",
|
"onUpdate": "NO ACTION",
|
||||||
"onDelete": "CASCADE",
|
"onDelete": "CASCADE",
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
@@ -1688,174 +1634,133 @@
|
|||||||
"table": "session_share"
|
"table": "session_share"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["email", "url"],
|
||||||
"email",
|
|
||||||
"url"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "control_account_pk",
|
"name": "control_account_pk",
|
||||||
"entityType": "pks",
|
"entityType": "pks",
|
||||||
"table": "control_account"
|
"table": "control_account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["project_id", "directory"],
|
||||||
"project_id",
|
|
||||||
"directory"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "project_directory_pk",
|
"name": "project_directory_pk",
|
||||||
"entityType": "pks",
|
"entityType": "pks",
|
||||||
"table": "project_directory"
|
"table": "project_directory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id", "position"],
|
||||||
"session_id",
|
|
||||||
"position"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "todo_pk",
|
"name": "todo_pk",
|
||||||
"entityType": "pks",
|
"entityType": "pks",
|
||||||
"table": "todo"
|
"table": "todo"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "workspace_pk",
|
"name": "workspace_pk",
|
||||||
"table": "workspace",
|
"table": "workspace",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["name"],
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "data_migration_pk",
|
"name": "data_migration_pk",
|
||||||
"table": "data_migration",
|
"table": "data_migration",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "account_state_pk",
|
"name": "account_state_pk",
|
||||||
"table": "account_state",
|
"table": "account_state",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "account_pk",
|
"name": "account_pk",
|
||||||
"table": "account",
|
"table": "account",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "credential_pk",
|
"name": "credential_pk",
|
||||||
"table": "credential",
|
"table": "credential",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["aggregate_id"],
|
||||||
"aggregate_id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "event_sequence_pk",
|
"name": "event_sequence_pk",
|
||||||
"table": "event_sequence",
|
"table": "event_sequence",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "event_pk",
|
"name": "event_pk",
|
||||||
"table": "event",
|
"table": "event",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "permission_pk",
|
"name": "permission_pk",
|
||||||
"table": "permission",
|
"table": "permission",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "project_pk",
|
"name": "project_pk",
|
||||||
"table": "project",
|
"table": "project",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "message_pk",
|
"name": "message_pk",
|
||||||
"table": "message",
|
"table": "message",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "part_pk",
|
"name": "part_pk",
|
||||||
"table": "part",
|
"table": "part",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "session_context_epoch_pk",
|
"name": "session_context_epoch_pk",
|
||||||
"table": "session_context_epoch",
|
"table": "session_context_epoch",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "session_input_pk",
|
"name": "session_input_pk",
|
||||||
"table": "session_input",
|
"table": "session_input",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "session_message_pk",
|
"name": "session_message_pk",
|
||||||
"table": "session_message",
|
"table": "session_message",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "session_pk",
|
"name": "session_pk",
|
||||||
"table": "session",
|
"table": "session",
|
||||||
"entityType": "pks"
|
"entityType": "pks"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": [
|
"columns": ["session_id"],
|
||||||
"session_id"
|
|
||||||
],
|
|
||||||
"nameExplicit": false,
|
"nameExplicit": false,
|
||||||
"name": "session_share_pk",
|
"name": "session_share_pk",
|
||||||
"table": "session_share",
|
"table": "session_share",
|
||||||
|
|||||||
@@ -236,7 +236,9 @@ export const layer = Layer.effect(
|
|||||||
|
|
||||||
all: Effect.fn("CatalogV2.provider.all")(function* () {
|
all: Effect.fn("CatalogV2.provider.all")(function* () {
|
||||||
const credentials = yield* active()
|
const credentials = yield* active()
|
||||||
return Array.fromIterable(state.get().providers.values()).map((record) => project(record.provider, credentials))
|
return Array.fromIterable(state.get().providers.values()).map((record) =>
|
||||||
|
project(record.provider, credentials),
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
available: Effect.fn("CatalogV2.provider.available")(function* () {
|
available: Effect.fn("CatalogV2.provider.available")(function* () {
|
||||||
|
|||||||
@@ -213,10 +213,7 @@ export interface Interface {
|
|||||||
readonly inputs: Inputs
|
readonly inputs: Inputs
|
||||||
/** User-facing label for the credential created on completion. */
|
/** User-facing label for the credential created on completion. */
|
||||||
readonly label?: string
|
readonly label?: string
|
||||||
}) => Effect.Effect<
|
}) => Effect.Effect<Attempt, AuthorizationError>
|
||||||
Attempt,
|
|
||||||
AuthorizationError
|
|
||||||
>
|
|
||||||
/** Returns the current state of an OAuth attempt. */
|
/** Returns the current state of an OAuth attempt. */
|
||||||
readonly status: (attemptID: AttemptID) => Effect.Effect<AttemptStatus>
|
readonly status: (attemptID: AttemptID) => Effect.Effect<AttemptStatus>
|
||||||
/** Completes the attempt and stores its credential. */
|
/** Completes the attempt and stores its credential. */
|
||||||
@@ -273,7 +270,8 @@ export const locationLayer = Layer.effect(
|
|||||||
list: () => Array.from(draft.connectors.values(), (entry) => entry.connector) as Info[],
|
list: () => Array.from(draft.connectors.values(), (entry) => entry.connector) as Info[],
|
||||||
get: (id) => draft.connectors.get(id)?.connector as Info | undefined,
|
get: (id) => draft.connectors.get(id)?.connector as Info | undefined,
|
||||||
update: (id, update) => {
|
update: (id, update) => {
|
||||||
const current = draft.connectors.get(id) ??
|
const current =
|
||||||
|
draft.connectors.get(id) ??
|
||||||
castDraft({ connector: new Info({ id, name: id, methods: [] }), implementations: new Map() })
|
castDraft({ connector: new Info({ id, name: id, methods: [] }), implementations: new Map() })
|
||||||
if (!draft.connectors.has(id)) draft.connectors.set(id, current)
|
if (!draft.connectors.has(id)) draft.connectors.set(id, current)
|
||||||
update(current.connector)
|
update(current.connector)
|
||||||
@@ -282,7 +280,8 @@ export const locationLayer = Layer.effect(
|
|||||||
remove: (id) => draft.connectors.delete(id),
|
remove: (id) => draft.connectors.delete(id),
|
||||||
method: {
|
method: {
|
||||||
update: (implementation) => {
|
update: (implementation) => {
|
||||||
const current = draft.connectors.get(implementation.connectorID) ??
|
const current =
|
||||||
|
draft.connectors.get(implementation.connectorID) ??
|
||||||
castDraft({
|
castDraft({
|
||||||
connector: new Info({ id: implementation.connectorID, name: implementation.connectorID, methods: [] }),
|
connector: new Info({ id: implementation.connectorID, name: implementation.connectorID, methods: [] }),
|
||||||
implementations: new Map<MethodID, Implementation>(),
|
implementations: new Map<MethodID, Implementation>(),
|
||||||
@@ -318,10 +317,7 @@ export const locationLayer = Layer.effect(
|
|||||||
return error instanceof Error ? error.message : String(error)
|
return error instanceof Error ? error.message : String(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const settle = Effect.fnUntraced(function* (
|
const settle = Effect.fnUntraced(function* (attemptID: AttemptID, exit: Exit.Exit<Credential.Value, unknown>) {
|
||||||
attemptID: AttemptID,
|
|
||||||
exit: Exit.Exit<Credential.Value, unknown>,
|
|
||||||
) {
|
|
||||||
const now = yield* Clock.currentTimeMillis
|
const now = yield* Clock.currentTimeMillis
|
||||||
const result = yield* SynchronizedRef.modify(attempts, (current) => {
|
const result = yield* SynchronizedRef.modify(attempts, (current) => {
|
||||||
const attempt = current.get(attemptID)
|
const attempt = current.get(attemptID)
|
||||||
|
|||||||
@@ -118,7 +118,11 @@ export const legacyImportLayer = Layer.effectDiscard(
|
|||||||
const id = ID.create()
|
const id = ID.create()
|
||||||
const connector = ConnectorSchema.ID.make(connectorID.replace(/\/+$/, ""))
|
const connector = ConnectorSchema.ID.make(connectorID.replace(/\/+$/, ""))
|
||||||
const methodID = ConnectorSchema.MethodID.make(
|
const methodID = ConnectorSchema.MethodID.make(
|
||||||
credential.type === "api" ? "api-key" : connector === ConnectorSchema.ID.make("openai") ? "chatgpt-browser" : "oauth",
|
credential.type === "api"
|
||||||
|
? "api-key"
|
||||||
|
: connector === ConnectorSchema.ID.make("openai")
|
||||||
|
? "chatgpt-browser"
|
||||||
|
: "oauth",
|
||||||
)
|
)
|
||||||
const next: Value =
|
const next: Value =
|
||||||
credential.type === "api"
|
credential.type === "api"
|
||||||
@@ -206,9 +210,12 @@ export const layer = Layer.effect(
|
|||||||
return row ? info(row) : undefined
|
return row ? info(row) : undefined
|
||||||
}),
|
}),
|
||||||
all: Effect.fn("Credential.all")(function* () {
|
all: Effect.fn("Credential.all")(function* () {
|
||||||
return (yield* db.select().from(CredentialTable).orderBy(asc(CredentialTable.time_created)).all().pipe(Effect.orDie)).map(
|
return (yield* db
|
||||||
info,
|
.select()
|
||||||
)
|
.from(CredentialTable)
|
||||||
|
.orderBy(asc(CredentialTable.time_created))
|
||||||
|
.all()
|
||||||
|
.pipe(Effect.orDie)).map(info)
|
||||||
}),
|
}),
|
||||||
active: Effect.fn("Credential.active")(function* (connectorID) {
|
active: Effect.fn("Credential.active")(function* (connectorID) {
|
||||||
const row = yield* db
|
const row = yield* db
|
||||||
@@ -220,19 +227,22 @@ export const layer = Layer.effect(
|
|||||||
return row ? info(row) : undefined
|
return row ? info(row) : undefined
|
||||||
}),
|
}),
|
||||||
activeAll: Effect.fn("Credential.activeAll")(function* () {
|
activeAll: Effect.fn("Credential.activeAll")(function* () {
|
||||||
const rows = yield* db.select().from(CredentialTable).where(eq(CredentialTable.active, true)).all().pipe(Effect.orDie)
|
const rows = yield* db
|
||||||
|
.select()
|
||||||
|
.from(CredentialTable)
|
||||||
|
.where(eq(CredentialTable.active, true))
|
||||||
|
.all()
|
||||||
|
.pipe(Effect.orDie)
|
||||||
return new Map(rows.map((row) => [row.connector_id, info(row)]))
|
return new Map(rows.map((row) => [row.connector_id, info(row)]))
|
||||||
}),
|
}),
|
||||||
forConnector: Effect.fn("Credential.forConnector")(function* (connectorID) {
|
forConnector: Effect.fn("Credential.forConnector")(function* (connectorID) {
|
||||||
return (
|
return (yield* db
|
||||||
yield* db
|
.select()
|
||||||
.select()
|
.from(CredentialTable)
|
||||||
.from(CredentialTable)
|
.where(eq(CredentialTable.connector_id, connectorID))
|
||||||
.where(eq(CredentialTable.connector_id, connectorID))
|
.orderBy(asc(CredentialTable.time_created))
|
||||||
.orderBy(asc(CredentialTable.time_created))
|
.all()
|
||||||
.all()
|
.pipe(Effect.orDie)).map(info)
|
||||||
.pipe(Effect.orDie)
|
|
||||||
).map(info)
|
|
||||||
}),
|
}),
|
||||||
create: Effect.fn("Credential.create")(function* (input) {
|
create: Effect.fn("Credential.create")(function* (input) {
|
||||||
const credential = new Info({
|
const credential = new Info({
|
||||||
@@ -298,7 +308,11 @@ export const layer = Layer.effect(
|
|||||||
.orderBy(asc(CredentialTable.time_created))
|
.orderBy(asc(CredentialTable.time_created))
|
||||||
.get()
|
.get()
|
||||||
if (replacement) {
|
if (replacement) {
|
||||||
yield* tx.update(CredentialTable).set({ active: true }).where(eq(CredentialTable.id, replacement.id)).run()
|
yield* tx
|
||||||
|
.update(CredentialTable)
|
||||||
|
.set({ active: true })
|
||||||
|
.where(eq(CredentialTable.id, replacement.id))
|
||||||
|
.run()
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
credential: info(row),
|
credential: info(row),
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export const CredentialTable = sqliteTable(
|
|||||||
...Timestamps,
|
...Timestamps,
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
uniqueIndex("credential_connector_active_idx").on(table.connector_id).where(sql`${table.active} = 1`),
|
uniqueIndex("credential_connector_active_idx")
|
||||||
|
.on(table.connector_id)
|
||||||
|
.where(sql`${table.active} = 1`),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ export default {
|
|||||||
\`time_updated\` integer NOT NULL
|
\`time_updated\` integer NOT NULL
|
||||||
);
|
);
|
||||||
`)
|
`)
|
||||||
yield* tx.run(`CREATE UNIQUE INDEX \`credential_connector_active_idx\` ON \`credential\` (\`connector_id\`) WHERE "credential"."active" = 1;`)
|
yield* tx.run(
|
||||||
|
`CREATE UNIQUE INDEX \`credential_connector_active_idx\` ON \`credential\` (\`connector_id\`) WHERE "credential"."active" = 1;`,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
} satisfies DatabaseMigration.Migration
|
} satisfies DatabaseMigration.Migration
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export const CloudflareWorkersAIPlugin = PluginV2.define({
|
|||||||
if (!hasWorkersEndpoint(evt.model.api) && !accountId) return
|
if (!hasWorkersEndpoint(evt.model.api) && !accountId) return
|
||||||
const mod = yield* Effect.promise(() => import("@ai-sdk/openai-compatible"))
|
const mod = yield* Effect.promise(() => import("@ai-sdk/openai-compatible"))
|
||||||
evt.sdk = mod.createOpenAICompatible(
|
evt.sdk = mod.createOpenAICompatible(
|
||||||
sdkOptions({ ...evt.options, baseURL: evt.options.baseURL ?? (accountId ? workersEndpoint(accountId) : undefined) }) as any,
|
sdkOptions({
|
||||||
|
...evt.options,
|
||||||
|
baseURL: evt.options.baseURL ?? (accountId ? workersEndpoint(accountId) : undefined),
|
||||||
|
}) as any,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
"aisdk.language": Effect.fn(function* (evt) {
|
"aisdk.language": Effect.fn(function* (evt) {
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ function claim(token: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const successPage = "<!doctype html><title>OpenCode</title><h1>Authorization successful</h1><p>You can close this window.</p>"
|
const successPage =
|
||||||
|
"<!doctype html><title>OpenCode</title><h1>Authorization successful</h1><p>You can close this window.</p>"
|
||||||
const errorPage = (message: string) =>
|
const errorPage = (message: string) =>
|
||||||
`<!doctype html><title>OpenCode</title><h1>Authorization failed</h1><p>${message.replace(/[&<>"']/g, "")}</p>`
|
`<!doctype html><title>OpenCode</title><h1>Authorization failed</h1><p>${message.replace(/[&<>"']/g, "")}</p>`
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ describe("Connector", () => {
|
|||||||
yield* connectors
|
yield* connectors
|
||||||
.update((editor) => editor.update(openai, (connector) => (connector.name = "OpenAI")))
|
.update((editor) => editor.update(openai, (connector) => (connector.name = "OpenAI")))
|
||||||
.pipe(Scope.provide(scope))
|
.pipe(Scope.provide(scope))
|
||||||
expect(yield* connectors.get(openai)).toEqual(
|
expect(yield* connectors.get(openai)).toEqual(new Connector.Info({ id: openai, name: "OpenAI", methods: [] }))
|
||||||
new Connector.Info({ id: openai, name: "OpenAI", methods: [] }),
|
|
||||||
)
|
|
||||||
|
|
||||||
yield* Scope.close(scope, Exit.void)
|
yield* Scope.close(scope, Exit.void)
|
||||||
expect(yield* connectors.get(openai)).toBeUndefined()
|
expect(yield* connectors.get(openai)).toBeUndefined()
|
||||||
@@ -313,9 +311,9 @@ describe("Connector", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const attempt = yield* connectors.connect.oauth.begin({ connectorID, methodID, inputs: {} })
|
const attempt = yield* connectors.connect.oauth.begin({ connectorID, methodID, inputs: {} })
|
||||||
expect(yield* connectors.connect.oauth.complete({ attemptID: attempt.attemptID }).pipe(Effect.flip)).toBeInstanceOf(
|
expect(
|
||||||
Connector.CodeRequiredError,
|
yield* connectors.connect.oauth.complete({ attemptID: attempt.attemptID }).pipe(Effect.flip),
|
||||||
)
|
).toBeInstanceOf(Connector.CodeRequiredError)
|
||||||
expect(closed).toBe(false)
|
expect(closed).toBe(false)
|
||||||
yield* connectors.connect.oauth.cancel(attempt.attemptID)
|
yield* connectors.connect.oauth.cancel(attempt.attemptID)
|
||||||
expect(closed).toBe(true)
|
expect(closed).toBe(true)
|
||||||
|
|||||||
@@ -203,5 +203,4 @@ describe("Credential", () => {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,13 +23,8 @@ const locationLayer = Layer.succeed(
|
|||||||
)
|
)
|
||||||
const plugins = PluginV2.layer.pipe(Layer.provide(events))
|
const plugins = PluginV2.layer.pipe(Layer.provide(events))
|
||||||
const policy = Policy.layer.pipe(Layer.provide(locationLayer))
|
const policy = Policy.layer.pipe(Layer.provide(locationLayer))
|
||||||
const credentials = Credential.layer.pipe(
|
const credentials = Credential.layer.pipe(Layer.provide(Database.layerFromPath(":memory:")), Layer.provide(events))
|
||||||
Layer.provide(Database.layerFromPath(":memory:")),
|
const catalog = Catalog.layer.pipe(Layer.provide(Layer.mergeAll(events, locationLayer, plugins, policy, credentials)))
|
||||||
Layer.provide(events),
|
|
||||||
)
|
|
||||||
const catalog = Catalog.layer.pipe(
|
|
||||||
Layer.provide(Layer.mergeAll(events, locationLayer, plugins, policy, credentials)),
|
|
||||||
)
|
|
||||||
const connectors = Connector.locationLayer.pipe(Layer.provide(credentials), Layer.provide(events))
|
const connectors = Connector.locationLayer.pipe(Layer.provide(credentials), Layer.provide(events))
|
||||||
const layer = Layer.mergeAll(catalog, connectors, credentials, events, locationLayer, plugins)
|
const layer = Layer.mergeAll(catalog, connectors, credentials, events, locationLayer, plugins)
|
||||||
const it = testEffect(layer)
|
const it = testEffect(layer)
|
||||||
|
|||||||
@@ -152,10 +152,12 @@ describe("CloudflareWorkersAIPlugin", () => {
|
|||||||
provider.api = { type: "aisdk", package: "test-provider" }
|
provider.api = { type: "aisdk", package: "test-provider" }
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
expect((yield* catalog.provider.get(ProviderV2.ID.make("cloudflare-workers-ai"))).request.body).toMatchObject({
|
expect((yield* catalog.provider.get(ProviderV2.ID.make("cloudflare-workers-ai"))).request.body).toMatchObject(
|
||||||
apiKey: "account-key",
|
{
|
||||||
accountId: "account-acct",
|
apiKey: "account-key",
|
||||||
})
|
accountId: "account-acct",
|
||||||
|
},
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -76,17 +76,18 @@ export const ConnectorHandler = HttpApiBuilder.group(Api, "server.connector", (h
|
|||||||
"connector.connect.oauth.complete",
|
"connector.connect.oauth.complete",
|
||||||
Effect.fn(function* (ctx) {
|
Effect.fn(function* (ctx) {
|
||||||
const service = yield* Connector.Service
|
const service = yield* Connector.Service
|
||||||
yield* service.connect.oauth
|
yield* service.connect.oauth.complete({ attemptID: ctx.params.attemptID, code: ctx.payload.code }).pipe(
|
||||||
.complete({ attemptID: ctx.params.attemptID, code: ctx.payload.code })
|
Effect.mapError(
|
||||||
.pipe(
|
(error) =>
|
||||||
Effect.mapError(
|
new InvalidRequestError({
|
||||||
(error) =>
|
message:
|
||||||
new InvalidRequestError({
|
error._tag === "Connector.CodeRequired"
|
||||||
message: error._tag === "Connector.CodeRequired" ? "Authorization code is required" : "Authentication failed",
|
? "Authorization code is required"
|
||||||
kind: error._tag === "Connector.CodeRequired" ? "connector_code_required" : "connector_authorization",
|
: "Authentication failed",
|
||||||
}),
|
kind: error._tag === "Connector.CodeRequired" ? "connector_code_required" : "connector_authorization",
|
||||||
),
|
}),
|
||||||
)
|
),
|
||||||
|
)
|
||||||
return HttpApiSchema.NoContent.make()
|
return HttpApiSchema.NoContent.make()
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -425,10 +425,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||||||
break
|
break
|
||||||
case "credential.switched": {
|
case "credential.switched": {
|
||||||
const location = { directory: metadata.directory, workspaceID: metadata.workspace }
|
const location = { directory: metadata.directory, workspaceID: metadata.workspace }
|
||||||
void Promise.allSettled([
|
void Promise.allSettled([result.location.model.refresh(location), result.location.provider.refresh(location)])
|
||||||
result.location.model.refresh(location),
|
|
||||||
result.location.provider.refresh(location),
|
|
||||||
])
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "connector.updated":
|
case "connector.updated":
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ export function createFetch(override?: FetchHandler) {
|
|||||||
if (url.pathname === "/experimental/console") return json({ consoleManagedProviders: [], switchableOrgCount: 0 })
|
if (url.pathname === "/experimental/console") return json({ consoleManagedProviders: [], switchableOrgCount: 0 })
|
||||||
if (url.pathname === "/path") return json({ home: "", state: "", config: "", worktree, directory })
|
if (url.pathname === "/path") return json({ home: "", state: "", config: "", worktree, directory })
|
||||||
if (url.pathname === "/api/location") return json({ directory, project: { id: "proj_test", directory: worktree } })
|
if (url.pathname === "/api/location") return json({ directory, project: { id: "proj_test", directory: worktree } })
|
||||||
if (["/api/agent", "/api/model", "/api/provider", "/api/connector", "/api/command", "/api/skill"].includes(url.pathname))
|
if (
|
||||||
|
["/api/agent", "/api/model", "/api/provider", "/api/connector", "/api/command", "/api/skill"].includes(
|
||||||
|
url.pathname,
|
||||||
|
)
|
||||||
|
)
|
||||||
return json({
|
return json({
|
||||||
location: { directory, project: { id: "proj_test", directory: worktree } },
|
location: { directory, project: { id: "proj_test", directory: worktree } },
|
||||||
data: [],
|
data: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user