@madewithremy/admin 0.1.7 → 0.1.9
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 +1327 -14
- package/dist/index.js +774 -180
- package/dist/index.js.map +1 -1
- package/dist/prod.js +2081 -288
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -374,8 +374,11 @@ __export(dataSources_exports, {
|
|
|
374
374
|
promote: () => promote,
|
|
375
375
|
revectorize: () => revectorize,
|
|
376
376
|
rm: () => rm,
|
|
377
|
+
rmWhere: () => rmWhere,
|
|
378
|
+
rmWhereAll: () => rmWhereAll,
|
|
377
379
|
search: () => search,
|
|
378
380
|
summarize: () => summarize,
|
|
381
|
+
waitForCandidate: () => waitForCandidate,
|
|
379
382
|
waitForIngest: () => waitForIngest,
|
|
380
383
|
waitForMove: () => waitForMove
|
|
381
384
|
});
|
|
@@ -386,6 +389,48 @@ function sleep(ms) {
|
|
|
386
389
|
return new Promise((r) => setTimeout(r, ms));
|
|
387
390
|
}
|
|
388
391
|
|
|
392
|
+
// src/poll.ts
|
|
393
|
+
async function pollUntil(read, isSettled, options) {
|
|
394
|
+
const start2 = Date.now();
|
|
395
|
+
let transientSince = null;
|
|
396
|
+
while (true) {
|
|
397
|
+
let value;
|
|
398
|
+
try {
|
|
399
|
+
value = await read();
|
|
400
|
+
transientSince = null;
|
|
401
|
+
} catch (err) {
|
|
402
|
+
if (!isTransientError(err)) {
|
|
403
|
+
throw err;
|
|
404
|
+
}
|
|
405
|
+
transientSince ??= Date.now();
|
|
406
|
+
if (Date.now() - transientSince > TRANSIENT_GRACE_MS) {
|
|
407
|
+
throw err;
|
|
408
|
+
}
|
|
409
|
+
options.onProgress?.(
|
|
410
|
+
`retrying after a gateway error\u2026 (${elapsedSeconds(start2)}s)`
|
|
411
|
+
);
|
|
412
|
+
await sleep(options.pollMs);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (isSettled(value)) {
|
|
416
|
+
return { settled: true, value };
|
|
417
|
+
}
|
|
418
|
+
if (Date.now() - start2 > options.timeoutMs) {
|
|
419
|
+
return { settled: false, value };
|
|
420
|
+
}
|
|
421
|
+
if (options.describe) {
|
|
422
|
+
options.onProgress?.(options.describe(value, start2));
|
|
423
|
+
}
|
|
424
|
+
await sleep(options.pollMs);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function elapsedSeconds(start2) {
|
|
428
|
+
return Math.round((Date.now() - start2) / 1e3);
|
|
429
|
+
}
|
|
430
|
+
function timedOut(timeoutMs, still) {
|
|
431
|
+
return `Timed out after ${Math.round(timeoutMs / 1e3)}s ${still}`;
|
|
432
|
+
}
|
|
433
|
+
|
|
389
434
|
// src/upload.ts
|
|
390
435
|
async function uploadDirect(upload, bytes, filename) {
|
|
391
436
|
const form = new FormData();
|
|
@@ -437,7 +482,12 @@ async function addDocument(ctx, params) {
|
|
|
437
482
|
);
|
|
438
483
|
if (token.alreadyCurrent) {
|
|
439
484
|
onProgress?.(`${filename}: unchanged, skipped`);
|
|
440
|
-
return {
|
|
485
|
+
return {
|
|
486
|
+
filename,
|
|
487
|
+
skipped: true,
|
|
488
|
+
document: token.document,
|
|
489
|
+
documents: token.documents ?? [token.document]
|
|
490
|
+
};
|
|
441
491
|
}
|
|
442
492
|
onProgress?.(
|
|
443
493
|
`${filename}: uploading ${(content.length / 1024 / 1024).toFixed(1)}MB\u2026`
|
|
@@ -460,7 +510,9 @@ async function addDocument(ctx, params) {
|
|
|
460
510
|
filename,
|
|
461
511
|
skipped: false,
|
|
462
512
|
queued: confirmed.queued,
|
|
463
|
-
document: confirmed.document
|
|
513
|
+
document: confirmed.document,
|
|
514
|
+
documents: confirmed.documents ?? (confirmed.document ? [confirmed.document] : []),
|
|
515
|
+
outcome: confirmed.outcome
|
|
464
516
|
};
|
|
465
517
|
}
|
|
466
518
|
async function waitForIngest(ctx, params) {
|
|
@@ -470,50 +522,64 @@ async function waitForIngest(ctx, params) {
|
|
|
470
522
|
return { status: "up-to-date", documents: [] };
|
|
471
523
|
}
|
|
472
524
|
const wanted = new Set(documentIds);
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if (Date.now() - transientSince > TRANSIENT_GRACE_MS) {
|
|
486
|
-
throw err;
|
|
487
|
-
}
|
|
488
|
-
onProgress?.(
|
|
489
|
-
`retrying after a gateway error\u2026 (${Math.round((Date.now() - start) / 1e3)}s)`
|
|
490
|
-
);
|
|
491
|
-
await sleep(POLL_MS);
|
|
492
|
-
continue;
|
|
493
|
-
}
|
|
494
|
-
const tracked = (docs ?? []).filter((d) => wanted.has(d.id));
|
|
495
|
-
const pending = tracked.filter((d) => d.status === "processing");
|
|
496
|
-
const failed = tracked.filter((d) => d.status === "error");
|
|
497
|
-
if (pending.length === 0) {
|
|
498
|
-
return {
|
|
499
|
-
status: failed.length ? "error" : "done",
|
|
500
|
-
documents: tracked.map(summarize)
|
|
501
|
-
};
|
|
525
|
+
const pendingOf = (docs) => docs.filter((d) => d.status === "processing");
|
|
526
|
+
const outcome = await pollUntil(
|
|
527
|
+
async () => {
|
|
528
|
+
const docs = await allDocuments(ctx, { slug, ids: documentIds });
|
|
529
|
+
return (docs ?? []).filter((d) => wanted.has(d.id));
|
|
530
|
+
},
|
|
531
|
+
(tracked2) => pendingOf(tracked2).length === 0,
|
|
532
|
+
{
|
|
533
|
+
timeoutMs,
|
|
534
|
+
pollMs: POLL_MS,
|
|
535
|
+
describe: (tracked2, start2) => `ingesting\u2026 ${tracked2.length - pendingOf(tracked2).length}/${tracked2.length} done (${elapsedSeconds(start2)}s)`,
|
|
536
|
+
onProgress
|
|
502
537
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
538
|
+
);
|
|
539
|
+
const tracked = outcome.value;
|
|
540
|
+
if (!outcome.settled) {
|
|
541
|
+
return {
|
|
542
|
+
status: "timeout",
|
|
543
|
+
documents: tracked.map(summarize),
|
|
544
|
+
error: timedOut(
|
|
545
|
+
timeoutMs,
|
|
546
|
+
`with ${pendingOf(tracked).length} document(s) still processing`
|
|
547
|
+
)
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
status: tracked.some((d) => d.status === "error") ? "error" : "done",
|
|
552
|
+
documents: tracked.map(summarize)
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
async function waitForCandidate(ctx, params) {
|
|
556
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
557
|
+
const pendingOf = (docs2) => docs2.filter((d) => d.status === "processing");
|
|
558
|
+
const outcome = await pollUntil(
|
|
559
|
+
() => allDocuments(ctx, { slug: params.slug, candidate: true }),
|
|
560
|
+
(docs2) => pendingOf(docs2).length === 0,
|
|
561
|
+
{
|
|
562
|
+
timeoutMs,
|
|
563
|
+
pollMs: POLL_MS,
|
|
564
|
+
describe: (docs2, start2) => `rebuilding\u2026 ${docs2.length - pendingOf(docs2).length}/${docs2.length} done (${elapsedSeconds(start2)}s)`,
|
|
565
|
+
onProgress: params.onProgress
|
|
509
566
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
567
|
+
);
|
|
568
|
+
const docs = outcome.value;
|
|
569
|
+
if (!outcome.settled) {
|
|
570
|
+
return {
|
|
571
|
+
status: "timeout",
|
|
572
|
+
documents: docs.map(summarize),
|
|
573
|
+
error: timedOut(
|
|
574
|
+
timeoutMs,
|
|
575
|
+
`with ${pendingOf(docs).length} document(s) still building`
|
|
576
|
+
)
|
|
577
|
+
};
|
|
516
578
|
}
|
|
579
|
+
return {
|
|
580
|
+
status: docs.some((d) => d.status === "error") ? "error" : "ready",
|
|
581
|
+
documents: docs.map(summarize)
|
|
582
|
+
};
|
|
517
583
|
}
|
|
518
584
|
var DOCUMENTS_IDS_MAX = 200;
|
|
519
585
|
function documents(ctx, params) {
|
|
@@ -621,52 +687,39 @@ function move(ctx, params) {
|
|
|
621
687
|
}
|
|
622
688
|
async function waitForMove(ctx, params) {
|
|
623
689
|
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
for (; ; ) {
|
|
627
|
-
let source;
|
|
628
|
-
try {
|
|
690
|
+
const outcome = await pollUntil(
|
|
691
|
+
async () => {
|
|
629
692
|
const { dataSources } = await list3(ctx);
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (!isTransientError(err)) {
|
|
634
|
-
throw err;
|
|
693
|
+
const source2 = dataSources.find((s) => s.slug === params.slug);
|
|
694
|
+
if (!source2) {
|
|
695
|
+
throw new Error(`Data source "${params.slug}" not found.`);
|
|
635
696
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
)
|
|
643
|
-
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
|
-
if (!source) {
|
|
647
|
-
throw new Error(`Data source "${params.slug}" not found.`);
|
|
648
|
-
}
|
|
649
|
-
const migration = source.migration;
|
|
650
|
-
if (!migration) {
|
|
651
|
-
return { status: "done", source };
|
|
652
|
-
}
|
|
653
|
-
if (migration.error) {
|
|
654
|
-
return { status: "failed", source, error: migration.error };
|
|
655
|
-
}
|
|
656
|
-
if (Date.now() - start > timeoutMs) {
|
|
657
|
-
return {
|
|
658
|
-
status: "timeout",
|
|
659
|
-
source,
|
|
660
|
-
error: `Timed out after ${Math.round(timeoutMs / 1e3)}s with ${migration.copied}/${migration.total} documents copied`
|
|
661
|
-
};
|
|
697
|
+
return source2;
|
|
698
|
+
},
|
|
699
|
+
(source2) => !source2.migration || source2.migration.error !== null,
|
|
700
|
+
{
|
|
701
|
+
timeoutMs,
|
|
702
|
+
pollMs: POLL_MS,
|
|
703
|
+
describe: (source2, start2) => `moving\u2026 ${source2.migration.copied}/${source2.migration.total} documents (${elapsedSeconds(start2)}s)`,
|
|
704
|
+
onProgress: params.onProgress
|
|
662
705
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
706
|
+
);
|
|
707
|
+
const source = outcome.value;
|
|
708
|
+
const migration = source.migration;
|
|
709
|
+
if (!outcome.settled) {
|
|
710
|
+
return {
|
|
711
|
+
status: "timeout",
|
|
712
|
+
source,
|
|
713
|
+
error: timedOut(
|
|
714
|
+
timeoutMs,
|
|
715
|
+
`with ${migration.copied}/${migration.total} documents copied`
|
|
716
|
+
)
|
|
717
|
+
};
|
|
669
718
|
}
|
|
719
|
+
if (migration?.error) {
|
|
720
|
+
return { status: "failed", source, error: migration.error };
|
|
721
|
+
}
|
|
722
|
+
return { status: "done", source };
|
|
670
723
|
}
|
|
671
724
|
function revectorize(ctx, params) {
|
|
672
725
|
const { slug, ingest } = params;
|
|
@@ -713,6 +766,27 @@ function rm(ctx, params) {
|
|
|
713
766
|
}
|
|
714
767
|
);
|
|
715
768
|
}
|
|
769
|
+
function rmWhere(ctx, params) {
|
|
770
|
+
return call(
|
|
771
|
+
ctx,
|
|
772
|
+
"POST",
|
|
773
|
+
`${base(ctx.appId)}/documents/delete-many`,
|
|
774
|
+
{ slug: params.slug, filter: params.filter }
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
async function rmWhereAll(ctx, params) {
|
|
778
|
+
let deleted = 0;
|
|
779
|
+
while (true) {
|
|
780
|
+
const page = await rmWhere(ctx, params);
|
|
781
|
+
deleted += page.deleted;
|
|
782
|
+
if (page.remaining === 0 || page.deleted === 0) {
|
|
783
|
+
return { deleted };
|
|
784
|
+
}
|
|
785
|
+
params.onProgress?.(
|
|
786
|
+
`removed ${deleted.toLocaleString()} so far, ${page.remaining.toLocaleString()} remaining\u2026`
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
716
790
|
function deleteSource(ctx, slug) {
|
|
717
791
|
return call(
|
|
718
792
|
ctx,
|
|
@@ -722,6 +796,538 @@ function deleteSource(ctx, slug) {
|
|
|
722
796
|
);
|
|
723
797
|
}
|
|
724
798
|
|
|
799
|
+
// src/ops/dataSourceJobs.ts
|
|
800
|
+
var dataSourceJobs_exports = {};
|
|
801
|
+
__export(dataSourceJobs_exports, {
|
|
802
|
+
DEFAULT_WAIT_TIMEOUT_MS: () => DEFAULT_WAIT_TIMEOUT_MS2,
|
|
803
|
+
approve: () => approve,
|
|
804
|
+
cancel: () => cancel,
|
|
805
|
+
describeProgress: () => describeProgress,
|
|
806
|
+
get: () => get2,
|
|
807
|
+
list: () => list4,
|
|
808
|
+
pause: () => pause,
|
|
809
|
+
resume: () => resume,
|
|
810
|
+
start: () => start,
|
|
811
|
+
uploadManifest: () => uploadManifest,
|
|
812
|
+
waitForJob: () => waitForJob,
|
|
813
|
+
waitForPlan: () => waitForPlan
|
|
814
|
+
});
|
|
815
|
+
var DEFAULT_WAIT_TIMEOUT_MS2 = 60 * 60 * 1e3;
|
|
816
|
+
var POLL_MS2 = 5e3;
|
|
817
|
+
function base2(appId) {
|
|
818
|
+
return `/_internal/v2/apps/${appId}/datasources/jobs`;
|
|
819
|
+
}
|
|
820
|
+
function start(ctx, params) {
|
|
821
|
+
const { slug, source, approve: approve2, budgetDollars, concurrency, limit } = params;
|
|
822
|
+
return call(ctx, "POST", base2(ctx.appId), {
|
|
823
|
+
slug,
|
|
824
|
+
source,
|
|
825
|
+
...approve2 ? { approve: true } : {},
|
|
826
|
+
...budgetDollars !== void 0 ? { budgetDollars } : {},
|
|
827
|
+
...concurrency !== void 0 ? { concurrency } : {},
|
|
828
|
+
...limit !== void 0 ? { limit } : {}
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
async function uploadManifest(ctx, params) {
|
|
832
|
+
const token = await call(
|
|
833
|
+
ctx,
|
|
834
|
+
"POST",
|
|
835
|
+
`${base2(ctx.appId)}/manifest-token`,
|
|
836
|
+
{ slug: params.slug }
|
|
837
|
+
);
|
|
838
|
+
await uploadDirect(token.upload, params.content, "manifest.jsonl");
|
|
839
|
+
return { key: token.key };
|
|
840
|
+
}
|
|
841
|
+
function list4(ctx, params) {
|
|
842
|
+
return call(
|
|
843
|
+
ctx,
|
|
844
|
+
"GET",
|
|
845
|
+
`${base2(ctx.appId)}${qs({ slug: params?.slug })}`
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
function get2(ctx, params) {
|
|
849
|
+
return call(
|
|
850
|
+
ctx,
|
|
851
|
+
"GET",
|
|
852
|
+
`${base2(ctx.appId)}/${encodeURIComponent(params.id)}`
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
function approve(ctx, params) {
|
|
856
|
+
return call(
|
|
857
|
+
ctx,
|
|
858
|
+
"POST",
|
|
859
|
+
`${base2(ctx.appId)}/${encodeURIComponent(params.id)}/approve`
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
function pause(ctx, params) {
|
|
863
|
+
return call(
|
|
864
|
+
ctx,
|
|
865
|
+
"POST",
|
|
866
|
+
`${base2(ctx.appId)}/${encodeURIComponent(params.id)}/pause`
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
function resume(ctx, params) {
|
|
870
|
+
return call(
|
|
871
|
+
ctx,
|
|
872
|
+
"POST",
|
|
873
|
+
`${base2(ctx.appId)}/${encodeURIComponent(params.id)}/resume`
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
function cancel(ctx, params) {
|
|
877
|
+
return call(
|
|
878
|
+
ctx,
|
|
879
|
+
"POST",
|
|
880
|
+
`${base2(ctx.appId)}/${encodeURIComponent(params.id)}/cancel`
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
function waitForPlan(ctx, params) {
|
|
884
|
+
return settle(ctx, params, (job) => job.state !== "planning");
|
|
885
|
+
}
|
|
886
|
+
function waitForJob(ctx, params) {
|
|
887
|
+
return settle(
|
|
888
|
+
ctx,
|
|
889
|
+
params,
|
|
890
|
+
(job) => !["planning", "planned", "running"].includes(job.state) || job.state === "planned" && (job.error !== null || !job.autoApprove)
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
async function settle(ctx, params, isSettled) {
|
|
894
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS2;
|
|
895
|
+
const outcome = await pollUntil(
|
|
896
|
+
async () => (await get2(ctx, { id: params.id })).job,
|
|
897
|
+
isSettled,
|
|
898
|
+
{
|
|
899
|
+
timeoutMs,
|
|
900
|
+
pollMs: POLL_MS2,
|
|
901
|
+
describe: describeProgress,
|
|
902
|
+
onProgress: params.onProgress
|
|
903
|
+
}
|
|
904
|
+
);
|
|
905
|
+
const job = outcome.value;
|
|
906
|
+
if (!outcome.settled) {
|
|
907
|
+
return {
|
|
908
|
+
status: "timeout",
|
|
909
|
+
job,
|
|
910
|
+
error: timedOut(timeoutMs, `; job is still ${job.state}`)
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
if (job.state === "failed" || job.state === "cancelled") {
|
|
914
|
+
return {
|
|
915
|
+
status: "failed",
|
|
916
|
+
job,
|
|
917
|
+
error: job.error ?? `The job was ${job.state}.`
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
if (job.state === "paused") {
|
|
921
|
+
return {
|
|
922
|
+
status: "failed",
|
|
923
|
+
job,
|
|
924
|
+
error: job.error ?? `The job paused (${job.pauseReason ?? "user"}). Resume it to continue.`
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
if (job.state === "planned" && (job.error !== null || job.autoApprove)) {
|
|
928
|
+
return {
|
|
929
|
+
status: "planned",
|
|
930
|
+
job,
|
|
931
|
+
error: job.error ?? "The plan is ready but the job did not start. Approve it once the cause is fixed."
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
return { status: "done", job };
|
|
935
|
+
}
|
|
936
|
+
function describeProgress(job, start2) {
|
|
937
|
+
const elapsed = `(${elapsedSeconds(start2)}s)`;
|
|
938
|
+
if (job.state === "planning") {
|
|
939
|
+
return job.enumerationDone ? `planning\u2026 reading a sample of ${job.counts.objectsSeen.toLocaleString()} objects ${elapsed}` : `planning\u2026 ${job.counts.objectsSeen.toLocaleString()} objects counted ${elapsed}`;
|
|
940
|
+
}
|
|
941
|
+
const total = job.plan?.projected.documents ?? job.counts.objectsSeen;
|
|
942
|
+
const processed = job.counts.documentsDone + job.counts.documentsSkipped + job.counts.documentsFailed;
|
|
943
|
+
const spend = `$${job.estimatedDollars.toFixed(2)}${job.budgetDollars !== null ? ` of $${job.budgetDollars.toFixed(2)}` : ""}`;
|
|
944
|
+
return `${job.state}\u2026 ${processed.toLocaleString()}/${total.toLocaleString()} documents \xB7 ${spend} ${elapsed}`;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// src/ops/dataSourceConnectors.ts
|
|
948
|
+
var dataSourceConnectors_exports = {};
|
|
949
|
+
__export(dataSourceConnectors_exports, {
|
|
950
|
+
connect: () => connect,
|
|
951
|
+
disconnect: () => disconnect,
|
|
952
|
+
get: () => get3,
|
|
953
|
+
sync: () => sync
|
|
954
|
+
});
|
|
955
|
+
function base3(appId) {
|
|
956
|
+
return `/_internal/v2/apps/${appId}/datasources`;
|
|
957
|
+
}
|
|
958
|
+
function connect(ctx, params) {
|
|
959
|
+
const {
|
|
960
|
+
slug,
|
|
961
|
+
bucket,
|
|
962
|
+
region,
|
|
963
|
+
prefix,
|
|
964
|
+
endpoint,
|
|
965
|
+
accessKeyIdSecret,
|
|
966
|
+
secretAccessKeySecret,
|
|
967
|
+
deletions,
|
|
968
|
+
budgetDollarsPerSync
|
|
969
|
+
} = params;
|
|
970
|
+
return call(
|
|
971
|
+
ctx,
|
|
972
|
+
"POST",
|
|
973
|
+
`${base3(ctx.appId)}/connector`,
|
|
974
|
+
{
|
|
975
|
+
slug,
|
|
976
|
+
bucket,
|
|
977
|
+
region,
|
|
978
|
+
...prefix !== void 0 ? { prefix } : {},
|
|
979
|
+
...endpoint !== void 0 ? { endpoint } : {},
|
|
980
|
+
accessKeyIdSecret,
|
|
981
|
+
secretAccessKeySecret,
|
|
982
|
+
...deletions !== void 0 ? { deletions } : {},
|
|
983
|
+
...budgetDollarsPerSync !== void 0 ? { budgetDollarsPerSync } : {}
|
|
984
|
+
}
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
function get3(ctx, params) {
|
|
988
|
+
return call(
|
|
989
|
+
ctx,
|
|
990
|
+
"GET",
|
|
991
|
+
`${base3(ctx.appId)}/connector${qs({ slug: params.slug })}`
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
function disconnect(ctx, params) {
|
|
995
|
+
return call(
|
|
996
|
+
ctx,
|
|
997
|
+
"POST",
|
|
998
|
+
`${base3(ctx.appId)}/connector/remove`,
|
|
999
|
+
{ slug: params.slug }
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
function sync(ctx, params) {
|
|
1003
|
+
return call(ctx, "POST", `${base3(ctx.appId)}/sync`, {
|
|
1004
|
+
slug: params.slug,
|
|
1005
|
+
...params.budgetDollars !== void 0 ? { budgetDollars: params.budgetDollars } : {}
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// src/ops/dataSourceEvals.ts
|
|
1010
|
+
var dataSourceEvals_exports = {};
|
|
1011
|
+
__export(dataSourceEvals_exports, {
|
|
1012
|
+
DEFAULT_WAIT_TIMEOUT_MS: () => DEFAULT_WAIT_TIMEOUT_MS3,
|
|
1013
|
+
addQueries: () => addQueries,
|
|
1014
|
+
compare: () => compare,
|
|
1015
|
+
createSet: () => createSet,
|
|
1016
|
+
deleteQuery: () => deleteQuery,
|
|
1017
|
+
deleteSet: () => deleteSet,
|
|
1018
|
+
getRun: () => getRun,
|
|
1019
|
+
getSet: () => getSet,
|
|
1020
|
+
hydrate: () => hydrate,
|
|
1021
|
+
listQueries: () => listQueries,
|
|
1022
|
+
listRuns: () => listRuns,
|
|
1023
|
+
listSets: () => listSets,
|
|
1024
|
+
run: () => run2,
|
|
1025
|
+
sample: () => sample,
|
|
1026
|
+
waitForHydration: () => waitForHydration,
|
|
1027
|
+
waitForRun: () => waitForRun,
|
|
1028
|
+
waitForSet: () => waitForSet
|
|
1029
|
+
});
|
|
1030
|
+
var DEFAULT_WAIT_TIMEOUT_MS3 = 30 * 60 * 1e3;
|
|
1031
|
+
var POLL_MS3 = 4e3;
|
|
1032
|
+
function base4(appId) {
|
|
1033
|
+
return `/_internal/v2/apps/${appId}/datasources`;
|
|
1034
|
+
}
|
|
1035
|
+
function hydrate(ctx, params) {
|
|
1036
|
+
return call(
|
|
1037
|
+
ctx,
|
|
1038
|
+
"POST",
|
|
1039
|
+
`${base4(ctx.appId)}/hydrate`,
|
|
1040
|
+
{ slug: params.slug }
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
async function waitForHydration(ctx, params) {
|
|
1044
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS3;
|
|
1045
|
+
const outcome = await pollUntil(
|
|
1046
|
+
async () => {
|
|
1047
|
+
const { dataSources } = await list3(ctx);
|
|
1048
|
+
const source2 = dataSources.find((s) => s.slug === params.slug);
|
|
1049
|
+
if (!source2) {
|
|
1050
|
+
throw new Error(`Data source "${params.slug}" not found.`);
|
|
1051
|
+
}
|
|
1052
|
+
return source2;
|
|
1053
|
+
},
|
|
1054
|
+
(source2) => !source2.hydration || source2.hydration.error !== null,
|
|
1055
|
+
{
|
|
1056
|
+
timeoutMs,
|
|
1057
|
+
pollMs: POLL_MS3,
|
|
1058
|
+
describe: (source2, start2) => `loading\u2026 ${source2.hydration.copied}/${source2.hydration.total} documents (${elapsedSeconds(start2)}s)`,
|
|
1059
|
+
onProgress: params.onProgress
|
|
1060
|
+
}
|
|
1061
|
+
);
|
|
1062
|
+
const source = outcome.value;
|
|
1063
|
+
const hydration = source.hydration;
|
|
1064
|
+
if (!outcome.settled) {
|
|
1065
|
+
return {
|
|
1066
|
+
status: "timeout",
|
|
1067
|
+
source,
|
|
1068
|
+
error: timedOut(
|
|
1069
|
+
timeoutMs,
|
|
1070
|
+
`with ${hydration.copied}/${hydration.total} documents loaded`
|
|
1071
|
+
)
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
if (hydration?.error) {
|
|
1075
|
+
return { status: "failed", source, error: hydration.error };
|
|
1076
|
+
}
|
|
1077
|
+
return { status: "done", source };
|
|
1078
|
+
}
|
|
1079
|
+
function sample(ctx, params) {
|
|
1080
|
+
const { slug, size, as, filter, stratify, placement } = params;
|
|
1081
|
+
return call(
|
|
1082
|
+
ctx,
|
|
1083
|
+
"POST",
|
|
1084
|
+
`${base4(ctx.appId)}/sample`,
|
|
1085
|
+
{
|
|
1086
|
+
slug,
|
|
1087
|
+
size,
|
|
1088
|
+
...as ? { as } : {},
|
|
1089
|
+
...filter ? { filter } : {},
|
|
1090
|
+
...stratify ? { stratify } : {},
|
|
1091
|
+
...placement !== void 0 ? { placement } : {}
|
|
1092
|
+
}
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
function createSet(ctx, params) {
|
|
1096
|
+
const { slug, name, description, size, style, modelId, tags, seed } = params;
|
|
1097
|
+
return call(ctx, "POST", `${base4(ctx.appId)}/eval/sets`, {
|
|
1098
|
+
slug,
|
|
1099
|
+
name,
|
|
1100
|
+
...description ? { description } : {},
|
|
1101
|
+
...size !== void 0 ? { size } : {},
|
|
1102
|
+
...style ? { style } : {},
|
|
1103
|
+
...modelId ? { modelId } : {},
|
|
1104
|
+
...tags?.length ? { tags } : {},
|
|
1105
|
+
...seed !== void 0 ? { seed } : {}
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
function listSets(ctx, params) {
|
|
1109
|
+
return call(
|
|
1110
|
+
ctx,
|
|
1111
|
+
"GET",
|
|
1112
|
+
`${base4(ctx.appId)}/eval/sets${qs({ slug: params?.slug })}`
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
function getSet(ctx, params) {
|
|
1116
|
+
return call(
|
|
1117
|
+
ctx,
|
|
1118
|
+
"GET",
|
|
1119
|
+
`${base4(ctx.appId)}/eval/sets/${encodeURIComponent(params.id)}${qs({
|
|
1120
|
+
queries: params.queries ? "true" : void 0
|
|
1121
|
+
})}`
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
function deleteSet(ctx, params) {
|
|
1125
|
+
return call(
|
|
1126
|
+
ctx,
|
|
1127
|
+
"POST",
|
|
1128
|
+
`${base4(ctx.appId)}/eval/sets/${encodeURIComponent(params.id)}/delete`
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
function addQueries(ctx, params) {
|
|
1132
|
+
return call(
|
|
1133
|
+
ctx,
|
|
1134
|
+
"POST",
|
|
1135
|
+
`${base4(ctx.appId)}/eval/sets/${encodeURIComponent(params.id)}/queries`,
|
|
1136
|
+
{ queries: params.queries }
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
function listQueries(ctx, params) {
|
|
1140
|
+
return call(
|
|
1141
|
+
ctx,
|
|
1142
|
+
"GET",
|
|
1143
|
+
`${base4(ctx.appId)}/eval/sets/${encodeURIComponent(params.id)}/queries`
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
function deleteQuery(ctx, params) {
|
|
1147
|
+
return call(
|
|
1148
|
+
ctx,
|
|
1149
|
+
"POST",
|
|
1150
|
+
`${base4(ctx.appId)}/eval/sets/${encodeURIComponent(params.id)}/queries/delete`,
|
|
1151
|
+
{ queryId: params.queryId }
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
function run2(ctx, params) {
|
|
1155
|
+
const { setId, slug, candidate, label, retrieval } = params;
|
|
1156
|
+
return call(ctx, "POST", `${base4(ctx.appId)}/eval/runs`, {
|
|
1157
|
+
setId,
|
|
1158
|
+
...slug ? { slug } : {},
|
|
1159
|
+
...candidate ? { candidate: true } : {},
|
|
1160
|
+
...label ? { label } : {},
|
|
1161
|
+
...retrieval && Object.keys(retrieval).length ? { retrieval } : {}
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
function listRuns(ctx, params) {
|
|
1165
|
+
return call(
|
|
1166
|
+
ctx,
|
|
1167
|
+
"GET",
|
|
1168
|
+
`${base4(ctx.appId)}/eval/runs${qs({ setId: params?.setId, slug: params?.slug })}`
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
function getRun(ctx, params) {
|
|
1172
|
+
return call(
|
|
1173
|
+
ctx,
|
|
1174
|
+
"GET",
|
|
1175
|
+
`${base4(ctx.appId)}/eval/runs/${encodeURIComponent(params.id)}${qs({
|
|
1176
|
+
queries: params.queries ? "true" : void 0,
|
|
1177
|
+
worst: params.worst
|
|
1178
|
+
})}`
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
function compare(ctx, params) {
|
|
1182
|
+
return call(
|
|
1183
|
+
ctx,
|
|
1184
|
+
"GET",
|
|
1185
|
+
`${base4(ctx.appId)}/eval/runs/compare${qs({ a: params.a, b: params.b })}`
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
async function waitForRun(ctx, params) {
|
|
1189
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS3;
|
|
1190
|
+
const outcome = await pollUntil(
|
|
1191
|
+
async () => (await getRun(ctx, { id: params.id })).run,
|
|
1192
|
+
(run4) => run4.state === "done" || run4.state === "failed",
|
|
1193
|
+
{
|
|
1194
|
+
timeoutMs,
|
|
1195
|
+
pollMs: POLL_MS3,
|
|
1196
|
+
describe: (run4, start2) => `${run4.state}\u2026 ${run4.completed}/${run4.total} queries (${elapsedSeconds(start2)}s)`,
|
|
1197
|
+
onProgress: params.onProgress
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1200
|
+
const run3 = outcome.value;
|
|
1201
|
+
if (!outcome.settled) {
|
|
1202
|
+
return {
|
|
1203
|
+
status: "timeout",
|
|
1204
|
+
run: run3,
|
|
1205
|
+
error: timedOut(
|
|
1206
|
+
timeoutMs,
|
|
1207
|
+
`; run is ${run3.state} (${run3.completed}/${run3.total})`
|
|
1208
|
+
)
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
if (run3.state === "failed") {
|
|
1212
|
+
return { status: "failed", run: run3, error: run3.error ?? "The run failed." };
|
|
1213
|
+
}
|
|
1214
|
+
return { status: "done", run: run3 };
|
|
1215
|
+
}
|
|
1216
|
+
async function waitForSet(ctx, params) {
|
|
1217
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS3;
|
|
1218
|
+
const outcome = await pollUntil(
|
|
1219
|
+
async () => (await getSet(ctx, { id: params.id })).set,
|
|
1220
|
+
(set4) => set4.state === "ready" || set4.state === "failed",
|
|
1221
|
+
{
|
|
1222
|
+
timeoutMs,
|
|
1223
|
+
pollMs: POLL_MS3,
|
|
1224
|
+
describe: (set4, start2) => `${set4.state}\u2026 (${elapsedSeconds(start2)}s)`,
|
|
1225
|
+
onProgress: params.onProgress
|
|
1226
|
+
}
|
|
1227
|
+
);
|
|
1228
|
+
const set3 = outcome.value;
|
|
1229
|
+
if (!outcome.settled) {
|
|
1230
|
+
return {
|
|
1231
|
+
status: "timeout",
|
|
1232
|
+
set: set3,
|
|
1233
|
+
error: timedOut(timeoutMs, `; set is still ${set3.state}`)
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
if (set3.state === "failed") {
|
|
1237
|
+
return { status: "failed", set: set3, error: set3.error ?? "Generation failed." };
|
|
1238
|
+
}
|
|
1239
|
+
return { status: "done", set: set3 };
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// src/ops/dataSourceMappers.ts
|
|
1243
|
+
var dataSourceMappers_exports = {};
|
|
1244
|
+
__export(dataSourceMappers_exports, {
|
|
1245
|
+
inspect: () => inspect,
|
|
1246
|
+
mapDeploy: () => mapDeploy,
|
|
1247
|
+
mapTest: () => mapTest,
|
|
1248
|
+
quarantine: () => quarantine,
|
|
1249
|
+
remap: () => remap,
|
|
1250
|
+
replay: () => replay
|
|
1251
|
+
});
|
|
1252
|
+
function base5(appId) {
|
|
1253
|
+
return `/_internal/v2/apps/${appId}/datasources`;
|
|
1254
|
+
}
|
|
1255
|
+
function selectionBody(selection) {
|
|
1256
|
+
if ("connector" in selection) {
|
|
1257
|
+
return { connector: true };
|
|
1258
|
+
}
|
|
1259
|
+
return {
|
|
1260
|
+
store: selection.store,
|
|
1261
|
+
...selection.access ? { access: selection.access } : {},
|
|
1262
|
+
...selection.prefix !== void 0 ? { prefix: selection.prefix } : {}
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
function inspect(ctx, params) {
|
|
1266
|
+
return call(
|
|
1267
|
+
ctx,
|
|
1268
|
+
"POST",
|
|
1269
|
+
`${base5(ctx.appId)}/inspect`,
|
|
1270
|
+
{
|
|
1271
|
+
...params.slug ? { slug: params.slug } : {},
|
|
1272
|
+
...selectionBody(params.selection),
|
|
1273
|
+
...params.keys ? { keys: params.keys } : {},
|
|
1274
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
function mapTest(ctx, params) {
|
|
1279
|
+
return call(
|
|
1280
|
+
ctx,
|
|
1281
|
+
"POST",
|
|
1282
|
+
`${base5(ctx.appId)}/map-test`,
|
|
1283
|
+
{
|
|
1284
|
+
slug: params.slug,
|
|
1285
|
+
...selectionBody(params.selection),
|
|
1286
|
+
...params.keys ? { keys: params.keys } : {},
|
|
1287
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
1288
|
+
...params.dev ? { dev: true } : {}
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
}
|
|
1292
|
+
function mapDeploy(ctx, params) {
|
|
1293
|
+
return call(
|
|
1294
|
+
ctx,
|
|
1295
|
+
"POST",
|
|
1296
|
+
`${base5(ctx.appId)}/mapper/deploy`,
|
|
1297
|
+
{
|
|
1298
|
+
slug: params.slug,
|
|
1299
|
+
...params.releaseId ? { releaseId: params.releaseId } : {}
|
|
1300
|
+
}
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
function remap(ctx, params) {
|
|
1304
|
+
return call(ctx, "POST", `${base5(ctx.appId)}/remap`, {
|
|
1305
|
+
slug: params.slug,
|
|
1306
|
+
...params.budgetDollars !== void 0 ? { budgetDollars: params.budgetDollars } : {},
|
|
1307
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
function quarantine(ctx, params) {
|
|
1311
|
+
return call(
|
|
1312
|
+
ctx,
|
|
1313
|
+
"GET",
|
|
1314
|
+
`${base5(ctx.appId)}/jobs/${params.id}/quarantine${qs({
|
|
1315
|
+
...params.kind ? { kind: params.kind } : {},
|
|
1316
|
+
...params.reason ? { reason: params.reason } : {},
|
|
1317
|
+
...params.cursor ? { cursor: params.cursor } : {},
|
|
1318
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1319
|
+
})}`
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
function replay(ctx, params) {
|
|
1323
|
+
return call(
|
|
1324
|
+
ctx,
|
|
1325
|
+
"POST",
|
|
1326
|
+
`${base5(ctx.appId)}/jobs/${params.id}/replay`,
|
|
1327
|
+
params.kind ? { kind: params.kind } : {}
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
725
1331
|
// src/ops/db.ts
|
|
726
1332
|
var db_exports = {};
|
|
727
1333
|
__export(db_exports, {
|
|
@@ -749,18 +1355,18 @@ var releases_exports = {};
|
|
|
749
1355
|
__export(releases_exports, {
|
|
750
1356
|
byCommit: () => byCommit,
|
|
751
1357
|
dashboardLive: () => dashboardLive,
|
|
752
|
-
get: () =>
|
|
753
|
-
list: () =>
|
|
1358
|
+
get: () => get4,
|
|
1359
|
+
list: () => list5,
|
|
754
1360
|
waitForCommit: () => waitForCommit
|
|
755
1361
|
});
|
|
756
|
-
function
|
|
1362
|
+
function list5(ctx, params = {}) {
|
|
757
1363
|
return call(
|
|
758
1364
|
ctx,
|
|
759
1365
|
"GET",
|
|
760
1366
|
`/_internal/v2/apps/${ctx.appId}/releases${qs({ limit: params.limit })}`
|
|
761
1367
|
);
|
|
762
1368
|
}
|
|
763
|
-
function
|
|
1369
|
+
function get4(ctx, releaseId) {
|
|
764
1370
|
return call(
|
|
765
1371
|
ctx,
|
|
766
1372
|
"GET",
|
|
@@ -809,14 +1415,14 @@ function summarizeRelease(release) {
|
|
|
809
1415
|
...release.failurePhase ? { failurePhase: release.failurePhase } : {}
|
|
810
1416
|
};
|
|
811
1417
|
}
|
|
812
|
-
var
|
|
1418
|
+
var POLL_MS4 = 3e3;
|
|
813
1419
|
var RESOLVE_GRACE_MS = 3e4;
|
|
814
1420
|
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
815
1421
|
async function waitForCommit(ctx, params) {
|
|
816
1422
|
const { commitSha, onProgress } = params;
|
|
817
1423
|
const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
818
1424
|
const shortSha = commitSha.slice(0, 8);
|
|
819
|
-
const
|
|
1425
|
+
const start2 = Date.now();
|
|
820
1426
|
let release;
|
|
821
1427
|
while (true) {
|
|
822
1428
|
const r = await byCommit(ctx, commitSha);
|
|
@@ -829,14 +1435,14 @@ async function waitForCommit(ctx, params) {
|
|
|
829
1435
|
`Failed to resolve release for ${shortSha}: HTTP ${r.status} ${JSON.stringify(r.body)}`
|
|
830
1436
|
);
|
|
831
1437
|
}
|
|
832
|
-
if (Date.now() -
|
|
1438
|
+
if (Date.now() - start2 > RESOLVE_GRACE_MS) {
|
|
833
1439
|
return {
|
|
834
1440
|
outcome: "not_found",
|
|
835
1441
|
error: `No release created for commit ${commitSha} within ${RESOLVE_GRACE_MS / 1e3}s \u2014 either the push hasn't registered yet or this SHA never produced a build`
|
|
836
1442
|
};
|
|
837
1443
|
}
|
|
838
1444
|
onProgress?.(`waiting for release to be created for ${shortSha}\u2026`);
|
|
839
|
-
await sleep(
|
|
1445
|
+
await sleep(POLL_MS4);
|
|
840
1446
|
}
|
|
841
1447
|
const SUCCESS = /* @__PURE__ */ new Set(["live", "preview"]);
|
|
842
1448
|
while (true) {
|
|
@@ -857,7 +1463,7 @@ async function waitForCommit(ctx, params) {
|
|
|
857
1463
|
summary: summarizeRelease(release)
|
|
858
1464
|
};
|
|
859
1465
|
}
|
|
860
|
-
if (Date.now() -
|
|
1466
|
+
if (Date.now() - start2 > timeoutMs) {
|
|
861
1467
|
return {
|
|
862
1468
|
outcome: "timeout",
|
|
863
1469
|
release,
|
|
@@ -866,9 +1472,9 @@ async function waitForCommit(ctx, params) {
|
|
|
866
1472
|
};
|
|
867
1473
|
}
|
|
868
1474
|
onProgress?.(
|
|
869
|
-
`${release.status}\u2026 (${Math.round((Date.now() -
|
|
1475
|
+
`${release.status}\u2026 (${Math.round((Date.now() - start2) / 1e3)}s)`
|
|
870
1476
|
);
|
|
871
|
-
await sleep(
|
|
1477
|
+
await sleep(POLL_MS4);
|
|
872
1478
|
const r = await byCommit(ctx, commitSha);
|
|
873
1479
|
if (r.ok) {
|
|
874
1480
|
release = r.body;
|
|
@@ -911,10 +1517,10 @@ __export(domains_exports, {
|
|
|
911
1517
|
customRemove: () => customRemove,
|
|
912
1518
|
customRetry: () => customRetry,
|
|
913
1519
|
findHostname: () => findHostname,
|
|
914
|
-
get: () =>
|
|
1520
|
+
get: () => get5,
|
|
915
1521
|
set: () => set
|
|
916
1522
|
});
|
|
917
|
-
function
|
|
1523
|
+
function get5(ctx) {
|
|
918
1524
|
return call(
|
|
919
1525
|
ctx,
|
|
920
1526
|
"GET",
|
|
@@ -995,9 +1601,9 @@ __export(email_exports, {
|
|
|
995
1601
|
batch: () => batch2,
|
|
996
1602
|
batches: () => batches,
|
|
997
1603
|
checkDomain: () => checkDomain,
|
|
998
|
-
get: () =>
|
|
1604
|
+
get: () => get6,
|
|
999
1605
|
inbox: () => inbox,
|
|
1000
|
-
list: () =>
|
|
1606
|
+
list: () => list6,
|
|
1001
1607
|
listDomains: () => listDomains,
|
|
1002
1608
|
removeDomain: () => removeDomain,
|
|
1003
1609
|
stats: () => stats2,
|
|
@@ -1032,14 +1638,14 @@ async function resolveDomainId(ctx, direction, domain) {
|
|
|
1032
1638
|
}
|
|
1033
1639
|
return match.id;
|
|
1034
1640
|
}
|
|
1035
|
-
function
|
|
1641
|
+
function list6(ctx, params = {}) {
|
|
1036
1642
|
return call(
|
|
1037
1643
|
ctx,
|
|
1038
1644
|
"GET",
|
|
1039
1645
|
`/_internal/v2/apps/${ctx.appId}/outbound-email/messages${qs(params)}`
|
|
1040
1646
|
);
|
|
1041
1647
|
}
|
|
1042
|
-
function
|
|
1648
|
+
function get6(ctx, messageId) {
|
|
1043
1649
|
return call(
|
|
1044
1650
|
ctx,
|
|
1045
1651
|
"GET",
|
|
@@ -1229,38 +1835,38 @@ function remove(ctx, ref) {
|
|
|
1229
1835
|
// src/ops/infra.ts
|
|
1230
1836
|
var infra_exports = {};
|
|
1231
1837
|
__export(infra_exports, {
|
|
1232
|
-
DEFAULT_WAIT_TIMEOUT_MS: () =>
|
|
1838
|
+
DEFAULT_WAIT_TIMEOUT_MS: () => DEFAULT_WAIT_TIMEOUT_MS4,
|
|
1233
1839
|
destroy: () => destroy,
|
|
1234
|
-
get: () =>
|
|
1840
|
+
get: () => get7,
|
|
1235
1841
|
hibernate: () => hibernate,
|
|
1236
|
-
list: () =>
|
|
1842
|
+
list: () => list7,
|
|
1237
1843
|
provision: () => provision,
|
|
1238
1844
|
rename: () => rename,
|
|
1239
1845
|
resize: () => resize,
|
|
1240
|
-
resume: () =>
|
|
1846
|
+
resume: () => resume2,
|
|
1241
1847
|
waitForPhase: () => waitForPhase
|
|
1242
1848
|
});
|
|
1243
|
-
var
|
|
1244
|
-
var
|
|
1245
|
-
function
|
|
1849
|
+
var DEFAULT_WAIT_TIMEOUT_MS4 = 10 * 60 * 1e3;
|
|
1850
|
+
var POLL_MS5 = 3e3;
|
|
1851
|
+
function base6(appId) {
|
|
1246
1852
|
return `/_internal/v2/apps/${appId}/infra`;
|
|
1247
1853
|
}
|
|
1248
|
-
function
|
|
1854
|
+
function list7(ctx, params) {
|
|
1249
1855
|
return call(
|
|
1250
1856
|
ctx,
|
|
1251
1857
|
"GET",
|
|
1252
|
-
`${
|
|
1858
|
+
`${base6(ctx.appId)}${params?.includeDestroyed ? "?includeDestroyed=true" : ""}`
|
|
1253
1859
|
);
|
|
1254
1860
|
}
|
|
1255
|
-
function
|
|
1861
|
+
function get7(ctx, params) {
|
|
1256
1862
|
return call(
|
|
1257
1863
|
ctx,
|
|
1258
1864
|
"GET",
|
|
1259
|
-
`${
|
|
1865
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}`
|
|
1260
1866
|
);
|
|
1261
1867
|
}
|
|
1262
1868
|
function provision(ctx, params) {
|
|
1263
|
-
return call(ctx, "POST",
|
|
1869
|
+
return call(ctx, "POST", base6(ctx.appId), {
|
|
1264
1870
|
offeringId: params.offeringId,
|
|
1265
1871
|
...params.name ? { name: params.name } : {}
|
|
1266
1872
|
});
|
|
@@ -1269,28 +1875,28 @@ function hibernate(ctx, params) {
|
|
|
1269
1875
|
return call(
|
|
1270
1876
|
ctx,
|
|
1271
1877
|
"POST",
|
|
1272
|
-
`${
|
|
1878
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/hibernate`
|
|
1273
1879
|
);
|
|
1274
1880
|
}
|
|
1275
|
-
function
|
|
1881
|
+
function resume2(ctx, params) {
|
|
1276
1882
|
return call(
|
|
1277
1883
|
ctx,
|
|
1278
1884
|
"POST",
|
|
1279
|
-
`${
|
|
1885
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/resume`
|
|
1280
1886
|
);
|
|
1281
1887
|
}
|
|
1282
1888
|
function destroy(ctx, params) {
|
|
1283
1889
|
return call(
|
|
1284
1890
|
ctx,
|
|
1285
1891
|
"POST",
|
|
1286
|
-
`${
|
|
1892
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/destroy`
|
|
1287
1893
|
);
|
|
1288
1894
|
}
|
|
1289
1895
|
function resize(ctx, params) {
|
|
1290
1896
|
return call(
|
|
1291
1897
|
ctx,
|
|
1292
1898
|
"POST",
|
|
1293
|
-
`${
|
|
1899
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/resize`,
|
|
1294
1900
|
{ offeringId: params.offeringId }
|
|
1295
1901
|
);
|
|
1296
1902
|
}
|
|
@@ -1298,56 +1904,40 @@ function rename(ctx, params) {
|
|
|
1298
1904
|
return call(
|
|
1299
1905
|
ctx,
|
|
1300
1906
|
"POST",
|
|
1301
|
-
`${
|
|
1907
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/rename`,
|
|
1302
1908
|
{ name: params.name }
|
|
1303
1909
|
);
|
|
1304
1910
|
}
|
|
1305
1911
|
async function waitForPhase(ctx, params) {
|
|
1306
|
-
const timeoutMs = params.timeoutMs ??
|
|
1912
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS4;
|
|
1307
1913
|
const wanted = new Set(params.phases);
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
throw err;
|
|
1318
|
-
}
|
|
1319
|
-
transientSince ??= Date.now();
|
|
1320
|
-
if (Date.now() - transientSince > TRANSIENT_GRACE_MS) {
|
|
1321
|
-
throw err;
|
|
1322
|
-
}
|
|
1323
|
-
params.onProgress?.(
|
|
1324
|
-
`retrying after a gateway error\u2026 (${Math.round((Date.now() - start) / 1e3)}s)`
|
|
1325
|
-
);
|
|
1326
|
-
await sleep(POLL_MS3);
|
|
1327
|
-
continue;
|
|
1328
|
-
}
|
|
1329
|
-
if (wanted.has(resource.phase) && (params.until?.(resource) ?? true)) {
|
|
1330
|
-
return { status: "done", resource };
|
|
1331
|
-
}
|
|
1332
|
-
if (resource.phase === "failed") {
|
|
1333
|
-
return {
|
|
1334
|
-
status: "failed",
|
|
1335
|
-
resource,
|
|
1336
|
-
error: resource.lastError ?? "The platform could not complete the change."
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
if (Date.now() - start > timeoutMs) {
|
|
1340
|
-
return {
|
|
1341
|
-
status: "timeout",
|
|
1342
|
-
resource,
|
|
1343
|
-
error: `Timed out after ${Math.round(timeoutMs / 1e3)}s; resource is still ${resource.phase}`
|
|
1344
|
-
};
|
|
1914
|
+
const arrived = (resource2) => wanted.has(resource2.phase) && (params.until?.(resource2) ?? true);
|
|
1915
|
+
const outcome = await pollUntil(
|
|
1916
|
+
async () => (await get7(ctx, { id: params.id })).resource,
|
|
1917
|
+
(resource2) => arrived(resource2) || resource2.phase === "failed",
|
|
1918
|
+
{
|
|
1919
|
+
timeoutMs,
|
|
1920
|
+
pollMs: POLL_MS5,
|
|
1921
|
+
describe: (resource2, start2) => `${resource2.phase}${resource2.detail ? ` \xB7 ${resource2.detail}` : ""}${resource2.resizingTo ? ` \xB7 resizing to ${resource2.resizingTo.label}` : ""}\u2026 (${elapsedSeconds(start2)}s)`,
|
|
1922
|
+
onProgress: params.onProgress
|
|
1345
1923
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1924
|
+
);
|
|
1925
|
+
const resource = outcome.value;
|
|
1926
|
+
if (!outcome.settled) {
|
|
1927
|
+
return {
|
|
1928
|
+
status: "timeout",
|
|
1929
|
+
resource,
|
|
1930
|
+
error: timedOut(timeoutMs, `; resource is still ${resource.phase}`)
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
if (arrived(resource)) {
|
|
1934
|
+
return { status: "done", resource };
|
|
1350
1935
|
}
|
|
1936
|
+
return {
|
|
1937
|
+
status: "failed",
|
|
1938
|
+
resource,
|
|
1939
|
+
error: resource.lastError ?? "The platform could not complete the change."
|
|
1940
|
+
};
|
|
1351
1941
|
}
|
|
1352
1942
|
|
|
1353
1943
|
// src/ops/issues.ts
|
|
@@ -1358,18 +1948,18 @@ __export(issues_exports, {
|
|
|
1358
1948
|
create: () => create2,
|
|
1359
1949
|
del: () => del,
|
|
1360
1950
|
edit: () => edit,
|
|
1361
|
-
get: () =>
|
|
1362
|
-
list: () =>
|
|
1951
|
+
get: () => get8,
|
|
1952
|
+
list: () => list8,
|
|
1363
1953
|
reopen: () => reopen
|
|
1364
1954
|
});
|
|
1365
|
-
function
|
|
1955
|
+
function list8(ctx, params = {}) {
|
|
1366
1956
|
return call(
|
|
1367
1957
|
ctx,
|
|
1368
1958
|
"GET",
|
|
1369
1959
|
`/_internal/v2/apps/${ctx.appId}/issues${qs(params)}`
|
|
1370
1960
|
);
|
|
1371
1961
|
}
|
|
1372
|
-
function
|
|
1962
|
+
function get8(ctx, number) {
|
|
1373
1963
|
return call(
|
|
1374
1964
|
ctx,
|
|
1375
1965
|
"GET",
|
|
@@ -1453,7 +2043,7 @@ __export(jewels_exports, {
|
|
|
1453
2043
|
JEWEL_RUN_TIMEOUT_MS: () => JEWEL_RUN_TIMEOUT_MS,
|
|
1454
2044
|
dryrun: () => dryrun,
|
|
1455
2045
|
exportSummary: () => exportSummary,
|
|
1456
|
-
getRun: () =>
|
|
2046
|
+
getRun: () => getRun2,
|
|
1457
2047
|
grade: () => grade,
|
|
1458
2048
|
overview: () => overview,
|
|
1459
2049
|
pair: () => pair,
|
|
@@ -1550,7 +2140,7 @@ function runs(ctx, params = {}) {
|
|
|
1550
2140
|
`/_internal/v2/apps/${ctx.appId}/jewels/training-runs${qs(params)}`
|
|
1551
2141
|
);
|
|
1552
2142
|
}
|
|
1553
|
-
function
|
|
2143
|
+
function getRun2(ctx, runId) {
|
|
1554
2144
|
return call(
|
|
1555
2145
|
ctx,
|
|
1556
2146
|
"GET",
|
|
@@ -1571,9 +2161,9 @@ function grade(ctx, runId) {
|
|
|
1571
2161
|
var methods_exports = {};
|
|
1572
2162
|
__export(methods_exports, {
|
|
1573
2163
|
invoke: () => invoke,
|
|
1574
|
-
list: () =>
|
|
2164
|
+
list: () => list9
|
|
1575
2165
|
});
|
|
1576
|
-
async function
|
|
2166
|
+
async function list9(ctx) {
|
|
1577
2167
|
const dashboard = await call(
|
|
1578
2168
|
ctx,
|
|
1579
2169
|
"GET",
|
|
@@ -1630,19 +2220,19 @@ function invalidate(ctx, params = {}) {
|
|
|
1630
2220
|
// src/ops/requests.ts
|
|
1631
2221
|
var requests_exports = {};
|
|
1632
2222
|
__export(requests_exports, {
|
|
1633
|
-
get: () =>
|
|
1634
|
-
list: () =>
|
|
2223
|
+
get: () => get9,
|
|
2224
|
+
list: () => list10,
|
|
1635
2225
|
statsForMethod: () => statsForMethod,
|
|
1636
2226
|
statsSummary: () => statsSummary
|
|
1637
2227
|
});
|
|
1638
|
-
function
|
|
2228
|
+
function list10(ctx, params = {}) {
|
|
1639
2229
|
return call(
|
|
1640
2230
|
ctx,
|
|
1641
2231
|
"GET",
|
|
1642
2232
|
`/_internal/v2/apps/${ctx.appId}/requests${qs(params)}`
|
|
1643
2233
|
);
|
|
1644
2234
|
}
|
|
1645
|
-
function
|
|
2235
|
+
function get9(ctx, requestId) {
|
|
1646
2236
|
return call(
|
|
1647
2237
|
ctx,
|
|
1648
2238
|
"GET",
|
|
@@ -1668,18 +2258,18 @@ function statsForMethod(ctx, methodId, params = {}) {
|
|
|
1668
2258
|
var secrets_exports = {};
|
|
1669
2259
|
__export(secrets_exports, {
|
|
1670
2260
|
del: () => del2,
|
|
1671
|
-
get: () =>
|
|
1672
|
-
list: () =>
|
|
2261
|
+
get: () => get10,
|
|
2262
|
+
list: () => list11,
|
|
1673
2263
|
set: () => set2
|
|
1674
2264
|
});
|
|
1675
|
-
function
|
|
2265
|
+
function list11(ctx) {
|
|
1676
2266
|
return call(
|
|
1677
2267
|
ctx,
|
|
1678
2268
|
"GET",
|
|
1679
2269
|
`/_internal/v2/apps/${ctx.appId}/secrets`
|
|
1680
2270
|
);
|
|
1681
2271
|
}
|
|
1682
|
-
function
|
|
2272
|
+
function get10(ctx, key) {
|
|
1683
2273
|
return call(
|
|
1684
2274
|
ctx,
|
|
1685
2275
|
"GET",
|
|
@@ -1735,11 +2325,11 @@ function updateSettings(ctx, partial) {
|
|
|
1735
2325
|
var users_exports = {};
|
|
1736
2326
|
__export(users_exports, {
|
|
1737
2327
|
createApiKey: () => createApiKey,
|
|
1738
|
-
list: () =>
|
|
2328
|
+
list: () => list12,
|
|
1739
2329
|
revokeApiKey: () => revokeApiKey,
|
|
1740
2330
|
setRole: () => setRole
|
|
1741
2331
|
});
|
|
1742
|
-
function
|
|
2332
|
+
function list12(ctx, params = {}) {
|
|
1743
2333
|
return call(
|
|
1744
2334
|
ctx,
|
|
1745
2335
|
"GET",
|
|
@@ -1925,6 +2515,10 @@ function buildClient(ctx) {
|
|
|
1925
2515
|
cron: bindOps(cron_exports, ctx),
|
|
1926
2516
|
data: bindOps(data_exports, ctx),
|
|
1927
2517
|
dataSources: bindOps(dataSources_exports, ctx),
|
|
2518
|
+
dataSourceJobs: bindOps(dataSourceJobs_exports, ctx),
|
|
2519
|
+
dataSourceConnectors: bindOps(dataSourceConnectors_exports, ctx),
|
|
2520
|
+
dataSourceEvals: bindOps(dataSourceEvals_exports, ctx),
|
|
2521
|
+
dataSourceMappers: bindOps(dataSourceMappers_exports, ctx),
|
|
1928
2522
|
db: bindOps(db_exports, ctx),
|
|
1929
2523
|
diagnostics: bindOps(diagnostics_exports, ctx),
|
|
1930
2524
|
domains: bindOps(domains_exports, ctx),
|