@lukoweb/apitogo 0.1.50 → 0.1.53

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 (36) hide show
  1. package/dist/cli/cli.js +1339 -922
  2. package/dist/declarations/config/apitogo-config-core.d.ts +25 -0
  3. package/dist/declarations/config/apitogo-config-loader.d.ts +2 -0
  4. package/dist/declarations/config/apitogo-config-loader.node.d.ts +4 -0
  5. package/dist/declarations/config/build-apitogo-config.d.ts +8 -0
  6. package/dist/declarations/config/loader.d.ts +4 -0
  7. package/dist/declarations/config/local-manifest.d.ts +16 -9
  8. package/dist/declarations/config/validators/HeaderNavigationSchema.d.ts +24 -24
  9. package/dist/declarations/config/validators/ModulesSchema.d.ts +38 -0
  10. package/dist/declarations/config/validators/ZudokuConfig.d.ts +18 -9
  11. package/dist/declarations/index.d.ts +2 -1
  12. package/dist/declarations/lib/authentication/auth-header-nav.d.ts +10 -0
  13. package/dist/declarations/lib/core/plugins.d.ts +1 -0
  14. package/dist/declarations/lib/ui/Button.d.ts +1 -1
  15. package/dist/declarations/lib/ui/Item.d.ts +1 -1
  16. package/dist/flat-config.d.ts +36 -23
  17. package/docs/configuration/authentication.md +11 -8
  18. package/docs/configuration/manifest.md +83 -93
  19. package/package.json +17 -1
  20. package/src/config/apitogo-config-core.ts +485 -0
  21. package/src/config/apitogo-config-loader.node.ts +68 -0
  22. package/src/config/apitogo-config-loader.ts +6 -0
  23. package/src/config/build-apitogo-config.ts +52 -0
  24. package/src/config/loader.ts +61 -1
  25. package/src/config/local-manifest.ts +72 -52
  26. package/src/config/resolve-modules.ts +16 -13
  27. package/src/config/validators/ModulesSchema.ts +17 -0
  28. package/src/index.ts +9 -1
  29. package/src/lib/authentication/auth-header-nav.ts +56 -0
  30. package/src/lib/authentication/providers/dev-portal-utils.ts +7 -2
  31. package/src/lib/components/Header.tsx +48 -60
  32. package/src/lib/components/MobileTopNavigation.tsx +29 -40
  33. package/src/lib/core/plugins.ts +1 -0
  34. package/src/vite/dev-portal-env.ts +12 -4
  35. package/src/vite/plugin-config.ts +20 -3
  36. package/src/vite/plugin-local-manifest.ts +15 -0
