@innspel/core 0.3.0 → 0.4.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/README.md CHANGED
@@ -97,6 +97,9 @@ innspel.knownIssues.confirm(id) // «Ja, jeg også»
97
97
  innspel.subjects.submissions() // «Mine innspill», inkl. det som venter på nett
98
98
  innspel.subjects.status(submissionId) // status for én egen innsending
99
99
  innspel.programs.list() // invitasjoner, deltakelser, oppfølginger
100
+ innspel.programs.accept(invitationToken) // ja til invitasjonen — tokenet kom i DIN kanal
101
+ innspel.programs.decline(invitationToken) // nei. Ingen årsak spørres
102
+ innspel.programs.withdraw(participationId) // «Gå ut» — umiddelbart, alltid tillatt
100
103
  innspel.attachments.upload(submissionId, attachment) // skjermbilde til en innsending som alt er lagret
101
104
  innspel.queue.pending() // det som ligger i offline-køen
102
105
  innspel.queue.flush() // sendes ellers automatisk
package/dist/index.cjs CHANGED
@@ -811,6 +811,24 @@ var configGet = (options) => (options?.client ?? client).get({
811
811
  url: "/v1/ingest/config",
812
812
  ...options
813
813
  });
814
+ var programsAccept = (options) => (options.client ?? client).post({
815
+ security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
816
+ key: "FeedbackTokenAuth",
817
+ scheme: "bearer",
818
+ type: "http"
819
+ }],
820
+ url: "/v1/ingest/invitations/{token}/accept",
821
+ ...options
822
+ });
823
+ var programsDecline = (options) => (options.client ?? client).post({
824
+ security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
825
+ key: "FeedbackTokenAuth",
826
+ scheme: "bearer",
827
+ type: "http"
828
+ }],
829
+ url: "/v1/ingest/invitations/{token}/decline",
830
+ ...options
831
+ });
814
832
  var knownIssuesList2 = (options) => (options?.client ?? client).get({
815
833
  security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
816
834
  key: "FeedbackTokenAuth",
@@ -833,6 +851,15 @@ var knownIssuesConfirm = (options) => (options.client ?? client).post({
833
851
  ...options.headers
834
852
  }
835
853
  });
854
+ var programsWithdraw = (options) => (options.client ?? client).post({
855
+ security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
856
+ key: "FeedbackTokenAuth",
857
+ scheme: "bearer",
858
+ type: "http"
859
+ }],
860
+ url: "/v1/ingest/participations/{id}/withdraw",
861
+ ...options
862
+ });
836
863
  var programsListMine = (options) => (options?.client ?? client).get({
837
864
  security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
838
865
  key: "FeedbackTokenAuth",
@@ -1219,7 +1246,7 @@ async function lastOppTilLagring(fetchImpl, presign, body, signal) {
1219
1246
  }
1220
1247
 
1221
1248
  // src/versjon.ts
1222
- var VERSJON = "0.3.0";
1249
+ var VERSJON = "0.4.0";
1223
1250
 
1224
1251
  // src/klient.ts
1225
1252
  var STANDARD_TIMEOUT_MS = 1e4;
@@ -1329,6 +1356,14 @@ function init(options) {
1329
1356
  if (!res.response.ok) throw tilApiFeil(res.response.status, res.error, res.response);
1330
1357
  return res.data;
1331
1358
  }
1359
+ function krevInvitasjonstoken(token) {
1360
+ if (typeof token !== "string" || token.length === 0) {
1361
+ throw new InnspelConfigError(
1362
+ "invitationToken",
1363
+ "mangler \u2014 det er engangs-tokenet leietakeren sendte i sin egen kanal (dyplenke, varsel eller e-post)"
1364
+ );
1365
+ }
1366
+ }
1332
1367
  function krevToken() {
1333
1368
  if (anonym) {
1334
1369
  throw new InnspelApiError(
@@ -1542,6 +1577,47 @@ function init(options) {
1542
1577
  return medToken(
1543
1578
  (h) => programsListMine({ client: klient, headers: h, signal: signal() })
1544
1579
  );
1580
+ },
1581
+ async accept(invitationToken) {
1582
+ krevInvitasjonstoken(invitationToken);
1583
+ krevToken();
1584
+ const svar = await medToken(
1585
+ (h) => programsAccept({
1586
+ client: klient,
1587
+ headers: h,
1588
+ signal: signal(),
1589
+ path: { token: invitationToken }
1590
+ })
1591
+ );
1592
+ telemetri.emit({ name: "invitation_accepted" });
1593
+ return svar;
1594
+ },
1595
+ async decline(invitationToken) {
1596
+ krevInvitasjonstoken(invitationToken);
1597
+ krevToken();
1598
+ await medToken(
1599
+ (h) => programsDecline({
1600
+ client: klient,
1601
+ headers: h,
1602
+ signal: signal(),
1603
+ path: { token: invitationToken }
1604
+ })
1605
+ );
1606
+ telemetri.emit({ name: "invitation_declined" });
1607
+ },
1608
+ async withdraw(participationId) {
1609
+ if (typeof participationId !== "string" || participationId.length === 0) {
1610
+ throw new InnspelConfigError("participationId", "mangler \u2014 bruk id fra deltakelsen i programs.list()");
1611
+ }
1612
+ krevToken();
1613
+ return medToken(
1614
+ (h) => programsWithdraw({
1615
+ client: klient,
1616
+ headers: h,
1617
+ signal: signal(),
1618
+ path: { id: participationId }
1619
+ })
1620
+ );
1545
1621
  }
1546
1622
  },
1547
1623
  attachments: {