@teamvortexsoftware/vortex-nextjs-15-sdk 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/bin/vortex-setup.js +181 -0
  2. package/package.json +4 -6
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const VORTEX_ROUTES = [
7
+ 'jwt/route.ts',
8
+ 'invitations/route.ts',
9
+ 'invitations/[invitationId]/route.ts',
10
+ 'invitations/accept/route.ts',
11
+ 'invitations/by-group/[groupType]/[groupId]/route.ts',
12
+ 'invitations/[invitationId]/reinvite/route.ts'
13
+ ];
14
+
15
+ const ROUTE_TEMPLATES = {
16
+ 'jwt/route.ts': `import 'lib/vortex-config';
17
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
18
+
19
+ export const { POST } = createVortexRoutes().jwt;
20
+ `,
21
+
22
+ 'invitations/route.ts': `import 'lib/vortex-config';
23
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
24
+
25
+ export const { GET } = createVortexRoutes().invitations;
26
+ `,
27
+
28
+ 'invitations/[invitationId]/route.ts': `import 'lib/vortex-config';
29
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
30
+
31
+ export const { GET, DELETE } = createVortexRoutes().invitation;
32
+ `,
33
+
34
+ 'invitations/accept/route.ts': `import 'lib/vortex-config';
35
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
36
+
37
+ export const { POST } = createVortexRoutes().invitationsAccept;
38
+ `,
39
+
40
+ 'invitations/by-group/[groupType]/[groupId]/route.ts': `import 'lib/vortex-config';
41
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
42
+
43
+ export const { GET, DELETE } = createVortexRoutes().invitationsByGroup;
44
+ `,
45
+
46
+ 'invitations/[invitationId]/reinvite/route.ts': `import 'lib/vortex-config';
47
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
48
+
49
+ export const { POST } = createVortexRoutes().invitationReinvite;
50
+ `
51
+ };
52
+
53
+ const CONFIG_TEMPLATE = `import {
54
+ configureVortexLazy,
55
+ createAllowAllAccessControl,
56
+ type VortexConfig,
57
+ } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
58
+
59
+ // Configure Vortex with lazy initialization - only runs when first API call is made
60
+ configureVortexLazy(async (): Promise<VortexConfig> => {
61
+ return {
62
+ apiKey: process.env.VORTEX_API_KEY!,
63
+
64
+ // Required: How to authenticate users for JWT generation
65
+ authenticateUser: async (request) => {
66
+ // TODO: Replace this with your authentication logic
67
+ //
68
+ // Examples:
69
+ // - NextAuth.js: const session = await getServerSession(request, authOptions);
70
+ // - Supabase: const { data: { user } } = await supabase.auth.getUser();
71
+ // - Custom JWT: const user = await verifyJwtToken(request);
72
+ //
73
+ // Expected return format:
74
+ // return {
75
+ // userId: user.id,
76
+ // identifiers: [{ type: 'email', value: user.email }],
77
+ // groups: [{ type: 'team', id: 'team-123', name: 'My Team' }],
78
+ // };
79
+
80
+ throw new Error('TODO: Implement authenticateUser in lib/vortex-config.ts');
81
+ },
82
+
83
+ // Simple access control - allows all operations (customize for production)
84
+ ...createAllowAllAccessControl(),
85
+
86
+ // For production, replace createAllowAllAccessControl() with custom logic:
87
+ // canDeleteInvitation: async (request, user, resource) => {
88
+ // return user?.role === 'admin';
89
+ // },
90
+ // canAccessInvitationsByGroup: async (request, user, resource) => {
91
+ // return user?.groups.some(g =>
92
+ // g.type === resource?.groupType && g.id === resource?.groupId
93
+ // );
94
+ // },
95
+ // ... other access control hooks
96
+ };
97
+ });
98
+ `;
99
+
100
+ function createDirectory(dirPath) {
101
+ if (!fs.existsSync(dirPath)) {
102
+ fs.mkdirSync(dirPath, { recursive: true });
103
+ console.log(`✓ Created directory: ${dirPath}`);
104
+ }
105
+ }
106
+
107
+ function writeFileIfNotExists(filePath, content) {
108
+ if (fs.existsSync(filePath)) {
109
+ console.log(`⚠ File already exists, skipping: ${filePath}`);
110
+ return false;
111
+ }
112
+
113
+ fs.writeFileSync(filePath, content);
114
+ console.log(`✓ Created file: ${filePath}`);
115
+ return true;
116
+ }
117
+
118
+ function main() {
119
+ console.log('🚀 Setting up Vortex Next.js 15 SDK...\n');
120
+
121
+ // Check if we're in a Next.js project
122
+ if (!fs.existsSync('next.config.js') && !fs.existsSync('next.config.ts') && !fs.existsSync('next.config.mjs')) {
123
+ console.error('❌ This doesn\'t appear to be a Next.js project. Make sure you\'re in the root directory.');
124
+ process.exit(1);
125
+ }
126
+
127
+ // Check for app directory
128
+ if (!fs.existsSync('app')) {
129
+ console.error('❌ This setup requires Next.js App Router. Please ensure you have an "app" directory.');
130
+ process.exit(1);
131
+ }
132
+
133
+ let filesCreated = 0;
134
+
135
+ // Create API routes
136
+ const apiDir = path.join('app', 'api', 'vortex');
137
+ createDirectory(apiDir);
138
+
139
+ VORTEX_ROUTES.forEach(route => {
140
+ const filePath = path.join(apiDir, route);
141
+ const dirPath = path.dirname(filePath);
142
+
143
+ createDirectory(dirPath);
144
+
145
+ if (writeFileIfNotExists(filePath, ROUTE_TEMPLATES[route])) {
146
+ filesCreated++;
147
+ }
148
+ });
149
+
150
+ // Create lib directory and config file
151
+ createDirectory('lib');
152
+ const configPath = path.join('lib', 'vortex-config.ts');
153
+
154
+ if (writeFileIfNotExists(configPath, CONFIG_TEMPLATE)) {
155
+ filesCreated++;
156
+ }
157
+
158
+ console.log(`\n🎉 Setup complete! Created ${filesCreated} new files.`);
159
+ console.log('\n📋 Next steps:');
160
+ console.log('1. Add your VORTEX_API_KEY to .env.local:');
161
+ console.log(' VORTEX_API_KEY=your_api_key_here');
162
+ console.log('2. Import the config in your app/layout.tsx:');
163
+ console.log(' import \'../lib/vortex-config\';');
164
+ console.log('3. Implement the authenticateUser function in lib/vortex-config.ts');
165
+ console.log('4. Wrap your app in VortexProvider:');
166
+ console.log(' <VortexProvider config={{ apiBaseUrl: \'/api/vortex\' }}>');
167
+
168
+ console.log('\n✨ Features:');
169
+ console.log('• Super simple - each route is just 3 lines!');
170
+ console.log('• Lazy initialization - no database calls during build');
171
+ console.log('• createAllowAllAccessControl() for easy development');
172
+ console.log('• Full TypeScript support with IntelliSense');
173
+
174
+ console.log('\n📚 See the README for examples and customization options.');
175
+ }
176
+
177
+ if (require.main === module) {
178
+ main();
179
+ }
180
+
181
+ module.exports = { main };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@teamvortexsoftware/vortex-nextjs-15-sdk",
3
3
  "description": "Drop-in Next.js module for Vortex API integration",
