@testerpaykit/api-client 3.1.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to `@testerpaykit/api-client` are documented here.
4
4
 
5
+ ## 3.2.0 — 2026-11-18
6
+
7
+ ### Added
8
+ - `getPersonas(projectId)` → `{ current, persona, personas }` or `null` on
9
+ 404, and `setPersona({ projectId, personaId })` (`null` = "Myself"):
10
+ test personas of "Login with TPK" (GET/PUT `/v1/testers/me/personas`).
11
+ Types `TesterPersona`, `TesterPersonaList`, `TesterPersonaText`.
12
+
5
13
  ## 3.1.0 — 2026-11-14
6
14
 
7
15
  ### Added
package/dist/index.d.mts CHANGED
@@ -443,6 +443,24 @@ declare class TesterPayKitApiClient implements IApiClient {
443
443
  projectId?: string;
444
444
  platform?: 'ios' | 'android' | 'web';
445
445
  }): Promise<AppLinkResponse>;
446
+ /**
447
+ * The test personas of a project and the tester's current choice
448
+ * (GET /v1/testers/me/personas?project_id=). Suggested personas come
449
+ * first; `current` null = "Myself". A 404 (the tester is not in the
450
+ * project yet) yields null: skip the picker silently.
451
+ */
452
+ getPersonas(projectId: string): Promise<TesterPersonaList | null>;
453
+ /**
454
+ * The tester picks a persona (PUT /v1/testers/me/personas);
455
+ * `personaId` null = "Myself". New sessions and reports carry it.
456
+ */
457
+ setPersona(input: {
458
+ projectId: string;
459
+ personaId: string | null;
460
+ }): Promise<{
461
+ current: string | null;
462
+ persona: TesterPersona | null;
463
+ }>;
446
464
  getCompensation(): Promise<CompensationWallet>;
447
465
  recordPaidWork(command: WorkCommand): Promise<PaidAssignment>;
448
466
  registerCompensationPush(registration: PushRegistration): Promise<void>;
@@ -873,6 +891,35 @@ interface AppLinkResponse {
873
891
  appUrl: string;
874
892
  expiresAt: string;
875
893
  }
894
+ /** A text in both UI languages. */
895
+ interface TesterPersonaText {
896
+ de: string;
897
+ en: string;
898
+ }
899
+ /** One test persona (made-up data; never real data of the tester). */
900
+ interface TesterPersona {
901
+ id: string;
902
+ /** True for a persona the developer made for this project. */
903
+ own: boolean;
904
+ slug?: string | null;
905
+ title: TesterPersonaText;
906
+ sub: TesterPersonaText;
907
+ briefing: TesterPersonaText;
908
+ watch: {
909
+ de: string[];
910
+ en: string[];
911
+ };
912
+ attributes: Record<string, unknown>;
913
+ /** The developer suggested it (those come first). */
914
+ suggested?: boolean;
915
+ }
916
+ /** Answer of GET /v1/testers/me/personas. */
917
+ interface TesterPersonaList {
918
+ /** The chosen persona id; null = "Myself". */
919
+ current: string | null;
920
+ persona: TesterPersona | null;
921
+ personas: TesterPersona[];
922
+ }
876
923
  interface TesterPoints {
877
924
  total: number;
878
925
  breakdown?: Record<string, number>;
@@ -978,4 +1025,4 @@ interface TaskStep {
978
1025
  }
979
1026
 
980
1027
  export { ClientOutdatedError, TPK_CLIENT_HEADER, TesterPayKitApiClient, parseClientOutdated };
981
- export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
1028
+ export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPersona, TesterPersonaList, TesterPersonaText, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
package/dist/index.d.ts CHANGED
@@ -443,6 +443,24 @@ declare class TesterPayKitApiClient implements IApiClient {
443
443
  projectId?: string;
444
444
  platform?: 'ios' | 'android' | 'web';
445
445
  }): Promise<AppLinkResponse>;
