@innspel/core 0.4.0 → 0.5.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/dist/index.cjs +72 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +72 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -811,6 +811,19 @@ var configGet = (options) => (options?.client ?? client).get({
|
|
|
811
811
|
url: "/v1/ingest/config",
|
|
812
812
|
...options
|
|
813
813
|
});
|
|
814
|
+
var programsRespond = (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/follow-ups/{id}/respond",
|
|
821
|
+
...options,
|
|
822
|
+
headers: {
|
|
823
|
+
"Content-Type": "application/json",
|
|
824
|
+
...options.headers
|
|
825
|
+
}
|
|
826
|
+
});
|
|
814
827
|
var programsAccept = (options) => (options.client ?? client).post({
|
|
815
828
|
security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
|
|
816
829
|
key: "FeedbackTokenAuth",
|
|
@@ -900,6 +913,19 @@ var submissionsStatus = (options) => (options.client ?? client).get({
|
|
|
900
913
|
url: "/v1/ingest/submissions/{id}/status",
|
|
901
914
|
...options
|
|
902
915
|
});
|
|
916
|
+
var programsCompleteTask = (options) => (options.client ?? client).post({
|
|
917
|
+
security: [{ name: "X-Innspel-Tenant-Key", type: "apiKey" }, {
|
|
918
|
+
key: "FeedbackTokenAuth",
|
|
919
|
+
scheme: "bearer",
|
|
920
|
+
type: "http"
|
|
921
|
+
}],
|
|
922
|
+
url: "/v1/ingest/tasks/{id}/complete",
|
|
923
|
+
...options,
|
|
924
|
+
headers: {
|
|
925
|
+
"Content-Type": "application/json",
|
|
926
|
+
...options.headers
|
|
927
|
+
}
|
|
928
|
+
});
|
|
903
929
|
|
|
904
930
|
// src/feil.ts
|
|
905
931
|
var PREFIKS = "[innspel]";
|
|
@@ -1246,11 +1272,21 @@ async function lastOppTilLagring(fetchImpl, presign, body, signal) {
|
|
|
1246
1272
|
}
|
|
1247
1273
|
|
|
1248
1274
|
// src/versjon.ts
|
|
1249
|
-
var VERSJON = "0.
|
|
1275
|
+
var VERSJON = "0.5.0";
|
|
1250
1276
|
|
|
1251
1277
|
// src/klient.ts
|
|
1252
1278
|
var STANDARD_TIMEOUT_MS = 1e4;
|
|
1253
1279
|
var noopTelemetri = { emit: () => void 0 };
|
|
1280
|
+
var UTFALL = ["fungerte", "delvis", "ikke"];
|
|
1281
|
+
var SETNING_MAKS = 140;
|
|
1282
|
+
function validerUtfall(input) {
|
|
1283
|
+
if (!UTFALL.includes(input.outcome)) {
|
|
1284
|
+
throw new InnspelConfigError("outcome", `m\xE5 v\xE6re ett av ${UTFALL.join(" \xB7 ")}`);
|
|
1285
|
+
}
|
|
1286
|
+
if (input.text !== void 0 && (typeof input.text !== "string" || input.text.length > SETNING_MAKS)) {
|
|
1287
|
+
throw new InnspelConfigError("text", `er valgfri, men aldri lengre enn ${SETNING_MAKS} tegn`);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1254
1290
|
function krev(betingelse, felt, hva) {
|
|
1255
1291
|
if (!betingelse) throw new InnspelConfigError(felt, hva);
|
|
1256
1292
|
}
|
|
@@ -1618,6 +1654,41 @@ function init(options) {
|
|
|
1618
1654
|
path: { id: participationId }
|
|
1619
1655
|
})
|
|
1620
1656
|
);
|
|
1657
|
+
},
|
|
1658
|
+
async completeTask(taskId, completion) {
|
|
1659
|
+
if (typeof taskId !== "string" || taskId.length === 0) {
|
|
1660
|
+
throw new InnspelConfigError("taskId", "mangler \u2014 bruk id fra program.tasks i programs.list()");
|
|
1661
|
+
}
|
|
1662
|
+
validerUtfall(completion);
|
|
1663
|
+
krevToken();
|
|
1664
|
+
const svar = await medToken(
|
|
1665
|
+
(h) => programsCompleteTask({
|
|
1666
|
+
client: klient,
|
|
1667
|
+
headers: h,
|
|
1668
|
+
signal: signal(),
|
|
1669
|
+
path: { id: taskId },
|
|
1670
|
+
body: completion
|
|
1671
|
+
})
|
|
1672
|
+
);
|
|
1673
|
+
telemetri.emit({ name: "task_completed", outcome: completion.outcome });
|
|
1674
|
+
return svar;
|
|
1675
|
+
},
|
|
1676
|
+
async respond(followUpId, response) {
|
|
1677
|
+
if (typeof followUpId !== "string" || followUpId.length === 0) {
|
|
1678
|
+
throw new InnspelConfigError("followUpId", "mangler \u2014 bruk id fra pendingFollowUps i programs.list()");
|
|
1679
|
+
}
|
|
1680
|
+
validerUtfall(response);
|
|
1681
|
+
krevToken();
|
|
1682
|
+
await medToken(
|
|
1683
|
+
(h) => programsRespond({
|
|
1684
|
+
client: klient,
|
|
1685
|
+
headers: h,
|
|
1686
|
+
signal: signal(),
|
|
1687
|
+
path: { id: followUpId },
|
|
1688
|
+
body: response
|
|
1689
|
+
})
|
|
1690
|
+
);
|
|
1691
|
+
telemetri.emit({ name: "followup_answered" });
|
|
1621
1692
|
}
|
|
1622
1693
|
},
|
|
1623
1694
|
attachments: {
|