@kadi.build/core 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +84 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +229 -0
- package/dist/client.js.map +1 -1
- package/dist/crypto.d.ts +88 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +120 -0
- package/dist/crypto.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
- package/src/client.ts +2380 -0
- package/src/crypto.ts +153 -0
- package/src/errors.ts +292 -0
- package/src/index.ts +114 -0
- package/src/lockfile.ts +493 -0
- package/src/transports/broker.ts +682 -0
- package/src/transports/native.ts +307 -0
- package/src/transports/stdio.ts +580 -0
- package/src/types.ts +1011 -0
- package/src/zod.ts +69 -0
- package/tsconfig.json +52 -0
package/src/zod.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod utilities for kadi-core v0.1.0
|
|
3
|
+
*
|
|
4
|
+
* Uses Zod 4's built-in JSON Schema conversion.
|
|
5
|
+
* See: https://zod.dev/json-schema
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { z, type ZodType } from 'zod';
|
|
9
|
+
import type { JSONSchema } from './types.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check if a value is a Zod schema.
|
|
13
|
+
*
|
|
14
|
+
* Uses duck-typing on the internal `_zod` property rather than `instanceof`
|
|
15
|
+
* to handle cases where prototype chains are broken by bundlers (e.g., esbuild)
|
|
16
|
+
* or when multiple Zod instances exist.
|
|
17
|
+
*/
|
|
18
|
+
export function isZodSchema(value: unknown): value is ZodType {
|
|
19
|
+
if (value === null || typeof value !== 'object') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// All Zod 4 schemas have an internal _zod property
|
|
24
|
+
if (!('_zod' in value)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const zod = (value as { _zod: unknown })._zod;
|
|
29
|
+
if (zod === null || typeof zod !== 'object') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// _zod.def holds the schema definition
|
|
34
|
+
if (!('def' in zod)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const def = (zod as { def: unknown }).def;
|
|
39
|
+
if (def === null || typeof def !== 'object') {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// def.type is the discriminator (e.g., "string", "object", "array")
|
|
44
|
+
if (!('type' in def)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return typeof (def as { type: unknown }).type === 'string';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Convert a Zod schema to JSON Schema using Zod 4's built-in conversion.
|
|
53
|
+
*
|
|
54
|
+
* @param schema - Zod schema to convert
|
|
55
|
+
* @returns JSON Schema equivalent
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const inputSchema = z.object({
|
|
60
|
+
* text: z.string().describe('Text to analyze'),
|
|
61
|
+
* limit: z.number().optional().default(10),
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* const jsonSchema = zodToJsonSchema(inputSchema);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function zodToJsonSchema(schema: ZodType): JSONSchema {
|
|
68
|
+
return z.toJSONSchema(schema);
|
|
69
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Output Configuration
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"lib": ["ES2022"],
|
|
8
|
+
"types": ["node"],
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
|
|
12
|
+
// Module Resolution
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"allowSyntheticDefaultImports": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
|
|
17
|
+
// Type Checking - STRICT (No any allowed!)
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noImplicitAny": true,
|
|
20
|
+
"strictNullChecks": true,
|
|
21
|
+
"strictFunctionTypes": true,
|
|
22
|
+
"strictBindCallApply": true,
|
|
23
|
+
"strictPropertyInitialization": true,
|
|
24
|
+
"noImplicitThis": true,
|
|
25
|
+
"alwaysStrict": true,
|
|
26
|
+
"noUnusedLocals": true,
|
|
27
|
+
"noUnusedParameters": true,
|
|
28
|
+
"noImplicitReturns": true,
|
|
29
|
+
"noFallthroughCasesInSwitch": true,
|
|
30
|
+
"noUncheckedIndexedAccess": true,
|
|
31
|
+
|
|
32
|
+
// Emit Configuration
|
|
33
|
+
"declaration": true,
|
|
34
|
+
"declarationMap": true,
|
|
35
|
+
"sourceMap": true,
|
|
36
|
+
"removeComments": false,
|
|
37
|
+
|
|
38
|
+
// Advanced
|
|
39
|
+
"skipLibCheck": true,
|
|
40
|
+
"forceConsistentCasingInFileNames": true
|
|
41
|
+
},
|
|
42
|
+
"include": ["src/**/*"],
|
|
43
|
+
"exclude": [
|
|
44
|
+
"node_modules",
|
|
45
|
+
"dist",
|
|
46
|
+
"src-old",
|
|
47
|
+
"examples",
|
|
48
|
+
"backup",
|
|
49
|
+
"**/*.test.ts",
|
|
50
|
+
"**/*.spec.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|