446
+ /**
447
+ * The test personas of a project and the tester's current choice
448
+ * (GET /v1/testers/me/personas?project_id=). Suggested personas come
449
+ * first; `current` null = "Myself". A 404 (the tester is not in the
450
+ * project yet) yields null: skip the picker silently.
451
+ */
452
+ getPersonas(projectId: string): Promise<TesterPersonaList | null>;
453
+ /**
454
+ * The tester picks a persona (PUT /v1/testers/me/personas);
455
+ * `personaId` null = "Myself". New sessions and reports carry it.
456
+ */
457
+ setPersona(input: {
458
+ projectId: string;
459
+ personaId: string | null;
460
+ }): Promise<{
461
+ current: string | null;
462
+ persona: TesterPersona | null;
463
+ }>;
446
464
  getCompensation(): Promise<CompensationWallet>;
447
465
  recordPaidWork(command: WorkCommand): Promise<PaidAssignment>;
448
466
  registerCompensationPush(registration: PushRegistration): Promise<void>;
@@ -873,6 +891,35 @@ interface AppLinkResponse {
873
891
  appUrl: string;
874
892
  expiresAt: string;
875
893
  }
894
+ /** A text in both UI languages. */
895
+ interface TesterPersonaText {
896
+ de: string;
897
+ en: string;
898
+ }
899
+ /** One test persona (made-up data; never real data of the tester). */
900
+ interface TesterPersona {
901
+ id: string;
902
+ /** True for a persona the developer made for this project. */
903
+ own: boolean;
904
+ slug?: string | null;
905
+ title: TesterPersonaText;
906
+ sub: TesterPersonaText;
907
+ briefing: TesterPersonaText;
908
+ watch: {
909
+ de: string[];
910
+ en: string[];
911
+ };
912
+ attributes: Record<string, unknown>;
913
+ /** The developer suggested it (those come first). */
914
+ suggested?: boolean;
915
+ }
916
+ /** Answer of GET /v1/testers/me/personas. */
917
+ interface TesterPersonaList {
918
+ /** The chosen persona id; null = "Myself". */
919
+ current: string | null;
920
+ persona: TesterPersona | null;
921
+ personas: TesterPersona[];
922
+ }
876
923
  interface TesterPoints {
877
924
  total: number;
878
925
  breakdown?: Record<string, number>;
@@ -978,4 +1025,4 @@ interface TaskStep {
978
1025
  }
979
1026
 
980
1027
  export { ClientOutdatedError, TPK_CLIENT_HEADER, TesterPayKitApiClient, parseClientOutdated };
981
- export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
1028
+ export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPersona, TesterPersonaList, TesterPersonaText, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
package/dist/index.js CHANGED
@@ -539,6 +539,36 @@ var TesterPayKitApiClient = class {
539
539
  );
540
540
  return response.data;
541
541
  }
542
+ /**
543
+ * The test personas of a project and the tester's current choice
544
+ * (GET /v1/testers/me/personas?project_id=). Suggested personas come
545
+ * first; `current` null = "Myself". A 404 (the tester is not in the
546
+ * project yet) yields null: skip the picker silently.
547
+ */
548
+ async getPersonas(projectId) {
549
+ try {
550
+ const response = await this.client.get("/v1/testers/me/personas", {
551
+ params: { project_id: projectId }
552
+ });
553
+ const data = response.data;
554
+ if (!data || !Array.isArray(data.personas)) return null;
555
+ return { current: data.current ?? null, persona: data.persona ?? null, personas: data.personas };
556
+ } catch (e) {
557
+ if (e?.response?.status === 404) return null;
558
+ throw e;
559
+ }
560
+ }
561
+ /**
562
+ * The tester picks a persona (PUT /v1/testers/me/personas);
563
+ * `personaId` null = "Myself". New sessions and reports carry it.
564
+ */
565
+ async setPersona(input) {
566
+ const response = await this.client.put(
567
+ "/v1/testers/me/personas",
568
+ { project_id: input.projectId, persona_id: input.personaId }
569
+ );
570
+ return { current: response.data?.current ?? null, persona: response.data?.persona ?? null };
571
+ }
542
572
  async getCompensation() {
543
573
  return (await this.client.get("/v1/testers/me/compensation")).data;
544
574
  }
