incremnt 0.7.0 → 0.7.2

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/src/remote.js CHANGED
@@ -42,7 +42,8 @@ const remoteCommandHandlers = {
42
42
  'ask-show': executeRemoteRead,
43
43
  'program-share-fetch': executeRemoteRead,
44
44
  'increment-score-current': executeRemoteRead,
45
- 'increment-score-history': executeRemoteRead
45
+ 'increment-score-history': executeRemoteRead,
46
+ 'coach-observations-current': executeRemoteRead
46
47
  };
47
48
 
48
49
  async function executeRemoteRead(options, sessionState, normalizedCommand) {
@@ -175,6 +176,11 @@ function endpointForCommand(baseUrl, normalizedCommand, options) {
175
176
  if (options.limit) url.searchParams.set('limit', options.limit);
176
177
  return url;
177
178
  }
179
+ case 'coach-observations-current': {
180
+ const url = resolveServiceUrl(baseUrl, '/cli/coach-observations/current');
181
+ if (options.limit) url.searchParams.set('limit', options.limit);
182
+ return url;
183
+ }
178
184
  default:
179
185
  return resolveServiceUrl(baseUrl, '/');
180
186
  }
@@ -321,6 +327,32 @@ export async function buildWriteRequest(commandId, options, sessionState) {
321
327
  body
322
328
  };
323
329
  }
330
+ case 'coach-observations-seen': {
331
+ if (!options.id) {
332
+ const error = new Error('--id is required for coach observations seen.');
333
+ error.code = 'MISSING_OPTION';
334
+ throw error;
335
+ }
336
+ const body = {};
337
+ if (options.seenAt) body.seenAt = options.seenAt;
338
+ return {
339
+ method: 'POST',
340
+ url: resolveServiceUrl(baseUrl, `/cli/coach-observations/${encodeURIComponent(options.id)}/seen`).toString(),
341
+ body
342
+ };
343
+ }
344
+ case 'coach-observations-dismiss': {
345
+ if (!options.id) {
346
+ const error = new Error('--id is required for coach observations dismiss.');
347
+ error.code = 'MISSING_OPTION';
348
+ throw error;
349
+ }
350
+ return {
351
+ method: 'POST',
352
+ url: resolveServiceUrl(baseUrl, `/cli/coach-observations/${encodeURIComponent(options.id)}/dismiss`).toString(),
353
+ body: {}
354
+ };
355
+ }
324
356
  default: {
325
357
  const error = new Error(`Command ${commandId} does not support --dry-run.`);
326
358
  error.code = 'UNSUPPORTED_DRY_RUN';
@@ -553,6 +585,76 @@ const remoteWriteCommandHandlers = {
553
585
  throw error;
554
586
  }
555
587
  return response.json();
588
+ },
589
+
590
+ 'coach-observations-seen': async (options, sessionState) => {
591
+ const baseUrl = sessionState.session?.transport?.baseUrl;
592
+ if (!baseUrl) throw notImplementedError();
593
+ if (!options.id) {
594
+ const error = new Error('--id is required for coach observations seen.');
595
+ error.code = 'MISSING_OPTION';
596
+ throw error;
597
+ }
598
+
599
+ const body = {};
600
+ if (options.seenAt) body.seenAt = options.seenAt;
601
+ const endpoint = resolveServiceUrl(baseUrl, `/cli/coach-observations/${encodeURIComponent(options.id)}/seen`);
602
+ const response = await fetch(endpoint, {
603
+ method: 'POST',
604
+ headers: {
605
+ 'Content-Type': 'application/json',
606
+ Authorization: `Bearer ${sessionState.session?.auth?.accessToken ?? ''}`
607
+ },
608
+ body: JSON.stringify(body)
609
+ });
610
+
611
+ if (response.status === 401 || response.status === 403) throw authenticationFailedError();
612
+ if (response.status === 404) {
613
+ const error = new Error(`Coach observation not found: ${options.id}`);
614
+ error.code = 'REMOTE_NOT_FOUND';
615
+ throw error;
616
+ }
617
+ if (!response.ok) {
618
+ const payload = await response.json().catch(() => null);
619
+ const error = new Error(payload?.error ?? `Unexpected error (HTTP ${response.status}).`);
620
+ error.code = 'REMOTE_HTTP_ERROR';
621
+ throw error;
622
+ }
623
+ return response.json();
624
+ },
625
+
626
+ 'coach-observations-dismiss': async (options, sessionState) => {
627
+ const baseUrl = sessionState.session?.transport?.baseUrl;
628
+ if (!baseUrl) throw notImplementedError();
629
+ if (!options.id) {
630
+ const error = new Error('--id is required for coach observations dismiss.');
631
+ error.code = 'MISSING_OPTION';
632
+ throw error;
633
+ }
634
+
635
+ const endpoint = resolveServiceUrl(baseUrl, `/cli/coach-observations/${encodeURIComponent(options.id)}/dismiss`);
636
+ const response = await fetch(endpoint, {
637
+ method: 'POST',
638
+ headers: {
639
+ 'Content-Type': 'application/json',
640
+ Authorization: `Bearer ${sessionState.session?.auth?.accessToken ?? ''}`
641
+ },
642
+ body: JSON.stringify({})
643
+ });
644
+
645
+ if (response.status === 401 || response.status === 403) throw authenticationFailedError();
646
+ if (response.status === 404) {
647
+ const error = new Error(`Coach observation not found: ${options.id}`);
648
+ error.code = 'REMOTE_NOT_FOUND';
649
+ throw error;
650
+ }
651
+ if (!response.ok) {
652
+ const payload = await response.json().catch(() => null);
653
+ const error = new Error(payload?.error ?? `Unexpected error (HTTP ${response.status}).`);
654
+ error.code = 'REMOTE_HTTP_ERROR';
655
+ throw error;
656
+ }
657
+ return response.json();
556
658
  }
557
659
  };
558
660