@aiqa/sdk 0.0.5 → 1.0.0-develop.1

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 CHANGED
@@ -16,6 +16,7 @@ A TypeScript/JavaScript SDK for interacting with the AIQA WebSocket service. Thi
16
16
  - [Types](#types)
17
17
  - [Examples](#examples)
18
18
  - [Error Handling](#error-handling)
19
+ - [Semantic Versioning](#semantic-versioning)
19
20
 
20
21
  ## Installation
21
22
 
@@ -28,24 +29,24 @@ npm install @aiqa/sdk
28
29
  ### Basic Setup
29
30
 
30
31
  ```typescript
31
- import AiQaSdk from '@aiqa/sdk';
32
+ import AiQaSdk from "@aiqa/sdk";
32
33
 
33
34
  // Initialize the SDK
34
35
  const sdk = new AiQaSdk(
35
- 'app-id-123',
36
- 'app-secret-xyz',
37
- 'https://api.solutionson.ai/'
36
+ "app-id-123",
37
+ "app-secret-xyz",
38
+ "https://api.solutionson.ai/",
38
39
  );
39
40
 
40
41
  // Connect to the service, then attach listeners
41
42
  sdk.connect();
42
43
 
43
- sdk.on('connect', () => {
44
- console.log('Connected to AIQA service');
44
+ sdk.on("connect", () => {
45
+ console.log("Connected to AIQA service");
45
46
  });
46
47
 
47
- sdk.on('error', (error) => {
48
- console.error('Connection error:', error);
48
+ sdk.on("error", (error) => {
49
+ console.error("Connection error:", error);
49
50
  });
50
51
  ```
51
52
 
@@ -95,22 +96,25 @@ const application = await sdk.getApplication();
95
96
  Adds a fact to the active application (Promise-based).
96
97
 
97
98
  **Parameters:**
99
+
98
100
  - `fact: ApplicationFactInput`
99
101
  ```typescript
100
102
  {
101
103
  id: string;
102
104
  question: string;
103
105
  expected_answer: any;
104
- answer_format: { type: 'STRING' };
106
+ answer_format: {
107
+ type: "STRING";
108
+ }
105
109
  }
106
110
  ```
107
111
 
108
112
  ```typescript
109
113
  const isMatched = await sdk.addFact({
110
- id: 'fact-123',
111
- question: 'Do you agree?',
112
- expected_answer: 'Yes',
113
- answer_format: { type: 'STRING' }
114
+ id: "fact-123",
115
+ question: "Do you agree?",
116
+ expected_answer: "Yes",
117
+ answer_format: { type: "STRING" },
114
118
  });
115
119
  ```
116
120
 
@@ -155,6 +159,7 @@ const isRecording = await sdk.isRecordingNow();
155
159
  Registers an event listener. Call `connect()` before `on()`.
156
160
 
157
161
  **Available Events:**
162
+
158
163
  - `connect` - Socket.IO connection established
159
164
  - `disconnect` - Socket.IO connection closed
160
165
  - `close` - Socket.IO connection closed
@@ -167,12 +172,12 @@ Registers an event listener. Call `connect()` before `on()`.
167
172
 
168
173
  ```typescript
169
174
  sdk.connect();
170
- sdk.on('connect', () => {
171
- console.log('Connected');
175
+ sdk.on("connect", () => {
176
+ console.log("Connected");
172
177
  });
173
178
 
174
- sdk.on('authenticated', (application) => {
175
- console.log('Authenticated:', application);
179
+ sdk.on("authenticated", (application) => {
180
+ console.log("Authenticated:", application);
176
181
  });
177
182
  ```
178
183
 
@@ -181,7 +186,7 @@ sdk.on('authenticated', (application) => {
181
186
  Removes an event listener.
182
187
 
183
188
  ```typescript
184
- sdk.off('connect');
189
+ sdk.off("connect");
185
190
  ```
186
191
 
187
192
  ## Types
@@ -196,7 +201,7 @@ type Application = {
196
201
  agent_id: string;
197
202
  agent_first_name: string;
198
203
  agent_last_name: string;
199
- }
204
+ };
200
205
  ```
201
206
 
202
207
  ### ApplicationFact
@@ -204,9 +209,9 @@ type Application = {
204
209
  ```typescript
205
210
  type ApplicationFact = ApplicationFactInput & {
206
211
  ai_answer?: any;
207
- question_status: 'searching' | 'asked' | 'not_asked';
208
- verification_status: 'processing' | 'matched' | 'unmatched';
209
- }
212
+ question_status: "searching" | "asked" | "not_asked";
213
+ verification_status: "processing" | "matched" | "unmatched";
214
+ };
210
215
  ```
211
216
 
212
217
  ### ApplicationFactInput
@@ -217,7 +222,16 @@ type ApplicationFactInput = {
217
222
  question: string;
218
223
  expected_answer: any;
219
224
  answer_format: {
220
- type: 'STRING' | 'NUMBER' | 'INT' | 'FLOAT' | 'BOOL' | 'LIST' | 'STRICT' | 'SINGLE_CHOICE' | 'MULTIPLE_CHOICES';
225
+ type:
226
+ | "STRING"
227
+ | "NUMBER"
228
+ | "INT"
229
+ | "FLOAT"
230
+ | "BOOL"
231
+ | "LIST"
232
+ | "STRICT"
233
+ | "SINGLE_CHOICE"
234
+ | "MULTIPLE_CHOICES";
221
235
  choices?: { key: string; text: string }[];
222
236
  };
223
237
  category_id?: string;
@@ -225,7 +239,7 @@ type ApplicationFactInput = {
225
239
  language?: string;
226
240
  critical?: boolean;
227
241
  is_skipped?: boolean;
228
- }
242
+ };
229
243
  ```
230
244
 
231
245
  ### FactUpdateEvent
@@ -234,63 +248,98 @@ type ApplicationFactInput = {
234
248
  type FactUpdateEvent = {
235
249
  fact_id: string;
236
250
  question_id?: string;
237
- status: 'asked' | 'answered_detected' | 'agent_answered' | 'verification_pending' | 'verified' | 'failed';
251
+ status:
252
+ | "asked"
253
+ | "answered_detected"
254
+ | "agent_answered"
255
+ | "verification_pending"
256
+ | "verified"
257
+ | "failed";
238
258
  detectedAnswer?: any;
239
259
  agentAnswer?: any;
240
260
  verifiedAnswer?: any;
241
- }
261
+ };
262
+ ```
263
+
264
+ ## Semantic Versioning
265
+
266
+ Version bumps are automated with semantic commits and `semantic-release` in Bitbucket Pipelines:
267
+
268
+ - `master` creates stable releases.
269
+ - `develop` creates prereleases on the `develop` channel (for example `1.2.3-develop.1`).
270
+
271
+ ### Commit types and version bump
272
+
273
+ - `fix: ...` -> patch bump (`0.0.6` -> `0.0.7`)
274
+ - `feat: ...` -> minor bump (`0.0.6` -> `0.1.0`)
275
+ - `feat!: ...` or commit body with `BREAKING CHANGE:` -> major bump (`0.0.6` -> `1.0.0`)
276
+ - `chore: ...`
277
+ - Other commit types (for example `docs:`, `chore:`) do not trigger a release by default.
278
+
279
+ ### Examples
280
+
281
+ ```text
282
+ fix: handle socket timeout error
283
+ feat: add isRecordingNow helper
284
+ feat!: change addFact response contract
242
285
  ```
243
286
 
287
+ ### Pipeline requirements
288
+
289
+ Set these repository variables so the release step can push tags/commits and publish to npm:
290
+
291
+ - `BB_TOKEN_BASIC_AUTH` with value `user:token`
292
+ - `NPM_TOKEN` with publish access to `@aiqa/sdk`
293
+
244
294
  ## Examples
245
295
 
246
296
  ### Complete Example: Recording Session
247
297
 
248
298
  ```typescript
249
- import AiQaSdk from '@aiqa/sdk';
299
+ import AiQaSdk from "@aiqa/sdk";
250
300
 
251
301
  // Initialize SDK
252
302
  const sdk = new AiQaSdk(
253
- 'application-id-123',
254
- 'application-secret-xyz',
255
- 'https://api.solutionson.ai/'
303
+ "application-id-123",
304
+ "application-secret-xyz",
305
+ "https://api.solutionson.ai/",
256
306
  );
257
307
 
258
308
  sdk.connect();
259
309
 
260
- sdk.on('connect', async () => {
261
- console.log('Connected!');
310
+ sdk.on("connect", async () => {
311
+ console.log("Connected!");
262
312
 
263
313
  try {
264
314
  const application = await sdk.getApplication();
265
- console.log('Application loaded:', application.application_id);
315
+ console.log("Application loaded:", application.application_id);
266
316
 
267
317
  // Start recording
268
318
  await sdk.startRecording();
269
- console.log('Recording started');
319
+ console.log("Recording started");
270
320
 
271
321
  // Add a fact
272
322
  const factMatched = await sdk.addFact({
273
- id: 'q1',
274
- question: 'What is your name?',
275
- expected_answer: '',
323
+ id: "q1",
324
+ question: "What is your name?",
325
+ expected_answer: "",
276
326
  answer_format: {
277
- type: 'STRING'
278
- }
327
+ type: "STRING",
328
+ },
279
329
  });
280
330
 
281
- console.log('Fact matched:', factMatched);
331
+ console.log("Fact matched:", factMatched);
282
332
 
283
333
  // Stop recording
284
334
  await sdk.stopRecording();
285
- console.log('Recording stopped');
286
-
335
+ console.log("Recording stopped");
287
336
  } catch (error) {
288
- console.error('Error:', error);
337
+ console.error("Error:", error);
289
338
  }
290
339
  });
291
340
 
292
- sdk.on('error', (error) => {
293
- console.error('SDK Error:', error);
341
+ sdk.on("error", (error) => {
342
+ console.error("SDK Error:", error);
294
343
  });
295
344
  ```
296
345
 
@@ -301,9 +350,9 @@ All methods are Promise-based. Use `try/catch` for errors.
301
350
  ```typescript
302
351
  try {
303
352
  const application = await sdk.getApplication();
304
- console.log('Success:', application);
353
+ console.log("Success:", application);
305
354
  } catch (error) {
306
- console.error('Error:', error);
355
+ console.error("Error:", error);
307
356
  }
308
357
  ```
309
358
 
@@ -320,4 +369,4 @@ The server emits an `app_version` payload with `{ min, max }` supported SDK vers
320
369
 
321
370
  ## License
322
371
 
323
- MIT
372
+ MIT
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "@aiqa/sdk",
3
- "version": "0.0.5",
3
+ "version": "1.0.0-develop.1",
4
4
  "main": "dist/node/node.js",
5
5
  "module": "dist/node/node.js",
6
6
  "types": "dist/node/node.d.ts",
7
- "engines": { "node": ">=18" },
7
+ "engines": {
8
+ "node": ">=18"
9
+ },
8
10
  "scripts": {
9
11
  "build": "tsup && node -e \"const fs=require('fs');['dist/node/node','dist/browser/browser'].forEach(f=>{const mts=f+'.d.mts';const ts=f+'.d.ts';if(fs.existsSync(mts)){fs.renameSync(mts,ts);}});\"",
12
+ "commitlint": "commitlint",
10
13
  "dev:node": "tsx src/node.ts",
14
+ "lint": "tsc --noEmit -p tsconfig.json",
15
+ "format": "prettier --check \"{src,tests}/**/*.{ts,tsx,js,json,md,yml,yaml}\" \"*.{js,json,md,yml,yaml,ts}\"",
16
+ "release": "semantic-release",
11
17
  "start:node": "node dist/node/node.js",
12
18
  "serve:browser": "serve .",
13
- "test": "jest"
19
+ "test": "jest",
20
+ "prepare": "husky"
14
21
  },
15
22
  "exports": {
16
23
  ".": {
@@ -37,14 +44,25 @@
37
44
  "dist"
38
45
  ],
39
46
  "devDependencies": {
47
+ "@commitlint/cli": "^20.4.4",
48
+ "@commitlint/config-conventional": "^20.4.4",
40
49
  "@jest/globals": "^29.7.0",
50
+ "@semantic-release/changelog": "^6.0.3",
51
+ "@semantic-release/commit-analyzer": "^13.0.1",
52
+ "@semantic-release/git": "^10.0.1",
53
+ "@semantic-release/npm": "^12.0.2",
54
+ "@semantic-release/release-notes-generator": "^14.1.0",
55
+ "@types/node": "^22.0.0",
56
+ "conventional-changelog-conventionalcommits": "^9.3.0",
41
57
  "esbuild": "^0.23.0",
58
+ "husky": "^9.1.7",
42
59
  "jest": "^29.7.0",
60
+ "prettier": "^3.8.1",
61
+ "semantic-release": "^24.2.9",
62
+ "serve": "^14.2.3",
43
63
  "socket.io": "^4.7.5",
44
64
  "ts-jest": "^29.2.3",
45
65
  "ts-node": "^10.9.2",
46
- "@types/node": "^22.0.0",
47
- "serve": "^14.2.3",
48
66
  "tsup": "^8.0.0",
49
67
  "tsx": "^4.0.0",
50
68
  "typescript": "^5.7.0"
@@ -52,4 +70,4 @@
52
70
  "dependencies": {
53
71
  "socket.io-client": "^4.7.5"
54
72
  }
55
- }
73
+ }
@@ -1,2 +0,0 @@
1
-
2
- export { }