@auth/edgedb-adapter 0.2.3 → 0.2.4

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/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ## Installation
10
10
  *
11
- * ```bash npm2yarn2pnpm
11
+ * ```bash npm2yarn
12
12
  * npm install edgedb @auth/edgedb-adapter
13
13
  * npm install @edgedb/generate --save-dev
14
14
  * ```
@@ -21,7 +21,7 @@ import type { Client } from "edgedb";
21
21
  *
22
22
  * To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
23
23
  *
24
- * ```bash npm2yarn2pnpm
24
+ * ```bash npm2yarn
25
25
  * npm install edgedb @auth/edgedb-adapter
26
26
  * npm install @edgedb/generate --save-dev
27
27
  * ```
@@ -81,7 +81,7 @@ import type { Client } from "edgedb";
81
81
  *
82
82
  * Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
83
83
  *
84
- * > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models)
84
+ * > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
85
85
  *
86
86
  * ```json title="default.esdl"
87
87
  * module default {
@@ -175,7 +175,7 @@ import type { Client } from "edgedb";
175
175
  *
176
176
  * ### Generate the query builder
177
177
  *
178
- * ```npm2yarn2pnpm
178
+ * ```npm2yarn
179
179
  * npx @edgedb/generate edgeql-js
180
180
  * ```
181
181
  *
package/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ## Installation
10
10
  *
11
- * ```bash npm2yarn2pnpm
11
+ * ```bash npm2yarn
12
12
  * npm install edgedb @auth/edgedb-adapter
13
13
  * npm install @edgedb/generate --save-dev
14
14
  * ```
@@ -19,7 +19,7 @@
19
19
  *
20
20
  * To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
21
21
  *
22
- * ```bash npm2yarn2pnpm
22
+ * ```bash npm2yarn
23
23
  * npm install edgedb @auth/edgedb-adapter
24
24
  * npm install @edgedb/generate --save-dev
25
25
  * ```
@@ -79,7 +79,7 @@
79
79
  *
80
80
  * Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
81
81
  *
82
- * > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models)
82
+ * > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
83
83
  *
84
84
  * ```json title="default.esdl"
85
85
  * module default {
@@ -173,7 +173,7 @@
173
173
  *
174
174
  * ### Generate the query builder
175
175
  *
176
- * ```npm2yarn2pnpm
176
+ * ```npm2yarn
177
177
  * npx @edgedb/generate edgeql-js
178
178
  * ```
179
179
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth/edgedb-adapter",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "EdgeDB adapter for next-auth.",
5
5
  "homepage": "https://authjs.dev",
6
6
  "repository": "https://github.com/nextauthjs/next-auth",
@@ -37,18 +37,13 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@auth/core": "0.18.0"
40
+ "@auth/core": "0.18.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "edgedb": "^1.0.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@auth/adapter-test": "^0.0.0",
47
- "@auth/tsconfig": "^0.0.0",
48
- "jest": "^27.4.3",
49
- "typescript": "^4.7.4",
50
- "edgedb": "^1.0.1",
51
- "@auth/core": "0.18.0"
46
+ "edgedb": "^1.0.1"
52
47
  },
