@seeka-labs/cli-apps 3.8.2 → 3.8.6
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/ai-context/internal/examples/_index.md +1 -1
- package/dist/ai-context/internal/examples/v1/activecampaign/_ai-summary.md +25 -32
- package/dist/ai-context/internal/examples/v1/complianz/_ai-summary.md +17 -23
- package/dist/ai-context/internal/examples/v1/ivvy/_ai-summary.md +20 -19
- package/dist/ai-context/internal/examples/v1/me-and-u-connect/_ai-summary.md +18 -16
- package/dist/ai-context/internal/examples/v1/me-and-u-manage/_ai-summary.md +22 -34
- package/dist/ai-context/internal/examples/v1/nowbookit/_ai-summary.md +26 -26
- package/dist/ai-context/internal/examples/v1/sevenrooms/_ai-summary.md +22 -21
- package/dist/ai-context/internal/examples/v1/tradable-bits/_ai-summary.md +20 -22
- package/dist/ai-context/internal/examples/v1/transcend/_ai-summary.md +43 -23
- package/dist/ai-context/internal/examples/v2/calendly/_ai-summary.md +19 -16
- package/dist/ai-context/internal/examples/v2/clarity/_ai-summary.md +14 -21
- package/dist/ai-context/internal/examples/v2/google-bigquery/_ai-summary.md +15 -14
- package/dist/ai-context/internal/examples/v2/klaviyo-events/_ai-summary.md +24 -15
- package/dist/ai-context/internal/examples/v2/navitas/_ai-summary.md +16 -28
- package/dist/ai-context/internal/examples/v2/trustarc/_ai-summary.md +14 -16
- package/dist/ai-context/internal/examples/v2/typeform/_ai-summary.md +20 -19
- package/dist/ai-context/internal/examples/v2/webhook/_ai-summary.md +16 -14
- package/dist/ai-context/internal/examples/v2/yeastar/_ai-summary.md +19 -15
- package/dist/ai-context/internal/examples/v3/google-ads/_ai-summary.md +19 -17
- package/dist/index.cjs +2465 -281
- package/dist/index.cjs.map +4 -4
- package/dist/init-template/README.azurefunc.md +1 -1
- package/dist/init-template/app/browser/package.json +1 -1
- package/dist/init-template/app/lib/package.json +1 -1
- package/dist/init-template/app/server-azurefunc/package.json +1 -1
- package/dist/init-template/app/ui/package.json +1 -1
- package/package.json +5 -2
- package/dist/ai-context/internal/architecture/v1-structure.md +0 -192
- package/dist/ai-context/internal/architecture/v2-structure.md +0 -261
- package/dist/ai-context/internal/architecture/v3-structure.md +0 -386
- package/dist/ai-context/internal/examples/v1/_index.md +0 -53
- package/dist/ai-context/internal/examples/v2/_index.md +0 -66
- package/dist/ai-context/internal/examples/v3/_index.md +0 -105
|
@@ -39,7 +39,7 @@ See `AGENTS.md` for AI assistant instructions.
|
|
|
39
39
|
#### Hydrate Seeka AI context
|
|
40
40
|
Below command will download the latest context files to `.seeka/ai/context/` directory to provide guidance for your app development.
|
|
41
41
|
|
|
42
|
-
`npx @seeka-labs/cli-apps ai context`
|
|
42
|
+
`npx @seeka-labs/cli-apps@latest ai context`
|
|
43
43
|
|
|
44
44
|
## Local Development
|
|
45
45
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seeka-labs/cli-apps",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Seeka - Apps CLI",
|
|
6
6
|
"author": "SEEKA <platform@seeka.co>",
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"build:ci": "yarn build:templates && tsc --noEmit && esbuild src/index.ts --bundle --sourcemap --platform=node --target=node22 --outfile=dist/index.cjs",
|
|
29
29
|
"build": "yarn build:templates && tsc --noEmit && esbuild src/index.ts --bundle --sourcemap --platform=node --target=node22 --outfile=dist/index.cjs",
|
|
30
30
|
"build:templates": "ts-node scripts/build-templates.ts",
|
|
31
|
+
"ai:context:run": "yarn build && node dist/index.cjs ai context",
|
|
32
|
+
"cli:run": "yarn build && node dist/index.cjs",
|
|
31
33
|
"watch": "tsc -w",
|
|
32
34
|
"clean": "rimraf dist",
|
|
33
35
|
"dev": "yarn run clean && yarn build && rimraf seeka-app-test1 && node dist/index.cjs init seeka-app-test1 --template azure-function --email 'dev@seeka.co' --developer Seeka --noDependencies --browser --npmUsername testy --npmPassword passworddd --env 'SEEKA_APP_ID=123' 'SEEKA_APP_SECRET=345' --packageManager yarn",
|
|
@@ -63,7 +65,8 @@
|
|
|
63
65
|
"lodash-es": "^4",
|
|
64
66
|
"source-map-support": "^0",
|
|
65
67
|
"ts-jest": "^29",
|
|
68
|
+
"ts-node": "^10",
|
|
66
69
|
"typescript": "^5"
|
|
67
70
|
},
|
|
68
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "7bb14ccbd1859349c57898ff0ab5b62394cf07b1"
|
|
69
72
|
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# V1 App Template Structure (Legacy)
|
|
2
|
-
|
|
3
|
-
> **⚠️ Legacy Version**: V1 is no longer used for new apps. This documentation is provided for reference when examining existing V1 apps for feature implementation patterns.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
V1 apps were the first generation of Seeka apps. They are **single-package Azure Functions apps** (not monorepos) with all code in a flat `src/` directory structure.
|
|
8
|
-
|
|
9
|
-
## Key Differences from V3
|
|
10
|
-
|
|
11
|
-
| Aspect | V1 | V3 |
|
|
12
|
-
|--------|----|----|
|
|
13
|
-
| Structure | Single package, flat `src/` | Monorepo with `app/` workspaces |
|
|
14
|
-
| Azure Functions | V4 programming model | V4 programming model |
|
|
15
|
-
| Shared code | In `src/lib/` within same package | Separate `app/lib/` package |
|
|
16
|
-
| Browser plugin | Nested in `src/browser/` (if present) | Separate `app/browser/` package |
|
|
17
|
-
| UI component | Not present | Separate `app/ui/` package |
|
|
18
|
-
| Build system | tsc | esbuild with optimizations |
|
|
19
|
-
| Configuration | `host.json` at root | `host.json` in `app/server/` |
|
|
20
|
-
|
|
21
|
-
## V1 Directory Structure
|
|
22
|
-
|
|
23
|
-
V1 apps have two main variants:
|
|
24
|
-
|
|
25
|
-
### Standard V1 (Azure Functions)
|
|
26
|
-
|
|
27
|
-
Most V1 apps follow this structure:
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
your-app-name/
|
|
31
|
-
├── src/
|
|
32
|
-
│ ├── functions/ # Azure Function handlers
|
|
33
|
-
│ │ ├── seekaAppWebhook.ts # Main Seeka webhook
|
|
34
|
-
│ │ ├── healthCheck.ts # Health check endpoint
|
|
35
|
-
│ │ └── [platformWebhook].ts # Platform-specific webhooks (optional)
|
|
36
|
-
│ ├── lib/ # Business logic and utilities
|
|
37
|
-
│ │ ├── logging/
|
|
38
|
-
│ │ │ └── index.ts # Winston logging setup
|
|
39
|
-
│ │ ├── services/
|
|
40
|
-
│ │ │ └── index.ts # Business logic services
|
|
41
|
-
│ │ ├── state/
|
|
42
|
-
│ │ │ ├── seeka/
|
|
43
|
-
│ │ │ │ └── installations.ts # Installation state management
|
|
44
|
-
│ │ │ └── redis/
|
|
45
|
-
│ │ │ └── index.ts # Redis client setup
|
|
46
|
-
│ │ ├── jobs/
|
|
47
|
-
│ │ │ └── index.ts # Background job definitions (optional)
|
|
48
|
-
│ │ ├── models/
|
|
49
|
-
│ │ │ └── index.ts # TypeScript interfaces (optional)
|
|
50
|
-
│ │ └── [platform-name]/ # Platform-specific API clients
|
|
51
|
-
│ │ ├── api/
|
|
52
|
-
│ │ │ └── index.ts
|
|
53
|
-
│ │ └── [feature]/
|
|
54
|
-
│ │ └── index.ts
|
|
55
|
-
│ └── browser/ # Browser plugin (optional, nested package)
|
|
56
|
-
│ ├── src/
|
|
57
|
-
│ │ ├── browser.ts
|
|
58
|
-
│ │ └── plugin/
|
|
59
|
-
│ │ └── index.ts
|
|
60
|
-
│ ├── package.json
|
|
61
|
-
│ ├── tsconfig.json
|
|
62
|
-
│ └── README.md
|
|
63
|
-
├── host.json # Azure Functions host configuration
|
|
64
|
-
├── local.settings.json # Local development settings (gitignored)
|
|
65
|
-
├── package.json # Single package.json for entire app
|
|
66
|
-
├── tsconfig.json
|
|
67
|
-
└── README.md
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Express-based V1 (Alternative)
|
|
71
|
-
|
|
72
|
-
Some V1 apps use Express instead of Azure Functions:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
your-app-name/
|
|
76
|
-
├── src/
|
|
77
|
-
│ ├── app/
|
|
78
|
-
│ │ └── index.ts # Express app setup
|
|
79
|
-
│ ├── routes/ # Express route handlers
|
|
80
|
-
│ │ ├── seekaAppWebhook.ts
|
|
81
|
-
│ │ └── [platformWebhook].ts
|
|
82
|
-
│ ├── lib/ # Same structure as above
|
|
83
|
-
│ │ └── ...
|
|
84
|
-
│ └── index.ts # Entry point
|
|
85
|
-
├── package.json
|
|
86
|
-
├── tsconfig.json
|
|
87
|
-
└── README.md
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Example V1 Apps by Category
|
|
91
|
-
|
|
92
|
-
### Server-only Apps (No Browser Plugin)
|
|
93
|
-
- **activecampaign** - CRM integration with ActiveCampaign
|
|
94
|
-
- **nowbookit** - Booking platform integration
|
|
95
|
-
- **klaviyo-events** (early version pattern)
|
|
96
|
-
|
|
97
|
-
### Apps with Browser Plugin
|
|
98
|
-
- **complianz** - Cookie consent management
|
|
99
|
-
- **sevenrooms** - Restaurant reservation platform
|
|
100
|
-
- **tradable-bits** - Fan engagement platform
|
|
101
|
-
- **transcend** - Privacy/consent management
|
|
102
|
-
|
|
103
|
-
### Express-based Apps
|
|
104
|
-
- **ivvy** - Event venue management (uses Express routes)
|
|
105
|
-
|
|
106
|
-
## Key V1 Patterns
|
|
107
|
-
|
|
108
|
-
### Installation State Management
|
|
109
|
-
|
|
110
|
-
V1 apps typically manage installation state in `src/lib/state/seeka/installations.ts`:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
// src/lib/state/seeka/installations.ts
|
|
114
|
-
import { createClient } from 'redis';
|
|
115
|
-
|
|
116
|
-
export interface AppInstallContext {
|
|
117
|
-
applicationInstallId: string;
|
|
118
|
-
organisationId: string;
|
|
119
|
-
organisationBrandId: string;
|
|
120
|
-
installedAt: string;
|
|
121
|
-
installationState?: {
|
|
122
|
-
grantedPermissions: string[];
|
|
123
|
-
installationSettings: AppInstallationSettings;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const getInstallation = async (installId: string): Promise<AppInstallContext | null> => {
|
|
128
|
-
// Redis-based installation lookup
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const saveInstallation = async (installation: AppInstallContext): Promise<void> => {
|
|
132
|
-
// Redis-based installation storage
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Platform API Clients
|
|
137
|
-
|
|
138
|
-
V1 apps organize platform-specific code in `src/lib/[platform-name]/`:
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
// src/lib/active-campaign/api/index.ts
|
|
142
|
-
export class ActiveCampaignClient {
|
|
143
|
-
constructor(private apiUrl: string, private apiKey: string) {}
|
|
144
|
-
|
|
145
|
-
async createContact(contact: ContactData): Promise<Contact> {
|
|
146
|
-
// API implementation
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Browser Plugin (Nested Package)
|
|
152
|
-
|
|
153
|
-
When present, the browser plugin is a nested package within `src/browser/`:
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
// src/browser/src/plugin/index.ts
|
|
157
|
-
export class AppBrowserPlugin {
|
|
158
|
-
constructor(config: PluginConfig) {
|
|
159
|
-
// Initialize plugin
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Plugin methods for browser-side functionality
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## When to Reference V1 Apps
|
|
167
|
-
|
|
168
|
-
V1 apps contain valuable implementation patterns for:
|
|
169
|
-
|
|
170
|
-
- **External API integrations**: How specific platforms (ActiveCampaign, SevenRooms, etc.) were integrated
|
|
171
|
-
- **Data transformation logic**: Converting Seeka activity data to platform-specific formats
|
|
172
|
-
- **Webhook handling**: Receiving and processing webhooks from external platforms
|
|
173
|
-
- **Queue-based processing**: Background job patterns for async operations
|
|
174
|
-
- **Redis state management**: Installation and session state patterns
|
|
175
|
-
|
|
176
|
-
## Adapting V1 Patterns to V3
|
|
177
|
-
|
|
178
|
-
When using V1 code as reference for a new V3 app:
|
|
179
|
-
|
|
180
|
-
1. **Move shared types** from `src/lib/models/` to `app/lib/src/models/`
|
|
181
|
-
2. **Move validation logic** to `app/lib/src/validation/`
|
|
182
|
-
3. **Move services** from `src/lib/services/` to `app/server/src/app/services/`
|
|
183
|
-
4. **Move API routes** to `app/server/src/app/api/routes/`
|
|
184
|
-
5. **Use SDK utilities** from `@seeka-labs/sdk-apps-server-host` instead of custom implementations
|
|
185
|
-
6. **Replace custom logging** with the SDK's winston-based logging setup
|
|
186
|
-
7. **Move browser plugin** from `src/browser/` to `app/browser/`
|
|
187
|
-
|
|
188
|
-
## See Also
|
|
189
|
-
|
|
190
|
-
- `v2-structure.md` - V2 legacy structure (monorepo introduction)
|
|
191
|
-
- `v3-structure.md` - Current template structure (use for new apps)
|
|
192
|
-
- `../examples/v1/` - V1 example apps for feature reference
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
# V2 App Template Structure (Legacy)
|
|
2
|
-
|
|
3
|
-
> **⚠️ Legacy Version**: V2 is no longer used for new apps. This documentation is provided for reference when examining existing V2 apps for feature implementation patterns.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
V2 apps introduced the **monorepo structure** with separate packages for server, UI, and browser components. V2 apps use Azure Functions V4 programming model (same as V3) but organize code differently.
|
|
8
|
-
|
|
9
|
-
## Key Differences from V3
|
|
10
|
-
|
|
11
|
-
| Aspect | V2 | V3 |
|
|
12
|
-
|--------|----|----|
|
|
13
|
-
| Shared library | Code in `app/server/src/lib/` | Separate `app/lib/` package |
|
|
14
|
-
| Server structure | `src/functions/` + `src/lib/` | `src/functions/` + `src/app/` |
|
|
15
|
-
| Business logic | Mixed in `src/lib/` | Organized in `src/app/` subdirs |
|
|
16
|
-
| SDK usage | Custom implementations | Uses `@seeka-labs/sdk-apps-server-host` |
|
|
17
|
-
| CLI config | Not present | `.seeka/` directory with config |
|
|
18
|
-
|
|
19
|
-
## V2 Directory Structure
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
your-app-name/
|
|
23
|
-
├── app/
|
|
24
|
-
│ ├── browser/ # Browser plugin (optional)
|
|
25
|
-
│ │ ├── src/
|
|
26
|
-
│ │ │ ├── browser.ts # Browser entry point
|
|
27
|
-
│ │ │ └── plugin/
|
|
28
|
-
│ │ │ └── index.ts # Plugin implementation
|
|
29
|
-
│ │ ├── package.json
|
|
30
|
-
│ │ ├── tsconfig.json
|
|
31
|
-
│ │ └── README.md
|
|
32
|
-
│ ├── server/ # Azure Functions server
|
|
33
|
-
│ │ ├── src/
|
|
34
|
-
│ │ │ ├── functions/ # Azure Function handlers
|
|
35
|
-
│ │ │ │ ├── seekaAppWebhook.ts # Main Seeka webhook
|
|
36
|
-
│ │ │ │ ├── healthCheck.ts # Health check endpoint
|
|
37
|
-
│ │ │ │ ├── ui.ts # UI static file serving
|
|
38
|
-
│ │ │ │ ├── [platform]Webhook.ts # Platform webhooks (optional)
|
|
39
|
-
│ │ │ │ ├── [platform]Auth*.ts # OAuth handlers (optional)
|
|
40
|
-
│ │ │ │ └── *QueueHandler.ts # Queue processors (optional)
|
|
41
|
-
│ │ │ └── lib/ # Business logic (V2 style)
|
|
42
|
-
│ │ │ ├── logging/
|
|
43
|
-
│ │ │ │ └── index.ts # Winston logging setup
|
|
44
|
-
│ │ │ ├── services/
|
|
45
|
-
│ │ │ │ └── index.ts # Business logic services
|
|
46
|
-
│ │ │ ├── state/
|
|
47
|
-
│ │ │ │ ├── seeka/
|
|
48
|
-
│ │ │ │ │ └── installations.ts
|
|
49
|
-
│ │ │ │ └── redis/
|
|
50
|
-
│ │ │ │ └── index.ts
|
|
51
|
-
│ │ │ ├── jobs/
|
|
52
|
-
│ │ │ │ └── index.ts # Background job definitions
|
|
53
|
-
│ │ │ ├── models/
|
|
54
|
-
│ │ │ │ └── index.ts # TypeScript interfaces
|
|
55
|
-
│ │ │ ├── browser/
|
|
56
|
-
│ │ │ │ └── index.ts # Browser plugin config
|
|
57
|
-
│ │ │ ├── api/ # REST API routes (optional)
|
|
58
|
-
│ │ │ │ ├── auth.ts
|
|
59
|
-
│ │ │ │ └── routes/
|
|
60
|
-
│ │ │ │ └── *.ts
|
|
61
|
-
│ │ │ └── [platform-name]/ # Platform-specific code
|
|
62
|
-
│ │ │ └── *.ts
|
|
63
|
-
│ │ ├── host.json # Azure Functions host config
|
|
64
|
-
│ │ ├── local.settings.json # Local dev settings (gitignored)
|
|
65
|
-
│ │ ├── package.json
|
|
66
|
-
│ │ ├── tsconfig.json
|
|
67
|
-
│ │ └── README.md
|
|
68
|
-
│ └── ui/ # Configuration UI (optional)
|
|
69
|
-
│ ├── src/
|
|
70
|
-
│ │ ├── main.tsx # React entry point
|
|
71
|
-
│ │ ├── App.tsx # Main App component
|
|
72
|
-
│ │ ├── vite-env.d.ts
|
|
73
|
-
│ │ └── seeka-labs-app-sdk-ui/ # Shared UI utilities
|
|
74
|
-
│ │ ├── utils/
|
|
75
|
-
│ │ └── shared/
|
|
76
|
-
│ ├── public/
|
|
77
|
-
│ │ └── manifest.json
|
|
78
|
-
│ ├── scripts/
|
|
79
|
-
│ │ └── copy-output.mjs
|
|
80
|
-
│ ├── package.json
|
|
81
|
-
│ ├── tsconfig.json
|
|
82
|
-
│ ├── tsconfig.node.json
|
|
83
|
-
│ ├── vite.config.ts
|
|
84
|
-
│ └── README.md
|
|
85
|
-
├── .vscode/ # VS Code configuration (optional)
|
|
86
|
-
│ ├── launch.json
|
|
87
|
-
│ ├── settings.json
|
|
88
|
-
│ ├── extensions.json
|
|
89
|
-
│ └── tasks.json
|
|
90
|
-
├── package.json # Root package.json (workspaces)
|
|
91
|
-
├── tsconfig.json # Root TypeScript config
|
|
92
|
-
└── README.md
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Example V2 Apps by Category
|
|
96
|
-
|
|
97
|
-
### Full-featured Apps (Server + UI + Browser)
|
|
98
|
-
- **calendly** - Calendar scheduling integration with OAuth
|
|
99
|
-
- **typeform** - Form/survey integration with OAuth
|
|
100
|
-
|
|
101
|
-
### Server + UI Apps (No Browser)
|
|
102
|
-
- **webhook** - Generic inbound webhook handler
|
|
103
|
-
- **yeastar** - Phone system CRM integration
|
|
104
|
-
|
|
105
|
-
### Server-only Apps
|
|
106
|
-
- **klaviyo-events** - Email marketing event tracking
|
|
107
|
-
- **google-bigquery** - Data warehouse integration
|
|
108
|
-
- **navitas** - Education platform integration
|
|
109
|
-
|
|
110
|
-
### Browser-focused Apps
|
|
111
|
-
- **clarity** - Microsoft Clarity analytics (browser + server)
|
|
112
|
-
- **trustarc** - Privacy/consent management (browser + server)
|
|
113
|
-
|
|
114
|
-
## Key V2 Patterns
|
|
115
|
-
|
|
116
|
-
### Function Definition (V2 uses V4 programming model)
|
|
117
|
-
|
|
118
|
-
V2 apps use the same Azure Functions V4 programming model as V3:
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
// app/server/src/functions/seekaAppWebhook.ts
|
|
122
|
-
import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';
|
|
123
|
-
|
|
124
|
-
app.http('seekaAppWebhook', {
|
|
125
|
-
methods: ['POST'],
|
|
126
|
-
authLevel: 'anonymous',
|
|
127
|
-
route: 'api/webhook/seeka/app',
|
|
128
|
-
handler: seekaAppWebhook
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export async function seekaAppWebhook(
|
|
132
|
-
req: HttpRequest,
|
|
133
|
-
context: InvocationContext
|
|
134
|
-
): Promise<HttpResponseInit> {
|
|
135
|
-
const body = JSON.parse(await req.text());
|
|
136
|
-
// Process webhook...
|
|
137
|
-
return { status: 204 };
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Queue Handler Pattern
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
// app/server/src/functions/handleSeekaActivityQueueHandler.ts
|
|
145
|
-
import { app, InvocationContext } from '@azure/functions';
|
|
146
|
-
|
|
147
|
-
app.storageQueue('handleSeekaActivityQueueHandler', {
|
|
148
|
-
queueName: 'seeka-activity-queue',
|
|
149
|
-
connection: 'AzureWebJobsStorage',
|
|
150
|
-
handler: async (queueItem: unknown, context: InvocationContext) => {
|
|
151
|
-
// Process queued item
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Installation State (V2 Custom Implementation)
|
|
157
|
-
|
|
158
|
-
V2 apps typically have custom installation management in `src/lib/state/`:
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
// app/server/src/lib/state/seeka/installations.ts
|
|
162
|
-
import { getRedisClient } from '../redis';
|
|
163
|
-
|
|
164
|
-
export interface AppInstallContext {
|
|
165
|
-
applicationInstallId: string;
|
|
166
|
-
organisationId: string;
|
|
167
|
-
organisationBrandId: string;
|
|
168
|
-
installedAt: string;
|
|
169
|
-
installationState?: {
|
|
170
|
-
grantedPermissions: string[];
|
|
171
|
-
installationSettings: AppInstallationSettings;
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export const getInstallation = async (installId: string): Promise<AppInstallContext | null> => {
|
|
176
|
-
const redis = await getRedisClient();
|
|
177
|
-
const data = await redis.get(`installation:${installId}`);
|
|
178
|
-
return data ? JSON.parse(data) : null;
|
|
179
|
-
};
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### API Routes Pattern
|
|
183
|
-
|
|
184
|
-
V2 apps with UI typically have API routes in `src/lib/api/`:
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
// app/server/src/lib/api/routes/setTrackingSettings.ts
|
|
188
|
-
import { HttpRequest, HttpResponseInit } from '@azure/functions';
|
|
189
|
-
import { getInstallation, saveInstallation } from '../../state/seeka/installations';
|
|
190
|
-
|
|
191
|
-
export const setTrackingSettings = async (
|
|
192
|
-
req: HttpRequest,
|
|
193
|
-
installId: string
|
|
194
|
-
): Promise<HttpResponseInit> => {
|
|
195
|
-
const body = await req.json();
|
|
196
|
-
const installation = await getInstallation(installId);
|
|
197
|
-
// Update settings...
|
|
198
|
-
await saveInstallation(installation);
|
|
199
|
-
return { status: 200, jsonBody: { success: true } };
|
|
200
|
-
};
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### UI Component Pattern
|
|
204
|
-
|
|
205
|
-
V2 UIs use React with Vite and shared UI utilities:
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
// app/ui/src/App.tsx
|
|
209
|
-
import { useTokens } from './seeka-labs-app-sdk-ui/shared/auth/useTokens';
|
|
210
|
-
|
|
211
|
-
function App() {
|
|
212
|
-
const { accessToken, installationId } = useTokens();
|
|
213
|
-
|
|
214
|
-
// Render configuration UI
|
|
215
|
-
}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## When to Reference V2 Apps
|
|
219
|
-
|
|
220
|
-
V2 apps are excellent references for:
|
|
221
|
-
|
|
222
|
-
- **Monorepo organization**: How to structure multi-package apps
|
|
223
|
-
- **UI configuration patterns**: React-based settings UIs with Vite
|
|
224
|
-
- **OAuth integration flows**: Platform authentication (Calendly, Typeform, Google)
|
|
225
|
-
- **API route patterns**: REST endpoints for UI communication
|
|
226
|
-
- **Browser plugin architecture**: Plugin structure and server communication
|
|
227
|
-
- **Queue-based processing**: Async activity processing patterns
|
|
228
|
-
|
|
229
|
-
## Adapting V2 Patterns to V3
|
|
230
|
-
|
|
231
|
-
When using V2 code as reference for a new V3 app:
|
|
232
|
-
|
|
233
|
-
1. **Create `app/lib/` package** for shared code instead of keeping it in `app/server/src/lib/`
|
|
234
|
-
2. **Move models** from `app/server/src/lib/models/` to `app/lib/src/models/`
|
|
235
|
-
3. **Move validation** to `app/lib/src/validation/`
|
|
236
|
-
4. **Reorganize server code**:
|
|
237
|
-
- Move `src/lib/services/` to `src/app/services/`
|
|
238
|
-
- Move `src/lib/api/` to `src/app/api/`
|
|
239
|
-
- Move `src/lib/jobs/` to `src/app/jobs/`
|
|
240
|
-
- Move `src/lib/logging/` to `src/app/logging/`
|
|
241
|
-
5. **Use SDK utilities** from `@seeka-labs/sdk-apps-server-host`:
|
|
242
|
-
- Replace custom `getInstallation`/`saveInstallation` with SDK functions
|
|
243
|
-
- Use SDK logging setup instead of custom winston config
|
|
244
|
-
6. **Add `.seeka/` directory** with `init.app.seeka.cli.config.json`
|
|
245
|
-
|
|
246
|
-
## Migration Checklist: V2 → V3
|
|
247
|
-
|
|
248
|
-
- [ ] Create `app/lib/` package with `package.json` and `tsconfig.json`
|
|
249
|
-
- [ ] Move shared models and validation to `app/lib/src/`
|
|
250
|
-
- [ ] Reorganize `app/server/src/lib/` to `app/server/src/app/`
|
|
251
|
-
- [ ] Update imports to use `app/lib` package
|
|
252
|
-
- [ ] Replace custom installation management with SDK utilities
|
|
253
|
-
- [ ] Add `.seeka/init.app.seeka.cli.config.json`
|
|
254
|
-
- [ ] Update SDK packages to latest versions
|
|
255
|
-
- [ ] Test all endpoints, queue handlers, and UI
|
|
256
|
-
|
|
257
|
-
## See Also
|
|
258
|
-
|
|
259
|
-
- `v1-structure.md` - V1 legacy structure (single package)
|
|
260
|
-
- `v3-structure.md` - Current template structure (use for new apps)
|
|
261
|
-
- `../examples/v2/` - V2 example apps for feature reference
|