@baeta/plugin-prisma 2.0.0-next.13 → 2.0.0-next.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @baeta/plugin-prisma
2
2
 
3
+ ## 2.0.0-next.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Drop Node v23 and v25 by [@andreisergiu98](https://github.com/andreisergiu98) in [#474](https://github.com/andreisergiu98/baeta/pull/474)
8
+ - Updated dependencies [[`dc89e17`](https://github.com/andreisergiu98/baeta/commit/dc89e1728926f4bd5a5e1351635c38bf8d5938dc), [`1249b32`](https://github.com/andreisergiu98/baeta/commit/1249b32c42270151d6d6de46d54c82c1f975719b), [`3571c17`](https://github.com/andreisergiu98/baeta/commit/3571c1785a4eb1361c47b80725c990cefa27a791), [`d179c12`](https://github.com/andreisergiu98/baeta/commit/d179c12488f6ac11add26f8337e088f791d820b7), [`03c2bc9`](https://github.com/andreisergiu98/baeta/commit/03c2bc9913b6ffdc15f627f9d177347e0805defd)]:
9
+ - @baeta/generator-sdk@2.0.0-next.6
10
+ - @baeta/plugin-exec@2.0.0-next.15
11
+ - @baeta/util-path@2.0.0-next.5
12
+
13
+ ## 2.0.0-next.14
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies:
18
+ - @baeta/plugin-exec@2.0.0-next.14
19
+
3
20
  ## 2.0.0-next.13
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -35,10 +35,11 @@ Building GraphQL APIs shouldn't be complicated. **Baeta** is a modern, modular,
35
35
  - **Middleware & Directives**: Easy integration of custom behaviors
36
36
  - **High Performance**: Built for scalability and efficiency
37
37
 
38
- #### And optional extensions and plugins
38
+ #### And optional app plugins and libraries
39
39
 
40
- - **@baeta/extension-auth**: Add powerful scope-based authorization
41
- - **@baeta/extension-cache**: Implement automatic caching with simple update patterns
40
+ - **@baeta/auth**: Add powerful scope-based authorization
41
+ - **@baeta/complexity**: Reject resource-exhausting queries with depth, breadth and complexity limits
42
+ - **@baeta/cache**: Type-safe caching with declarative queries and automatic reconciliation
42
43
  - ... and more!
43
44
 
44
45
  ## Why use Baeta?
@@ -89,7 +90,7 @@ const usersQuery = Query.users.resolve(() => {
89
90
  return dataSource.user.findMany();
90
91
  });
91
92
 
92
- Query.$fields({
93
+ export default Query.$fields({
93
94
  user: userQuery,
94
95
  users: usersQuery,
95
96
  });
@@ -98,17 +99,13 @@ Query.$fields({
98
99
  #### 3. Add authorization
99
100
 
100
101
  ```typescript
102
+ import { auth, rule, scope } from "./lib/auth.ts";
101
103
  import { UserModule } from "./typedef.ts";
102
104
 
103
105
  const { Query } = UserModule;
104
106
 
105
107
  const userQuery = Query.user
106
- .$auth({
107
- $or: {
108
- isPublic: true,
109
- isLoggedIn: true,
110
- },
111
- })
108
+ .$use(auth(rule.or(scope.isPublic, scope.isLoggedIn)))
112
109
  .resolve(async ({ args }) => {
113
110
  // ...
114
111
  });
@@ -117,23 +114,33 @@ const userQuery = Query.user
117
114
  #### 4. Add caching
118
115
 
119
116
  ```typescript
120
- const { Query, Mutation, User } = UserModule;
121
-
122
- export const userCache = User.$createCache();
123
-
124
- const userQuery = Query.user
125
- .$auth({
126
- // ...
117
+ import { createCache, defineQuery } from "@baeta/cache";
118
+ import { redisClient } from "./lib/redis.ts";
119
+
120
+ const { Query, Mutation } = UserModule;
121
+
122
+ export const userCache = createCache(redisClient, {
123
+ name: "UserCache",
124
+ parse: JSON.parse,
125
+ serialize: JSON.stringify,
126
+ })
127
+ .withQueries({
128
+ findUser: defineQuery({
129
+ resolve: async (args: { id: string }) => {
130
+ return dataSource.user.findUnique({ where: args });
131
+ },
132
+ }),
127
133
  })
128
- .$useCache(userCache)
129
- .resolve(async ({ args }) => {
130
- // ...
131
- });
134
+ .build();
135
+
136
+ const userQuery = Query.user.map(({ args }) =>
137
+ userCache.queries.findUser({ id: args.where.id }),
138
+ );
132
139
 
133
140
  const updateUserMutation = Mutation.updateUser
134
141
  .$use(async (next) => {
135
142
  const user = await next();
136
- await userCache.save(user);
143
+ if (user) await userCache.update(user);
137
144
  return user;
138
145
  })
139
146
  .resolve(async ({ args }) => {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import * as _$_baeta_generator_sdk0 from "@baeta/generator-sdk";
2
-
3
1
  //#region lib/options.d.ts
4
2
  /**
5
3
  * Configuration options for the Prisma plugin
@@ -36,7 +34,7 @@ interface PrismaPluginOptions {
36
34
  * @param options - Configuration options for the pagination plugin
37
35
  * @returns A Baeta generator plugin
38
36
  */
39
- declare function prismaPlugin(options: PrismaPluginOptions): _$_baeta_generator_sdk0.GeneratorPluginV1<unknown>[];
37
+ declare function prismaPlugin(options: PrismaPluginOptions): import("@baeta/generator-sdk").GeneratorPluginV1<unknown>[];
40
38
  //#endregion
41
39
  export { type PrismaPluginOptions, prismaPlugin as default, prismaPlugin };
42
40
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ function createPrismaClientPlugin(options) {
23
23
  skip: async (ctx) => {
24
24
  const schema = resolve(ctx.generatorOptions.cwd, prismaSchema);
25
25
  if (ctx.watching && ctx.changedFile?.path !== schema) return true;
26
- if (!ctx.watching && generatedSchemaPath) return compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);
26
+ if (!ctx.watching && generatedSchemaPath) return await compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);
27
27
  return false;
28
28
  }
29
29
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../lib/client-generator.ts","../index.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { resolve } from '@baeta/util-path';\nimport type { PrismaPluginOptions } from './options.ts';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n\tconst [currentSchema, generatedSchema] = await Promise.all([\n\t\treadFile(resolve(cwd, current), 'utf-8'),\n\t\treadFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n\t]);\n\treturn currentSchema.replaceAll(' ', '') === generatedSchema?.replaceAll(' ', '');\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n\tconst { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n\treturn createExecPlugin({\n\t\tname: 'prisma-client',\n\t\tactionName: 'Prisma client',\n\t\texec: generateCommand ?? 'prisma generate',\n\t\twatch: (generatorOptions, watcher, reload) => {\n\t\t\tconst prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (file.path === prismaPath) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tskip: async (ctx: Ctx) => {\n\t\t\tconst schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n\t\t\tif (ctx.watching && ctx.changedFile?.path !== schema) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!ctx.watching && generatedSchemaPath) {\n\t\t\t\treturn compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t});\n}\n","import { createPrismaClientPlugin } from './lib/client-generator.ts';\nimport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport default prismaPlugin;\n\n/**\n * A plugin that manages Prisma client generation in your Baeta project.\n * See https://baeta.io/docs/plugins/prisma\n *\n * @param options - Configuration options for the pagination plugin\n * @returns A Baeta generator plugin\n */\nexport function prismaPlugin(options: PrismaPluginOptions) {\n\tif (options.generateClient === false) {\n\t\treturn [];\n\t}\n\treturn [createPrismaClientPlugin(options)];\n}\n"],"mappings":";;;;AAMA,eAAe,eAAe,KAAa,SAAiB,WAAmB;CAC9E,MAAM,CAAC,eAAe,mBAAmB,MAAM,QAAQ,IAAI,CAC1D,SAAS,QAAQ,KAAK,QAAQ,EAAE,QAAQ,EACxC,SAAS,QAAQ,KAAK,UAAU,EAAE,QAAQ,CAAC,YAAY,KAAK,CAC5D,CAAC;AACF,QAAO,cAAc,WAAW,KAAK,GAAG,KAAK,iBAAiB,WAAW,KAAK,GAAG;;AAGlF,SAAgB,yBAAyB,SAA8B;CACtE,MAAM,EAAE,cAAc,iBAAiB,wBAAwB;AAE/D,QAAO,iBAAiB;EACvB,MAAM;EACN,YAAY;EACZ,MAAM,mBAAmB;EACzB,QAAQ,kBAAkB,SAAS,WAAW;GAC7C,MAAM,aAAa,QAAQ,iBAAiB,KAAK,aAAa;GAE9D,MAAM,gBAAgB,SAAsB;AAC3C,QAAI,KAAK,SAAS,WACjB,QAAO,KAAK;;AAId,WAAQ,GAAG,UAAU,aAAa;AAClC,WAAQ,GAAG,UAAU,aAAa;;EAEnC,MAAM,OAAO,QAAa;GACzB,MAAM,SAAS,QAAQ,IAAI,iBAAiB,KAAK,aAAa;AAE9D,OAAI,IAAI,YAAY,IAAI,aAAa,SAAS,OAC7C,QAAO;AAGR,OAAI,CAAC,IAAI,YAAY,oBACpB,QAAO,eAAe,IAAI,iBAAiB,KAAK,cAAc,oBAAoB;AAGnF,UAAO;;EAER,CAAC;;;;ACzCH,IAAA,wBAAe;;;;;;;;AASf,SAAgB,aAAa,SAA8B;AAC1D,KAAI,QAAQ,mBAAmB,MAC9B,QAAO,EAAE;AAEV,QAAO,CAAC,yBAAyB,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../lib/client-generator.ts","../index.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { resolve } from '@baeta/util-path';\nimport type { PrismaPluginOptions } from './options.ts';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n\tconst [currentSchema, generatedSchema] = await Promise.all([\n\t\treadFile(resolve(cwd, current), 'utf-8'),\n\t\treadFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n\t]);\n\treturn currentSchema.replaceAll(' ', '') === generatedSchema?.replaceAll(' ', '');\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n\tconst { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n\treturn createExecPlugin({\n\t\tname: 'prisma-client',\n\t\tactionName: 'Prisma client',\n\t\texec: generateCommand ?? 'prisma generate',\n\t\twatch: (generatorOptions, watcher, reload) => {\n\t\t\tconst prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (file.path === prismaPath) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tskip: async (ctx: Ctx) => {\n\t\t\tconst schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n\t\t\tif (ctx.watching && ctx.changedFile?.path !== schema) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!ctx.watching && generatedSchemaPath) {\n\t\t\t\treturn await compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t});\n}\n","import { createPrismaClientPlugin } from './lib/client-generator.ts';\nimport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport default prismaPlugin;\n\n/**\n * A plugin that manages Prisma client generation in your Baeta project.\n * See https://baeta.io/docs/plugins/prisma\n *\n * @param options - Configuration options for the pagination plugin\n * @returns A Baeta generator plugin\n */\nexport function prismaPlugin(options: PrismaPluginOptions) {\n\tif (options.generateClient === false) {\n\t\treturn [];\n\t}\n\treturn [createPrismaClientPlugin(options)];\n}\n"],"mappings":";;;;AAMA,eAAe,eAAe,KAAa,SAAiB,WAAmB;CAC9E,MAAM,CAAC,eAAe,mBAAmB,MAAM,QAAQ,IAAI,CAC1D,SAAS,QAAQ,KAAK,OAAO,GAAG,OAAO,GACvC,SAAS,QAAQ,KAAK,SAAS,GAAG,OAAO,EAAE,YAAY,IAAI,CAC5D,CAAC;CACD,OAAO,cAAc,WAAW,KAAK,EAAE,MAAM,iBAAiB,WAAW,KAAK,EAAE;AACjF;AAEA,SAAgB,yBAAyB,SAA8B;CACtE,MAAM,EAAE,cAAc,iBAAiB,wBAAwB;CAE/D,OAAO,iBAAiB;EACvB,MAAM;EACN,YAAY;EACZ,MAAM,mBAAmB;EACzB,QAAQ,kBAAkB,SAAS,WAAW;GAC7C,MAAM,aAAa,QAAQ,iBAAiB,KAAK,YAAY;GAE7D,MAAM,gBAAgB,SAAsB;IAC3C,IAAI,KAAK,SAAS,YACjB,OAAO,IAAI;GAEb;GAEA,QAAQ,GAAG,UAAU,YAAY;GACjC,QAAQ,GAAG,UAAU,YAAY;EAClC;EACA,MAAM,OAAO,QAAa;GACzB,MAAM,SAAS,QAAQ,IAAI,iBAAiB,KAAK,YAAY;GAE7D,IAAI,IAAI,YAAY,IAAI,aAAa,SAAS,QAC7C,OAAO;GAGR,IAAI,CAAC,IAAI,YAAY,qBACpB,OAAO,MAAM,eAAe,IAAI,iBAAiB,KAAK,cAAc,mBAAmB;GAGxF,OAAO;EACR;CACD,CAAC;AACF;;;AC1CA,IAAA,wBAAe;;;;;;;;AASf,SAAgB,aAAa,SAA8B;CAC1D,IAAI,QAAQ,mBAAmB,OAC9B,OAAO,CAAC;CAET,OAAO,CAAC,yBAAyB,OAAO,CAAC;AAC1C"}
package/package.json CHANGED
@@ -1,58 +1,63 @@
1
1
  {
2
2
  "name": "@baeta/plugin-prisma",
3
- "version": "2.0.0-next.13",
3
+ "version": "2.0.0-next.15",
4
+ "description": "Prisma integration plugin for Baeta.",
4
5
  "keywords": [
5
6
  "baeta",
7
+ "builder",
8
+ "framework",
6
9
  "graphql",
7
10
  "schema",
8
11
  "types",
9
- "typescript",
10
- "framework",
11
- "builder"
12
+ "typescript"
12
13
  ],
13
14
  "homepage": "https://github.com/andreisergiu98/baeta#readme",
14
15
  "bugs": {
15
16
  "url": "https://github.com/andreisergiu98/baeta/issues"
16
17
  },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/andreisergiu98/baeta.git",
20
- "directory": "packages/plugin-prisma"
21
- },
22
18
  "license": "MIT",
23
19
  "author": {
24
20
  "name": "Andrei Pampu",
25
21
  "url": "https://github.com/andreisergiu98"
26
22
  },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/andreisergiu98/baeta.git",
26
+ "directory": "packages/plugin-prisma"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
27
31
  "type": "module",
32
+ "sideEffects": false,
33
+ "types": "dist/index.d.ts",
28
34
  "exports": {
29
35
  ".": {
30
36
  "types": "./dist/index.d.ts",
31
37
  "default": "./dist/index.js"
32
38
  }
33
39
  },
34
- "types": "dist/index.d.ts",
35
- "files": [
36
- "dist",
37
- "package.json"
38
- ],
40
+ "publishConfig": {
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ }
46
+ },
47
+ "access": "public"
48
+ },
39
49
  "scripts": {
40
50
  "build": "builder build",
41
51
  "check:deps": "builder check-deps",
42
- "prepack": "builder prepare",
43
52
  "postpack": "builder prepare --restore",
53
+ "prepack": "builder prepare",
44
54
  "test": "builder test",
45
55
  "types": "tsc --noEmit"
46
56
  },
47
- "ava": {
48
- "extensions": [
49
- "ts"
50
- ]
51
- },
52
57
  "dependencies": {
53
- "@baeta/generator-sdk": "^2.0.0-next.5",
54
- "@baeta/plugin-exec": "^2.0.0-next.13",
55
- "@baeta/util-path": "^2.0.0-next.4"
58
+ "@baeta/generator-sdk": "^2.0.0-next.6",
59
+ "@baeta/plugin-exec": "^2.0.0-next.15",
60
+ "@baeta/util-path": "^2.0.0-next.5"
56
61
  },
57
62
  "devDependencies": {
58
63
  "@baeta/builder": "^0.0.0",
@@ -61,17 +66,13 @@
61
66
  "@types/node": "^22.19.17",
62
67
  "typescript": "^6.0.0"
63
68
  },
64
- "engines": {
65
- "node": ">=22.20.0"
69
+ "ava": {
70
+ "extensions": [
71
+ "ts"
72
+ ]
66
73
  },
67
- "publishConfig": {
68
- "access": "public",
69
- "exports": {
70
- ".": {
71
- "types": "./dist/index.d.ts",
72
- "default": "./dist/index.js"
73
- }
74
- }
74
+ "engines": {
75
+ "node": "^22.20.0 || ^24.0.0 || >=26.0.0"
75
76
  },
76
77
  "typedocOptions": {
77
78
  "entryPoints": [