53
48
  "jest": {
54
49
  "preset": "@auth/adapter-test/jest"
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ## Installation
10
10
  *
11
- * ```bash npm2yarn2pnpm
11
+ * ```bash npm2yarn
12
12
  * npm install edgedb @auth/edgedb-adapter
13
13
  * npm install @edgedb/generate --save-dev
14
14
  * ```
@@ -25,54 +25,54 @@ import type {
25
25
  import type { Client } from "edgedb"
26
26
 
27
27
  /**
28
- *
28
+ *
29
29
  * To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
30
- *
31
- * ```bash npm2yarn2pnpm
30
+ *
31
+ * ```bash npm2yarn
32
32
  * npm install edgedb @auth/edgedb-adapter
33
33
  * npm install @edgedb/generate --save-dev
34
34
  * ```
35
- *
35
+ *
36
36
  * ## Installation
37
- *
38
- * First, ensure you have the EdgeDB CLI installed.
39
- *
37
+ *
38
+ * First, ensure you have the EdgeDB CLI installed.
39
+ *
40
40
  * Follow the instructions below, or read the [EdgeDB quickstart](https://www.edgedb.com/docs/intro/quickstart) to install the EdgeDB CLI and initialize a project
41
- *
41
+ *
42
42
  * ### Linux or macOS
43
43
  * ```bash
44
44
  * curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
45
45
  * ```
46
- *
46
+ *
47
47
  * ### Windows
48
48
  * ```powershell
49
49
  * iwr https://ps1.edgedb.com -useb | iex
50
50
  * ```
51
- *
51
+ *
52
52
  * Check that the CLI is available with the `edgedb --version` command. If you get a `Command not found` error, you may need to open a new terminal window before the `edgedb` command is available.
53
- *
53
+ *
54
54
  * Once the CLI is installed, initialize a project from the application’s root directory. You’ll be presented with a series of prompts.
55
- *
55
+ *
56
56
  * ```bash
57
57
  * edgedb project init
58
58
  * ```
59
- *
59
+ *
60
60
  * This process will spin up an EdgeDB instance and [“link”](https://www.edgedb.com/docs/cli/edgedb_instance/edgedb_instance_link#edgedb-instance-link) it with your current directory. As long as you’re inside that directory, CLI commands and client libraries will be able to connect to the linked instance automatically, without additional configuration.
61
- *
61
+ *
62
62
  * ## Setup
63
- *
63
+ *
64
64
  * ### NextAuth.js configuration
65
- *
65
+ *
66
66
  * Configure your NextAuth.js to use the EdgeDB Adapter:
67
- *
67
+ *
68
68
  * ```javascript title="pages/api/auth/[...nextauth].js"
69
69
  * import NextAuth from "next-auth"
70
70
  * import GoogleProvider from "next-auth/providers/google"
71
71
  * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
72
72
  * import { createClient } from "edgedb"
73
- *
73
+ *
74
74
  * const client = createClient()
75
- *
75
+ *
76
76
  * export default NextAuth({
77
77
  * adapter: EdgeDBAdapter(client),
78
78
  * providers: [
@@ -83,13 +83,13 @@ import type { Client } from "edgedb"
83
83
  * ],
84
84
  * })
85
85
  * ```
86
- *
86
+ *
87
87
  * ### Create the EdgeDB schema
88
- *
88
+ *
89
89
  * Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
90
90
  *
91
- * > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models)
92
- *
91
+ * > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
92
+ *
93
93
  * ```json title="default.esdl"
94
94
  * module default {
95
95
  * type User {
@@ -100,12 +100,12 @@ import type { Client } from "edgedb"
100
100
  * property emailVerified -> datetime;
101
101
  * property image -> str;
102
102
  * multi link accounts := .<user[is Account];
103
- * multi link sessions := .<user[is Session];
103
+ * multi link sessions := .<user[is Session];
104
104
  * property createdAt -> datetime {
105
105
  * default := datetime_current();
106
106
  * };
107
107
  * }
108
- *
108
+ *
109
109
  * type Account {
110
110
  * required property userId := .user.id;
111
111
  * required property type -> str;
@@ -126,10 +126,10 @@ import type { Client } from "edgedb"
126
126
  * property createdAt -> datetime {
127
127
  * default := datetime_current();
128
128
  * };
129
- *
129
+ *
130
130
  * constraint exclusive on ((.provider, .providerAccountId))
131
131
  * }
132
- *
132
+ *
133
133
  * type Session {
134
134
  * required property sessionToken -> str {
135
135
  * constraint exclusive;
@@ -143,7 +143,7 @@ import type { Client } from "edgedb"
143
143
  * default := datetime_current();
144
144
  * };
145
145
  * }
146
- *
146
+ *
147
147
  * type VerificationToken {
148
148
  * required property identifier -> str;
149
149
  * required property token -> str {
@@ -153,43 +153,43 @@ import type { Client } from "edgedb"
153
153
  * property createdAt -> datetime {
154
154
  * default := datetime_current();
155
155
  * };
156
- *
156
+ *
157
157
  * constraint exclusive on ((.identifier, .token))
158
158
  * }
159
159
  * }
160
- *
160
+ *
161
161
  * # Disable the application of access policies within access policies
162
162
  * # themselves. This behavior will become the default in EdgeDB 3.0.
163
163
  * # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
164
164
  * using future nonrecursive_access_policies;
165
165
  * ```
166
- *
166
+ *
167
167
  * ### Migrate the database schema
168
- *
168
+ *
169
169
  * Create a migration
170
- *
170
+ *
171
171
  * ```
172
172
  * edgedb migration create
173
173
  * ```
174
- *
174
+ *
175
175
  * Apply the migration
176
- *
176
+ *
177
177
  * ```
178
178
  * edgedb migrate
179
179
  * ```
180
- *
180
+ *
181
181
  * To learn more about [EdgeDB migrations](https://www.edgedb.com/docs/intro/migrations#generate-a-migration), check out the [Migrations docs](https://www.edgedb.com/docs/intro/migrations).
182
- *
182
+ *
183
183
  * ### Generate the query builder
184
- *
185
- * ```npm2yarn2pnpm
184
+ *
185
+ * ```npm2yarn
186
186
  * npx @edgedb/generate edgeql-js
187
187
  * ```
188
- *
188
+ *
189
189
  * This will generate the [query builder](https://www.edgedb.com/docs/clients/js/querybuilder) so that you can write fully typed EdgeQL queries with TypeScript in a code-first way.
190
- *
190
+ *
191
191
  * For example
192
- *
192
+ *
193
193
  * ```ts
194
194
  * const query = e.select(e.User, () => ({
195
195
  * id: true,
@@ -199,9 +199,9 @@ import type { Client } from "edgedb"
199
199
  * image: true,
200
200
  * filter_single: { email: 'johndoe@example.com' },
201
201
  * }));
202
- *
202
+ *
203
203
  * return await query.run(client);
204
- *
204
+ *
205
205
  * // Return type:
206
206
  * // {
207
207
  * // id: string;
@@ -210,49 +210,49 @@ import type { Client } from "edgedb"
210
210
  * // image: string | null;
211
211
  * // name: string | null;
212
212
  * // } | null
213
- *
213
+ *
214
214
  * ```
215
- *
216
- *
215
+ *
216
+ *
217
217
  * ## Deploying
218
- *
218
+ *
219
219
  * ### Deploy EdgeDB
220
- *
220
+ *
221
221
  * First deploy an EdgeDB instance on your preferred cloud provider:
222
- *
222
+ *
223
223
  * [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
224
- *
224
+ *
225
225
  * [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
226
- *
226
+ *
227
227
  * [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
228
- *
228
+ *
229
229
  * [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
230
- *
230
+ *
231
231
  * [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
232
- *
232
+ *
233
233
  * [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
234
- *
234
+ *
235
235
  * ### Find your instance’s DSN
236
- *
236
+ *
237
237
  * The DSN is also known as a connection string. It will have the format `edgedb://username:password@hostname:port`. The exact instructions for this depend on which cloud you are deploying to.
238
- *
238
+ *
239
239
  * ### Set an environment variable
240
- *
240
+ *
241
241
  * ```env title=".env"
242
242
  * EDGEDB_DSN=edgedb://johndoe:supersecure@myhost.com:420
243
243
  * ```
244
- *
244
+ *
245
245
  * ### Update the client
246
- *
246
+ *
247
247
  * ```diff title="pages/api/auth/[...nextauth].js"
248
248
  * import NextAuth from "next-auth"
249
249
  * import GoogleProvider from "next-auth/providers/google"
250
250
  * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
251
251
  * import { createClient } from "edgedb"
252
- *
252
+ *
253
253
  * - const client = createClient()
254
254
  * + const client = createClient({ dsn: process.env.EDGEDB_DSN })
255
- *
255
+ *
256
256
  * export default NextAuth({
257
257
  * adapter: EdgeDBAdapter(client),
258
258
  * providers: [
@@ -263,21 +263,21 @@ import type { Client } from "edgedb"
263
263
  * ],
264
264
  * })
265
265
  * ```
266
- *
267
- *
268
- *
266
+ *
267
+ *
268
+ *
269
269
  * ### Apply migrations
270
- *
270
+ *
271
271
  * Use the DSN to apply migrations against your remote instance.
272
- *
272
+ *
273
273
  * ```bash
274
274
  * edgedb migrate --dsn <your-instance-dsn>
275
275
  * ```
276
- *
276
+ *
277
277
  * ### Set up a `prebuild` script
278
- *
278
+ *
279
279
  * Add the following `prebuild` script to your `package.json`. When your hosting provider initializes the build, it will trigger this script which will generate the query builder. The `npx @edgedb/generate edgeql-js` command will read the value of the `EDGEDB_DSN` environment variable, connect to the database, and generate the query builder before your hosting provider starts building the project.
280
- *
280
+ *
281
281
  * ```diff title="package.json"
282
282
  * "scripts": {
283
283
  * "dev": "next dev",
@@ -287,7 +287,7 @@ import type { Client } from "edgedb"
287
287
  * + "prebuild": "npx @edgedb/generate edgeql-js"
288
288
  * },
289
289
  * ```
290
- *
290
+ *
291
291
  */
292
292
  export function EdgeDBAdapter(client: Client): Adapter {
293
293
  return {