@usenadia/node 0.1.0 → 0.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.
package/dist/index.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ // src/index.ts
2
+ import { createHmac, timingSafeEqual } from "crypto";
3
+
1
4
  // src/generated/core/bodySerializer.gen.ts
2
5
  var serializeFormDataPair = (data, key, value) => {
3
6
  if (typeof value === "string" || value instanceof Blob) {
@@ -831,11 +834,39 @@ var uploadFromUrl = (options) => (options.client ?? client).post({
831
834
  ...options.headers
832
835
  }
833
836
  });
837
+ var createUpload = (options) => (options.client ?? client).post({
838
+ security: [{ name: "Authorization", type: "apiKey" }],
839
+ url: "/public/v1/uploads",
840
+ ...options,
841
+ headers: {
842
+ "Content-Type": "application/json",
843
+ ...options.headers
844
+ }
845
+ });
846
+ var confirmUpload = (options) => (options.client ?? client).post({
847
+ security: [{ name: "Authorization", type: "apiKey" }],
848
+ url: "/public/v1/uploads/{uploadId}/confirm",
849
+ ...options
850
+ });
834
851
  var findSlot = (options) => (options.client ?? client).get({
835
852
  security: [{ name: "Authorization", type: "apiKey" }],
836
853
  url: "/public/v1/find-slot/{id}",
837
854
  ...options
838
855
  });
856
+ var getPostingTimes = (options) => (options.client ?? client).get({
857
+ security: [{ name: "Authorization", type: "apiKey" }],
858
+ url: "/public/v1/integrations/{id}/posting-times",
859
+ ...options
860
+ });
861
+ var setPostingTimes = (options) => (options.client ?? client).put({
862
+ security: [{ name: "Authorization", type: "apiKey" }],
863
+ url: "/public/v1/integrations/{id}/posting-times",
864
+ ...options,
865
+ headers: {
866
+ "Content-Type": "application/json",
867
+ ...options.headers
868
+ }
869
+ });
839
870
  var listPosts = (options) => (options.client ?? client).get({
840
871
  security: [{ name: "Authorization", type: "apiKey" }],
841
872
  url: "/public/v1/posts",
@@ -855,6 +886,11 @@ var deletePost = (options) => (options.client ?? client).delete({
855
886
  url: "/public/v1/posts/{id}",
856
887
  ...options
857
888
  });
889
+ var getPost = (options) => (options.client ?? client).get({
890
+ security: [{ name: "Authorization", type: "apiKey" }],
891
+ url: "/public/v1/posts/{id}",
892
+ ...options
893
+ });
858
894
  var deletePostGroup = (options) => (options.client ?? client).delete({
859
895
  security: [{ name: "Authorization", type: "apiKey" }],
860
896
  url: "/public/v1/posts/group/{group}",
@@ -865,6 +901,25 @@ var checkConnection = (options) => (options?.client ?? client).get({
865
901
  url: "/public/v1/is-connected",
866
902
  ...options
867
903
  });
904
+ var listWorkspaces = (options) => (options?.client ?? client).get({
905
+ security: [{ name: "Authorization", type: "apiKey" }],
906
+ url: "/public/v1/workspaces",
907
+ ...options
908
+ });
909
+ var createWorkspace = (options) => (options.client ?? client).post({
910
+ security: [{ name: "Authorization", type: "apiKey" }],
911
+ url: "/public/v1/workspaces",
912
+ ...options,
913
+ headers: {
914
+ "Content-Type": "application/json",
915
+ ...options.headers
916
+ }
917
+ });
918
+ var getSubscription = (options) => (options?.client ?? client).get({
919
+ security: [{ name: "Authorization", type: "apiKey" }],
920
+ url: "/public/v1/subscription",
921
+ ...options
922
+ });
868
923
  var listGroups = (options) => (options?.client ?? client).get({
869
924
  security: [{ name: "Authorization", type: "apiKey" }],
870
925
  url: "/public/v1/groups",
@@ -885,24 +940,6 @@ var listNotifications = (options) => (options?.client ?? client).get({
885
940
  url: "/public/v1/notifications",
886
941
  ...options
887
942
  });
888
- var generateVideo = (options) => (options.client ?? client).post({
889
- security: [{ name: "Authorization", type: "apiKey" }],
890
- url: "/public/v1/generate-video",
891
- ...options,
892
- headers: {
893
- "Content-Type": "application/json",
894
- ...options.headers
895
- }
896
- });
897
- var callVideoFunction = (options) => (options.client ?? client).post({
898
- security: [{ name: "Authorization", type: "apiKey" }],
899
- url: "/public/v1/video/function",
900
- ...options,
901
- headers: {
902
- "Content-Type": "application/json",
903
- ...options.headers
904
- }
905
- });
906
943
  var deleteChannel = (options) => (options.client ?? client).delete({
907
944
  security: [{ name: "Authorization", type: "apiKey" }],
908
945
  url: "/public/v1/integrations/{id}",
@@ -927,6 +964,25 @@ var changePostStatus = (options) => (options.client ?? client).put({
927
964
  ...options.headers
928
965
  }
929
966
  });
967
+ var removePostAutomation = (options) => (options.client ?? client).delete({
968
+ security: [{ name: "Authorization", type: "apiKey" }],
969
+ url: "/public/v1/posts/{id}/automation",
970
+ ...options
971
+ });
972
+ var getPostAutomation = (options) => (options.client ?? client).get({
973
+ security: [{ name: "Authorization", type: "apiKey" }],
974
+ url: "/public/v1/posts/{id}/automation",
975
+ ...options
976
+ });
977
+ var setPostAutomation = (options) => (options.client ?? client).put({
978
+ security: [{ name: "Authorization", type: "apiKey" }],
979
+ url: "/public/v1/posts/{id}/automation",
980
+ ...options,
981
+ headers: {
982
+ "Content-Type": "application/json",
983
+ ...options.headers
984
+ }
985
+ });
930
986
  var setPostReleaseId = (options) => (options.client ?? client).put({
931
987
  security: [{ name: "Authorization", type: "apiKey" }],
932
988
  url: "/public/v1/posts/{id}/release-id",
@@ -936,6 +992,24 @@ var setPostReleaseId = (options) => (options.client ?? client).put({
936
992
  ...options.headers
937
993
  }
938
994
  });
995
+ var setPostCover = (options) => (options.client ?? client).put({
996
+ security: [{ name: "Authorization", type: "apiKey" }],
997
+ url: "/public/v1/posts/{id}/cover",
998
+ ...options,
999
+ headers: {
1000
+ "Content-Type": "application/json",
1001
+ ...options.headers
1002
+ }
1003
+ });
1004
+ var setPostPublication = (options) => (options.client ?? client).put({
1005
+ security: [{ name: "Authorization", type: "apiKey" }],
1006
+ url: "/public/v1/posts/{id}/publication",
1007
+ ...options,
1008
+ headers: {
1009
+ "Content-Type": "application/json",
1010
+ ...options.headers
1011
+ }
1012
+ });
939
1013
  var getChannelAnalytics = (options) => (options.client ?? client).get({
940
1014
  security: [{ name: "Authorization", type: "apiKey" }],
941
1015
  url: "/public/v1/analytics/{integration}",
@@ -956,6 +1030,11 @@ var getVideoHistory = (options) => (options.client ?? client).get({
956
1030
  url: "/public/v1/video-history/{integrationId}",
957
1031
  ...options
958
1032
  });
1033
+ var getViewsPerDay = (options) => (options.client ?? client).get({
1034
+ security: [{ name: "Authorization", type: "apiKey" }],
1035
+ url: "/public/v1/views-per-day/{integrationId}",
1036
+ ...options
1037
+ });
959
1038
  var getPostAnalytics = (options) => (options.client ?? client).get({
960
1039
  security: [{ name: "Authorization", type: "apiKey" }],
961
1040
  url: "/public/v1/analytics/post/{postId}",
@@ -1111,7 +1190,7 @@ var poseAutomationFlow = (options) => (options.client ?? client).post({
1111
1190
  ...options.headers
1112
1191
  }
1113
1192
  });
1114
- var listChannelAutomationPoses = (options) => (options.client ?? client).get({
1193
+ var listChannelAutomationPoses = (options) => (options?.client ?? client).get({
1115
1194
  security: [{ name: "Authorization", type: "apiKey" }],
1116
1195
  url: "/public/v1/automation-flow-poses",
1117
1196
  ...options
@@ -1154,6 +1233,16 @@ var replayAutomationPose = (options) => (options.client ?? client).post({
1154
1233
  ...options.headers
1155
1234
  }
1156
1235
  });
1236
+ var previewAutomationPoseCatchUp = (options) => (options.client ?? client).get({
1237
+ security: [{ name: "Authorization", type: "apiKey" }],
1238
+ url: "/public/v1/automation-flow-poses/{id}/catch-up",
1239
+ ...options
1240
+ });
1241
+ var catchUpAutomationPose = (options) => (options.client ?? client).post({
1242
+ security: [{ name: "Authorization", type: "apiKey" }],
1243
+ url: "/public/v1/automation-flow-poses/{id}/catch-up",
1244
+ ...options
1245
+ });
1157
1246
  var listWebhookEvents = (options) => (options?.client ?? client).get({
1158
1247
  security: [{ name: "Authorization", type: "apiKey" }],
1159
1248
  url: "/public/v1/webhooks/events",
@@ -1183,6 +1272,15 @@ var getWebhook = (options) => (options.client ?? client).get({
1183
1272
  url: "/public/v1/webhooks/{id}",
1184
1273
  ...options
1185
1274
  });
1275
+ var testWebhook = (options) => (options.client ?? client).post({
1276
+ security: [{ name: "Authorization", type: "apiKey" }],
1277
+ url: "/public/v1/webhooks/{id}/test",
1278
+ ...options,
1279
+ headers: {
1280
+ "Content-Type": "application/json",
1281
+ ...options.headers
1282
+ }
1283
+ });
1186
1284
  var listContents = (options) => (options?.client ?? client).get({
1187
1285
  security: [{ name: "Authorization", type: "apiKey" }],
1188
1286
  url: "/public/v1/contents",
@@ -1230,6 +1328,15 @@ var upsertContent = (options) => (options.client ?? client).post({
1230
1328
  ...options.headers
1231
1329
  }
1232
1330
  });
1331
+ var createContentFromLink = (options) => (options.client ?? client).post({
1332
+ security: [{ name: "Authorization", type: "apiKey" }],
1333
+ url: "/public/v1/contents/from-link",
1334
+ ...options,
1335
+ headers: {
1336
+ "Content-Type": "application/json",
1337
+ ...options.headers
1338
+ }
1339
+ });
1233
1340
  var moveContent = (options) => (options.client ?? client).put({
1234
1341
  security: [{ name: "Authorization", type: "apiKey" }],
1235
1342
  url: "/public/v1/contents/{id}/move",
@@ -1263,24 +1370,6 @@ var listHookFamilies = (options) => (options?.client ?? client).get({
1263
1370
  url: "/public/v1/hooks/families",
1264
1371
  ...options
1265
1372
  });
1266
- var replaceHookFamilies = (options) => (options.client ?? client).put({
1267
- security: [{ name: "Authorization", type: "apiKey" }],
1268
- url: "/public/v1/hooks/families",
1269
- ...options,
1270
- headers: {
1271
- "Content-Type": "application/json",
1272
- ...options.headers
1273
- }
1274
- });
1275
- var importHooks = (options) => (options.client ?? client).post({
1276
- security: [{ name: "Authorization", type: "apiKey" }],
1277
- url: "/public/v1/hooks/import",
1278
- ...options,
1279
- headers: {
1280
- "Content-Type": "application/json",
1281
- ...options.headers
1282
- }
1283
- });
1284
1373
  var listMusic = (options) => (options?.client ?? client).get({
1285
1374
  security: [{ name: "Authorization", type: "apiKey" }],
1286
1375
  url: "/public/v1/music",
@@ -1315,6 +1404,20 @@ var uploadMusicFile = (options) => (options.client ?? client).put({
1315
1404
  ...options.headers
1316
1405
  }
1317
1406
  });
1407
+ var deleteWorkspace = (options) => (options.client ?? client).delete({
1408
+ security: [{ name: "Authorization", type: "apiKey" }],
1409
+ url: "/public/v1/workspaces/{id}",
1410
+ ...options
1411
+ });
1412
+ var updateWorkspace = (options) => (options.client ?? client).put({
1413
+ security: [{ name: "Authorization", type: "apiKey" }],
1414
+ url: "/public/v1/workspaces/{id}",
1415
+ ...options,
1416
+ headers: {
1417
+ "Content-Type": "application/json",
1418
+ ...options.headers
1419
+ }
1420
+ });
1318
1421
 
1319
1422
  // src/index.ts
1320
1423
  var DEFAULT_BASE_URL = "https://app.usenadia.com/api";
@@ -1337,22 +1440,60 @@ var NadiaError = class _NadiaError extends Error {
1337
1440
  }
1338
1441
  };
1339
1442
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
1443
+ var DIRECT_TYPES = {
1444
+ mp4: "video/mp4",
1445
+ jpg: "image/jpeg",
1446
+ jpeg: "image/jpeg",
1447
+ png: "image/png",
1448
+ webp: "image/webp",
1449
+ gif: "image/gif"
1450
+ };
1451
+ var PARALLEL_PARTS = 4;
1452
+ var PART_TRIES = 3;
1453
+ var UPLOAD_ROUNDS = 4;
1454
+ function directType(name, blobType) {
1455
+ const ext = /\.([a-z0-9]+)$/i.exec(name)?.[1]?.toLowerCase();
1456
+ if (ext && DIRECT_TYPES[ext]) return DIRECT_TYPES[ext];
1457
+ return Object.values(DIRECT_TYPES).includes(blobType) ? blobType : void 0;
1458
+ }
1459
+ var uploadContentType = (filename) => directType(filename, "");
1460
+ async function openSource(file, filename) {
1461
+ if (typeof file !== "string") {
1462
+ const own = file.name;
1463
+ return { blob: file, name: filename ?? (own || "upload") };
1464
+ }
1465
+ const fs = await import("fs");
1466
+ const { basename } = await import("path");
1467
+ const blob = typeof fs.openAsBlob === "function" ? await fs.openAsBlob(file) : new Blob([await fs.promises.readFile(file)]);
1468
+ return { blob, name: filename ?? basename(file) };
1469
+ }
1470
+ var range = (from, to) => Array.from({ length: to - from + 1 }, (_, i) => from + i);
1471
+ function missingParts(body) {
1472
+ const list = body?.missingParts;
1473
+ return Array.isArray(list) ? list.filter((n) => Number.isInteger(n) && n > 0) : [];
1474
+ }
1340
1475
  var messageOf = (body) => {
1341
- if (body && typeof body === "object" && "msg" in body) {
1342
- const msg = body.msg;
1343
- if (typeof msg === "string") return msg;
1476
+ if (!body || typeof body !== "object") return void 0;
1477
+ const { msg, message } = body;
1478
+ if (typeof msg === "string") return msg;
1479
+ if (typeof message === "string") return message;
1480
+ if (Array.isArray(message) && message.length && message.every((m) => typeof m === "string")) {
1481
+ return message.join("; ");
1344
1482
  }
1345
1483
  return void 0;
1346
1484
  };
1347
1485
  var Nadia = class {
1348
1486
  client;
1349
1487
  retries;
1488
+ /** For the bytes of an upload, which go to the upload host, not the API. */
1489
+ fetchImpl;
1350
1490
  constructor(apiKey, options = {}) {
1351
1491
  if (!apiKey) {
1352
1492
  throw new Error("An API key is required.");
1353
1493
  }
1354
1494
  const opts = typeof options === "string" ? { baseUrl: options } : options;
1355
1495
  this.retries = opts.retries ?? 2;
1496
+ this.fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
1356
1497
  this.client = client;
1357
1498
  this.client.setConfig({
1358
1499
  baseUrl: opts.baseUrl ?? DEFAULT_BASE_URL,
@@ -1398,10 +1539,68 @@ var Nadia = class {
1398
1539
  (o) => listPosts({ ...o, query })
1399
1540
  );
1400
1541
  }
1401
- /** Upload a file and get a URL usable in a post. */
1402
- upload(file, filename = "upload") {
1542
+ /**
1543
+ * Upload a file and get a URL usable in a post: a path on disk, or a
1544
+ * `Blob` / `File` with its name.
1545
+ *
1546
+ * An MP4, JPEG, PNG, WebP or GIF goes in parts of 20 MB straight to the
1547
+ * storage (`POST /public/v1/uploads`, then its confirm): four parts at a
1548
+ * time, a part cut by the network sent again, and the parts the confirm
1549
+ * says are missing sent again before confirming once more. A server that
1550
+ * does not take parts answers a single PUT, which is done instead; a
1551
+ * server without that route (older, or self-hosted on an older release)
1552
+ * and any other type (HEIC, MOV… which the server converts) go through
1553
+ * `POST /public/v1/upload`, the whole file in one request, as before.
1554
+ *
1555
+ * Resolves to the media: `id` and `path` always (what a post takes),
1556
+ * plus `size`, `duration`, `width`, `height`, `codec` when it went in
1557
+ * parts or in a single PUT.
1558
+ */
1559
+ async upload(file, filename) {
1560
+ const source = await openSource(file, filename);
1561
+ const type = directType(source.name, source.blob.type);
1562
+ if (!type) return this.uploadWhole(source);
1563
+ let opened;
1564
+ try {
1565
+ opened = await this.call(
1566
+ (o) => createUpload({
1567
+ ...o,
1568
+ body: { filename: source.name, contentType: type, size: source.blob.size }
1569
+ })
1570
+ );
1571
+ } catch (err) {
1572
+ if (err instanceof NadiaError && (err.status === 404 || err.status === 405)) {
1573
+ return this.uploadWhole(source);
1574
+ }
1575
+ throw err;
1576
+ }
1577
+ if (opened.parts) {
1578
+ await this.sendParts(opened, source.blob, range(1, opened.parts));
1579
+ } else {
1580
+ await this.sendWhole(opened, source.blob);
1581
+ }
1582
+ for (let round = 1; ; round++) {
1583
+ try {
1584
+ return await this.call(
1585
+ (o) => confirmUpload({ ...o, path: { uploadId: opened.uploadId } })
1586
+ );
1587
+ } catch (err) {
1588
+ if (!(err instanceof NadiaError) || err.status !== 409 || round >= UPLOAD_ROUNDS) throw err;
1589
+ const missing = missingParts(err.body);
1590
+ if (missing.length && opened.parts) {
1591
+ await this.sendParts(opened, source.blob, missing);
1592
+ } else if (/^CONFIRM_IN_PROGRESS/.test(err.message)) {
1593
+ await sleep(3e3);
1594
+ } else {
1595
+ throw err;
1596
+ }
1597
+ }
1598
+ }
1599
+ }
1600
+ /** The whole file in one multipart request: `POST /public/v1/upload`. */
1601
+ uploadWhole(source) {
1403
1602
  const form = new FormData();
1404
- form.append("file", file, filename);
1603
+ form.append("file", source.blob, source.name);
1405
1604
  return this.call(
1406
1605
  (o) => uploadFile({
1407
1606
  ...o,
@@ -1410,6 +1609,58 @@ var Nadia = class {
1410
1609
  })
1411
1610
  );
1412
1611
  }
1612
+ /** Each part to `<uploadUrl>/<n>`, a few at a time, each retried. */
1613
+ async sendParts(opened, blob, numbers) {
1614
+ const queue = [...numbers];
1615
+ const size = opened.partSize;
1616
+ const worker = async () => {
1617
+ for (let n = queue.shift(); n !== void 0; n = queue.shift()) {
1618
+ const from = (n - 1) * size;
1619
+ await this.put(`${opened.uploadUrl}/${n}`, blob.slice(from, Math.min(from + size, blob.size)), {
1620
+ "Content-Type": "application/octet-stream"
1621
+ }, 200);
1622
+ }
1623
+ };
1624
+ await Promise.all(Array.from({ length: Math.min(PARALLEL_PARTS, queue.length) }, worker));
1625
+ }
1626
+ /** The single PUT of a server that takes no parts. */
1627
+ sendWhole(opened, blob) {
1628
+ const headers = Object.fromEntries(
1629
+ Object.entries(opened.headers ?? {}).filter(([k]) => k.toLowerCase() !== "content-length")
1630
+ );
1631
+ return this.put(opened.uploadUrl, blob, headers, 201);
1632
+ }
1633
+ /**
1634
+ * A PUT of raw bytes, without the API key (the URL is the credential):
1635
+ * three tries on a network error, a 5xx or a 429, none on anything else.
1636
+ */
1637
+ async put(url, body, headers, ok) {
1638
+ let last;
1639
+ for (let attempt = 1; attempt <= PART_TRIES; attempt++) {
1640
+ let response;
1641
+ try {
1642
+ response = await this.fetchImpl(url, { method: "PUT", headers, body });
1643
+ } catch (err) {
1644
+ last = new NadiaError(0, err, `The upload of ${url.replace(/\/v2\/[^/]+/, "/v2/\u2026")} did not complete.`);
1645
+ }
1646
+ if (response) {
1647
+ if (response.status === ok || response.ok) {
1648
+ await response.body?.cancel();
1649
+ return;
1650
+ }
1651
+ const text = await response.text();
1652
+ let parsed = text;
1653
+ try {
1654
+ parsed = JSON.parse(text);
1655
+ } catch {
1656
+ }
1657
+ last = new NadiaError(response.status, parsed, messageOf(parsed) ?? `The upload answered ${response.status}`);
1658
+ if (!last.isTransient) throw last;
1659
+ }
1660
+ if (attempt < PART_TRIES) await sleep(attempt * 1e3);
1661
+ }
1662
+ throw last;
1663
+ }
1413
1664
  /** List your connected channels. */
1414
1665
  integrations() {
1415
1666
  return this.call((o) => listChannels(o));
@@ -1537,17 +1788,81 @@ var Nadia = class {
1537
1788
  }
1538
1789
  };
1539
1790
  var index_default = Nadia;
1791
+ var NadiaWebhookError = class _NadiaWebhookError extends Error {
1792
+ reason;
1793
+ constructor(reason, message) {
1794
+ super(message);
1795
+ this.name = "NadiaWebhookError";
1796
+ this.reason = reason;
1797
+ Object.setPrototypeOf(this, _NadiaWebhookError.prototype);
1798
+ }
1799
+ };
1800
+ function checkSignature(o) {
1801
+ const { secret, signature, timestamp, body } = o;
1802
+ if (!signature || timestamp === null || timestamp === void 0 || timestamp === "") {
1803
+ return { ok: false, reason: "missing_header", message: "X-Nadia-Signature or X-Nadia-Timestamp is missing." };
1804
+ }
1805
+ const ts = String(timestamp);
1806
+ if (o.tolerance !== void 0) {
1807
+ const seconds = Number(ts);
1808
+ const now = (o.now ?? Date.now()) / 1e3;
1809
+ if (!Number.isFinite(seconds) || Math.abs(now - seconds) > o.tolerance) {
1810
+ return { ok: false, reason: "stale", message: `Timestamp outside the ${o.tolerance}s tolerance.` };
1811
+ }
1812
+ }
1813
+ const expected = Buffer.from(
1814
+ "sha256=" + createHmac("sha256", secret).update(`${ts}.`).update(body).digest("hex")
1815
+ );
1816
+ const received = Buffer.from(signature);
1817
+ if (received.length !== expected.length || !timingSafeEqual(received, expected)) {
1818
+ return { ok: false, reason: "bad_signature", message: "Signature does not match." };
1819
+ }
1820
+ return { ok: true };
1821
+ }
1822
+ function verifyWebhookSignature(options) {
1823
+ return checkSignature(options).ok;
1824
+ }
1825
+ function parseWebhook(options) {
1826
+ const header = (name) => {
1827
+ const h = options.headers;
1828
+ if (typeof h.get === "function") return h.get(name) ?? void 0;
1829
+ const record = h;
1830
+ const key = Object.keys(record).find((k) => k.toLowerCase() === name.toLowerCase());
1831
+ const value = key === void 0 ? void 0 : record[key];
1832
+ return Array.isArray(value) ? value[0] : value;
1833
+ };
1834
+ const check = checkSignature({
1835
+ secret: options.secret,
1836
+ signature: header("X-Nadia-Signature"),
1837
+ timestamp: header("X-Nadia-Timestamp"),
1838
+ body: options.body,
1839
+ tolerance: options.tolerance ?? 300,
1840
+ now: options.now
1841
+ });
1842
+ if (!check.ok) throw new NadiaWebhookError(check.reason, check.message);
1843
+ try {
1844
+ const text = typeof options.body === "string" ? options.body : new TextDecoder().decode(options.body);
1845
+ return JSON.parse(text);
1846
+ } catch {
1847
+ throw new NadiaWebhookError("bad_body", "The body is not JSON.");
1848
+ }
1849
+ }
1540
1850
  export {
1541
1851
  DEFAULT_BASE_URL,
1542
1852
  Nadia,
1543
1853
  NadiaError,
1544
- callVideoFunction,
1854
+ NadiaWebhookError,
1855
+ catchUpAutomationPose,
1545
1856
  changePostStatus,
1546
1857
  checkConnection,
1858
+ confirmUpload,
1547
1859
  createAutomationFlow,
1548
1860
  createContent,
1861
+ createContentFromLink,
1549
1862
  createPost,
1863
+ createUpload,
1550
1864
  createWebhook,
1865
+ createWorkspace,
1551
1866
  index_default as default,
1552
1867
  deleteAutomationFlow,
1553
1868
  deleteAutomationPose,
@@ -1557,8 +1872,8 @@ export {
1557
1872
  deletePost,
1558
1873
  deletePostGroup,
1559
1874
  deleteWebhook,
1875
+ deleteWorkspace,
1560
1876
  findSlot,
1561
- generateVideo,
1562
1877
  getAccountHistory,
1563
1878
  getAutomationFlow,
1564
1879
  getAutomationPose,
@@ -1569,11 +1884,15 @@ export {
1569
1884
  getConversation,
1570
1885
  getHookForms,
1571
1886
  getMusicTrack,
1887
+ getPost,
1572
1888
  getPostAnalytics,
1889
+ getPostAutomation,
1890
+ getPostingTimes,
1891
+ getSubscription,
1573
1892
  getVideoHistory,
1893
+ getViewsPerDay,
1574
1894
  getWebhook,
1575
1895
  hideComment,
1576
- importHooks,
1577
1896
  importMusic,
1578
1897
  linkContentPost,
1579
1898
  listAutomationFlowPoses,
@@ -1596,12 +1915,15 @@ export {
1596
1915
  listVideoPerformance,
1597
1916
  listWebhookEvents,
1598
1917
  listWebhooks,
1918
+ listWorkspaces,
1599
1919
  moveContent,
1920
+ parseWebhook,
1600
1921
  pollAutomationPose,
1601
1922
  pollInbox,
1602
1923
  poseAutomationFlow,
1603
1924
  previewAutomationEmail,
1604
- replaceHookFamilies,
1925
+ previewAutomationPoseCatchUp,
1926
+ removePostAutomation,
1605
1927
  replayAutomationPose,
1606
1928
  replyToComment,
1607
1929
  runChannelTool,
@@ -1609,15 +1931,23 @@ export {
1609
1931
  sendAutomationTestEmail,
1610
1932
  sendDirectMessage,
1611
1933
  setAutomationFlowStatus,
1934
+ setPostAutomation,
1935
+ setPostCover,
1936
+ setPostPublication,
1612
1937
  setPostReleaseId,
1938
+ setPostingTimes,
1613
1939
  startChannelConnection,
1614
1940
  subscribeInboxWebhook,
1941
+ testWebhook,
1615
1942
  updateAutomationFlow,
1616
1943
  updateAutomationPose,
1617
1944
  updateContent,
1945
+ updateWorkspace,
1946
+ uploadContentType,
1618
1947
  uploadFile,
1619
1948
  uploadFromUrl,
1620
1949
  uploadMusicFile,
1621
- upsertContent
1950
+ upsertContent,
1951
+ verifyWebhookSignature
1622
1952
  };
1623
1953
  //# sourceMappingURL=index.mjs.map