@madewithremy/admin 0.1.6 → 0.1.8
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 +1435 -29
- package/dist/index.js +786 -138
- package/dist/index.js.map +1 -1
- package/dist/prod.js +2252 -296
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -370,12 +370,17 @@ __export(dataSources_exports, {
|
|
|
370
370
|
documents: () => documents,
|
|
371
371
|
drop: () => drop,
|
|
372
372
|
list: () => list3,
|
|
373
|
+
move: () => move,
|
|
373
374
|
promote: () => promote,
|
|
374
375
|
revectorize: () => revectorize,
|
|
375
376
|
rm: () => rm,
|
|
377
|
+
rmWhere: () => rmWhere,
|
|
378
|
+
rmWhereAll: () => rmWhereAll,
|
|
376
379
|
search: () => search,
|
|
377
380
|
summarize: () => summarize,
|
|
378
|
-
|
|
381
|
+
waitForCandidate: () => waitForCandidate,
|
|
382
|
+
waitForIngest: () => waitForIngest,
|
|
383
|
+
waitForMove: () => waitForMove
|
|
379
384
|
});
|
|
380
385
|
import { createHash } from "crypto";
|
|
381
386
|
|
|
@@ -384,6 +389,48 @@ function sleep(ms) {
|
|
|
384
389
|
return new Promise((r) => setTimeout(r, ms));
|
|
385
390
|
}
|
|
386
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
|
+
|
|
387
434
|
// src/upload.ts
|
|
388
435
|
async function uploadDirect(upload, bytes, filename) {
|
|
389
436
|
const form = new FormData();
|
|
@@ -435,7 +482,12 @@ async function addDocument(ctx, params) {
|
|
|
435
482
|
);
|
|
436
483
|
if (token.alreadyCurrent) {
|
|
437
484
|
onProgress?.(`${filename}: unchanged, skipped`);
|
|
438
|
-
return {
|
|
485
|
+
return {
|
|
486
|
+
filename,
|
|
487
|
+
skipped: true,
|
|
488
|
+
document: token.document,
|
|
489
|
+
documents: token.documents ?? [token.document]
|
|
490
|
+
};
|
|
439
491
|
}
|
|
440
492
|
onProgress?.(
|
|
441
493
|
`${filename}: uploading ${(content.length / 1024 / 1024).toFixed(1)}MB\u2026`
|
|
@@ -458,7 +510,9 @@ async function addDocument(ctx, params) {
|
|
|
458
510
|
filename,
|
|
459
511
|
skipped: false,
|
|
460
512
|
queued: confirmed.queued,
|
|
461
|
-
document: confirmed.document
|
|
513
|
+
document: confirmed.document,
|
|
514
|
+
documents: confirmed.documents ?? (confirmed.document ? [confirmed.document] : []),
|
|
515
|
+
outcome: confirmed.outcome
|
|
462
516
|
};
|
|
463
517
|
}
|
|
464
518
|
async function waitForIngest(ctx, params) {
|
|
@@ -468,50 +522,64 @@ async function waitForIngest(ctx, params) {
|
|
|
468
522
|
return { status: "up-to-date", documents: [] };
|
|
469
523
|
}
|
|
470
524
|
const wanted = new Set(documentIds);
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (Date.now() - transientSince > TRANSIENT_GRACE_MS) {
|
|
484
|
-
throw err;
|
|
485
|
-
}
|
|
486
|
-
onProgress?.(
|
|
487
|
-
`retrying after a gateway error\u2026 (${Math.round((Date.now() - start) / 1e3)}s)`
|
|
488
|
-
);
|
|
489
|
-
await sleep(POLL_MS);
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
492
|
-
const tracked = (docs ?? []).filter((d) => wanted.has(d.id));
|
|
493
|
-
const pending = tracked.filter((d) => d.status === "processing");
|
|
494
|
-
const failed = tracked.filter((d) => d.status === "error");
|
|
495
|
-
if (pending.length === 0) {
|
|
496
|
-
return {
|
|
497
|
-
status: failed.length ? "error" : "done",
|
|
498
|
-
documents: tracked.map(summarize)
|
|
499
|
-
};
|
|
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
|
|
500
537
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
|
507
566
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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
|
+
};
|
|
514
578
|
}
|
|
579
|
+
return {
|
|
580
|
+
status: docs.some((d) => d.status === "error") ? "error" : "ready",
|
|
581
|
+
documents: docs.map(summarize)
|
|
582
|
+
};
|
|
515
583
|
}
|
|
516
584
|
var DOCUMENTS_IDS_MAX = 200;
|
|
517
585
|
function documents(ctx, params) {
|
|
@@ -611,6 +679,48 @@ function create(ctx, params) {
|
|
|
611
679
|
...placement !== void 0 ? { placement } : {}
|
|
612
680
|
});
|
|
613
681
|
}
|
|
682
|
+
function move(ctx, params) {
|
|
683
|
+
return call(ctx, "POST", `${base(ctx.appId)}/move`, {
|
|
684
|
+
slug: params.slug,
|
|
685
|
+
placement: params.placement
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
async function waitForMove(ctx, params) {
|
|
689
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
690
|
+
const outcome = await pollUntil(
|
|
691
|
+
async () => {
|
|
692
|
+
const { dataSources } = await list3(ctx);
|
|
693
|
+
const source2 = dataSources.find((s) => s.slug === params.slug);
|
|
694
|
+
if (!source2) {
|
|
695
|
+
throw new Error(`Data source "${params.slug}" not found.`);
|
|
696
|
+
}
|
|
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
|
|
705
|
+
}
|
|
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
|
+
};
|
|
718
|
+
}
|
|
719
|
+
if (migration?.error) {
|
|
720
|
+
return { status: "failed", source, error: migration.error };
|
|
721
|
+
}
|
|
722
|
+
return { status: "done", source };
|
|
723
|
+
}
|
|
614
724
|
function revectorize(ctx, params) {
|
|
615
725
|
const { slug, ingest } = params;
|
|
616
726
|
return call(
|
|
@@ -656,6 +766,27 @@ function rm(ctx, params) {
|
|
|
656
766
|
}
|
|
657
767
|
);
|
|
658
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
|
+
}
|
|
659
790
|
function deleteSource(ctx, slug) {
|
|
660
791
|
return call(
|
|
661
792
|
ctx,
|
|
@@ -665,6 +796,526 @@ function deleteSource(ctx, slug) {
|
|
|
665
796
|
);
|
|
666
797
|
}
|
|
667
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
|
+
mapTest: () => mapTest,
|
|
1247
|
+
quarantine: () => quarantine,
|
|
1248
|
+
remap: () => remap,
|
|
1249
|
+
replay: () => replay
|
|
1250
|
+
});
|
|
1251
|
+
function base5(appId) {
|
|
1252
|
+
return `/_internal/v2/apps/${appId}/datasources`;
|
|
1253
|
+
}
|
|
1254
|
+
function selectionBody(selection) {
|
|
1255
|
+
if ("connector" in selection) {
|
|
1256
|
+
return { connector: true };
|
|
1257
|
+
}
|
|
1258
|
+
return {
|
|
1259
|
+
store: selection.store,
|
|
1260
|
+
...selection.access ? { access: selection.access } : {},
|
|
1261
|
+
...selection.prefix !== void 0 ? { prefix: selection.prefix } : {}
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function inspect(ctx, params) {
|
|
1265
|
+
return call(
|
|
1266
|
+
ctx,
|
|
1267
|
+
"POST",
|
|
1268
|
+
`${base5(ctx.appId)}/inspect`,
|
|
1269
|
+
{
|
|
1270
|
+
...params.slug ? { slug: params.slug } : {},
|
|
1271
|
+
...selectionBody(params.selection),
|
|
1272
|
+
...params.keys ? { keys: params.keys } : {},
|
|
1273
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1274
|
+
}
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
function mapTest(ctx, params) {
|
|
1278
|
+
return call(
|
|
1279
|
+
ctx,
|
|
1280
|
+
"POST",
|
|
1281
|
+
`${base5(ctx.appId)}/map-test`,
|
|
1282
|
+
{
|
|
1283
|
+
slug: params.slug,
|
|
1284
|
+
...selectionBody(params.selection),
|
|
1285
|
+
...params.keys ? { keys: params.keys } : {},
|
|
1286
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
1287
|
+
...params.dev ? { dev: true } : {}
|
|
1288
|
+
}
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
function remap(ctx, params) {
|
|
1292
|
+
return call(ctx, "POST", `${base5(ctx.appId)}/remap`, {
|
|
1293
|
+
slug: params.slug,
|
|
1294
|
+
...params.budgetDollars !== void 0 ? { budgetDollars: params.budgetDollars } : {},
|
|
1295
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
function quarantine(ctx, params) {
|
|
1299
|
+
return call(
|
|
1300
|
+
ctx,
|
|
1301
|
+
"GET",
|
|
1302
|
+
`${base5(ctx.appId)}/jobs/${params.id}/quarantine${qs({
|
|
1303
|
+
...params.kind ? { kind: params.kind } : {},
|
|
1304
|
+
...params.reason ? { reason: params.reason } : {},
|
|
1305
|
+
...params.cursor ? { cursor: params.cursor } : {},
|
|
1306
|
+
...params.limit !== void 0 ? { limit: params.limit } : {}
|
|
1307
|
+
})}`
|
|
1308
|
+
);
|
|
1309
|
+
}
|
|
1310
|
+
function replay(ctx, params) {
|
|
1311
|
+
return call(
|
|
1312
|
+
ctx,
|
|
1313
|
+
"POST",
|
|
1314
|
+
`${base5(ctx.appId)}/jobs/${params.id}/replay`,
|
|
1315
|
+
params.kind ? { kind: params.kind } : {}
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
668
1319
|
// src/ops/db.ts
|
|
669
1320
|
var db_exports = {};
|
|
670
1321
|
__export(db_exports, {
|
|
@@ -692,18 +1343,18 @@ var releases_exports = {};
|
|
|
692
1343
|
__export(releases_exports, {
|
|
693
1344
|
byCommit: () => byCommit,
|
|
694
1345
|
dashboardLive: () => dashboardLive,
|
|
695
|
-
get: () =>
|
|
696
|
-
list: () =>
|
|
1346
|
+
get: () => get4,
|
|
1347
|
+
list: () => list5,
|
|
697
1348
|
waitForCommit: () => waitForCommit
|
|
698
1349
|
});
|
|
699
|
-
function
|
|
1350
|
+
function list5(ctx, params = {}) {
|
|
700
1351
|
return call(
|
|
701
1352
|
ctx,
|
|
702
1353
|
"GET",
|
|
703
1354
|
`/_internal/v2/apps/${ctx.appId}/releases${qs({ limit: params.limit })}`
|
|
704
1355
|
);
|
|
705
1356
|
}
|
|
706
|
-
function
|
|
1357
|
+
function get4(ctx, releaseId) {
|
|
707
1358
|
return call(
|
|
708
1359
|
ctx,
|
|
709
1360
|
"GET",
|
|
@@ -752,14 +1403,14 @@ function summarizeRelease(release) {
|
|
|
752
1403
|
...release.failurePhase ? { failurePhase: release.failurePhase } : {}
|
|
753
1404
|
};
|
|
754
1405
|
}
|
|
755
|
-
var
|
|
1406
|
+
var POLL_MS4 = 3e3;
|
|
756
1407
|
var RESOLVE_GRACE_MS = 3e4;
|
|
757
1408
|
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
758
1409
|
async function waitForCommit(ctx, params) {
|
|
759
1410
|
const { commitSha, onProgress } = params;
|
|
760
1411
|
const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
761
1412
|
const shortSha = commitSha.slice(0, 8);
|
|
762
|
-
const
|
|
1413
|
+
const start2 = Date.now();
|
|
763
1414
|
let release;
|
|
764
1415
|
while (true) {
|
|
765
1416
|
const r = await byCommit(ctx, commitSha);
|
|
@@ -772,14 +1423,14 @@ async function waitForCommit(ctx, params) {
|
|
|
772
1423
|
`Failed to resolve release for ${shortSha}: HTTP ${r.status} ${JSON.stringify(r.body)}`
|
|
773
1424
|
);
|
|
774
1425
|
}
|
|
775
|
-
if (Date.now() -
|
|
1426
|
+
if (Date.now() - start2 > RESOLVE_GRACE_MS) {
|
|
776
1427
|
return {
|
|
777
1428
|
outcome: "not_found",
|
|
778
1429
|
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`
|
|
779
1430
|
};
|
|
780
1431
|
}
|
|
781
1432
|
onProgress?.(`waiting for release to be created for ${shortSha}\u2026`);
|
|
782
|
-
await sleep(
|
|
1433
|
+
await sleep(POLL_MS4);
|
|
783
1434
|
}
|
|
784
1435
|
const SUCCESS = /* @__PURE__ */ new Set(["live", "preview"]);
|
|
785
1436
|
while (true) {
|
|
@@ -800,7 +1451,7 @@ async function waitForCommit(ctx, params) {
|
|
|
800
1451
|
summary: summarizeRelease(release)
|
|
801
1452
|
};
|
|
802
1453
|
}
|
|
803
|
-
if (Date.now() -
|
|
1454
|
+
if (Date.now() - start2 > timeoutMs) {
|
|
804
1455
|
return {
|
|
805
1456
|
outcome: "timeout",
|
|
806
1457
|
release,
|
|
@@ -809,9 +1460,9 @@ async function waitForCommit(ctx, params) {
|
|
|
809
1460
|
};
|
|
810
1461
|
}
|
|
811
1462
|
onProgress?.(
|
|
812
|
-
`${release.status}\u2026 (${Math.round((Date.now() -
|
|
1463
|
+
`${release.status}\u2026 (${Math.round((Date.now() - start2) / 1e3)}s)`
|
|
813
1464
|
);
|
|
814
|
-
await sleep(
|
|
1465
|
+
await sleep(POLL_MS4);
|
|
815
1466
|
const r = await byCommit(ctx, commitSha);
|
|
816
1467
|
if (r.ok) {
|
|
817
1468
|
release = r.body;
|
|
@@ -854,10 +1505,10 @@ __export(domains_exports, {
|
|
|
854
1505
|
customRemove: () => customRemove,
|
|
855
1506
|
customRetry: () => customRetry,
|
|
856
1507
|
findHostname: () => findHostname,
|
|
857
|
-
get: () =>
|
|
1508
|
+
get: () => get5,
|
|
858
1509
|
set: () => set
|
|
859
1510
|
});
|
|
860
|
-
function
|
|
1511
|
+
function get5(ctx) {
|
|
861
1512
|
return call(
|
|
862
1513
|
ctx,
|
|
863
1514
|
"GET",
|
|
@@ -938,9 +1589,9 @@ __export(email_exports, {
|
|
|
938
1589
|
batch: () => batch2,
|
|
939
1590
|
batches: () => batches,
|
|
940
1591
|
checkDomain: () => checkDomain,
|
|
941
|
-
get: () =>
|
|
1592
|
+
get: () => get6,
|
|
942
1593
|
inbox: () => inbox,
|
|
943
|
-
list: () =>
|
|
1594
|
+
list: () => list6,
|
|
944
1595
|
listDomains: () => listDomains,
|
|
945
1596
|
removeDomain: () => removeDomain,
|
|
946
1597
|
stats: () => stats2,
|
|
@@ -975,14 +1626,14 @@ async function resolveDomainId(ctx, direction, domain) {
|
|
|
975
1626
|
}
|
|
976
1627
|
return match.id;
|
|
977
1628
|
}
|
|
978
|
-
function
|
|
1629
|
+
function list6(ctx, params = {}) {
|
|
979
1630
|
return call(
|
|
980
1631
|
ctx,
|
|
981
1632
|
"GET",
|
|
982
1633
|
`/_internal/v2/apps/${ctx.appId}/outbound-email/messages${qs(params)}`
|
|
983
1634
|
);
|
|
984
1635
|
}
|
|
985
|
-
function
|
|
1636
|
+
function get6(ctx, messageId) {
|
|
986
1637
|
return call(
|
|
987
1638
|
ctx,
|
|
988
1639
|
"GET",
|
|
@@ -1172,37 +1823,38 @@ function remove(ctx, ref) {
|
|
|
1172
1823
|
// src/ops/infra.ts
|
|
1173
1824
|
var infra_exports = {};
|
|
1174
1825
|
__export(infra_exports, {
|
|
1175
|
-
DEFAULT_WAIT_TIMEOUT_MS: () =>
|
|
1826
|
+
DEFAULT_WAIT_TIMEOUT_MS: () => DEFAULT_WAIT_TIMEOUT_MS4,
|
|
1176
1827
|
destroy: () => destroy,
|
|
1177
|
-
get: () =>
|
|
1828
|
+
get: () => get7,
|
|
1178
1829
|
hibernate: () => hibernate,
|
|
1179
|
-
list: () =>
|
|
1830
|
+
list: () => list7,
|
|
1180
1831
|
provision: () => provision,
|
|
1181
1832
|
rename: () => rename,
|
|
1182
|
-
|
|
1833
|
+
resize: () => resize,
|
|
1834
|
+
resume: () => resume2,
|
|
1183
1835
|
waitForPhase: () => waitForPhase
|
|
1184
1836
|
});
|
|
1185
|
-
var
|
|
1186
|
-
var
|
|
1187
|
-
function
|
|
1837
|
+
var DEFAULT_WAIT_TIMEOUT_MS4 = 10 * 60 * 1e3;
|
|
1838
|
+
var POLL_MS5 = 3e3;
|
|
1839
|
+
function base6(appId) {
|
|
1188
1840
|
return `/_internal/v2/apps/${appId}/infra`;
|
|
1189
1841
|
}
|
|
1190
|
-
function
|
|
1842
|
+
function list7(ctx, params) {
|
|
1191
1843
|
return call(
|
|
1192
1844
|
ctx,
|
|
1193
1845
|
"GET",
|
|
1194
|
-
`${
|
|
1846
|
+
`${base6(ctx.appId)}${params?.includeDestroyed ? "?includeDestroyed=true" : ""}`
|
|
1195
1847
|
);
|
|
1196
1848
|
}
|
|
1197
|
-
function
|
|
1849
|
+
function get7(ctx, params) {
|
|
1198
1850
|
return call(
|
|
1199
1851
|
ctx,
|
|
1200
1852
|
"GET",
|
|
1201
|
-
`${
|
|
1853
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}`
|
|
1202
1854
|
);
|
|
1203
1855
|
}
|
|
1204
1856
|
function provision(ctx, params) {
|
|
1205
|
-
return call(ctx, "POST",
|
|
1857
|
+
return call(ctx, "POST", base6(ctx.appId), {
|
|
1206
1858
|
offeringId: params.offeringId,
|
|
1207
1859
|
...params.name ? { name: params.name } : {}
|
|
1208
1860
|
});
|
|
@@ -1211,77 +1863,69 @@ function hibernate(ctx, params) {
|
|
|
1211
1863
|
return call(
|
|
1212
1864
|
ctx,
|
|
1213
1865
|
"POST",
|
|
1214
|
-
`${
|
|
1866
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/hibernate`
|
|
1215
1867
|
);
|
|
1216
1868
|
}
|
|
1217
|
-
function
|
|
1869
|
+
function resume2(ctx, params) {
|
|
1218
1870
|
return call(
|
|
1219
1871
|
ctx,
|
|
1220
1872
|
"POST",
|
|
1221
|
-
`${
|
|
1873
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/resume`
|
|
1222
1874
|
);
|
|
1223
1875
|
}
|
|
1224
1876
|
function destroy(ctx, params) {
|
|
1225
1877
|
return call(
|
|
1226
1878
|
ctx,
|
|
1227
1879
|
"POST",
|
|
1228
|
-
`${
|
|
1880
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/destroy`
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
function resize(ctx, params) {
|
|
1884
|
+
return call(
|
|
1885
|
+
ctx,
|
|
1886
|
+
"POST",
|
|
1887
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/resize`,
|
|
1888
|
+
{ offeringId: params.offeringId }
|
|
1229
1889
|
);
|
|
1230
1890
|
}
|
|
1231
1891
|
function rename(ctx, params) {
|
|
1232
1892
|
return call(
|
|
1233
1893
|
ctx,
|
|
1234
1894
|
"POST",
|
|
1235
|
-
`${
|
|
1895
|
+
`${base6(ctx.appId)}/${encodeURIComponent(params.id)}/rename`,
|
|
1236
1896
|
{ name: params.name }
|
|
1237
1897
|
);
|
|
1238
1898
|
}
|
|
1239
1899
|
async function waitForPhase(ctx, params) {
|
|
1240
|
-
const timeoutMs = params.timeoutMs ??
|
|
1900
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS4;
|
|
1241
1901
|
const wanted = new Set(params.phases);
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
throw err;
|
|
1252
|
-
}
|
|
1253
|
-
transientSince ??= Date.now();
|
|
1254
|
-
if (Date.now() - transientSince > TRANSIENT_GRACE_MS) {
|
|
1255
|
-
throw err;
|
|
1256
|
-
}
|
|
1257
|
-
params.onProgress?.(
|
|
1258
|
-
`retrying after a gateway error\u2026 (${Math.round((Date.now() - start) / 1e3)}s)`
|
|
1259
|
-
);
|
|
1260
|
-
await sleep(POLL_MS3);
|
|
1261
|
-
continue;
|
|
1262
|
-
}
|
|
1263
|
-
if (wanted.has(resource.phase)) {
|
|
1264
|
-
return { status: "done", resource };
|
|
1265
|
-
}
|
|
1266
|
-
if (resource.phase === "failed") {
|
|
1267
|
-
return {
|
|
1268
|
-
status: "failed",
|
|
1269
|
-
resource,
|
|
1270
|
-
error: resource.lastError ?? "The platform could not complete the change."
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
if (Date.now() - start > timeoutMs) {
|
|
1274
|
-
return {
|
|
1275
|
-
status: "timeout",
|
|
1276
|
-
resource,
|
|
1277
|
-
error: `Timed out after ${Math.round(timeoutMs / 1e3)}s; resource is still ${resource.phase}`
|
|
1278
|
-
};
|
|
1902
|
+
const arrived = (resource2) => wanted.has(resource2.phase) && (params.until?.(resource2) ?? true);
|
|
1903
|
+
const outcome = await pollUntil(
|
|
1904
|
+
async () => (await get7(ctx, { id: params.id })).resource,
|
|
1905
|
+
(resource2) => arrived(resource2) || resource2.phase === "failed",
|
|
1906
|
+
{
|
|
1907
|
+
timeoutMs,
|
|
1908
|
+
pollMs: POLL_MS5,
|
|
1909
|
+
describe: (resource2, start2) => `${resource2.phase}${resource2.detail ? ` \xB7 ${resource2.detail}` : ""}${resource2.resizingTo ? ` \xB7 resizing to ${resource2.resizingTo.label}` : ""}\u2026 (${elapsedSeconds(start2)}s)`,
|
|
1910
|
+
onProgress: params.onProgress
|
|
1279
1911
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1912
|
+
);
|
|
1913
|
+
const resource = outcome.value;
|
|
1914
|
+
if (!outcome.settled) {
|
|
1915
|
+
return {
|
|
1916
|
+
status: "timeout",
|
|
1917
|
+
resource,
|
|
1918
|
+
error: timedOut(timeoutMs, `; resource is still ${resource.phase}`)
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
if (arrived(resource)) {
|
|
1922
|
+
return { status: "done", resource };
|
|
1284
1923
|
}
|
|
1924
|
+
return {
|
|
1925
|
+
status: "failed",
|
|
1926
|
+
resource,
|
|
1927
|
+
error: resource.lastError ?? "The platform could not complete the change."
|
|
1928
|
+
};
|
|
1285
1929
|
}
|
|
1286
1930
|
|
|
1287
1931
|
// src/ops/issues.ts
|
|
@@ -1292,18 +1936,18 @@ __export(issues_exports, {
|
|
|
1292
1936
|
create: () => create2,
|
|
1293
1937
|
del: () => del,
|
|
1294
1938
|
edit: () => edit,
|
|
1295
|
-
get: () =>
|
|
1296
|
-
list: () =>
|
|
1939
|
+
get: () => get8,
|
|
1940
|
+
list: () => list8,
|
|
1297
1941
|
reopen: () => reopen
|
|
1298
1942
|
});
|
|
1299
|
-
function
|
|
1943
|
+
function list8(ctx, params = {}) {
|
|
1300
1944
|
return call(
|
|
1301
1945
|
ctx,
|
|
1302
1946
|
"GET",
|
|
1303
1947
|
`/_internal/v2/apps/${ctx.appId}/issues${qs(params)}`
|
|
1304
1948
|
);
|
|
1305
1949
|
}
|
|
1306
|
-
function
|
|
1950
|
+
function get8(ctx, number) {
|
|
1307
1951
|
return call(
|
|
1308
1952
|
ctx,
|
|
1309
1953
|
"GET",
|
|
@@ -1387,7 +2031,7 @@ __export(jewels_exports, {
|
|
|
1387
2031
|
JEWEL_RUN_TIMEOUT_MS: () => JEWEL_RUN_TIMEOUT_MS,
|
|
1388
2032
|
dryrun: () => dryrun,
|
|
1389
2033
|
exportSummary: () => exportSummary,
|
|
1390
|
-
getRun: () =>
|
|
2034
|
+
getRun: () => getRun2,
|
|
1391
2035
|
grade: () => grade,
|
|
1392
2036
|
overview: () => overview,
|
|
1393
2037
|
pair: () => pair,
|
|
@@ -1484,7 +2128,7 @@ function runs(ctx, params = {}) {
|
|
|
1484
2128
|
`/_internal/v2/apps/${ctx.appId}/jewels/training-runs${qs(params)}`
|
|
1485
2129
|
);
|
|
1486
2130
|
}
|
|
1487
|
-
function
|
|
2131
|
+
function getRun2(ctx, runId) {
|
|
1488
2132
|
return call(
|
|
1489
2133
|
ctx,
|
|
1490
2134
|
"GET",
|
|
@@ -1505,9 +2149,9 @@ function grade(ctx, runId) {
|
|
|
1505
2149
|
var methods_exports = {};
|
|
1506
2150
|
__export(methods_exports, {
|
|
1507
2151
|
invoke: () => invoke,
|
|
1508
|
-
list: () =>
|
|
2152
|
+
list: () => list9
|
|
1509
2153
|
});
|
|
1510
|
-
async function
|
|
2154
|
+
async function list9(ctx) {
|
|
1511
2155
|
const dashboard = await call(
|
|
1512
2156
|
ctx,
|
|
1513
2157
|
"GET",
|
|
@@ -1564,19 +2208,19 @@ function invalidate(ctx, params = {}) {
|
|
|
1564
2208
|
// src/ops/requests.ts
|
|
1565
2209
|
var requests_exports = {};
|
|
1566
2210
|
__export(requests_exports, {
|
|
1567
|
-
get: () =>
|
|
1568
|
-
list: () =>
|
|
2211
|
+
get: () => get9,
|
|
2212
|
+
list: () => list10,
|
|
1569
2213
|
statsForMethod: () => statsForMethod,
|
|
1570
2214
|
statsSummary: () => statsSummary
|
|
1571
2215
|
});
|
|
1572
|
-
function
|
|
2216
|
+
function list10(ctx, params = {}) {
|
|
1573
2217
|
return call(
|
|
1574
2218
|
ctx,
|
|
1575
2219
|
"GET",
|
|
1576
2220
|
`/_internal/v2/apps/${ctx.appId}/requests${qs(params)}`
|
|
1577
2221
|
);
|
|
1578
2222
|
}
|
|
1579
|
-
function
|
|
2223
|
+
function get9(ctx, requestId) {
|
|
1580
2224
|
return call(
|
|
1581
2225
|
ctx,
|
|
1582
2226
|
"GET",
|
|
@@ -1602,18 +2246,18 @@ function statsForMethod(ctx, methodId, params = {}) {
|
|
|
1602
2246
|
var secrets_exports = {};
|
|
1603
2247
|
__export(secrets_exports, {
|
|
1604
2248
|
del: () => del2,
|
|
1605
|
-
get: () =>
|
|
1606
|
-
list: () =>
|
|
2249
|
+
get: () => get10,
|
|
2250
|
+
list: () => list11,
|
|
1607
2251
|
set: () => set2
|
|
1608
2252
|
});
|
|
1609
|
-
function
|
|
2253
|
+
function list11(ctx) {
|
|
1610
2254
|
return call(
|
|
1611
2255
|
ctx,
|
|
1612
2256
|
"GET",
|
|
1613
2257
|
`/_internal/v2/apps/${ctx.appId}/secrets`
|
|
1614
2258
|
);
|
|
1615
2259
|
}
|
|
1616
|
-
function
|
|
2260
|
+
function get10(ctx, key) {
|
|
1617
2261
|
return call(
|
|
1618
2262
|
ctx,
|
|
1619
2263
|
"GET",
|
|
@@ -1669,11 +2313,11 @@ function updateSettings(ctx, partial) {
|
|
|
1669
2313
|
var users_exports = {};
|
|
1670
2314
|
__export(users_exports, {
|
|
1671
2315
|
createApiKey: () => createApiKey,
|
|
1672
|
-
list: () =>
|
|
2316
|
+
list: () => list12,
|
|
1673
2317
|
revokeApiKey: () => revokeApiKey,
|
|
1674
2318
|
setRole: () => setRole
|
|
1675
2319
|
});
|
|
1676
|
-
function
|
|
2320
|
+
function list12(ctx, params = {}) {
|
|
1677
2321
|
return call(
|
|
1678
2322
|
ctx,
|
|
1679
2323
|
"GET",
|
|
@@ -1859,6 +2503,10 @@ function buildClient(ctx) {
|
|
|
1859
2503
|
cron: bindOps(cron_exports, ctx),
|
|
1860
2504
|
data: bindOps(data_exports, ctx),
|
|
1861
2505
|
dataSources: bindOps(dataSources_exports, ctx),
|
|
2506
|
+
dataSourceJobs: bindOps(dataSourceJobs_exports, ctx),
|
|
2507
|
+
dataSourceConnectors: bindOps(dataSourceConnectors_exports, ctx),
|
|
2508
|
+
dataSourceEvals: bindOps(dataSourceEvals_exports, ctx),
|
|
2509
|
+
dataSourceMappers: bindOps(dataSourceMappers_exports, ctx),
|
|
1862
2510
|
db: bindOps(db_exports, ctx),
|
|
1863
2511
|
diagnostics: bindOps(diagnostics_exports, ctx),
|
|
1864
2512
|
domains: bindOps(domains_exports, ctx),
|