@innspel/core 0.6.0 → 0.6.1

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedSettings, C as ContextInput, a as CaptureInput, b as CaptureResult, K as KnownIssueQuery, c as KnownIssuesKnownIssueCard, S as SubmissionsSubmissionStatusView, M as MySubmission, P as ProgramsMyPrograms, d as ProgramsParticipationView, e as ProgramsTaskCompletionCreate, f as ProgramsTaskCompletionView, g as ProgramsFollowUpResponseCreate, A as AttachmentInput, h as SubmissionsAttachmentView, Q as QueuedSubmission, F as FlushResult, i as PatternFinding, T as TelemetryEvent, O as OpenFeedbackOptions, j as Presenter, I as InnspelOptions, k as CommonErrorCode, l as SubmissionsAttachmentMime } from './typer-CK03lxOC.cjs';
2
- export { m as AttachmentBody, n as AttachmentOutcome, o as CaptureFeil, p as CaptureOnske, q as Correlation, r as FollowUpKind, s as FollowUpView, t as IdentityProvider, u as InnspelStorage, v as InvitationView, w as KnownIssueRef, x as KnownIssueStatus, y as PatternKind, z as Platform, B as ProgramTask, D as ProgramView, E as ReasonCode, G as ReplyView, H as StatusType, J as SubmissionStatus, L as SubmissionType, N as TaskOutcome, U as Telemetry, V as TextMaxLength } from './typer-CK03lxOC.cjs';
1
+ import { R as ResolvedSettings, C as ContextInput, a as CaptureInput, b as CaptureResult, K as KnownIssueQuery, c as KnownIssuesKnownIssueCard, S as SubmissionsSubmissionStatusView, M as MySubmission, P as ProgramsMyPrograms, d as ProgramsParticipationView, e as ProgramsTaskCompletionCreate, f as ProgramsTaskCompletionView, g as ProgramsFollowUpResponseCreate, A as AttachmentInput, h as SubmissionsAttachmentView, Q as QueuedSubmission, F as FlushResult, i as PatternFinding, T as TelemetryEvent, O as OpenFeedbackOptions, j as Presenter, I as InnspelOptions, k as CommonErrorCode, l as SubmissionsAttachmentMime } from './typer-Cf6TFjPD.cjs';
2
+ export { m as AttachmentBody, n as AttachmentOutcome, o as CaptureFeil, p as CaptureOnske, q as Correlation, r as FollowUpKind, s as FollowUpView, t as IdentityProvider, u as InnspelStorage, v as InvitationView, w as KnownIssueRef, x as KnownIssueStatus, y as PatternKind, z as Platform, B as ProgramTask, D as ProgramView, E as ReasonCode, G as ReplyView, H as StatusType, J as SubmissionStatus, L as SubmissionType, N as TaskOutcome, U as Telemetry, V as TextMaxLength } from './typer-Cf6TFjPD.cjs';
3
3
 
4
4
  /** Klienten `init` gir deg. Én per app; den er trygg å holde på. */
