nucleus-core-ts 0.10.147 → 0.10.151
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/LICENSE +48 -48
- package/dist/.build-ok +1 -1
- package/dist/fe/components/AuthorizationPage/labels.js +13 -13
- package/dist/fe/components/Captcha/labels.js +17 -17
- package/dist/fe/components/ChatPanel/helpers.js +17 -17
- package/dist/fe/components/ChatPanel/labels.js +16 -16
- package/dist/fe/components/DataTable/labels.js +16 -16
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +15 -15
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +9 -9
- package/dist/fe/components/DevicesPage/labels.js +12 -12
- package/dist/fe/components/ForgotPasswordPage/labels.js +8 -8
- package/dist/fe/components/FormBuilder/components/FormField.js +5 -5
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +9 -9
- package/dist/fe/components/IntegrationsPage/components/ConnectionAuthFields.js +8 -8
- package/dist/fe/components/IntegrationsPage/components/ConnectionBasicFields.js +3 -3
- package/dist/fe/components/IntegrationsPage/components/ConnectionExport.js +23 -23
- package/dist/fe/components/IntegrationsPage/components/ConnectionForm.js +22 -22
- package/dist/fe/components/IntegrationsPage/components/ConnectionList.js +7 -7
- package/dist/fe/components/IntegrationsPage/components/ConnectionOauthFields.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/ConnectionSettingsTab.js +24 -24
- package/dist/fe/components/IntegrationsPage/components/ConnectionSwitcher.js +19 -19
- package/dist/fe/components/IntegrationsPage/components/ConnectionTabs.js +15 -15
- package/dist/fe/components/IntegrationsPage/components/ConnectionTest.js +21 -21
- package/dist/fe/components/IntegrationsPage/components/ConnectionTransfer.js +18 -18
- package/dist/fe/components/IntegrationsPage/components/CredentialFields.js +19 -19
- package/dist/fe/components/IntegrationsPage/components/CredentialSlotRow.js +8 -8
- package/dist/fe/components/IntegrationsPage/components/EndpointForm.js +7 -7
- package/dist/fe/components/IntegrationsPage/components/EndpointFormFields.js +12 -12
- package/dist/fe/components/IntegrationsPage/components/EndpointList.js +7 -7
- package/dist/fe/components/IntegrationsPage/components/EndpointSample.js +36 -36
- package/dist/fe/components/IntegrationsPage/components/EndpointsTab.js +29 -29
- package/dist/fe/components/IntegrationsPage/components/FieldMappingRow.js +7 -7
- package/dist/fe/components/IntegrationsPage/components/FieldMappingRows.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/IntegrationsPage.js +60 -60
- package/dist/fe/components/IntegrationsPage/components/MappingAccountFields.js +15 -15
- package/dist/fe/components/IntegrationsPage/components/MappingEditor.js +9 -9
- package/dist/fe/components/IntegrationsPage/components/MappingList.js +23 -23
- package/dist/fe/components/IntegrationsPage/components/MappingPasswordField.js +12 -12
- package/dist/fe/components/IntegrationsPage/components/MappingScheduleFields.js +23 -23
- package/dist/fe/components/IntegrationsPage/components/MappingWriteModeFields.js +31 -31
- package/dist/fe/components/IntegrationsPage/components/MappingsTab.js +56 -56
- package/dist/fe/components/IntegrationsPage/components/PaginationFields.js +11 -11
- package/dist/fe/components/IntegrationsPage/components/ParamBindingRows.js +15 -15
- package/dist/fe/components/IntegrationsPage/components/Primitives.js +28 -28
- package/dist/fe/components/IntegrationsPage/components/ReferenceCheckRows.js +9 -9
- package/dist/fe/components/IntegrationsPage/components/RunConfirmStep.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/RunHistory.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/RunHistoryRow.js +9 -9
- package/dist/fe/components/IntegrationsPage/components/RunPanel.js +40 -40
- package/dist/fe/components/IntegrationsPage/components/RunPasswordField.js +18 -18
- package/dist/fe/components/IntegrationsPage/components/RunPlanIssues.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/RunPlanReferences.js +12 -12
- package/dist/fe/components/IntegrationsPage/components/RunPlanSuggestions.js +11 -11
- package/dist/fe/components/IntegrationsPage/components/RunPlanSummary.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/RunProgressBar.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/RunRevertConflicts.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/Skeletons.js +7 -7
- package/dist/fe/components/IntegrationsPage/components/authOptions.js +4 -4
- package/dist/fe/components/IntegrationsPage/components/connectionDraft.js +27 -27
- package/dist/fe/components/IntegrationsPage/components/credentialSlots.js +25 -25
- package/dist/fe/components/IntegrationsPage/components/deleteIsConfirmed.js +9 -9
- package/dist/fe/components/IntegrationsPage/components/fieldMappingOptions.js +4 -4
- package/dist/fe/components/IntegrationsPage/components/formSupport.js +34 -34
- package/dist/fe/components/IntegrationsPage/components/jsonArray.js +14 -14
- package/dist/fe/components/IntegrationsPage/components/jsonObjectField.js +15 -15
- package/dist/fe/components/IntegrationsPage/components/mappingDraft.js +10 -10
- package/dist/fe/components/IntegrationsPage/components/mappingStaleness.js +22 -22
- package/dist/fe/components/IntegrationsPage/components/nextRuns.js +8 -8
- package/dist/fe/components/IntegrationsPage/components/passwordIsNeeded.js +13 -13
- package/dist/fe/components/IntegrationsPage/components/pathParams.js +6 -6
- package/dist/fe/components/IntegrationsPage/components/runFormat.js +18 -18
- package/dist/fe/components/IntegrationsPage/components/settleOwnership.js +18 -18
- package/dist/fe/components/IntegrationsPage/components/useInfiniteList.js +8 -8
- package/dist/fe/components/IntegrationsPage/store/index.js +20 -20
- package/dist/fe/components/IntegrationsPage/store/upsertInto.js +12 -12
- package/dist/fe/components/IntegrationsPage/text/context.js +6 -6
- package/dist/fe/components/IntegrationsPage/text/index.js +18 -18
- package/dist/fe/components/IntegrationsPage/theme/index.js +29 -29
- package/dist/fe/components/IntegrationsPage/types/records.js +10 -10
- package/dist/fe/components/IntegrationsPage/types/results.js +3 -3
- package/dist/fe/components/NotificationCenter/labels.js +17 -17
- package/dist/fe/components/ProfilePage/labels.js +10 -10
- package/dist/fe/components/ResetPasswordPage/labels.js +4 -4
- package/dist/fe/components/SetPasswordPage/labels.js +11 -11
- package/dist/fe/components/UsersPage/labels.js +14 -14
- package/dist/fe/utils/columnUtils.js +24 -24
- package/dist/fe/utils/searchFold.js +36 -36
- package/dist/index.js +6 -6
- package/dist/server.js +6 -6
- package/dist/src/Client/Proxy/authz.js +4 -4
- package/dist/src/Client/Proxy/httpProxy.js +136 -136
- package/dist/src/Client/Proxy/largeBody.js +29 -29
- package/dist/src/Client/Proxy/utils.js +32 -32
- package/dist/src/Client/Proxy/wsProxy.js +59 -59
- package/dist/src/Managers/Redis/index.d.ts +14 -0
- package/dist/src/Nucleus/routes/auth/admin/impersonationStore.d.ts +3 -4
- package/dist/src/Nucleus/routes/auth/refresh/issuedPair.d.ts +67 -0
- package/dist/src/Nucleus/routes/auth/refresh/recordIssued.d.ts +15 -6
- package/dist/src/Nucleus/routes/auth/refresh/refreshChain.d.ts +56 -0
- package/dist/src/Services/Auth/SessionStore/utils.d.ts +2 -0
- package/dist/src/Shared/cron.js +71 -71
- package/dist/src/Shared/redactSecrets.js +156 -156
- package/dist/src/Shared/redaction/bare.js +61 -61
- package/dist/src/Shared/redaction/floor.js +48 -48
- package/dist/src/Shared/redaction/freeText.js +70 -70
- package/dist/src/Shared/redaction/json.js +30 -30
- package/dist/src/Shared/redaction/lists.js +23 -23
- package/dist/src/Shared/redaction/markers.js +28 -28
- package/dist/src/Shared/redaction/names.js +49 -49
- package/dist/src/Shared/redaction/pairs.js +54 -54
- package/dist/src/Shared/redaction/secretString.js +29 -29
- package/dist/src/Shared/redaction/structured.js +52 -52
- package/dist/src/Shared/redaction/walk.js +25 -25
- package/infra/scripts/generate-project.ts +766 -766
- package/infra/templates/README.md +57 -57
- package/infra/templates/backend/.dockerignore +9 -9
- package/infra/templates/backend/.env.example +15 -15
- package/infra/templates/backend/README.md +28 -28
- package/infra/templates/backend/azure-pipelines.yml +135 -135
- package/infra/templates/backend/k8s/Dockerfile +31 -31
- package/infra/templates/backend/k8s/configmap.yaml +26 -26
- package/infra/templates/backend/k8s/deployment.yaml +85 -85
- package/infra/templates/backend/k8s/pvc.yaml +12 -12
- package/infra/templates/backend/k8s/service.yaml +13 -13
- package/infra/templates/backend/tsconfig.json +22 -22
- package/infra/templates/frontend/.dockerignore +10 -10
- package/infra/templates/frontend/.env.example +8 -8
- package/infra/templates/frontend/.env.local.example +10 -10
- package/infra/templates/frontend/README.md +69 -69
- package/infra/templates/frontend/app/[tablename]/page.tsx +37 -37
- package/infra/templates/frontend/app/_components/AuthWrapper/index.tsx +63 -63
- package/infra/templates/frontend/app/authorization/page.tsx +43 -43
- package/infra/templates/frontend/app/change-password/page.tsx +23 -23
- package/infra/templates/frontend/app/devices/page.tsx +127 -127
- package/infra/templates/frontend/app/forgot-password/page.tsx +20 -20
- package/infra/templates/frontend/app/globals.css +28 -28
- package/infra/templates/frontend/app/layout.tsx +35 -35
- package/infra/templates/frontend/app/login/page.tsx +33 -33
- package/infra/templates/frontend/app/page.tsx +565 -565
- package/infra/templates/frontend/app/profile/page.tsx +92 -92
- package/infra/templates/frontend/app/register/page.tsx +27 -27
- package/infra/templates/frontend/app/reset-password/page.tsx +60 -60
- package/infra/templates/frontend/app/set-password/page.tsx +43 -43
- package/infra/templates/frontend/app/ui-docs/page.tsx +52 -52
- package/infra/templates/frontend/app/users/page.tsx +52 -52
- package/infra/templates/frontend/app/verify-email/page.tsx +41 -41
- package/infra/templates/frontend/app/verify-magic-link/page.tsx +46 -46
- package/infra/templates/frontend/azure-pipelines.yml +137 -137
- package/infra/templates/frontend/code-and-design-principles.md +438 -438
- package/infra/templates/frontend/k8s/Dockerfile +50 -50
- package/infra/templates/frontend/k8s/configmap.yaml +18 -18
- package/infra/templates/frontend/k8s/deployment.yaml +72 -72
- package/infra/templates/frontend/k8s/ingress.yaml +36 -36
- package/infra/templates/frontend/k8s/service.yaml +14 -14
- package/infra/templates/frontend/lib/api/endpoints.ts +37 -37
- package/infra/templates/frontend/lib/api/factory.ts +44 -44
- package/infra/templates/frontend/lib/api/hook.ts +10 -10
- package/infra/templates/frontend/next.config.ts +19 -19
- package/infra/templates/frontend/package.json +34 -34
- package/infra/templates/frontend/postcss.config.mjs +5 -5
- package/infra/templates/frontend/server.ts +114 -114
- package/infra/templates/frontend/tsconfig.json +23 -23
- package/package.json +1 -1
- package/public/components/CTA.tsx +25 -25
- package/public/components/Capabilities.tsx +67 -67
- package/public/components/Features.tsx +107 -107
- package/public/components/Footer.tsx +58 -58
- package/public/components/Hero.tsx +51 -51
- package/public/components/Managers.tsx +55 -55
- package/public/components/Nav.tsx +91 -91
- package/public/components/Stack.tsx +36 -36
- package/public/components/docs/Docs.tsx +60 -60
- package/public/components/docs/DocsContent.tsx +176 -176
- package/public/components/docs/DocsRightSidebar.tsx +53 -53
- package/public/components/docs/DocsSidebar.tsx +54 -54
- package/public/components/docs/content/authentication.ts +836 -836
- package/public/components/docs/content/authorization.ts +268 -268
- package/public/components/docs/content/backupRestore.ts +173 -173
- package/public/components/docs/content/clientModule.ts +287 -287
- package/public/components/docs/content/entityCrud.ts +682 -682
- package/public/components/docs/content/monitoring.ts +313 -313
- package/public/components/docs/content/multiTenant.ts +269 -269
- package/public/components/docs/content/oauthApiKeys.ts +325 -325
- package/public/components/docs/content/pubsub.ts +131 -131
- package/public/components/docs/content/storageCdn.ts +171 -171
- package/public/components/docs/content/verification.ts +289 -289
- package/public/components/docs/docsData.ts +113 -113
- package/public/components/docs/index.ts +6 -6
- package/public/components/index.ts +9 -9
- package/public/docs.css +629 -629
- package/public/index.html +81 -81
- package/public/index.tsx +42 -42
- package/public/store.ts +76 -76
- package/public/styles.css +858 -858
- package/schemas/config.nucleus.json +2651 -2651
- package/scripts/audit-purge-noise.ts +120 -120
- package/scripts/build.ts +582 -582
- package/scripts/generate-system-tables-types.ts +18 -18
- package/scripts/generate-types-schema.test.ts +73 -73
- package/scripts/generate-types-schema.ts +1284 -1284
- package/scripts/packagedScripts.test.ts +87 -87
- package/scripts/publish.ts +276 -276
- package/scripts/skillCitations.test.ts +107 -107
- package/scripts/verify-publishable.ts +40 -40
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import type { DocItem } from '../docsData'
|
|
2
|
-
|
|
3
|
-
export const pubsubItems: DocItem[] = [
|
|
4
|
-
{
|
|
5
|
-
id: 'pubsub-system',
|
|
6
|
-
title: 'PubSub System',
|
|
7
|
-
subItems: [
|
|
8
|
-
{
|
|
9
|
-
id: 'pubsub-overview',
|
|
10
|
-
title: 'How PubSub Works',
|
|
11
|
-
content: `
|
|
12
|
-
## How PubSub Works
|
|
13
|
-
|
|
14
|
-
Nucleus provides a real-time event system that combines **Dapr PubSub** (for service-to-service messaging in Kubernetes) with **WebSocket** (for browser-to-server real-time communication). Events published by the server are delivered to connected browser clients via WebSocket.
|
|
15
|
-
|
|
16
|
-
### Architecture
|
|
17
|
-
|
|
18
|
-
\`\`\`
|
|
19
|
-
Backend Service → Dapr PubSub → Nucleus PubSub Handler → WebSocket → Browser
|
|
20
|
-
↓
|
|
21
|
-
Per-user message queue
|
|
22
|
-
ACK tracking
|
|
23
|
-
Presence broadcasting
|
|
24
|
-
\`\`\`
|
|
25
|
-
|
|
26
|
-
### How It Works
|
|
27
|
-
|
|
28
|
-
1. **Server publishes an event** — Any service can publish events through Dapr's PubSub API (or directly through the Nucleus PubSub manager)
|
|
29
|
-
2. **Nucleus receives the event** — The Dapr subscription endpoint receives the message
|
|
30
|
-
3. **User routing** — The event includes a \`userId\` field. Nucleus looks up all WebSocket connections for that user
|
|
31
|
-
4. **WebSocket delivery** — The event is sent to all of the user's connected clients
|
|
32
|
-
5. **ACK system** — The client must acknowledge receipt. Unacknowledged messages are retried
|
|
33
|
-
|
|
34
|
-
### WebSocket Connection
|
|
35
|
-
|
|
36
|
-
Clients connect to the WebSocket endpoint:
|
|
37
|
-
|
|
38
|
-
\`\`\`
|
|
39
|
-
ws://localhost:9000/api/events/subscribe?token=access_token_here
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
The token is validated on connection. Each authenticated user can have up to \`maxClientsPerUser\` simultaneous connections (default: 10).
|
|
43
|
-
|
|
44
|
-
### Event Format
|
|
45
|
-
|
|
46
|
-
Events sent to clients follow this format:
|
|
47
|
-
|
|
48
|
-
\`\`\`json
|
|
49
|
-
{
|
|
50
|
-
"id": "event-uuid",
|
|
51
|
-
"type": "entity.created",
|
|
52
|
-
"data": {
|
|
53
|
-
"entityName": "products",
|
|
54
|
-
"entityId": "product-uuid",
|
|
55
|
-
"record": { ... }
|
|
56
|
-
},
|
|
57
|
-
"timestamp": "2024-01-15T10:30:00Z"
|
|
58
|
-
}
|
|
59
|
-
\`\`\`
|
|
60
|
-
|
|
61
|
-
### Idle Timeout
|
|
62
|
-
|
|
63
|
-
WebSocket connections are automatically closed after \`wsIdleTimeout\` seconds of inactivity (default: 120). Clients should send periodic ping frames to keep the connection alive.
|
|
64
|
-
`,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: 'pubsub-config',
|
|
68
|
-
title: 'PubSub Configuration',
|
|
69
|
-
content: `
|
|
70
|
-
## PubSub Configuration
|
|
71
|
-
|
|
72
|
-
\`\`\`json
|
|
73
|
-
{
|
|
74
|
-
"pubsub": {
|
|
75
|
-
"enabled": true,
|
|
76
|
-
"basePath": "/subs",
|
|
77
|
-
"wsPath": "/api/events/subscribe",
|
|
78
|
-
"pubsubName": "pubsub-redis",
|
|
79
|
-
"maxClientsPerUser": 10,
|
|
80
|
-
"wsIdleTimeout": 120,
|
|
81
|
-
"ack": {
|
|
82
|
-
"enabled": true,
|
|
83
|
-
"ttlSeconds": 300,
|
|
84
|
-
"maxRetries": 3,
|
|
85
|
-
"retryIntervalMs": 5000
|
|
86
|
-
},
|
|
87
|
-
"presence": {
|
|
88
|
-
"enabled": true,
|
|
89
|
-
"debounceMs": 5000
|
|
90
|
-
},
|
|
91
|
-
"cleanupIntervalMs": 60000
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
\`\`\`
|
|
95
|
-
|
|
96
|
-
| Field | Type | Default | Description |
|
|
97
|
-
|-------|------|---------|-------------|
|
|
98
|
-
| \`enabled\` | boolean | false | Enable PubSub system |
|
|
99
|
-
| \`basePath\` | string | \`"/subs"\` | Dapr subscription endpoint base |
|
|
100
|
-
| \`wsPath\` | string | \`"/api/events/subscribe"\` | WebSocket endpoint path |
|
|
101
|
-
| \`pubsubName\` | string | \`"pubsub-redis"\` | Dapr pubsub component name |
|
|
102
|
-
| \`maxClientsPerUser\` | number | 10 | Max concurrent WS connections per user |
|
|
103
|
-
| \`wsIdleTimeout\` | number | 120 | Seconds before idle WS is closed |
|
|
104
|
-
| \`cleanupIntervalMs\` | number | 60000 | Stale client cleanup interval |
|
|
105
|
-
|
|
106
|
-
### ACK System
|
|
107
|
-
|
|
108
|
-
When ACK is enabled, the server tracks message delivery:
|
|
109
|
-
|
|
110
|
-
| Field | Description |
|
|
111
|
-
|-------|-------------|
|
|
112
|
-
| \`ttlSeconds\` | How long to keep unacked messages (default: 300s) |
|
|
113
|
-
| \`maxRetries\` | Max retry attempts for unacked messages (default: 3) |
|
|
114
|
-
| \`retryIntervalMs\` | Delay between retries in ms (default: 5000) |
|
|
115
|
-
|
|
116
|
-
After \`maxRetries\`, the message is dropped. Clients acknowledge messages by sending an ACK frame with the message ID.
|
|
117
|
-
|
|
118
|
-
### Presence Broadcasting
|
|
119
|
-
|
|
120
|
-
When presence is enabled, Nucleus broadcasts user online/offline status to other connected users. The \`debounceMs\` setting prevents rapid online/offline flicker during reconnections.
|
|
121
|
-
|
|
122
|
-
### Dapr vs Direct Mode
|
|
123
|
-
|
|
124
|
-
In Kubernetes with Dapr, events flow through the Dapr sidecar's PubSub component (typically Redis Streams). For local development without Dapr, Nucleus falls back to direct in-process event delivery.
|
|
125
|
-
|
|
126
|
-
Set \`redis.withDapr: false\` in your config for local development. The PubSub API surface remains the same — only the transport changes.
|
|
127
|
-
`,
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
]
|
|
1
|
+
import type { DocItem } from '../docsData'
|
|
2
|
+
|
|
3
|
+
export const pubsubItems: DocItem[] = [
|
|
4
|
+
{
|
|
5
|
+
id: 'pubsub-system',
|
|
6
|
+
title: 'PubSub System',
|
|
7
|
+
subItems: [
|
|
8
|
+
{
|
|
9
|
+
id: 'pubsub-overview',
|
|
10
|
+
title: 'How PubSub Works',
|
|
11
|
+
content: `
|
|
12
|
+
## How PubSub Works
|
|
13
|
+
|
|
14
|
+
Nucleus provides a real-time event system that combines **Dapr PubSub** (for service-to-service messaging in Kubernetes) with **WebSocket** (for browser-to-server real-time communication). Events published by the server are delivered to connected browser clients via WebSocket.
|
|
15
|
+
|
|
16
|
+
### Architecture
|
|
17
|
+
|
|
18
|
+
\`\`\`
|
|
19
|
+
Backend Service → Dapr PubSub → Nucleus PubSub Handler → WebSocket → Browser
|
|
20
|
+
↓
|
|
21
|
+
Per-user message queue
|
|
22
|
+
ACK tracking
|
|
23
|
+
Presence broadcasting
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
### How It Works
|
|
27
|
+
|
|
28
|
+
1. **Server publishes an event** — Any service can publish events through Dapr's PubSub API (or directly through the Nucleus PubSub manager)
|
|
29
|
+
2. **Nucleus receives the event** — The Dapr subscription endpoint receives the message
|
|
30
|
+
3. **User routing** — The event includes a \`userId\` field. Nucleus looks up all WebSocket connections for that user
|
|
31
|
+
4. **WebSocket delivery** — The event is sent to all of the user's connected clients
|
|
32
|
+
5. **ACK system** — The client must acknowledge receipt. Unacknowledged messages are retried
|
|
33
|
+
|
|
34
|
+
### WebSocket Connection
|
|
35
|
+
|
|
36
|
+
Clients connect to the WebSocket endpoint:
|
|
37
|
+
|
|
38
|
+
\`\`\`
|
|
39
|
+
ws://localhost:9000/api/events/subscribe?token=access_token_here
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
The token is validated on connection. Each authenticated user can have up to \`maxClientsPerUser\` simultaneous connections (default: 10).
|
|
43
|
+
|
|
44
|
+
### Event Format
|
|
45
|
+
|
|
46
|
+
Events sent to clients follow this format:
|
|
47
|
+
|
|
48
|
+
\`\`\`json
|
|
49
|
+
{
|
|
50
|
+
"id": "event-uuid",
|
|
51
|
+
"type": "entity.created",
|
|
52
|
+
"data": {
|
|
53
|
+
"entityName": "products",
|
|
54
|
+
"entityId": "product-uuid",
|
|
55
|
+
"record": { ... }
|
|
56
|
+
},
|
|
57
|
+
"timestamp": "2024-01-15T10:30:00Z"
|
|
58
|
+
}
|
|
59
|
+
\`\`\`
|
|
60
|
+
|
|
61
|
+
### Idle Timeout
|
|
62
|
+
|
|
63
|
+
WebSocket connections are automatically closed after \`wsIdleTimeout\` seconds of inactivity (default: 120). Clients should send periodic ping frames to keep the connection alive.
|
|
64
|
+
`,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'pubsub-config',
|
|
68
|
+
title: 'PubSub Configuration',
|
|
69
|
+
content: `
|
|
70
|
+
## PubSub Configuration
|
|
71
|
+
|
|
72
|
+
\`\`\`json
|
|
73
|
+
{
|
|
74
|
+
"pubsub": {
|
|
75
|
+
"enabled": true,
|
|
76
|
+
"basePath": "/subs",
|
|
77
|
+
"wsPath": "/api/events/subscribe",
|
|
78
|
+
"pubsubName": "pubsub-redis",
|
|
79
|
+
"maxClientsPerUser": 10,
|
|
80
|
+
"wsIdleTimeout": 120,
|
|
81
|
+
"ack": {
|
|
82
|
+
"enabled": true,
|
|
83
|
+
"ttlSeconds": 300,
|
|
84
|
+
"maxRetries": 3,
|
|
85
|
+
"retryIntervalMs": 5000
|
|
86
|
+
},
|
|
87
|
+
"presence": {
|
|
88
|
+
"enabled": true,
|
|
89
|
+
"debounceMs": 5000
|
|
90
|
+
},
|
|
91
|
+
"cleanupIntervalMs": 60000
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
| Field | Type | Default | Description |
|
|
97
|
+
|-------|------|---------|-------------|
|
|
98
|
+
| \`enabled\` | boolean | false | Enable PubSub system |
|
|
99
|
+
| \`basePath\` | string | \`"/subs"\` | Dapr subscription endpoint base |
|
|
100
|
+
| \`wsPath\` | string | \`"/api/events/subscribe"\` | WebSocket endpoint path |
|
|
101
|
+
| \`pubsubName\` | string | \`"pubsub-redis"\` | Dapr pubsub component name |
|
|
102
|
+
| \`maxClientsPerUser\` | number | 10 | Max concurrent WS connections per user |
|
|
103
|
+
| \`wsIdleTimeout\` | number | 120 | Seconds before idle WS is closed |
|
|
104
|
+
| \`cleanupIntervalMs\` | number | 60000 | Stale client cleanup interval |
|
|
105
|
+
|
|
106
|
+
### ACK System
|
|
107
|
+
|
|
108
|
+
When ACK is enabled, the server tracks message delivery:
|
|
109
|
+
|
|
110
|
+
| Field | Description |
|
|
111
|
+
|-------|-------------|
|
|
112
|
+
| \`ttlSeconds\` | How long to keep unacked messages (default: 300s) |
|
|
113
|
+
| \`maxRetries\` | Max retry attempts for unacked messages (default: 3) |
|
|
114
|
+
| \`retryIntervalMs\` | Delay between retries in ms (default: 5000) |
|
|
115
|
+
|
|
116
|
+
After \`maxRetries\`, the message is dropped. Clients acknowledge messages by sending an ACK frame with the message ID.
|
|
117
|
+
|
|
118
|
+
### Presence Broadcasting
|
|
119
|
+
|
|
120
|
+
When presence is enabled, Nucleus broadcasts user online/offline status to other connected users. The \`debounceMs\` setting prevents rapid online/offline flicker during reconnections.
|
|
121
|
+
|
|
122
|
+
### Dapr vs Direct Mode
|
|
123
|
+
|
|
124
|
+
In Kubernetes with Dapr, events flow through the Dapr sidecar's PubSub component (typically Redis Streams). For local development without Dapr, Nucleus falls back to direct in-process event delivery.
|
|
125
|
+
|
|
126
|
+
Set \`redis.withDapr: false\` in your config for local development. The PubSub API surface remains the same — only the transport changes.
|
|
127
|
+
`,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
]
|
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import type { DocItem } from '../docsData'
|
|
2
|
-
|
|
3
|
-
export const storageCdnItems: DocItem[] = [
|
|
4
|
-
{
|
|
5
|
-
id: 'storage-overview',
|
|
6
|
-
title: 'File Storage',
|
|
7
|
-
subItems: [
|
|
8
|
-
{
|
|
9
|
-
id: 'storage-how-it-works',
|
|
10
|
-
title: 'How File Storage Works',
|
|
11
|
-
content: `
|
|
12
|
-
## How File Storage Works
|
|
13
|
-
|
|
14
|
-
Nucleus provides built-in file upload and storage capabilities. Files are stored on the local filesystem (or a mounted volume in K8s) and served through a CDN-like endpoint with caching, ETag support, and range requests.
|
|
15
|
-
|
|
16
|
-
### Upload Flow
|
|
17
|
-
|
|
18
|
-
1. Client sends a multipart/form-data request to the storage endpoint or a FormData entity endpoint
|
|
19
|
-
2. Nucleus validates each file against size limits, allowed/blocked MIME types
|
|
20
|
-
3. Valid files are saved to the configured storage path with a unique filename
|
|
21
|
-
4. File metadata (original name, size, MIME type, storage path) is returned
|
|
22
|
-
|
|
23
|
-
### Storage Endpoint
|
|
24
|
-
|
|
25
|
-
\`\`\`
|
|
26
|
-
POST /storage/upload
|
|
27
|
-
Content-Type: multipart/form-data
|
|
28
|
-
\`\`\`
|
|
29
|
-
|
|
30
|
-
The upload endpoint accepts files in the configured \`filesField\` (default: \`"files"\`). Multiple files can be uploaded in a single request.
|
|
31
|
-
|
|
32
|
-
### Response
|
|
33
|
-
|
|
34
|
-
\`\`\`json
|
|
35
|
-
{
|
|
36
|
-
"success": true,
|
|
37
|
-
"data": {
|
|
38
|
-
"files": [
|
|
39
|
-
{
|
|
40
|
-
"originalName": "photo.jpg",
|
|
41
|
-
"fileName": "a1b2c3d4-photo.jpg",
|
|
42
|
-
"mimeType": "image/jpeg",
|
|
43
|
-
"size": 245760,
|
|
44
|
-
"path": "/storage/files/a1b2c3d4-photo.jpg",
|
|
45
|
-
"url": "/cdn/a1b2c3d4-photo.jpg"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
\`\`\`
|
|
51
|
-
|
|
52
|
-
### File Validation
|
|
53
|
-
|
|
54
|
-
Files are validated before storage:
|
|
55
|
-
|
|
56
|
-
| Check | Config Field | Description |
|
|
57
|
-
|-------|-------------|-------------|
|
|
58
|
-
| **Size** | \`maxFileSizeBytes\` | Maximum file size in bytes (default: 10MB) |
|
|
59
|
-
| **Allowed types** | \`allowedMimeTypes\` | Whitelist of MIME types (supports wildcards like \`"image/*"\`) |
|
|
60
|
-
| **Blocked types** | \`blockedMimeTypes\` | Blacklist of MIME types |
|
|
61
|
-
|
|
62
|
-
If a file fails validation, it's rejected with a descriptive error message and the remaining files continue processing.
|
|
63
|
-
|
|
64
|
-
### File Deletion
|
|
65
|
-
|
|
66
|
-
\`\`\`
|
|
67
|
-
DELETE /storage/:fileName
|
|
68
|
-
\`\`\`
|
|
69
|
-
|
|
70
|
-
Deletes the file from disk and removes the metadata record.
|
|
71
|
-
`,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: 'storage-config',
|
|
75
|
-
title: 'Storage Configuration',
|
|
76
|
-
content: `
|
|
77
|
-
## Storage Configuration
|
|
78
|
-
|
|
79
|
-
\`\`\`json
|
|
80
|
-
{
|
|
81
|
-
"storage": {
|
|
82
|
-
"enabled": true,
|
|
83
|
-
"basePath": "/storage",
|
|
84
|
-
"maxFileSizeBytes": 10485760,
|
|
85
|
-
"allowedMimeTypes": ["image/*", "application/pdf", "text/*"],
|
|
86
|
-
"blockedMimeTypes": ["application/x-msdownload"],
|
|
87
|
-
"cdn": {
|
|
88
|
-
"enabled": true,
|
|
89
|
-
"basePath": "/cdn",
|
|
90
|
-
"cacheMaxAge": 86400,
|
|
91
|
-
"enableRangeRequests": true,
|
|
92
|
-
"enableEtag": true,
|
|
93
|
-
"corsOrigins": ["https://yourapp.com"]
|
|
94
|
-
},
|
|
95
|
-
"formData": {
|
|
96
|
-
"filesField": "files",
|
|
97
|
-
"dataField": "data",
|
|
98
|
-
"maxFiles": 10
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
\`\`\`
|
|
103
|
-
|
|
104
|
-
| Field | Type | Default | Description |
|
|
105
|
-
|-------|------|---------|-------------|
|
|
106
|
-
| \`enabled\` | boolean | false | Enable storage system |
|
|
107
|
-
| \`basePath\` | string | \`"/storage"\` | Upload endpoint base path |
|
|
108
|
-
| \`maxFileSizeBytes\` | number | 10485760 | Max file size (10MB) |
|
|
109
|
-
| \`allowedMimeTypes\` | string[] | all | Whitelist (supports \`"image/*"\` wildcards) |
|
|
110
|
-
| \`blockedMimeTypes\` | string[] | none | Blacklist |
|
|
111
|
-
| \`formData.filesField\` | string | \`"files"\` | FormData field name for files |
|
|
112
|
-
| \`formData.dataField\` | string | \`"data"\` | FormData field name for JSON data |
|
|
113
|
-
| \`formData.maxFiles\` | number | 10 | Max files per upload |
|
|
114
|
-
`,
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: 'cdn-serving',
|
|
120
|
-
title: 'CDN Serving',
|
|
121
|
-
subItems: [
|
|
122
|
-
{
|
|
123
|
-
id: 'cdn-overview',
|
|
124
|
-
title: 'How CDN Serving Works',
|
|
125
|
-
content: `
|
|
126
|
-
## CDN Serving
|
|
127
|
-
|
|
128
|
-
When CDN is enabled, Nucleus serves uploaded files through a dedicated endpoint with HTTP caching optimizations.
|
|
129
|
-
|
|
130
|
-
### CDN Endpoint
|
|
131
|
-
|
|
132
|
-
\`\`\`
|
|
133
|
-
GET /cdn/:fileName
|
|
134
|
-
\`\`\`
|
|
135
|
-
|
|
136
|
-
### Features
|
|
137
|
-
|
|
138
|
-
**Cache-Control Headers** — Files are served with \`Cache-Control: public, max-age={cacheMaxAge}\`. Default is 86400 seconds (24 hours). This tells browsers and CDN proxies to cache the file.
|
|
139
|
-
|
|
140
|
-
**ETag Support** — When \`enableEtag\` is true, Nucleus generates an ETag header based on the file content hash. Subsequent requests with \`If-None-Match\` return 304 Not Modified if the file hasn't changed — saving bandwidth.
|
|
141
|
-
|
|
142
|
-
**Range Requests** — When \`enableRangeRequests\` is true, the endpoint supports HTTP Range headers for partial content delivery. This is essential for:
|
|
143
|
-
- Video/audio streaming (seeking)
|
|
144
|
-
- Resumable downloads
|
|
145
|
-
- Large file progressive loading
|
|
146
|
-
|
|
147
|
-
**CORS** — The \`corsOrigins\` array specifies which origins can access files. This is separate from your main CORS config and applies only to CDN routes.
|
|
148
|
-
|
|
149
|
-
### CDN Configuration
|
|
150
|
-
|
|
151
|
-
\`\`\`json
|
|
152
|
-
{
|
|
153
|
-
"cdn": {
|
|
154
|
-
"enabled": true,
|
|
155
|
-
"basePath": "/cdn",
|
|
156
|
-
"cacheMaxAge": 86400,
|
|
157
|
-
"enableRangeRequests": true,
|
|
158
|
-
"enableEtag": true,
|
|
159
|
-
"corsOrigins": ["https://yourapp.com", "https://admin.yourapp.com"]
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
\`\`\`
|
|
163
|
-
|
|
164
|
-
### Production Tip
|
|
165
|
-
|
|
166
|
-
In production, place a real CDN (like Cloudflare or Azure CDN) in front of the Nucleus CDN endpoint. The CDN will cache files at the edge, reducing load on your server. The Cache-Control and ETag headers Nucleus sets are compatible with all major CDN providers.
|
|
167
|
-
`,
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
]
|
|
1
|
+
import type { DocItem } from '../docsData'
|
|
2
|
+
|
|
3
|
+
export const storageCdnItems: DocItem[] = [
|
|
4
|
+
{
|
|
5
|
+
id: 'storage-overview',
|
|
6
|
+
title: 'File Storage',
|
|
7
|
+
subItems: [
|
|
8
|
+
{
|
|
9
|
+
id: 'storage-how-it-works',
|
|
10
|
+
title: 'How File Storage Works',
|
|
11
|
+
content: `
|
|
12
|
+
## How File Storage Works
|
|
13
|
+
|
|
14
|
+
Nucleus provides built-in file upload and storage capabilities. Files are stored on the local filesystem (or a mounted volume in K8s) and served through a CDN-like endpoint with caching, ETag support, and range requests.
|
|
15
|
+
|
|
16
|
+
### Upload Flow
|
|
17
|
+
|
|
18
|
+
1. Client sends a multipart/form-data request to the storage endpoint or a FormData entity endpoint
|
|
19
|
+
2. Nucleus validates each file against size limits, allowed/blocked MIME types
|
|
20
|
+
3. Valid files are saved to the configured storage path with a unique filename
|
|
21
|
+
4. File metadata (original name, size, MIME type, storage path) is returned
|
|
22
|
+
|
|
23
|
+
### Storage Endpoint
|
|
24
|
+
|
|
25
|
+
\`\`\`
|
|
26
|
+
POST /storage/upload
|
|
27
|
+
Content-Type: multipart/form-data
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
The upload endpoint accepts files in the configured \`filesField\` (default: \`"files"\`). Multiple files can be uploaded in a single request.
|
|
31
|
+
|
|
32
|
+
### Response
|
|
33
|
+
|
|
34
|
+
\`\`\`json
|
|
35
|
+
{
|
|
36
|
+
"success": true,
|
|
37
|
+
"data": {
|
|
38
|
+
"files": [
|
|
39
|
+
{
|
|
40
|
+
"originalName": "photo.jpg",
|
|
41
|
+
"fileName": "a1b2c3d4-photo.jpg",
|
|
42
|
+
"mimeType": "image/jpeg",
|
|
43
|
+
"size": 245760,
|
|
44
|
+
"path": "/storage/files/a1b2c3d4-photo.jpg",
|
|
45
|
+
"url": "/cdn/a1b2c3d4-photo.jpg"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
### File Validation
|
|
53
|
+
|
|
54
|
+
Files are validated before storage:
|
|
55
|
+
|
|
56
|
+
| Check | Config Field | Description |
|
|
57
|
+
|-------|-------------|-------------|
|
|
58
|
+
| **Size** | \`maxFileSizeBytes\` | Maximum file size in bytes (default: 10MB) |
|
|
59
|
+
| **Allowed types** | \`allowedMimeTypes\` | Whitelist of MIME types (supports wildcards like \`"image/*"\`) |
|
|
60
|
+
| **Blocked types** | \`blockedMimeTypes\` | Blacklist of MIME types |
|
|
61
|
+
|
|
62
|
+
If a file fails validation, it's rejected with a descriptive error message and the remaining files continue processing.
|
|
63
|
+
|
|
64
|
+
### File Deletion
|
|
65
|
+
|
|
66
|
+
\`\`\`
|
|
67
|
+
DELETE /storage/:fileName
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
Deletes the file from disk and removes the metadata record.
|
|
71
|
+
`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'storage-config',
|
|
75
|
+
title: 'Storage Configuration',
|
|
76
|
+
content: `
|
|
77
|
+
## Storage Configuration
|
|
78
|
+
|
|
79
|
+
\`\`\`json
|
|
80
|
+
{
|
|
81
|
+
"storage": {
|
|
82
|
+
"enabled": true,
|
|
83
|
+
"basePath": "/storage",
|
|
84
|
+
"maxFileSizeBytes": 10485760,
|
|
85
|
+
"allowedMimeTypes": ["image/*", "application/pdf", "text/*"],
|
|
86
|
+
"blockedMimeTypes": ["application/x-msdownload"],
|
|
87
|
+
"cdn": {
|
|
88
|
+
"enabled": true,
|
|
89
|
+
"basePath": "/cdn",
|
|
90
|
+
"cacheMaxAge": 86400,
|
|
91
|
+
"enableRangeRequests": true,
|
|
92
|
+
"enableEtag": true,
|
|
93
|
+
"corsOrigins": ["https://yourapp.com"]
|
|
94
|
+
},
|
|
95
|
+
"formData": {
|
|
96
|
+
"filesField": "files",
|
|
97
|
+
"dataField": "data",
|
|
98
|
+
"maxFiles": 10
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
\`\`\`
|
|
103
|
+
|
|
104
|
+
| Field | Type | Default | Description |
|
|
105
|
+
|-------|------|---------|-------------|
|
|
106
|
+
| \`enabled\` | boolean | false | Enable storage system |
|
|
107
|
+
| \`basePath\` | string | \`"/storage"\` | Upload endpoint base path |
|
|
108
|
+
| \`maxFileSizeBytes\` | number | 10485760 | Max file size (10MB) |
|
|
109
|
+
| \`allowedMimeTypes\` | string[] | all | Whitelist (supports \`"image/*"\` wildcards) |
|
|
110
|
+
| \`blockedMimeTypes\` | string[] | none | Blacklist |
|
|
111
|
+
| \`formData.filesField\` | string | \`"files"\` | FormData field name for files |
|
|
112
|
+
| \`formData.dataField\` | string | \`"data"\` | FormData field name for JSON data |
|
|
113
|
+
| \`formData.maxFiles\` | number | 10 | Max files per upload |
|
|
114
|
+
`,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'cdn-serving',
|
|
120
|
+
title: 'CDN Serving',
|
|
121
|
+
subItems: [
|
|
122
|
+
{
|
|
123
|
+
id: 'cdn-overview',
|
|
124
|
+
title: 'How CDN Serving Works',
|
|
125
|
+
content: `
|
|
126
|
+
## CDN Serving
|
|
127
|
+
|
|
128
|
+
When CDN is enabled, Nucleus serves uploaded files through a dedicated endpoint with HTTP caching optimizations.
|
|
129
|
+
|
|
130
|
+
### CDN Endpoint
|
|
131
|
+
|
|
132
|
+
\`\`\`
|
|
133
|
+
GET /cdn/:fileName
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
### Features
|
|
137
|
+
|
|
138
|
+
**Cache-Control Headers** — Files are served with \`Cache-Control: public, max-age={cacheMaxAge}\`. Default is 86400 seconds (24 hours). This tells browsers and CDN proxies to cache the file.
|
|
139
|
+
|
|
140
|
+
**ETag Support** — When \`enableEtag\` is true, Nucleus generates an ETag header based on the file content hash. Subsequent requests with \`If-None-Match\` return 304 Not Modified if the file hasn't changed — saving bandwidth.
|
|
141
|
+
|
|
142
|
+
**Range Requests** — When \`enableRangeRequests\` is true, the endpoint supports HTTP Range headers for partial content delivery. This is essential for:
|
|
143
|
+
- Video/audio streaming (seeking)
|
|
144
|
+
- Resumable downloads
|
|
145
|
+
- Large file progressive loading
|
|
146
|
+
|
|
147
|
+
**CORS** — The \`corsOrigins\` array specifies which origins can access files. This is separate from your main CORS config and applies only to CDN routes.
|
|
148
|
+
|
|
149
|
+
### CDN Configuration
|
|
150
|
+
|
|
151
|
+
\`\`\`json
|
|
152
|
+
{
|
|
153
|
+
"cdn": {
|
|
154
|
+
"enabled": true,
|
|
155
|
+
"basePath": "/cdn",
|
|
156
|
+
"cacheMaxAge": 86400,
|
|
157
|
+
"enableRangeRequests": true,
|
|
158
|
+
"enableEtag": true,
|
|
159
|
+
"corsOrigins": ["https://yourapp.com", "https://admin.yourapp.com"]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
### Production Tip
|
|
165
|
+
|
|
166
|
+
In production, place a real CDN (like Cloudflare or Azure CDN) in front of the Nucleus CDN endpoint. The CDN will cache files at the edge, reducing load on your server. The Cache-Control and ETag headers Nucleus sets are compatible with all major CDN providers.
|
|
167
|
+
`,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
]
|