@testerpaykit/api-client 1.1.0 → 1.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.
@@ -1,18 +1,15 @@
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
-
1
+ $ tsup src/index.ts --format cjs,esm --dts
5
2
  CLI Building entry: src/index.ts
6
3
  CLI Using tsconfig: tsconfig.json
7
4
  CLI tsup v8.5.1
8
5
  CLI Target: es2020
9
6
  CJS Build start
10
7
  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
8
+ ESM dist/index.mjs 18.53 KB
9
+ ESM ⚡️ Build success in 15ms
10
+ CJS dist/index.js 20.18 KB
11
+ CJS ⚡️ Build success in 15ms
15
12
  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
13
+ DTS ⚡️ Build success in 444ms
14
+ DTS dist/index.d.ts 23.08 KB
15
+ DTS dist/index.d.mts 23.08 KB
@@ -0,0 +1,12 @@
1
+ $ vitest --run
2
+ The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
3
+
4
+ RUN v1.6.1 /Users/udi/work/moinsen/ideas/moinsen-infrastructure/TesterPayKit/sdks/typescript/packages/api-client
5
+
6
+ ✓ tests/TesterPayKitApiClient.test.ts (14 tests) 6ms
7
+
8
+ Test Files 1 passed (1)
9
+ Tests 14 passed (14)
10
+ Start at 16:58:26
11
+ Duration 473ms (transform 72ms, setup 0ms, collect 157ms, tests 6ms, environment 0ms, prepare 114ms)
12
+
package/dist/index.d.mts CHANGED
@@ -194,6 +194,20 @@ declare class TesterPayKitApiClient implements IApiClient {
194
194
  getMyProfile(): Promise<TesterProfile>;
195
195
  /** GET /v1/testers/me/points — current point balance + breakdown. */
196
196
  getMyPoints(): Promise<TesterPoints>;
197
+ /**
198
+ * POST /v1/testers/me/demand-signals
199
+ * Distribution-platform phase-3 market-validation signal ("would you
200
+ * use / pay for / recommend it?") for a session this tester actually
201
+ * experienced. Upserts per session on the server; each answer must be
202
+ * 'yes' | 'maybe' | 'no'.
203
+ */
204
+ submitDemandSignal(input: {
205
+ sessionId: string;
206
+ wouldUse: 'yes' | 'maybe' | 'no';
207
+ wouldPay: 'yes' | 'maybe' | 'no';
208
+ wouldRecommend: 'yes' | 'maybe' | 'no';
209
+ comment?: string;
210
+ }): Promise<void>;
197
211
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
198
212
  getEarningsSummary(): Promise<EarningsSummary>;
199
213
  /** GET /v1/testers/earnings/payouts — paginated payout history. */
package/dist/index.d.ts CHANGED
@@ -194,6 +194,20 @@ declare class TesterPayKitApiClient implements IApiClient {
194
194
  getMyProfile(): Promise<TesterProfile>;
195
195
  /** GET /v1/testers/me/points — current point balance + breakdown. */
196
196
  getMyPoints(): Promise<TesterPoints>;
197
+ /**
198
+ * POST /v1/testers/me/demand-signals
199
+ * Distribution-platform phase-3 market-validation signal ("would you
200
+ * use / pay for / recommend it?") for a session this tester actually
201
+ * experienced. Upserts per session on the server; each answer must be
202
+ * 'yes' | 'maybe' | 'no'.
203
+ */
204
+ submitDemandSignal(input: {
205
+ sessionId: string;
206
+ wouldUse: 'yes' | 'maybe' | 'no';
207
+ wouldPay: 'yes' | 'maybe' | 'no';
208
+ wouldRecommend: 'yes' | 'maybe' | 'no';
209
+ comment?: string;
210
+ }): Promise<void>;
197
211
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
198
212
  getEarningsSummary(): Promise<EarningsSummary>;
199
213
  /** GET /v1/testers/earnings/payouts — paginated payout history. */
package/dist/index.js CHANGED
@@ -294,6 +294,7 @@ var TesterPayKitApiClient = class {
294
294
  * Hits POST /v1/testers/sessions/:id/events in batch mode.
295
295
  */
296
296
  async addSessionEvents(sessionId, events) {
297
+ assertSessionId(sessionId, "addSessionEvents");
297
298
  const response = await this.client.post(
298
299
  `/v1/testers/sessions/${sessionId}/events`,
299
300
  {
@@ -314,6 +315,7 @@ var TesterPayKitApiClient = class {
314
315
  * Hits POST /v1/testers/sessions/:id/breadcrumbs in batch mode.
315
316
  */
316
317
  async addSessionBreadcrumbs(sessionId, breadcrumbs) {
318
+ assertSessionId(sessionId, "addSessionBreadcrumbs");
317
319
  const response = await this.client.post(
318
320
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
319
321
  {
@@ -385,6 +387,23 @@ var TesterPayKitApiClient = class {
385
387
  );
386
388
  return response.data;
387
389
  }
390
+ /**
391
+ * POST /v1/testers/me/demand-signals
392
+ * Distribution-platform phase-3 market-validation signal ("would you
393
+ * use / pay for / recommend it?") for a session this tester actually
394
+ * experienced. Upserts per session on the server; each answer must be
395
+ * 'yes' | 'maybe' | 'no'.
396
+ */
397
+ async submitDemandSignal(input) {
398
+ const comment = input.comment?.trim();
399
+ await this.client.post("/v1/testers/me/demand-signals", {
400
+ session_id: input.sessionId,
401
+ would_use: input.wouldUse,
402
+ would_pay: input.wouldPay,
403
+ would_recommend: input.wouldRecommend,
404
+ ...comment ? { comment } : {}
405
+ });
406
+ }
388
407
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
389
408
  async getEarningsSummary() {
390
409
  const response = await this.client.get(
@@ -557,6 +576,13 @@ var TesterPayKitApiClient = class {
557
576
  function formatTimestamp(timestamp) {
558
577
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
559
578
  }
579
+ function assertSessionId(sessionId, op) {
580
+ if (!sessionId) {
581
+ throw new Error(
582
+ `TesterPayKitApiClient.${op}: sessionId is empty \u2014 start a session before flushing session telemetry.`
583
+ );
584
+ }
585
+ }
560
586
  // Annotate the CommonJS export names for ESM import in node:
561
587
  0 && (module.exports = {
562
588
  TesterPayKitApiClient
package/dist/index.mjs CHANGED
@@ -260,6 +260,7 @@ var TesterPayKitApiClient = class {
260
260
  * Hits POST /v1/testers/sessions/:id/events in batch mode.
261
261
  */
262
262
  async addSessionEvents(sessionId, events) {
263
+ assertSessionId(sessionId, "addSessionEvents");
263
264
  const response = await this.client.post(
264
265
  `/v1/testers/sessions/${sessionId}/events`,
265
266
  {
@@ -280,6 +281,7 @@ var TesterPayKitApiClient = class {
280
281
  * Hits POST /v1/testers/sessions/:id/breadcrumbs in batch mode.
281
282
  */
282
283
  async addSessionBreadcrumbs(sessionId, breadcrumbs) {
284
+ assertSessionId(sessionId, "addSessionBreadcrumbs");
283
285
  const response = await this.client.post(
284
286
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
285
287
  {
@@ -351,6 +353,23 @@ var TesterPayKitApiClient = class {
351
353
  );
352
354
  return response.data;
353
355
  }
356
+ /**
357
+ * POST /v1/testers/me/demand-signals
358
+ * Distribution-platform phase-3 market-validation signal ("would you
359
+ * use / pay for / recommend it?") for a session this tester actually
360
+ * experienced. Upserts per session on the server; each answer must be
361
+ * 'yes' | 'maybe' | 'no'.
362
+ */
363
+ async submitDemandSignal(input) {
364
+ const comment = input.comment?.trim();
365
+ await this.client.post("/v1/testers/me/demand-signals", {
366
+ session_id: input.sessionId,
367
+ would_use: input.wouldUse,
368
+ would_pay: input.wouldPay,
369
+ would_recommend: input.wouldRecommend,
370
+ ...comment ? { comment } : {}
371
+ });
372
+ }
354
373
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
355
374
  async getEarningsSummary() {
356
375
  const response = await this.client.get(
@@ -523,6 +542,13 @@ var TesterPayKitApiClient = class {
523
542
  function formatTimestamp(timestamp) {
524
543
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
525
544
  }
545
+ function assertSessionId(sessionId, op) {
546
+ if (!sessionId) {
547
+ throw new Error(
548
+ `TesterPayKitApiClient.${op}: sessionId is empty \u2014 start a session before flushing session telemetry.`
549
+ );
550
+ }
551
+ }
526
552
  export {
527
553
  TesterPayKitApiClient
528
554
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testerpaykit/api-client",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "API client for TesterPayKit backend",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -366,6 +366,7 @@ export class TesterPayKitApiClient implements IApiClient {
366
366
  sessionId: string,
367
367
  events: SessionEventInput[],
368
368
  ): Promise<SessionEventsResponse> {
369
+ assertSessionId(sessionId, 'addSessionEvents');
369
370
  const response = await this.client.post<SessionEventsResponse>(
370
371
  `/v1/testers/sessions/${sessionId}/events`,
371
372
  {
@@ -390,6 +391,7 @@ export class TesterPayKitApiClient implements IApiClient {
390
391
  sessionId: string,
391
392
  breadcrumbs: SessionBreadcrumbInput[],
392
393
  ): Promise<SessionBreadcrumbsResponse> {
394
+ assertSessionId(sessionId, 'addSessionBreadcrumbs');
393
395
  const response = await this.client.post<SessionBreadcrumbsResponse>(
394
396
  `/v1/testers/sessions/${sessionId}/breadcrumbs`,
395
397
  {
@@ -471,6 +473,30 @@ export class TesterPayKitApiClient implements IApiClient {
471
473
  return response.data;
472
474
  }
473
475
 
476
+ /**
477
+ * POST /v1/testers/me/demand-signals
478
+ * Distribution-platform phase-3 market-validation signal ("would you
479
+ * use / pay for / recommend it?") for a session this tester actually
480
+ * experienced. Upserts per session on the server; each answer must be
481
+ * 'yes' | 'maybe' | 'no'.
482
+ */
483
+ async submitDemandSignal(input: {
484
+ sessionId: string;
485
+ wouldUse: 'yes' | 'maybe' | 'no';
486
+ wouldPay: 'yes' | 'maybe' | 'no';
487
+ wouldRecommend: 'yes' | 'maybe' | 'no';
488
+ comment?: string;
489
+ }): Promise<void> {
490
+ const comment = input.comment?.trim();
491
+ await this.client.post('/v1/testers/me/demand-signals', {
492
+ session_id: input.sessionId,
493
+ would_use: input.wouldUse,
494
+ would_pay: input.wouldPay,
495
+ would_recommend: input.wouldRecommend,
496
+ ...(comment ? { comment } : {}),
497
+ });
498
+ }
499
+
474
500
  /** GET /v1/testers/earnings/summary — totals, current balance, this month. */
475
501
  async getEarningsSummary(): Promise<EarningsSummary> {
476
502
  const response = await this.client.get<EarningsSummary>(
@@ -1115,3 +1141,17 @@ export interface TaskStep {
1115
1141
  function formatTimestamp(timestamp: Date | string): string {
1116
1142
  return timestamp instanceof Date ? timestamp.toISOString() : timestamp;
1117
1143
  }
1144
+
1145
+ /**
1146
+ * Guard against session-bound calls with an empty session id, which
1147
+ * would otherwise produce `/v1/testers/sessions//breadcrumbs` (double
1148
+ * slash → 401 spam, findling F-0002). Callers must resolve a real
1149
+ * session id first (or skip the flush).
1150
+ */
1151
+ function assertSessionId(sessionId: string, op: string): void {
1152
+ if (!sessionId) {
1153
+ throw new Error(
1154
+ `TesterPayKitApiClient.${op}: sessionId is empty — start a session before flushing session telemetry.`,
1155
+ );
1156
+ }
1157
+ }
@@ -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', () => {