@auth/edgedb-adapter 0.7.2 → 1.0.0

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <br/>
3
3
  <a href="https://authjs.dev" target="_blank">
4
- <img height="64px" src="https://authjs.dev/img/logo/logo-sm.png" />
4
+ <img height="64px" src="https://authjs.dev/img/logo-sm.png" />
5
5
  </a>
6
6
  <a href="https://www.edgedb.com/" target="_blank">
7
7
  <img height="64px" src="https://authjs.dev/img/adapters/edgedb.svg"/>
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}>
3
- * <p style={{fontWeight: "normal"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
2
+ * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
3
+ * <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
4
4
  * <a href="https://www.edgedb.com/">
5
5
  * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />
6
6
  * </a>
@@ -33,11 +33,13 @@ import type { Client } from "edgedb";
33
33
  * 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
34
34
  *
35
35
  * ### Linux or macOS
36
+ *
36
37
  * ```bash
37
38
  * curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
38
39
  * ```
39
40
  *
40
41
  * ### Windows
42
+ *
41
43
  * ```powershell
42
44
  * iwr https://ps1.edgedb.com -useb | iex
43
45
  * ```
@@ -58,7 +60,7 @@ import type { Client } from "edgedb";
58
60
  *
59
61
  * Configure your NextAuth.js to use the EdgeDB Adapter:
60
62
  *
61
- * ```javascript title="pages/api/auth/[...nextauth].js"
63
+ * ```js title="pages/api/auth/[...nextauth].js"
62
64
  * import NextAuth from "next-auth"
63
65
  * import GoogleProvider from "next-auth/providers/google"
64
66
  * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
@@ -89,7 +91,7 @@ import type { Client } from "edgedb";
89
91
  * property name -> str;
90
92
  * required property email -> str {
91
93
  * constraint exclusive;
92
- * }
94
+ * };
93
95
  * property emailVerified -> datetime;
94
96
  * property image -> str;
95
97
  * multi link accounts := .<user[is Account];
@@ -119,14 +121,13 @@ import type { Client } from "edgedb";
119
121
  * property createdAt -> datetime {
120
122
  * default := datetime_current();
121
123
  * };
122
- *
123
- * constraint exclusive on ((.provider, .providerAccountId))
124
+ * constraint exclusive on ((.provider, .providerAccountId));
124
125
  * }
125
126
  *
126
127
  * type Session {
127
128
  * required property sessionToken -> str {
128
129
  * constraint exclusive;
129
- * }
130
+ * };
130
131
  * required property userId := .user.id;
131
132
  * required property expires -> datetime;
132
133
  * required link user -> User {
@@ -141,124 +142,83 @@ import type { Client } from "edgedb";
141
142
  * required property identifier -> str;
142
143
  * required property token -> str {
143
144
  * constraint exclusive;
144
- * }
145
+ * };
145
146
  * required property expires -> datetime;
146
147
  * property createdAt -> datetime {
147
148
  * default := datetime_current();
148
149
  * };
149
150
  *
150
- * constraint exclusive on ((.identifier, .token))
151
+ * constraint exclusive on ((.identifier, .token));
151
152
  * }
152
153
  * }
153
154
  *
154
155
  * # Disable the application of access policies within access policies
155
156
  * # themselves. This behavior will become the default in EdgeDB 3.0.
156
157
  * # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
158
+ *
157
159
  * using future nonrecursive_access_policies;
158
160
  * ```
159
161
  *
160
162
  * ### Migrate the database schema
161
163
  *
162
- * Create a migration
164
+ * 1. Create a migration
163
165
  *
164
- * ```
166
+ * ```bash
165
167
  * edgedb migration create
166
168
  * ```
167
169
  *
168
- * Apply the migration
170
+ * 2. Apply the migration
169
171
  *
170
- * ```
172
+ * ```bash
171
173
  * edgedb migrate
172
174
  * ```
173
175
  *
174
- * 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).
176
+ * 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).
175
177
  *
176
178
  * ### Generate the query builder
177
179
  *
178
- * ```npm2yarn
180
+ * ```bash
179
181
  * npx @edgedb/generate edgeql-js
180
182
  * ```
181
183
  *
182
184
  * 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.
183
185
  *
