@usenadia/node 0.1.1 → 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/README.md +20 -4
- package/dist/index.d.mts +1983 -361
- package/dist/index.d.ts +1983 -361
- package/dist/index.js +326 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +296 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -834,11 +834,39 @@ var uploadFromUrl = (options) => (options.client ?? client).post({
|
|
|
834
834
|
...options.headers
|
|
835
835
|
}
|
|
836
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
|
+
});
|
|
837
851
|
var findSlot = (options) => (options.client ?? client).get({
|
|
838
852
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
839
853
|
url: "/public/v1/find-slot/{id}",
|
|
840
854
|
...options
|
|
841
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
|
+
});
|
|
842
870
|
var listPosts = (options) => (options.client ?? client).get({
|
|
843
871
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
844
872
|
url: "/public/v1/posts",
|
|
@@ -858,6 +886,11 @@ var deletePost = (options) => (options.client ?? client).delete({
|
|
|
858
886
|
url: "/public/v1/posts/{id}",
|
|
859
887
|
...options
|
|
860
888
|
});
|
|
889
|
+
var getPost = (options) => (options.client ?? client).get({
|
|
890
|
+
security: [{ name: "Authorization", type: "apiKey" }],
|
|
891
|
+
url: "/public/v1/posts/{id}",
|
|
892
|
+
...options
|
|
893
|
+
});
|
|
861
894
|
var deletePostGroup = (options) => (options.client ?? client).delete({
|
|
862
895
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
863
896
|
url: "/public/v1/posts/group/{group}",
|
|
@@ -868,6 +901,25 @@ var checkConnection = (options) => (options?.client ?? client).get({
|
|
|
868
901
|
url: "/public/v1/is-connected",
|
|
869
902
|
...options
|
|
870
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
|
+
});
|
|
871
923
|
var listGroups = (options) => (options?.client ?? client).get({
|
|
872
924
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
873
925
|
url: "/public/v1/groups",
|
|
@@ -888,24 +940,6 @@ var listNotifications = (options) => (options?.client ?? client).get({
|
|
|
888
940
|
url: "/public/v1/notifications",
|
|
889
941
|
...options
|
|
890
942
|
});
|
|
891
|
-
var generateVideo = (options) => (options.client ?? client).post({
|
|
892
|
-
security: [{ name: "Authorization", type: "apiKey" }],
|
|
893
|
-
url: "/public/v1/generate-video",
|
|
894
|
-
...options,
|
|
895
|
-
headers: {
|
|
896
|
-
"Content-Type": "application/json",
|
|
897
|
-
...options.headers
|
|
898
|
-
}
|
|
899
|
-
});
|
|
900
|
-
var callVideoFunction = (options) => (options.client ?? client).post({
|
|
901
|
-
security: [{ name: "Authorization", type: "apiKey" }],
|
|
902
|
-
url: "/public/v1/video/function",
|
|
903
|
-
...options,
|
|
904
|
-
headers: {
|
|
905
|
-
"Content-Type": "application/json",
|
|
906
|
-
...options.headers
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
943
|
var deleteChannel = (options) => (options.client ?? client).delete({
|
|
910
944
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
911
945
|
url: "/public/v1/integrations/{id}",
|
|
@@ -930,6 +964,25 @@ var changePostStatus = (options) => (options.client ?? client).put({
|
|
|
930
964
|
...options.headers
|
|
931
965
|
}
|
|
932
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
|
+
});
|
|
933
986
|
var setPostReleaseId = (options) => (options.client ?? client).put({
|
|
934
987
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
935
988
|
url: "/public/v1/posts/{id}/release-id",
|
|
@@ -939,6 +992,24 @@ var setPostReleaseId = (options) => (options.client ?? client).put({
|
|
|
939
992
|
...options.headers
|
|
940
993
|
}
|
|
941
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
|
+
});
|
|
942
1013
|
var getChannelAnalytics = (options) => (options.client ?? client).get({
|
|
943
1014
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
944
1015
|
url: "/public/v1/analytics/{integration}",
|
|
@@ -959,6 +1030,11 @@ var getVideoHistory = (options) => (options.client ?? client).get({
|
|
|
959
1030
|
url: "/public/v1/video-history/{integrationId}",
|
|
960
1031
|
...options
|
|
961
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
|
+
});
|
|
962
1038
|
var getPostAnalytics = (options) => (options.client ?? client).get({
|
|
963
1039
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
964
1040
|
url: "/public/v1/analytics/post/{postId}",
|
|
@@ -1114,7 +1190,7 @@ var poseAutomationFlow = (options) => (options.client ?? client).post({
|
|
|
1114
1190
|
...options.headers
|
|
1115
1191
|
}
|
|
1116
1192
|
});
|
|
1117
|
-
var listChannelAutomationPoses = (options) => (options
|
|
1193
|
+
var listChannelAutomationPoses = (options) => (options?.client ?? client).get({
|
|
1118
1194
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1119
1195
|
url: "/public/v1/automation-flow-poses",
|
|
1120
1196
|
...options
|
|
@@ -1157,6 +1233,16 @@ var replayAutomationPose = (options) => (options.client ?? client).post({
|
|
|
1157
1233
|
...options.headers
|
|
1158
1234
|
}
|
|
1159
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
|
+
});
|
|
1160
1246
|
var listWebhookEvents = (options) => (options?.client ?? client).get({
|
|
1161
1247
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1162
1248
|
url: "/public/v1/webhooks/events",
|
|
@@ -1242,6 +1328,15 @@ var upsertContent = (options) => (options.client ?? client).post({
|
|
|
1242
1328
|
...options.headers
|
|
1243
1329
|
}
|
|
1244
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
|
+
});
|
|
1245
1340
|
var moveContent = (options) => (options.client ?? client).put({
|
|
1246
1341
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1247
1342
|
url: "/public/v1/contents/{id}/move",
|
|
@@ -1275,24 +1370,6 @@ var listHookFamilies = (options) => (options?.client ?? client).get({
|
|
|
1275
1370
|
url: "/public/v1/hooks/families",
|
|
1276
1371
|
...options
|
|
1277
1372
|
});
|
|
1278
|
-
var replaceHookFamilies = (options) => (options.client ?? client).put({
|
|
1279
|
-
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1280
|
-
url: "/public/v1/hooks/families",
|
|
1281
|
-
...options,
|
|
1282
|
-
headers: {
|
|
1283
|
-
"Content-Type": "application/json",
|
|
1284
|
-
...options.headers
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1287
|
-
var importHooks = (options) => (options.client ?? client).post({
|
|
1288
|
-
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1289
|
-
url: "/public/v1/hooks/import",
|
|
1290
|
-
...options,
|
|
1291
|
-
headers: {
|
|
1292
|
-
"Content-Type": "application/json",
|
|
1293
|
-
...options.headers
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
1373
|
var listMusic = (options) => (options?.client ?? client).get({
|
|
1297
1374
|
security: [{ name: "Authorization", type: "apiKey" }],
|
|
1298
1375
|
url: "/public/v1/music",
|
|
@@ -1327,6 +1404,20 @@ var uploadMusicFile = (options) => (options.client ?? client).put({
|
|
|
1327
1404
|
...options.headers
|
|
1328
1405
|
}
|
|
1329
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
|
+
});
|
|
1330
1421
|
|
|
1331
1422
|
// src/index.ts
|
|
1332
1423
|
var DEFAULT_BASE_URL = "https://app.usenadia.com/api";
|
|
@@ -1349,6 +1440,38 @@ var NadiaError = class _NadiaError extends Error {
|
|
|
1349
1440
|
}
|
|
1350
1441
|
};
|
|
1351
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
|
+
}
|
|
1352
1475
|
var messageOf = (body) => {
|
|
1353
1476
|
if (!body || typeof body !== "object") return void 0;
|
|
1354
1477
|
const { msg, message } = body;
|
|
@@ -1362,12 +1485,15 @@ var messageOf = (body) => {
|
|
|
1362
1485
|
var Nadia = class {
|
|
1363
1486
|
client;
|
|
1364
1487
|
retries;
|
|
1488
|
+
/** For the bytes of an upload, which go to the upload host, not the API. */
|
|
1489
|
+
fetchImpl;
|
|
1365
1490
|
constructor(apiKey, options = {}) {
|
|
1366
1491
|
if (!apiKey) {
|
|
1367
1492
|
throw new Error("An API key is required.");
|
|
1368
1493
|
}
|
|
1369
1494
|
const opts = typeof options === "string" ? { baseUrl: options } : options;
|
|
1370
1495
|
this.retries = opts.retries ?? 2;
|
|
1496
|
+
this.fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
|
|
1371
1497
|
this.client = client;
|
|
1372
1498
|
this.client.setConfig({
|
|
1373
1499
|
baseUrl: opts.baseUrl ?? DEFAULT_BASE_URL,
|
|
@@ -1413,10 +1539,68 @@ var Nadia = class {
|
|
|
1413
1539
|
(o) => listPosts({ ...o, query })
|
|
1414
1540
|
);
|
|
1415
1541
|
}
|
|
1416
|
-
/**
|
|
1417
|
-
|
|
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) {
|
|
1418
1602
|
const form = new FormData();
|
|
1419
|
-
form.append("file",
|
|
1603
|
+
form.append("file", source.blob, source.name);
|
|
1420
1604
|
return this.call(
|
|
1421
1605
|
(o) => uploadFile({
|
|
1422
1606
|
...o,
|
|
@@ -1425,6 +1609,58 @@ var Nadia = class {
|
|
|
1425
1609
|
})
|
|
1426
1610
|
);
|
|
1427
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
|
+
}
|
|
1428
1664
|
/** List your connected channels. */
|
|
1429
1665
|
integrations() {
|
|
1430
1666
|
return this.call((o) => listChannels(o));
|
|
@@ -1616,13 +1852,17 @@ export {
|
|
|
1616
1852
|
Nadia,
|
|
1617
1853
|
NadiaError,
|
|
1618
1854
|
NadiaWebhookError,
|
|
1619
|
-
|
|
1855
|
+
catchUpAutomationPose,
|
|
1620
1856
|
changePostStatus,
|
|
1621
1857
|
checkConnection,
|
|
1858
|
+
confirmUpload,
|
|
1622
1859
|
createAutomationFlow,
|
|
1623
1860
|
createContent,
|
|
1861
|
+
createContentFromLink,
|
|
1624
1862
|
createPost,
|
|
1863
|
+
createUpload,
|
|
1625
1864
|
createWebhook,
|
|
1865
|
+
createWorkspace,
|
|
1626
1866
|
index_default as default,
|
|
1627
1867
|
deleteAutomationFlow,
|
|
1628
1868
|
deleteAutomationPose,
|
|
@@ -1632,8 +1872,8 @@ export {
|
|
|
1632
1872
|
deletePost,
|
|
1633
1873
|
deletePostGroup,
|
|
1634
1874
|
deleteWebhook,
|
|
1875
|
+
deleteWorkspace,
|
|
1635
1876
|
findSlot,
|
|
1636
|
-
generateVideo,
|
|
1637
1877
|
getAccountHistory,
|
|
1638
1878
|
getAutomationFlow,
|
|
1639
1879
|
getAutomationPose,
|
|
@@ -1644,11 +1884,15 @@ export {
|
|
|
1644
1884
|
getConversation,
|
|
1645
1885
|
getHookForms,
|
|
1646
1886
|
getMusicTrack,
|
|
1887
|
+
getPost,
|
|
1647
1888
|
getPostAnalytics,
|
|
1889
|
+
getPostAutomation,
|
|
1890
|
+
getPostingTimes,
|
|
1891
|
+
getSubscription,
|
|
1648
1892
|
getVideoHistory,
|
|
1893
|
+
getViewsPerDay,
|
|
1649
1894
|
getWebhook,
|
|
1650
1895
|
hideComment,
|
|
1651
|
-
importHooks,
|
|
1652
1896
|
importMusic,
|
|
1653
1897
|
linkContentPost,
|
|
1654
1898
|
listAutomationFlowPoses,
|
|
@@ -1671,13 +1915,15 @@ export {
|
|
|
1671
1915
|
listVideoPerformance,
|
|
1672
1916
|
listWebhookEvents,
|
|
1673
1917
|
listWebhooks,
|
|
1918
|
+
listWorkspaces,
|
|
1674
1919
|
moveContent,
|
|
1675
1920
|
parseWebhook,
|
|
1676
1921
|
pollAutomationPose,
|
|
1677
1922
|
pollInbox,
|
|
1678
1923
|
poseAutomationFlow,
|
|
1679
1924
|
previewAutomationEmail,
|
|
1680
|
-
|
|
1925
|
+
previewAutomationPoseCatchUp,
|
|
1926
|
+
removePostAutomation,
|
|
1681
1927
|
replayAutomationPose,
|
|
1682
1928
|
replyToComment,
|
|
1683
1929
|
runChannelTool,
|
|
@@ -1685,13 +1931,19 @@ export {
|
|
|
1685
1931
|
sendAutomationTestEmail,
|
|
1686
1932
|
sendDirectMessage,
|
|
1687
1933
|
setAutomationFlowStatus,
|
|
1934
|
+
setPostAutomation,
|
|
1935
|
+
setPostCover,
|
|
1936
|
+
setPostPublication,
|
|
1688
1937
|
setPostReleaseId,
|
|
1938
|
+
setPostingTimes,
|
|
1689
1939
|
startChannelConnection,
|
|
1690
1940
|
subscribeInboxWebhook,
|
|
1691
1941
|
testWebhook,
|
|
1692
1942
|
updateAutomationFlow,
|
|
1693
1943
|
updateAutomationPose,
|
|
1694
1944
|
updateContent,
|
|
1945
|
+
updateWorkspace,
|
|
1946
|
+
uploadContentType,
|
|
1695
1947
|
uploadFile,
|
|
1696
1948
|
uploadFromUrl,
|
|
1697
1949
|
uploadMusicFile,
|