@stryke/prisma-trpc-generator 0.10.2 → 0.10.4
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 +17 -16
- package/dist/generator.js +17 -16
- package/dist/index.cjs +17 -16
- package/dist/index.js +17 -16
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -6883,7 +6883,7 @@ var configSchema = z.object({
|
|
|
6883
6883
|
withShield: configBoolean.default("false"),
|
|
6884
6884
|
contextPath: z.string().trim().default("../context"),
|
|
6885
6885
|
trpcOptions: configBoolean.default("true"),
|
|
6886
|
-
showModelNameInProcedure: configBoolean.default("
|
|
6886
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
6887
6887
|
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
6888
6888
|
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
6889
6889
|
})
|
|
@@ -7640,24 +7640,25 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7640
7640
|
sourceFile.addStatements(
|
|
7641
7641
|
/* ts */
|
|
7642
7642
|
`import { createContext } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';
|
|
7643
|
-
|
|
7644
|
-
|
|
7643
|
+
import { initTRPC } from '@trpc/server';
|
|
7644
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7645
|
+
import { cookies } from "next/headers";`
|
|
7645
7646
|
);
|
|
7646
7647
|
}
|
|
7647
7648
|
sourceFile.addStatements(
|
|
7648
7649
|
/* ts */
|
|
7649
7650
|
`
|
|
7650
|
-
|
|
7651
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7651
7652
|
);
|
|
7652
7653
|
const middlewares = [];
|
|
7653
7654
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
7654
7655
|
sourceFile.addStatements(
|
|
7655
7656
|
/* ts */
|
|
7656
7657
|
`
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7658
|
+
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
7659
|
+
console.log('inside middleware!')
|
|
7660
|
+
return next()
|
|
7661
|
+
});`
|
|
7661
7662
|
);
|
|
7662
7663
|
middlewares.push({
|
|
7663
7664
|
type: "global",
|
|
@@ -7671,13 +7672,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7671
7672
|
sourceFile.addStatements(
|
|
7672
7673
|
/* ts */
|
|
7673
7674
|
`
|
|
7674
|
-
|
|
7675
|
+
import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
|
|
7675
7676
|
`
|
|
7676
7677
|
);
|
|
7677
7678
|
sourceFile.addStatements(
|
|
7678
7679
|
/* ts */
|
|
7679
7680
|
`
|
|
7680
|
-
|
|
7681
|
+
export const globalMiddleware = t.middleware(middleware);`
|
|
7681
7682
|
);
|
|
7682
7683
|
middlewares.push({
|
|
7683
7684
|
type: "global",
|
|
@@ -7691,7 +7692,7 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7691
7692
|
sourceFile.addStatements(
|
|
7692
7693
|
/* ts */
|
|
7693
7694
|
`
|
|
7694
|
-
|
|
7695
|
+
export const permissionsMiddleware = t.middleware(permissions);
|
|
7695
7696
|
`
|
|
7696
7697
|
);
|
|
7697
7698
|
middlewares.push({
|
|
@@ -7715,7 +7716,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7715
7716
|
sourceFile.addStatements(
|
|
7716
7717
|
/* ts */
|
|
7717
7718
|
`
|
|
7718
|
-
|
|
7719
|
+
export const publicProcedure = t.procedure; `
|
|
7719
7720
|
);
|
|
7720
7721
|
if (middlewares.length > 0) {
|
|
7721
7722
|
const procName = getProcedureName(config);
|
|
@@ -7724,7 +7725,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7724
7725
|
sourceFile.addStatements(
|
|
7725
7726
|
/* ts */
|
|
7726
7727
|
`
|
|
7727
|
-
|
|
7728
|
+
export const ${procName} = t.procedure`
|
|
7728
7729
|
);
|
|
7729
7730
|
}
|
|
7730
7731
|
sourceFile.addStatements(
|
|
@@ -7737,9 +7738,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7737
7738
|
sourceFile.addStatements(
|
|
7738
7739
|
/* ts */
|
|
7739
7740
|
`
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7741
|
+
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
7742
|
+
createTRPCServerActionHandler(cookies, t, createContext);
|
|
7743
|
+
`
|
|
7743
7744
|
);
|
|
7744
7745
|
}
|
|
7745
7746
|
sourceFile.formatText({
|
package/dist/generator.js
CHANGED
|
@@ -6888,7 +6888,7 @@ var configSchema = z.object({
|
|
|
6888
6888
|
withShield: configBoolean.default("false"),
|
|
6889
6889
|
contextPath: z.string().trim().default("../context"),
|
|
6890
6890
|
trpcOptions: configBoolean.default("true"),
|
|
6891
|
-
showModelNameInProcedure: configBoolean.default("
|
|
6891
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
6892
6892
|
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
6893
6893
|
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
6894
6894
|
})
|
|
@@ -7645,24 +7645,25 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7645
7645
|
sourceFile.addStatements(
|
|
7646
7646
|
/* ts */
|
|
7647
7647
|
`import { createContext } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';
|
|
7648
|
-
|
|
7649
|
-
|
|
7648
|
+
import { initTRPC } from '@trpc/server';
|
|
7649
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7650
|
+
import { cookies } from "next/headers";`
|
|
7650
7651
|
);
|
|
7651
7652
|
}
|
|
7652
7653
|
sourceFile.addStatements(
|
|
7653
7654
|
/* ts */
|
|
7654
7655
|
`
|
|
7655
|
-
|
|
7656
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7656
7657
|
);
|
|
7657
7658
|
const middlewares = [];
|
|
7658
7659
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
7659
7660
|
sourceFile.addStatements(
|
|
7660
7661
|
/* ts */
|
|
7661
7662
|
`
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7663
|
+
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
7664
|
+
console.log('inside middleware!')
|
|
7665
|
+
return next()
|
|
7666
|
+
});`
|
|
7666
7667
|
);
|
|
7667
7668
|
middlewares.push({
|
|
7668
7669
|
type: "global",
|
|
@@ -7676,13 +7677,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7676
7677
|
sourceFile.addStatements(
|
|
7677
7678
|
/* ts */
|
|
7678
7679
|
`
|
|
7679
|
-
|
|
7680
|
+
import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
|
|
7680
7681
|
`
|
|
7681
7682
|
);
|
|
7682
7683
|
sourceFile.addStatements(
|
|
7683
7684
|
/* ts */
|
|
7684
7685
|
`
|
|
7685
|
-
|
|
7686
|
+
export const globalMiddleware = t.middleware(middleware);`
|
|
7686
7687
|
);
|
|
7687
7688
|
middlewares.push({
|
|
7688
7689
|
type: "global",
|
|
@@ -7696,7 +7697,7 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7696
7697
|
sourceFile.addStatements(
|
|
7697
7698
|
/* ts */
|
|
7698
7699
|
`
|
|
7699
|
-
|
|
7700
|
+
export const permissionsMiddleware = t.middleware(permissions);
|
|
7700
7701
|
`
|
|
7701
7702
|
);
|
|
7702
7703
|
middlewares.push({
|
|
@@ -7720,7 +7721,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7720
7721
|
sourceFile.addStatements(
|
|
7721
7722
|
/* ts */
|
|
7722
7723
|
`
|
|
7723
|
-
|
|
7724
|
+
export const publicProcedure = t.procedure; `
|
|
7724
7725
|
);
|
|
7725
7726
|
if (middlewares.length > 0) {
|
|
7726
7727
|
const procName = getProcedureName(config);
|
|
@@ -7729,7 +7730,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7729
7730
|
sourceFile.addStatements(
|
|
7730
7731
|
/* ts */
|
|
7731
7732
|
`
|
|
7732
|
-
|
|
7733
|
+
export const ${procName} = t.procedure`
|
|
7733
7734
|
);
|
|
7734
7735
|
}
|
|
7735
7736
|
sourceFile.addStatements(
|
|
@@ -7742,9 +7743,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7742
7743
|
sourceFile.addStatements(
|
|
7743
7744
|
/* ts */
|
|
7744
7745
|
`
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7746
|
+
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
7747
|
+
createTRPCServerActionHandler(cookies, t, createContext);
|
|
7748
|
+
`
|
|
7748
7749
|
);
|
|
7749
7750
|
}
|
|
7750
7751
|
sourceFile.formatText({
|
package/dist/index.cjs
CHANGED
|
@@ -6879,7 +6879,7 @@ var configSchema = z.object({
|
|
|
6879
6879
|
withShield: configBoolean.default("false"),
|
|
6880
6880
|
contextPath: z.string().trim().default("../context"),
|
|
6881
6881
|
trpcOptions: configBoolean.default("true"),
|
|
6882
|
-
showModelNameInProcedure: configBoolean.default("
|
|
6882
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
6883
6883
|
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
6884
6884
|
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
6885
6885
|
})
|
|
@@ -7636,24 +7636,25 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7636
7636
|
sourceFile.addStatements(
|
|
7637
7637
|
/* ts */
|
|
7638
7638
|
`import { createContext } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';
|
|
7639
|
-
|
|
7640
|
-
|
|
7639
|
+
import { initTRPC } from '@trpc/server';
|
|
7640
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7641
|
+
import { cookies } from "next/headers";`
|
|
7641
7642
|
);
|
|
7642
7643
|
}
|
|
7643
7644
|
sourceFile.addStatements(
|
|
7644
7645
|
/* ts */
|
|
7645
7646
|
`
|
|
7646
|
-
|
|
7647
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7647
7648
|
);
|
|
7648
7649
|
const middlewares = [];
|
|
7649
7650
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
7650
7651
|
sourceFile.addStatements(
|
|
7651
7652
|
/* ts */
|
|
7652
7653
|
`
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7654
|
+
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
7655
|
+
console.log('inside middleware!')
|
|
7656
|
+
return next()
|
|
7657
|
+
});`
|
|
7657
7658
|
);
|
|
7658
7659
|
middlewares.push({
|
|
7659
7660
|
type: "global",
|
|
@@ -7667,13 +7668,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7667
7668
|
sourceFile.addStatements(
|
|
7668
7669
|
/* ts */
|
|
7669
7670
|
`
|
|
7670
|
-
|
|
7671
|
+
import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
|
|
7671
7672
|
`
|
|
7672
7673
|
);
|
|
7673
7674
|
sourceFile.addStatements(
|
|
7674
7675
|
/* ts */
|
|
7675
7676
|
`
|
|
7676
|
-
|
|
7677
|
+
export const globalMiddleware = t.middleware(middleware);`
|
|
7677
7678
|
);
|
|
7678
7679
|
middlewares.push({
|
|
7679
7680
|
type: "global",
|
|
@@ -7687,7 +7688,7 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7687
7688
|
sourceFile.addStatements(
|
|
7688
7689
|
/* ts */
|
|
7689
7690
|
`
|
|
7690
|
-
|
|
7691
|
+
export const permissionsMiddleware = t.middleware(permissions);
|
|
7691
7692
|
`
|
|
7692
7693
|
);
|
|
7693
7694
|
middlewares.push({
|
|
@@ -7711,7 +7712,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7711
7712
|
sourceFile.addStatements(
|
|
7712
7713
|
/* ts */
|
|
7713
7714
|
`
|
|
7714
|
-
|
|
7715
|
+
export const publicProcedure = t.procedure; `
|
|
7715
7716
|
);
|
|
7716
7717
|
if (middlewares.length > 0) {
|
|
7717
7718
|
const procName = getProcedureName(config);
|
|
@@ -7720,7 +7721,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7720
7721
|
sourceFile.addStatements(
|
|
7721
7722
|
/* ts */
|
|
7722
7723
|
`
|
|
7723
|
-
|
|
7724
|
+
export const ${procName} = t.procedure`
|
|
7724
7725
|
);
|
|
7725
7726
|
}
|
|
7726
7727
|
sourceFile.addStatements(
|
|
@@ -7733,9 +7734,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7733
7734
|
sourceFile.addStatements(
|
|
7734
7735
|
/* ts */
|
|
7735
7736
|
`
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7737
|
+
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
7738
|
+
createTRPCServerActionHandler(cookies, t, createContext);
|
|
7739
|
+
`
|
|
7739
7740
|
);
|
|
7740
7741
|
}
|
|
7741
7742
|
sourceFile.formatText({
|
package/dist/index.js
CHANGED
|
@@ -6884,7 +6884,7 @@ var configSchema = z.object({
|
|
|
6884
6884
|
withShield: configBoolean.default("false"),
|
|
6885
6885
|
contextPath: z.string().trim().default("../context"),
|
|
6886
6886
|
trpcOptions: configBoolean.default("true"),
|
|
6887
|
-
showModelNameInProcedure: configBoolean.default("
|
|
6887
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
6888
6888
|
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
6889
6889
|
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
6890
6890
|
})
|
|
@@ -7641,24 +7641,25 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7641
7641
|
sourceFile.addStatements(
|
|
7642
7642
|
/* ts */
|
|
7643
7643
|
`import { createContext } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';
|
|
7644
|
-
|
|
7645
|
-
|
|
7644
|
+
import { initTRPC } from '@trpc/server';
|
|
7645
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7646
|
+
import { cookies } from "next/headers";`
|
|
7646
7647
|
);
|
|
7647
7648
|
}
|
|
7648
7649
|
sourceFile.addStatements(
|
|
7649
7650
|
/* ts */
|
|
7650
7651
|
`
|
|
7651
|
-
|
|
7652
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7652
7653
|
);
|
|
7653
7654
|
const middlewares = [];
|
|
7654
7655
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
7655
7656
|
sourceFile.addStatements(
|
|
7656
7657
|
/* ts */
|
|
7657
7658
|
`
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7659
|
+
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
7660
|
+
console.log('inside middleware!')
|
|
7661
|
+
return next()
|
|
7662
|
+
});`
|
|
7662
7663
|
);
|
|
7663
7664
|
middlewares.push({
|
|
7664
7665
|
type: "global",
|
|
@@ -7672,13 +7673,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7672
7673
|
sourceFile.addStatements(
|
|
7673
7674
|
/* ts */
|
|
7674
7675
|
`
|
|
7675
|
-
|
|
7676
|
+
import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
|
|
7676
7677
|
`
|
|
7677
7678
|
);
|
|
7678
7679
|
sourceFile.addStatements(
|
|
7679
7680
|
/* ts */
|
|
7680
7681
|
`
|
|
7681
|
-
|
|
7682
|
+
export const globalMiddleware = t.middleware(middleware);`
|
|
7682
7683
|
);
|
|
7683
7684
|
middlewares.push({
|
|
7684
7685
|
type: "global",
|
|
@@ -7692,7 +7693,7 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
|
7692
7693
|
sourceFile.addStatements(
|
|
7693
7694
|
/* ts */
|
|
7694
7695
|
`
|
|
7695
|
-
|
|
7696
|
+
export const permissionsMiddleware = t.middleware(permissions);
|
|
7696
7697
|
`
|
|
7697
7698
|
);
|
|
7698
7699
|
middlewares.push({
|
|
@@ -7716,7 +7717,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7716
7717
|
sourceFile.addStatements(
|
|
7717
7718
|
/* ts */
|
|
7718
7719
|
`
|
|
7719
|
-
|
|
7720
|
+
export const publicProcedure = t.procedure; `
|
|
7720
7721
|
);
|
|
7721
7722
|
if (middlewares.length > 0) {
|
|
7722
7723
|
const procName = getProcedureName(config);
|
|
@@ -7725,7 +7726,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7725
7726
|
sourceFile.addStatements(
|
|
7726
7727
|
/* ts */
|
|
7727
7728
|
`
|
|
7728
|
-
|
|
7729
|
+
export const ${procName} = t.procedure`
|
|
7729
7730
|
);
|
|
7730
7731
|
}
|
|
7731
7732
|
sourceFile.addStatements(
|
|
@@ -7738,9 +7739,9 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7738
7739
|
sourceFile.addStatements(
|
|
7739
7740
|
/* ts */
|
|
7740
7741
|
`
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7742
|
+
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
7743
|
+
createTRPCServerActionHandler(cookies, t, createContext);
|
|
7744
|
+
`
|
|
7744
7745
|
);
|
|
7745
7746
|
}
|
|
7746
7747
|
sourceFile.formatText({
|