@guinetik/primitives-ts 0.8.2 → 0.8.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 +127 -63
- package/dist/access.types.d.ts +98 -0
- package/dist/access.types.d.ts.map +1 -0
- package/dist/access.types.js +105 -0
- package/dist/access.types.spec.d.ts +2 -0
- package/dist/access.types.spec.d.ts.map +1 -0
- package/dist/access.types.spec.js +38 -0
- package/dist/chat.types.d.ts +11 -11
- package/dist/chat.types.d.ts.map +1 -1
- package/dist/chat.types.js +8 -8
- package/dist/chat.types.spec.js +19 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/type-guards.spec.js +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,31 +40,105 @@ const metrics: SystemMetrics = {
|
|
|
40
40
|
};
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
##
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
## Concept Catalog
|
|
44
|
+
|
|
45
|
+
`primitives-ts` is the contract layer of the Guinetik stack. Every type below is
|
|
46
|
+
consumed by at least two of: the NestJS API, the Vue admin panel, the Firestore
|
|
47
|
+
migration tooling, and guinetik.com itself.
|
|
48
|
+
|
|
49
|
+
```mermaid
|
|
50
|
+
flowchart LR
|
|
51
|
+
P[primitives-ts]
|
|
52
|
+
P --> ID[Identity]
|
|
53
|
+
P --> CO[Content]
|
|
54
|
+
P --> OP[Operations]
|
|
55
|
+
P --> AS[Assistant]
|
|
56
|
+
P --> ST[Storage]
|
|
57
|
+
|
|
58
|
+
ID --> ID1[auth]
|
|
59
|
+
ID --> ID2[access]
|
|
60
|
+
ID --> ID3[totp]
|
|
61
|
+
ID --> ID4[security]
|
|
62
|
+
|
|
63
|
+
CO --> CO1[website]
|
|
64
|
+
CO --> CO2[launchpad]
|
|
65
|
+
CO --> CO3[files]
|
|
66
|
+
|
|
67
|
+
OP --> OP1[system]
|
|
68
|
+
OP --> OP2[agents]
|
|
69
|
+
OP --> OP3[deployments]
|
|
70
|
+
OP --> OP4[github]
|
|
71
|
+
|
|
72
|
+
AS --> AS1[chat]
|
|
73
|
+
AS --> AS2[guards]
|
|
74
|
+
|
|
75
|
+
ST --> ST1[firestore]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### How the domains relate
|
|
79
|
+
|
|
80
|
+
```mermaid
|
|
81
|
+
flowchart LR
|
|
82
|
+
A[auth<br/>who you are] --> B[access<br/>what you may do]
|
|
83
|
+
T[totp<br/>second factor] --> A
|
|
84
|
+
B --> F[FeatureKey]
|
|
85
|
+
F --> C[Content]
|
|
86
|
+
F --> O[Operations]
|
|
87
|
+
F --> X[Assistant]
|
|
88
|
+
C --> S[(firestore)]
|
|
89
|
+
X --> S
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Authentication proves identity, access control turns that identity into a set of
|
|
93
|
+
`FeatureKey` grants, and every other domain is gated by one of those keys. The
|
|
94
|
+
Firestore document types are the persisted shape of whatever the other domains
|
|
95
|
+
produce.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### Identity & Access
|
|
100
|
+
|
|
101
|
+
| Module | Key exports | Purpose |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| `auth.types` | `User`, `AuthResponse`, `LoginPayload`, `AuthProvider`, `UserProvider` | Firebase-backed sign-in, email or Google |
|
|
104
|
+
| `access.types` | `AdminRole`, `FeatureKey`, `FEATURE_CATALOG`, `AdminUser`, `userHasFeature` | Role plus per-feature grants for the admin panel |
|
|
105
|
+
| `totp.types` | `TotpSetupResponse`, `TotpVerifyRequest`, `TotpStatusResponse` | Time-based one-time password enrolment and checks |
|
|
106
|
+
| `security.interface` | `Security`, `SecurityLevel`, `SecurityChallengeResult` | Provider-agnostic challenge contract |
|
|
107
|
+
|
|
108
|
+
An `AdminUser` is an `admin` or a `guest`; a guest sees only the features
|
|
109
|
+
explicitly granted to it. The nine grantable features are `dashboard`, `site`,
|
|
110
|
+
`runtime`, `files`, `launchpad`, `users`, `system`, `chat` and `agents`.
|
|
111
|
+
|
|
112
|
+
### Content
|
|
113
|
+
|
|
114
|
+
| Module | Key exports | Purpose |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `website.types` | `SiteContent`, `SiteMetadata`, `SiteSections`, `Menu`, `Theme`, `Card` | Everything guinetik.com renders |
|
|
117
|
+
| `website-firestore.types` | `ProjectDocument`, `DemoDocument`, `FIRESTORE_COLLECTIONS` | The stored counterparts of the above |
|
|
118
|
+
| `launchpad.types` | `LaunchpadBoard`, `LaunchpadGroup`, `LaunchpadItem` | Bookmark board grouping and layout |
|
|
119
|
+
| `file.types` | `FileMetadata`, `FileUploadResponse`, `FileUploadProgress` | Uploads and their lifecycle |
|
|
120
|
+
|
|
121
|
+
### Operations
|
|
122
|
+
|
|
123
|
+
| Module | Key exports | Purpose |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| `system.types` | `SystemMetrics`, `Container`, `LogEntry`, `NetworkStats`, `CommandResult` | Host and Docker telemetry |
|
|
126
|
+
| `agent.types` | `AgentInfo`, `AgentStatus`, `AgentTask`, `AgentTasksResponse` | Autonomous agent fleet monitoring |
|
|
127
|
+
| `deployment-history.types` | `DeploymentRecord`, `DeploymentHistoryResponse` | What shipped, when, and whether it held |
|
|
128
|
+
| `github.types` | `GitHubRepository`, `GitHubOwner`, `GitHubLicense` | The subset of the GitHub REST shape we consume |
|
|
129
|
+
|
|
130
|
+
### Assistant
|
|
131
|
+
|
|
132
|
+
| Module | Key exports | Purpose |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| `chat.types` | `ChatSession`, `ChatMessage`, `ClaudeModel`, `SendMessageRequest` | Session-based chat with model selection |
|
|
135
|
+
| `type-guards` | `isChatMessage`, `isChatSession`, `isModel`, `isClaudeModel` | Runtime validation at the API boundary |
|
|
136
|
+
|
|
137
|
+
### Storage
|
|
138
|
+
|
|
139
|
+
| Module | Key exports | Purpose |
|
|
140
|
+
| --- | --- | --- |
|
|
141
|
+
| `firestore.types` | `FirestoreDocument`, `FirestoreCollection` | Base document shape every stored type extends |
|
|
68
142
|
|
|
69
143
|
## Development
|
|
70
144
|
|
|
@@ -151,62 +225,52 @@ Available type guards:
|
|
|
151
225
|
|
|
152
226
|
### Publishing Process
|
|
153
227
|
|
|
154
|
-
|
|
228
|
+
Releases are published to the public npm registry by **GitHub Actions using npm
|
|
229
|
+
trusted publishing (OIDC)** — there is no npm token to fetch or set, and
|
|
230
|
+
`npm publish` is never run by hand.
|
|
155
231
|
|
|
156
|
-
1. **
|
|
232
|
+
1. **Make and test your changes** in `src/`, then check the consumers compile:
|
|
157
233
|
```bash
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
npm version major # for breaking changes (0.2.5 -> 1.0.0)
|
|
234
|
+
npm test && npm run build
|
|
235
|
+
# temporary overlay for a quick type-check; the real install replaces it later
|
|
236
|
+
cp -r dist/* ../api/node_modules/@guinetik/primitives-ts/dist/ && (cd ../api && npx tsc --noEmit)
|
|
162
237
|
```
|
|
163
238
|
|
|
164
|
-
2. **
|
|
165
|
-
|
|
166
|
-
|
|
239
|
+
2. **Cut the release** from the monorepo root (bumps `package.json`, commits,
|
|
240
|
+
tags `primitives-v<version>`, pushes branch + tag):
|
|
241
|
+
```powershell
|
|
242
|
+
.\scripts\release-primitives.ps1 # patch: 0.8.1 -> 0.8.2
|
|
243
|
+
.\scripts\release-primitives.ps1 -Bump minor # 0.8.1 -> 0.9.0
|
|
167
244
|
```
|
|
168
245
|
|
|
169
|
-
3. **
|
|
246
|
+
3. **Wait for the workflow** (`.github/workflows/publish-primitives.yml`,
|
|
247
|
+
about a minute) and confirm the registry has it:
|
|
170
248
|
```bash
|
|
171
|
-
|
|
172
|
-
# Set it with: $env:NPM_KEY = "your-npm-access-token"
|
|
173
|
-
npm publish --access public
|
|
249
|
+
npm view @guinetik/primitives-ts version
|
|
174
250
|
```
|
|
175
251
|
|
|
176
|
-
4. **
|
|
252
|
+
4. **Pin the new version in dependent projects** (exact, no `^`/`~`):
|
|
177
253
|
```bash
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
# Then install in each project
|
|
182
|
-
cd ../api
|
|
183
|
-
npm install
|
|
184
|
-
|
|
185
|
-
cd ../admin
|
|
186
|
-
npm install
|
|
254
|
+
cd ../api && npm install --save-exact @guinetik/primitives-ts@<version>
|
|
255
|
+
cd ../admin && npm install --save-exact @guinetik/primitives-ts@<version>
|
|
256
|
+
cd ../db && npm install --save-exact @guinetik/primitives-ts@<version>
|
|
187
257
|
```
|
|
188
258
|
|
|
259
|
+
Full details, one-time trusted-publisher setup and troubleshooting:
|
|
260
|
+
[`docs/development/primitives-publishing.md`](../docs/development/primitives-publishing.md).
|
|
261
|
+
|
|
189
262
|
### Why No Local Linking?
|
|
190
263
|
|
|
191
264
|
- **Prevents version drift** - Ensures all projects use exact versions
|
|
192
265
|
- **Avoids build issues** - npm link can cause TypeScript declaration file problems
|
|
193
|
-
- **Deployment consistency** -
|
|
194
|
-
- **Simple workflow** -
|
|
195
|
-
|
|
196
|
-
### NPM Authentication
|
|
266
|
+
- **Deployment consistency** - Docker build contexts are the app folders, so `../primitives` does not exist there
|
|
267
|
+
- **Simple workflow** - A tag push publishes; consumers just `npm install`
|
|
197
268
|
|
|
198
|
-
|
|
199
|
-
- Stored in: Bitwarden Secrets Manager
|
|
200
|
-
- Secret name: `NPM_KEY`
|
|
201
|
-
- Used by: Local development, CI/CD, and autonomous agents
|
|
269
|
+
### Authentication
|
|
202
270
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
# Or set manually if you have the token
|
|
208
|
-
$env:NPM_KEY = "npm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
209
|
-
```
|
|
271
|
+
None. Installing the package needs no credentials (it is public), and
|
|
272
|
+
publishing is authenticated by the GitHub Actions workflow's OIDC identity,
|
|
273
|
+
registered on npmjs.com as the package's trusted publisher.
|
|
210
274
|
|
|
211
275
|
## License
|
|
212
276
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature-based access control types shared between API and Admin.
|
|
3
|
+
*/
|
|
4
|
+
import type { User } from './auth.types';
|
|
5
|
+
/** Application roles for admin panel users. */
|
|
6
|
+
export type AdminRole = 'admin' | 'guest';
|
|
7
|
+
/** Lifecycle status for admin directory records. */
|
|
8
|
+
export type AdminUserStatus = 'invited' | 'active' | 'disabled';
|
|
9
|
+
/** Avatar resolution strategy for admin users. */
|
|
10
|
+
export type AvatarSource = 'gravatar' | 'google' | 'custom';
|
|
11
|
+
/** Feature keys that gate admin panel pages and API areas. */
|
|
12
|
+
export type FeatureKey = 'dashboard' | 'site' | 'runtime' | 'files' | 'launchpad' | 'users' | 'system' | 'chat' | 'agents';
|
|
13
|
+
/** Canonical ordered list of grantable features. */
|
|
14
|
+
export declare const FEATURE_CATALOG: readonly FeatureKey[];
|
|
15
|
+
/** Human-readable labels for feature checklist UI. */
|
|
16
|
+
export declare const FEATURE_LABELS: Record<FeatureKey, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns true when the value is a known feature key.
|
|
19
|
+
*
|
|
20
|
+
* @param value - Candidate feature key.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isFeatureKey(value: unknown): value is FeatureKey;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes and validates a feature grant list.
|
|
25
|
+
*
|
|
26
|
+
* @param features - Raw feature keys from input or Firestore.
|
|
27
|
+
* @returns Deduplicated feature keys in catalog order.
|
|
28
|
+
* @throws Error when an unknown or duplicate value is present.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeFeatureKeys(features: unknown): FeatureKey[];
|
|
31
|
+
/** Authenticated admin panel user returned by `/auth/me` and login flows. */
|
|
32
|
+
export interface AuthenticatedUser extends User {
|
|
33
|
+
role?: AdminRole;
|
|
34
|
+
features?: FeatureKey[];
|
|
35
|
+
status?: AdminUserStatus;
|
|
36
|
+
avatarSource?: AvatarSource;
|
|
37
|
+
}
|
|
38
|
+
/** Admin directory user exposed by `/users` management APIs. */
|
|
39
|
+
export interface AdminUser {
|
|
40
|
+
id: string;
|
|
41
|
+
uid?: string;
|
|
42
|
+
email: string;
|
|
43
|
+
displayName?: string;
|
|
44
|
+
role: AdminRole;
|
|
45
|
+
features: FeatureKey[];
|
|
46
|
+
status: AdminUserStatus;
|
|
47
|
+
avatarSource: AvatarSource;
|
|
48
|
+
photoURL: string;
|
|
49
|
+
customPhotoURL?: string;
|
|
50
|
+
emailVerified: boolean;
|
|
51
|
+
invitedByUid?: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
lastSignInAt?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Payload for inviting a new admin panel user. */
|
|
57
|
+
export interface InviteAdminUserInput {
|
|
58
|
+
email: string;
|
|
59
|
+
displayName?: string;
|
|
60
|
+
role?: AdminRole;
|
|
61
|
+
features?: FeatureKey[];
|
|
62
|
+
}
|
|
63
|
+
/** Payload for updating an admin directory user. */
|
|
64
|
+
export interface UpdateAdminUserInput {
|
|
65
|
+
displayName?: string;
|
|
66
|
+
status?: AdminUserStatus;
|
|
67
|
+
avatarSource?: AvatarSource;
|
|
68
|
+
customPhotoURL?: string;
|
|
69
|
+
role?: AdminRole;
|
|
70
|
+
features?: FeatureKey[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the effective role for legacy documents without an explicit role.
|
|
74
|
+
*
|
|
75
|
+
* @param role - Stored role, if any.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveAdminRole(role?: AdminRole): AdminRole;
|
|
78
|
+
/**
|
|
79
|
+
* Returns whether the user has admin-level unrestricted access.
|
|
80
|
+
*
|
|
81
|
+
* @param user - Authenticated or directory user.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isAdminUser(user: Pick<AuthenticatedUser, 'role'>): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether a user may access a feature.
|
|
86
|
+
*
|
|
87
|
+
* @param user - Authenticated user with role and feature grants.
|
|
88
|
+
* @param feature - Required feature key.
|
|
89
|
+
*/
|
|
90
|
+
export declare function userHasFeature(user: Pick<AuthenticatedUser, 'role' | 'features'>, feature: FeatureKey): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Checks whether a user may access at least one of the given features.
|
|
93
|
+
*
|
|
94
|
+
* @param user - Authenticated user with role and feature grants.
|
|
95
|
+
* @param features - Candidate feature keys.
|
|
96
|
+
*/
|
|
97
|
+
export declare function userHasAnyFeature(user: Pick<AuthenticatedUser, 'role' | 'features'>, features: readonly FeatureKey[]): boolean;
|
|
98
|
+
//# sourceMappingURL=access.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.types.d.ts","sourceRoot":"","sources":["../src/access.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Feature-based access control types shared between API and Admin.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FEATURE_LABELS = exports.FEATURE_CATALOG = void 0;
|
|
7
|
+
exports.isFeatureKey = isFeatureKey;
|
|
8
|
+
exports.normalizeFeatureKeys = normalizeFeatureKeys;
|
|
9
|
+
exports.resolveAdminRole = resolveAdminRole;
|
|
10
|
+
exports.isAdminUser = isAdminUser;
|
|
11
|
+
exports.userHasFeature = userHasFeature;
|
|
12
|
+
exports.userHasAnyFeature = userHasAnyFeature;
|
|
13
|
+
/** Canonical ordered list of grantable features. */
|
|
14
|
+
exports.FEATURE_CATALOG = [
|
|
15
|
+
'dashboard',
|
|
16
|
+
'site',
|
|
17
|
+
'runtime',
|
|
18
|
+
'files',
|
|
19
|
+
'launchpad',
|
|
20
|
+
'users',
|
|
21
|
+
'system',
|
|
22
|
+
'chat',
|
|
23
|
+
'agents',
|
|
24
|
+
];
|
|
25
|
+
/** Human-readable labels for feature checklist UI. */
|
|
26
|
+
exports.FEATURE_LABELS = {
|
|
27
|
+
dashboard: 'Dashboard',
|
|
28
|
+
site: 'Site',
|
|
29
|
+
runtime: 'Runtime',
|
|
30
|
+
files: 'File uploads',
|
|
31
|
+
launchpad: 'Launchpad',
|
|
32
|
+
users: 'Users',
|
|
33
|
+
system: 'System monitoring',
|
|
34
|
+
chat: 'Chat',
|
|
35
|
+
agents: 'Agents',
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Returns true when the value is a known feature key.
|
|
39
|
+
*
|
|
40
|
+
* @param value - Candidate feature key.
|
|
41
|
+
*/
|
|
42
|
+
function isFeatureKey(value) {
|
|
43
|
+
return typeof value === 'string' && exports.FEATURE_CATALOG.includes(value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Normalizes and validates a feature grant list.
|
|
47
|
+
*
|
|
48
|
+
* @param features - Raw feature keys from input or Firestore.
|
|
49
|
+
* @returns Deduplicated feature keys in catalog order.
|
|
50
|
+
* @throws Error when an unknown or duplicate value is present.
|
|
51
|
+
*/
|
|
52
|
+
function normalizeFeatureKeys(features) {
|
|
53
|
+
if (!Array.isArray(features)) {
|
|
54
|
+
throw new Error('Features must be an array');
|
|
55
|
+
}
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
for (const value of features) {
|
|
58
|
+
if (!isFeatureKey(value)) {
|
|
59
|
+
throw new Error(`Unknown feature key: ${String(value)}`);
|
|
60
|
+
}
|
|
61
|
+
if (seen.has(value)) {
|
|
62
|
+
throw new Error(`Duplicate feature key: ${value}`);
|
|
63
|
+
}
|
|
64
|
+
seen.add(value);
|
|
65
|
+
}
|
|
66
|
+
return exports.FEATURE_CATALOG.filter((key) => seen.has(key));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolves the effective role for legacy documents without an explicit role.
|
|
70
|
+
*
|
|
71
|
+
* @param role - Stored role, if any.
|
|
72
|
+
*/
|
|
73
|
+
function resolveAdminRole(role) {
|
|
74
|
+
return role ?? 'admin';
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns whether the user has admin-level unrestricted access.
|
|
78
|
+
*
|
|
79
|
+
* @param user - Authenticated or directory user.
|
|
80
|
+
*/
|
|
81
|
+
function isAdminUser(user) {
|
|
82
|
+
return resolveAdminRole(user.role) === 'admin';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether a user may access a feature.
|
|
86
|
+
*
|
|
87
|
+
* @param user - Authenticated user with role and feature grants.
|
|
88
|
+
* @param feature - Required feature key.
|
|
89
|
+
*/
|
|
90
|
+
function userHasFeature(user, feature) {
|
|
91
|
+
if (isAdminUser(user))
|
|
92
|
+
return true;
|
|
93
|
+
return user.features?.includes(feature) ?? false;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Checks whether a user may access at least one of the given features.
|
|
97
|
+
*
|
|
98
|
+
* @param user - Authenticated user with role and feature grants.
|
|
99
|
+
* @param features - Candidate feature keys.
|
|
100
|
+
*/
|
|
101
|
+
function userHasAnyFeature(user, features) {
|
|
102
|
+
if (isAdminUser(user))
|
|
103
|
+
return true;
|
|
104
|
+
return features.some((feature) => user.features?.includes(feature));
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.types.spec.d.ts","sourceRoot":"","sources":["../src/access.types.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const access_types_1 = require("./access.types");
|
|
4
|
+
describe('access.types', () => {
|
|
5
|
+
it('recognizes valid feature keys', () => {
|
|
6
|
+
expect((0, access_types_1.isFeatureKey)('dashboard')).toBe(true);
|
|
7
|
+
expect((0, access_types_1.isFeatureKey)('unknown')).toBe(false);
|
|
8
|
+
});
|
|
9
|
+
it('normalizes feature keys in catalog order', () => {
|
|
10
|
+
expect((0, access_types_1.normalizeFeatureKeys)(['chat', 'site'])).toEqual(['site', 'chat']);
|
|
11
|
+
});
|
|
12
|
+
it('rejects duplicate feature keys', () => {
|
|
13
|
+
expect(() => (0, access_types_1.normalizeFeatureKeys)(['chat', 'site', 'chat'])).toThrow(/Duplicate feature key/);
|
|
14
|
+
});
|
|
15
|
+
it('rejects unknown feature keys', () => {
|
|
16
|
+
expect(() => (0, access_types_1.normalizeFeatureKeys)(['dashboard', 'billing'])).toThrow(/Unknown feature key/);
|
|
17
|
+
});
|
|
18
|
+
it('defaults missing roles to admin for legacy users', () => {
|
|
19
|
+
expect((0, access_types_1.resolveAdminRole)(undefined)).toBe('admin');
|
|
20
|
+
expect((0, access_types_1.resolveAdminRole)('guest')).toBe('guest');
|
|
21
|
+
});
|
|
22
|
+
it('grants admins every feature without explicit grants', () => {
|
|
23
|
+
const admin = { role: 'admin', features: [] };
|
|
24
|
+
expect((0, access_types_1.userHasFeature)(admin, 'system')).toBe(true);
|
|
25
|
+
expect((0, access_types_1.userHasAnyFeature)(admin, ['dashboard', 'launchpad'])).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
it('requires explicit grants for guests', () => {
|
|
28
|
+
const guest = { role: 'guest', features: ['dashboard'] };
|
|
29
|
+
expect((0, access_types_1.userHasFeature)(guest, 'dashboard')).toBe(true);
|
|
30
|
+
expect((0, access_types_1.userHasFeature)(guest, 'system')).toBe(false);
|
|
31
|
+
expect((0, access_types_1.userHasAnyFeature)(guest, ['dashboard', 'launchpad'])).toBe(true);
|
|
32
|
+
expect((0, access_types_1.userHasAnyFeature)(guest, ['system', 'chat'])).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
it('exposes a stable feature catalog', () => {
|
|
35
|
+
expect(access_types_1.FEATURE_CATALOG).toContain('users');
|
|
36
|
+
expect(access_types_1.FEATURE_CATALOG.length).toBe(9);
|
|
37
|
+
});
|
|
38
|
+
});
|
package/dist/chat.types.d.ts
CHANGED
|
@@ -20,14 +20,14 @@ export interface Model {
|
|
|
20
20
|
* @deprecated Use Model type instead
|
|
21
21
|
*/
|
|
22
22
|
export declare enum ClaudeModel {
|
|
23
|
-
/** Claude Haiku
|
|
24
|
-
|
|
25
|
-
/** Claude Sonnet
|
|
26
|
-
|
|
27
|
-
/** Claude
|
|
28
|
-
|
|
29
|
-
/** Claude
|
|
30
|
-
|
|
23
|
+
/** Claude Haiku 4.5 - Fastest, most cost-effective */
|
|
24
|
+
HAIKU_4_5 = "claude-haiku-4-5",
|
|
25
|
+
/** Claude Sonnet 5 - Balanced performance and quality */
|
|
26
|
+
SONNET_5 = "claude-sonnet-5",
|
|
27
|
+
/** Claude Opus 5 - Powerful reasoning, adaptive thinking on by default */
|
|
28
|
+
OPUS_5 = "claude-opus-5",
|
|
29
|
+
/** Claude Fable 5 - Most capable model, premium pricing */
|
|
30
|
+
FABLE_5 = "claude-fable-5"
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Model metadata for display in UI
|
|
@@ -55,7 +55,7 @@ export interface ChatSession {
|
|
|
55
55
|
id: string;
|
|
56
56
|
/** User ID who created the session */
|
|
57
57
|
userId: string;
|
|
58
|
-
/** Current model ID for the session (e.g., "claude-
|
|
58
|
+
/** Current model ID for the session (e.g., "claude-opus-5") */
|
|
59
59
|
model: string;
|
|
60
60
|
/** Session creation timestamp */
|
|
61
61
|
createdAt: Date;
|
|
@@ -89,7 +89,7 @@ export interface SendMessageRequest {
|
|
|
89
89
|
sessionId?: string;
|
|
90
90
|
/** User message content */
|
|
91
91
|
message: string;
|
|
92
|
-
/** Model ID to use for response (e.g., "claude-
|
|
92
|
+
/** Model ID to use for response (e.g., "claude-opus-5") */
|
|
93
93
|
model: string;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
@@ -127,7 +127,7 @@ export interface GetSessionMessagesResponse {
|
|
|
127
127
|
* Create new session request
|
|
128
128
|
*/
|
|
129
129
|
export interface CreateSessionRequest {
|
|
130
|
-
/** Initial model ID for the session (e.g., "claude-
|
|
130
|
+
/** Initial model ID for the session (e.g., "claude-opus-5") */
|
|
131
131
|
model: string;
|
|
132
132
|
/** Optional session title */
|
|
133
133
|
title?: string;
|
package/dist/chat.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../src/chat.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;CACpD;AAED;;;GAGG;AACH,oBAAY,WAAW;IACrB,sDAAsD;IACtD,SAAS,
|
|
1
|
+
{"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../src/chat.types.ts"],"names":[],"mappings":"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"}
|
package/dist/chat.types.js
CHANGED
|
@@ -11,12 +11,12 @@ exports.ClaudeModel = void 0;
|
|
|
11
11
|
*/
|
|
12
12
|
var ClaudeModel;
|
|
13
13
|
(function (ClaudeModel) {
|
|
14
|
-
/** Claude Haiku
|
|
15
|
-
ClaudeModel["
|
|
16
|
-
/** Claude Sonnet
|
|
17
|
-
ClaudeModel["
|
|
18
|
-
/** Claude
|
|
19
|
-
ClaudeModel["
|
|
20
|
-
/** Claude
|
|
21
|
-
ClaudeModel["
|
|
14
|
+
/** Claude Haiku 4.5 - Fastest, most cost-effective */
|
|
15
|
+
ClaudeModel["HAIKU_4_5"] = "claude-haiku-4-5";
|
|
16
|
+
/** Claude Sonnet 5 - Balanced performance and quality */
|
|
17
|
+
ClaudeModel["SONNET_5"] = "claude-sonnet-5";
|
|
18
|
+
/** Claude Opus 5 - Powerful reasoning, adaptive thinking on by default */
|
|
19
|
+
ClaudeModel["OPUS_5"] = "claude-opus-5";
|
|
20
|
+
/** Claude Fable 5 - Most capable model, premium pricing */
|
|
21
|
+
ClaudeModel["FABLE_5"] = "claude-fable-5";
|
|
22
22
|
})(ClaudeModel || (exports.ClaudeModel = ClaudeModel = {}));
|
package/dist/chat.types.spec.js
CHANGED
|
@@ -17,35 +17,35 @@ describe('Chat Types', () => {
|
|
|
17
17
|
const modelCount = Object.keys(chat_types_1.ClaudeModel).length;
|
|
18
18
|
expect(modelCount).toBe(4);
|
|
19
19
|
});
|
|
20
|
-
it('should have
|
|
21
|
-
expect(chat_types_1.ClaudeModel.
|
|
20
|
+
it('should have HAIKU_4_5 with correct ID', () => {
|
|
21
|
+
expect(chat_types_1.ClaudeModel.HAIKU_4_5).toBe('claude-haiku-4-5');
|
|
22
22
|
});
|
|
23
|
-
it('should have
|
|
24
|
-
expect(chat_types_1.ClaudeModel.
|
|
23
|
+
it('should have SONNET_5 with correct ID', () => {
|
|
24
|
+
expect(chat_types_1.ClaudeModel.SONNET_5).toBe('claude-sonnet-5');
|
|
25
25
|
});
|
|
26
|
-
it('should have
|
|
27
|
-
expect(chat_types_1.ClaudeModel.
|
|
26
|
+
it('should have OPUS_5 with correct ID', () => {
|
|
27
|
+
expect(chat_types_1.ClaudeModel.OPUS_5).toBe('claude-opus-5');
|
|
28
28
|
});
|
|
29
|
-
it('should have
|
|
30
|
-
expect(chat_types_1.ClaudeModel.
|
|
29
|
+
it('should have FABLE_5 with correct ID', () => {
|
|
30
|
+
expect(chat_types_1.ClaudeModel.FABLE_5).toBe('claude-fable-5');
|
|
31
31
|
});
|
|
32
32
|
it('should not have duplicate model IDs', () => {
|
|
33
33
|
const modelIds = Object.values(chat_types_1.ClaudeModel);
|
|
34
34
|
const uniqueIds = new Set(modelIds);
|
|
35
35
|
expect(modelIds.length).toBe(uniqueIds.size);
|
|
36
36
|
});
|
|
37
|
-
it('should
|
|
37
|
+
it('should not carry legacy date suffixes', () => {
|
|
38
38
|
const allModels = Object.values(chat_types_1.ClaudeModel);
|
|
39
|
-
const datePattern =
|
|
39
|
+
const datePattern = /-\d{8}$/; // legacy YYYYMMDD snapshot suffix
|
|
40
40
|
allModels.forEach((modelId) => {
|
|
41
|
-
expect(modelId).toMatch(datePattern);
|
|
41
|
+
expect(modelId).not.toMatch(datePattern);
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
it('should be accessible by enum key', () => {
|
|
45
|
-
expect(chat_types_1.ClaudeModel['
|
|
46
|
-
expect(chat_types_1.ClaudeModel['
|
|
47
|
-
expect(chat_types_1.ClaudeModel['
|
|
48
|
-
expect(chat_types_1.ClaudeModel['
|
|
45
|
+
expect(chat_types_1.ClaudeModel['HAIKU_4_5']).toBeDefined();
|
|
46
|
+
expect(chat_types_1.ClaudeModel['SONNET_5']).toBeDefined();
|
|
47
|
+
expect(chat_types_1.ClaudeModel['OPUS_5']).toBeDefined();
|
|
48
|
+
expect(chat_types_1.ClaudeModel['FABLE_5']).toBeDefined();
|
|
49
49
|
});
|
|
50
50
|
it('should support iteration over enum values', () => {
|
|
51
51
|
const models = [];
|
|
@@ -53,10 +53,10 @@ describe('Chat Types', () => {
|
|
|
53
53
|
models.push(model);
|
|
54
54
|
}
|
|
55
55
|
expect(models).toHaveLength(4);
|
|
56
|
-
expect(models).toContain('claude-
|
|
57
|
-
expect(models).toContain('claude-
|
|
58
|
-
expect(models).toContain('claude-
|
|
59
|
-
expect(models).toContain('claude-
|
|
56
|
+
expect(models).toContain('claude-haiku-4-5');
|
|
57
|
+
expect(models).toContain('claude-sonnet-5');
|
|
58
|
+
expect(models).toContain('claude-opus-5');
|
|
59
|
+
expect(models).toContain('claude-fable-5');
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
describe('Model Tier Values', () => {
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,cAAc,CAAC;AAG7B,cAAc,4BAA4B,CAAC;AAG3C,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC;AAG9B,cAAc,eAAe,CAAC;AAG9B,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,cAAc,CAAC;AAG7B,cAAc,4BAA4B,CAAC;AAG3C,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC;AAG9B,cAAc,eAAe,CAAC;AAG9B,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.SecurityLevel = void 0;
|
|
27
27
|
// Auth types
|
|
28
28
|
__exportStar(require("./auth.types"), exports);
|
|
29
|
+
// Access control types
|
|
30
|
+
__exportStar(require("./access.types"), exports);
|
|
29
31
|
// System monitoring types
|
|
30
32
|
__exportStar(require("./system.types"), exports);
|
|
31
33
|
// Website/Site content types
|
package/dist/type-guards.spec.js
CHANGED
|
@@ -35,7 +35,7 @@ describe('Type Guards', () => {
|
|
|
35
35
|
it('should return true for ChatMessage with optional model', () => {
|
|
36
36
|
const messageWithModel = {
|
|
37
37
|
...validMessage,
|
|
38
|
-
model: 'claude-
|
|
38
|
+
model: 'claude-opus-5',
|
|
39
39
|
};
|
|
40
40
|
expect((0, type_guards_1.isChatMessage)(messageWithModel)).toBe(true);
|
|
41
41
|
});
|
|
@@ -68,7 +68,7 @@ describe('Type Guards', () => {
|
|
|
68
68
|
const validSession = {
|
|
69
69
|
id: 'session_123',
|
|
70
70
|
userId: 'user_456',
|
|
71
|
-
model: 'claude-
|
|
71
|
+
model: 'claude-opus-5',
|
|
72
72
|
createdAt: new Date(),
|
|
73
73
|
updatedAt: new Date(),
|
|
74
74
|
};
|
|
@@ -105,7 +105,7 @@ describe('Type Guards', () => {
|
|
|
105
105
|
describe('isModel', () => {
|
|
106
106
|
const validModel = {
|
|
107
107
|
type: 'model',
|
|
108
|
-
id: 'claude-
|
|
108
|
+
id: 'claude-opus-5',
|
|
109
109
|
display_name: 'Claude Sonnet 4.5',
|
|
110
110
|
created_at: '2025-09-29T00:00:00Z',
|
|
111
111
|
};
|
|
@@ -139,19 +139,19 @@ describe('Type Guards', () => {
|
|
|
139
139
|
});
|
|
140
140
|
describe('isClaudeModel', () => {
|
|
141
141
|
it('should return true for valid ClaudeModel enum values', () => {
|
|
142
|
-
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.
|
|
143
|
-
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.
|
|
144
|
-
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.
|
|
145
|
-
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.
|
|
142
|
+
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.HAIKU_4_5)).toBe(true);
|
|
143
|
+
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.SONNET_5)).toBe(true);
|
|
144
|
+
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.OPUS_5)).toBe(true);
|
|
145
|
+
expect((0, type_guards_1.isClaudeModel)(chat_types_1.ClaudeModel.FABLE_5)).toBe(true);
|
|
146
146
|
});
|
|
147
147
|
it('should return true for valid model ID strings', () => {
|
|
148
|
-
expect((0, type_guards_1.isClaudeModel)('claude-
|
|
149
|
-
expect((0, type_guards_1.isClaudeModel)('claude-
|
|
150
|
-
expect((0, type_guards_1.isClaudeModel)('claude-
|
|
151
|
-
expect((0, type_guards_1.isClaudeModel)('claude-
|
|
148
|
+
expect((0, type_guards_1.isClaudeModel)('claude-haiku-4-5')).toBe(true);
|
|
149
|
+
expect((0, type_guards_1.isClaudeModel)('claude-sonnet-5')).toBe(true);
|
|
150
|
+
expect((0, type_guards_1.isClaudeModel)('claude-opus-5')).toBe(true);
|
|
151
|
+
expect((0, type_guards_1.isClaudeModel)('claude-fable-5')).toBe(true);
|
|
152
152
|
});
|
|
153
153
|
it('should return false for invalid model IDs', () => {
|
|
154
|
-
expect((0, type_guards_1.isClaudeModel)('claude-
|
|
154
|
+
expect((0, type_guards_1.isClaudeModel)('claude-3-opus-20240229')).toBe(false);
|
|
155
155
|
expect((0, type_guards_1.isClaudeModel)('gpt-4')).toBe(false);
|
|
156
156
|
expect((0, type_guards_1.isClaudeModel)('invalid-model')).toBe(false);
|
|
157
157
|
expect((0, type_guards_1.isClaudeModel)('')).toBe(false);
|
|
@@ -166,7 +166,7 @@ describe('Type Guards', () => {
|
|
|
166
166
|
describe('isSendMessageRequest', () => {
|
|
167
167
|
const validRequest = {
|
|
168
168
|
message: 'Hello, Claude!',
|
|
169
|
-
model: 'claude-
|
|
169
|
+
model: 'claude-opus-5',
|
|
170
170
|
};
|
|
171
171
|
it('should return true for valid SendMessageRequest', () => {
|
|
172
172
|
expect((0, type_guards_1.isSendMessageRequest)(validRequest)).toBe(true);
|
|
@@ -194,7 +194,7 @@ describe('Type Guards', () => {
|
|
|
194
194
|
});
|
|
195
195
|
describe('isCreateSessionRequest', () => {
|
|
196
196
|
const validRequest = {
|
|
197
|
-
model: 'claude-
|
|
197
|
+
model: 'claude-opus-5',
|
|
198
198
|
};
|
|
199
199
|
it('should return true for valid CreateSessionRequest', () => {
|
|
200
200
|
expect((0, type_guards_1.isCreateSessionRequest)(validRequest)).toBe(true);
|