@@ -61,31 +61,43 @@ export type _Schema9 = (("Inter" | "Roboto" | "Open Sans" | "Poppins" | "Montser
61
61
  * Whether this module is active in the application.
62
62
  */
63
63
  export type _Schema15 = boolean
64
- export type _Schema35 = ({
64
+ /**
65
+ * Gateway plan catalog for /pricing preview and publish (canonical storage).
66
+ */
67
+ export type _Schema35 = {
68
+ sku: string
69
+ displayName: string
70
+ priceAmount?: number
71
+ priceCurrency?: string
72
+ billingPeriod?: string
73
+ limitsJson?: string
74
+ includedActionKeys?: string[]
75
+ }[]
76
+ export type _Schema36 = ({
65
77
  type: "url"
66
- input: (string | _Schema36[])
67
- server?: _Schema37
68
- path?: _Schema38
69
- categories?: _Schema39
70
- options?: _Schema41
78
+ input: (string | _Schema37[])
79
+ server?: _Schema38
80
+ path?: _Schema39
81
+ categories?: _Schema40
82
+ options?: _Schema42
71
83
  } | {
72
84
  type: "file"
73
- input: (string | (string | _Schema36)[])
74
- server?: _Schema37
75
- path?: _Schema38
76
- categories?: _Schema39
77
- options?: _Schema41
85
+ input: (string | (string | _Schema37)[])
86
+ server?: _Schema38
87
+ path?: _Schema39
88
+ categories?: _Schema40
89
+ options?: _Schema42
78
90
  } | {
79
91
  type: "raw"
80
92
  input: string
81
- server?: _Schema37
82
- path?: _Schema38
83
- categories?: _Schema39
84
- options?: _Schema41
93
+ server?: _Schema38
94
+ path?: _Schema39
95
+ categories?: _Schema40
96
+ options?: _Schema42
85
97
  })
86
- export type _Schema37 = string
87
98
  export type _Schema38 = string
88
- export type _Schema39 = {
99
+ export type _Schema39 = string
100
+ export type _Schema40 = {
89
101
  label: string
90
102
  tags: string[]
91
103
  }[]
@@ -369,8 +381,8 @@ export interface FlatZudokuConfig {
369
381
  landing?: _Schema16
370
382
  userPanel?: _Schema23
371
383
  }
372
- apis?: (_Schema35 | _Schema35[])
373
- catalogs?: (_Schema42 | _Schema42[])
384
+ apis?: (_Schema36 | _Schema36[])
385
+ catalogs?: (_Schema43 | _Schema43[])
374
386
  apiKeys?: {
375
387
  enabled: boolean
376
388
  getConsumers?: unknown
@@ -398,7 +410,7 @@ export interface FlatZudokuConfig {
398
410
  }
399
411
  enableStatusPages?: boolean
400
412
  defaults?: {
401
- apis: _Schema41
413
+ apis: _Schema42
402
414
  examplesLanguage?: string
403
415
  }
404
416
  __pluginDirs?: string[]
@@ -589,6 +601,7 @@ export interface _Schema23 {
589
601
  [k: string]: unknown
590
602
  }
591
603
  content?: _Schema34
604
+ items?: _Schema35
592
605
  }
593
606
  }
594
607
  /**
@@ -619,12 +632,12 @@ export interface _Schema34 {
619
632
  description?: string
620
633
  }[]
621
634
  }
622
- export interface _Schema36 {
635
+ export interface _Schema37 {
623
636
  path: string
624
637
  input: string
625
638
  label?: string
626
639
  }
627
- export interface _Schema41 {
640
+ export interface _Schema42 {
628
641
  examplesLanguage?: string
629
642
  supportedLanguages?: {
630
643
  value: string
@@ -641,7 +654,7 @@ export interface _Schema41 {
641
654
  transformExamples?: unknown
642
655
  generateCodeSnippet?: unknown
643
656
  }
644
- export interface _Schema42 {
657
+ export interface _Schema43 {
645
658
  path: string
646
659
  label: string
647
660
  items?: string[]
@@ -41,21 +41,24 @@ only.
41
41
  Set the backend API URL via environment variable (MCP writes this at scaffold/publish):
42
42
 
43
43
  ```bash
44
- VITE_APITOGO_DEV_PORTAL_API_URL=https://your-dev-portal-api.example.com
44
+ VITE_APITOGO_AUTHENTICATION_API_BASE_URL=https://your-dev-portal-api.example.com
45
45
  ```
46
46
 
47
+ You can also set `authentication.apiBaseUrl` in `apitogo.config.json` or
48
+ `APITOGO_CONFIG_authentication__apiBaseUrl` in `.env`.
49
+
47
50
  **Local preview:** When the backend URL is a placeholder or unreachable, the account area shows a
48
51
  message that sign-in unlocks after publish. Docs and API reference remain public. Plans on
49
- `/pricing` load from `apitogo.json` with optional `apitogo.local.json` overrides (including
50
- `includedActionKeys` per plan). Plan edits hot-reload without restarting the dev server.
52
+ `/pricing` load from `apitogo.config.json` (overridable via `.env` see [Manifest](./manifest.md),
53
+ including `includedActionKeys` per plan). Plan edits hot-reload without restarting the dev server.
51
54
 
52
55
  ### Dev portal configuration files
53
56
 
54
- | Concern | File |
55
- | ----------------------------------------------------------------- | ---------------------------------------------------------------- |
56
- | Site nav, docs, plugins, auth wiring | `apitogo.config.tsx` |
57
- | Plans, rate limits, `includedActionKeys`, project/deploy metadata | `apitogo.json` (+ env overrides — see [Manifest](./manifest.md)) |
58
- | OIDC and Stripe for publish (MCP only) | `apitogo.local.secrets.json` |
57
+ | Concern | File |
58
+ | -------------------------------------------------------- | -------------------------------------------------------------------------- |
59
+ | Site, plans, modules, branding, backend/gateway metadata | `apitogo.config.json` (+ `.env` overrides — see [Manifest](./manifest.md)) |
60
+ | Plugins and custom code | `apitogo.config.tsx` |
61
+ | OIDC and Stripe for publish | `.env.local` via `APITOGO_CONFIG_authentication__*` |
59
62
 
60
63
  **Production:** Register one OIDC app with redirect URI `https://{backend}/signin-oidc` (see MCP
61
64
  `manualSteps.oidcRedirectUri`). The frontend uses cookie sessions via `credentials: "include"` on
@@ -1,116 +1,106 @@
1
- ---
2
- title: Manifest (apitogo.json)
3
- sidebar_icon: file-json
4
- ---
1
+ # Site configuration (apitogo.config.json)
5
2
 
6
- Dev portal sites provisioned through APItoGo use JSON manifest files for plans, branding, backend
7
- paths, and gateway settings. Shared defaults live in **`apitogo.json`**; optional per-environment
8
- files override values without duplicating the full config.
3
+ Dev portal sites use a single JSON file for site settings, plans, authentication, and backend
4
+ metadata. Code-only pieces (plugins, custom components) stay in `apitogo.config.tsx`.
9
5
 
10
6
  ## Files
11
7
 
12
- | File | When used | Purpose |
13
- | ---------------------------- | ---------------- | ------------------------------------------------------------------------- |
14
- | `apitogo.json` | Always (base) | Committed defaults: `siteName`, `branding`, `plans`, `backend`, `gateway` |
15
- | `apitogo.local.json` | `npm run dev` | Local-only overrides (optional) |
16
- | `apitogo.prod.json` | `npm run build` | Production build overrides (optional) |
17
- | `apitogo.local.secrets.json` | MCP publish only | OIDC and Stripe credentials — never loaded by the dev server |
18
-
19
- New scaffolds ship `apitogo.json` plus `apitogo.local.example.json` and `apitogo.prod.example.json`
20
- to show how overrides work. Copy or rename the examples when you need environment-specific values.
21
-
22
- ## Resolution
23
-
24
- At dev and build time the tooling merges the base file with the environment override:
25
-
26
- ```mermaid
27
- flowchart LR
28
- base["apitogo.json"]
29
- local["apitogo.local.json"]
30
- prod["apitogo.prod.json"]
31
- devMerge["merge"]
32
- buildMerge["merge"]
33
- viteDev["npm run dev"]
34
- viteBuild["npm run build"]
35
-
36
- base --> devMerge
37
- local --> devMerge
38
- base --> buildMerge
39
- prod --> buildMerge
40
- viteDev --> devMerge
41
- buildMerge --> viteBuild
42
- ```
43
-
44
- - **Local preview** (`npm run dev`): `apitogo.json` + `apitogo.local.json`
45
- - **Production build** (`npm run build`): `apitogo.json` + `apitogo.prod.json`
46
- - **Deployed site**: plans are served from the live dev-portal API (`GET /api/v1/plans`), not from
47
- JSON files in the browser bundle
48
-
49
- If `apitogo.json` is missing but `apitogo.local.json` exists, the local file is used as the full
50
- manifest (legacy single-file projects).
51
-
52
- ## Merge rules
53
-
54
- Override files patch the base manifest:
8
+ | File | Purpose |
9
+ | --------------------- | ----------------------------------------------------------- |
10
+ | `apitogo.config.json` | Committed defaults: site, modules, authentication, backend |
11
+ | `apitogo.config.tsx` | Plugins and other non-JSON configuration |
12
+ | `.env` / `.env.local` | Public client vars + publish secrets via `APITOGO_CONFIG_*` |
55
13
 
56
- - Top-level keys: override wins
57
- - `branding`, `backend`, `gateway`: deep-merged (override fields patch nested objects)
58
- - `plans`: merged by `sku` — an override plan with the same SKU updates only the fields you specify
59
-
60
- Example base (`apitogo.json`):
14
+ ## Canonical shape
61
15
 
62
16
  ```json
63
17
  {
64
- "siteName": "My API",
65
- "branding": { "title": "My API" },
66
- "plans": [
67
- {
68
- "sku": "pro",
69
- "displayName": "Pro",
70
- "isFree": false,
71
- "priceAmount": 9.99,
72
- "billingPeriod": "month"
18
+ "site": {
19
+ "title": "My API",
20
+ "logo": {
21
+ "src": { "light": "/logo-light.png", "dark": "/logo-dark.png" },
22
+ "alt": "My API",
23
+ "width": "130px"
24
+ }
25
+ },
26
+ "authentication": {
27
+ "enabled": true,
28
+ "type": "dev-portal",
29
+ "apiBaseUrl": "https://your-dev-portal-api.example.com",
30
+ "gateway": {
31
+ "authMode": "bringYourOwnOidc",
32
+ "oidcMetadataUrl": "https://login.example.com/.well-known/openid-configuration"
33
+ }
34
+ },
35
+ "modules": {
36
+ "docs": { "files": "/pages/**/*.{md,mdx}" },
37
+ "landing": { "enabled": true, "path": "/", "layout": "landing" },
38
+ "userPanel": {
39
+ "enabled": true,
40
+ "dashboard": { "enabled": true },
41
+ "userManagement": { "enabled": true },
42
+ "plans": {
43
+ "enabled": true,
44
+ "items": [
45
+ {
46
+ "sku": "free",
47
+ "displayName": "Free",
48
+ "priceAmount": 0
49
+ }
50
+ ]
51
+ }
73
52
  }
74
- ]
53
+ },
54
+ "apis": [{ "type": "file", "input": "./apis/openapi.yaml", "path": "api" }]
75
55
  }
76
56
  ```
77
57
 
78
- Example local override (`apitogo.local.json`):
58
+ - **Site name / logo:** only `site.title` and `site.logo` (platform branding is derived at publish).
59
+ - **OpenAPI path:** `backend.openApiPath` is derived from `apis[0].input`.
60
+ - **Billing / account plans:** use `modules.userPanel.plans.enabled` and store the plan catalog in
61
+ `modules.userPanel.plans.items`. Legacy root `plans` is migrated on load. Legacy `pricing.enabled`
62
+ is migrated and stripped from site JSON; MCP/publish still receives derived `pricing.enabled`.
63
+ - **Docs / API keys:** configure under `modules.docs` and `modules.userPanel.apiKeys` only.
79
64
 
80
- ```json
81
- {
82
- "projectId": "your-local-project-id",
83
- "backend": { "sourceDirectory": "../my-api" }
84
- }
65
+ ## Environment variables
66
+
67
+ Public client URL (mirrors `authentication.apiBaseUrl`):
68
+
69
+ ```sh
70
+ VITE_APITOGO_AUTHENTICATION_API_BASE_URL=https://your-dev-portal-api.example.com
85
71
  ```
86
72
 
87
- Example production override (`apitogo.prod.json`):
73
+ Nested config overrides:
88
74
 
89
- ```json
90
- {
91
- "plans": [{ "sku": "pro", "priceAmount": 19.99 }],
92
- "backend": { "deployed": true }
93
- }
75
+ ```sh
76
+ APITOGO_CONFIG_site__title=My Local Site
77
+ APITOGO_CONFIG_pricing__enabled=true
78
+ APITOGO_CONFIG_projectId=your-local-project-id
79
+ APITOGO_CONFIG_authentication__apiBaseUrl=https://your-dev-portal-api.example.com
94
80
  ```
95
81
 
96
- ## What to put where
82
+ Publish secrets (`.env.local`, never commit):
83
+
84
+ ```sh
85
+ APITOGO_CONFIG_authentication__oidc__authority=https://login.example.com
86
+ APITOGO_CONFIG_authentication__oidc__clientId=your-client-id
87
+ APITOGO_CONFIG_authentication__oidc__clientSecret=your-client-secret
88
+ APITOGO_CONFIG_authentication__stripe__secretKey=sk_test_...
89
+ APITOGO_CONFIG_authentication__stripe__webhookSecret=whsec_...
90
+ ```
97
91
 
98
- | Concern | Recommended file |
99
- | -------------------------------------------- | ------------------------------------------------------------------------ |
100
- | Plans, rate limits, `includedActionKeys` | `apitogo.json` (shared) |
101
- | Branding, site name | `apitogo.json` |
102
- | Backend paths, OpenAPI location | `apitogo.json`; machine-specific paths in `apitogo.local.json` |
103
- | `projectId` after bootstrap | `apitogo.local.json` until MCP writes to the correct file |
104
- | Production-only plan pricing or deploy flags | `apitogo.prod.json` |
105
- | OIDC / Stripe | `apitogo.local.secrets.json` (see [Authentication](./authentication.md)) |
92
+ ## Thin `apitogo.config.tsx`
106
93
 
107
- ## Hot reload
94
+ ```tsx
95
+ import { buildApitogoConfig } from "@lukoweb/apitogo";
96
+ import { devPortalBillingPlugin } from "@lukoweb/apitogo-plugin-dev-portal-billing";
108
97
 
109
- During `npm run dev`, changes to `apitogo.json` or `apitogo.local.json` hot-reload on `/pricing`
110
- without restarting the server. Restart the dev server after changing
111
- `VITE_APITOGO_DEV_PORTAL_API_URL` in `.env`.
98
+ export default buildApitogoConfig({
99
+ plugins: [devPortalBillingPlugin()],
100
+ });
101
+ ```
112
102
 
113
- ## Related configuration
103
+ ## Related
114
104
 
115
- - Site navigation, docs, and plugins: [`apitogo.config.tsx`](./overview.md)
116
- - Authentication for dev-portal sites: [Authentication](./authentication.md)
105
+ - [Authentication](./authentication.md)
106
+ - [Overview](./overview.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukoweb/apitogo",
3
- "version": "0.1.50",
3
+ "version": "0.1.53",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -153,6 +153,14 @@
153
153
  "./local-manifest": {
154
154
  "types": "./dist/declarations/config/local-manifest.d.ts",
155
155
  "default": "./src/config/local-manifest.ts"
156
+ },
157
+ "./build-config": {
158
+ "types": "./dist/declarations/config/build-apitogo-config.d.ts",
159
+ "default": "./src/config/build-apitogo-config.ts"
160
+ },
161
+ "./config-loader": {
162
+ "types": "./dist/declarations/config/apitogo-config-loader.d.ts",
163
+ "default": "./src/config/apitogo-config-loader.ts"
156
164
  }
157
165
  },
158
166
  "scripts": {
@@ -467,6 +475,14 @@
467
475
  "./local-manifest": {
468
476
  "types": "./dist/declarations/config/local-manifest.d.ts",
469
477
  "default": "./src/config/local-manifest.ts"
478
+ },
479
+ "./build-config": {
480
+ "types": "./dist/declarations/config/build-apitogo-config.d.ts",
481
+ "default": "./src/config/build-apitogo-config.ts"
482
+ },
483
+ "./config-loader": {
484
+ "types": "./dist/declarations/config/apitogo-config-loader.d.ts",
485
+ "default": "./src/config/apitogo-config-loader.ts"
470
486
  }
471
487
  },
472
488
  "access": "public"