@testerpaykit/api-client 1.6.0 → 2.0.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 +41 -0
- package/dist/index.d.mts +218 -13
- package/dist/index.d.ts +218 -13
- package/dist/index.js +95 -13
- package/dist/index.mjs +95 -13
- package/package.json +1 -1
- package/src/TesterPayKitApiClient.ts +175 -23
- package/src/compensation.ts +59 -0
- package/src/index.ts +1 -0
- package/tests/TesterPayKitApiClient.test.ts +83 -0
package/dist/index.js
CHANGED
|
@@ -39,6 +39,12 @@ var import_axios = __toESM(require("axios"));
|
|
|
39
39
|
var import_core = require("@testerpaykit/core");
|
|
40
40
|
var TesterPayKitApiClient = class {
|
|
41
41
|
constructor(config) {
|
|
42
|
+
/**
|
|
43
|
+
* Called on any 403 `phone_required` / `approval_required` answer: the
|
|
44
|
+
* tester is not (or no longer) cleared to report. SDKs hide their
|
|
45
|
+
* tester UI on it. The request still rejects as before.
|
|
46
|
+
*/
|
|
47
|
+
this.onTesterGate = null;
|
|
42
48
|
this.apiKey = config.apiKey;
|
|
43
49
|
this.tokenManager = config.tokenManager || new import_core.TokenManager();
|
|
44
50
|
this.client = import_axios.default.create({
|
|
@@ -67,6 +73,13 @@ var TesterPayKitApiClient = class {
|
|
|
67
73
|
if (error.response?.status === 401) {
|
|
68
74
|
this.tokenManager.clear();
|
|
69
75
|
}
|
|
76
|
+
const code = error.response?.data?.error;
|
|
77
|
+
if (error.response?.status === 403 && (code === "phone_required" || code === "approval_required")) {
|
|
78
|
+
try {
|
|
79
|
+
this.onTesterGate?.(code);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
70
83
|
return Promise.reject(error);
|
|
71
84
|
}
|
|
72
85
|
);
|
|
@@ -249,11 +262,13 @@ var TesterPayKitApiClient = class {
|
|
|
249
262
|
/**
|
|
250
263
|
* Claim a remote AI-tester run waiting for this project.
|
|
251
264
|
* POST /v1/testers/me/ai-sessions/claim — 204 → null.
|
|
265
|
+
* `appVersion` lets the API hand out AI retests of a fixed bug, which
|
|
266
|
+
* only a build at or above the fixed version may run.
|
|
252
267
|
*/
|
|
253
|
-
async claimRemoteAiSession(projectId) {
|
|
268
|
+
async claimRemoteAiSession(projectId, appVersion) {
|
|
254
269
|
const response = await this.client.post(
|
|
255
270
|
"/v1/testers/me/ai-sessions/claim",
|
|
256
|
-
{ project_id: projectId }
|
|
271
|
+
{ project_id: projectId, ...appVersion ? { app_version: appVersion } : {} }
|
|
257
272
|
);
|
|
258
273
|
if (response.status === 204 || !response.data?.sessionId) return null;
|
|
259
274
|
return response.data;
|
|
@@ -288,6 +303,43 @@ var TesterPayKitApiClient = class {
|
|
|
288
303
|
);
|
|
289
304
|
return response.data?.id;
|
|
290
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* What to test in this app: the project's checklist tasks with this
|
|
308
|
+
* tester's (`mine`) and the AI tester's (`ai`) latest pass.
|
|
309
|
+
* GET /v1/testers/me/checklist?project_id=… — a 404 (tester not in the
|
|
310
|
+
* project yet) yields an empty list.
|
|
311
|
+
*/
|
|
312
|
+
async getChecklist(projectId) {
|
|
313
|
+
try {
|
|
314
|
+
const response = await this.client.get(
|
|
315
|
+
"/v1/testers/me/checklist",
|
|
316
|
+
{ params: { project_id: projectId } }
|
|
317
|
+
);
|
|
318
|
+
return Array.isArray(response.data?.tasks) ? response.data.tasks : [];
|
|
319
|
+
} catch (e) {
|
|
320
|
+
if (e?.response?.status === 404) return [];
|
|
321
|
+
throw e;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* One pass through a checklist task, a verdict per step.
|
|
326
|
+
* POST /v1/testers/me/checklist/{taskId}/runs → the run's status.
|
|
327
|
+
*/
|
|
328
|
+
async submitChecklistRun(input) {
|
|
329
|
+
const response = await this.client.post(
|
|
330
|
+
`/v1/testers/me/checklist/${encodeURIComponent(input.taskId)}/runs`,
|
|
331
|
+
{
|
|
332
|
+
project_id: input.projectId,
|
|
333
|
+
step_results: input.stepResults.map((r) => ({
|
|
334
|
+
step: r.step,
|
|
335
|
+
passed: r.passed,
|
|
336
|
+
...r.note && r.note.trim() ? { note: r.note.trim() } : {}
|
|
337
|
+
})),
|
|
338
|
+
...input.summary && input.summary.trim() ? { summary: input.summary.trim() } : {}
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
return response.data?.status;
|
|
342
|
+
}
|
|
291
343
|
/**
|
|
292
344
|
* Attach a file (screenshot, log, voice note) to an already-
|
|
293
345
|
* submitted bug report. Hits POST /v1/testers/me/bug-reports/
|
|
@@ -425,6 +477,47 @@ var TesterPayKitApiClient = class {
|
|
|
425
477
|
);
|
|
426
478
|
return response.data;
|
|
427
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* POST /v1/testers/me/phone/start — sends a 6-digit SMS code.
|
|
482
|
+
* Throws with status 400 (invalid_phone), 429 (too_many_codes) or
|
|
483
|
+
* 503 (sms_not_configured: the server cannot send SMS yet).
|
|
484
|
+
*/
|
|
485
|
+
async startPhoneVerification(phone) {
|
|
486
|
+
const response = await this.client.post(
|
|
487
|
+
"/v1/testers/me/phone/start",
|
|
488
|
+
{ phone }
|
|
489
|
+
);
|
|
490
|
+
return response.data;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
494
|
+
* tester's handle; the same number on another install hands it over.
|
|
495
|
+
* `device` binds the number to this physical device (migration 077):
|
|
496
|
+
* a number already confirmed on another device throws 409
|
|
497
|
+
* `device_not_allowed` until an admin allows the new one.
|
|
498
|
+
*/
|
|
499
|
+
async confirmPhoneVerification(verificationId, code, device) {
|
|
500
|
+
const response = await this.client.post(
|
|
501
|
+
"/v1/testers/me/phone/confirm",
|
|
502
|
+
{ verificationId, code, ...device }
|
|
503
|
+
);
|
|
504
|
+
return response.data;
|
|
505
|
+
}
|
|
506
|
+
async getCompensation() {
|
|
507
|
+
return (await this.client.get("/v1/testers/me/compensation")).data;
|
|
508
|
+
}
|
|
509
|
+
async recordPaidWork(command) {
|
|
510
|
+
return (await this.client.post("/v1/testers/me/compensation", command)).data;
|
|
511
|
+
}
|
|
512
|
+
async registerCompensationPush(registration) {
|
|
513
|
+
await this.client.post("/v1/testers/me/compensation", { action: "push", ...registration });
|
|
514
|
+
}
|
|
515
|
+
async getPayoutAccount() {
|
|
516
|
+
return (await this.client.get("/v1/testers/me/payout-account")).data;
|
|
517
|
+
}
|
|
518
|
+
async createPayoutAccountLink() {
|
|
519
|
+
return (await this.client.post("/v1/testers/me/payout-account")).data;
|
|
520
|
+
}
|
|
428
521
|
/** GET /v1/testers/me/points — current point balance + breakdown. */
|
|
429
522
|
async getMyPoints() {
|
|
430
523
|
const response = await this.client.get(
|
|
@@ -541,17 +634,6 @@ var TesterPayKitApiClient = class {
|
|
|
541
634
|
);
|
|
542
635
|
return response.data;
|
|
543
636
|
}
|
|
544
|
-
/**
|
|
545
|
-
* POST /v1/session-feedback
|
|
546
|
-
* Submit end-of-session feedback (rating, comments, etc.).
|
|
547
|
-
*/
|
|
548
|
-
async submitSessionEndFeedback(payload) {
|
|
549
|
-
const response = await this.client.post(
|
|
550
|
-
"/v1/session-feedback",
|
|
551
|
-
payload
|
|
552
|
-
);
|
|
553
|
-
return response.data;
|
|
554
|
-
}
|
|
555
637
|
/**
|
|
556
638
|
* Upload an attachment directly (not tied to a specific bug report).
|
|
557
639
|
* POST /v1/attachments — alternate path from the contract alongside
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
} from "@testerpaykit/core";
|
|
6
6
|
var TesterPayKitApiClient = class {
|
|
7
7
|
constructor(config) {
|
|
8
|
+
/**
|
|
9
|
+
* Called on any 403 `phone_required` / `approval_required` answer: the
|
|
10
|
+
* tester is not (or no longer) cleared to report. SDKs hide their
|
|
11
|
+
* tester UI on it. The request still rejects as before.
|
|
12
|
+
*/
|
|
13
|
+
this.onTesterGate = null;
|
|
8
14
|
this.apiKey = config.apiKey;
|
|
9
15
|
this.tokenManager = config.tokenManager || new TokenManager();
|
|
10
16
|
this.client = axios.create({
|
|
@@ -33,6 +39,13 @@ var TesterPayKitApiClient = class {
|
|
|
33
39
|
if (error.response?.status === 401) {
|
|
34
40
|
this.tokenManager.clear();
|
|
35
41
|
}
|
|
42
|
+
const code = error.response?.data?.error;
|
|
43
|
+
if (error.response?.status === 403 && (code === "phone_required" || code === "approval_required")) {
|
|
44
|
+
try {
|
|
45
|
+
this.onTesterGate?.(code);
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
36
49
|
return Promise.reject(error);
|
|
37
50
|
}
|
|
38
51
|
);
|
|
@@ -215,11 +228,13 @@ var TesterPayKitApiClient = class {
|
|
|
215
228
|
/**
|
|
216
229
|
* Claim a remote AI-tester run waiting for this project.
|
|
217
230
|
* POST /v1/testers/me/ai-sessions/claim — 204 → null.
|
|
231
|
+
* `appVersion` lets the API hand out AI retests of a fixed bug, which
|
|
232
|
+
* only a build at or above the fixed version may run.
|
|
218
233
|
*/
|
|
219
|
-
async claimRemoteAiSession(projectId) {
|
|
234
|
+
async claimRemoteAiSession(projectId, appVersion) {
|
|
220
235
|
const response = await this.client.post(
|
|
221
236
|
"/v1/testers/me/ai-sessions/claim",
|
|
222
|
-
{ project_id: projectId }
|
|
237
|
+
{ project_id: projectId, ...appVersion ? { app_version: appVersion } : {} }
|
|
223
238
|
);
|
|
224
239
|
if (response.status === 204 || !response.data?.sessionId) return null;
|
|
225
240
|
return response.data;
|
|
@@ -254,6 +269,43 @@ var TesterPayKitApiClient = class {
|
|
|
254
269
|
);
|
|
255
270
|
return response.data?.id;
|
|
256
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* What to test in this app: the project's checklist tasks with this
|
|
274
|
+
* tester's (`mine`) and the AI tester's (`ai`) latest pass.
|
|
275
|
+
* GET /v1/testers/me/checklist?project_id=… — a 404 (tester not in the
|
|
276
|
+
* project yet) yields an empty list.
|
|
277
|
+
*/
|
|
278
|
+
async getChecklist(projectId) {
|
|
279
|
+
try {
|
|
280
|
+
const response = await this.client.get(
|
|
281
|
+
"/v1/testers/me/checklist",
|
|
282
|
+
{ params: { project_id: projectId } }
|
|
283
|
+
);
|
|
284
|
+
return Array.isArray(response.data?.tasks) ? response.data.tasks : [];
|
|
285
|
+
} catch (e) {
|
|
286
|
+
if (e?.response?.status === 404) return [];
|
|
287
|
+
throw e;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* One pass through a checklist task, a verdict per step.
|
|
292
|
+
* POST /v1/testers/me/checklist/{taskId}/runs → the run's status.
|
|
293
|
+
*/
|
|
294
|
+
async submitChecklistRun(input) {
|
|
295
|
+
const response = await this.client.post(
|
|
296
|
+
`/v1/testers/me/checklist/${encodeURIComponent(input.taskId)}/runs`,
|
|
297
|
+
{
|
|
298
|
+
project_id: input.projectId,
|
|
299
|
+
step_results: input.stepResults.map((r) => ({
|
|
300
|
+
step: r.step,
|
|
301
|
+
passed: r.passed,
|
|
302
|
+
...r.note && r.note.trim() ? { note: r.note.trim() } : {}
|
|
303
|
+
})),
|
|
304
|
+
...input.summary && input.summary.trim() ? { summary: input.summary.trim() } : {}
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
return response.data?.status;
|
|
308
|
+
}
|
|
257
309
|
/**
|
|
258
310
|
* Attach a file (screenshot, log, voice note) to an already-
|
|
259
311
|
* submitted bug report. Hits POST /v1/testers/me/bug-reports/
|
|
@@ -391,6 +443,47 @@ var TesterPayKitApiClient = class {
|
|
|
391
443
|
);
|
|
392
444
|
return response.data;
|
|
393
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* POST /v1/testers/me/phone/start — sends a 6-digit SMS code.
|
|
448
|
+
* Throws with status 400 (invalid_phone), 429 (too_many_codes) or
|
|
449
|
+
* 503 (sms_not_configured: the server cannot send SMS yet).
|
|
450
|
+
*/
|
|
451
|
+
async startPhoneVerification(phone) {
|
|
452
|
+
const response = await this.client.post(
|
|
453
|
+
"/v1/testers/me/phone/start",
|
|
454
|
+
{ phone }
|
|
455
|
+
);
|
|
456
|
+
return response.data;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
460
|
+
* tester's handle; the same number on another install hands it over.
|
|
461
|
+
* `device` binds the number to this physical device (migration 077):
|
|
462
|
+
* a number already confirmed on another device throws 409
|
|
463
|
+
* `device_not_allowed` until an admin allows the new one.
|
|
464
|
+
*/
|
|
465
|
+
async confirmPhoneVerification(verificationId, code, device) {
|
|
466
|
+
const response = await this.client.post(
|
|
467
|
+
"/v1/testers/me/phone/confirm",
|
|
468
|
+
{ verificationId, code, ...device }
|
|
469
|
+
);
|
|
470
|
+
return response.data;
|
|
471
|
+
}
|
|
472
|
+
async getCompensation() {
|
|
473
|
+
return (await this.client.get("/v1/testers/me/compensation")).data;
|
|
474
|
+
}
|
|
475
|
+
async recordPaidWork(command) {
|
|
476
|
+
return (await this.client.post("/v1/testers/me/compensation", command)).data;
|
|
477
|
+
}
|
|
478
|
+
async registerCompensationPush(registration) {
|
|
479
|
+
await this.client.post("/v1/testers/me/compensation", { action: "push", ...registration });
|
|
480
|
+
}
|
|
481
|
+
async getPayoutAccount() {
|
|
482
|
+
return (await this.client.get("/v1/testers/me/payout-account")).data;
|
|
483
|
+
}
|
|
484
|
+
async createPayoutAccountLink() {
|
|
485
|
+
return (await this.client.post("/v1/testers/me/payout-account")).data;
|
|
486
|
+
}
|
|
394
487
|
/** GET /v1/testers/me/points — current point balance + breakdown. */
|
|
395
488
|
async getMyPoints() {
|
|
396
489
|
const response = await this.client.get(
|
|
@@ -507,17 +600,6 @@ var TesterPayKitApiClient = class {
|
|
|
507
600
|
);
|
|
508
601
|
return response.data;
|
|
509
602
|
}
|
|
510
|
-
/**
|
|
511
|
-
* POST /v1/session-feedback
|
|
512
|
-
* Submit end-of-session feedback (rating, comments, etc.).
|
|
513
|
-
*/
|
|
514
|
-
async submitSessionEndFeedback(payload) {
|
|
515
|
-
const response = await this.client.post(
|
|
516
|
-
"/v1/session-feedback",
|
|
517
|
-
payload
|
|
518
|
-
);
|
|
519
|
-
return response.data;
|
|
520
|
-
}
|
|
521
603
|
/**
|
|
522
604
|
* Upload an attachment directly (not tied to a specific bug report).
|
|
523
605
|
* POST /v1/attachments — alternate path from the contract alongside
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from 'axios';
|
|
2
|
+
import type { CompensationWallet, PaidAssignment, WorkCommand, PushRegistration } from './compensation';
|
|
2
3
|
import {
|
|
3
4
|
IApiClient,
|
|
4
5
|
LoginRequest,
|
|
@@ -20,6 +21,42 @@ export interface LiveNoteInput {
|
|
|
20
21
|
screenshotBase64?: string | null;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/** One step verdict of a checklist pass (`step` is 1-based). */
|
|
25
|
+
export interface ChecklistStepResult {
|
|
26
|
+
step: number;
|
|
27
|
+
passed: boolean;
|
|
28
|
+
note?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The latest pass through a checklist task (by this tester or the AI). */
|
|
32
|
+
export interface ChecklistRun {
|
|
33
|
+
status: 'passed' | 'failed' | 'incomplete' | string;
|
|
34
|
+
steps: ChecklistStepResult[];
|
|
35
|
+
summary?: string;
|
|
36
|
+
at: string;
|
|
37
|
+
tester?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One task of a project's checklist: what should be tested. */
|
|
41
|
+
export interface ChecklistTask {
|
|
42
|
+
id: string;
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
steps: string[];
|
|
46
|
+
/** This tester's latest pass. */
|
|
47
|
+
mine?: ChecklistRun;
|
|
48
|
+
/** The AI tester's latest pass. */
|
|
49
|
+
ai?: ChecklistRun;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Body of `submitChecklistRun`. */
|
|
53
|
+
export interface ChecklistRunInput {
|
|
54
|
+
projectId: string;
|
|
55
|
+
taskId: string;
|
|
56
|
+
stepResults: ChecklistStepResult[];
|
|
57
|
+
summary?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
23
60
|
export interface ApiClientConfig {
|
|
24
61
|
baseURL?: string;
|
|
25
62
|
apiKey: string;
|
|
@@ -34,11 +71,21 @@ export interface ApiClientConfig {
|
|
|
34
71
|
* - Request/response interceptors for auth headers
|
|
35
72
|
* - Integration with TokenManager for token lifecycle
|
|
36
73
|
*/
|
|
74
|
+
/** The tester gate's 403 codes (migrations 075 + 077). */
|
|
75
|
+
export type TesterGateReason = 'phone_required' | 'approval_required';
|
|
76
|
+
|
|
37
77
|
export class TesterPayKitApiClient implements IApiClient {
|
|
38
78
|
private client: AxiosInstance;
|
|
39
79
|
private tokenManager: TokenManager;
|
|
40
80
|
private apiKey: string;
|
|
41
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Called on any 403 `phone_required` / `approval_required` answer: the
|
|
84
|
+
* tester is not (or no longer) cleared to report. SDKs hide their
|
|
85
|
+
* tester UI on it. The request still rejects as before.
|
|
86
|
+
*/
|
|
87
|
+
onTesterGate: ((reason: TesterGateReason) => void) | null = null;
|
|
88
|
+
|
|
42
89
|
constructor(config: ApiClientConfig) {
|
|
43
90
|
this.apiKey = config.apiKey;
|
|
44
91
|
this.tokenManager = config.tokenManager || new TokenManager();
|
|
@@ -75,6 +122,17 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
75
122
|
// Token expired or invalid, clear tokens
|
|
76
123
|
this.tokenManager.clear();
|
|
77
124
|
}
|
|
125
|
+
const code = error.response?.data?.error;
|
|
126
|
+
if (
|
|
127
|
+
error.response?.status === 403 &&
|
|
128
|
+
(code === 'phone_required' || code === 'approval_required')
|
|
129
|
+
) {
|
|
130
|
+
try {
|
|
131
|
+
this.onTesterGate?.(code);
|
|
132
|
+
} catch {
|
|
133
|
+
// A listener problem must not change the request's outcome.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
78
136
|
return Promise.reject(error);
|
|
79
137
|
}
|
|
80
138
|
);
|
|
@@ -320,11 +378,16 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
320
378
|
/**
|
|
321
379
|
* Claim a remote AI-tester run waiting for this project.
|
|
322
380
|
* POST /v1/testers/me/ai-sessions/claim — 204 → null.
|
|
381
|
+
* `appVersion` lets the API hand out AI retests of a fixed bug, which
|
|
382
|
+
* only a build at or above the fixed version may run.
|
|
323
383
|
*/
|
|
324
|
-
async claimRemoteAiSession(
|
|
384
|
+
async claimRemoteAiSession(
|
|
385
|
+
projectId: string,
|
|
386
|
+
appVersion?: string,
|
|
387
|
+
): Promise<RemoteAiSession | null> {
|
|
325
388
|
const response = await this.client.post<RemoteAiSession>(
|
|
326
389
|
'/v1/testers/me/ai-sessions/claim',
|
|
327
|
-
{ project_id: projectId },
|
|
390
|
+
{ project_id: projectId, ...(appVersion ? { app_version: appVersion } : {}) },
|
|
328
391
|
);
|
|
329
392
|
if (response.status === 204 || !response.data?.sessionId) return null;
|
|
330
393
|
return response.data;
|
|
@@ -362,6 +425,45 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
362
425
|
return response.data?.id;
|
|
363
426
|
}
|
|
364
427
|
|
|
428
|
+
/**
|
|
429
|
+
* What to test in this app: the project's checklist tasks with this
|
|
430
|
+
* tester's (`mine`) and the AI tester's (`ai`) latest pass.
|
|
431
|
+
* GET /v1/testers/me/checklist?project_id=… — a 404 (tester not in the
|
|
432
|
+
* project yet) yields an empty list.
|
|
433
|
+
*/
|
|
434
|
+
async getChecklist(projectId: string): Promise<ChecklistTask[]> {
|
|
435
|
+
try {
|
|
436
|
+
const response = await this.client.get<{ tasks?: ChecklistTask[] }>(
|
|
437
|
+
'/v1/testers/me/checklist',
|
|
438
|
+
{ params: { project_id: projectId } },
|
|
439
|
+
);
|
|
440
|
+
return Array.isArray(response.data?.tasks) ? response.data.tasks : [];
|
|
441
|
+
} catch (e) {
|
|
442
|
+
if ((e as { response?: { status?: number } })?.response?.status === 404) return [];
|
|
443
|
+
throw e;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* One pass through a checklist task, a verdict per step.
|
|
449
|
+
* POST /v1/testers/me/checklist/{taskId}/runs → the run's status.
|
|
450
|
+
*/
|
|
451
|
+
async submitChecklistRun(input: ChecklistRunInput): Promise<string> {
|
|
452
|
+
const response = await this.client.post<{ status: string }>(
|
|
453
|
+
`/v1/testers/me/checklist/${encodeURIComponent(input.taskId)}/runs`,
|
|
454
|
+
{
|
|
455
|
+
project_id: input.projectId,
|
|
456
|
+
step_results: input.stepResults.map((r) => ({
|
|
457
|
+
step: r.step,
|
|
458
|
+
passed: r.passed,
|
|
459
|
+
...(r.note && r.note.trim() ? { note: r.note.trim() } : {}),
|
|
460
|
+
})),
|
|
461
|
+
...(input.summary && input.summary.trim() ? { summary: input.summary.trim() } : {}),
|
|
462
|
+
},
|
|
463
|
+
);
|
|
464
|
+
return response.data?.status;
|
|
465
|
+
}
|
|
466
|
+
|
|
365
467
|
/**
|
|
366
468
|
* Attach a file (screenshot, log, voice note) to an already-
|
|
367
469
|
* submitted bug report. Hits POST /v1/testers/me/bug-reports/
|
|
@@ -526,6 +628,58 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
526
628
|
return response.data;
|
|
527
629
|
}
|
|
528
630
|
|
|
631
|
+
/**
|
|
632
|
+
* POST /v1/testers/me/phone/start — sends a 6-digit SMS code.
|
|
633
|
+
* Throws with status 400 (invalid_phone), 429 (too_many_codes) or
|
|
634
|
+
* 503 (sms_not_configured: the server cannot send SMS yet).
|
|
635
|
+
*/
|
|
636
|
+
async startPhoneVerification(phone: string): Promise<PhoneStartResponse> {
|
|
637
|
+
const response = await this.client.post<PhoneStartResponse>(
|
|
638
|
+
'/v1/testers/me/phone/start',
|
|
639
|
+
{ phone },
|
|
640
|
+
);
|
|
641
|
+
return response.data;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
646
|
+
* tester's handle; the same number on another install hands it over.
|
|
647
|
+
* `device` binds the number to this physical device (migration 077):
|
|
648
|
+
* a number already confirmed on another device throws 409
|
|
649
|
+
* `device_not_allowed` until an admin allows the new one.
|
|
650
|
+
*/
|
|
651
|
+
async confirmPhoneVerification(
|
|
652
|
+
verificationId: string,
|
|
653
|
+
code: string,
|
|
654
|
+
device?: { deviceKey: string; platform: 'ios' | 'android' | 'web' },
|
|
655
|
+
): Promise<PhoneConfirmResponse> {
|
|
656
|
+
const response = await this.client.post<PhoneConfirmResponse>(
|
|
657
|
+
'/v1/testers/me/phone/confirm',
|
|
658
|
+
{ verificationId, code, ...device },
|
|
659
|
+
);
|
|
660
|
+
return response.data;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
async getCompensation(): Promise<CompensationWallet> {
|
|
664
|
+
return (await this.client.get<CompensationWallet>('/v1/testers/me/compensation')).data;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async recordPaidWork(command: WorkCommand): Promise<PaidAssignment> {
|
|
668
|
+
return (await this.client.post<PaidAssignment>('/v1/testers/me/compensation', command)).data;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
async registerCompensationPush(registration: PushRegistration): Promise<void> {
|
|
672
|
+
await this.client.post('/v1/testers/me/compensation', { action: 'push', ...registration });
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
async getPayoutAccount(): Promise<{ has_account: boolean; transfers_active: boolean; payments_configured: boolean }> {
|
|
676
|
+
return (await this.client.get('/v1/testers/me/payout-account')).data;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async createPayoutAccountLink(): Promise<{ url: string }> {
|
|
680
|
+
return (await this.client.post('/v1/testers/me/payout-account')).data;
|
|
681
|
+
}
|
|
682
|
+
|
|
529
683
|
/** GET /v1/testers/me/points — current point balance + breakdown. */
|
|
530
684
|
async getMyPoints(): Promise<TesterPoints> {
|
|
531
685
|
const response = await this.client.get<TesterPoints>(
|
|
@@ -674,20 +828,6 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
674
828
|
return response.data;
|
|
675
829
|
}
|
|
676
830
|
|
|
677
|
-
/**
|
|
678
|
-
* POST /v1/session-feedback
|
|
679
|
-
* Submit end-of-session feedback (rating, comments, etc.).
|
|
680
|
-
*/
|
|
681
|
-
async submitSessionEndFeedback(
|
|
682
|
-
payload: Record<string, unknown>,
|
|
683
|
-
): Promise<FeedbackResponse> {
|
|
684
|
-
const response = await this.client.post<FeedbackResponse>(
|
|
685
|
-
'/v1/session-feedback',
|
|
686
|
-
payload,
|
|
687
|
-
);
|
|
688
|
-
return response.data;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
831
|
/**
|
|
692
832
|
* Upload an attachment directly (not tied to a specific bug report).
|
|
693
833
|
* POST /v1/attachments — alternate path from the contract alongside
|
|
@@ -1134,7 +1274,12 @@ export interface EnrollmentResponse {
|
|
|
1134
1274
|
export interface TesterProfile {
|
|
1135
1275
|
id: string;
|
|
1136
1276
|
email?: string | null;
|
|
1277
|
+
/** System handle, e.g. "sad-banana" (migration 074). */
|
|
1137
1278
|
handle?: string | null;
|
|
1279
|
+
/** True once this install confirmed a phone number. */
|
|
1280
|
+
phoneVerified?: boolean;
|
|
1281
|
+
/** True once an admin approved the person (migration 077). */
|
|
1282
|
+
approved?: boolean;
|
|
1138
1283
|
fullName?: string | null;
|
|
1139
1284
|
rating?: number | null;
|
|
1140
1285
|
pointsTotal?: number | null;
|
|
@@ -1142,6 +1287,20 @@ export interface TesterProfile {
|
|
|
1142
1287
|
createdAt?: string;
|
|
1143
1288
|
}
|
|
1144
1289
|
|
|
1290
|
+
export interface PhoneStartResponse {
|
|
1291
|
+
verificationId: string;
|
|
1292
|
+
expiresInSeconds: number;
|
|
1293
|
+
/** Only returned by a development server. */
|
|
1294
|
+
devCode?: string;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
export interface PhoneConfirmResponse {
|
|
1298
|
+
handle: string;
|
|
1299
|
+
phoneVerified: boolean;
|
|
1300
|
+
/** Tester status after the confirmation (e.g. `active`, `pending`). */
|
|
1301
|
+
status?: string | null;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1145
1304
|
export interface TesterPoints {
|
|
1146
1305
|
total: number;
|
|
1147
1306
|
breakdown?: Record<string, number>;
|
|
@@ -1204,13 +1363,6 @@ export interface TesterDeviceResponse {
|
|
|
1204
1363
|
deviceType: string;
|
|
1205
1364
|
}
|
|
1206
1365
|
|
|
1207
|
-
/** Response from POST /v1/session-feedback */
|
|
1208
|
-
export interface FeedbackResponse {
|
|
1209
|
-
id: string;
|
|
1210
|
-
status: string;
|
|
1211
|
-
message?: string;
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
1366
|
function stepResults(verdicts: RetestStepVerdicts): { step: number; passed: boolean }[] {
|
|
1215
1367
|
return Object.entries(verdicts).map(([step, passed]) => ({ step: Number(step), passed }));
|
|
1216
1368
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** `play` = play money in the pilot: real ledger rows, never a payout.
|
|
2
|
+
* Every UI labels such amounts "Spielgeld · Pilot" / "Play money · pilot". */
|
|
3
|
+
export type MoneyMode = 'play' | 'test' | 'live';
|
|
4
|
+
export type WorkState = 'offered' | 'active' | 'paused' | 'review' | 'disputed' | 'approved' | 'cancelled';
|
|
5
|
+
export interface PaidAssignment {
|
|
6
|
+
id: string; project_id: string; tester_id: string; title: string; project_name: string;
|
|
7
|
+
mode: MoneyMode; terms_version: 1; rate_cents: number; minimum_cents: number;
|
|
8
|
+
budget_cents: number; seconds: number; running_since: string | null;
|
|
9
|
+
state: WorkState; revision: number; amount_cents: number | null;
|
|
10
|
+
review_due: string | null; review_note: string | null; completion_note: string | null;
|
|
11
|
+
}
|
|
12
|
+
/** time = paid assignment · task = checklist task on its announced time ·
|
|
13
|
+
* bonus = idea bonus · bug_bonus · reproduction · retest (one per round). */
|
|
14
|
+
export type MoneyKind = 'time' | 'task' | 'bonus' | 'bug_bonus' | 'reproduction' | 'retest' | 'start_bonus';
|
|
15
|
+
export interface MoneyEntry {
|
|
16
|
+
id: string; project_id: string; project_name: string; tester_id: string; mode: MoneyMode;
|
|
17
|
+
kind: MoneyKind; reason: string; amount_cents: number; currency: 'eur';
|
|
18
|
+
/** review = waits for the 3-working-day window, then released. */
|
|
19
|
+
status: 'review' | 'approved' | 'processing' | 'transferred' | 'held';
|
|
20
|
+
units: number; review_due: string | null; review_note: string | null;
|
|
21
|
+
bug_id: string | null; task_preset_id: string | null;
|
|
22
|
+
created_at: string; transfer_id: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Sums in the current mode, in cents. Bonuses never count towards the 5 € floor. */
|
|
25
|
+
export interface MoneyTotals {
|
|
26
|
+
in_review_cents: number; released_cents: number; bonus_cents: number;
|
|
27
|
+
held_cents: number; total_cents: number;
|
|
28
|
+
}
|
|
29
|
+
export interface CompensationRates {
|
|
30
|
+
rate_cents_per_minute: number; minimum_cents: number;
|
|
31
|
+
bug_bonus_cents: { easy: number; medium: number; hard: number };
|
|
32
|
+
reproduction_cents: number; retest_per_fix_cents: number; retest_round_minimum_cents: number;
|
|
33
|
+
idea_bonus_choices_cents: number[]; review_working_days: number;
|
|
34
|
+
/** Start bonus, booked once per person on the first phone confirmation. */
|
|
35
|
+
start_bonus_cents?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface CompensationWallet {
|
|
38
|
+
/** Current mode; `play` = label every amount as play money. */
|
|
39
|
+
mode: MoneyMode;
|
|
40
|
+
currency: 'eur'; server_time: string; rates: CompensationRates;
|
|
41
|
+
/** The person = every app install with the same confirmed phone. */
|
|
42
|
+
person: { handle: string | null; phone_confirmed: boolean; tester_count: number;
|
|
43
|
+
apps: Array<{ project_id: string; project_name: string }> };
|
|
44
|
+
/** Whole person across apps … */
|
|
45
|
+
totals: MoneyTotals;
|
|
46
|
+
/** … and the share of this app install. */
|
|
47
|
+
this_app: MoneyTotals;
|
|
48
|
+
assignments: PaidAssignment[]; entries: MoneyEntry[];
|
|
49
|
+
balances: Record<MoneyMode, Record<MoneyEntry['status'], number>>;
|
|
50
|
+
legacy: Array<{ id: string; source: string; amount_cents: number; status: string }>;
|
|
51
|
+
}
|
|
52
|
+
export interface WorkCommand {
|
|
53
|
+
assignment_id: string; request_id: string; revision: number;
|
|
54
|
+
action: 'start' | 'pause' | 'submit' | 'submit_partial' | 'decline';
|
|
55
|
+
accept_terms_version?: 1; seconds?: number; note?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PushRegistration {
|
|
58
|
+
installation_id: string; app_id: string; token?: string; enabled: boolean;
|
|
59
|
+
}
|
package/src/index.ts
CHANGED