5
5
  interface InnspelClient {
@@ -269,6 +269,6 @@ declare function dekkerAlt(rekter: readonly MaskRect[], bilde: {
269
269
  * ikke kan lese JSON, og `test/versjon.test.ts` holder den i takt med
270
270
  * `package.json`.
271
271
  */
272
- declare const VERSJON = "0.6.0";
272
+ declare const VERSJON = "0.6.1";
273
273
 
274
274
  export { AttachmentInput, SubmissionsAttachmentMime as AttachmentMime, SubmissionsAttachmentView as AttachmentView, CaptureInput, CaptureResult, ContextInput, CommonErrorCode as ErrorCode, FlushResult, ProgramsFollowUpResponseCreate as FollowUpResponseCreate, InnspelApiError, type InnspelClient, InnspelConfigError, InnspelOptions, InnspelQueueFullError, KONTEKST_FELTER, KO_TAK, KnownIssuesKnownIssueCard as KnownIssueCard, KnownIssueQuery, type MaskPoint, type MaskRect, ProgramsMyPrograms as MyPrograms, MySubmission, OpenFeedbackOptions, ProgramsParticipationView as ParticipationView, PatternFinding, Presenter, QueuedSubmission, ResolvedSettings, SubmissionsSubmissionStatusView as SubmissionStatusView, TILLATTE_MIME, ProgramsTaskCompletionCreate as TaskCompletionCreate, ProgramsTaskCompletionView as TaskCompletionView, TelemetryEvent, VEDLEGG_GRENSER, VERSJON, dekkerAlt, init, klipp, scanText, skaler, strokTilRekter, treffer, trykkTilRekt };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedSettings, C as ContextInput, a as CaptureInput, b as CaptureResult, K as KnownIssueQuery, c as KnownIssuesKnownIssueCard, S as SubmissionsSubmissionStatusView, M as MySubmission, P as ProgramsMyPrograms, d as ProgramsParticipationView, e as ProgramsTaskCompletionCreate, f as ProgramsTaskCompletionView, g as ProgramsFollowUpResponseCreate, A as AttachmentInput, h as SubmissionsAttachmentView, Q as QueuedSubmission, F as FlushResult, i as PatternFinding, T as TelemetryEvent, O as OpenFeedbackOptions, j as Presenter, I as InnspelOptions, k as CommonErrorCode, l as SubmissionsAttachmentMime } from './typer-CK03lxOC.js';
2
- export { m as AttachmentBody, n as AttachmentOutcome, o as CaptureFeil, p as CaptureOnske, q as Correlation, r as FollowUpKind, s as FollowUpView, t as IdentityProvider, u as InnspelStorage, v as InvitationView, w as KnownIssueRef, x as KnownIssueStatus, y as PatternKind, z as Platform, B as ProgramTask, D as ProgramView, E as ReasonCode, G as ReplyView, H as StatusType, J as SubmissionStatus, L as SubmissionType, N as TaskOutcome, U as Telemetry, V as TextMaxLength } from './typer-CK03lxOC.js';
1
+ import { R as ResolvedSettings, C as ContextInput, a as CaptureInput, b as CaptureResult, K as KnownIssueQuery, c as KnownIssuesKnownIssueCard, S as SubmissionsSubmissionStatusView, M as MySubmission, P as ProgramsMyPrograms, d as ProgramsParticipationView, e as ProgramsTaskCompletionCreate, f as ProgramsTaskCompletionView, g as ProgramsFollowUpResponseCreate, A as AttachmentInput, h as SubmissionsAttachmentView, Q as QueuedSubmission, F as FlushResult, i as PatternFinding, T as TelemetryEvent, O as OpenFeedbackOptions, j as Presenter, I as InnspelOptions, k as CommonErrorCode, l as SubmissionsAttachmentMime } from './typer-Cf6TFjPD.js';
2
+ export { m as AttachmentBody, n as AttachmentOutcome, o as CaptureFeil, p as CaptureOnske, q as Correlation, r as FollowUpKind, s as FollowUpView, t as IdentityProvider, u as InnspelStorage, v as InvitationView, w as KnownIssueRef, x as KnownIssueStatus, y as PatternKind, z as Platform, B as ProgramTask, D as ProgramView, E as ReasonCode, G as ReplyView, H as StatusType, J as SubmissionStatus, L as SubmissionType, N as TaskOutcome, U as Telemetry, V as TextMaxLength } from './typer-Cf6TFjPD.js';
3
3
 
4
4
  /** Klienten `init` gir deg. Én per app; den er trygg å holde på. */
5
5
  interface InnspelClient {
@@ -269,6 +269,6 @@ declare function dekkerAlt(rekter: readonly MaskRect[], bilde: {
269
269
  * ikke kan lese JSON, og `test/versjon.test.ts` holder den i takt med
270
270
  * `package.json`.
271
271
  */
272
- declare const VERSJON = "0.6.0";
272
+ declare const VERSJON = "0.6.1";
273
273
 
274
274
  export { AttachmentInput, SubmissionsAttachmentMime as AttachmentMime, SubmissionsAttachmentView as AttachmentView, CaptureInput, CaptureResult, ContextInput, CommonErrorCode as ErrorCode, FlushResult, ProgramsFollowUpResponseCreate as FollowUpResponseCreate, InnspelApiError, type InnspelClient, InnspelConfigError, InnspelOptions, InnspelQueueFullError, KONTEKST_FELTER, KO_TAK, KnownIssuesKnownIssueCard as KnownIssueCard, KnownIssueQuery, type MaskPoint, type MaskRect, ProgramsMyPrograms as MyPrograms, MySubmission, OpenFeedbackOptions, ProgramsParticipationView as ParticipationView, PatternFinding, Presenter, QueuedSubmission, ResolvedSettings, SubmissionsSubmissionStatusView as SubmissionStatusView, TILLATTE_MIME, ProgramsTaskCompletionCreate as TaskCompletionCreate, ProgramsTaskCompletionView as TaskCompletionView, TelemetryEvent, VEDLEGG_GRENSER, VERSJON, dekkerAlt, init, klipp, scanText, skaler, strokTilRekter, treffer, trykkTilRekt };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createClient, createConfig, VERSJON, submissionsListMine, knownIssuesList2, configGet, programsCompleteTask, programsAccept, knownIssuesConfirm, submissionsCreate, attachmentsPresign, attachmentsComplete, programsRespond, programsWithdraw, programsDecline, programsListMine, submissionsStatus } from './chunk-5QZNM2ZX.js';
2
- export { VERSJON } from './chunk-5QZNM2ZX.js';
1
+ import { createClient, createConfig, VERSJON, submissionsListMine, knownIssuesList2, configGet, submissionsCreate, attachmentsPresign, attachmentsComplete, programsRespond, programsCompleteTask, programsWithdraw, programsDecline, programsAccept, programsListMine, submissionsStatus, knownIssuesConfirm } from './chunk-INOPXTQM.js';
2
+ export { VERSJON } from './chunk-INOPXTQM.js';
3
3
 
4
4
  // src/feil.ts
5
5
  var PREFIKS = "[innspel]";
@@ -28,6 +28,8 @@ var InnspelApiError = class extends Error {
28
28
  this.retryAfter = retryAfter;
29
29
  }
30
30
  };
31
+ var NettverksFeil = class extends Error {
32
+ };
31
33
  var InnspelQueueFullError = class extends Error {
32
34
  name = "InnspelQueueFullError";
33
35
  code = "queue_full";
@@ -436,12 +438,10 @@ function init(options) {
436
438
  const telemetri = options.telemetry ?? noopTelemetri;
437
439
  const k\u00F8 = new Ko(options.storage);
438
440
  const anonym = options.identityProvider === null;
439
- const klient = createClient(
440
- createConfig({
441
- baseUrl: options.baseUrl,
442
- ...options.fetch ? { fetch: options.fetch } : {}
443
- })
444
- );
441
+ const nett = ((input) => (options.fetch ?? fetch)(input).catch((e) => {
442
+ throw new NettverksFeil(String(e));
443
+ }));
444
+ const klient = createClient(createConfig({ baseUrl: options.baseUrl, fetch: nett }));
445
445
  let presenter = null;
446
446
  async function headere() {
447
447
  const h = { "X-Innspel-Tenant-Key": options.tenantKey };
@@ -449,15 +449,29 @@ function init(options) {
449
449
  if (token) h["Authorization"] = `Bearer ${token}`;
450
450
  return h;
451
451
  }
452
- function signal() {
453
- return AbortSignal.timeout(options.timeoutMs ?? STANDARD_TIMEOUT_MS);
452
+ async function medTidsgrense(kall) {
453
+ const ms = options.timeoutMs ?? STANDARD_TIMEOUT_MS;
454
+ if (typeof AbortSignal.timeout == "function") return kall(AbortSignal.timeout(ms));
455
+ const kontroll = new AbortController();
456
+ const timer = setTimeout(() => kontroll.abort(), ms);
457
+ try {
458
+ return await kall(kontroll.signal);
459
+ } finally {
460
+ clearTimeout(timer);
461
+ }
454
462
  }
455
463
  async function medToken(kall) {
456
- let res = await kall(await headere());
464
+ const fors\u00F8k = async () => {
465
+ const h = await headere();
466
+ const r = await medTidsgrense((s) => kall(h, s));
467
+ if (!r.response) throw r.error;
468
+ return r;
469
+ };
470
+ let res = await fors\u00F8k();
457
471
  if (res.response.status === 401) {
458
472
  const feil = tilApiFeil(401, res.error, res.response);
459
473
  if (feil.code === "feedback_token_expired" && !anonym) {
460
- res = await kall(await headere());
474
+ res = await fors\u00F8k();
461
475
  }
462
476
  }
463
477
  if (!res.response.ok) throw tilApiFeil(res.response.status, res.error, res.response);
@@ -496,20 +510,20 @@ function init(options) {
496
510
  }
497
511
  }
498
512
  return medToken(
499
- (h) => submissionsCreate({
513
+ (h, s) => submissionsCreate({
500
514
  client: klient,
501
515
  headers: h,
502
- signal: signal(),
516
+ signal: s,
503
517
  body
504
518
  })
505
519
  );
506
520
  }
507
521
  async function lastOppVedlegg(submissionId, vedlegg) {
508
522
  const presign = await medToken(
509
- (h) => attachmentsPresign({
523
+ (h, s) => attachmentsPresign({
510
524
  client: klient,
511
525
  headers: h,
512
- signal: signal(),
526
+ signal: s,
513
527
  body: {
514
528
  submissionId,
515
529
  mime: vedlegg.mime,
@@ -519,12 +533,12 @@ function init(options) {
519
533
  }
520
534
  })
521
535
  );
522
- await lastOppTilLagring(options.fetch ?? fetch, presign, vedlegg.body, signal());
536
+ await medTidsgrense((s) => lastOppTilLagring(nett, presign, vedlegg.body, s));
523
537
  return medToken(
524
- (h) => attachmentsComplete({
538
+ (h, s) => attachmentsComplete({
525
539
  client: klient,
526
540
  headers: h,
527
- signal: signal(),
541
+ signal: s,
528
542
  path: { id: presign.attachmentId }
529
543
  })
530
544
  );
@@ -542,7 +556,7 @@ function init(options) {
542
556
  async loadSettings() {
543
557
  try {
544
558
  const cfg = await medToken(
545
- (h) => configGet({ client: klient, headers: h, signal: signal() })
559
+ (h, s) => configGet({ client: klient, headers: h, signal: s })
546
560
  );
547
561
  if (cfg?.textMaxLength === 140 || cfg?.textMaxLength === 280) settings.textMaxLength = cfg.textMaxLength;
548
562
  if (typeof cfg?.minTextLength === "number" && cfg.minTextLength >= 1) settings.minTextLength = cfg.minTextLength;
@@ -578,6 +592,7 @@ function init(options) {
578
592
  telemetri.emit({ name: "submission_failed", reason: e.code });
579
593
  throw e;
580
594
  }
595
+ if (!(e instanceof NettverksFeil)) throw e;
581
596
  await k\u00F8.leggTil({
582
597
  clientRef,
583
598
  type: input.type,
@@ -612,10 +627,10 @@ function init(options) {
612
627
  async for(query = {}) {
613
628
  try {
614
629
  const kort = await medToken(
615
- (h) => knownIssuesList2({
630
+ (h, s) => knownIssuesList2({
616
631
  client: klient,
617
632
  headers: h,
618
- signal: signal(),
633
+ signal: s,
619
634
  query: {
620
635
  ...query.screen !== void 0 ? { screen: query.screen } : {},
621
636
  ...query.version !== void 0 ? { version: query.version } : {},
@@ -632,10 +647,10 @@ function init(options) {
632
647
  },
633
648
  async confirm(knownIssueId) {
634
649
  const res = await medToken(
635
- (h) => knownIssuesConfirm({
650
+ (h, s) => knownIssuesConfirm({
636
651
  client: klient,
637
652
  headers: h,
638
- signal: signal(),
653
+ signal: s,
639
654
  path: { id: knownIssueId },
640
655
  body: { context: kontekst }
641
656
  })
@@ -657,10 +672,10 @@ function init(options) {
657
672
  let sendte;
658
673
  try {
659
674
  sendte = await medToken(
660
- (h) => submissionsListMine({ client: klient, headers: h, signal: signal() })
675
+ (h, s) => submissionsListMine({ client: klient, headers: h, signal: s })
661
676
  );
662
677
  } catch (e) {
663
- if (e instanceof InnspelApiError) throw e;
678
+ if (!(e instanceof NettverksFeil)) throw e;
664
679
  return ventende;
665
680
  }
666
681
  telemetri.emit({ name: "status_viewed" });
@@ -669,10 +684,10 @@ function init(options) {
669
684
  async status(submissionId) {
670
685
  krevToken();
671
686
  return medToken(
672
- (h) => submissionsStatus({
687
+ (h, s) => submissionsStatus({
673
688
  client: klient,
674
689
  headers: h,
675
- signal: signal(),
690
+ signal: s,
676
691
  path: { id: submissionId }
677
692
  })
678
693
  );
@@ -682,17 +697,17 @@ function init(options) {
682
697
  async list() {
683
698
  krevToken();
684
699
  return medToken(
685
- (h) => programsListMine({ client: klient, headers: h, signal: signal() })
700
+ (h, s) => programsListMine({ client: klient, headers: h, signal: s })
686
701
  );
687
702
  },
688
703
  async accept(invitationToken) {
689
704
  krevInvitasjonstoken(invitationToken);
690
705
  krevToken();
691
706
  const svar = await medToken(
692
- (h) => programsAccept({
707
+ (h, s) => programsAccept({
693
708
  client: klient,
694
709
  headers: h,
695
- signal: signal(),
710
+ signal: s,
696
711
  path: { token: invitationToken }
697
712
  })
698
713
  );
@@ -703,10 +718,10 @@ function init(options) {
703
718
  krevInvitasjonstoken(invitationToken);
704
719
  krevToken();
705
720
  await medToken(
706
- (h) => programsDecline({
721
+ (h, s) => programsDecline({
707
722
  client: klient,
708
723
  headers: h,
709
- signal: signal(),
724
+ signal: s,
710
725
  path: { token: invitationToken }
711
726
  })
712
727
  );
@@ -718,10 +733,10 @@ function init(options) {
718
733
  }
719
734
  krevToken();
720
735
  return medToken(
721
- (h) => programsWithdraw({
736
+ (h, s) => programsWithdraw({
722
737
  client: klient,
723
738
  headers: h,
724
- signal: signal(),
739
+ signal: s,
725
740
  path: { id: participationId }
726
741
  })
727
742
  );
@@ -733,10 +748,10 @@ function init(options) {
733
748
  validerUtfall(completion);
734
749
  krevToken();
735
750
  const svar = await medToken(
736
- (h) => programsCompleteTask({
751
+ (h, s) => programsCompleteTask({
737
752
  client: klient,
738
753
  headers: h,
739
- signal: signal(),
754
+ signal: s,
740
755
  path: { id: taskId },
741
756
  body: completion
742
757
  })
@@ -751,10 +766,10 @@ function init(options) {
751
766
  validerUtfall(response);
752
767
  krevToken();
753
768
  await medToken(
754
- (h) => programsRespond({
769
+ (h, s) => programsRespond({
755
770
  client: klient,
756
771
  headers: h,
757
- signal: signal(),
772
+ signal: s,
758
773
  path: { id: followUpId },
759
774
  body: response
760
775
  })