@teamvortexsoftware/vortex-nextjs-15-sdk 0.0.2 → 0.0.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/README.md CHANGED
@@ -38,7 +38,7 @@ lib/
38
38
 
39
39
  Each route file is just 3 lines:
40
40
  ```typescript
41
- import 'lib/vortex-config';
41
+ import '@/lib/vortex-config';
42
42
  import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
43
43
 
44
44
  export const { GET, DELETE } = createVortexRoutes().invitation;
@@ -170,7 +170,7 @@ Need custom logic? Create your own routes:
170
170
 
171
171
  ```typescript
172
172
  // app/api/custom-invitation/route.ts
173
- import 'lib/vortex-config';
173
+ import '@/lib/vortex-config';
174
174
  import { handleGetInvitation, createErrorResponse } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
175
175
 
176
176
  export async function GET(request: NextRequest) {
@@ -189,7 +189,7 @@ export async function GET(request: NextRequest) {
189
189
 
190
190
  ### Build Errors
191
191
  If you see configuration errors during build:
192
- - Make sure you're importing `'lib/vortex-config'` in your layout
192
+ - Make sure you're importing `'@/lib/vortex-config'` (or `'../lib/vortex-config'`) in your layout
193
193
  - Check that your `.env.local` has `VORTEX_API_KEY`
194
194
  - Ensure you're using lazy initialization (`configureVortexLazy`)
195
195
 
@@ -0,0 +1,200 @@
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
+ function createRouteTemplates(baseDir) {
16
+ const configImport = baseDir ? '@/lib/vortex-config' : '@/lib/vortex-config';
17
+
18
+ return {
19
+ 'jwt/route.ts': `import '${configImport}';
20
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
21
+
22
+ export const { POST } = createVortexRoutes().jwt;
23
+ `,
24
+
25
+ 'invitations/route.ts': `import '${configImport}';
26
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
27
+
28
+ export const { GET } = createVortexRoutes().invitations;
29
+ `,
30
+
31
+ 'invitations/[invitationId]/route.ts': `import '${configImport}';
32
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
33
+
34
+ export const { GET, DELETE } = createVortexRoutes().invitation;
35
+ `,
36
+
37
+ 'invitations/accept/route.ts': `import '${configImport}';
38
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
39
+
40
+ export const { POST } = createVortexRoutes().invitationsAccept;
41
+ `,
42
+
43
+ 'invitations/by-group/[groupType]/[groupId]/route.ts': `import '${configImport}';
44
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
45
+
46
+ export const { GET, DELETE } = createVortexRoutes().invitationsByGroup;
47
+ `,
48
+
49
+ 'invitations/[invitationId]/reinvite/route.ts': `import '${configImport}';
50
+ import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
51
+
52
+ export const { POST } = createVortexRoutes().invitationReinvite;
53
+ `
54
+ };
55
+ }
56
+
57
+ const CONFIG_TEMPLATE = `import {
58
+ configureVortexLazy,
59
+ createAllowAllAccessControl,
60
+ type VortexConfig,
61
+ } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
62
+
63
+ // Configure Vortex with lazy initialization - only runs when first API call is made
64
+ configureVortexLazy(async (): Promise<VortexConfig> => {
65
+ return {
66
+ apiKey: process.env.VORTEX_API_KEY!,
67
+
68
+ // Required: How to authenticate users for JWT generation
69
+ authenticateUser: async (request) => {
70
+ // TODO: Replace this with your authentication logic
71
+ //
72
+ // Examples:
73
+ // - NextAuth.js: const session = await getServerSession(request, authOptions);
74
+ // - Supabase: const { data: { user } } = await supabase.auth.getUser();
75
+ // - Custom JWT: const user = await verifyJwtToken(request);
76
+ //
77
+ // Expected return format:
78
+ // return {
79
+ // userId: user.id,
80
+ // identifiers: [{ type: 'email', value: user.email }],
81
+ // groups: [{ type: 'team', id: 'team-123', name: 'My Team' }],
82
+ // };
83
+
84
+ throw new Error('TODO: Implement authenticateUser in lib/vortex-config.ts');
85
+ },
86
+
87
+ // Simple access control - allows all operations (customize for production)
88
+ ...createAllowAllAccessControl(),
89
+
90
+ // For production, replace createAllowAllAccessControl() with custom logic:
91
+ // canDeleteInvitation: async (request, user, resource) => {
92
+ // return user?.role === 'admin';
93
+ // },
94
+ // canAccessInvitationsByGroup: async (request, user, resource) => {
95
+ // return user?.groups.some(g =>
96
+ // g.type === resource?.groupType && g.id === resource?.groupId
97
+ // );
98
+ // },
99
+ // ... other access control hooks
100
+ };
101
+ });
102
+ `;
103
+
104
+ function createDirectory(dirPath) {
105
+ if (!fs.existsSync(dirPath)) {
106
+ fs.mkdirSync(dirPath, { recursive: true });
107
+ console.log(`✓ Created directory: ${dirPath}`);
108
+ }
109
+ }
110
+
111
+ function writeFileIfNotExists(filePath, content) {
112
+ if (fs.existsSync(filePath)) {
113
+ console.log(`⚠ File already exists, skipping: ${filePath}`);
114
+ return false;
115
+ }
116
+
117
+ fs.writeFileSync(filePath, content);
118
+ console.log(`✓ Created file: ${filePath}`);
119
+ return true;
120
+ }
121
+
122
+ function main() {
123
+ console.log('🚀 Setting up Vortex Next.js 15 SDK...\n');
124
+
125
+ // Check if we're in a Next.js project
126
+ if (!fs.existsSync('next.config.js') && !fs.existsSync('next.config.ts') && !fs.existsSync('next.config.mjs')) {
127
+ console.error('❌ This doesn\'t appear to be a Next.js project. Make sure you\'re in the root directory.');
128
+ process.exit(1);
129
+ }
130
+
131
+ // Check for app directory - support both root app/ and src/app/
132
+ let baseDir = '';
133
+ if (fs.existsSync('app')) {
134
+ baseDir = '';
135
+ console.log('✓ Found app directory at project root');
136
+ } else if (fs.existsSync('src/app')) {
137
+ baseDir = 'src';
138
+ console.log('✓ Found app directory in src/');
139
+ } else {
140
+ console.error('❌ This setup requires Next.js App Router. Please ensure you have an "app" or "src/app" directory.');
141
+ process.exit(1);
142
+ }
143
+
144
+ let filesCreated = 0;
145
+
146
+ // Create API routes
147
+ const apiDir = path.join(baseDir, 'app', 'api', 'vortex');
148
+ createDirectory(apiDir);
149
+
150
+ const routeTemplates = createRouteTemplates(baseDir);
151
+
152
+ VORTEX_ROUTES.forEach(route => {
153
+ const filePath = path.join(apiDir, route);
154
+ const dirPath = path.dirname(filePath);
155
+
156
+ createDirectory(dirPath);
157
+
158
+ if (writeFileIfNotExists(filePath, routeTemplates[route])) {
159
+ filesCreated++;
160
+ }
161
+ });
162
+
163
+ // Create lib directory and config file
164
+ const libDir = baseDir ? path.join(baseDir, 'lib') : 'lib';
165
+ createDirectory(libDir);
166
+ const configPath = path.join(libDir, 'vortex-config.ts');
167
+
168
+ if (writeFileIfNotExists(configPath, CONFIG_TEMPLATE)) {
169
+ filesCreated++;
170
+ }
171
+
172
+ console.log(`\n🎉 Setup complete! Created ${filesCreated} new files.`);
173
+ console.log('\n📋 Next steps:');
174
+ console.log('1. Add your VORTEX_API_KEY to .env.local:');
175
+ console.log(' VORTEX_API_KEY=your_api_key_here');
176
+
177
+ const layoutPath = baseDir ? `${baseDir}/app/layout.tsx` : 'app/layout.tsx';
178
+ const configImportPath = baseDir ? '../lib/vortex-config' : '../lib/vortex-config';
179
+ const configFilePath = baseDir ? `${baseDir}/lib/vortex-config.ts` : 'lib/vortex-config.ts';
180
+
181
+ console.log(`2. Import the config in your ${layoutPath}:`);
182
+ console.log(` import '${configImportPath}';`);
183
+ console.log(`3. Implement the authenticateUser function in ${configFilePath}`);
184
+ console.log('4. Wrap your app in VortexProvider:');
185
+ console.log(' <VortexProvider config={{ apiBaseUrl: \'/api/vortex\' }}>');
186
+
187
+ console.log('\n✨ Features:');
188
+ console.log('• Super simple - each route is just 3 lines!');
189
+ console.log('• Lazy initialization - no database calls during build');
190
+ console.log('• createAllowAllAccessControl() for easy development');
191
+ console.log('• Full TypeScript support with IntelliSense');
192
+
193
+ console.log('\n📚 See the README for examples and customization options.');
194
+ }
195
+
196
+ if (require.main === module) {
197
+ main();
198
+ }
199
+
200
+ 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.4",
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"