@defai.digital/ax-cli 3.8.10 → 3.8.11
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 +54 -1
- package/dist/index.js +0 -0
- package/node_modules/@ax-cli/schemas/dist/index.d.ts +14 -0
- package/node_modules/@ax-cli/schemas/dist/index.d.ts.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/index.js +19 -0
- package/node_modules/@ax-cli/schemas/dist/index.js.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/brand-types.d.ts +308 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/brand-types.d.ts.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/brand-types.js +243 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/brand-types.js.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/enums.d.ts +227 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/enums.d.ts.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/enums.js +222 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/enums.js.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/id-types.d.ts +286 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/id-types.d.ts.map +1 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/id-types.js +136 -0
- package/node_modules/@ax-cli/schemas/dist/public/core/id-types.js.map +1 -0
- package/package.json +4 -2
- package/packages/schemas/dist/index.d.ts +14 -0
- package/packages/schemas/dist/index.d.ts.map +1 -0
- package/packages/schemas/dist/index.js +19 -0
- package/packages/schemas/dist/index.js.map +1 -0
- package/packages/schemas/dist/public/core/brand-types.d.ts +308 -0
- package/packages/schemas/dist/public/core/brand-types.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/brand-types.js +243 -0
- package/packages/schemas/dist/public/core/brand-types.js.map +1 -0
- package/packages/schemas/dist/public/core/enums.d.ts +227 -0
- package/packages/schemas/dist/public/core/enums.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/enums.js +222 -0
- package/packages/schemas/dist/public/core/enums.js.map +1 -0
- package/packages/schemas/dist/public/core/id-types.d.ts +286 -0
- package/packages/schemas/dist/public/core/id-types.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/id-types.js +136 -0
- package/packages/schemas/dist/public/core/id-types.js.map +1 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID Brand Types for @ax-cli/schemas
|
|
3
|
+
*
|
|
4
|
+
* This file contains all ID brand type factories using the createBrandFactory utility.
|
|
5
|
+
* Each ID type is validated and branded to prevent mixing different ID types at compile time.
|
|
6
|
+
*
|
|
7
|
+
* SECURITY: All IDs MUST be validated at system boundaries using the provided factories.
|
|
8
|
+
*
|
|
9
|
+
* @module id-types
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { type Brand } from './brand-types.js';
|
|
13
|
+
/**
|
|
14
|
+
* API Response ID - Unique identifier for API responses
|
|
15
|
+
*
|
|
16
|
+
* @security MUST validate at API boundaries
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = ApiResponseId.schema.safeParse(userInput);
|
|
20
|
+
* if (result.success) {
|
|
21
|
+
* const id = result.data; // Validated and branded
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const ApiResponseId: {
|
|
26
|
+
schema: {
|
|
27
|
+
parse: (input: unknown) => Brand<string, "ApiResponseId">;
|
|
28
|
+
safeParse: (input: unknown) => {
|
|
29
|
+
success: true;
|
|
30
|
+
data: Brand<string, "ApiResponseId">;
|
|
31
|
+
} | {
|
|
32
|
+
success: false;
|
|
33
|
+
error: unknown;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
parse: (input: unknown) => Brand<string, "ApiResponseId">;
|
|
37
|
+
is: (value: unknown) => value is Brand<string, "ApiResponseId">;
|
|
38
|
+
brandName: "ApiResponseId";
|
|
39
|
+
};
|
|
40
|
+
export type ApiResponseId = Brand<string, 'ApiResponseId'>;
|
|
41
|
+
/**
|
|
42
|
+
* Tool Call ID - Unique identifier for tool calls in API responses
|
|
43
|
+
*
|
|
44
|
+
* @security MUST validate at API boundaries
|
|
45
|
+
*/
|
|
46
|
+
export declare const ToolCallId: {
|
|
47
|
+
schema: {
|
|
48
|
+
parse: (input: unknown) => Brand<string, "ToolCallId">;
|
|
49
|
+
safeParse: (input: unknown) => {
|
|
50
|
+
success: true;
|
|
51
|
+
data: Brand<string, "ToolCallId">;
|
|
52
|
+
} | {
|
|
53
|
+
success: false;
|
|
54
|
+
error: unknown;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
parse: (input: unknown) => Brand<string, "ToolCallId">;
|
|
58
|
+
is: (value: unknown) => value is Brand<string, "ToolCallId">;
|
|
59
|
+
brandName: "ToolCallId";
|
|
60
|
+
};
|
|
61
|
+
export type ToolCallId = Brand<string, 'ToolCallId'>;
|
|
62
|
+
/**
|
|
63
|
+
* ToolCallIdSchema - Zod schema for ToolCallId that can be used in z.object()
|
|
64
|
+
* This transforms strings to branded ToolCallId types
|
|
65
|
+
*/
|
|
66
|
+
export declare const ToolCallIdSchema: z.ZodEffects<z.ZodString, Brand<string, "ToolCallId">, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Model ID - Identifier for AI models
|
|
69
|
+
*
|
|
70
|
+
* @security MUST validate at configuration boundaries
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const modelId = ModelId.parse('glm-4.6'); // Validates and brands
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const ModelId: {
|
|
77
|
+
schema: {
|
|
78
|
+
parse: (input: unknown) => Brand<string, "ModelId">;
|
|
79
|
+
safeParse: (input: unknown) => {
|
|
80
|
+
success: true;
|
|
81
|
+
data: Brand<string, "ModelId">;
|
|
82
|
+
} | {
|
|
83
|
+
success: false;
|
|
84
|
+
error: unknown;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
parse: (input: unknown) => Brand<string, "ModelId">;
|
|
88
|
+
is: (value: unknown) => value is Brand<string, "ModelId">;
|
|
89
|
+
brandName: "ModelId";
|
|
90
|
+
};
|
|
91
|
+
export type ModelId = Brand<string, 'ModelId'>;
|
|
92
|
+
/**
|
|
93
|
+
* ModelIdSchema - Zod schema for ModelId that can be used in z.object()
|
|
94
|
+
* This transforms strings to branded ModelId types
|
|
95
|
+
*/
|
|
96
|
+
export declare const ModelIdSchema: z.ZodEffects<z.ZodString, Brand<string, "ModelId">, string>;
|
|
97
|
+
/**
|
|
98
|
+
* Tenant ID - Unique identifier for tenants (multi-tenancy support)
|
|
99
|
+
*
|
|
100
|
+
* @security MUST validate at authentication boundaries
|
|
101
|
+
*/
|
|
102
|
+
export declare const TenantId: {
|
|
103
|
+
schema: {
|
|
104
|
+
parse: (input: unknown) => Brand<string, "TenantId">;
|
|
105
|
+
safeParse: (input: unknown) => {
|
|
106
|
+
success: true;
|
|
107
|
+
data: Brand<string, "TenantId">;
|
|
108
|
+
} | {
|
|
109
|
+
success: false;
|
|
110
|
+
error: unknown;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
parse: (input: unknown) => Brand<string, "TenantId">;
|
|
114
|
+
is: (value: unknown) => value is Brand<string, "TenantId">;
|
|
115
|
+
brandName: "TenantId";
|
|
116
|
+
};
|
|
117
|
+
export type TenantId = Brand<string, 'TenantId'>;
|
|
118
|
+
/**
|
|
119
|
+
* API Key ID - Unique identifier for API keys
|
|
120
|
+
*
|
|
121
|
+
* @security MUST validate at authentication boundaries
|
|
122
|
+
* @security NEVER log API key values - only IDs
|
|
123
|
+
*/
|
|
124
|
+
export declare const ApiKeyId: {
|
|
125
|
+
schema: {
|
|
126
|
+
parse: (input: unknown) => Brand<string, "ApiKeyId">;
|
|
127
|
+
safeParse: (input: unknown) => {
|
|
128
|
+
success: true;
|
|
129
|
+
data: Brand<string, "ApiKeyId">;
|
|
130
|
+
} | {
|
|
131
|
+
success: false;
|
|
132
|
+
error: unknown;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
parse: (input: unknown) => Brand<string, "ApiKeyId">;
|
|
136
|
+
is: (value: unknown) => value is Brand<string, "ApiKeyId">;
|
|
137
|
+
brandName: "ApiKeyId";
|
|
138
|
+
};
|
|
139
|
+
export type ApiKeyId = Brand<string, 'ApiKeyId'>;
|
|
140
|
+
/**
|
|
141
|
+
* MCP Server ID - Unique identifier for Model Context Protocol servers
|
|
142
|
+
*
|
|
143
|
+
* @security MUST validate at MCP configuration boundaries
|
|
144
|
+
*/
|
|
145
|
+
export declare const MCPServerId: {
|
|
146
|
+
schema: {
|
|
147
|
+
parse: (input: unknown) => Brand<string, "MCPServerId">;
|
|
148
|
+
safeParse: (input: unknown) => {
|
|
149
|
+
success: true;
|
|
150
|
+
data: Brand<string, "MCPServerId">;
|
|
151
|
+
} | {
|
|
152
|
+
success: false;
|
|
153
|
+
error: unknown;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
parse: (input: unknown) => Brand<string, "MCPServerId">;
|
|
157
|
+
is: (value: unknown) => value is Brand<string, "MCPServerId">;
|
|
158
|
+
brandName: "MCPServerId";
|
|
159
|
+
};
|
|
160
|
+
export type MCPServerId = Brand<string, 'MCPServerId'>;
|
|
161
|
+
/**
|
|
162
|
+
* MCPServerIdSchema - Zod schema for MCPServerId that can be used in z.object()
|
|
163
|
+
* This transforms strings to branded MCPServerId types
|
|
164
|
+
*/
|
|
165
|
+
export declare const MCPServerIdSchema: z.ZodEffects<z.ZodString, Brand<string, "MCPServerId">, string>;
|
|
166
|
+
/**
|
|
167
|
+
* Usage Record ID - Unique identifier for usage tracking records
|
|
168
|
+
*
|
|
169
|
+
* @security MUST validate at billing/usage boundaries
|
|
170
|
+
*/
|
|
171
|
+
export declare const UsageRecordId: {
|
|
172
|
+
schema: {
|
|
173
|
+
parse: (input: unknown) => Brand<string, "UsageRecordId">;
|
|
174
|
+
safeParse: (input: unknown) => {
|
|
175
|
+
success: true;
|
|
176
|
+
data: Brand<string, "UsageRecordId">;
|
|
177
|
+
} | {
|
|
178
|
+
success: false;
|
|
179
|
+
error: unknown;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
parse: (input: unknown) => Brand<string, "UsageRecordId">;
|
|
183
|
+
is: (value: unknown) => value is Brand<string, "UsageRecordId">;
|
|
184
|
+
brandName: "UsageRecordId";
|
|
185
|
+
};
|
|
186
|
+
export type UsageRecordId = Brand<string, 'UsageRecordId'>;
|
|
187
|
+
/**
|
|
188
|
+
* Plan ID - Unique identifier for subscription/usage plans
|
|
189
|
+
*
|
|
190
|
+
* @security MUST validate at billing boundaries
|
|
191
|
+
*/
|
|
192
|
+
export declare const PlanId: {
|
|
193
|
+
schema: {
|
|
194
|
+
parse: (input: unknown) => Brand<string, "PlanId">;
|
|
195
|
+
safeParse: (input: unknown) => {
|
|
196
|
+
success: true;
|
|
197
|
+
data: Brand<string, "PlanId">;
|
|
198
|
+
} | {
|
|
199
|
+
success: false;
|
|
200
|
+
error: unknown;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
parse: (input: unknown) => Brand<string, "PlanId">;
|
|
204
|
+
is: (value: unknown) => value is Brand<string, "PlanId">;
|
|
205
|
+
brandName: "PlanId";
|
|
206
|
+
};
|
|
207
|
+
export type PlanId = Brand<string, 'PlanId'>;
|
|
208
|
+
/**
|
|
209
|
+
* Session ID - Unique identifier for user sessions
|
|
210
|
+
*
|
|
211
|
+
* @security MUST validate at session management boundaries
|
|
212
|
+
* @security CRITICAL: Session IDs should be cryptographically random
|
|
213
|
+
*/
|
|
214
|
+
export declare const SessionId: {
|
|
215
|
+
schema: {
|
|
216
|
+
parse: (input: unknown) => Brand<string, "SessionId">;
|
|
217
|
+
safeParse: (input: unknown) => {
|
|
218
|
+
success: true;
|
|
219
|
+
data: Brand<string, "SessionId">;
|
|
220
|
+
} | {
|
|
221
|
+
success: false;
|
|
222
|
+
error: unknown;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
parse: (input: unknown) => Brand<string, "SessionId">;
|
|
226
|
+
is: (value: unknown) => value is Brand<string, "SessionId">;
|
|
227
|
+
brandName: "SessionId";
|
|
228
|
+
};
|
|
229
|
+
export type SessionId = Brand<string, 'SessionId'>;
|
|
230
|
+
/**
|
|
231
|
+
* Request ID - Unique identifier for tracking requests
|
|
232
|
+
*
|
|
233
|
+
* Used for distributed tracing and logging correlation
|
|
234
|
+
*/
|
|
235
|
+
export declare const RequestId: {
|
|
236
|
+
schema: {
|
|
237
|
+
parse: (input: unknown) => Brand<string, "RequestId">;
|
|
238
|
+
safeParse: (input: unknown) => {
|
|
239
|
+
success: true;
|
|
240
|
+
data: Brand<string, "RequestId">;
|
|
241
|
+
} | {
|
|
242
|
+
success: false;
|
|
243
|
+
error: unknown;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
parse: (input: unknown) => Brand<string, "RequestId">;
|
|
247
|
+
is: (value: unknown) => value is Brand<string, "RequestId">;
|
|
248
|
+
brandName: "RequestId";
|
|
249
|
+
};
|
|
250
|
+
export type RequestId = Brand<string, 'RequestId'>;
|
|
251
|
+
/**
|
|
252
|
+
* COMPILE-TIME SAFETY EXAMPLES
|
|
253
|
+
*
|
|
254
|
+
* The following examples demonstrate how brand types prevent ID mixing:
|
|
255
|
+
*
|
|
256
|
+
* ```typescript
|
|
257
|
+
* function updateUsage(tenantId: TenantId, apiKeyId: ApiKeyId) {
|
|
258
|
+
* // Implementation
|
|
259
|
+
* }
|
|
260
|
+
*
|
|
261
|
+
* const tenant = TenantId.parse('550e8400-e29b-41d4-a716-446655440000');
|
|
262
|
+
* const apiKey = ApiKeyId.parse('660f9511-f3ac-52e5-b827-557766551111');
|
|
263
|
+
*
|
|
264
|
+
* updateUsage(tenant, apiKey); // ✅ Correct
|
|
265
|
+
* updateUsage(apiKey, tenant); // ❌ Compile error!
|
|
266
|
+
* updateUsage('raw-string', apiKey); // ❌ Compile error!
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* VALIDATION AT BOUNDARIES
|
|
270
|
+
*
|
|
271
|
+
* ```typescript
|
|
272
|
+
* // API endpoint
|
|
273
|
+
* app.post('/api/usage', (req, res) => {
|
|
274
|
+
* const tenantResult = TenantId.schema.safeParse(req.body.tenantId);
|
|
275
|
+
* const apiKeyResult = ApiKeyId.schema.safeParse(req.headers['x-api-key-id']);
|
|
276
|
+
*
|
|
277
|
+
* if (!tenantResult.success || !apiKeyResult.success) {
|
|
278
|
+
* return res.status(400).json({ error: 'Invalid IDs' });
|
|
279
|
+
* }
|
|
280
|
+
*
|
|
281
|
+
* // Now safe to use - validated AND branded
|
|
282
|
+
* updateUsage(tenantResult.data, apiKeyResult.data);
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
//# sourceMappingURL=id-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-types.d.ts","sourceRoot":"","sources":["../../../src/public/core/id-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA6B,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAGzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;CAGtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,gEAAyE,CAAC;AAEvG;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;CAGnB,CAAC;AAEF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@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID Brand Types for @ax-cli/schemas
|
|
3
|
+
*
|
|
4
|
+
* This file contains all ID brand type factories using the createBrandFactory utility.
|
|
5
|
+
* Each ID type is validated and branded to prevent mixing different ID types at compile time.
|
|
6
|
+
*
|
|
7
|
+
* SECURITY: All IDs MUST be validated at system boundaries using the provided factories.
|
|
8
|
+
*
|
|
9
|
+
* @module id-types
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { createBrandFactory, brand } from './brand-types.js';
|
|
13
|
+
/**
|
|
14
|
+
* API Response ID - Unique identifier for API responses
|
|
15
|
+
*
|
|
16
|
+
* @security MUST validate at API boundaries
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = ApiResponseId.schema.safeParse(userInput);
|
|
20
|
+
* if (result.success) {
|
|
21
|
+
* const id = result.data; // Validated and branded
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const ApiResponseId = createBrandFactory(z.string().uuid(), 'ApiResponseId');
|
|
26
|
+
/**
|
|
27
|
+
* Tool Call ID - Unique identifier for tool calls in API responses
|
|
28
|
+
*
|
|
29
|
+
* @security MUST validate at API boundaries
|
|
30
|
+
*/
|
|
31
|
+
export const ToolCallId = createBrandFactory(z.string().min(1), 'ToolCallId');
|
|
32
|
+
/**
|
|
33
|
+
* ToolCallIdSchema - Zod schema for ToolCallId that can be used in z.object()
|
|
34
|
+
* This transforms strings to branded ToolCallId types
|
|
35
|
+
*/
|
|
36
|
+
export const ToolCallIdSchema = z.string().min(1).transform((val) => brand(val));
|
|
37
|
+
/**
|
|
38
|
+
* Model ID - Identifier for AI models
|
|
39
|
+
*
|
|
40
|
+
* @security MUST validate at configuration boundaries
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const modelId = ModelId.parse('glm-4.6'); // Validates and brands
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const ModelId = createBrandFactory(z.string().min(1), 'ModelId');
|
|
47
|
+
/**
|
|
48
|
+
* ModelIdSchema - Zod schema for ModelId that can be used in z.object()
|
|
49
|
+
* This transforms strings to branded ModelId types
|
|
50
|
+
*/
|
|
51
|
+
export const ModelIdSchema = z.string().min(1).transform((val) => brand(val));
|
|
52
|
+
/**
|
|
53
|
+
* Tenant ID - Unique identifier for tenants (multi-tenancy support)
|
|
54
|
+
*
|
|
55
|
+
* @security MUST validate at authentication boundaries
|
|
56
|
+
*/
|
|
57
|
+
export const TenantId = createBrandFactory(z.string().uuid(), 'TenantId');
|
|
58
|
+
/**
|
|
59
|
+
* API Key ID - Unique identifier for API keys
|
|
60
|
+
*
|
|
61
|
+
* @security MUST validate at authentication boundaries
|
|
62
|
+
* @security NEVER log API key values - only IDs
|
|
63
|
+
*/
|
|
64
|
+
export const ApiKeyId = createBrandFactory(z.string().uuid(), 'ApiKeyId');
|
|
65
|
+
/**
|
|
66
|
+
* MCP Server ID - Unique identifier for Model Context Protocol servers
|
|
67
|
+
*
|
|
68
|
+
* @security MUST validate at MCP configuration boundaries
|
|
69
|
+
*/
|
|
70
|
+
export const MCPServerId = createBrandFactory(z.string().min(1), 'MCPServerId');
|
|
71
|
+
/**
|
|
72
|
+
* MCPServerIdSchema - Zod schema for MCPServerId that can be used in z.object()
|
|
73
|
+
* This transforms strings to branded MCPServerId types
|
|
74
|
+
*/
|
|
75
|
+
export const MCPServerIdSchema = z.string().min(1).transform((val) => brand(val));
|
|
76
|
+
/**
|
|
77
|
+
* Usage Record ID - Unique identifier for usage tracking records
|
|
78
|
+
*
|
|
79
|
+
* @security MUST validate at billing/usage boundaries
|
|
80
|
+
*/
|
|
81
|
+
export const UsageRecordId = createBrandFactory(z.string().uuid(), 'UsageRecordId');
|
|
82
|
+
/**
|
|
83
|
+
* Plan ID - Unique identifier for subscription/usage plans
|
|
84
|
+
*
|
|
85
|
+
* @security MUST validate at billing boundaries
|
|
86
|
+
*/
|
|
87
|
+
export const PlanId = createBrandFactory(z.string().min(1), 'PlanId');
|
|
88
|
+
/**
|
|
89
|
+
* Session ID - Unique identifier for user sessions
|
|
90
|
+
*
|
|
91
|
+
* @security MUST validate at session management boundaries
|
|
92
|
+
* @security CRITICAL: Session IDs should be cryptographically random
|
|
93
|
+
*/
|
|
94
|
+
export const SessionId = createBrandFactory(z.string().uuid(), 'SessionId');
|
|
95
|
+
/**
|
|
96
|
+
* Request ID - Unique identifier for tracking requests
|
|
97
|
+
*
|
|
98
|
+
* Used for distributed tracing and logging correlation
|
|
99
|
+
*/
|
|
100
|
+
export const RequestId = createBrandFactory(z.string().uuid(), 'RequestId');
|
|
101
|
+
/**
|
|
102
|
+
* COMPILE-TIME SAFETY EXAMPLES
|
|
103
|
+
*
|
|
104
|
+
* The following examples demonstrate how brand types prevent ID mixing:
|
|
105
|
+
*
|
|
106
|
+
* ```typescript
|
|
107
|
+
* function updateUsage(tenantId: TenantId, apiKeyId: ApiKeyId) {
|
|
108
|
+
* // Implementation
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* const tenant = TenantId.parse('550e8400-e29b-41d4-a716-446655440000');
|
|
112
|
+
* const apiKey = ApiKeyId.parse('660f9511-f3ac-52e5-b827-557766551111');
|
|
113
|
+
*
|
|
114
|
+
* updateUsage(tenant, apiKey); // ✅ Correct
|
|
115
|
+
* updateUsage(apiKey, tenant); // ❌ Compile error!
|
|
116
|
+
* updateUsage('raw-string', apiKey); // ❌ Compile error!
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* VALIDATION AT BOUNDARIES
|
|
120
|
+
*
|
|
121
|
+
* ```typescript
|
|
122
|
+
* // API endpoint
|
|
123
|
+
* app.post('/api/usage', (req, res) => {
|
|
124
|
+
* const tenantResult = TenantId.schema.safeParse(req.body.tenantId);
|
|
125
|
+
* const apiKeyResult = ApiKeyId.schema.safeParse(req.headers['x-api-key-id']);
|
|
126
|
+
*
|
|
127
|
+
* if (!tenantResult.success || !apiKeyResult.success) {
|
|
128
|
+
* return res.status(400).json({ error: 'Invalid IDs' });
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* // Now safe to use - validated AND branded
|
|
132
|
+
* updateUsage(tenantResult.data, apiKeyResult.data);
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
//# sourceMappingURL=id-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-types.js","sourceRoot":"","sources":["../../../src/public/core/id-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC7C,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EACjB,eAAe,CAChB,CAAC;AAIF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAC1C,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,YAAY,CACb,CAAC;AAIF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAuB,GAAG,CAAC,CAAC,CAAC;AAEvG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,kBAAkB,CACvC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,SAAS,CACV,CAAC;AAIF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defai.digital/ax-cli",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.11",
|
|
4
4
|
"sdkVersion": "1.2.0",
|
|
5
5
|
"description": "Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.",
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
"test": "vitest run",
|
|
49
49
|
"test:watch": "vitest",
|
|
50
50
|
"test:ui": "vitest --ui",
|
|
51
|
-
"test:coverage": "vitest run --coverage"
|
|
51
|
+
"test:coverage": "vitest run --coverage",
|
|
52
|
+
"prepublishOnly": "npm run build && node scripts/prepare-publish.js",
|
|
53
|
+
"postpublish": "node scripts/restore-symlink.js"
|
|
52
54
|
},
|
|
53
55
|
"keywords": [
|
|
54
56
|
"cli",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ax-cli/schemas - Single Source of Truth Type System
|
|
3
|
+
*
|
|
4
|
+
* This package provides centralized Zod schemas, brand types, and enums
|
|
5
|
+
* for the entire ax-cli ecosystem.
|
|
6
|
+
*
|
|
7
|
+
* SECURITY: All exports are controlled. Internal helpers are not exposed.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { brand, unbrand, isBranded, createBrandFactory, type __brand, type Brand, type ExtractBrand, type ExtractBase, } from './public/core/brand-types.js';
|
|
12
|
+
export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, type ApiResponseId as ApiResponseIdType, type ToolCallId as ToolCallIdType, type ModelId as ModelIdType, type TenantId as TenantIdType, type ApiKeyId as ApiKeyIdType, type MCPServerId as MCPServerIdType, type UsageRecordId as UsageRecordIdType, type PlanId as PlanIdType, type SessionId as SessionIdType, type RequestId as RequestIdType, } from './public/core/id-types.js';
|
|
13
|
+
export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, type MessageRole, type FinishReason, type Transport, type EditorCommand, } from './public/core/enums.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,UAAU,IAAI,cAAc,EACjC,KAAK,OAAO,IAAI,WAAW,EAC3B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,WAAW,IAAI,eAAe,EACnC,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,SAAS,IAAI,aAAa,GAChC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ax-cli/schemas - Single Source of Truth Type System
|
|
3
|
+
*
|
|
4
|
+
* This package provides centralized Zod schemas, brand types, and enums
|
|
5
|
+
* for the entire ax-cli ecosystem.
|
|
6
|
+
*
|
|
7
|
+
* SECURITY: All exports are controlled. Internal helpers are not exposed.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
// Core brand type utilities
|
|
12
|
+
export { brand, unbrand, isBranded, createBrandFactory, } from './public/core/brand-types.js';
|
|
13
|
+
// ID Brand Types
|
|
14
|
+
export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, } from './public/core/id-types.js';
|
|
15
|
+
// Centralized Enums
|
|
16
|
+
export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, } from './public/core/enums.js';
|
|
17
|
+
// Additional exports will be added as we implement them:
|
|
18
|
+
// - Domain schemas (Usage, API, MCP)
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,4BAA4B;AAC5B,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GAKnB,MAAM,8BAA8B,CAAC;AAEtC,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,GAWV,MAAM,2BAA2B,CAAC;AAEnC,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAKlB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,qCAAqC"}
|