@idealyst/cli 1.1.9 → 1.2.1
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/commands/add.js +233 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/info.js +193 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.js +155 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/constants.js +119 -0
- package/dist/constants.js.map +1 -0
- package/dist/generators/core/index.js +23 -0
- package/dist/generators/core/index.js.map +1 -0
- package/dist/generators/core/mobile.js +286 -0
- package/dist/generators/core/mobile.js.map +1 -0
- package/dist/generators/core/shared.js +207 -0
- package/dist/generators/core/shared.js.map +1 -0
- package/dist/generators/core/web.js +377 -0
- package/dist/generators/core/web.js.map +1 -0
- package/dist/generators/extensions/api.js +223 -0
- package/dist/generators/extensions/api.js.map +1 -0
- package/dist/generators/extensions/devcontainer.js +510 -0
- package/dist/generators/extensions/devcontainer.js.map +1 -0
- package/dist/generators/extensions/graphql.js +202 -0
- package/dist/generators/extensions/graphql.js.map +1 -0
- package/dist/generators/extensions/index.js +17 -0
- package/dist/generators/extensions/index.js.map +1 -0
- package/dist/generators/extensions/prisma.js +249 -0
- package/dist/generators/extensions/prisma.js.map +1 -0
- package/dist/generators/extensions/trpc.js +258 -0
- package/dist/generators/extensions/trpc.js.map +1 -0
- package/dist/generators/index.js +106 -4
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/reactNative.js +177 -0
- package/dist/generators/reactNative.js.map +1 -0
- package/dist/generators/workspace.js +272 -0
- package/dist/generators/workspace.js.map +1 -0
- package/dist/identifiers/android.js +75 -0
- package/dist/identifiers/android.js.map +1 -0
- package/dist/identifiers/index.js +35 -0
- package/dist/identifiers/index.js.map +1 -0
- package/dist/identifiers/ios.js +65 -0
- package/dist/identifiers/ios.js.map +1 -0
- package/dist/index.js +41 -319
- package/dist/index.js.map +1 -1
- package/dist/templates/copier.js +135 -0
- package/dist/templates/copier.js.map +1 -0
- package/dist/templates/index.js +23 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/merger.js +113 -0
- package/dist/templates/merger.js.map +1 -0
- package/dist/templates/processor.js +142 -0
- package/dist/templates/processor.js.map +1 -0
- package/dist/types/commands/add.d.ts +14 -0
- package/dist/types/commands/index.d.ts +6 -0
- package/dist/types/commands/info.d.ts +10 -0
- package/dist/types/commands/init.d.ts +19 -0
- package/dist/types/constants.d.ts +76 -0
- package/dist/types/generators/core/index.d.ts +6 -0
- package/dist/types/generators/core/mobile.d.ts +13 -0
- package/dist/types/generators/core/shared.d.ts +8 -0
- package/dist/types/generators/core/web.d.ts +8 -0
- package/dist/types/generators/extensions/api.d.ts +8 -0
- package/dist/types/generators/extensions/devcontainer.d.ts +15 -0
- package/dist/types/generators/extensions/graphql.d.ts +8 -0
- package/dist/types/generators/extensions/index.d.ts +8 -0
- package/dist/types/generators/extensions/prisma.d.ts +8 -0
- package/dist/types/generators/extensions/trpc.d.ts +9 -0
- package/dist/types/generators/index.d.ts +11 -3
- package/dist/types/generators/reactNative.d.ts +19 -0
- package/dist/types/generators/workspace.d.ts +8 -0
- package/dist/types/identifiers/android.d.ts +26 -0
- package/dist/types/identifiers/index.d.ts +26 -0
- package/dist/types/identifiers/ios.d.ts +21 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/templates/copier.d.ts +24 -0
- package/dist/types/templates/index.d.ts +6 -0
- package/dist/types/templates/merger.d.ts +43 -0
- package/dist/types/templates/processor.d.ts +39 -0
- package/dist/types/types.d.ts +153 -5
- package/dist/types/utils/filesystem.d.ts +56 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/logger.d.ts +58 -0
- package/dist/types/utils/shell.d.ts +35 -0
- package/dist/types/utils/validation.d.ts +32 -0
- package/dist/types/wizard/index.d.ts +20 -0
- package/dist/types/wizard/steps/apiExtension.d.ts +5 -0
- package/dist/types/wizard/steps/appDisplayName.d.ts +5 -0
- package/dist/types/wizard/steps/devcontainerExtension.d.ts +5 -0
- package/dist/types/wizard/steps/graphqlExtension.d.ts +5 -0
- package/dist/types/wizard/steps/index.d.ts +12 -0
- package/dist/types/wizard/steps/orgDomain.d.ts +5 -0
- package/dist/types/wizard/steps/prismaExtension.d.ts +5 -0
- package/dist/types/wizard/steps/projectName.d.ts +5 -0
- package/dist/types/wizard/steps/summary.d.ts +5 -0
- package/dist/types/wizard/steps/trpcExtension.d.ts +5 -0
- package/dist/types/wizard/validators.d.ts +17 -0
- package/dist/types.js +41 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/filesystem.js +173 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.js +95 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/shell.js +113 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/validation.js +196 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/wizard/index.js +177 -0
- package/dist/wizard/index.js.map +1 -0
- package/dist/wizard/steps/apiExtension.js +33 -0
- package/dist/wizard/steps/apiExtension.js.map +1 -0
- package/dist/wizard/steps/appDisplayName.js +53 -0
- package/dist/wizard/steps/appDisplayName.js.map +1 -0
- package/dist/wizard/steps/devcontainerExtension.js +78 -0
- package/dist/wizard/steps/devcontainerExtension.js.map +1 -0
- package/dist/wizard/steps/graphqlExtension.js +37 -0
- package/dist/wizard/steps/graphqlExtension.js.map +1 -0
- package/dist/wizard/steps/index.js +25 -0
- package/dist/wizard/steps/index.js.map +1 -0
- package/dist/wizard/steps/orgDomain.js +40 -0
- package/dist/wizard/steps/orgDomain.js.map +1 -0
- package/dist/wizard/steps/prismaExtension.js +33 -0
- package/dist/wizard/steps/prismaExtension.js.map +1 -0
- package/dist/wizard/steps/projectName.js +40 -0
- package/dist/wizard/steps/projectName.js.map +1 -0
- package/dist/wizard/steps/summary.js +107 -0
- package/dist/wizard/steps/summary.js.map +1 -0
- package/dist/wizard/steps/trpcExtension.js +37 -0
- package/dist/wizard/steps/trpcExtension.js.map +1 -0
- package/dist/wizard/validators.js +35 -0
- package/dist/wizard/validators.js.map +1 -0
- package/package.json +6 -19
- package/README.md +0 -110
- package/dist/generators/init.js +0 -268
- package/dist/generators/init.js.map +0 -1
- package/dist/generators/utils.js +0 -682
- package/dist/generators/utils.js.map +0 -1
- package/dist/scripts/configure-react-native-monorepo.js +0 -144
- package/dist/scripts/configure-react-native-monorepo.js.map +0 -1
- package/dist/template/.devcontainer/Dockerfile +0 -26
- package/dist/template/.devcontainer/devcontainer.json +0 -113
- package/dist/template/.devcontainer/docker-compose.yml +0 -59
- package/dist/template/.devcontainer/figma-mcp.sh +0 -32
- package/dist/template/.devcontainer/gitignore.template +0 -2
- package/dist/template/.devcontainer/setup.sh +0 -45
- package/dist/template/DOCKER.md +0 -0
- package/dist/template/Dockerfile +0 -111
- package/dist/template/README.md +0 -233
- package/dist/template/docker/nginx/prod.conf +0 -238
- package/dist/template/docker/nginx.conf +0 -131
- package/dist/template/docker/postgres/init.sql +0 -41
- package/dist/template/docker/prometheus/prometheus.yml +0 -52
- package/dist/template/docker-compose.prod.yml +0 -146
- package/dist/template/docker-compose.yml +0 -143
- package/dist/template/dockerignore.template +0 -151
- package/dist/template/env.example.template +0 -36
- package/dist/template/gitignore.template +0 -56
- package/dist/template/jest.config.js +0 -20
- package/dist/template/mcp.json.template +0 -8
- package/dist/template/package.json +0 -45
- package/dist/template/packages/api/README.md +0 -510
- package/dist/template/packages/api/__tests__/api.test.ts +0 -26
- package/dist/template/packages/api/env.example.template +0 -6
- package/dist/template/packages/api/gitignore.template +0 -35
- package/dist/template/packages/api/jest.config.js +0 -23
- package/dist/template/packages/api/jest.setup.js +0 -9
- package/dist/template/packages/api/package.json +0 -66
- package/dist/template/packages/api/src/context.ts +0 -52
- package/dist/template/packages/api/src/controllers/TestController.ts +0 -0
- package/dist/template/packages/api/src/graphql/builder.ts +0 -75
- package/dist/template/packages/api/src/graphql/generated.ts +0 -64
- package/dist/template/packages/api/src/graphql/index.ts +0 -75
- package/dist/template/packages/api/src/graphql/types/index.ts +0 -44
- package/dist/template/packages/api/src/graphql/types/test.ts +0 -245
- package/dist/template/packages/api/src/index.ts +0 -26
- package/dist/template/packages/api/src/lib/database.ts +0 -23
- package/dist/template/packages/api/src/router/index.ts +0 -163
- package/dist/template/packages/api/src/routers/test.ts +0 -161
- package/dist/template/packages/api/src/server.ts +0 -68
- package/dist/template/packages/api/src/trpc.ts +0 -28
- package/dist/template/packages/api/tsconfig.json +0 -44
- package/dist/template/packages/database/README.md +0 -162
- package/dist/template/packages/database/gitignore.template +0 -41
- package/dist/template/packages/database/package.json +0 -49
- package/dist/template/packages/database/prisma/seed.ts +0 -64
- package/dist/template/packages/database/schema.prisma +0 -107
- package/dist/template/packages/database/src/index.ts +0 -15
- package/dist/template/packages/database/src/validators.ts +0 -10
- package/dist/template/packages/database/tsconfig.json +0 -18
- package/dist/template/packages/mobile/README.md +0 -86
- package/dist/template/packages/mobile/__tests__/App.test.tsx +0 -156
- package/dist/template/packages/mobile/__tests__/components.test.tsx +0 -300
- package/dist/template/packages/mobile/app.json +0 -5
- package/dist/template/packages/mobile/babel.config.js +0 -10
- package/dist/template/packages/mobile/gitignore.template +0 -73
- package/dist/template/packages/mobile/index.js +0 -6
- package/dist/template/packages/mobile/jest.config.js +0 -21
- package/dist/template/packages/mobile/jest.setup.js +0 -12
- package/dist/template/packages/mobile/metro.config.js +0 -36
- package/dist/template/packages/mobile/package.json +0 -60
- package/dist/template/packages/mobile/src/App.tsx +0 -8
- package/dist/template/packages/mobile/src/utils/trpc.ts +0 -7
- package/dist/template/packages/mobile/tsconfig.json +0 -28
- package/dist/template/packages/shared/README.md +0 -135
- package/dist/template/packages/shared/__tests__/shared.test.ts +0 -51
- package/dist/template/packages/shared/gitignore.template +0 -35
- package/dist/template/packages/shared/jest.config.js +0 -22
- package/dist/template/packages/shared/package.json +0 -68
- package/dist/template/packages/shared/src/components/App.tsx +0 -57
- package/dist/template/packages/shared/src/components/HelloWorld.tsx +0 -531
- package/dist/template/packages/shared/src/components/index.ts +0 -1
- package/dist/template/packages/shared/src/graphql/client.ts +0 -34
- package/dist/template/packages/shared/src/index.ts +0 -22
- package/dist/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
- package/dist/template/packages/shared/src/trpc/client.ts +0 -44
- package/dist/template/packages/shared/tsconfig.json +0 -22
- package/dist/template/packages/web/README.md +0 -131
- package/dist/template/packages/web/__tests__/App.test.tsx +0 -342
- package/dist/template/packages/web/__tests__/components.test.tsx +0 -564
- package/dist/template/packages/web/gitignore.template +0 -35
- package/dist/template/packages/web/index.html +0 -13
- package/dist/template/packages/web/jest.config.js +0 -27
- package/dist/template/packages/web/jest.setup.js +0 -24
- package/dist/template/packages/web/package.json +0 -69
- package/dist/template/packages/web/src/App.tsx +0 -14
- package/dist/template/packages/web/src/components/TestDemo.tsx +0 -164
- package/dist/template/packages/web/src/main.tsx +0 -25
- package/dist/template/packages/web/src/utils/trpc.ts +0 -7
- package/dist/template/packages/web/tsconfig.json +0 -26
- package/dist/template/packages/web/vite.config.ts +0 -98
- package/dist/template/setup.sh +0 -30
- package/dist/template/tsconfig.json +0 -22
- package/dist/template/yarnrc.yml.template +0 -4
- package/dist/types/generators/init.d.ts +0 -5
- package/dist/types/generators/utils.d.ts +0 -45
- package/dist/types/scripts/configure-react-native-monorepo.d.ts +0 -23
- package/template/.devcontainer/Dockerfile +0 -26
- package/template/.devcontainer/devcontainer.json +0 -113
- package/template/.devcontainer/docker-compose.yml +0 -59
- package/template/.devcontainer/figma-mcp.sh +0 -32
- package/template/.devcontainer/setup.sh +0 -45
- package/template/.dockerignore +0 -151
- package/template/.env.example +0 -36
- package/template/.env.production +0 -56
- package/template/DOCKER.md +0 -0
- package/template/Dockerfile +0 -111
- package/template/README.md +0 -233
- package/template/docker/nginx/prod.conf +0 -238
- package/template/docker/nginx.conf +0 -131
- package/template/docker/postgres/init.sql +0 -41
- package/template/docker/prometheus/prometheus.yml +0 -52
- package/template/docker-compose.prod.yml +0 -146
- package/template/docker-compose.yml +0 -143
- package/template/jest.config.js +0 -20
- package/template/package.json +0 -45
- package/template/packages/api/.env.example +0 -6
- package/template/packages/api/README.md +0 -510
- package/template/packages/api/__tests__/api.test.ts +0 -26
- package/template/packages/api/jest.config.js +0 -23
- package/template/packages/api/jest.setup.js +0 -9
- package/template/packages/api/package.json +0 -66
- package/template/packages/api/src/context.ts +0 -52
- package/template/packages/api/src/controllers/TestController.ts +0 -0
- package/template/packages/api/src/graphql/builder.ts +0 -75
- package/template/packages/api/src/graphql/generated.ts +0 -64
- package/template/packages/api/src/graphql/index.ts +0 -75
- package/template/packages/api/src/graphql/types/index.ts +0 -44
- package/template/packages/api/src/graphql/types/test.ts +0 -245
- package/template/packages/api/src/index.ts +0 -26
- package/template/packages/api/src/lib/database.ts +0 -23
- package/template/packages/api/src/router/index.ts +0 -163
- package/template/packages/api/src/routers/test.ts +0 -161
- package/template/packages/api/src/server.ts +0 -68
- package/template/packages/api/src/trpc.ts +0 -28
- package/template/packages/api/tsconfig.json +0 -44
- package/template/packages/database/README.md +0 -162
- package/template/packages/database/package.json +0 -49
- package/template/packages/database/prisma/seed.ts +0 -64
- package/template/packages/database/schema.prisma +0 -107
- package/template/packages/database/src/index.ts +0 -15
- package/template/packages/database/src/validators.ts +0 -10
- package/template/packages/database/tsconfig.json +0 -18
- package/template/packages/mobile/README.md +0 -86
- package/template/packages/mobile/__tests__/App.test.tsx +0 -156
- package/template/packages/mobile/__tests__/components.test.tsx +0 -300
- package/template/packages/mobile/app.json +0 -5
- package/template/packages/mobile/babel.config.js +0 -26
- package/template/packages/mobile/index.js +0 -8
- package/template/packages/mobile/jest.config.js +0 -21
- package/template/packages/mobile/jest.setup.js +0 -12
- package/template/packages/mobile/metro.config.js +0 -36
- package/template/packages/mobile/package.json +0 -60
- package/template/packages/mobile/src/App.tsx +0 -8
- package/template/packages/mobile/src/utils/trpc.ts +0 -7
- package/template/packages/mobile/tsconfig.json +0 -28
- package/template/packages/shared/README.md +0 -135
- package/template/packages/shared/__tests__/shared.test.ts +0 -51
- package/template/packages/shared/jest.config.js +0 -22
- package/template/packages/shared/package.json +0 -68
- package/template/packages/shared/src/components/App.tsx +0 -57
- package/template/packages/shared/src/components/HelloWorld.tsx +0 -531
- package/template/packages/shared/src/components/index.ts +0 -1
- package/template/packages/shared/src/graphql/client.ts +0 -34
- package/template/packages/shared/src/index.ts +0 -25
- package/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
- package/template/packages/shared/src/trpc/client.ts +0 -44
- package/template/packages/shared/src/unistyles.ts +0 -50
- package/template/packages/shared/tsconfig.json +0 -22
- package/template/packages/web/README.md +0 -131
- package/template/packages/web/__tests__/App.test.tsx +0 -342
- package/template/packages/web/__tests__/components.test.tsx +0 -564
- package/template/packages/web/index.html +0 -13
- package/template/packages/web/jest.config.js +0 -27
- package/template/packages/web/jest.setup.js +0 -24
- package/template/packages/web/package.json +0 -69
- package/template/packages/web/src/App.tsx +0 -14
- package/template/packages/web/src/components/TestDemo.tsx +0 -164
- package/template/packages/web/src/main.tsx +0 -27
- package/template/packages/web/src/utils/trpc.ts +0 -7
- package/template/packages/web/tsconfig.json +0 -26
- package/template/packages/web/vite.config.ts +0 -114
- package/template/setup.sh +0 -30
- package/template/tsconfig.json +0 -22
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import SchemaBuilder from '@pothos/core';
|
|
2
|
-
import PrismaPlugin from '@pothos/plugin-prisma';
|
|
3
|
-
import RelayPlugin from '@pothos/plugin-relay';
|
|
4
|
-
import ValidationPlugin from '@pothos/plugin-validation';
|
|
5
|
-
import type PrismaTypes from './generated.js';
|
|
6
|
-
import { prisma } from '../lib/database.js';
|
|
7
|
-
import type { Context } from '../context.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Pothos Schema Builder
|
|
11
|
-
*
|
|
12
|
-
* This is the central schema builder for GraphQL. It integrates with:
|
|
13
|
-
* - Prisma: Auto-generates types from your database models
|
|
14
|
-
* - Relay: Provides connection/pagination patterns
|
|
15
|
-
* - Validation: Integrates with Zod for input validation
|
|
16
|
-
*
|
|
17
|
-
* The builder is configured with your Prisma client and context type,
|
|
18
|
-
* enabling full type safety between your database and GraphQL schema.
|
|
19
|
-
*/
|
|
20
|
-
export const builder = new SchemaBuilder<{
|
|
21
|
-
PrismaTypes: PrismaTypes;
|
|
22
|
-
Context: Context;
|
|
23
|
-
Scalars: {
|
|
24
|
-
DateTime: {
|
|
25
|
-
Input: Date;
|
|
26
|
-
Output: Date;
|
|
27
|
-
};
|
|
28
|
-
JSON: {
|
|
29
|
-
Input: unknown;
|
|
30
|
-
Output: unknown;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
}>({
|
|
34
|
-
plugins: [PrismaPlugin, RelayPlugin, ValidationPlugin],
|
|
35
|
-
prisma: {
|
|
36
|
-
client: prisma,
|
|
37
|
-
// Use cursor-based pagination by default
|
|
38
|
-
exposeDescriptions: true,
|
|
39
|
-
// Filter out internal Prisma fields
|
|
40
|
-
filterConnectionTotalCount: true,
|
|
41
|
-
},
|
|
42
|
-
relay: {
|
|
43
|
-
// Configure Relay-style connections
|
|
44
|
-
clientMutationId: 'omit',
|
|
45
|
-
cursorType: 'String',
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Add custom scalars
|
|
50
|
-
builder.scalarType('DateTime', {
|
|
51
|
-
serialize: (value) => value.toISOString(),
|
|
52
|
-
parseValue: (value) => {
|
|
53
|
-
if (typeof value !== 'string') {
|
|
54
|
-
throw new Error('DateTime must be a string');
|
|
55
|
-
}
|
|
56
|
-
return new Date(value);
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
builder.scalarType('JSON', {
|
|
61
|
-
serialize: (value) => value,
|
|
62
|
-
parseValue: (value) => value,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Initialize Query and Mutation types
|
|
66
|
-
// These will be extended by individual type definitions
|
|
67
|
-
builder.queryType({
|
|
68
|
-
description: 'The root query type',
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
builder.mutationType({
|
|
72
|
-
description: 'The root mutation type',
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export default builder;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pothos Prisma Types
|
|
3
|
-
*
|
|
4
|
-
* This file provides type definitions for the Pothos Prisma plugin.
|
|
5
|
-
* It maps your Prisma models to Pothos types.
|
|
6
|
-
*
|
|
7
|
-
* NOTE: For production use with many models, consider using the official
|
|
8
|
-
* Pothos Prisma generator: https://pothos-graphql.dev/docs/plugins/prisma
|
|
9
|
-
*
|
|
10
|
-
* Add to your schema.prisma:
|
|
11
|
-
* generator pothos {
|
|
12
|
-
* provider = "prisma-pothos-types"
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { Prisma } from '@{{workspaceScope}}/database/client';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Prisma model type definitions for Pothos
|
|
20
|
-
*
|
|
21
|
-
* This maps each Prisma model to its Pothos type configuration.
|
|
22
|
-
* The Shape type defines the fields available on the model.
|
|
23
|
-
*
|
|
24
|
-
* Add new models here as you create them in your Prisma schema.
|
|
25
|
-
* Example for a model with relations:
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* Product: {
|
|
29
|
-
* Name: 'Product';
|
|
30
|
-
* Shape: Prisma.ProductGetPayload<object>;
|
|
31
|
-
* Include: Prisma.ProductInclude;
|
|
32
|
-
* Select: Prisma.ProductSelect;
|
|
33
|
-
* OrderBy: Prisma.ProductOrderByWithRelationInput[];
|
|
34
|
-
* WhereUnique: Prisma.ProductWhereUniqueInput;
|
|
35
|
-
* Where: Prisma.ProductWhereInput;
|
|
36
|
-
* Create: Prisma.ProductCreateInput;
|
|
37
|
-
* Update: Prisma.ProductUpdateInput;
|
|
38
|
-
* RelationName: 'category' | 'orders';
|
|
39
|
-
* ListRelations: 'orders';
|
|
40
|
-
* Relations: {
|
|
41
|
-
* category: { Shape: Prisma.CategoryGetPayload<object>; Name: 'Category'; Nullable: false };
|
|
42
|
-
* orders: { Shape: Prisma.OrderGetPayload<object>[]; Name: 'Order'; Nullable: false };
|
|
43
|
-
* };
|
|
44
|
-
* };
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
type PrismaTypes = {
|
|
48
|
-
Test: {
|
|
49
|
-
Name: 'Test';
|
|
50
|
-
Shape: Prisma.TestGetPayload<object>;
|
|
51
|
-
Include: never; // Test has no relations
|
|
52
|
-
Select: Prisma.TestSelect;
|
|
53
|
-
OrderBy: Prisma.TestOrderByWithRelationInput[];
|
|
54
|
-
WhereUnique: Prisma.TestWhereUniqueInput;
|
|
55
|
-
Where: Prisma.TestWhereInput;
|
|
56
|
-
Create: Prisma.TestCreateInput;
|
|
57
|
-
Update: Prisma.TestUpdateInput;
|
|
58
|
-
RelationName: never;
|
|
59
|
-
ListRelations: never;
|
|
60
|
-
Relations: Record<string, never>;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default PrismaTypes;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { createYoga } from 'graphql-yoga';
|
|
2
|
-
import { builder } from './builder.js';
|
|
3
|
-
import type { Context } from '../context.js';
|
|
4
|
-
|
|
5
|
-
// Import all type definitions to register them with the builder
|
|
6
|
-
import './types/index.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Build the GraphQL Schema
|
|
10
|
-
*
|
|
11
|
-
* The schema is built from all types registered with the Pothos builder.
|
|
12
|
-
* Type definitions are automatically imported from the types directory.
|
|
13
|
-
*/
|
|
14
|
-
export const schema = builder.toSchema();
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* GraphQL Yoga Configuration
|
|
18
|
-
*
|
|
19
|
-
* Creates the GraphQL Yoga server instance configured for use with Express.
|
|
20
|
-
* Yoga handles:
|
|
21
|
-
* - GraphQL query execution
|
|
22
|
-
* - GraphQL Playground (in development)
|
|
23
|
-
* - Subscriptions (WebSocket support)
|
|
24
|
-
* - File uploads (multipart requests)
|
|
25
|
-
* - Batching
|
|
26
|
-
*/
|
|
27
|
-
export interface YogaContext {
|
|
28
|
-
req: Express.Request;
|
|
29
|
-
res: Express.Response;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const yoga = createYoga<YogaContext>({
|
|
33
|
-
schema,
|
|
34
|
-
// GraphQL endpoint path (will be mounted at /graphql in server.ts)
|
|
35
|
-
graphqlEndpoint: '/graphql',
|
|
36
|
-
|
|
37
|
-
// Enable GraphiQL playground in development
|
|
38
|
-
graphiql: process.env.NODE_ENV !== 'production',
|
|
39
|
-
|
|
40
|
-
// Landing page configuration
|
|
41
|
-
landingPage: process.env.NODE_ENV !== 'production',
|
|
42
|
-
|
|
43
|
-
// Context factory - creates the context for each request
|
|
44
|
-
context: async ({ req, res }): Promise<Context> => {
|
|
45
|
-
return {
|
|
46
|
-
req: req as any,
|
|
47
|
-
res: res as any,
|
|
48
|
-
// Add additional context here (e.g., authenticated user)
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// Logging configuration
|
|
53
|
-
logging: {
|
|
54
|
-
debug: (...args) => {
|
|
55
|
-
if (process.env.NODE_ENV === 'development') {
|
|
56
|
-
console.debug('[GraphQL]', ...args);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
info: (...args) => console.info('[GraphQL]', ...args),
|
|
60
|
-
warn: (...args) => console.warn('[GraphQL]', ...args),
|
|
61
|
-
error: (...args) => console.error('[GraphQL]', ...args),
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// Enable CORS handling (coordinate with Express CORS)
|
|
65
|
-
cors: false, // Let Express handle CORS
|
|
66
|
-
|
|
67
|
-
// Mask errors in production
|
|
68
|
-
maskedErrors: process.env.NODE_ENV === 'production',
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Export schema for testing and introspection
|
|
72
|
-
export { schema as graphqlSchema };
|
|
73
|
-
|
|
74
|
-
// Export builder for extensions
|
|
75
|
-
export { builder } from './builder.js';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GraphQL Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* This file imports and registers all GraphQL types with the schema builder.
|
|
5
|
-
* Each type file defines Prisma model mappings and their queries/mutations.
|
|
6
|
-
*
|
|
7
|
-
* The Test type demonstrates the GraphQL equivalent of the tRPC test router,
|
|
8
|
-
* showing how both APIs can expose the same functionality.
|
|
9
|
-
*
|
|
10
|
-
* To add a new type:
|
|
11
|
-
* 1. Create a new file in this directory (e.g., `product.ts`)
|
|
12
|
-
* 2. Define the Prisma object type and any queries/mutations
|
|
13
|
-
* 3. Import the file here to register it with the schema
|
|
14
|
-
*
|
|
15
|
-
* Example:
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // product.ts
|
|
18
|
-
* builder.prismaObject('Product', {
|
|
19
|
-
* fields: (t) => ({
|
|
20
|
-
* id: t.exposeID('id'),
|
|
21
|
-
* name: t.exposeString('name'),
|
|
22
|
-
* }),
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
// =============================================================================
|
|
28
|
-
// Active Type Definitions
|
|
29
|
-
// =============================================================================
|
|
30
|
-
|
|
31
|
-
// Test model - demonstrates GraphQL equivalent of tRPC CRUD router
|
|
32
|
-
import './test.js';
|
|
33
|
-
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// Additional Types
|
|
36
|
-
// =============================================================================
|
|
37
|
-
|
|
38
|
-
// Add additional type imports here as you create them.
|
|
39
|
-
// Example:
|
|
40
|
-
// import './product.js';
|
|
41
|
-
// import './order.js';
|
|
42
|
-
|
|
43
|
-
// Re-export builder for convenience
|
|
44
|
-
export { builder } from '../builder.js';
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { builder } from '../builder.js';
|
|
2
|
-
import { prisma } from '../../lib/database.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Test GraphQL Type
|
|
6
|
-
*
|
|
7
|
-
* This is the GraphQL equivalent of the tRPC test router (src/routers/test.ts).
|
|
8
|
-
* Both APIs provide the same CRUD operations for the Test model.
|
|
9
|
-
*
|
|
10
|
-
* GraphQL Queries (equivalent to tRPC queries):
|
|
11
|
-
* - test(id) → trpc.test.getById({ id })
|
|
12
|
-
* - tests(skip, take) → trpc.test.getAll({ skip, take })
|
|
13
|
-
* - testCount → trpc.test.count({})
|
|
14
|
-
*
|
|
15
|
-
* GraphQL Mutations (equivalent to tRPC mutations):
|
|
16
|
-
* - createTest(input) → trpc.test.create(data)
|
|
17
|
-
* - updateTest(id, input) → trpc.test.update({ id, data })
|
|
18
|
-
* - deleteTest(id) → trpc.test.delete({ id })
|
|
19
|
-
*
|
|
20
|
-
* Example GraphQL queries:
|
|
21
|
-
*
|
|
22
|
-
* ```graphql
|
|
23
|
-
* # Get all tests (equivalent to trpc.test.getAll.useQuery({ take: 10 }))
|
|
24
|
-
* query {
|
|
25
|
-
* tests(take: 10) {
|
|
26
|
-
* id
|
|
27
|
-
* name
|
|
28
|
-
* message
|
|
29
|
-
* status
|
|
30
|
-
* createdAt
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* # Get test by ID (equivalent to trpc.test.getById.useQuery({ id: 'xxx' }))
|
|
35
|
-
* query {
|
|
36
|
-
* test(id: "test-id") {
|
|
37
|
-
* id
|
|
38
|
-
* name
|
|
39
|
-
* message
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
*
|
|
43
|
-
* # Create test (equivalent to trpc.test.create.useMutation())
|
|
44
|
-
* mutation {
|
|
45
|
-
* createTest(input: {
|
|
46
|
-
* name: "My Test"
|
|
47
|
-
* message: "Hello World"
|
|
48
|
-
* status: "active"
|
|
49
|
-
* }) {
|
|
50
|
-
* id
|
|
51
|
-
* name
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* # Update test (equivalent to trpc.test.update.useMutation())
|
|
56
|
-
* mutation {
|
|
57
|
-
* updateTest(id: "test-id", input: { name: "Updated Name" }) {
|
|
58
|
-
* id
|
|
59
|
-
* name
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
* # Delete test (equivalent to trpc.test.delete.useMutation())
|
|
64
|
-
* mutation {
|
|
65
|
-
* deleteTest(id: "test-id") {
|
|
66
|
-
* id
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
// =============================================================================
|
|
73
|
-
// Type Definition
|
|
74
|
-
// =============================================================================
|
|
75
|
-
|
|
76
|
-
const TestType = builder.prismaObject('Test', {
|
|
77
|
-
description: 'A test record for API testing',
|
|
78
|
-
fields: (t) => ({
|
|
79
|
-
id: t.exposeID('id', { description: 'Unique identifier' }),
|
|
80
|
-
name: t.exposeString('name', { description: 'Name of the test' }),
|
|
81
|
-
message: t.exposeString('message', { description: 'Test message content' }),
|
|
82
|
-
status: t.exposeString('status', { description: 'Status: "active" or "inactive"' }),
|
|
83
|
-
createdAt: t.expose('createdAt', { type: 'DateTime', description: 'Creation timestamp' }),
|
|
84
|
-
updatedAt: t.expose('updatedAt', { type: 'DateTime', description: 'Last update timestamp' }),
|
|
85
|
-
}),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// =============================================================================
|
|
89
|
-
// Queries (equivalent to tRPC queries)
|
|
90
|
-
// =============================================================================
|
|
91
|
-
|
|
92
|
-
builder.queryFields((t) => ({
|
|
93
|
-
// Equivalent to: trpc.test.getById({ id })
|
|
94
|
-
test: t.field({
|
|
95
|
-
type: TestType,
|
|
96
|
-
nullable: true,
|
|
97
|
-
description: 'Get a single test by ID',
|
|
98
|
-
args: {
|
|
99
|
-
id: t.arg.string({ required: true, description: 'The test ID' }),
|
|
100
|
-
},
|
|
101
|
-
resolve: async (_root, args) => {
|
|
102
|
-
return prisma.test.findUnique({
|
|
103
|
-
where: { id: args.id },
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
|
|
108
|
-
// Equivalent to: trpc.test.getAll({ skip, take, orderBy })
|
|
109
|
-
tests: t.field({
|
|
110
|
-
type: [TestType],
|
|
111
|
-
description: 'Get all tests with pagination',
|
|
112
|
-
args: {
|
|
113
|
-
skip: t.arg.int({ description: 'Number of records to skip' }),
|
|
114
|
-
take: t.arg.int({ description: 'Number of records to take (default: 10, max: 100)' }),
|
|
115
|
-
orderBy: t.arg.string({ description: 'Field to order by (e.g., "createdAt")' }),
|
|
116
|
-
orderDir: t.arg.string({ description: 'Order direction: "asc" or "desc" (default: "desc")' }),
|
|
117
|
-
},
|
|
118
|
-
resolve: async (_root, args) => {
|
|
119
|
-
const take = Math.min(args.take ?? 10, 100);
|
|
120
|
-
const orderField = args.orderBy ?? 'createdAt';
|
|
121
|
-
const orderDir = args.orderDir === 'asc' ? 'asc' : 'desc';
|
|
122
|
-
|
|
123
|
-
return prisma.test.findMany({
|
|
124
|
-
...(args.skip != null ? { skip: args.skip } : {}),
|
|
125
|
-
take,
|
|
126
|
-
orderBy: { [orderField]: orderDir },
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
}),
|
|
130
|
-
|
|
131
|
-
// Equivalent to: trpc.test.count({ where })
|
|
132
|
-
testCount: t.int({
|
|
133
|
-
description: 'Get total count of test records',
|
|
134
|
-
args: {
|
|
135
|
-
status: t.arg.string({ description: 'Filter by status' }),
|
|
136
|
-
},
|
|
137
|
-
resolve: async (_root, args) => {
|
|
138
|
-
return prisma.test.count({
|
|
139
|
-
...(args.status != null ? { where: { status: args.status } } : {}),
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
}),
|
|
143
|
-
}));
|
|
144
|
-
|
|
145
|
-
// =============================================================================
|
|
146
|
-
// Input Types
|
|
147
|
-
// =============================================================================
|
|
148
|
-
|
|
149
|
-
const CreateTestInput = builder.inputType('CreateTestInput', {
|
|
150
|
-
description: 'Input for creating a new test',
|
|
151
|
-
fields: (t) => ({
|
|
152
|
-
name: t.string({ required: true, description: 'Name of the test (required)' }),
|
|
153
|
-
message: t.string({ required: true, description: 'Test message content (required)' }),
|
|
154
|
-
status: t.string({ defaultValue: 'active', description: 'Status: "active" or "inactive" (default: "active")' }),
|
|
155
|
-
}),
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const UpdateTestInput = builder.inputType('UpdateTestInput', {
|
|
159
|
-
description: 'Input for updating an existing test',
|
|
160
|
-
fields: (t) => ({
|
|
161
|
-
name: t.string({ description: 'New name (optional)' }),
|
|
162
|
-
message: t.string({ description: 'New message (optional)' }),
|
|
163
|
-
status: t.string({ description: 'New status (optional)' }),
|
|
164
|
-
}),
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// =============================================================================
|
|
168
|
-
// Mutations (equivalent to tRPC mutations)
|
|
169
|
-
// =============================================================================
|
|
170
|
-
|
|
171
|
-
builder.mutationFields((t) => ({
|
|
172
|
-
// Equivalent to: trpc.test.create(data)
|
|
173
|
-
createTest: t.field({
|
|
174
|
-
type: TestType,
|
|
175
|
-
description: 'Create a new test record',
|
|
176
|
-
args: {
|
|
177
|
-
input: t.arg({ type: CreateTestInput, required: true }),
|
|
178
|
-
},
|
|
179
|
-
resolve: async (_root, args) => {
|
|
180
|
-
return prisma.test.create({
|
|
181
|
-
data: {
|
|
182
|
-
name: args.input.name,
|
|
183
|
-
message: args.input.message,
|
|
184
|
-
status: args.input.status ?? 'active',
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
}),
|
|
189
|
-
|
|
190
|
-
// Equivalent to: trpc.test.update({ id, data })
|
|
191
|
-
updateTest: t.field({
|
|
192
|
-
type: TestType,
|
|
193
|
-
nullable: true,
|
|
194
|
-
description: 'Update an existing test record',
|
|
195
|
-
args: {
|
|
196
|
-
id: t.arg.string({ required: true, description: 'The test ID to update' }),
|
|
197
|
-
input: t.arg({ type: UpdateTestInput, required: true }),
|
|
198
|
-
},
|
|
199
|
-
resolve: async (_root, args) => {
|
|
200
|
-
// Check if record exists
|
|
201
|
-
const existing = await prisma.test.findUnique({
|
|
202
|
-
where: { id: args.id },
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (!existing) {
|
|
206
|
-
throw new Error('Test not found');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Build update data only with defined values
|
|
210
|
-
const updateData: { name?: string; message?: string; status?: string } = {};
|
|
211
|
-
if (args.input.name != null) updateData.name = args.input.name;
|
|
212
|
-
if (args.input.message != null) updateData.message = args.input.message;
|
|
213
|
-
if (args.input.status != null) updateData.status = args.input.status;
|
|
214
|
-
|
|
215
|
-
return prisma.test.update({
|
|
216
|
-
where: { id: args.id },
|
|
217
|
-
data: updateData,
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
}),
|
|
221
|
-
|
|
222
|
-
// Equivalent to: trpc.test.delete({ id })
|
|
223
|
-
deleteTest: t.field({
|
|
224
|
-
type: TestType,
|
|
225
|
-
nullable: true,
|
|
226
|
-
description: 'Delete a test record',
|
|
227
|
-
args: {
|
|
228
|
-
id: t.arg.string({ required: true, description: 'The test ID to delete' }),
|
|
229
|
-
},
|
|
230
|
-
resolve: async (_root, args) => {
|
|
231
|
-
// Check if record exists
|
|
232
|
-
const existing = await prisma.test.findUnique({
|
|
233
|
-
where: { id: args.id },
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
if (!existing) {
|
|
237
|
-
throw new Error('Test not found');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return prisma.test.delete({
|
|
241
|
-
where: { id: args.id },
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
}),
|
|
245
|
-
}));
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Main exports for the API
|
|
2
|
-
|
|
3
|
-
// ============================================
|
|
4
|
-
// tRPC Exports
|
|
5
|
-
// ============================================
|
|
6
|
-
export { appRouter } from './router/index.js';
|
|
7
|
-
export type { AppRouter } from './router/index.js';
|
|
8
|
-
|
|
9
|
-
// Export tRPC utilities for creating routers
|
|
10
|
-
export { router, publicProcedure } from './trpc.js';
|
|
11
|
-
|
|
12
|
-
// ============================================
|
|
13
|
-
// GraphQL Exports
|
|
14
|
-
// ============================================
|
|
15
|
-
export { schema as graphqlSchema, yoga, builder } from './graphql/index.js';
|
|
16
|
-
|
|
17
|
-
// ============================================
|
|
18
|
-
// Shared Exports
|
|
19
|
-
// ============================================
|
|
20
|
-
|
|
21
|
-
// Export context types for client usage
|
|
22
|
-
export type { Context } from './context.js';
|
|
23
|
-
export { createContext, createGraphQLContext } from './context.js';
|
|
24
|
-
|
|
25
|
-
// Export Prisma client for direct database access if needed
|
|
26
|
-
export { prisma } from './lib/database.js';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PrismaClient } from '@{{workspaceScope}}/database/client';
|
|
2
|
-
|
|
3
|
-
// Initialize Prisma Client
|
|
4
|
-
declare global {
|
|
5
|
-
// eslint-disable-next-line no-var
|
|
6
|
-
var __prisma: PrismaClient | undefined;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Prevent multiple instances of Prisma Client in development
|
|
10
|
-
export const prisma: PrismaClient = globalThis.__prisma ?? new PrismaClient({
|
|
11
|
-
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
-
globalThis.__prisma = prisma;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Graceful shutdown
|
|
19
|
-
process.on('beforeExit', async () => {
|
|
20
|
-
await prisma.$disconnect();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export default prisma;
|