package/dist/index.mjs CHANGED
@@ -502,6 +502,36 @@ var TesterPayKitApiClient = class {
502
502
  );
503
503
  return response.data;
504
504
  }
505
+ /**
506
+ * The test personas of a project and the tester's current choice
507
+ * (GET /v1/testers/me/personas?project_id=). Suggested personas come
508
+ * first; `current` null = "Myself". A 404 (the tester is not in the
509
+ * project yet) yields null: skip the picker silently.
510
+ */
511
+ async getPersonas(projectId) {
512
+ try {
513
+ const response = await this.client.get("/v1/testers/me/personas", {
514
+ params: { project_id: projectId }
515
+ });
516
+ const data = response.data;
517
+ if (!data || !Array.isArray(data.personas)) return null;
518
+ return { current: data.current ?? null, persona: data.persona ?? null, personas: data.personas };
519
+ } catch (e) {
520
+ if (e?.response?.status === 404) return null;
521
+ throw e;
522
+ }
523
+ }
524
+ /**
525
+ * The tester picks a persona (PUT /v1/testers/me/personas);
526
+ * `personaId` null = "Myself". New sessions and reports carry it.
527
+ */
528
+ async setPersona(input) {
529
+ const response = await this.client.put(
530
+ "/v1/testers/me/personas",
531
+ { project_id: input.projectId, persona_id: input.personaId }
532
+ );
533
+ return { current: response.data?.current ?? null, persona: response.data?.persona ?? null };
534
+ }
505
535
  async getCompensation() {
506
536
  return (await this.client.get("/v1/testers/me/compensation")).data;
507
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testerpaykit/api-client",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "API client for TesterPayKit backend",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -726,6 +726,41 @@ export class TesterPayKitApiClient implements IApiClient {
726
726
  return response.data;
727
727
  }
728
728
 
729
+ /**
730
+ * The test personas of a project and the tester's current choice
731
+ * (GET /v1/testers/me/personas?project_id=). Suggested personas come
732
+ * first; `current` null = "Myself". A 404 (the tester is not in the
733
+ * project yet) yields null: skip the picker silently.
734
+ */
735
+ async getPersonas(projectId: string): Promise<TesterPersonaList | null> {
736
+ try {
737
+ const response = await this.client.get<TesterPersonaList>('/v1/testers/me/personas', {
738
+ params: { project_id: projectId },
739
+ });
740
+ const data = response.data;
741
+ if (!data || !Array.isArray(data.personas)) return null;
742
+ return { current: data.current ?? null, persona: data.persona ?? null, personas: data.personas };
743
+ } catch (e) {
744
+ if ((e as { response?: { status?: number } })?.response?.status === 404) return null;
745
+ throw e;
746
+ }
747
+ }
748
+
749
+ /**
750
+ * The tester picks a persona (PUT /v1/testers/me/personas);
751
+ * `personaId` null = "Myself". New sessions and reports carry it.
752
+ */
753
+ async setPersona(input: {
754
+ projectId: string;
755
+ personaId: string | null;
756
+ }): Promise<{ current: string | null; persona: TesterPersona | null }> {
757
+ const response = await this.client.put<{ current: string | null; persona: TesterPersona | null }>(
758
+ '/v1/testers/me/personas',
759
+ { project_id: input.projectId, persona_id: input.personaId },
760
+ );
761
+ return { current: response.data?.current ?? null, persona: response.data?.persona ?? null };
762
+ }
763
+
729
764
  async getCompensation(): Promise<CompensationWallet> {
730
765
  return (await this.client.get<CompensationWallet>('/v1/testers/me/compensation')).data;
731
766
  }
@@ -1362,6 +1397,35 @@ export interface AppLinkResponse {
1362
1397
  expiresAt: string;
1363
1398
  }
1364
1399
 
