Skip to content

Commit

Permalink
add json field for connection options
Browse files Browse the repository at this point in the history
  • Loading branch information
markusahlstrand committed Sep 15, 2024
1 parent d36211a commit 863dfca
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 13 deletions.
6 changes: 6 additions & 0 deletions apps/demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @authhero/demo

## 0.0.29

### Patch Changes

- [email protected]

## 0.0.28

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@authhero/demo",
"private": true,
"version": "0.0.28",
"version": "0.0.29",
"scripts": {
"dev": "bun --watch src/bun.ts"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/adapter-interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @authhero/adapter-interfaces

## 0.17.0

### Minor Changes

- Change to use a json field for connection options

### Patch Changes

- Add more properties to connection options

## 0.16.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.16.0",
"version": "0.17.0",
"files": [
"dist"
],
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-interfaces/src/types/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export const connectionInsertSchema = z.object({
client_secret: z.string().optional(),
app_secret: z.string().optional(),
scope: z.string().optional(),
authorization_endpoint: z.string().default("").optional(),
token_endpoint: z.string().default("").optional(),
})
.default({})
.optional(),
enabled_clients: z.array(z.string()).default([]).optional(),
authorization_endpoint: z.string().default("").optional(),
response_type: z.custom<AuthorizationResponseType>().optional(),
response_mode: z.custom<AuthorizationResponseMode>().optional(),
});
Expand Down
8 changes: 8 additions & 0 deletions packages/authhero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# authhero

## 0.2.31

### Patch Changes

- Updated dependencies
- Updated dependencies
- @authhero/adapter-interfaces@0.17.0

## 0.2.30

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/authhero/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "authhero",
"version": "0.2.30",
"version": "0.2.31",
"files": [
"dist"
],
Expand Down
8 changes: 8 additions & 0 deletions packages/drizzle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @authhero/drizzle

## 0.1.47

### Patch Changes

- Updated dependencies
- Updated dependencies
- @authhero/adapter-interfaces@0.17.0

## 0.1.46

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/drizzle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.1.46",
"version": "0.1.47",
"files": [
"dist"
],
Expand Down
12 changes: 12 additions & 0 deletions packages/kysely/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @authhero/kysely-adapter

## 0.11.0

### Minor Changes

- Change to use a json field for connection options

### Patch Changes

- Updated dependencies
- Updated dependencies
- @authhero/adapter-interfaces@0.17.0

## 0.10.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/kysely/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.10.0",
"version": "0.11.0",
"files": [
"dist"
],
Expand Down
8 changes: 6 additions & 2 deletions packages/kysely/src/connections/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { nanoid } from "nanoid";
import { Kysely } from "kysely";
import { Connection, ConnectionInsert } from "@authhero/adapter-interfaces";
import { Database } from "../db";
import { flattenObject } from "../utils/flatten";

export function create(db: Kysely<Database>) {
return async (
Expand All @@ -18,7 +17,12 @@ export function create(db: Kysely<Database>) {

await db
.insertInto("connections")
.values({ ...flattenObject(connection), tenant_id })
.values({
...connection,
// The connection options will have many different properties depending on the strategy
options: JSON.stringify(connection.options || {}),
tenant_id,
})
.execute();

return connection;
Expand Down
6 changes: 4 additions & 2 deletions packages/kysely/src/connections/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Kysely } from "kysely";
import { removeNullProperties } from "../helpers/remove-nulls";
import { Connection } from "@authhero/adapter-interfaces";
import { Database } from "../db";
import { unflattenObject } from "../utils/flatten";

export function get(db: Kysely<Database>) {
return async (
Expand All @@ -20,6 +19,9 @@ export function get(db: Kysely<Database>) {
return null;
}

return removeNullProperties(unflattenObject(connection, ["options"]));
return removeNullProperties({
...connection,
options: JSON.parse(connection.options),
});
};
}
8 changes: 6 additions & 2 deletions packages/kysely/src/connections/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Kysely } from "kysely";
import { ConnectionInsert } from "@authhero/adapter-interfaces";
import { Database } from "../db";
import { flattenObject } from "../utils/flatten";

export function update(db: Kysely<Database>) {
return async (
Expand All @@ -16,7 +15,12 @@ export function update(db: Kysely<Database>) {

await db
.updateTable("connections")
.set(flattenObject(sqlConnection))
.set({
...sqlConnection,
options: sqlConnection.options
? JSON.stringify(sqlConnection.options)
: undefined,
})
.where("connections.id", "=", connection_id)
.where("connections.tenant_id", "=", tenant_id)
.execute();
Expand Down
8 changes: 8 additions & 0 deletions packages/saml/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @authhero/saml

## 0.1.47

### Patch Changes

- Updated dependencies
- Updated dependencies
- @authhero/adapter-interfaces@0.17.0

## 0.1.46

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.1.46",
"version": "0.1.47",
"files": [
"dist"
],
Expand Down

0 comments on commit 863dfca

Please sign in to comment.