@cedarjs/internal 7.0.1-next.467 → 7.1.0-rc.32

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;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"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AA8CtE,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;AAyYD,eAAO,MAAM,gBAAgB,iHAiE5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
package/dist/build/api.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  import {
18
18
  getConfig,
19
19
  getPaths,
20
+ projectSideIsEsm,
20
21
  createPrismaClientFileMatcher,
21
22
  resolveFile
22
23
  } from "@cedarjs/project-config";
@@ -90,6 +91,7 @@ const runCedarBabelTransformsPlugin = {
90
91
  fileContents = applyJobPathInjector(fileContents, args.path, getPaths().api.jobs) ?? fileContents;
91
92
  const normalizedPath = normalizePath(args.path);
92
93
  const cedarPaths = getPaths();
94
+ const isEsm = projectSideIsEsm("api");
93
95
  const apiBabelConfigPath = getApiSideBabelConfigPath();
94
96
  let code = fileContents;
95
97
  if (apiBabelConfigPath) {
@@ -108,7 +110,9 @@ const runCedarBabelTransformsPlugin = {
108
110
  code = applyImportExtensions(code, args.path);
109
111
  const functionsDir = normalizePath(cedarPaths.api.functions);
110
112
  if (normalizedPath.startsWith(functionsDir + "/")) {
111
- code = applyHandlerAlsWrapping(code) ?? code;
113
+ code = applyHandlerAlsWrapping(code, {
114
+ projectIsEsm: isEsm
115
+ }) ?? code;
112
116
  }
113
117
  if (normalizedPath.startsWith(normalizePath(cedarPaths.api.src) + "/")) {
114
118
  code = applyOtelWrapping(code, args.path, cedarPaths.api.src) ?? code;
@@ -193,6 +197,7 @@ function createDirectoryNamedImportVitePlugin() {
193
197
  }
194
198
  function createCedarViteApiPlugin() {
195
199
  const cedarConfig = getConfig();
200
+ const isEsm = projectSideIsEsm("api");
196
201
  const prismaClientFiles = createPrismaClientFileMatcher();
197
202
  return {
198
203
  name: "cedar-vite-api-babel-transform",
@@ -251,7 +256,9 @@ function createCedarViteApiPlugin() {
251
256
  outputCode = applyImportExtensions(outputCode, id);
252
257
  const functionsDir = normalizePath(cedarPaths.api.functions);
253
258
  if (normalizedId.startsWith(functionsDir + "/")) {
254
- outputCode = applyHandlerAlsWrapping(outputCode) ?? outputCode;
259
+ outputCode = applyHandlerAlsWrapping(outputCode, {
260
+ projectIsEsm: isEsm
261
+ }) ?? outputCode;
255
262
  }
256
263
  if (!transformedCode) {
257
264
  if (outputCode === code) {
@@ -271,6 +278,8 @@ function createCedarViteApiPlugin() {
271
278
  }
272
279
  const buildApiWithVite = async () => {
273
280
  const cedarPaths = getPaths();
281
+ const isEsm = projectSideIsEsm("api");
282
+ const format = isEsm ? "es" : "cjs";
274
283
  const apiFiles = findApiFiles();
275
284
  const input = {};
276
285
  for (const f of apiFiles) {
@@ -287,7 +296,7 @@ const buildApiWithVite = async () => {
287
296
  rollupOptions: {
288
297
  input,
289
298
  output: {
290
- format: "es",
299
+ format,
291
300
  preserveModules: true,
292
301
  preserveModulesRoot: cedarPaths.api.src,
293
302
  entryFileNames: "[name].js",
@@ -368,12 +377,13 @@ async function fixSourceMaps(distDir, srcDir) {
368
377
  }
369
378
  function getEsbuildOptions(files) {
370
379
  const cedarPaths = getPaths();
380
+ const format = projectSideIsEsm("api") ? "esm" : "cjs";
371
381
  return {
372
382
  absWorkingDir: cedarPaths.api.base,
373
383
  entryPoints: files,
374
384
  platform: "node",
375
385
  target: "node24",
376
- format: "esm",
386
+ format,
377
387
  allowOverwrite: true,
378
388
  bundle: false,
379
389
  // Registration order matters: cedarApiGraphqlPlugin (narrow filter) must
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAsB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA8GzB,CAAA"}
1
+ {"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAsB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAiHzB,CAAA"}
@@ -5,7 +5,7 @@ import {
5
5
  getApiSideBabelPluginsForVite,
6
6
  transformWithBabel
7
7
  } from "@cedarjs/babel-config";
8
- import { getConfig, getPaths } from "@cedarjs/project-config";
8
+ import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
9
9
  import {
10
10
  applyGqlormInject,
11
11
  applyGraphqlOptionsExtract
@@ -59,7 +59,9 @@ const cedarApiGraphqlPlugin = {
59
59
  if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
60
60
  code = applyOtelWrapping(code, args.path, getPaths().api.src) ?? code;
61
61
  }
62
- code = applyHandlerAlsWrapping(code) ?? code;
62
+ code = applyHandlerAlsWrapping(code, {
63
+ projectIsEsm: projectSideIsEsm("api")
64
+ }) ?? code;
63
65
  return {
64
66
  contents: code,
65
67
  // Babel output is always plain JS. Without Babel the contents are
@@ -1,2 +1,4 @@
1
- export declare function applyHandlerAlsWrapping(code: string): string | null;
1
+ export declare function applyHandlerAlsWrapping(code: string, { projectIsEsm }?: {
2
+ projectIsEsm?: boolean;
3
+ }): string | null;
2
4
  //# sourceMappingURL=esbuild-plugin-handler-als-wrapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsCnE"}
1
+ {"version":3,"file":"esbuild-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,GAAG,IAAI,CA0Cf"}
@@ -1,4 +1,4 @@
1
- function applyHandlerAlsWrapping(code) {
1
+ function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
2
2
  const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
3
3
  const handlerMatch = handlerRe.exec(code);
4
4
  if (!handlerMatch) {
@@ -6,7 +6,8 @@ function applyHandlerAlsWrapping(code) {
6
6
  }
7
7
  const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
8
8
  const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
9
- const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '@cedarjs/context/dist/store.js'
9
+ const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
10
+ const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '${storePath}'
10
11
  `;
11
12
  const handlerStart = handlerMatch.index;
12
13
  const before = code.slice(0, handlerStart);
@@ -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;AAmQD,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;AAmB9D,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,CAwDvE,CAAA;AA+DD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AA2OD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
@@ -14,7 +14,6 @@ import { Kind } from "graphql";
14
14
  import {
15
15
  getPaths,
16
16
  getConfig,
17
- getParsedScalars,
18
17
  resolveGeneratedPrismaClient
19
18
  } from "@cedarjs/project-config";
20
19
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
@@ -115,10 +114,7 @@ const generateTypeDefGraphQLWeb = async () => {
115
114
  {
116
115
  name: "add",
117
116
  options: {
118
- content: [
119
- `import { Prisma } from "$api/src/lib/db"`,
120
- ...getApolloScalarDeclarations()
121
- ],
117
+ content: `import { Prisma } from "$api/src/lib/db"`,
122
118
  placement: "prepend"
123
119
  },
124
120
  codegenPlugin: addPlugin
@@ -163,23 +159,6 @@ function mergeScalars(cedarScalars, userScalars) {
163
159
  }
164
160
  return userScalars;
165
161
  }
166
- function getApolloScalarDeclarations() {
167
- const declarations = [];
168
- if (getParsedScalars().DateTime === "Date") {
169
- declarations.push(
170
- [
171
- "declare module '@apollo/client' {",
172
- " namespace ApolloCache {",
173
- " interface Scalars {",
174
- " DateTime: { serialized: string; parsed: Date }",
175
- " }",
176
- " }",
177
- "}"
178
- ].join("\n")
179
- );
180
- }
181
- return declarations;
182
- }
183
162
  async function runCodegenGraphQL(documents, extraPlugins, filename, side) {
184
163
  const userCodegenConfig = await loadCodegenConfig({
185
164
  configFilePath: getPaths().base
@@ -303,14 +282,11 @@ async function getPluginConfig(side) {
303
282
  const scalars = {
304
283
  // We need these, otherwise these scalars are mapped to any
305
284
  BigInt: "number",
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
- DateTime: side === 1 /* WEB */ ? getParsedScalars().DateTime === "Date" ? { input: "Date | string", output: "Date" } : "string" : "Date | string",
285
+ // @Note: DateTime fields can be valid Date-strings, or the Date object in the api side. They're always strings on the web side.
286
+ DateTime: side === 1 /* WEB */ ? "string" : "Date | string",
308
287
  Date: side === 1 /* WEB */ ? "string" : "Date | string",
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" },
288
+ JSON: "Prisma.JsonValue",
289
+ JSONObject: "Prisma.JsonObject",
314
290
  Time: side === 1 /* WEB */ ? "string" : "Date | string",
315
291
  Byte: "Uint8Array"
316
292
  };
@@ -333,12 +309,7 @@ async function getPluginConfig(side) {
333
309
  // We do this, so that service tests can call resolvers without doing a null check
334
310
  // see https://github.com/redwoodjs/redwood/pull/6222#issuecomment-1230156868
335
311
  // Look at type or source https://shrtm.nu/2BA0 for possible config, not well documented
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
312
+ resolvers: true
342
313
  },
343
314
  contextType: `@cedarjs/graphql-server/dist/types#CedarGraphQLContext`
344
315
  };
@@ -3,14 +3,7 @@ import '@cedarjs/auth'
3
3
 
4
4
  import { getCurrentUser } from '../../../api/src/lib/auth.js'
5
5
 
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
- >
6
+ export type InferredCurrentUser = Awaited<ReturnType<typeof getCurrentUser>>
14
7
 
15
8
  type UndefinedRoles = {
16
9
  /**
@@ -28,12 +21,10 @@ type Overwrite<T, U> = Omit<T, keyof U> & U
28
21
 
29
22
  declare module '@cedarjs/context' {
30
23
  interface GlobalContext {
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
24
+ currentUser?: Overwrite<UndefinedRoles, InferredCurrentUser>
34
25
  }
35
26
  }
36
27
 
37
28
  declare module '@cedarjs/auth' {
38
- interface LoggedInUser extends InferredLoggedInUser {}
29
+ interface CurrentUser extends InferredCurrentUser {}
39
30
  }
@@ -1,11 +1,11 @@
1
1
  import type { vi as _vi } from 'vitest'
2
2
 
3
- import type { InferredLoggedInUser } from './all-currentUser.js'
3
+ import type { CurrentUser } from '@cedarjs/auth'
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: InferredLoggedInUser | null) => void
10
+ const mockCurrentUser: (currentUser: CurrentUser) => void
11
11
  }
@@ -5,14 +5,14 @@ import type {
5
5
  mockGraphQLQuery as _mockGraphQLQuery,
6
6
  } from '@cedarjs/testing/web'
7
7
 
8
- import type { InferredLoggedInUser } from './all-currentUser.js'
8
+ import { InferredCurrentUser } 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: InferredLoggedInUser | null) => void
15
+ const mockCurrentUser: (currentUser: InferredCurrentUser) => void
16
16
  const mockGraphQLQuery: typeof _mockGraphQLQuery
17
17
  const mockGraphQLMutation: typeof _mockGraphQLMutation
18
18
  }
@@ -304,16 +304,8 @@ const generateViteClientTypesDirective = () => {
304
304
  };
305
305
  function generateStubStorybookTypes() {
306
306
  const stubStorybookTypesFileContent = `declare module '@storybook/react' {
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
307
+ export type Meta<T = any> = any
308
+ export type StoryObj<T = any> = any
317
309
  }
318
310
  `;
319
311
  const cedarProjectPaths = getPaths();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/internal",
3
- "version": "7.0.1-next.467",
3
+ "version": "7.1.0-rc.32",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -87,12 +87,6 @@
87
87
  "types": "./dist/generate/gqlormSchema.d.ts",
88
88
  "default": "./dist/generate/gqlormSchema.js"
89
89
  }
90
- },
91
- "./dist/generate/parsedScalars.js": {
92
- "default": {
93
- "types": "./dist/generate/parsedScalars.d.ts",
94
- "default": "./dist/generate/parsedScalars.js"
95
- }
96
90
  }
97
91
  },
98
92
  "types": "dist/index.d.ts",
@@ -119,15 +113,15 @@
119
113
  "dependencies": {
120
114
  "@babel/core": "^7.26.10",
121
115
  "@babel/parser": "7.29.9",
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",
116
+ "@babel/traverse": "7.29.8",
117
+ "@cedarjs/api": "7.1.0-rc.32",
118
+ "@cedarjs/babel-config": "7.1.0-rc.32",
119
+ "@cedarjs/cli-helpers": "7.1.0-rc.32",
120
+ "@cedarjs/graphql-server": "7.1.0-rc.32",
121
+ "@cedarjs/project-config": "7.1.0-rc.32",
122
+ "@cedarjs/router": "7.1.0-rc.32",
123
+ "@cedarjs/structure": "7.1.0-rc.32",
124
+ "@cedarjs/utils": "7.1.0-rc.32",
131
125
  "@graphql-codegen/add": "6.0.1",
132
126
  "@graphql-codegen/cli": "6.3.1",
133
127
  "@graphql-codegen/client-preset": "5.3.0",
@@ -139,12 +133,12 @@
139
133
  "@graphql-codegen/typescript-operations": "5.1.0",
140
134
  "@graphql-codegen/typescript-resolvers": "5.1.8",
141
135
  "@graphql-codegen/visitor-plugin-common": "6.3.0",
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
- "@prisma/dmmf": "7.10.0",
147
- "@prisma/internals": "7.10.0",
136
+ "@graphql-tools/code-file-loader": "8.1.39",
137
+ "@graphql-tools/graphql-file-loader": "8.1.20",
138
+ "@graphql-tools/load": "8.1.17",
139
+ "@graphql-tools/merge": "9.2.4",
140
+ "@prisma/dmmf": "7.8.0",
141
+ "@prisma/internals": "7.8.0",
148
142
  "@sdl-codegen/node": "2.0.1",
149
143
  "ansis": "4.4.0",
150
144
  "chokidar": "3.6.0",
@@ -154,24 +148,24 @@
154
148
  "graphql": "16.14.2",
155
149
  "kill-port": "1.6.1",
156
150
  "magic-string": "0.30.21",
157
- "oxc-parser": "0.153.0",
158
- "prettier": "3.9.10",
151
+ "oxc-parser": "0.151.0",
152
+ "prettier": "3.9.8",
159
153
  "rimraf": "6.1.3",
160
154
  "source-map": "0.8.0",
161
155
  "termi-link": "1.1.0",
162
156
  "tsconfig-paths": "4.2.0",
163
157
  "typescript": "5.9.3",
164
- "vite": "7.3.7",
158
+ "vite": "7.3.6",
165
159
  "vite-tsconfig-paths": "^6.1.1"
166
160
  },
167
161
  "devDependencies": {
168
- "@cedarjs/framework-tools": "7.0.1-next.467",
162
+ "@cedarjs/framework-tools": "7.1.0-rc.32",
169
163
  "@jridgewell/trace-mapping": "0.3.31",
170
- "@oxc-project/types": "^0.153.0",
171
- "concurrently": "9.2.5",
172
- "graphql-tag": "2.12.7",
173
- "memfs": "4.80.0",
174
- "publint": "0.3.25",
164
+ "@oxc-project/types": "^0.151.0",
165
+ "concurrently": "9.2.4",
166
+ "graphql-tag": "2.12.6",
167
+ "memfs": "4.78.1",
168
+ "publint": "0.3.24",
175
169
  "ts-dedent": "2.3.0",
176
170
  "vitest": "4.1.11"
177
171
  },
@@ -1,42 +0,0 @@
1
- import type { GraphQLSchema } from 'graphql';
2
- import type { ParsedScalarsConfig } from '@cedarjs/project-config';
3
- /**
4
- * What `CedarApolloProvider` needs to make Apollo Client's cache parse the
5
- * scalars in `graphql.parsedScalars`. The `typePolicies` and `inputObjects`
6
- * are passed to `InMemoryCache` as they are.
7
- */
8
- export interface ParsedScalarsCacheConfig {
9
- /**
10
- * The scalars to parse, and the type each is parsed into
11
- */
12
- scalars: ParsedScalarsConfig;
13
- /**
14
- * The fields in the schema that hold a parsed scalar
15
- */
16
- typePolicies: Record<string, {
17
- fields: Record<string, {
18
- scalar: string;
19
- }>;
20
- }>;
21
- /**
22
- * The input objects that hold a parsed scalar, directly or through another
23
- * input object
24
- */
25
- inputObjects: Record<string, {
26
- fields: Record<string, string>;
27
- }>;
28
- }
29
- /**
30
- * Finds every field in the schema that holds one of the scalars in
31
- * `parsedScalars`, in the shape Apollo Client's `InMemoryCache` takes, so that
32
- * the cache parses those fields when it reads a response and serializes them
33
- * in a query's variables.
34
- */
35
- export declare function getParsedScalarsCacheConfig(schema: GraphQLSchema, parsedScalars: ParsedScalarsConfig): ParsedScalarsCacheConfig;
36
- /**
37
- * Reads the project's `graphql.parsedScalars` setting and its generated
38
- * GraphQL schema, and returns the cache config for them. Returns `undefined`
39
- * when no scalar is set to be parsed, or when the schema hasn't been generated.
40
- */
41
- export declare function loadParsedScalarsCacheConfig(): ParsedScalarsCacheConfig | undefined;
42
- //# sourceMappingURL=parsedScalars.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsedScalars.d.ts","sourceRoot":"","sources":["../../src/generate/parsedScalars.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,SAAS,CAAA;AASzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAGlE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAA;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;IAC5E;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAA;CACjE;AA0BD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,mBAAmB,GACjC,wBAAwB,CA0E1B;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,IAC1C,wBAAwB,GAAG,SAAS,CAwBrC"}
@@ -1,96 +0,0 @@
1
- import fs from "node:fs";
2
- import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
3
- import { loadSchemaSync } from "@graphql-tools/load";
4
- import {
5
- getNamedType,
6
- isInputObjectType,
7
- isListType,
8
- isNonNullType,
9
- isObjectType
10
- } from "graphql";
11
- import { getParsedScalars, getPaths } from "@cedarjs/project-config";
12
- function scalarTypeName(type, names) {
13
- if (isNonNullType(type)) {
14
- return scalarTypeName(type.ofType, names);
15
- }
16
- if (isListType(type)) {
17
- const inner = scalarTypeName(type.ofType, names);
18
- return inner === void 0 ? void 0 : `[${inner}]`;
19
- }
20
- const name = getNamedType(type).name;
21
- return names.has(name) ? name : void 0;
22
- }
23
- function getParsedScalarsCacheConfig(schema, parsedScalars) {
24
- const scalarNames = new Set(Object.keys(parsedScalars));
25
- const typePolicies = {};
26
- const inputObjects = {};
27
- if (scalarNames.size === 0) {
28
- return { scalars: parsedScalars, typePolicies, inputObjects };
29
- }
30
- const types = Object.values(schema.getTypeMap()).filter(
31
- (type) => !type.name.startsWith("__")
32
- );
33
- for (const type of types) {
34
- if (!isObjectType(type)) {
35
- continue;
36
- }
37
- for (const field of Object.values(type.getFields())) {
38
- const scalar = scalarTypeName(field.type, scalarNames);
39
- if (scalar) {
40
- typePolicies[type.name] ??= { fields: {} };
41
- typePolicies[type.name].fields[field.name] = { scalar };
42
- }
43
- }
44
- }
45
- const inputTypes = types.filter(isInputObjectType);
46
- let inputObjectNames = /* @__PURE__ */ new Set();
47
- let grew = true;
48
- while (grew) {
49
- const names2 = /* @__PURE__ */ new Set([...scalarNames, ...inputObjectNames]);
50
- const next = new Set(inputObjectNames);
51
- for (const type of inputTypes) {
52
- const holdsScalar = Object.values(type.getFields()).some(
53
- (field) => scalarTypeName(field.type, names2) !== void 0
54
- );
55
- if (holdsScalar) {
56
- next.add(type.name);
57
- }
58
- }
59
- grew = next.size > inputObjectNames.size;
60
- inputObjectNames = next;
61
- }
62
- const names = /* @__PURE__ */ new Set([...scalarNames, ...inputObjectNames]);
63
- for (const type of inputTypes) {
64
- if (!inputObjectNames.has(type.name)) {
65
- continue;
66
- }
67
- const fields = {};
68
- for (const field of Object.values(type.getFields())) {
69
- const fieldType = scalarTypeName(field.type, names);
70
- if (fieldType) {
71
- fields[field.name] = fieldType;
72
- }
73
- }
74
- inputObjects[type.name] = { fields };
75
- }
76
- return { scalars: parsedScalars, typePolicies, inputObjects };
77
- }
78
- function loadParsedScalarsCacheConfig() {
79
- const parsedScalars = getParsedScalars();
80
- if (Object.keys(parsedScalars).length === 0) {
81
- return void 0;
82
- }
83
- const schemaPath = getPaths().generated.schema;
84
- if (!fs.existsSync(schemaPath)) {
85
- return void 0;
86
- }
87
- const schema = loadSchemaSync(schemaPath, {
88
- loaders: [new GraphQLFileLoader()],
89
- sort: true
90
- });
91
- return getParsedScalarsCacheConfig(schema, parsedScalars);
92
- }
93
- export {
94
- getParsedScalarsCacheConfig,
95
- loadParsedScalarsCacheConfig
96
- };