@testerpaykit/api-client 1.1.0 → 1.3.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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { TokenManager, IApiClient, LoginRequest, LoginResponse, WeeklySummary, VoiceBugExtractResponse } from '@testerpaykit/core';
1
+ import { TokenManager, IApiClient, LoginRequest, LoginResponse, WeeklySummary, RemoteAiSession, VoiceBugExtractResponse } from '@testerpaykit/core';
2
2
 
3
3
  interface ApiClientConfig {
4
4
  baseURL?: string;
@@ -140,6 +140,11 @@ declare class TesterPayKitApiClient implements IApiClient {
140
140
  markNotificationsRead(params?: {
141
141
  id?: string;
142
142
  }): Promise<number>;
143
+ /**
144
+ * Claim a remote AI-tester run waiting for this project.
145
+ * POST /v1/testers/me/ai-sessions/claim — 204 → null.
146
+ */
147
+ claimRemoteAiSession(projectId: string): Promise<RemoteAiSession | null>;
143
148
  /**
144
149
  * Attach a file (screenshot, log, voice note) to an already-
145
150
  * submitted bug report. Hits POST /v1/testers/me/bug-reports/
@@ -194,6 +199,20 @@ declare class TesterPayKitApiClient implements IApiClient {
194
199
  getMyProfile(): Promise<TesterProfile>;
195
200
  /** GET /v1/testers/me/points — current point balance + breakdown. */
196
201
  getMyPoints(): Promise<TesterPoints>;
202
+ /**
203
+ * POST /v1/testers/me/demand-signals
204
+ * Distribution-platform phase-3 market-validation signal ("would you
205
+ * use / pay for / recommend it?") for a session this tester actually
206
+ * experienced. Upserts per session on the server; each answer must be
207
+ * 'yes' | 'maybe' | 'no'.
208
+ */
209
+ submitDemandSignal(input: {
210
+ sessionId: string;
211
+ wouldUse: 'yes' | 'maybe' | 'no';
212
+ wouldPay: 'yes' | 'maybe' | 'no';
213
+ wouldRecommend: 'yes' | 'maybe' | 'no';
214
+ comment?: string;
215
+ }): Promise<void>;
197
216
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
198
217
  getEarningsSummary(): Promise<EarningsSummary>;
199
218
  /** GET /v1/testers/earnings/payouts — paginated payout history. */
@@ -667,4 +686,5 @@ interface TaskStep {
667
686
  estimatedMinutes?: number | null;
668
687
  }
669
688
 
670
- export { type AnonymousLoginResponse, type ApiClientConfig, type BugCategory, type BugReportAttachmentInput, type BugReportAttachmentResponse, type BugReportPayload, type BugReportResponse, type BugReportType, type BugSeverity, type EarningsSummary, type EndTesterSessionInput, type EnrollmentResponse, type FeedbackResponse, type KnowledgeBaseAnswer, type KnowledgeBaseCitation, type KnowledgeFile, type KnowledgeFileSummary, type MyBugReportSummary, type MyBugReportsResponse, type NotificationsResult, type PayoutRecord, type RegisterDeviceInput, type RetestItem, type SessionBreadcrumbInput, type SessionBreadcrumbsResponse, type SessionEventInput, type SessionEventsResponse, type StartTesterSessionInput, type SubmissionResponse, type TaskListFilter, type TaskListResponse, type TaskPreset, type TaskStep, type TesterDeviceResponse, TesterPayKitApiClient, type TesterPoints, type TesterProfile, type TesterSessionEndReason, type TesterSessionResponse, type TesterTask, type TpkNotification };
689
+ export { TesterPayKitApiClient };
690
+ export type { AnonymousLoginResponse, ApiClientConfig, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, FeedbackResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PayoutRecord, RegisterDeviceInput, RetestItem, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TokenManager, IApiClient, LoginRequest, LoginResponse, WeeklySummary, VoiceBugExtractResponse } from '@testerpaykit/core';
1
+ import { TokenManager, IApiClient, LoginRequest, LoginResponse, WeeklySummary, RemoteAiSession, VoiceBugExtractResponse } from '@testerpaykit/core';
2
2
 
3
3
  interface ApiClientConfig {
4
4
  baseURL?: string;
@@ -140,6 +140,11 @@ declare class TesterPayKitApiClient implements IApiClient {
140
140
  markNotificationsRead(params?: {
141
141
  id?: string;
142
142
  }): Promise<number>;
143
+ /**
144
+ * Claim a remote AI-tester run waiting for this project.
145
+ * POST /v1/testers/me/ai-sessions/claim — 204 → null.
146
+ */
147
+ claimRemoteAiSession(projectId: string): Promise<RemoteAiSession | null>;
143
148
  /**
144
149
  * Attach a file (screenshot, log, voice note) to an already-
145
150
  * submitted bug report. Hits POST /v1/testers/me/bug-reports/
@@ -194,6 +199,20 @@ declare class TesterPayKitApiClient implements IApiClient {
194
199
  getMyProfile(): Promise<TesterProfile>;
195
200
  /** GET /v1/testers/me/points — current point balance + breakdown. */
196
201
  getMyPoints(): Promise<TesterPoints>;
202
+ /**
203
+ * POST /v1/testers/me/demand-signals
204
+ * Distribution-platform phase-3 market-validation signal ("would you
205
+ * use / pay for / recommend it?") for a session this tester actually
206
+ * experienced. Upserts per session on the server; each answer must be
207
+ * 'yes' | 'maybe' | 'no'.
208
+ */
209
+ submitDemandSignal(input: {
210
+ sessionId: string;
211
+ wouldUse: 'yes' | 'maybe' | 'no';
212
+ wouldPay: 'yes' | 'maybe' | 'no';
213
+ wouldRecommend: 'yes' | 'maybe' | 'no';
214
+ comment?: string;
215
+ }): Promise<void>;
197
216
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
198
217
  getEarningsSummary(): Promise<EarningsSummary>;
199
218
  /** GET /v1/testers/earnings/payouts — paginated payout history. */
@@ -667,4 +686,5 @@ interface TaskStep {
667
686
  estimatedMinutes?: number | null;
668
687
  }
669
688
 
670
- export { type AnonymousLoginResponse, type ApiClientConfig, type BugCategory, type BugReportAttachmentInput, type BugReportAttachmentResponse, type BugReportPayload, type BugReportResponse, type BugReportType, type BugSeverity, type EarningsSummary, type EndTesterSessionInput, type EnrollmentResponse, type FeedbackResponse, type KnowledgeBaseAnswer, type KnowledgeBaseCitation, type KnowledgeFile, type KnowledgeFileSummary, type MyBugReportSummary, type MyBugReportsResponse, type NotificationsResult, type PayoutRecord, type RegisterDeviceInput, type RetestItem, type SessionBreadcrumbInput, type SessionBreadcrumbsResponse, type SessionEventInput, type SessionEventsResponse, type StartTesterSessionInput, type SubmissionResponse, type TaskListFilter, type TaskListResponse, type TaskPreset, type TaskStep, type TesterDeviceResponse, TesterPayKitApiClient, type TesterPoints, type TesterProfile, type TesterSessionEndReason, type TesterSessionResponse, type TesterTask, type TpkNotification };
689
+ export { TesterPayKitApiClient };
690
+ export type { AnonymousLoginResponse, ApiClientConfig, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, FeedbackResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PayoutRecord, RegisterDeviceInput, RetestItem, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification };
package/dist/index.js CHANGED
@@ -246,6 +246,18 @@ var TesterPayKitApiClient = class {
246
246
  );
247
247
  return response.data.unreadCount;
248
248
  }
249
+ /**
250
+ * Claim a remote AI-tester run waiting for this project.
251
+ * POST /v1/testers/me/ai-sessions/claim — 204 → null.
252
+ */
253
+ async claimRemoteAiSession(projectId) {
254
+ const response = await this.client.post(
255
+ "/v1/testers/me/ai-sessions/claim",
256
+ { project_id: projectId }
257
+ );
258
+ if (response.status === 204 || !response.data?.sessionId) return null;
259
+ return response.data;
260
+ }
249
261
  /**
250
262
  * Attach a file (screenshot, log, voice note) to an already-
251
263
  * submitted bug report. Hits POST /v1/testers/me/bug-reports/
@@ -294,6 +306,7 @@ var TesterPayKitApiClient = class {
294
306
  * Hits POST /v1/testers/sessions/:id/events in batch mode.
295
307
  */
296
308
  async addSessionEvents(sessionId, events) {
309
+ assertSessionId(sessionId, "addSessionEvents");
297
310
  const response = await this.client.post(
298
311
  `/v1/testers/sessions/${sessionId}/events`,
299
312
  {
@@ -314,6 +327,7 @@ var TesterPayKitApiClient = class {
314
327
  * Hits POST /v1/testers/sessions/:id/breadcrumbs in batch mode.
315
328
  */
316
329
  async addSessionBreadcrumbs(sessionId, breadcrumbs) {
330
+ assertSessionId(sessionId, "addSessionBreadcrumbs");
317
331
  const response = await this.client.post(
318
332
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
319
333
  {
@@ -385,6 +399,23 @@ var TesterPayKitApiClient = class {
385
399
  );
386
400
  return response.data;
387
401
  }
402
+ /**
403
+ * POST /v1/testers/me/demand-signals
404
+ * Distribution-platform phase-3 market-validation signal ("would you
405
+ * use / pay for / recommend it?") for a session this tester actually
406
+ * experienced. Upserts per session on the server; each answer must be
407
+ * 'yes' | 'maybe' | 'no'.
408
+ */
409
+ async submitDemandSignal(input) {
410
+ const comment = input.comment?.trim();
411
+ await this.client.post("/v1/testers/me/demand-signals", {
412
+ session_id: input.sessionId,
413
+ would_use: input.wouldUse,
414
+ would_pay: input.wouldPay,
415
+ would_recommend: input.wouldRecommend,
416
+ ...comment ? { comment } : {}
417
+ });
418
+ }
388
419
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
389
420
  async getEarningsSummary() {
390
421
  const response = await this.client.get(
@@ -557,6 +588,13 @@ var TesterPayKitApiClient = class {
557
588
  function formatTimestamp(timestamp) {
558
589
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
559
590
  }
591
+ function assertSessionId(sessionId, op) {
592
+ if (!sessionId) {
593
+ throw new Error(
594
+ `TesterPayKitApiClient.${op}: sessionId is empty \u2014 start a session before flushing session telemetry.`
595
+ );
596
+ }
597
+ }
560
598
  // Annotate the CommonJS export names for ESM import in node:
561
599
  0 && (module.exports = {
562
600
  TesterPayKitApiClient
package/dist/index.mjs CHANGED
@@ -212,6 +212,18 @@ var TesterPayKitApiClient = class {
212
212
  );
213
213
  return response.data.unreadCount;
214
214
  }
215
+ /**
216
+ * Claim a remote AI-tester run waiting for this project.
217
+ * POST /v1/testers/me/ai-sessions/claim — 204 → null.
218
+ */
219
+ async claimRemoteAiSession(projectId) {
220
+ const response = await this.client.post(
221
+ "/v1/testers/me/ai-sessions/claim",
222
+ { project_id: projectId }
223
+ );
224
+ if (response.status === 204 || !response.data?.sessionId) return null;
225
+ return response.data;
226
+ }
215
227
  /**
216
228
  * Attach a file (screenshot, log, voice note) to an already-
217
229
  * submitted bug report. Hits POST /v1/testers/me/bug-reports/
@@ -260,6 +272,7 @@ var TesterPayKitApiClient = class {
260
272
  * Hits POST /v1/testers/sessions/:id/events in batch mode.
261
273
  */
262
274
  async addSessionEvents(sessionId, events) {
275
+ assertSessionId(sessionId, "addSessionEvents");
263
276
  const response = await this.client.post(
264
277
  `/v1/testers/sessions/${sessionId}/events`,
265
278
  {
@@ -280,6 +293,7 @@ var TesterPayKitApiClient = class {
280
293
  * Hits POST /v1/testers/sessions/:id/breadcrumbs in batch mode.
281
294
  */
282
295
  async addSessionBreadcrumbs(sessionId, breadcrumbs) {
296
+ assertSessionId(sessionId, "addSessionBreadcrumbs");
283
297
  const response = await this.client.post(
284
298
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
285
299
  {
@@ -351,6 +365,23 @@ var TesterPayKitApiClient = class {
351
365
  );
352
366
  return response.data;
353
367
  }
368
+ /**
369
+ * POST /v1/testers/me/demand-signals
370
+ * Distribution-platform phase-3 market-validation signal ("would you
371
+ * use / pay for / recommend it?") for a session this tester actually
372
+ * experienced. Upserts per session on the server; each answer must be
373
+ * 'yes' | 'maybe' | 'no'.
374
+ */
375
+ async submitDemandSignal(input) {
376
+ const comment = input.comment?.trim();
377
+ await this.client.post("/v1/testers/me/demand-signals", {
378
+ session_id: input.sessionId,
379
+ would_use: input.wouldUse,
380
+ would_pay: input.wouldPay,
381
+ would_recommend: input.wouldRecommend,
382
+ ...comment ? { comment } : {}
383
+ });
384
+ }
354
385
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
355
386
  async getEarningsSummary() {
356
387
  const response = await this.client.get(
@@ -523,6 +554,13 @@ var TesterPayKitApiClient = class {
523
554
  function formatTimestamp(timestamp) {
524
555
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
525
556
  }
557
+ function assertSessionId(sessionId, op) {
558
+ if (!sessionId) {
559
+ throw new Error(
560
+ `TesterPayKitApiClient.${op}: sessionId is empty \u2014 start a session before flushing session telemetry.`
561
+ );
562
+ }
563
+ }
526
564
  export {
527
565
  TesterPayKitApiClient
528
566
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testerpaykit/api-client",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "API client for TesterPayKit backend",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,14 +13,14 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "axios": "^1.6.2",
17
- "@testerpaykit/core": "1.0.1"
16
+ "axios": "^1.20.0",
17
+ "@testerpaykit/core": "1.1.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@types/node": "^20.10.0",
21
- "tsup": "^8.0.1",
22
- "typescript": "^5.3.3",
23
- "vitest": "^1.0.4"
20
+ "@types/node": "^26.6.5",
21
+ "tsup": "^9.0.0",
22
+ "typescript": "^6.0.3",
23
+ "vitest": "^5.0.5"
24
24
  },
25
25
  "keywords": [
26
26
  "testerpaykit",
@@ -6,6 +6,7 @@ import {
6
6
  WeeklySummary,
7
7
  TokenManager,
8
8
  VoiceBugExtractResponse,
9
+ RemoteAiSession,
9
10
  } from '@testerpaykit/core';
10
11
 
11
12
  export interface ApiClientConfig {
@@ -305,6 +306,19 @@ export class TesterPayKitApiClient implements IApiClient {
305
306
  return response.data.unreadCount;
306
307
  }
307
308
 
309
+ /**
310
+ * Claim a remote AI-tester run waiting for this project.
311
+ * POST /v1/testers/me/ai-sessions/claim — 204 → null.
312
+ */
313
+ async claimRemoteAiSession(projectId: string): Promise<RemoteAiSession | null> {
314
+ const response = await this.client.post<RemoteAiSession>(
315
+ '/v1/testers/me/ai-sessions/claim',
316
+ { project_id: projectId },
317
+ );
318
+ if (response.status === 204 || !response.data?.sessionId) return null;
319
+ return response.data;
320
+ }
321
+
308
322
  /**
309
323
  * Attach a file (screenshot, log, voice note) to an already-
310
324
  * submitted bug report. Hits POST /v1/testers/me/bug-reports/
@@ -366,6 +380,7 @@ export class TesterPayKitApiClient implements IApiClient {
366
380
  sessionId: string,
367
381
  events: SessionEventInput[],
368
382
  ): Promise<SessionEventsResponse> {
383
+ assertSessionId(sessionId, 'addSessionEvents');
369
384
  const response = await this.client.post<SessionEventsResponse>(
370
385
  `/v1/testers/sessions/${sessionId}/events`,
371
386
  {
@@ -390,6 +405,7 @@ export class TesterPayKitApiClient implements IApiClient {
390
405
  sessionId: string,
391
406
  breadcrumbs: SessionBreadcrumbInput[],
392
407
  ): Promise<SessionBreadcrumbsResponse> {
408
+ assertSessionId(sessionId, 'addSessionBreadcrumbs');
393
409
  const response = await this.client.post<SessionBreadcrumbsResponse>(
394
410
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
395
411
  {
@@ -471,6 +487,30 @@ export class TesterPayKitApiClient implements IApiClient {
471
487
  return response.data;
472
488
  }
473
489
 
490
+ /**
491
+ * POST /v1/testers/me/demand-signals
492
+ * Distribution-platform phase-3 market-validation signal ("would you
493
+ * use / pay for / recommend it?") for a session this tester actually
494
+ * experienced. Upserts per session on the server; each answer must be
495
+ * 'yes' | 'maybe' | 'no'.
496
+ */
497
+ async submitDemandSignal(input: {
498
+ sessionId: string;
499
+ wouldUse: 'yes' | 'maybe' | 'no';
500
+ wouldPay: 'yes' | 'maybe' | 'no';
501
+ wouldRecommend: 'yes' | 'maybe' | 'no';
502
+ comment?: string;
503
+ }): Promise<void> {
504
+ const comment = input.comment?.trim();
505
+ await this.client.post('/v1/testers/me/demand-signals', {
506
+ session_id: input.sessionId,
507
+ would_use: input.wouldUse,
508
+ would_pay: input.wouldPay,
509
+ would_recommend: input.wouldRecommend,
510
+ ...(comment ? { comment } : {}),
511
+ });
512
+ }
513
+
474
514
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
475
515
  async getEarningsSummary(): Promise<EarningsSummary> {
476
516
  const response = await this.client.get<EarningsSummary>(
@@ -1115,3 +1155,17 @@ export interface TaskStep {
1115
1155
  function formatTimestamp(timestamp: Date | string): string {
1116
1156
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
1117
1157
  }
1158
+
1159
+ /**
1160
+ * Guard against session-bound calls with an empty session id, which
1161
+ * would otherwise produce `/v1/testers/sessions//breadcrumbs` (double
1162
+ * slash → 401 spam, findling F-0002). Callers must resolve a real
1163
+ * session id first (or skip the flush).
1164
+ */
1165
+ function assertSessionId(sessionId: string, op: string): void {
1166
+ if (!sessionId) {
1167
+ throw new Error(
1168
+ `TesterPayKitApiClient.${op}: sessionId is empty — start a session before flushing session telemetry.`,
1169
+ );
1170
+ }
1171
+ }
@@ -323,6 +323,21 @@ describe('TesterPayKitApiClient', () => {
323
323
  );
324
324
  expect(result).toEqual(response.data);
325
325
  });
326
+
327
+ // findling F-0002: an empty session id would build
328
+ // `/v1/testers/sessions//breadcrumbs` (double slash → 401 spam).
329
+ // The client must refuse instead of firing the malformed request.
330
+ it('should reject session calls with an empty session id (no request fired)', async () => {
331
+ await expect(
332
+ client.addSessionBreadcrumbs('', [
333
+ { breadcrumbType: 'tap', message: 'x' },
334
+ ]),
335
+ ).rejects.toThrow(/sessionId is empty/);
336
+ await expect(
337
+ client.addSessionEvents('', [{ eventType: 'tapBucket' }]),
338
+ ).rejects.toThrow(/sessionId is empty/);
339
+ expect(mockAxiosInstance.post).not.toHaveBeenCalled();
340
+ });
326
341
  });
327
342
 
328
343
  describe('getPendingSubmissions', () => {
@@ -1,18 +0,0 @@
1
-
2
- > @testerpaykit/api-client@1.1.0 build /Users/udi/work/moinsen/ideas/moinsen-infrastructure/TesterPayKit/sdks/typescript/packages/api-client
3
- > tsup src/index.ts --format cjs,esm --dts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Target: es2020
9
- CJS Build start
10
- ESM Build start
11
- ESM dist/index.mjs 17.60 KB
12
- ESM ⚡️ Build success in 14ms
13
- CJS dist/index.js 19.25 KB
14
- CJS ⚡️ Build success in 14ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 405ms
17
- DTS dist/index.d.ts 22.55 KB
18
- DTS dist/index.d.mts 22.55 KB