@madewithremy/admin 0.1.30 → 0.1.32
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 +410 -25
- package/dist/index.js +110 -4
- package/dist/index.js.map +1 -1
- package/dist/prod.js +754 -118
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -404,11 +404,16 @@ __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,
|
|
414
|
+
passages: () => passages,
|
|
411
415
|
promote: () => promote,
|
|
416
|
+
pushDictionary: () => pushDictionary,
|
|
412
417
|
revectorize: () => revectorize,
|
|
413
418
|
rm: () => rm,
|
|
414
419
|
rmWhere: () => rmWhere,
|
|
@@ -546,7 +551,7 @@ var summarize = (d) => ({
|
|
|
546
551
|
...d.errorMessage ? { error: d.errorMessage } : {}
|
|
547
552
|
});
|
|
548
553
|
async function addDocument(ctx, params) {
|
|
549
|
-
const { slug, filename, content, metadata, onProgress } = params;
|
|
554
|
+
const { slug, filename, content, metadata, entities: entities2, onProgress } = params;
|
|
550
555
|
const contentHash = createHash("sha256").update(content).digest("hex");
|
|
551
556
|
const token = await call(
|
|
552
557
|
ctx,
|
|
@@ -556,7 +561,8 @@ async function addDocument(ctx, params) {
|
|
|
556
561
|
slug,
|
|
557
562
|
filename,
|
|
558
563
|
contentHash,
|
|
559
|
-
...metadata ? { metadata } : {}
|
|
564
|
+
...metadata ? { metadata } : {},
|
|
565
|
+
...entities2 ? { entities: entities2 } : {}
|
|
560
566
|
}
|
|
561
567
|
);
|
|
562
568
|
if (token.alreadyCurrent) {
|
|
@@ -582,7 +588,8 @@ async function addDocument(ctx, params) {
|
|
|
582
588
|
contentHash,
|
|
583
589
|
contentType: token.contentType,
|
|
584
590
|
size: content.length,
|
|
585
|
-
...metadata ? { metadata } : {}
|
|
591
|
+
...metadata ? { metadata } : {},
|
|
592
|
+
...entities2 ? { entities: entities2 } : {}
|
|
586
593
|
}
|
|
587
594
|
);
|
|
588
595
|
return {
|
|
@@ -759,6 +766,35 @@ function count(ctx, params) {
|
|
|
759
766
|
...candidate ? { candidate: true } : {}
|
|
760
767
|
});
|
|
761
768
|
}
|
|
769
|
+
function entities(ctx, params) {
|
|
770
|
+
const { slug, filter, limit, candidate } = params;
|
|
771
|
+
return call(
|
|
772
|
+
ctx,
|
|
773
|
+
"POST",
|
|
774
|
+
`${base(ctx.appId)}/entities`,
|
|
775
|
+
{
|
|
776
|
+
slug,
|
|
777
|
+
...filter ? { filter } : {},
|
|
778
|
+
...limit !== void 0 ? { limit } : {},
|
|
779
|
+
...candidate ? { candidate: true } : {}
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
function passages(ctx, params) {
|
|
784
|
+
const { slug, filter, cursor, limit, candidate } = params;
|
|
785
|
+
return call(
|
|
786
|
+
ctx,
|
|
787
|
+
"POST",
|
|
788
|
+
`${base(ctx.appId)}/passages`,
|
|
789
|
+
{
|
|
790
|
+
slug,
|
|
791
|
+
...filter ? { filter } : {},
|
|
792
|
+
...cursor ? { cursor } : {},
|
|
793
|
+
...limit !== void 0 ? { limit } : {},
|
|
794
|
+
...candidate ? { candidate: true } : {}
|
|
795
|
+
}
|
|
796
|
+
);
|
|
797
|
+
}
|
|
762
798
|
function configGet(ctx, slug) {
|
|
763
799
|
return call(
|
|
764
800
|
ctx,
|
|
@@ -920,6 +956,67 @@ function deleteSource(ctx, slug) {
|
|
|
920
956
|
{ slug }
|
|
921
957
|
);
|
|
922
958
|
}
|
|
959
|
+
var DICTIONARY_PAGE_ENTRIES = 1e4;
|
|
960
|
+
var DICTIONARY_PAGE_BYTES = 4e6;
|
|
961
|
+
async function pushDictionary(ctx, params) {
|
|
962
|
+
const { slug, entries } = params;
|
|
963
|
+
const stage = await call(
|
|
964
|
+
ctx,
|
|
965
|
+
"POST",
|
|
966
|
+
`${base(ctx.appId)}/dictionary/stage`,
|
|
967
|
+
{
|
|
968
|
+
slug,
|
|
969
|
+
...params.linkerVersion !== void 0 ? { linkerVersion: params.linkerVersion } : {}
|
|
970
|
+
}
|
|
971
|
+
);
|
|
972
|
+
const perPage = Math.min(
|
|
973
|
+
DICTIONARY_PAGE_ENTRIES,
|
|
974
|
+
stage.pageMaxEntries || DICTIONARY_PAGE_ENTRIES
|
|
975
|
+
);
|
|
976
|
+
let pages2 = 0;
|
|
977
|
+
let start2 = 0;
|
|
978
|
+
while (start2 < entries.length) {
|
|
979
|
+
let end = start2;
|
|
980
|
+
let bytes = 0;
|
|
981
|
+
while (end < entries.length && end - start2 < perPage) {
|
|
982
|
+
const size = JSON.stringify(entries[end]).length;
|
|
983
|
+
if (end > start2 && bytes + size > DICTIONARY_PAGE_BYTES) {
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
bytes += size;
|
|
987
|
+
end += 1;
|
|
988
|
+
}
|
|
989
|
+
await call(ctx, "POST", `${base(ctx.appId)}/dictionary/page`, {
|
|
990
|
+
slug,
|
|
991
|
+
stageId: stage.stageId,
|
|
992
|
+
page: pages2,
|
|
993
|
+
entries: entries.slice(start2, end)
|
|
994
|
+
});
|
|
995
|
+
pages2 += 1;
|
|
996
|
+
start2 = end;
|
|
997
|
+
params.onProgress?.(start2, entries.length);
|
|
998
|
+
}
|
|
999
|
+
return call(
|
|
1000
|
+
ctx,
|
|
1001
|
+
"POST",
|
|
1002
|
+
`${base(ctx.appId)}/dictionary/commit`,
|
|
1003
|
+
{ slug, stageId: stage.stageId, pages: pages2 }
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
function dictionary(ctx, params) {
|
|
1007
|
+
return call(
|
|
1008
|
+
ctx,
|
|
1009
|
+
"POST",
|
|
1010
|
+
`${base(ctx.appId)}/dictionary`,
|
|
1011
|
+
{ slug: params.slug }
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
function link(ctx, params) {
|
|
1015
|
+
return call(ctx, "POST", `${base(ctx.appId)}/link`, {
|
|
1016
|
+
slug: params.slug,
|
|
1017
|
+
text: params.text
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
923
1020
|
|
|
924
1021
|
// src/ops/dataSourceJobs.ts
|
|
925
1022
|
var dataSourceJobs_exports = {};
|
|
@@ -1447,7 +1544,8 @@ function mapTest(ctx, params) {
|
|
|
1447
1544
|
...selectionBody(params.selection),
|
|
1448
1545
|
...params.keys ? { keys: params.keys } : {},
|
|
1449
1546
|
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
1450
|
-
...params.dev ? { dev: true } : {}
|
|
1547
|
+
...params.dev ? { dev: true } : {},
|
|
1548
|
+
...params.releaseId ? { releaseId: params.releaseId } : {}
|
|
1451
1549
|
}
|
|
1452
1550
|
);
|
|
1453
1551
|
}
|
|
@@ -1475,6 +1573,7 @@ function quarantine(ctx, params) {
|
|
|
1475
1573
|
"GET",
|
|
1476
1574
|
`${base5(ctx.appId)}/jobs/${params.id}/quarantine${qs({
|
|
1477
1575
|
...params.kind ? { kind: params.kind } : {},
|
|
1576
|
+
...params.stage ? { stage: params.stage } : {},
|
|
1478
1577
|
...params.reason ? { reason: params.reason } : {},
|
|
1479
1578
|
...params.cursor ? { cursor: params.cursor } : {},
|
|
1480
1579
|
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
@@ -1567,6 +1666,13 @@ function summarizeRelease(release) {
|
|
|
1567
1666
|
publishedAt: release.publishedAt ?? null,
|
|
1568
1667
|
...release.previewUrl ? { previewUrl: release.previewUrl } : {}
|
|
1569
1668
|
};
|
|
1669
|
+
const readers = (release.dataSources ?? []).filter((d) => d.reader);
|
|
1670
|
+
if (readers.length > 0 && release.status === "live") {
|
|
1671
|
+
summary2.readers = readers.map((d) => ({
|
|
1672
|
+
slug: d.slug,
|
|
1673
|
+
unread: d.readerUnread ?? 0
|
|
1674
|
+
}));
|
|
1675
|
+
}
|
|
1570
1676
|
if (release.status !== "failed") {
|
|
1571
1677
|
return summary2;
|
|
1572
1678
|
}
|