@stryke/prisma-better-auth-generator 0.10.4 → 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.
- package/dist/generator.cjs +12 -4
- package/dist/generator.js +12 -4
- package/dist/index.cjs +12 -4
- package/dist/index.js +12 -4
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -222,7 +222,11 @@ var OMITTED_RESOURCES = [
|
|
|
222
222
|
"account",
|
|
223
223
|
"verification"
|
|
224
224
|
];
|
|
225
|
-
|
|
225
|
+
var ADDITIONAL_OPERATIONS = [
|
|
226
|
+
"softDelete",
|
|
227
|
+
"softDeleteMany"
|
|
228
|
+
];
|
|
229
|
+
async function generateAccessControl(sourceFile, config, modelOperations) {
|
|
226
230
|
sourceFile.addStatements(
|
|
227
231
|
/* ts */
|
|
228
232
|
`import { createAccessControl } from "better-auth/plugins/access";
|
|
@@ -237,7 +241,11 @@ export const statements = {
|
|
|
237
241
|
...defaultStatements,
|
|
238
242
|
${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
|
|
239
243
|
const { model, plural: _, ...operations } = modelOperation;
|
|
240
|
-
|
|
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(", ")}]`;
|
|
241
249
|
}).join(",\n")}
|
|
242
250
|
}`
|
|
243
251
|
);
|
|
@@ -4465,7 +4473,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4465
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);
|
|
4466
4474
|
var configSchema = z.object({
|
|
4467
4475
|
debug: configBoolean.default("false"),
|
|
4468
|
-
|
|
4476
|
+
withSoftDelete: configBoolean.default("false")
|
|
4469
4477
|
});
|
|
4470
4478
|
|
|
4471
4479
|
// src/project.ts
|
|
@@ -5152,7 +5160,7 @@ ${JSON.stringify(config)}`);
|
|
|
5152
5160
|
const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
|
|
5153
5161
|
overwrite: true
|
|
5154
5162
|
});
|
|
5155
|
-
await generateAccessControl(accessControl, modelOperations);
|
|
5163
|
+
await generateAccessControl(accessControl, config, modelOperations);
|
|
5156
5164
|
consoleLog("Saving Better-Auth router source files to disk");
|
|
5157
5165
|
await project.save();
|
|
5158
5166
|
consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
|
package/dist/generator.js
CHANGED
|
@@ -201,7 +201,11 @@ var OMITTED_RESOURCES = [
|
|
|
201
201
|
"account",
|
|
202
202
|
"verification"
|
|
203
203
|
];
|
|
204
|
-
|
|
204
|
+
var ADDITIONAL_OPERATIONS = [
|
|
205
|
+
"softDelete",
|
|
206
|
+
"softDeleteMany"
|
|
207
|
+
];
|
|
208
|
+
async function generateAccessControl(sourceFile, config, modelOperations) {
|
|
205
209
|
sourceFile.addStatements(
|
|
206
210
|
/* ts */
|
|
207
211
|
`import { createAccessControl } from "better-auth/plugins/access";
|
|
@@ -216,7 +220,11 @@ export const statements = {
|
|
|
216
220
|
...defaultStatements,
|
|
217
221
|
${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
|
|
218
222
|
const { model, plural: _, ...operations } = modelOperation;
|
|
219
|
-
|
|
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(", ")}]`;
|
|
220
228
|
}).join(",\n")}
|
|
221
229
|
}`
|
|
222
230
|
);
|
|
@@ -4444,7 +4452,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4444
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);
|
|
4445
4453
|
var configSchema = z.object({
|
|
4446
4454
|
debug: configBoolean.default("false"),
|
|
4447
|
-
|
|
4455
|
+
withSoftDelete: configBoolean.default("false")
|
|
4448
4456
|
});
|
|
4449
4457
|
|
|
4450
4458
|
// src/project.ts
|
|
@@ -5131,7 +5139,7 @@ ${JSON.stringify(config)}`);
|
|
|
5131
5139
|
const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
|
|
5132
5140
|
overwrite: true
|
|
5133
5141
|
});
|
|
5134
|
-
await generateAccessControl(accessControl, modelOperations);
|
|
5142
|
+
await generateAccessControl(accessControl, config, modelOperations);
|
|
5135
5143
|
consoleLog("Saving Better-Auth router source files to disk");
|
|
5136
5144
|
await project.save();
|
|
5137
5145
|
consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
|
package/dist/index.cjs
CHANGED
|
@@ -218,7 +218,11 @@ var OMITTED_RESOURCES = [
|
|
|
218
218
|
"account",
|
|
219
219
|
"verification"
|
|
220
220
|
];
|
|
221
|
-
|
|
221
|
+
var ADDITIONAL_OPERATIONS = [
|
|
222
|
+
"softDelete",
|
|
223
|
+
"softDeleteMany"
|
|
224
|
+
];
|
|
225
|
+
async function generateAccessControl(sourceFile, config, modelOperations) {
|
|
222
226
|
sourceFile.addStatements(
|
|
223
227
|
/* ts */
|
|
224
228
|
`import { createAccessControl } from "better-auth/plugins/access";
|
|
@@ -233,7 +237,11 @@ export const statements = {
|
|
|
233
237
|
...defaultStatements,
|
|
234
238
|
${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
|
|
235
239
|
const { model, plural: _, ...operations } = modelOperation;
|
|
236
|
-
|
|
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(", ")}]`;
|
|
237
245
|
}).join(",\n")}
|
|
238
246
|
}`
|
|
239
247
|
);
|
|
@@ -4461,7 +4469,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4461
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);
|
|
4462
4470
|
var configSchema = z.object({
|
|
4463
4471
|
debug: configBoolean.default("false"),
|
|
4464
|
-
|
|
4472
|
+
withSoftDelete: configBoolean.default("false")
|
|
4465
4473
|
});
|
|
4466
4474
|
|
|
4467
4475
|
// src/project.ts
|
|
@@ -5148,7 +5156,7 @@ ${JSON.stringify(config)}`);
|
|
|
5148
5156
|
const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
|
|
5149
5157
|
overwrite: true
|
|
5150
5158
|
});
|
|
5151
|
-
await generateAccessControl(accessControl, modelOperations);
|
|
5159
|
+
await generateAccessControl(accessControl, config, modelOperations);
|
|
5152
5160
|
consoleLog("Saving Better-Auth router source files to disk");
|
|
5153
5161
|
await project.save();
|
|
5154
5162
|
consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
|
package/dist/index.js
CHANGED
|
@@ -197,7 +197,11 @@ var OMITTED_RESOURCES = [
|
|
|
197
197
|
"account",
|
|
198
198
|
"verification"
|
|
199
199
|
];
|
|
200
|
-
|
|
200
|
+
var ADDITIONAL_OPERATIONS = [
|
|
201
|
+
"softDelete",
|
|
202
|
+
"softDeleteMany"
|
|
203
|
+
];
|
|
204
|
+
async function generateAccessControl(sourceFile, config, modelOperations) {
|
|
201
205
|
sourceFile.addStatements(
|
|
202
206
|
/* ts */
|
|
203
207
|
`import { createAccessControl } from "better-auth/plugins/access";
|
|
@@ -212,7 +216,11 @@ export const statements = {
|
|
|
212
216
|
...defaultStatements,
|
|
213
217
|
${modelOperations.filter((modelOperation) => !OMITTED_RESOURCES.includes(lowerCaseFirst(modelOperation.model))).map((modelOperation) => {
|
|
214
218
|
const { model, plural: _, ...operations } = modelOperation;
|
|
215
|
-
|
|
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(", ")}]`;
|
|
216
224
|
}).join(",\n")}
|
|
217
225
|
}`
|
|
218
226
|
);
|
|
@@ -4440,7 +4448,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4440
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);
|
|
4441
4449
|
var configSchema = z.object({
|
|
4442
4450
|
debug: configBoolean.default("false"),
|
|
4443
|
-
|
|
4451
|
+
withSoftDelete: configBoolean.default("false")
|
|
4444
4452
|
});
|
|
4445
4453
|
|
|
4446
4454
|
// src/project.ts
|
|
@@ -5127,7 +5135,7 @@ ${JSON.stringify(config)}`);
|
|
|
5127
5135
|
const accessControl = project.createSourceFile(joinPaths(outputDir, "./access-control.ts"), void 0, {
|
|
5128
5136
|
overwrite: true
|
|
5129
5137
|
});
|
|
5130
|
-
await generateAccessControl(accessControl, modelOperations);
|
|
5138
|
+
await generateAccessControl(accessControl, config, modelOperations);
|
|
5131
5139
|
consoleLog("Saving Better-Auth router source files to disk");
|
|
5132
5140
|
await project.save();
|
|
5133
5141
|
consoleLog("Storm Software - Prisma Better-Auth generator completed successfully");
|