184
- * For example
185
- *
186
186
  * ```ts
187
187
  * const query = e.select(e.User, () => ({
188
- * id: true,
189
- * email: true,
190
- * emailVerified: true,
191
- * name: true,
192
- * image: true,
193
- * filter_single: { email: 'johndoe@example.com' },
194
- * }));
188
+ * id: true,
189
+ * email: true,
190
+ * emailVerified: true,
191
+ * name: true,
192
+ * image: true,
193
+ * filter_single: { email: "johndoe@example.com" },
194
+ * }));
195
195
  *
196
196
  * return await query.run(client);
197
- *
198
- * // Return type:
199
- * // {
200
- * // id: string;
201
- * // email: string;
202
- * // emailVerified: Date | null;
203
- * // image: string | null;
204
- * // name: string | null;
205
- * // } | null
206
- *
207
197
  * ```
208
198
  *
209
- *
210
199
  * ## Deploying
211
200
  *
212
201
  * ### Deploy EdgeDB
213
202
  *
214
203
  * First deploy an EdgeDB instance on your preferred cloud provider:
215
204
  *
216
- * [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
217
- *
218
- * [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
219
- *
220
- * [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
221
- *
222
- * [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
223
- *
224
- * [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
225
- *
226
- * [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
205
+ * - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
206
+ * - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
207
+ * - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
208
+ * - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
209
+ * - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
210
+ * - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
227
211
  *
228
212
  * ### Find your instance’s DSN
229
213
  *
230
- * 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.
214
+ * 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 provider your'e deploying to.
231
215
  *
232
216
  * ### Set an environment variable
233
217
  *
234
- * ```env title=".env"
235
- * EDGEDB_DSN=edgedb://johndoe:supersecure@myhost.com:420
236
218
  * ```
237
- *
238
- * ### Update the client
239
- *
240
- * ```diff title="pages/api/auth/[...nextauth].js"
241
- * import NextAuth from "next-auth"
242
- * import GoogleProvider from "next-auth/providers/google"
243
- * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
244
- * import { createClient } from "edgedb"
245
- *
246
- * - const client = createClient()
247
- * + const client = createClient({ dsn: process.env.EDGEDB_DSN })
248
- *
249
- * export default NextAuth({
250
- * adapter: EdgeDBAdapter(client),
251
- * providers: [
252
- * GoogleProvider({
253
- * clientId: process.env.GOOGLE_CLIENT_ID,
254
- * clientSecret: process.env.GOOGLE_CLIENT_SECRET,
255
- * }),
256
- * ],
257
- * })
219
+ * EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
258
220
  * ```
259
221
  *
260
- *
261
- *
262
222
  * ### Apply migrations
263
223
  *
264
224
  * Use the DSN to apply migrations against your remote instance.
@@ -271,15 +231,6 @@ import type { Client } from "edgedb";
271
231
  *
272
232
  * 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.
273
233
  *
274
- * ```diff title="package.json"
275
- * "scripts": {
276
- * "dev": "next dev",
277
- * "build": "next build",
278
- * "start": "next start",
279
- * "lint": "next lint",
280
- * + "prebuild": "npx @edgedb/generate edgeql-js"
281
- * },
282
- * ```
283
234
  *
284
235
  */
285
236
  export declare function EdgeDBAdapter(client: Client): Adapter;
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmUrD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuNG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmUrD"}
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}>
3
- * <p style={{fontWeight: "normal"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
2
+ * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
3
+ * <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
4
4
  * <a href="https://www.edgedb.com/">
5
5
  * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />
6
6
  * </a>
@@ -31,11 +31,13 @@
31
31
  * 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
32
32
  *
33
33
  * ### Linux or macOS
34
+ *
34
35
  * ```bash
35
36
  * curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
36
37
  * ```
37
38
  *
38
39
  * ### Windows
40
+ *
39
41
  * ```powershell
40
42
  * iwr https://ps1.edgedb.com -useb | iex
41
43
  * ```
@@ -56,7 +58,7 @@
56
58
  *
57
59
  * Configure your NextAuth.js to use the EdgeDB Adapter:
58
60
  *
59
- * ```javascript title="pages/api/auth/[...nextauth].js"
61
+ * ```js title="pages/api/auth/[...nextauth].js"
60
62
  * import NextAuth from "next-auth"
61
63
  * import GoogleProvider from "next-auth/providers/google"
62
64
  * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
@@ -87,7 +89,7 @@
87
89
  * property name -> str;
88
90
  * required property email -> str {
89
91
  * constraint exclusive;
90
- * }
92
+ * };
91
93
  * property emailVerified -> datetime;
92
94
  * property image -> str;
93
95
  * multi link accounts := .<user[is Account];
@@ -117,14 +119,13 @@
117
119
  * property createdAt -> datetime {
118
120
  * default := datetime_current();
119
121
  * };
120
- *
121
- * constraint exclusive on ((.provider, .providerAccountId))
122
+ * constraint exclusive on ((.provider, .providerAccountId));
122
123
  * }
123
124
  *
124
125
  * type Session {
125
126
  * required property sessionToken -> str {
126
127
  * constraint exclusive;
127
- * }
128
+ * };
128
129
  * required property userId := .user.id;
129
130
  * required property expires -> datetime;
130
131
  * required link user -> User {
@@ -139,124 +140,83 @@
139
140
  * required property identifier -> str;
140
141
  * required property token -> str {
141
142
  * constraint exclusive;
142
- * }
143
+ * };
143
144
  * required property expires -> datetime;
144
145
  * property createdAt -> datetime {
145
146
  * default := datetime_current();
146
147
  * };
147
148
  *
148
- * constraint exclusive on ((.identifier, .token))
149
+ * constraint exclusive on ((.identifier, .token));
149
150
  * }
150
151
  * }
151
152
  *
152
153
  * # Disable the application of access policies within access policies
153
154
  * # themselves. This behavior will become the default in EdgeDB 3.0.
154
155
  * # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
156
+ *
155
157
  * using future nonrecursive_access_policies;
156
158
  * ```
157
159
  *
158
160
  * ### Migrate the database schema
159
161
  *
160
- * Create a migration
162
+ * 1. Create a migration
161
163
  *
162
- * ```
164
+ * ```bash
163
165
  * edgedb migration create
164
166
  * ```
165
167
  *
166
- * Apply the migration
168
+ * 2. Apply the migration
167
169
  *
168
- * ```
170
+ * ```bash
169
171
  * edgedb migrate
170
172
  * ```
171
173
  *
172
- * 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).
174
+ * 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).
173
175
  *
174
176
  * ### Generate the query builder
175
177
  *
176
- * ```npm2yarn
178
+ * ```bash
177
179
  * npx @edgedb/generate edgeql-js
178
180
  * ```
179
181
  *
180
182
  * 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.
181
183
  *
182
- * For example
183
- *
184
184
  * ```ts
185
185
  * const query = e.select(e.User, () => ({
186
- * id: true,
187
- * email: true,
188
- * emailVerified: true,
189
- * name: true,
190
- * image: true,
191
- * filter_single: { email: 'johndoe@example.com' },
192
- * }));
186
+ * id: true,
187
+ * email: true,
188
+ * emailVerified: true,
189
+ * name: true,
190
+ * image: true,
191
+ * filter_single: { email: "johndoe@example.com" },
192
+ * }));
193
193
  *
194
194
  * return await query.run(client);
195
- *
196
- * // Return type:
197
- * // {
198
- * // id: string;
199
- * // email: string;
200
- * // emailVerified: Date | null;
201
- * // image: string | null;
202
- * // name: string | null;
203
- * // } | null
204
- *
205
195
  * ```
206
196
  *
207
- *
208
197
  * ## Deploying
209
198
  *
210
199
  * ### Deploy EdgeDB
211
200
  *
212
201
  * First deploy an EdgeDB instance on your preferred cloud provider:
213
202
  *
214
- * [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
215
- *
216
- * [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
217
- *
218
- * [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
219
- *
220
- * [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
221
- *
222
- * [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
223
- *
224
- * [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
203
+ * - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
204
+ * - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
205
+ * - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
206
+ * - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
207
+ * - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
208
+ * - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
225
209
  *
226
210
  * ### Find your instance’s DSN
227
211
  *
228
- * 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.
212
+ * 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 provider your'e deploying to.
229
213
  *
230
214
  * ### Set an environment variable
231
215
  *
232
- * ```env title=".env"
233
- * EDGEDB_DSN=edgedb://johndoe:supersecure@myhost.com:420
234
216
  * ```
235
- *
236
- * ### Update the client
237
- *
238
- * ```diff title="pages/api/auth/[...nextauth].js"
239
- * import NextAuth from "next-auth"
240
- * import GoogleProvider from "next-auth/providers/google"
241
- * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
242
- * import { createClient } from "edgedb"
243
- *
244
- * - const client = createClient()
245
- * + const client = createClient({ dsn: process.env.EDGEDB_DSN })
246
- *
247
- * export default NextAuth({
248
- * adapter: EdgeDBAdapter(client),
249
- * providers: [
250
- * GoogleProvider({
251
- * clientId: process.env.GOOGLE_CLIENT_ID,
252
- * clientSecret: process.env.GOOGLE_CLIENT_SECRET,
253
- * }),
254
- * ],
255
- * })
217
+ * EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
256
218
  * ```
257
219
  *
258
- *
259
- *
260
220
  * ### Apply migrations
261
221
  *
262
222
  * Use the DSN to apply migrations against your remote instance.
@@ -269,15 +229,6 @@
269
229
  *
270
230
  * 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.
271
231
  *
272
- * ```diff title="package.json"
273
- * "scripts": {
274
- * "dev": "next dev",
275
- * "build": "next build",
276
- * "start": "next start",
277
- * "lint": "next lint",
278
- * + "prebuild": "npx @edgedb/generate edgeql-js"
279
- * },
280
- * ```
281
232
  *
282
233
  */
283
234
  export function EdgeDBAdapter(client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth/edgedb-adapter",
3
- "version": "0.7.2",
3
+ "version": "1.0.0",
4
4
  "description": "EdgeDB adapter for next-auth.",
5
5
  "homepage": "https://authjs.dev",
6
6
  "repository": "https://github.com/nextauthjs/next-auth",
@@ -37,7 +37,7 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@auth/core": "0.28.2"
40
+ "@auth/core": "0.30.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "edgedb": "^1.0.1"
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}>
3
- * <p style={{fontWeight: "normal"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
2
+ * <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
3
+ * <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
4
4
  * <a href="https://www.edgedb.com/">
5
5
  * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />
6
6
  * </a>
@@ -40,11 +40,13 @@ import type { Client } from "edgedb"
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
44
  * ```bash
44
45
  * curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
45
46
  * ```
46
47
  *
47
48
  * ### Windows
49
+ *
48
50
  * ```powershell
49
51
  * iwr https://ps1.edgedb.com -useb | iex
50
52
  * ```
@@ -65,7 +67,7 @@ import type { Client } from "edgedb"
65
67
  *
66
68
  * Configure your NextAuth.js to use the EdgeDB Adapter:
67
69
  *
68
- * ```javascript title="pages/api/auth/[...nextauth].js"
70
+ * ```js title="pages/api/auth/[...nextauth].js"
69
71
  * import NextAuth from "next-auth"
70
72
  * import GoogleProvider from "next-auth/providers/google"
71
73
  * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
@@ -96,7 +98,7 @@ import type { Client } from "edgedb"
96
98
  * property name -> str;
97
99
  * required property email -> str {
98
100
  * constraint exclusive;
99
- * }
101
+ * };
100
102
  * property emailVerified -> datetime;
101
103
  * property image -> str;
102
104
  * multi link accounts := .<user[is Account];
@@ -126,14 +128,13 @@ import type { Client } from "edgedb"
126
128
  * property createdAt -> datetime {
127
129
  * default := datetime_current();
128
130
  * };
129
- *
130
- * constraint exclusive on ((.provider, .providerAccountId))
131
+ * constraint exclusive on ((.provider, .providerAccountId));
131
132
  * }
132
133
  *
133
134
  * type Session {
134
135
  * required property sessionToken -> str {
135
136
  * constraint exclusive;
136
- * }
137
+ * };
137
138
  * required property userId := .user.id;
138
139
  * required property expires -> datetime;
139
140
  * required link user -> User {
@@ -148,124 +149,83 @@ import type { Client } from "edgedb"
148
149
  * required property identifier -> str;
149
150
  * required property token -> str {
150
151
  * constraint exclusive;
151
- * }
152
+ * };
152
153
  * required property expires -> datetime;
153
154
  * property createdAt -> datetime {
154
155
  * default := datetime_current();
155
156
  * };
156
157
  *
157
- * constraint exclusive on ((.identifier, .token))
158
+ * constraint exclusive on ((.identifier, .token));
158
159
  * }
159
160
  * }
160
161
  *
161
162
  * # Disable the application of access policies within access policies
162
163
  * # themselves. This behavior will become the default in EdgeDB 3.0.
163
164
  * # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
165
+ *
164
166
  * using future nonrecursive_access_policies;
165
167
  * ```
166
168
  *
167
169
  * ### Migrate the database schema
168
170
  *
169
- * Create a migration
171
+ * 1. Create a migration
170
172
  *
171
- * ```
173
+ * ```bash
172
174
  * edgedb migration create
173
175
  * ```
174
176
  *
175
- * Apply the migration
177
+ * 2. Apply the migration
176
178
  *
177
- * ```
179
+ * ```bash
178
180
  * edgedb migrate
179
181
  * ```
180
182
  *
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).
183
+ * 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
184
  *
183
185
  * ### Generate the query builder
184
186
  *
185
- * ```npm2yarn
187
+ * ```bash
186
188
  * npx @edgedb/generate edgeql-js
187
189
  * ```
188
190
  *
189
191
  * 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
192
  *
191
- * For example
192
- *
193
193
  * ```ts
194
194
  * const query = e.select(e.User, () => ({
195
- * id: true,
196
- * email: true,
197
- * emailVerified: true,
198
- * name: true,
199
- * image: true,
200
- * filter_single: { email: 'johndoe@example.com' },
201
- * }));
195
+ * id: true,
196
+ * email: true,
197
+ * emailVerified: true,
198
+ * name: true,
199
+ * image: true,
200
+ * filter_single: { email: "johndoe@example.com" },
201
+ * }));
202
202
  *
203
203
  * return await query.run(client);
204
- *
205
- * // Return type:
206
- * // {
207
- * // id: string;
208
- * // email: string;
209
- * // emailVerified: Date | null;
210
- * // image: string | null;
211
- * // name: string | null;
212
- * // } | null
213
- *
214
204
  * ```
215
205
  *
216
- *
217
206
  * ## Deploying
218
207
  *
219
208
  * ### Deploy EdgeDB
220
209
  *
221
210
  * First deploy an EdgeDB instance on your preferred cloud provider:
222
211
  *
223
- * [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
224
- *
225
- * [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
226
- *
227
- * [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
228
- *
229
- * [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
230
- *
231
- * [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
232
- *
233
- * [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
212
+ * - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
213
+ * - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
214
+ * - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
215
+ * - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
216
+ * - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
217
+ * - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
234
218
  *
235
219
  * ### Find your instance’s DSN
236
220
  *
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.
221
+ * 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 provider your'e deploying to.
238
222
  *
239
223
  * ### Set an environment variable
240
224
  *
241
- * ```env title=".env"
242
- * EDGEDB_DSN=edgedb://johndoe:supersecure@myhost.com:420
243
225
  * ```
244
- *
245
- * ### Update the client
246
- *
247
- * ```diff title="pages/api/auth/[...nextauth].js"
248
- * import NextAuth from "next-auth"
249
- * import GoogleProvider from "next-auth/providers/google"
250
- * import { EdgeDBAdapter } from "@auth/edgedb-adapter"
251
- * import { createClient } from "edgedb"
252
- *
253
- * - const client = createClient()
254
- * + const client = createClient({ dsn: process.env.EDGEDB_DSN })
255
- *
256
- * export default NextAuth({
257
- * adapter: EdgeDBAdapter(client),
258
- * providers: [
259
- * GoogleProvider({
260
- * clientId: process.env.GOOGLE_CLIENT_ID,
261
- * clientSecret: process.env.GOOGLE_CLIENT_SECRET,
262
- * }),
263
- * ],
264
- * })
226
+ * EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
265
227
  * ```
266
228
  *
267
- *
268
- *
269
229
  * ### Apply migrations
270
230
  *
271
231
  * Use the DSN to apply migrations against your remote instance.
@@ -278,15 +238,6 @@ import type { Client } from "edgedb"
278
238
  *
279
239
  * 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
240
  *
281
- * ```diff title="package.json"
282
- * "scripts": {
283
- * "dev": "next dev",
284
- * "build": "next build",
285
- * "start": "next start",
286
- * "lint": "next lint",
287
- * + "prebuild": "npx @edgedb/generate edgeql-js"
288
- * },
289
- * ```
290
241
  *
291
242
  */
292
243
  export function EdgeDBAdapter(client: Client): Adapter {