1400
+ /** A text in both UI languages. */
1401
+ export interface TesterPersonaText {
1402
+ de: string;
1403
+ en: string;
1404
+ }
1405
+
1406
+ /** One test persona (made-up data; never real data of the tester). */
1407
+ export interface TesterPersona {
1408
+ id: string;
1409
+ /** True for a persona the developer made for this project. */
1410
+ own: boolean;
1411
+ slug?: string | null;
1412
+ title: TesterPersonaText;
1413
+ sub: TesterPersonaText;
1414
+ briefing: TesterPersonaText;
1415
+ watch: { de: string[]; en: string[] };
1416
+ attributes: Record<string, unknown>;
1417
+ /** The developer suggested it (those come first). */
1418
+ suggested?: boolean;
1419
+ }
1420
+
1421
+ /** Answer of GET /v1/testers/me/personas. */
1422
+ export interface TesterPersonaList {
1423
+ /** The chosen persona id; null = "Myself". */
1424
+ current: string | null;
1425
+ persona: TesterPersona | null;
1426
+ personas: TesterPersona[];
1427
+ }
1428
+
1365
1429
  export interface TesterPoints {
1366
1430
  total: number;
1367
1431
  breakdown?: Record<string, number>;
@@ -22,6 +22,7 @@ describe('TesterPayKitApiClient', () => {
22
22
  // Create mock axios instance
23
23
  mockAxiosInstance = {
24
24
  post: vi.fn(),
25
+ put: vi.fn(),
25
26
  get: vi.fn(),
26
27
  interceptors: {
27
28
  request: {
@@ -303,6 +304,44 @@ describe('TesterPayKitApiClient', () => {
303
304
  });
304
305
  });
305
306
 
307
+ describe('personas', () => {
308
+ const list = { current: null, persona: null, personas: [{ id: 'a', own: false, title: { de: 'A', en: 'A' } }] };
309
+
310
+ it('reads the personas of a project', async () => {
311
+ mockAxiosInstance.get.mockResolvedValue({ data: list });
312
+ await expect(client.getPersonas('p-1')).resolves.toEqual(list);
313
+ expect(mockAxiosInstance.get).toHaveBeenCalledWith('/v1/testers/me/personas', { params: { project_id: 'p-1' } });
314
+ });
315
+
316
+ it('treats 404 (not in the project yet) as no personas', async () => {
317
+ mockAxiosInstance.get.mockRejectedValue({ response: { status: 404 } });
318
+ await expect(client.getPersonas('p-1')).resolves.toBeNull();
319
+ });
320
+
321
+ it('rethrows other errors', async () => {
322
+ mockAxiosInstance.get.mockRejectedValue({ response: { status: 500 } });
323
+ await expect(client.getPersonas('p-1')).rejects.toEqual({ response: { status: 500 } });
324
+ });
325
+
326
+ it('chooses a persona, and "Myself" as null', async () => {
327
+ mockAxiosInstance.put.mockResolvedValue({ data: { current: 'a', persona: list.personas[0] } });
328
+ await expect(client.setPersona({ projectId: 'p-1', personaId: 'a' })).resolves.toEqual({
329
+ current: 'a',
330
+ persona: list.personas[0],
331
+ });
332
+ expect(mockAxiosInstance.put).toHaveBeenCalledWith('/v1/testers/me/personas', {
333
+ project_id: 'p-1',
334
+ persona_id: 'a',
335
+ });
336
+ mockAxiosInstance.put.mockResolvedValue({ data: { current: null, persona: null } });
337
+ await client.setPersona({ projectId: 'p-1', personaId: null });
338
+ expect(mockAxiosInstance.put).toHaveBeenLastCalledWith('/v1/testers/me/personas', {
339
+ project_id: 'p-1',
340
+ persona_id: null,
341
+ });
342
+ });
343
+ });
344
+
306
345
  describe('checklist', () => {
307
346
  it('reads the checklist of a project', async () => {
308
347
  const tasks = [{ id: 't1', title: 'Login', steps: ['Open', 'Sign in'], mine: { status: 'passed', steps: [], at: 'x' } }];