ttc-ai-chat-sdk 0.0.1-beta

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.
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEmitter = exports.getEventEmitterClass = void 0;
4
+ class BrowserEmitter {
5
+ constructor() {
6
+ this.listeners = {};
7
+ }
8
+ on(evt, fn) {
9
+ var _a;
10
+ ((_a = this.listeners)[evt] || (_a[evt] = [])).push(fn);
11
+ return this;
12
+ }
13
+ off(evt, fn) {
14
+ if (!fn) {
15
+ this.listeners[evt] = [];
16
+ return this;
17
+ }
18
+ this.listeners[evt] = (this.listeners[evt] || []).filter(l => l !== fn);
19
+ return this;
20
+ }
21
+ once(evt, fn) {
22
+ const wrapper = (...args) => {
23
+ this.off(evt, wrapper);
24
+ fn(...args);
25
+ };
26
+ this.on(evt, wrapper);
27
+ return this;
28
+ }
29
+ emit(evt, ...args) {
30
+ (this.listeners[evt] || []).slice().forEach(l => {
31
+ try {
32
+ l(...args);
33
+ }
34
+ catch (e) { /* swallow to avoid breaking emit loop */ }
35
+ });
36
+ return true;
37
+ }
38
+ }
39
+ function getEventEmitterClass() {
40
+ return BrowserEmitter;
41
+ }
42
+ exports.getEventEmitterClass = getEventEmitterClass;
43
+ function createEmitter() {
44
+ return new BrowserEmitter();
45
+ }
46
+ exports.createEmitter = createEmitter;
47
+ //# sourceMappingURL=eventEmitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventEmitter.js","sourceRoot":"","sources":["../../src/utils/eventEmitter.ts"],"names":[],"mappings":";;;AAOA,MAAM,cAAc;IAApB;QACU,cAAS,GAA+B,EAAE,CAAC;IA+BrD,CAAC;IA7BC,EAAE,CAAC,GAAW,EAAE,EAAY;;QAC1B,OAAC,IAAI,CAAC,SAAS,EAAC,GAAG,SAAH,GAAG,IAAM,EAAE,EAAC,CAAC,IAAI,CAAC,EAAE,CA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
2
+ * Converts a JSON Schema to TypeScript type definition string
3
+ *
4
+ * @param schema - The JSON Schema object
5
+ * @returns TypeScript type definition as string
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const schema = {
10
+ * type: 'object',
11
+ * properties: {
12
+ * consultee_id: { type: 'string', minLength: 1, maxLength: 100 },
13
+ * startIndex: { default: 0, type: 'number', minimum: 0 },
14
+ * endIndex: { default: 10, type: 'number', minimum: 1 }
15
+ * },
16
+ * required: ['consultee_id', 'startIndex'],
17
+ * additionalProperties: false
18
+ * };
19
+ *
20
+ * const result = jsonSchemaToTypeScript(schema);
21
+ * // Returns: "{\n consultee_id: string;\n startIndex: number;\n endIndex?: number;\n}"
22
+ * ```
23
+ */
24
+ export declare function zodToTs(zod: any): string;
25
+ //# sourceMappingURL=zodToTs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zodToTs.d.ts","sourceRoot":"","sources":["../../src/utils/zodToTs.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAuBxC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.zodToTs = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ /**
9
+ * Converts a JSON Schema to TypeScript type definition string
10
+ *
11
+ * @param schema - The JSON Schema object
12
+ * @returns TypeScript type definition as string
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const schema = {
17
+ * type: 'object',
18
+ * properties: {
19
+ * consultee_id: { type: 'string', minLength: 1, maxLength: 100 },
20
+ * startIndex: { default: 0, type: 'number', minimum: 0 },
21
+ * endIndex: { default: 10, type: 'number', minimum: 1 }
22
+ * },
23
+ * required: ['consultee_id', 'startIndex'],
24
+ * additionalProperties: false
25
+ * };
26
+ *
27
+ * const result = jsonSchemaToTypeScript(schema);
28
+ * // Returns: "{\n consultee_id: string;\n startIndex: number;\n endIndex?: number;\n}"
29
+ * ```
30
+ */
31
+ function zodToTs(zod) {
32
+ const schema = zod_1.default.toJSONSchema(zod);
33
+ if (schema.type !== 'object' || !schema.properties) {
34
+ // Handle non-object schemas
35
+ if (schema.type === 'array' && schema.items) {
36
+ const itemType = convertPropertyType(schema.items);
37
+ return `${itemType}[]`;
38
+ }
39
+ return convertPropertyType(schema);
40
+ }
41
+ const requiredFields = new Set(schema.required || []);
42
+ const properties = [];
43
+ for (const [propName, propSchema] of Object.entries(schema.properties)) {
44
+ const isOptional = !requiredFields.has(propName);
45
+ const propType = convertPropertyType(propSchema);
46
+ const optionalMarker = isOptional ? '?' : '';
47
+ properties.push(` ${propName}${optionalMarker}: ${propType}`);
48
+ }
49
+ return `{\n${properties.join(';\n')};\n}`;
50
+ }
51
+ exports.zodToTs = zodToTs;
52
+ function convertPropertyType(property) {
53
+ switch (property.type) {
54
+ case 'string':
55
+ if (property.enum) {
56
+ return property.enum.map((val) => `'${val}'`).join(' | ');
57
+ }
58
+ return 'string';
59
+ case 'number':
60
+ case 'integer':
61
+ return 'number';
62
+ case 'boolean':
63
+ return 'boolean';
64
+ case 'array':
65
+ if (property.items) {
66
+ const itemType = convertPropertyType(property.items);
67
+ return `${itemType}[]`;
68
+ }
69
+ return 'any[]';
70
+ case 'object':
71
+ if (property.properties) {
72
+ return zodToTs({
73
+ type: 'object',
74
+ properties: property.properties,
75
+ required: property.required || []
76
+ });
77
+ }
78
+ return 'Record<string, any>';
79
+ case 'null':
80
+ return 'null';
81
+ default:
82
+ return 'any';
83
+ }
84
+ }
85
+ //# sourceMappingURL=zodToTs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zodToTs.js","sourceRoot":"","sources":["../../src/utils/zodToTs.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AAEpB;;;;;;;;;;;;;;;;;;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,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAChE;YACD,OAAO,QAAQ,CAAC;QAElB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC;QAElB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QAEnB,KAAK,OAAO;YACV,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAClB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACrD,OAAO,GAAG,QAAQ,IAAI,CAAC;aACxB;YACD,OAAO,OAAO,CAAC;QAEjB,KAAK,QAAQ;YACX,IAAI,QAAQ,CAAC,UAAU,EAAE;gBACvB,OAAO,OAAO,CAAC;oBACb,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,QAAQ,CAAC,UAAU;oBAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;iBAClC,CAAC,CAAC;aACJ;YACD,OAAO,qBAAqB,CAAC;QAE/B,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAEhB;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "ttc-ai-chat-sdk",
3
+ "version": "0.0.1-beta",
4
+ "description": "TypeScript client sdk for TTC AI services with decorators and schema validation.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "dev": "ts-node src/test/example.ts",
17
+ "start": "node dist/index.js",
18
+ "prepublishOnly": "npm run build && node validate-package.js",
19
+ "clean": "rm -rf dist",
20
+ "validate": "node validate-package.js"
21
+ },
22
+ "keywords": [
23
+ "rpc",
24
+ "typescript",
25
+ "decorators",
26
+ "api",
27
+ "express",
28
+ "zod",
29
+ "websocket",
30
+ "socket.io",
31
+ "client",
32
+ "schema-validation"
33
+ ],
34
+ "author": "",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/elijahdanie/ttc-ai-client.git"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/elijahdanie/ttc-ai-client/issues"
42
+ },
43
+ "homepage": "https://github.com/elijahdanie/ttc-ai-client#readme",
44
+ "dependencies": {
45
+ "reflect-metadata": "^0.2.2",
46
+ "socket.io-client": "^4.8.1",
47
+ "ttc-sc": "^2.1.6",
48
+ "typedi": "^0.10.0",
49
+ "zod": "^4.1.11"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^24.3.0",
53
+ "dotenv": "^17.2.1",
54
+ "esbuild": "^0.23.0",
55
+ "nodemon": "3.0.2",
56
+ "ts-node": "10.9.1",
57
+ "typescript": "5.2.2"
58
+ },
59
+ "engines": {
60
+ "node": ">=18.0.0"
61
+ },
62
+ "files": [
63
+ "dist/",
64
+ "package.json",
65
+ "README.md",
66
+ "tsrconfig.json"
67
+ ]
68
+ }