@stryke/prisma-better-auth-generator 0.10.3 → 0.11.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.
@@ -216,7 +216,17 @@ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
216
216
  }, "lowerCaseFirst");
217
217
 
218
218
  // src/access-control.ts
219
- async function generateAccessControl(sourceFile, modelOperations) {
219
+ var OMITTED_RESOURCES = [
220
+ "user",
221
+ "session",
222
+ "account",
223
+ "verification"
224
+ ];
225
+ var ADDITIONAL_OPERATIONS = [
226
+ "softDelete",
227
+ "softDeleteMany"
228
+ ];
229
+ async function generateAccessControl(sourceFile, config, modelOperations) {
220
230
  sourceFile.addStatements(
221
231
  /* ts */
222
232
  `import { createAccessControl } from "better-auth/plugins/access";
@@ -229,9 +239,13 @@ import {
229
239
  `
230
240
  export const statements = {
231
241
  ...defaultStatements,
232
- ${modelOperations.map((modelOperation) => {
242
+ ${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
233
243
  const { model, plural: _, ...operations } = modelOperation;
234
- return `${lowerCaseFirst(model)}: [${Object.keys(operations).sort().filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`).join(", ")}]`;
244
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`);
245
+ if (config.withSoftDelete) {
246
+ operationsList.push(...ADDITIONAL_OPERATIONS);
247
+ }
248
+ return `${lowerCaseFirst(model)}: [${Object.keys(operationsList).sort().join(", ")}]`;
235
249
  }).join(",\n")}
236
250
  }`
237
251
  );
@@ -4459,7 +4473,7 @@ var z = /* @__PURE__ */ Object.freeze({
4459
4473
  var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
4460
4474
  var configSchema = z.object({
4461
4475
  debug: configBoolean.default("false"),
4462
- withTRPC: configBoolean.default("true")
4476
+ withSoftDelete: configBoolean.default("false")
4463
4477
  });
4464
4478
 
4465
4479
  // src/project.ts
@@ -5146,7 +5160,7 @@ ${JSON.stringify(config)}`);
5146
5160
  const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
5147
5161
  overwrite: true
5148
5162
  });
5149
- await generateAccessControl(accessControl, modelOperations);
5163
+ await generateAccessControl(accessControl, config, modelOperations);
5150
5164
  consoleLog("Saving Better-Auth router source files to disk");
5151
5165
  await project.save();
5152
5166
  consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
package/dist/generator.js CHANGED
@@ -195,7 +195,17 @@ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
195
195
  }, "lowerCaseFirst");
196
196
 
197
197
  // src/access-control.ts
198
- async function generateAccessControl(sourceFile, modelOperations) {
198
+ var OMITTED_RESOURCES = [
199
+ "user",
200
+ "session",
201
+ "account",
202
+ "verification"
203
+ ];
204
+ var ADDITIONAL_OPERATIONS = [
205
+ "softDelete",
206
+ "softDeleteMany"
207
+ ];
208
+ async function generateAccessControl(sourceFile, config, modelOperations) {
199
209
  sourceFile.addStatements(
200
210
  /* ts */
201
211
  `import { createAccessControl } from "better-auth/plugins/access";
@@ -208,9 +218,13 @@ import {
208
218
  `
209
219
  export const statements = {
210
220
  ...defaultStatements,
211
- ${modelOperations.map((modelOperation) => {
221
+ ${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
212
222
  const { model, plural: _, ...operations } = modelOperation;
213
- return `${lowerCaseFirst(model)}: [${Object.keys(operations).sort().filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`).join(", ")}]`;
223
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`);
224
+ if (config.withSoftDelete) {
225
+ operationsList.push(...ADDITIONAL_OPERATIONS);
226
+ }
227
+ return `${lowerCaseFirst(model)}: [${Object.keys(operationsList).sort().join(", ")}]`;
214
228
  }).join(",\n")}
215
229
  }`
216
230
  );
@@ -4438,7 +4452,7 @@ var z = /* @__PURE__ */ Object.freeze({
4438
4452
  var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
4439
4453
  var configSchema = z.object({
4440
4454
  debug: configBoolean.default("false"),
4441
- withTRPC: configBoolean.default("true")
4455
+ withSoftDelete: configBoolean.default("false")
4442
4456
  });
4443
4457
 
4444
4458
  // src/project.ts
@@ -5125,7 +5139,7 @@ ${JSON.stringify(config)}`);
5125
5139
  const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
5126
5140
  overwrite: true
5127
5141
  });
5128
- await generateAccessControl(accessControl, modelOperations);
5142
+ await generateAccessControl(accessControl, config, modelOperations);
5129
5143
  consoleLog("Saving Better-Auth router source files to disk");
5130
5144
  await project.save();
5131
5145
  consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
package/dist/index.cjs CHANGED
@@ -212,7 +212,17 @@ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
212
212
  }, "lowerCaseFirst");
