@stryke/prisma-trpc-generator 0.7.1 → 0.7.2
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 +9 -36
- package/dist/generator.js +9 -36
- package/dist/index.cjs +9 -36
- package/dist/index.js +9 -36
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -7637,7 +7637,7 @@ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, va
|
|
|
7637
7637
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7638
7638
|
let shieldPath = joinPaths(outputDir, "shield");
|
|
7639
7639
|
if (typeof value === "string") {
|
|
7640
|
-
shieldPath =
|
|
7640
|
+
shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
|
|
7641
7641
|
}
|
|
7642
7642
|
sourceFile.addImportDeclaration({
|
|
7643
7643
|
moduleSpecifier: shieldPath,
|
|
@@ -7657,37 +7657,30 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
|
|
|
7657
7657
|
async function generateBaseRouter(sourceFile, config, options) {
|
|
7658
7658
|
const internals = await getPrismaInternals();
|
|
7659
7659
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7660
|
-
const relativeContextPath = joinPaths(relativePath(outputDir, options.schemaPath), config.contextPath);
|
|
7661
7660
|
sourceFile.addStatements(
|
|
7662
7661
|
/* ts */
|
|
7663
7662
|
`
|
|
7664
|
-
import type { Context } from '${
|
|
7665
|
-
`
|
|
7663
|
+
import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';`
|
|
7666
7664
|
);
|
|
7667
7665
|
if (config.trpcOptions) {
|
|
7668
7666
|
sourceFile.addStatements(
|
|
7669
7667
|
/* ts */
|
|
7670
7668
|
`
|
|
7671
|
-
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}'
|
|
7672
|
-
`
|
|
7669
|
+
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';`
|
|
7673
7670
|
);
|
|
7674
7671
|
}
|
|
7675
7672
|
if (config.withNext) {
|
|
7676
7673
|
sourceFile.addStatements(
|
|
7677
7674
|
/* ts */
|
|
7678
|
-
`
|
|
7679
|
-
import {
|
|
7680
|
-
import {
|
|
7681
|
-
import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
|
|
7682
|
-
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7683
|
-
`
|
|
7675
|
+
`import { createContext } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
|
|
7676
|
+
import { initTRPC } from '@trpc/server';
|
|
7677
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';`
|
|
7684
7678
|
);
|
|
7685
7679
|
}
|
|
7686
7680
|
sourceFile.addStatements(
|
|
7687
7681
|
/* ts */
|
|
7688
7682
|
`
|
|
7689
|
-
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""})
|
|
7690
|
-
`
|
|
7683
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7691
7684
|
);
|
|
7692
7685
|
const middlewares = [];
|
|
7693
7686
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
@@ -7776,13 +7769,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7776
7769
|
}
|
|
7777
7770
|
sourceFile.addStatements(
|
|
7778
7771
|
/* ts */
|
|
7779
|
-
`
|
|
7780
|
-
.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
|
|
7781
|
-
experimental_nextAppDirCaller({
|
|
7782
|
-
normalizeFormData: true,
|
|
7783
|
-
}),
|
|
7784
|
-
)` : ""}
|
|
7785
|
-
`
|
|
7772
|
+
`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`
|
|
7786
7773
|
);
|
|
7787
7774
|
});
|
|
7788
7775
|
}
|
|
@@ -11635,21 +11622,7 @@ async function generate(options) {
|
|
|
11635
11622
|
queries,
|
|
11636
11623
|
mutations,
|
|
11637
11624
|
subscriptions
|
|
11638
|
-
}, config,
|
|
11639
|
-
...options,
|
|
11640
|
-
generator: {
|
|
11641
|
-
...options.generator,
|
|
11642
|
-
output: {
|
|
11643
|
-
fromEnvVar: null,
|
|
11644
|
-
...options.generator.output,
|
|
11645
|
-
value: outputDir
|
|
11646
|
-
},
|
|
11647
|
-
config: {
|
|
11648
|
-
...options.generator.config,
|
|
11649
|
-
contextPath: config.contextPath
|
|
11650
|
-
}
|
|
11651
|
-
}
|
|
11652
|
-
}, shieldOutputDir);
|
|
11625
|
+
}, config, options, shieldOutputDir);
|
|
11653
11626
|
consoleLog("Saving tRPC Shield source file to disk");
|
|
11654
11627
|
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11655
11628
|
}
|
package/dist/generator.js
CHANGED
|
@@ -7642,7 +7642,7 @@ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, va
|
|
|
7642
7642
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7643
7643
|
let shieldPath = joinPaths(outputDir, "shield");
|
|
7644
7644
|
if (typeof value === "string") {
|
|
7645
|
-
shieldPath =
|
|
7645
|
+
shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
|
|
7646
7646
|
}
|
|
7647
7647
|
sourceFile.addImportDeclaration({
|
|
7648
7648
|
moduleSpecifier: shieldPath,
|
|
@@ -7662,37 +7662,30 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
|
|
|
7662
7662
|
async function generateBaseRouter(sourceFile, config, options) {
|
|
7663
7663
|
const internals = await getPrismaInternals();
|
|
7664
7664
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7665
|
-
const relativeContextPath = joinPaths(relativePath(outputDir, options.schemaPath), config.contextPath);
|
|
7666
7665
|
sourceFile.addStatements(
|
|
7667
7666
|
/* ts */
|
|
7668
7667
|
`
|
|
7669
|
-
import type { Context } from '${
|
|
7670
|
-
`
|
|
7668
|
+
import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';`
|
|
7671
7669
|
);
|
|
7672
7670
|
if (config.trpcOptions) {
|
|
7673
7671
|
sourceFile.addStatements(
|
|
7674
7672
|
/* ts */
|
|
7675
7673
|
`
|
|
7676
|
-
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}'
|
|
7677
|
-
`
|
|
7674
|
+
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';`
|
|
7678
7675
|
);
|
|
7679
7676
|
}
|
|
7680
7677
|
if (config.withNext) {
|
|
7681
7678
|
sourceFile.addStatements(
|
|
7682
7679
|
/* ts */
|
|
7683
|
-
`
|
|
7684
|
-
import {
|
|
7685
|
-
import {
|
|
7686
|
-
import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
|
|
7687
|
-
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7688
|
-
`
|
|
7680
|
+
`import { createContext } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
|
|
7681
|
+
import { initTRPC } from '@trpc/server';
|
|
7682
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';`
|
|
7689
7683
|
);
|
|
7690
7684
|
}
|
|
7691
7685
|
sourceFile.addStatements(
|
|
7692
7686
|
/* ts */
|
|
7693
7687
|
`
|
|
7694
|
-
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""})
|
|
7695
|
-
`
|
|
7688
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7696
7689
|
);
|
|
7697
7690
|
const middlewares = [];
|
|
7698
7691
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
@@ -7781,13 +7774,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7781
7774
|
}
|
|
7782
7775
|
sourceFile.addStatements(
|
|
7783
7776
|
/* ts */
|
|
7784
|
-
`
|
|
7785
|
-
.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
|
|
7786
|
-
experimental_nextAppDirCaller({
|
|
7787
|
-
normalizeFormData: true,
|
|
7788
|
-
}),
|
|
7789
|
-
)` : ""}
|
|
7790
|
-
`
|
|
7777
|
+
`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`
|
|
7791
7778
|
);
|
|
7792
7779
|
});
|
|
7793
7780
|
}
|
|
@@ -11640,21 +11627,7 @@ async function generate(options) {
|
|
|
11640
11627
|
queries,
|
|
11641
11628
|
mutations,
|
|
11642
11629
|
subscriptions
|
|
11643
|
-
}, config,
|
|
11644
|
-
...options,
|
|
11645
|
-
generator: {
|
|
11646
|
-
...options.generator,
|
|
11647
|
-
output: {
|
|
11648
|
-
fromEnvVar: null,
|
|
11649
|
-
...options.generator.output,
|
|
11650
|
-
value: outputDir
|
|
11651
|
-
},
|
|
11652
|
-
config: {
|
|
11653
|
-
...options.generator.config,
|
|
11654
|
-
contextPath: config.contextPath
|
|
11655
|
-
}
|
|
11656
|
-
}
|
|
11657
|
-
}, shieldOutputDir);
|
|
11630
|
+
}, config, options, shieldOutputDir);
|
|
11658
11631
|
consoleLog("Saving tRPC Shield source file to disk");
|
|
11659
11632
|
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11660
11633
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -7633,7 +7633,7 @@ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, va
|
|
|
7633
7633
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7634
7634
|
let shieldPath = joinPaths(outputDir, "shield");
|
|
7635
7635
|
if (typeof value === "string") {
|
|
7636
|
-
shieldPath =
|
|
7636
|
+
shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
|
|
7637
7637
|
}
|
|
7638
7638
|
sourceFile.addImportDeclaration({
|
|
7639
7639
|
moduleSpecifier: shieldPath,
|
|
@@ -7653,37 +7653,30 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
|
|
|
7653
7653
|
async function generateBaseRouter(sourceFile, config, options) {
|
|
7654
7654
|
const internals = await getPrismaInternals();
|
|
7655
7655
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7656
|
-
const relativeContextPath = joinPaths(relativePath(outputDir, options.schemaPath), config.contextPath);
|
|
7657
7656
|
sourceFile.addStatements(
|
|
7658
7657
|
/* ts */
|
|
7659
7658
|
`
|
|
7660
|
-
import type { Context } from '${
|
|
7661
|
-
`
|
|
7659
|
+
import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';`
|
|
7662
7660
|
);
|
|
7663
7661
|
if (config.trpcOptions) {
|
|
7664
7662
|
sourceFile.addStatements(
|
|
7665
7663
|
/* ts */
|
|
7666
7664
|
`
|
|
7667
|
-
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}'
|
|
7668
|
-
`
|
|
7665
|
+
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';`
|
|
7669
7666
|
);
|
|
7670
7667
|
}
|
|
7671
7668
|
if (config.withNext) {
|
|
7672
7669
|
sourceFile.addStatements(
|
|
7673
7670
|
/* ts */
|
|
7674
|
-
`
|
|
7675
|
-
import {
|
|
7676
|
-
import {
|
|
7677
|
-
import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
|
|
7678
|
-
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7679
|
-
`
|
|
7671
|
+
`import { createContext } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
|
|
7672
|
+
import { initTRPC } from '@trpc/server';
|
|
7673
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';`
|
|
7680
7674
|
);
|
|
7681
7675
|
}
|
|
7682
7676
|
sourceFile.addStatements(
|
|
7683
7677
|
/* ts */
|
|
7684
7678
|
`
|
|
7685
|
-
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""})
|
|
7686
|
-
`
|
|
7679
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7687
7680
|
);
|
|
7688
7681
|
const middlewares = [];
|
|
7689
7682
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
@@ -7772,13 +7765,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7772
7765
|
}
|
|
7773
7766
|
sourceFile.addStatements(
|
|
7774
7767
|
/* ts */
|
|
7775
|
-
`
|
|
7776
|
-
.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
|
|
7777
|
-
experimental_nextAppDirCaller({
|
|
7778
|
-
normalizeFormData: true,
|
|
7779
|
-
}),
|
|
7780
|
-
)` : ""}
|
|
7781
|
-
`
|
|
7768
|
+
`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`
|
|
7782
7769
|
);
|
|
7783
7770
|
});
|
|
7784
7771
|
}
|
|
@@ -11631,21 +11618,7 @@ async function generate(options) {
|
|
|
11631
11618
|
queries,
|
|
11632
11619
|
mutations,
|
|
11633
11620
|
subscriptions
|
|
11634
|
-
}, config,
|
|
11635
|
-
...options,
|
|
11636
|
-
generator: {
|
|
11637
|
-
...options.generator,
|
|
11638
|
-
output: {
|
|
11639
|
-
fromEnvVar: null,
|
|
11640
|
-
...options.generator.output,
|
|
11641
|
-
value: outputDir
|
|
11642
|
-
},
|
|
11643
|
-
config: {
|
|
11644
|
-
...options.generator.config,
|
|
11645
|
-
contextPath: config.contextPath
|
|
11646
|
-
}
|
|
11647
|
-
}
|
|
11648
|
-
}, shieldOutputDir);
|
|
11621
|
+
}, config, options, shieldOutputDir);
|
|
11649
11622
|
consoleLog("Saving tRPC Shield source file to disk");
|
|
11650
11623
|
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11651
11624
|
}
|
package/dist/index.js
CHANGED
|
@@ -7638,7 +7638,7 @@ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, va
|
|
|
7638
7638
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7639
7639
|
let shieldPath = joinPaths(outputDir, "shield");
|
|
7640
7640
|
if (typeof value === "string") {
|
|
7641
|
-
shieldPath =
|
|
7641
|
+
shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
|
|
7642
7642
|
}
|
|
7643
7643
|
sourceFile.addImportDeclaration({
|
|
7644
7644
|
moduleSpecifier: shieldPath,
|
|
@@ -7658,37 +7658,30 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
|
|
|
7658
7658
|
async function generateBaseRouter(sourceFile, config, options) {
|
|
7659
7659
|
const internals = await getPrismaInternals();
|
|
7660
7660
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
7661
|
-
const relativeContextPath = joinPaths(relativePath(outputDir, options.schemaPath), config.contextPath);
|
|
7662
7661
|
sourceFile.addStatements(
|
|
7663
7662
|
/* ts */
|
|
7664
7663
|
`
|
|
7665
|
-
import type { Context } from '${
|
|
7666
|
-
`
|
|
7664
|
+
import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';`
|
|
7667
7665
|
);
|
|
7668
7666
|
if (config.trpcOptions) {
|
|
7669
7667
|
sourceFile.addStatements(
|
|
7670
7668
|
/* ts */
|
|
7671
7669
|
`
|
|
7672
|
-
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}'
|
|
7673
|
-
`
|
|
7670
|
+
import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';`
|
|
7674
7671
|
);
|
|
7675
7672
|
}
|
|
7676
7673
|
if (config.withNext) {
|
|
7677
7674
|
sourceFile.addStatements(
|
|
7678
7675
|
/* ts */
|
|
7679
|
-
`
|
|
7680
|
-
import {
|
|
7681
|
-
import {
|
|
7682
|
-
import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
|
|
7683
|
-
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
7684
|
-
`
|
|
7676
|
+
`import { createContext } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
|
|
7677
|
+
import { initTRPC } from '@trpc/server';
|
|
7678
|
+
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';`
|
|
7685
7679
|
);
|
|
7686
7680
|
}
|
|
7687
7681
|
sourceFile.addStatements(
|
|
7688
7682
|
/* ts */
|
|
7689
7683
|
`
|
|
7690
|
-
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""})
|
|
7691
|
-
`
|
|
7684
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
7692
7685
|
);
|
|
7693
7686
|
const middlewares = [];
|
|
7694
7687
|
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
@@ -7777,13 +7770,7 @@ export const createCallerFactory = t.createCallerFactory;`
|
|
|
7777
7770
|
}
|
|
7778
7771
|
sourceFile.addStatements(
|
|
7779
7772
|
/* ts */
|
|
7780
|
-
`
|
|
7781
|
-
.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
|
|
7782
|
-
experimental_nextAppDirCaller({
|
|
7783
|
-
normalizeFormData: true,
|
|
7784
|
-
}),
|
|
7785
|
-
)` : ""}
|
|
7786
|
-
`
|
|
7773
|
+
`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`
|
|
7787
7774
|
);
|
|
7788
7775
|
});
|
|
7789
7776
|
}
|
|
@@ -11636,21 +11623,7 @@ async function generate(options) {
|
|
|
11636
11623
|
queries,
|
|
11637
11624
|
mutations,
|
|
11638
11625
|
subscriptions
|
|
11639
|
-
}, config,
|
|
11640
|
-
...options,
|
|
11641
|
-
generator: {
|
|
11642
|
-
...options.generator,
|
|
11643
|
-
output: {
|
|
11644
|
-
fromEnvVar: null,
|
|
11645
|
-
...options.generator.output,
|
|
11646
|
-
value: outputDir
|
|
11647
|
-
},
|
|
11648
|
-
config: {
|
|
11649
|
-
...options.generator.config,
|
|
11650
|
-
contextPath: config.contextPath
|
|
11651
|
-
}
|
|
11652
|
-
}
|
|
11653
|
-
}, shieldOutputDir);
|
|
11626
|
+
}, config, options, shieldOutputDir);
|
|
11654
11627
|
consoleLog("Saving tRPC Shield source file to disk");
|
|
11655
11628
|
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11656
11629
|
}
|