@madewithremy/admin 0.1.30 → 0.1.31
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.ts +351 -13
- package/dist/index.js +92 -3
- package/dist/index.js.map +1 -1
- package/dist/prod.js +566 -77
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -404,11 +404,15 @@ __export(dataSources_exports, {
|
|
|
404
404
|
count: () => count,
|
|
405
405
|
create: () => create,
|
|
406
406
|
deleteSource: () => deleteSource,
|
|
407
|
+
dictionary: () => dictionary,
|
|
407
408
|
documents: () => documents,
|
|
408
409
|
drop: () => drop,
|
|
410
|
+
entities: () => entities,
|
|
411
|
+
link: () => link,
|
|
409
412
|
list: () => list4,
|
|
410
413
|
move: () => move,
|
|
411
414
|
promote: () => promote,
|
|
415
|
+
pushDictionary: () => pushDictionary,
|
|
412
416
|
revectorize: () => revectorize,
|
|
413
417
|
rm: () => rm,
|
|
414
418
|
rmWhere: () => rmWhere,
|
|
@@ -546,7 +550,7 @@ var summarize = (d) => ({
|
|
|
546
550
|
...d.errorMessage ? { error: d.errorMessage } : {}
|
|
547
551
|
});
|
|
548
552
|
async function addDocument(ctx, params) {
|
|
549
|
-
const { slug, filename, content, metadata, onProgress } = params;
|
|
553
|
+
const { slug, filename, content, metadata, entities: entities2, onProgress } = params;
|
|
550
554
|
const contentHash = createHash("sha256").update(content).digest("hex");
|
|
551
555
|
const token = await call(
|
|
552
556
|
ctx,
|
|
@@ -556,7 +560,8 @@ async function addDocument(ctx, params) {
|
|
|
556
560
|
slug,
|
|
557
561
|
filename,
|
|
558
562
|
contentHash,
|
|
559
|
-
...metadata ? { metadata } : {}
|
|
563
|
+
...metadata ? { metadata } : {},
|
|
564
|
+
...entities2 ? { entities: entities2 } : {}
|
|
560
565
|
}
|
|
561
566
|
);
|
|
562
567
|
if (token.alreadyCurrent) {
|
|
@@ -582,7 +587,8 @@ async function addDocument(ctx, params) {
|
|
|
582
587
|
contentHash,
|
|
583
588
|
contentType: token.contentType,
|
|
584
589
|
size: content.length,
|
|
585
|
-
...metadata ? { metadata } : {}
|
|
590
|
+
...metadata ? { metadata } : {},
|
|
591
|
+
...entities2 ? { entities: entities2 } : {}
|
|
586
592
|
}
|
|
587
593
|
);
|
|
588
594
|
return {
|
|
@@ -759,6 +765,20 @@ function count(ctx, params) {
|
|
|
759
765
|
...candidate ? { candidate: true } : {}
|
|
760
766
|
});
|
|
761
767
|
}
|
|
768
|
+
function entities(ctx, params) {
|
|
769
|
+
const { slug, filter, limit, candidate } = params;
|
|
770
|
+
return call(
|
|
771
|
+
ctx,
|
|
772
|
+
"POST",
|
|
773
|
+
`${base(ctx.appId)}/entities`,
|
|
774
|
+
{
|
|
775
|
+
slug,
|
|
776
|
+
...filter ? { filter } : {},
|
|
777
|
+
...limit !== void 0 ? { limit } : {},
|
|
778
|
+
...candidate ? { candidate: true } : {}
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
}
|
|
762
782
|
function configGet(ctx, slug) {
|
|
763
783
|
return call(
|
|
764
784
|
ctx,
|
|
@@ -920,6 +940,67 @@ function deleteSource(ctx, slug) {
|
|
|
920
940
|
{ slug }
|
|
921
941
|
);
|
|
922
942
|
}
|
|
943
|
+
var DICTIONARY_PAGE_ENTRIES = 1e4;
|
|
944
|
+
var DICTIONARY_PAGE_BYTES = 4e6;
|
|
945
|
+
async function pushDictionary(ctx, params) {
|
|
946
|
+
const { slug, entries } = params;
|
|
947
|
+
const stage = await call(
|
|
948
|
+
ctx,
|
|
949
|
+
"POST",
|
|
950
|
+
`${base(ctx.appId)}/dictionary/stage`,
|
|
951
|
+
{
|
|
952
|
+
slug,
|
|
953
|
+
...params.linkerVersion !== void 0 ? { linkerVersion: params.linkerVersion } : {}
|
|
954
|
+
}
|
|
955
|
+
);
|
|
956
|
+
const perPage = Math.min(
|
|
957
|
+
DICTIONARY_PAGE_ENTRIES,
|
|
958
|
+
stage.pageMaxEntries || DICTIONARY_PAGE_ENTRIES
|
|
959
|
+
);
|
|
960
|
+
let pages2 = 0;
|
|
961
|
+
let start2 = 0;
|
|
962
|
+
while (start2 < entries.length) {
|
|
963
|
+
let end = start2;
|
|
964
|
+
let bytes = 0;
|
|
965
|
+
while (end < entries.length && end - start2 < perPage) {
|
|
966
|
+
const size = JSON.stringify(entries[end]).length;
|
|
967
|
+
if (end > start2 && bytes + size > DICTIONARY_PAGE_BYTES) {
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
bytes += size;
|
|
971
|
+
end += 1;
|
|
972
|
+
}
|
|
973
|
+
await call(ctx, "POST", `${base(ctx.appId)}/dictionary/page`, {
|
|
974
|
+
slug,
|
|
975
|
+
stageId: stage.stageId,
|
|
976
|
+
page: pages2,
|
|
977
|
+
entries: entries.slice(start2, end)
|
|
978
|
+
});
|
|
979
|
+
pages2 += 1;
|
|
980
|
+
start2 = end;
|
|
981
|
+
params.onProgress?.(start2, entries.length);
|
|
982
|
+
}
|
|
983
|
+
return call(
|
|
984
|
+
ctx,
|
|
985
|
+
"POST",
|
|
986
|
+
`${base(ctx.appId)}/dictionary/commit`,
|
|
987
|
+
{ slug, stageId: stage.stageId, pages: pages2 }
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
function dictionary(ctx, params) {
|
|
991
|
+
return call(
|
|
992
|
+
ctx,
|
|
993
|
+
"POST",
|
|
994
|
+
`${base(ctx.appId)}/dictionary`,
|
|
995
|
+
{ slug: params.slug }
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
function link(ctx, params) {
|
|
999
|
+
return call(ctx, "POST", `${base(ctx.appId)}/link`, {
|
|
1000
|
+
slug: params.slug,
|
|
1001
|
+
text: params.text
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
923
1004
|
|
|
924
1005
|
// src/ops/dataSourceJobs.ts
|
|
925
1006
|
var dataSourceJobs_exports = {};
|
|
@@ -1475,6 +1556,7 @@ function quarantine(ctx, params) {
|
|
|
1475
1556
|
"GET",
|
|
1476
1557
|
`${base5(ctx.appId)}/jobs/${params.id}/quarantine${qs({
|
|
1477
1558
|
...params.kind ? { kind: params.kind } : {},
|
|
1559
|
+
...params.stage ? { stage: params.stage } : {},
|
|
1478
1560
|
...params.reason ? { reason: params.reason } : {},
|
|
1479
1561
|
...params.cursor ? { cursor: params.cursor } : {},
|
|
1480
1562
|
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
@@ -1567,6 +1649,13 @@ function summarizeRelease(release) {
|
|
|
1567
1649
|
publishedAt: release.publishedAt ?? null,
|
|
1568
1650
|
...release.previewUrl ? { previewUrl: release.previewUrl } : {}
|
|
1569
1651
|
};
|
|
1652
|
+
const readers = (release.dataSources ?? []).filter((d) => d.reader);
|
|
1653
|
+
if (readers.length > 0 && release.status === "live") {
|
|
1654
|
+
summary2.readers = readers.map((d) => ({
|
|
1655
|
+
slug: d.slug,
|
|
1656
|
+
unread: d.readerUnread ?? 0
|
|
1657
|
+
}));
|
|
1658
|
+
}
|
|
1570
1659
|
if (release.status !== "failed") {
|
|
1571
1660
|
return summary2;
|
|
1572
1661
|
}
|