4
4
  "author": "@teamvortexsoftware",
5
- "version": "0.0.2",
5
+ "version": "0.0.3",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "bin": {
@@ -21,10 +21,10 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "build:stg": "pnpm run distclean && pnpm run build && mkdir -p dist.d/stg && mv dist dist.d/stg && echo && echo 'Build in ./dist.d/stg'",
24
- "prepublish:stg": "cp ./LICENSE ./README.md ./dist.d/stg/ && jq '.name = \"@teamvortexsoftware/vortex-nextjs-15-sdk-stg\" | .description = \"Vortex NextJS 15 SDK (STG)\" | del(.scripts.prepack)' ./package.json > ./dist.d/stg/package.json",
24
+ "prepublish:stg": "cp ./LICENSE ./README.md ./dist.d/stg/ && cp -r ./bin ./dist.d/stg/ && jq '.name = \"@teamvortexsoftware/vortex-nextjs-15-sdk-stg\" | .description = \"Vortex NextJS 15 SDK (STG)\" | del(.devDependencies.\"@teamvortexsoftware/eslint-config\") | del(.devDependencies.\"@teamvortexsoftware/typescript-config\") | .dependencies.\"@teamvortexsoftware/vortex-node-22-sdk\" = \"^0.0.3\" | del(.scripts.prepack)' ./package.json > ./dist.d/stg/package.json",
25
25
  "publish:stg": "pnpm run prepublish:stg && npm publish --userconfig ../../.npmrc --access restricted ./dist.d/stg",
26
26
  "build:prod": "pnpm run distclean && pnpm run build && mkdir -p dist.d/prod && mv dist dist.d/prod && echo && echo 'Build in ./dist.d/prod'",
27
- "prepublish:prod": "cp ./LICENSE ./README.md ./dist.d/prod/ && jq 'del(.scripts.prepack)' ./package.json > ./dist.d/prod/package.json",
27
+ "prepublish:prod": "cp ./LICENSE ./README.md ./dist.d/prod/ && cp -r ./bin ./dist.d/prod/ && jq 'del(.devDependencies.\"@teamvortexsoftware/eslint-config\") | del(.devDependencies.\"@teamvortexsoftware/typescript-config\") | .dependencies.\"@teamvortexsoftware/vortex-node-22-sdk\" = \"^0.0.3\" | del(.scripts.prepack)' ./package.json > ./dist.d/prod/package.json",
28
28
  "publish:prod": "pnpm run prepublish:prod && npm publish --userconfig ../../.npmrc --access public ./dist.d/prod",
29
29
  "check-types": "tsc --noEmit",
30
30
  "distclean": "rm -rf ./dist ./dist.d",
@@ -49,8 +49,6 @@
49
49
  "devDependencies": {
50
50
  "@eslint/js": "^9.24.0",
51
51
  "@jest/globals": "29.7.0",
52
- "@teamvortexsoftware/eslint-config": "workspace:*",
53
- "@teamvortexsoftware/typescript-config": "workspace:*",
54
52
  "eslint": "^9.24.0",
55
53
  "jest": "29.7.0",
56
54
  "typescript-eslint": "^8.30.1",
@@ -59,7 +57,7 @@
59
57
  "typescript": "^5.0.0"
60
58
  },
61
59
  "dependencies": {
62
- "@teamvortexsoftware/vortex-node-22-sdk": "workspace:*"
60
+ "@teamvortexsoftware/vortex-node-22-sdk": "^0.0.3"
63
61
  },
64
62
  "peerDependencies": {
65
63
  "next": ">=13.0.0"