@cedarjs/internal 7.0.1-next.333 → 7.0.1-next.467

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.
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AAwCtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAI9D,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8UD,eAAO,MAAM,gBAAgB,iHA+D5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AA6CtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAI9D,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA8XD,eAAO,MAAM,gBAAgB,iHA+D5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
package/dist/build/api.js CHANGED
@@ -14,7 +14,12 @@ import {
14
14
  getApiSideBabelPluginsForVite,
15
15
  transformWithBabel
16
16
  } from "@cedarjs/babel-config";
17
- import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
17
+ import {
18
+ getConfig,
19
+ getPaths,
20
+ createPrismaClientFileMatcher,
21
+ resolveFile
22
+ } from "@cedarjs/project-config";
18
23
  import { findApiFiles } from "../files.js";
19
24
  import {
20
25
  applyGqlormInject,
@@ -55,8 +60,19 @@ const cleanApiBuild = async () => {
55
60
  const runCedarBabelTransformsPlugin = {
56
61
  name: "cedar-esbuild-babel-transform",
57
62
  setup(build2) {
63
+ let prismaClientFiles = createPrismaClientFileMatcher();
64
+ build2.onStart(async () => {
65
+ prismaClientFiles = createPrismaClientFileMatcher();
66
+ await prismaClientFiles.load();
67
+ });
58
68
  build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
59
69
  let fileContents = await fs.promises.readFile(args.path, "utf-8");
70
+ if (await prismaClientFiles.matches(args.path)) {
71
+ return {
72
+ contents: applyImportExtensions(fileContents, args.path),
73
+ loader: getEsbuildLoader(args.path)
74
+ };
75
+ }
60
76
  fileContents = applySrcAlias(
61
77
  fileContents,
62
78
  path.dirname(
@@ -120,16 +136,23 @@ function getEsbuildLoader(filePath) {
120
136
  }
121
137
  }
122
138
  function createImportDirVitePlugin() {
139
+ const prismaClientFiles = createPrismaClientFileMatcher();
123
140
  return {
124
141
  name: "cedar-internal-import-dir",
125
142
  enforce: "pre",
126
- transform(code, id) {
143
+ async buildStart() {
144
+ await prismaClientFiles.load();
145
+ },
146
+ async transform(code, id) {
127
147
  if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
128
148
  return null;
129
149
  }
130
150
  if (id.includes("node_modules")) {
131
151
  return null;
132
152
  }
153
+ if (await prismaClientFiles.matches(id)) {
154
+ return null;
155
+ }
133
156
  const result = applyImportDir(code, id);
134
157
  if (!result) {
135
158
  return null;
@@ -170,9 +193,13 @@ function createDirectoryNamedImportVitePlugin() {
170
193
  }
171
194
  function createCedarViteApiPlugin() {
172
195
  const cedarConfig = getConfig();
196
+ const prismaClientFiles = createPrismaClientFileMatcher();
173
197
  return {
174
198
  name: "cedar-vite-api-babel-transform",
175
199
  enforce: "pre",
200
+ async buildStart() {
201
+ await prismaClientFiles.load();
202
+ },
176
203
  async transform(code, id) {
177
204
  if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
178
205
  return null;
@@ -184,6 +211,16 @@ function createCedarViteApiPlugin() {
184
211
  if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
185
212
  return null;
186
213
  }
214
+ if (await prismaClientFiles.matches(id)) {
215
+ const outputCode2 = applyImportExtensions(code, id);
216
+ if (outputCode2 === code) {
217
+ return null;
218
+ }
219
+ return {
220
+ code: outputCode2,
221
+ map: new MagicString(code).generateMap({ hires: true })
222
+ };
223
+ }
187
224
  let sourceCode = code;
188
225
  const normalizedId = normalizePath(id);
189
226
  sourceCode = applySrcAlias(
@@ -1 +1 @@
1
- {"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAoB9D,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAiFvE,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CA2DvE,CAAA;AAyFD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AAqPD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
1
+ {"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAoB9D,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAiFvE,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CA2DvE,CAAA;AAyFD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AAmQD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
@@ -306,8 +306,11 @@ async function getPluginConfig(side) {
306
306
  // @Note: DateTime fields can be valid Date-strings, or the Date object in the api side. They're strings on the web side, unless `graphql.parsedScalars.DateTime` is set. Then they are Date objects when the web side reads them, and Apollo Client accepts a Date or a string when they're sent.
307
307
  DateTime: side === 1 /* WEB */ ? getParsedScalars().DateTime === "Date" ? { input: "Date | string", output: "Date" } : "string" : "Date | string",
308
308
  Date: side === 1 /* WEB */ ? "string" : "Date | string",
309
- JSON: "Prisma.JsonValue",
310
- JSONObject: "Prisma.JsonObject",
309
+ // On the api side JSON inputs use Prisma's input types, so they can be
310
+ // passed straight to Prisma. These don't include a top-level null; a
311
+ // nullable JSON argument is typed as `InputMaybe<...>` instead
312
+ JSON: side === 1 /* WEB */ ? "Prisma.JsonValue" : { input: "Prisma.InputJsonValue", output: "Prisma.JsonValue" },
313
+ JSONObject: side === 1 /* WEB */ ? "Prisma.JsonObject" : { input: "Prisma.InputJsonObject", output: "Prisma.JsonObject" },
311
314
  Time: side === 1 /* WEB */ ? "string" : "Date | string",
312
315
  Byte: "Uint8Array"
313
316
  };
@@ -330,7 +333,12 @@ async function getPluginConfig(side) {
330
333
  // We do this, so that service tests can call resolvers without doing a null check
331
334
  // see https://github.com/redwoodjs/redwood/pull/6222#issuecomment-1230156868
332
335
  // Look at type or source https://shrtm.nu/2BA0 for possible config, not well documented
333
- resolvers: true
336
+ resolvers: true,
337
+ // `resolvers` doesn't cover the root types, so Query and Mutation
338
+ // resolvers need their own flags for services to export non-optional
339
+ // resolver functions
340
+ query: true,
341
+ mutation: true
334
342
  },
335
343
  contextType: `@cedarjs/graphql-server/dist/types#CedarGraphQLContext`
336
344
  };
@@ -3,7 +3,14 @@ import '@cedarjs/auth'
3
3
 
4
4
  import { getCurrentUser } from '../../../api/src/lib/auth.js'
5
5
 
6
- export type InferredCurrentUser = Awaited<ReturnType<typeof getCurrentUser>>
6
+ // The logged-in user getCurrentUser() returns. getCurrentUser() returns null
7
+ // when nobody is logged in; @cedarjs/auth's CurrentUser type and
8
+ // GlobalContext's currentUser type below cover that case. LoggedInUser below
9
+ // extends this type, and with strictNullChecks an interface can't extend a
10
+ // type that includes null.
11
+ export type InferredLoggedInUser = NonNullable<
12
+ Awaited<ReturnType<typeof getCurrentUser>>
13
+ >
7
14
 
8
15
  type UndefinedRoles = {
9
16
  /**
@@ -21,10 +28,12 @@ type Overwrite<T, U> = Omit<T, keyof U> & U
21
28
 
22
29
  declare module '@cedarjs/context' {
23
30
  interface GlobalContext {
24
- currentUser?: Overwrite<UndefinedRoles, InferredCurrentUser>
31
+ // Not set when nobody is logged in. Functions wrapped in useRequireAuth
32
+ // set it to whatever getCurrentUser() returned, including null
33
+ currentUser?: Overwrite<UndefinedRoles, InferredLoggedInUser> | null
25
34
  }
26
35
  }
27
36
 
28
37
  declare module '@cedarjs/auth' {
29
- interface CurrentUser extends InferredCurrentUser {}
38
+ interface LoggedInUser extends InferredLoggedInUser {}
30
39
  }
@@ -1,11 +1,11 @@
1
1
  import type { vi as _vi } from 'vitest'
2
2
 
3
- import type { CurrentUser } from '@cedarjs/auth'
3
+ import type { InferredLoggedInUser } from './all-currentUser.js'
4
4
 
5
5
  declare global {
6
6
  // describe, it, expect etc. are typed by @types/jest. Referencing
7
7
  // vitest/globals here would conflict with those declarations, so only vi
8
8
  // is declared
9
9
  const vi: typeof _vi
10
- const mockCurrentUser: (currentUser: CurrentUser) => void
10
+ const mockCurrentUser: (currentUser: InferredLoggedInUser | null) => void
11
11
  }
@@ -5,14 +5,14 @@ import type {
5
5
  mockGraphQLQuery as _mockGraphQLQuery,
6
6
  } from '@cedarjs/testing/web'
7
7
 
8
- import { InferredCurrentUser } from './all-currentUser.js'
8
+ import type { InferredLoggedInUser } from './all-currentUser.js'
9
9
 
10
10
  declare global {
11
11
  // describe, it, expect etc. are typed by @types/jest. Referencing
12
12
  // vitest/globals here would conflict with those declarations, so only vi
13
13
  // is declared
14
14
  const vi: typeof _vi
15
- const mockCurrentUser: (currentUser: InferredCurrentUser) => void
15
+ const mockCurrentUser: (currentUser: InferredLoggedInUser | null) => void
16
16
  const mockGraphQLQuery: typeof _mockGraphQLQuery
17
17
  const mockGraphQLMutation: typeof _mockGraphQLMutation
18
18
  }
@@ -304,8 +304,16 @@ const generateViteClientTypesDirective = () => {
304
304
  };
305
305
  function generateStubStorybookTypes() {
306
306
  const stubStorybookTypesFileContent = `declare module '@storybook/react' {
307
- export type Meta<T = any> = any
308
- export type StoryObj<T = any> = any
307
+ // Loose stand-ins for when Storybook isn't installed. \`render\` is spelled
308
+ // out so that its parameters are typed in stories, which keeps them valid
309
+ // with \`noImplicitAny\`
310
+ interface StubStoryAnnotations {
311
+ [key: string]: any
312
+ render?: (args: any, context: any) => any
313
+ }
314
+
315
+ export type Meta<T = any> = StubStoryAnnotations
316
+ export type StoryObj<T = any> = StubStoryAnnotations
309
317
  }
310
318
  `;
311
319
  const cedarProjectPaths = getPaths();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/internal",
3
- "version": "7.0.1-next.333",
3
+ "version": "7.0.1-next.467",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -119,15 +119,15 @@
119
119
  "dependencies": {
120
120
  "@babel/core": "^7.26.10",
121
121
  "@babel/parser": "7.29.9",
122
- "@babel/traverse": "7.29.8",
123
- "@cedarjs/api": "7.0.1-next.333",
124
- "@cedarjs/babel-config": "7.0.1-next.333",
125
- "@cedarjs/cli-helpers": "7.0.1-next.333",
126
- "@cedarjs/graphql-server": "7.0.1-next.333",
127
- "@cedarjs/project-config": "7.0.1-next.333",
128
- "@cedarjs/router": "7.0.1-next.333",
129
- "@cedarjs/structure": "7.0.1-next.333",
130
- "@cedarjs/utils": "7.0.1-next.333",
122
+ "@babel/traverse": "7.29.10",
123
+ "@cedarjs/api": "7.0.1-next.467",
124
+ "@cedarjs/babel-config": "7.0.1-next.467",
125
+ "@cedarjs/cli-helpers": "7.0.1-next.467",
126
+ "@cedarjs/graphql-server": "7.0.1-next.467",
127
+ "@cedarjs/project-config": "7.0.1-next.467",
128
+ "@cedarjs/router": "7.0.1-next.467",
129
+ "@cedarjs/structure": "7.0.1-next.467",
130
+ "@cedarjs/utils": "7.0.1-next.467",
131
131
  "@graphql-codegen/add": "6.0.1",
132
132
  "@graphql-codegen/cli": "6.3.1",
133
133
  "@graphql-codegen/client-preset": "5.3.0",
@@ -139,10 +139,10 @@
139
139
  "@graphql-codegen/typescript-operations": "5.1.0",
140
140
  "@graphql-codegen/typescript-resolvers": "5.1.8",
141
141
  "@graphql-codegen/visitor-plugin-common": "6.3.0",
142
- "@graphql-tools/code-file-loader": "8.1.39",
143
- "@graphql-tools/graphql-file-loader": "8.1.20",
144
- "@graphql-tools/load": "8.1.17",
145
- "@graphql-tools/merge": "9.2.4",
142
+ "@graphql-tools/code-file-loader": "8.1.41",
143
+ "@graphql-tools/graphql-file-loader": "8.1.22",
144
+ "@graphql-tools/load": "8.1.19",
145
+ "@graphql-tools/merge": "9.2.6",
146
146
  "@prisma/dmmf": "7.10.0",
147
147
  "@prisma/internals": "7.10.0",
148
148
  "@sdl-codegen/node": "2.0.1",
@@ -154,24 +154,24 @@
154
154
  "graphql": "16.14.2",
155
155
  "kill-port": "1.6.1",
156
156
  "magic-string": "0.30.21",
157
- "oxc-parser": "0.151.0",
158
- "prettier": "3.9.9",
157
+ "oxc-parser": "0.153.0",
158
+ "prettier": "3.9.10",
159
159
  "rimraf": "6.1.3",
160
160
  "source-map": "0.8.0",
161
161
  "termi-link": "1.1.0",
162
162
  "tsconfig-paths": "4.2.0",
163
163
  "typescript": "5.9.3",
164
- "vite": "7.3.6",
164
+ "vite": "7.3.7",
165
165
  "vite-tsconfig-paths": "^6.1.1"
166
166
  },
167
167
  "devDependencies": {
168
- "@cedarjs/framework-tools": "7.0.1-next.333",
168
+ "@cedarjs/framework-tools": "7.0.1-next.467",
169
169
  "@jridgewell/trace-mapping": "0.3.31",
170
- "@oxc-project/types": "^0.151.0",
171
- "concurrently": "9.2.4",
170
+ "@oxc-project/types": "^0.153.0",
171
+ "concurrently": "9.2.5",
172
172
  "graphql-tag": "2.12.7",
173
- "memfs": "4.79.0",
174
- "publint": "0.3.24",
173
+ "memfs": "4.80.0",
174
+ "publint": "0.3.25",
175
175
  "ts-dedent": "2.3.0",
176
176
  "vitest": "4.1.11"
177
177
  },