213
213
 
214
214
  // src/access-control.ts
215
- async function generateAccessControl(sourceFile, modelOperations) {
215
+ var OMITTED_RESOURCES = [
216
+ "user",
217
+ "session",
218
+ "account",
219
+ "verification"
220
+ ];
221
+ var ADDITIONAL_OPERATIONS = [
222
+ "softDelete",
223
+ "softDeleteMany"
224
+ ];
225
+ async function generateAccessControl(sourceFile, config, modelOperations) {
216
226
  sourceFile.addStatements(
217
227
  /* ts */
218
228
  `import { createAccessControl } from "better-auth/plugins/access";
@@ -225,9 +235,13 @@ import {
225
235
  `
226
236
  export const statements = {
227
237
  ...defaultStatements,
228
- ${modelOperations.map((modelOperation) => {
238
+ ${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
229
239
  const { model, plural: _, ...operations } = modelOperation;
230
- return `${lowerCaseFirst(model)}: [${Object.keys(operations).sort().filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`).join(", ")}]`;
240
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`);
241
+ if (config.withSoftDelete) {
242
+ operationsList.push(...ADDITIONAL_OPERATIONS);
243
+ }
244
+ return `${lowerCaseFirst(model)}: [${Object.keys(operationsList).sort().join(", ")}]`;
231
245
  }).join(",\n")}
232
246
  }`
233
247
  );
@@ -4455,7 +4469,7 @@ var z = /* @__PURE__ */ Object.freeze({
4455
4469
  var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
4456
4470
  var configSchema = z.object({
4457
4471
  debug: configBoolean.default("false"),
4458
- withTRPC: configBoolean.default("true")
4472
+ withSoftDelete: configBoolean.default("false")
4459
4473
  });
4460
4474
 
4461
4475
  // src/project.ts
@@ -5142,7 +5156,7 @@ ${JSON.stringify(config)}`);
5142
5156
  const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
5143
5157
  overwrite: true
5144
5158
  });
5145
- await generateAccessControl(accessControl, modelOperations);
5159
+ await generateAccessControl(accessControl, config, modelOperations);
5146
5160
  consoleLog("Saving Better-Auth router source files to disk");
5147
5161
  await project.save();
5148
5162
  consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
package/dist/index.js CHANGED
@@ -191,7 +191,17 @@ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
191
191
  }, "lowerCaseFirst");
192
192
 
193
193
  // src/access-control.ts
194
- async function generateAccessControl(sourceFile, modelOperations) {
194
+ var OMITTED_RESOURCES = [
195
+ "user",
196
+ "session",
197
+ "account",
198
+ "verification"
199
+ ];
200
+ var ADDITIONAL_OPERATIONS = [
201
+ "softDelete",
202
+ "softDeleteMany"
203
+ ];
204
+ async function generateAccessControl(sourceFile, config, modelOperations) {
195
205
  sourceFile.addStatements(
196
206
  /* ts */
197
207
  `import { createAccessControl } from "better-auth/plugins/access";
@@ -204,9 +214,13 @@ import {
204
214
  `
205
215
  export const statements = {
206
216
  ...defaultStatements,
207
- ${modelOperations.map((modelOperation) => {
217
+ ${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
208
218
  const { model, plural: _, ...operations } = modelOperation;
209
- return `${lowerCaseFirst(model)}: [${Object.keys(operations).sort().filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`).join(", ")}]`;
219
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow")).map((operation) => `"${operation.replace("One", "")}"`);
220
+ if (config.withSoftDelete) {
221
+ operationsList.push(...ADDITIONAL_OPERATIONS);
222
+ }
223
+ return `${lowerCaseFirst(model)}: [${Object.keys(operationsList).sort().join(", ")}]`;
210
224
  }).join(",\n")}
211
225
  }`
212
226
  );
@@ -4434,7 +4448,7 @@ var z = /* @__PURE__ */ Object.freeze({
4434
4448
  var configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
4435
4449
  var configSchema = z.object({
4436
4450
  debug: configBoolean.default("false"),
4437
- withTRPC: configBoolean.default("true")
4451
+ withSoftDelete: configBoolean.default("false")
4438
4452
  });
4439
4453
 
4440
4454
  // src/project.ts
@@ -5121,7 +5135,7 @@ ${JSON.stringify(config)}`);
5121
5135
  const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
5122
5136
  overwrite: true
5123
5137
  });
5124
- await generateAccessControl(accessControl, modelOperations);
5138
+ await generateAccessControl(accessControl, config, modelOperations);
5125
5139
  consoleLog("Saving Better-Auth router source files to disk");
5126
5140
  await project.save();
5127
5141
  consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-better-auth-generator",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "description": "A package containing a Prisma v6 generator for Better-Auth authentication.",
6
6
  "repository": {