@burdenoff/microfe-buildmyiq 2026.1107.4 → 2026.1107.5
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/buildmyiq/hooks/index.js +5 -5
- package/dist/buildmyiq/hooks/useBuiMigration.d.ts +25 -0
- package/dist/buildmyiq/hooks/useBuiMigration.d.ts.map +1 -1
- package/dist/buildmyiq/hooks/useBuiMigration.js +40 -24
- package/dist/buildmyiq/hooks/useBuiMigration.js.map +1 -1
- package/dist/buildmyiq/pages/migration/MigrationCenterPage.d.ts.map +1 -1
- package/dist/buildmyiq/pages/migration/MigrationCenterPage.js +255 -218
- package/dist/buildmyiq/pages/migration/MigrationCenterPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,8 +10,8 @@ import { AI_SIGNAL_TYPES as _t, EPISODE_MIN_MS as vt, EPISODE_RELEASE_MS as yt,
|
|
|
10
10
|
import { buildCredentialLinks as At, gatewayOrigin as jt } from "./useBuiCredentials.js";
|
|
11
11
|
import { hasCheckableContent as Mt } from "./accessibilityDraft.js";
|
|
12
12
|
import { accessibilityKeys as Nt, useBuiCheckContentAccessibility as Pt, useBuiCourseAccessibilityReport as Ft, useDebouncedValue as It } from "./useBuiAccessibility.js";
|
|
13
|
-
import {
|
|
14
|
-
import { interactiveKeys as
|
|
15
|
-
import { useMintScimToken as
|
|
16
|
-
import { fetchAllPages as
|
|
17
|
-
export { _t as AI_SIGNAL_TYPES, e as BUI_QUERY_KEYS, vt as EPISODE_MIN_MS, yt as EPISODE_RELEASE_MS, bt as EpisodeTracker, xt as GAZE_AWAY_YAW_RATIO, Je as LIKE_EMOJI, St as LOCKDOWN_SIGNAL_TYPE, Ct as NoiseFloor, wt as SIGNAL_LABELS, Nt as accessibilityKeys, t as buiQuery, Ye as buildCommentTree, At as buildCredentialLinks, n as clearGraphqlReadCaches, Xe as countComments, Tt as estimateYawRatio,
|
|
13
|
+
import { MEDIA_POLL_MS as Lt, exportToBlob as Rt, isMediaInProgress as zt, migrationKeys as Bt, saveExport as Vt, useBuiExportCourse as Ht, useBuiExportGradebook as Ut, useBuiImportCourse as Wt, useBuiMigrationJob as Gt, useBuiMigrationJobs as Kt, useBuiPreviewCourseImport as qt } from "./useBuiMigration.js";
|
|
14
|
+
import { interactiveKeys as Jt, useBuiAttachInteractivePackage as Yt, useBuiDetachInteractivePackage as Xt, useBuiExportInteractiveActivity as Zt, useBuiInteractiveActivityDraft as Qt, useBuiInteractivePlayer as $t, useBuiLessonInteractivePackage as en, useBuiMyInteractiveAttempts as tn, useBuiPreviewInteractiveAttempt as nn, useBuiSaveInteractiveActivity as rn, useBuiSetInteractivePassMark as an, useBuiSubmitMyInteractiveAttempt as on } from "./useBuiInteractive.js";
|
|
15
|
+
import { useMintScimToken as sn, useRevokeScimToken as cn, useScimBaseUrl as ln, useScimTokens as un } from "./useScimProvisioning.js";
|
|
16
|
+
import { fetchAllPages as dn, useBuiCourseChoices as fn, useBuiInsertLearningObject as pn, useBuiLearningObject as mn, useBuiLearningObjects as hn, useBuiPublishLearningObjectVersion as gn, useBuiRepositorySources as _n, useBuiSaveToRepository as vn, useBuiSetLearningObjectArchived as yn, useBuiUpdateLearningObject as bn } from "./useBuiLearningObjects.js";
|
|
17
|
+
export { _t as AI_SIGNAL_TYPES, e as BUI_QUERY_KEYS, vt as EPISODE_MIN_MS, yt as EPISODE_RELEASE_MS, bt as EpisodeTracker, xt as GAZE_AWAY_YAW_RATIO, Je as LIKE_EMOJI, St as LOCKDOWN_SIGNAL_TYPE, Lt as MEDIA_POLL_MS, Ct as NoiseFloor, wt as SIGNAL_LABELS, Nt as accessibilityKeys, t as buiQuery, Ye as buildCommentTree, At as buildCredentialLinks, n as clearGraphqlReadCaches, Xe as countComments, Tt as estimateYawRatio, Rt as exportToBlob, dn as fetchAllPages, Et as formatEpisodeDuration, jt as gatewayOrigin, Mt as hasCheckableContent, Jt as interactiveKeys, Dt as isLookingAway, zt as isMediaInProgress, ht as isProctoringSessionActive, Ze as likeState, Bt as migrationKeys, gt as proctoringStep, Vt as saveExport, Ot as speechBandLevelDb, kt as toBatches, r as useBuiAdminCopilotActions, i as useBuiAdminCopilotAsk, a as useBuiAdminCopilotDismissAction, o as useBuiAdminCopilotExecuteAction, s as useBuiAiSettings, c as useBuiAllMyEnrollments, l as useBuiApplyAssessmentDraft, u as useBuiApplyCourseOutline, d as useBuiArchiveAssessment, f as useBuiArchiveCourse, p as useBuiAssessment, m as useBuiAssessments, Yt as useBuiAttachInteractivePackage, h as useBuiAutoScoreSubmission, g as useBuiAutomationRuns, _ as useBuiAutomations, v as useBuiAwardBadge, y as useBuiBadgeAwards, b as useBuiBadges, x as useBuiCertificates, S as useBuiCertifications, Pt as useBuiCheckContentAccessibility, C as useBuiCohorts, Qe as useBuiComments, w as useBuiCompleteLtiDeepLink, T as useBuiCompleteLtiLink, E as useBuiCompleteMyEnrollment, D as useBuiConfigureAutomation, O as useBuiCourse, Ft as useBuiCourseAccessibilityReport, k as useBuiCourseAssistantSettings, fn as useBuiCourseChoices, A as useBuiCourses, j as useBuiCreateAssessment, M as useBuiCreateBadge, N as useBuiCreateCohort, P as useBuiCreateCourse, F as useBuiCreateCourseTeacher, I as useBuiCreateLesson, L as useBuiCreateModule, R as useBuiCreateQuestion, z as useBuiCreateSkill, B as useBuiDeactivateLtiPlatform, Xt as useBuiDetachInteractivePackage, V as useBuiEnroll, H as useBuiEnrollments, Ht as useBuiExportCourse, Ut as useBuiExportGradebook, Zt as useBuiExportInteractiveActivity, Ge as useBuiFileUpload, U as useBuiGradeSubmission, Wt as useBuiImportCourse, pn as useBuiInsertLearningObject, Qt as useBuiInteractiveActivityDraft, $t as useBuiInteractivePlayer, W as useBuiIssueCertificate, mn as useBuiLearningObject, hn as useBuiLearningObjects, en as useBuiLessonInteractivePackage, G as useBuiLessons, K as useBuiLoadDemoContent, q as useBuiLtiGradeSyncs, J as useBuiLtiLaunchContext, Y as useBuiLtiPlatforms, X as useBuiLtiResourceLinks, Z as useBuiLtiRoster, Gt as useBuiMigrationJob, Kt as useBuiMigrationJobs, Q as useBuiModules, $ as useBuiMyBadgeAwards, ee as useBuiMyCertificates, te as useBuiMyEnrollment, ne as useBuiMyEnrollments, tn as useBuiMyInteractiveAttempts, re as useBuiMyLearnerProfile, st as useBuiMyProctoringSession, ie as useBuiMySavedCourses, ae as useBuiMySubmissions, oe as useBuiMyTutorSessions, se as useBuiOnboardingStatus, ce as useBuiPathCatalogCourses, le as useBuiPathCatalogSkills, ot as useBuiPermissions, qt as useBuiPreviewCourseImport, nn as useBuiPreviewInteractiveAttempt, ct as useBuiProctoringIdentityFile, lt as useBuiProctoringSessionSignals, ut as useBuiProctoringSessions, ue as useBuiPublishAssessment, de as useBuiPublishCourse, gn as useBuiPublishLearningObjectVersion, fe as useBuiRecommendPaths, pe as useBuiRecordMyLessonProgress, dt as useBuiRecordProctoringSignals, me as useBuiRegisterLtiPlatform, he as useBuiRemoveDemoContent, _n as useBuiRepositorySources, ge as useBuiReviewGradeSuggestion, _e as useBuiReviewNextLessonSuggestion, ft as useBuiReviewProctoringSession, ve as useBuiReviewTutorAnswer, ye as useBuiRevokeBadgeAward, be as useBuiRevokeCertificate, xe as useBuiRunAutomationNow, rn as useBuiSaveInteractiveActivity, vn as useBuiSaveToRepository, Se as useBuiSetBadgeArchived, Ce as useBuiSetCourseAssistant, an as useBuiSetInteractivePassMark, yn as useBuiSetLearningObjectArchived, we as useBuiSkills, pt as useBuiStartProctoringSession, Te as useBuiSubmission, Ee as useBuiSubmissions, De as useBuiSubmitAssessment, on as useBuiSubmitMyInteractiveAttempt, Oe as useBuiSubmitPathFinder, mt as useBuiSubmitProctoringIdentity, ke as useBuiSuggestAssessmentDraft, Ae as useBuiSuggestCourseOutline, je as useBuiSuggestGrade, Me as useBuiSuggestNextLesson, Ne as useBuiSuggestSkillMappings, Pe as useBuiSyncLtiGrade, Fe as useBuiSyncLtiRoster, $e as useBuiToggleCommentLike, Ie as useBuiToggleSavedCourse, Le as useBuiTutorAsk, Re as useBuiTutorMode, ze as useBuiTutorReviewSessions, Be as useBuiUpdateAiSettings, Ve as useBuiUpdateBadge, He as useBuiUpdateCourse, bn as useBuiUpdateLearningObject, It as useDebouncedValue, tt as useEcoAssignTag, nt as useEcoCreateAndAssignTag, et as useEcoCreateComment, rt as useEcoEntityTags, Ke as useEcoFile, it as useEcoRemoveTagAssignment, at as useEcoTagSearch, Ue as useGateway, sn as useMintScimToken, We as useOffsetPager, cn as useRevokeScimToken, ln as useScimBaseUrl, un as useScimTokens, qe as wspaceFetch };
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* - `buiExportCourse(courseId, format)` / `buiExportCourseGradebook(courseId)`
|
|
10
10
|
* — open-standards exports, returned inline as base64.
|
|
11
11
|
* - `buiMigrationJobs` — the migration audit trail.
|
|
12
|
+
* - `buiMigrationJob(id)` — one job, polled while an import's media files
|
|
13
|
+
* upload in the background (BOFF-10581).
|
|
12
14
|
*
|
|
13
15
|
* Packages are uploaded PRIVATE through the platform file flow
|
|
14
16
|
* (`useBuiFileUpload`), so only the uploader can import them.
|
|
@@ -29,9 +31,24 @@ export interface BuiMigrationStats {
|
|
|
29
31
|
assessmentCount: number;
|
|
30
32
|
questionCount: number;
|
|
31
33
|
skippedCount: number;
|
|
34
|
+
/** Media files an import uploads to Files after writing the course (BOFF-10581). */
|
|
35
|
+
mediaFileCount: number;
|
|
32
36
|
rowCount: number;
|
|
33
37
|
byteSize: number;
|
|
34
38
|
}
|
|
39
|
+
export type BuiMigrationMediaStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'PARTIAL' | 'FAILED';
|
|
40
|
+
/** Where the background media upload of an import stands. */
|
|
41
|
+
export interface BuiMigrationMediaProgress {
|
|
42
|
+
status: BuiMigrationMediaStatus;
|
|
43
|
+
total: number;
|
|
44
|
+
uploaded: number;
|
|
45
|
+
failed: number;
|
|
46
|
+
pending: number;
|
|
47
|
+
}
|
|
48
|
+
/** True while an import's media files are still being uploaded. */
|
|
49
|
+
export declare const isMediaInProgress: (media: BuiMigrationMediaProgress | null | undefined) => boolean;
|
|
50
|
+
/** How often the Migration Center re-reads a job whose media is still uploading. */
|
|
51
|
+
export declare const MEDIA_POLL_MS = 4000;
|
|
35
52
|
export interface BuiMigrationJob {
|
|
36
53
|
id: string;
|
|
37
54
|
kind: BuiMigrationJobKind;
|
|
@@ -46,6 +63,8 @@ export interface BuiMigrationJob {
|
|
|
46
63
|
issues: BuiMigrationIssue[];
|
|
47
64
|
createdAt: string;
|
|
48
65
|
createdBy: string;
|
|
66
|
+
/** Null when the import had no media to upload (and for exports). */
|
|
67
|
+
media: BuiMigrationMediaProgress | null;
|
|
49
68
|
}
|
|
50
69
|
export interface BuiCourseImportPreview {
|
|
51
70
|
fileName: string;
|
|
@@ -75,6 +94,7 @@ export interface BuiMigrationExport {
|
|
|
75
94
|
}
|
|
76
95
|
export declare const migrationKeys: {
|
|
77
96
|
jobs: (offset: number) => readonly ["buildmyiq", "migrationJobs", number];
|
|
97
|
+
job: (id: string) => readonly ["buildmyiq", "migrationJobs", "job", string];
|
|
78
98
|
allJobs: readonly ["buildmyiq", "migrationJobs"];
|
|
79
99
|
};
|
|
80
100
|
export declare const MIGRATION_JOBS_PAGE_SIZE = 20;
|
|
@@ -85,6 +105,11 @@ export declare const useBuiMigrationJobs: (offset?: number) => import('@tanstack
|
|
|
85
105
|
hasMore: boolean;
|
|
86
106
|
};
|
|
87
107
|
}, Error>;
|
|
108
|
+
/**
|
|
109
|
+
* One migration job, re-read every few seconds while its media files are
|
|
110
|
+
* still uploading and left alone once the upload has finished.
|
|
111
|
+
*/
|
|
112
|
+
export declare const useBuiMigrationJob: (id: string | null) => import('@tanstack/react-query').UseQueryResult<BuiMigrationJob | null, Error>;
|
|
88
113
|
/** Reads an uploaded package and describes the import. Read-only on the server. */
|
|
89
114
|
export declare const useBuiPreviewCourseImport: () => import('@tanstack/react-query').UseMutationResult<BuiCourseImportPreview, Error, string, unknown>;
|
|
90
115
|
export interface BuiImportCourseInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuiMigration.d.ts","sourceRoot":"","sources":["../../../src/buildmyiq/hooks/useBuiMigration.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useBuiMigration.d.ts","sourceRoot":"","sources":["../../../src/buildmyiq/hooks/useBuiMigration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AACrE,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,eAAe,GAAG,kBAAkB,CAAC;AACzF,MAAM,MAAM,kBAAkB,GAC5B,kBAAkB,GAAG,eAAe,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,yBAAyB,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjG,6DAA6D;AAC7D,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd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KAC/D,IAKF,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,UAAU,GACrB,UAAU,IAAI,CAAC,kBAAkB,EAAE,eAAe,GAAG,UAAU,GAAG,UAAU,CAAC,KAC5E,IAcF,CAAC"}
|
|
@@ -2,73 +2,89 @@ import { useBuiRequestScope as e } from "./requestScope.js";
|
|
|
2
2
|
import { wspaceFetch as t } from "./useBuiFiles.js";
|
|
3
3
|
import { useMutation as n, useQuery as r, useQueryClient as i } from "@tanstack/react-query";
|
|
4
4
|
//#region src/buildmyiq/hooks/useBuiMigration.ts
|
|
5
|
-
var a = "stats { moduleCount lessonCount assessmentCount questionCount skippedCount rowCount byteSize }",
|
|
5
|
+
var a = (e) => e?.status === "PENDING" || e?.status === "RUNNING", o = 4e3, s = "stats { moduleCount lessonCount assessmentCount questionCount skippedCount mediaFileCount rowCount byteSize }", c = "issues { severity code message ref }", l = `
|
|
6
6
|
id kind status format sourceSystem fileId fileName courseId courseTitle createdAt createdBy
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
|
|
7
|
+
${s}
|
|
8
|
+
${c}
|
|
9
|
+
media { status total uploaded failed pending }
|
|
10
|
+
`, u = `fileName mimeType contentBase64 byteSize job { ${l} }`, d = {
|
|
10
11
|
jobs: (e) => [
|
|
11
12
|
"buildmyiq",
|
|
12
13
|
"migrationJobs",
|
|
13
14
|
e
|
|
14
15
|
],
|
|
16
|
+
job: (e) => [
|
|
17
|
+
"buildmyiq",
|
|
18
|
+
"migrationJobs",
|
|
19
|
+
"job",
|
|
20
|
+
e
|
|
21
|
+
],
|
|
15
22
|
allJobs: ["buildmyiq", "migrationJobs"]
|
|
16
|
-
},
|
|
23
|
+
}, f = (n = 0) => {
|
|
17
24
|
let i = e();
|
|
18
25
|
return r({
|
|
19
|
-
queryKey:
|
|
26
|
+
queryKey: d.jobs(n),
|
|
20
27
|
queryFn: async () => {
|
|
21
28
|
let e = n > 0 ? {
|
|
22
29
|
limit: 20,
|
|
23
30
|
offset: n
|
|
24
31
|
} : { limit: 20 };
|
|
25
32
|
return (await t(`query BuiMigrationJobs($pagination: PaginationInput) {
|
|
26
|
-
buiMigrationJobs(pagination: $pagination) { items { ${
|
|
33
|
+
buiMigrationJobs(pagination: $pagination) { items { ${l} } pageInfo { hasMore } }
|
|
27
34
|
}`, { pagination: e }, i)).buiMigrationJobs;
|
|
28
|
-
}
|
|
35
|
+
},
|
|
36
|
+
refetchInterval: (e) => e.state.data?.items.some((e) => a(e.media)) ? o : !1
|
|
29
37
|
});
|
|
30
|
-
},
|
|
38
|
+
}, p = (n) => {
|
|
39
|
+
let i = e();
|
|
40
|
+
return r({
|
|
41
|
+
queryKey: d.job(n ?? ""),
|
|
42
|
+
enabled: !!n,
|
|
43
|
+
queryFn: async () => (await t(`query BuiMigrationJob($id: ID!) { buiMigrationJob(id: $id) { ${l} } }`, { id: n }, i)).buiMigrationJob,
|
|
44
|
+
refetchInterval: (e) => a(e.state.data?.media) ? o : !1
|
|
45
|
+
});
|
|
46
|
+
}, m = () => {
|
|
31
47
|
let r = e();
|
|
32
48
|
return n({ mutationFn: async (e) => (await t(`query BuiPreviewCourseImport($fileId: ID!) {
|
|
33
49
|
buiPreviewCourseImport(fileId: $fileId) {
|
|
34
50
|
fileName format sourceSystem standardVersion title description canImport
|
|
35
|
-
${
|
|
51
|
+
${s}
|
|
36
52
|
modules { title items { title kind detail } }
|
|
37
|
-
${
|
|
53
|
+
${c}
|
|
38
54
|
}
|
|
39
55
|
}`, { fileId: e }, r)).buiPreviewCourseImport });
|
|
40
|
-
},
|
|
56
|
+
}, h = () => {
|
|
41
57
|
let r = e(), a = i();
|
|
42
58
|
return n({
|
|
43
59
|
mutationFn: async (e) => (await t(`mutation BuiImportCourse($input: BuiImportCourseInput!) {
|
|
44
|
-
buiImportCourse(input: $input) { job { ${
|
|
60
|
+
buiImportCourse(input: $input) { job { ${l} } course { id title slug } }
|
|
45
61
|
}`, { input: e }, r)).buiImportCourse,
|
|
46
62
|
onSettled: async () => {
|
|
47
|
-
await Promise.all([a.invalidateQueries({ queryKey:
|
|
63
|
+
await Promise.all([a.invalidateQueries({ queryKey: d.allJobs }), a.invalidateQueries({ queryKey: ["buildmyiq", "courses"] })]);
|
|
48
64
|
}
|
|
49
65
|
});
|
|
50
|
-
},
|
|
66
|
+
}, g = () => {
|
|
51
67
|
let r = e(), a = i();
|
|
52
68
|
return n({
|
|
53
69
|
mutationFn: async (e) => (await t(`mutation BuiExportCourse($courseId: ID!, $format: BuiCourseExportFormat!) {
|
|
54
|
-
buiExportCourse(courseId: $courseId, format: $format) { ${
|
|
70
|
+
buiExportCourse(courseId: $courseId, format: $format) { ${u} }
|
|
55
71
|
}`, e, r)).buiExportCourse,
|
|
56
|
-
onSuccess: () => a.invalidateQueries({ queryKey:
|
|
72
|
+
onSuccess: () => a.invalidateQueries({ queryKey: d.allJobs })
|
|
57
73
|
});
|
|
58
|
-
},
|
|
74
|
+
}, _ = () => {
|
|
59
75
|
let r = e(), a = i();
|
|
60
76
|
return n({
|
|
61
77
|
mutationFn: async (e) => (await t(`mutation BuiExportCourseGradebook($courseId: ID!) {
|
|
62
|
-
buiExportCourseGradebook(courseId: $courseId) { ${
|
|
78
|
+
buiExportCourseGradebook(courseId: $courseId) { ${u} }
|
|
63
79
|
}`, { courseId: e }, r)).buiExportCourseGradebook,
|
|
64
|
-
onSuccess: () => a.invalidateQueries({ queryKey:
|
|
80
|
+
onSuccess: () => a.invalidateQueries({ queryKey: d.allJobs })
|
|
65
81
|
});
|
|
66
|
-
},
|
|
82
|
+
}, v = (e) => {
|
|
67
83
|
let t = atob(e.contentBase64), n = new Uint8Array(t.length);
|
|
68
84
|
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
69
85
|
return new Blob([n], { type: e.mimeType });
|
|
70
|
-
},
|
|
71
|
-
let t = URL.createObjectURL(
|
|
86
|
+
}, y = (e) => {
|
|
87
|
+
let t = URL.createObjectURL(v(e));
|
|
72
88
|
try {
|
|
73
89
|
let n = document.createElement("a");
|
|
74
90
|
n.href = t, n.download = e.fileName, n.rel = "noopener", document.body.appendChild(n), n.click(), n.remove();
|
|
@@ -77,6 +93,6 @@ var a = "stats { moduleCount lessonCount assessmentCount questionCount skippedCo
|
|
|
77
93
|
}
|
|
78
94
|
};
|
|
79
95
|
//#endregion
|
|
80
|
-
export {
|
|
96
|
+
export { o as MEDIA_POLL_MS, v as exportToBlob, a as isMediaInProgress, d as migrationKeys, y as saveExport, g as useBuiExportCourse, _ as useBuiExportGradebook, h as useBuiImportCourse, p as useBuiMigrationJob, f as useBuiMigrationJobs, m as useBuiPreviewCourseImport };
|
|
81
97
|
|
|
82
98
|
//# sourceMappingURL=useBuiMigration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuiMigration.js","names":[],"sources":["../../../src/buildmyiq/hooks/useBuiMigration.ts"],"sourcesContent":["/**\n * Buildmyiq — course migration hooks (BOFF-4437).\n * @module buildmyiq/hooks/useBuiMigration\n *\n * Transport for the Migration Center:\n * - `buiPreviewCourseImport(fileId)` — what importing a Common Cartridge or Moodle\n * backup would create, with every skipped or converted item. Writes nothing.\n * - `buiImportCourse(input)` — imports the package as a new DRAFT course.\n * - `buiExportCourse(courseId, format)` / `buiExportCourseGradebook(courseId)`\n * — open-standards exports, returned inline as base64.\n * - `buiMigrationJobs` — the migration audit trail.\n *\n * Packages are uploaded PRIVATE through the platform file flow\n * (`useBuiFileUpload`), so only the uploader can import them.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { useBuiRequestScope } from './requestScope';\nimport { wspaceFetch } from './useBuiFiles';\n\nexport type BuiMigrationIssueSeverity = 'INFO' | 'WARNING' | 'ERROR';\nexport type BuiMigrationJobKind = 'COURSE_IMPORT' | 'COURSE_EXPORT' | 'GRADEBOOK_EXPORT';\nexport type BuiMigrationFormat =\n 'COMMON_CARTRIDGE' | 'MOODLE_BACKUP' | 'BUILDMYIQ_JSON' | 'GRADEBOOK_CSV';\nexport type BuiCourseExportFormat = 'COMMON_CARTRIDGE' | 'BUILDMYIQ_JSON';\n\nexport interface BuiMigrationIssue {\n severity: BuiMigrationIssueSeverity;\n code: string;\n message: string;\n ref: string | null;\n}\n\nexport interface BuiMigrationStats {\n moduleCount: number;\n lessonCount: number;\n assessmentCount: number;\n questionCount: number;\n skippedCount: number;\n rowCount: number;\n byteSize: number;\n}\n\nexport interface BuiMigrationJob {\n id: string;\n kind: BuiMigrationJobKind;\n status: 'COMPLETED' | 'FAILED';\n format: BuiMigrationFormat;\n sourceSystem: string | null;\n fileId: string | null;\n fileName: string | null;\n courseId: string | null;\n courseTitle: string | null;\n stats: BuiMigrationStats;\n issues: BuiMigrationIssue[];\n createdAt: string;\n createdBy: string;\n}\n\nexport interface BuiCourseImportPreview {\n fileName: string;\n format: BuiMigrationFormat;\n sourceSystem: string | null;\n standardVersion: string | null;\n title: string;\n description: string | null;\n stats: BuiMigrationStats;\n modules: Array<{ title: string; items: Array<{ title: string; kind: string; detail: string }> }>;\n issues: BuiMigrationIssue[];\n canImport: boolean;\n}\n\nexport interface BuiMigrationExport {\n job: BuiMigrationJob;\n fileName: string;\n mimeType: string;\n contentBase64: string;\n byteSize: number;\n}\n\nconst STATS_FIELDS = `stats { moduleCount lessonCount assessmentCount questionCount skippedCount rowCount byteSize }`;\nconst ISSUE_FIELDS = `issues { severity code message ref }`;\nconst JOB_FIELDS = `\n id kind status format sourceSystem fileId fileName courseId courseTitle createdAt createdBy\n ${STATS_FIELDS}\n ${ISSUE_FIELDS}\n`;\nconst EXPORT_FIELDS = `fileName mimeType contentBase64 byteSize job { ${JOB_FIELDS} }`;\n\nexport const migrationKeys = {\n jobs: (offset: number) => ['buildmyiq', 'migrationJobs', offset] as const,\n allJobs: ['buildmyiq', 'migrationJobs'] as const,\n};\n\nexport const MIGRATION_JOBS_PAGE_SIZE = 20;\n\n/** The migration audit trail, newest first, one page at a time. */\nexport const useBuiMigrationJobs = (offset = 0) => {\n const apiGatewayUrl = useBuiRequestScope();\n return useQuery({\n queryKey: migrationKeys.jobs(offset),\n queryFn: async () => {\n const pagination =\n offset > 0\n ? { limit: MIGRATION_JOBS_PAGE_SIZE, offset }\n : { limit: MIGRATION_JOBS_PAGE_SIZE };\n const data = await wspaceFetch<{\n buiMigrationJobs: { items: BuiMigrationJob[]; pageInfo: { hasMore: boolean } };\n }>(\n `query BuiMigrationJobs($pagination: PaginationInput) {\n buiMigrationJobs(pagination: $pagination) { items { ${JOB_FIELDS} } pageInfo { hasMore } }\n }`,\n { pagination },\n apiGatewayUrl\n );\n return data.buiMigrationJobs;\n },\n });\n};\n\n/** Reads an uploaded package and describes the import. Read-only on the server. */\nexport const useBuiPreviewCourseImport = () => {\n const apiGatewayUrl = useBuiRequestScope();\n return useMutation({\n mutationFn: async (fileId: string) => {\n const data = await wspaceFetch<{ buiPreviewCourseImport: BuiCourseImportPreview }>(\n `query BuiPreviewCourseImport($fileId: ID!) {\n buiPreviewCourseImport(fileId: $fileId) {\n fileName format sourceSystem standardVersion title description canImport\n ${STATS_FIELDS}\n modules { title items { title kind detail } }\n ${ISSUE_FIELDS}\n }\n }`,\n { fileId },\n apiGatewayUrl\n );\n return data.buiPreviewCourseImport;\n },\n });\n};\n\nexport interface BuiImportCourseInput {\n fileId: string;\n title?: string;\n}\n\n/** Imports the package as a new draft course. */\nexport const useBuiImportCourse = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: BuiImportCourseInput) => {\n const data = await wspaceFetch<{\n buiImportCourse: {\n job: BuiMigrationJob;\n course: { id: string; title: string; slug: string };\n };\n }>(\n `mutation BuiImportCourse($input: BuiImportCourseInput!) {\n buiImportCourse(input: $input) { job { ${JOB_FIELDS} } course { id title slug } }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.buiImportCourse;\n },\n onSettled: async () => {\n // A failed import is recorded too, so the audit trail changes either way.\n await Promise.all([\n qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n qc.invalidateQueries({ queryKey: ['buildmyiq', 'courses'] }),\n ]);\n },\n });\n};\n\n/** Exports a course as Common Cartridge or BuildMyIQ JSON. */\nexport const useBuiExportCourse = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (args: { courseId: string; format: BuiCourseExportFormat }) => {\n const data = await wspaceFetch<{ buiExportCourse: BuiMigrationExport }>(\n `mutation BuiExportCourse($courseId: ID!, $format: BuiCourseExportFormat!) {\n buiExportCourse(courseId: $courseId, format: $format) { ${EXPORT_FIELDS} }\n }`,\n args,\n apiGatewayUrl\n );\n return data.buiExportCourse;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n });\n};\n\n/** Exports a course's gradebook as CSV. */\nexport const useBuiExportGradebook = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (courseId: string) => {\n const data = await wspaceFetch<{ buiExportCourseGradebook: BuiMigrationExport }>(\n `mutation BuiExportCourseGradebook($courseId: ID!) {\n buiExportCourseGradebook(courseId: $courseId) { ${EXPORT_FIELDS} }\n }`,\n { courseId },\n apiGatewayUrl\n );\n return data.buiExportCourseGradebook;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n });\n};\n\n/** Decode an inline export into a Blob. */\nexport const exportToBlob = (\n exported: Pick<BuiMigrationExport, 'contentBase64' | 'mimeType'>\n): Blob => {\n const binary = atob(exported.contentBase64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return new Blob([bytes], { type: exported.mimeType });\n};\n\n/** Save an inline export to the user's device. */\nexport const saveExport = (\n exported: Pick<BuiMigrationExport, 'contentBase64' | 'mimeType' | 'fileName'>\n): void => {\n const url = URL.createObjectURL(exportToBlob(exported));\n try {\n const anchor = document.createElement('a');\n anchor.href = url;\n anchor.download = exported.fileName;\n anchor.rel = 'noopener';\n document.body.appendChild(anchor);\n anchor.click();\n anchor.remove();\n } finally {\n // Give the browser a moment to start the download before revoking.\n window.setTimeout(() => URL.revokeObjectURL(url), 10_000);\n }\n};\n"],"mappings":";;;;AAiFA,IAAM,IAAe,kGACf,IAAe,wCACf,IAAa;;IAEf,EAAa;IACb,EAAa;GAEX,IAAgB,kDAAkD,EAAW,KAEtE,IAAgB;CAC3B,OAAO,MAAmB;EAAC;EAAa;EAAiB;CAAM;CAC/D,SAAS,CAAC,aAAa,eAAe;AACxC,GAKa,KAAuB,IAAS,MAAM;CACjD,IAAM,IAAgB,EAAmB;CACzC,OAAO,EAAS;EACd,UAAU,EAAc,KAAK,CAAM;EACnC,SAAS,YAAY;GACnB,IAAM,IACJ,IAAS,IACL;IAAE,OAAA;IAAiC;GAAO,IAC1C,EAAE,OAAA,GAAgC;GAUxC,QAAO,MATY,EAGjB;gEACwD,EAAW;YAEnE,EAAE,cAAW,GACb,CACF,EAAA,CACY;EACd;CACF,CAAC;AACH,GAGa,UAAkC;CAC7C,IAAM,IAAgB,EAAmB;CACzC,OAAO,EAAY,EACjB,YAAY,OAAO,OAaV,MAZY,EACjB;;;cAGM,EAAa;;cAEb,EAAa;;YAGnB,EAAE,UAAO,GACT,CACF,EAAA,CACY,uBAEhB,CAAC;AACH,GAQa,UAA2B;CACtC,IAAM,IAAgB,EAAmB,GACnC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAaV,MAZY,EAMjB;mDAC2C,EAAW;YAEtD,EAAE,SAAM,GACR,CACF,EAAA,CACY;EAEd,WAAW,YAAY;GAErB,MAAM,QAAQ,IAAI,CAChB,EAAG,kBAAkB,EAAE,UAAU,EAAc,QAAQ,CAAC,GACxD,EAAG,kBAAkB,EAAE,UAAU,CAAC,aAAa,SAAS,EAAE,CAAC,CAC7D,CAAC;EACH;CACF,CAAC;AACH,GAGa,UAA2B;CACtC,IAAM,IAAgB,EAAmB,GACnC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPY,EACjB;oEAC4D,EAAc;YAE1E,GACA,CACF,EAAA,CACY;EAEd,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAc,QAAQ,CAAC;CAC3E,CAAC;AACH,GAGa,UAA8B;CACzC,IAAM,IAAgB,EAAmB,GACnC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPY,EACjB;4DACoD,EAAc;YAElE,EAAE,YAAS,GACX,CACF,EAAA,CACY;EAEd,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAc,QAAQ,CAAC;CAC3E,CAAC;AACH,GAGa,KACX,MACS;CACT,IAAM,IAAS,KAAK,EAAS,aAAa,GACpC,IAAQ,IAAI,WAAW,EAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAO,QAAQ,KAAK,EAAM,KAAK,EAAO,WAAW,CAAC;CACtE,OAAO,IAAI,KAAK,CAAC,CAAK,GAAG,EAAE,MAAM,EAAS,SAAS,CAAC;AACtD,GAGa,KACX,MACS;CACT,IAAM,IAAM,IAAI,gBAAgB,EAAa,CAAQ,CAAC;CACtD,IAAI;EACF,IAAM,IAAS,SAAS,cAAc,GAAG;EAMzC,AALA,EAAO,OAAO,GACd,EAAO,WAAW,EAAS,UAC3B,EAAO,MAAM,YACb,SAAS,KAAK,YAAY,CAAM,GAChC,EAAO,MAAM,GACb,EAAO,OAAO;CAChB,UAAU;EAER,OAAO,iBAAiB,IAAI,gBAAgB,CAAG,GAAG,GAAM;CAC1D;AACF"}
|
|
1
|
+
{"version":3,"file":"useBuiMigration.js","names":[],"sources":["../../../src/buildmyiq/hooks/useBuiMigration.ts"],"sourcesContent":["/**\n * Buildmyiq — course migration hooks (BOFF-4437).\n * @module buildmyiq/hooks/useBuiMigration\n *\n * Transport for the Migration Center:\n * - `buiPreviewCourseImport(fileId)` — what importing a Common Cartridge or Moodle\n * backup would create, with every skipped or converted item. Writes nothing.\n * - `buiImportCourse(input)` — imports the package as a new DRAFT course.\n * - `buiExportCourse(courseId, format)` / `buiExportCourseGradebook(courseId)`\n * — open-standards exports, returned inline as base64.\n * - `buiMigrationJobs` — the migration audit trail.\n * - `buiMigrationJob(id)` — one job, polled while an import's media files\n * upload in the background (BOFF-10581).\n *\n * Packages are uploaded PRIVATE through the platform file flow\n * (`useBuiFileUpload`), so only the uploader can import them.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { useBuiRequestScope } from './requestScope';\nimport { wspaceFetch } from './useBuiFiles';\n\nexport type BuiMigrationIssueSeverity = 'INFO' | 'WARNING' | 'ERROR';\nexport type BuiMigrationJobKind = 'COURSE_IMPORT' | 'COURSE_EXPORT' | 'GRADEBOOK_EXPORT';\nexport type BuiMigrationFormat =\n 'COMMON_CARTRIDGE' | 'MOODLE_BACKUP' | 'BUILDMYIQ_JSON' | 'GRADEBOOK_CSV';\nexport type BuiCourseExportFormat = 'COMMON_CARTRIDGE' | 'BUILDMYIQ_JSON';\n\nexport interface BuiMigrationIssue {\n severity: BuiMigrationIssueSeverity;\n code: string;\n message: string;\n ref: string | null;\n}\n\nexport interface BuiMigrationStats {\n moduleCount: number;\n lessonCount: number;\n assessmentCount: number;\n questionCount: number;\n skippedCount: number;\n /** Media files an import uploads to Files after writing the course (BOFF-10581). */\n mediaFileCount: number;\n rowCount: number;\n byteSize: number;\n}\n\nexport type BuiMigrationMediaStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'PARTIAL' | 'FAILED';\n\n/** Where the background media upload of an import stands. */\nexport interface BuiMigrationMediaProgress {\n status: BuiMigrationMediaStatus;\n total: number;\n uploaded: number;\n failed: number;\n pending: number;\n}\n\n/** True while an import's media files are still being uploaded. */\nexport const isMediaInProgress = (media: BuiMigrationMediaProgress | null | undefined): boolean =>\n media?.status === 'PENDING' || media?.status === 'RUNNING';\n\n/** How often the Migration Center re-reads a job whose media is still uploading. */\nexport const MEDIA_POLL_MS = 4000;\n\nexport interface BuiMigrationJob {\n id: string;\n kind: BuiMigrationJobKind;\n status: 'COMPLETED' | 'FAILED';\n format: BuiMigrationFormat;\n sourceSystem: string | null;\n fileId: string | null;\n fileName: string | null;\n courseId: string | null;\n courseTitle: string | null;\n stats: BuiMigrationStats;\n issues: BuiMigrationIssue[];\n createdAt: string;\n createdBy: string;\n /** Null when the import had no media to upload (and for exports). */\n media: BuiMigrationMediaProgress | null;\n}\n\nexport interface BuiCourseImportPreview {\n fileName: string;\n format: BuiMigrationFormat;\n sourceSystem: string | null;\n standardVersion: string | null;\n title: string;\n description: string | null;\n stats: BuiMigrationStats;\n modules: Array<{ title: string; items: Array<{ title: string; kind: string; detail: string }> }>;\n issues: BuiMigrationIssue[];\n canImport: boolean;\n}\n\nexport interface BuiMigrationExport {\n job: BuiMigrationJob;\n fileName: string;\n mimeType: string;\n contentBase64: string;\n byteSize: number;\n}\n\nconst STATS_FIELDS = `stats { moduleCount lessonCount assessmentCount questionCount skippedCount mediaFileCount rowCount byteSize }`;\nconst ISSUE_FIELDS = `issues { severity code message ref }`;\nconst JOB_FIELDS = `\n id kind status format sourceSystem fileId fileName courseId courseTitle createdAt createdBy\n ${STATS_FIELDS}\n ${ISSUE_FIELDS}\n media { status total uploaded failed pending }\n`;\nconst EXPORT_FIELDS = `fileName mimeType contentBase64 byteSize job { ${JOB_FIELDS} }`;\n\nexport const migrationKeys = {\n jobs: (offset: number) => ['buildmyiq', 'migrationJobs', offset] as const,\n job: (id: string) => ['buildmyiq', 'migrationJobs', 'job', id] as const,\n allJobs: ['buildmyiq', 'migrationJobs'] as const,\n};\n\nexport const MIGRATION_JOBS_PAGE_SIZE = 20;\n\n/** The migration audit trail, newest first, one page at a time. */\nexport const useBuiMigrationJobs = (offset = 0) => {\n const apiGatewayUrl = useBuiRequestScope();\n return useQuery({\n queryKey: migrationKeys.jobs(offset),\n queryFn: async () => {\n const pagination =\n offset > 0\n ? { limit: MIGRATION_JOBS_PAGE_SIZE, offset }\n : { limit: MIGRATION_JOBS_PAGE_SIZE };\n const data = await wspaceFetch<{\n buiMigrationJobs: { items: BuiMigrationJob[]; pageInfo: { hasMore: boolean } };\n }>(\n `query BuiMigrationJobs($pagination: PaginationInput) {\n buiMigrationJobs(pagination: $pagination) { items { ${JOB_FIELDS} } pageInfo { hasMore } }\n }`,\n { pagination },\n apiGatewayUrl\n );\n return data.buiMigrationJobs;\n },\n // Keep the history live while an import's media is still uploading.\n refetchInterval: (query) =>\n query.state.data?.items.some((job) => isMediaInProgress(job.media)) ? MEDIA_POLL_MS : false,\n });\n};\n\n/**\n * One migration job, re-read every few seconds while its media files are\n * still uploading and left alone once the upload has finished.\n */\nexport const useBuiMigrationJob = (id: string | null) => {\n const apiGatewayUrl = useBuiRequestScope();\n return useQuery({\n queryKey: migrationKeys.job(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await wspaceFetch<{ buiMigrationJob: BuiMigrationJob | null }>(\n `query BuiMigrationJob($id: ID!) { buiMigrationJob(id: $id) { ${JOB_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.buiMigrationJob;\n },\n refetchInterval: (query) =>\n isMediaInProgress(query.state.data?.media) ? MEDIA_POLL_MS : false,\n });\n};\n\n/** Reads an uploaded package and describes the import. Read-only on the server. */\nexport const useBuiPreviewCourseImport = () => {\n const apiGatewayUrl = useBuiRequestScope();\n return useMutation({\n mutationFn: async (fileId: string) => {\n const data = await wspaceFetch<{ buiPreviewCourseImport: BuiCourseImportPreview }>(\n `query BuiPreviewCourseImport($fileId: ID!) {\n buiPreviewCourseImport(fileId: $fileId) {\n fileName format sourceSystem standardVersion title description canImport\n ${STATS_FIELDS}\n modules { title items { title kind detail } }\n ${ISSUE_FIELDS}\n }\n }`,\n { fileId },\n apiGatewayUrl\n );\n return data.buiPreviewCourseImport;\n },\n });\n};\n\nexport interface BuiImportCourseInput {\n fileId: string;\n title?: string;\n}\n\n/** Imports the package as a new draft course. */\nexport const useBuiImportCourse = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: BuiImportCourseInput) => {\n const data = await wspaceFetch<{\n buiImportCourse: {\n job: BuiMigrationJob;\n course: { id: string; title: string; slug: string };\n };\n }>(\n `mutation BuiImportCourse($input: BuiImportCourseInput!) {\n buiImportCourse(input: $input) { job { ${JOB_FIELDS} } course { id title slug } }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.buiImportCourse;\n },\n onSettled: async () => {\n // A failed import is recorded too, so the audit trail changes either way.\n await Promise.all([\n qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n qc.invalidateQueries({ queryKey: ['buildmyiq', 'courses'] }),\n ]);\n },\n });\n};\n\n/** Exports a course as Common Cartridge or BuildMyIQ JSON. */\nexport const useBuiExportCourse = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (args: { courseId: string; format: BuiCourseExportFormat }) => {\n const data = await wspaceFetch<{ buiExportCourse: BuiMigrationExport }>(\n `mutation BuiExportCourse($courseId: ID!, $format: BuiCourseExportFormat!) {\n buiExportCourse(courseId: $courseId, format: $format) { ${EXPORT_FIELDS} }\n }`,\n args,\n apiGatewayUrl\n );\n return data.buiExportCourse;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n });\n};\n\n/** Exports a course's gradebook as CSV. */\nexport const useBuiExportGradebook = () => {\n const apiGatewayUrl = useBuiRequestScope();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (courseId: string) => {\n const data = await wspaceFetch<{ buiExportCourseGradebook: BuiMigrationExport }>(\n `mutation BuiExportCourseGradebook($courseId: ID!) {\n buiExportCourseGradebook(courseId: $courseId) { ${EXPORT_FIELDS} }\n }`,\n { courseId },\n apiGatewayUrl\n );\n return data.buiExportCourseGradebook;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: migrationKeys.allJobs }),\n });\n};\n\n/** Decode an inline export into a Blob. */\nexport const exportToBlob = (\n exported: Pick<BuiMigrationExport, 'contentBase64' | 'mimeType'>\n): Blob => {\n const binary = atob(exported.contentBase64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return new Blob([bytes], { type: exported.mimeType });\n};\n\n/** Save an inline export to the user's device. */\nexport const saveExport = (\n exported: Pick<BuiMigrationExport, 'contentBase64' | 'mimeType' | 'fileName'>\n): void => {\n const url = URL.createObjectURL(exportToBlob(exported));\n try {\n const anchor = document.createElement('a');\n anchor.href = url;\n anchor.download = exported.fileName;\n anchor.rel = 'noopener';\n document.body.appendChild(anchor);\n anchor.click();\n anchor.remove();\n } finally {\n // Give the browser a moment to start the download before revoking.\n window.setTimeout(() => URL.revokeObjectURL(url), 10_000);\n }\n};\n"],"mappings":";;;;AA4DA,IAAa,KAAqB,MAChC,GAAO,WAAW,aAAa,GAAO,WAAW,WAGtC,IAAgB,KAyCvB,IAAe,iHACf,IAAe,wCACf,IAAa;;IAEf,EAAa;IACb,EAAa;;GAGX,IAAgB,kDAAkD,EAAW,KAEtE,IAAgB;CAC3B,OAAO,MAAmB;EAAC;EAAa;EAAiB;CAAM;CAC/D,MAAM,MAAe;EAAC;EAAa;EAAiB;EAAO;CAAE;CAC7D,SAAS,CAAC,aAAa,eAAe;AACxC,GAKa,KAAuB,IAAS,MAAM;CACjD,IAAM,IAAgB,EAAmB;CACzC,OAAO,EAAS;EACd,UAAU,EAAc,KAAK,CAAM;EACnC,SAAS,YAAY;GACnB,IAAM,IACJ,IAAS,IACL;IAAE,OAAA;IAAiC;GAAO,IAC1C,EAAE,OAAA,GAAgC;GAUxC,QAAO,MATY,EAGjB;gEACwD,EAAW;YAEnE,EAAE,cAAW,GACb,CACF,EAAA,CACY;EACd;EAEA,kBAAkB,MAChB,EAAM,MAAM,MAAM,MAAM,MAAM,MAAQ,EAAkB,EAAI,KAAK,CAAC,IAAI,IAAgB;CAC1F,CAA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EAEd,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAc,QAAQ,CAAC;CAC3E,CAAC;AACH,GAGa,KACX,MACS;CACT,IAAM,IAAS,KAAK,EAAS,aAAa,GACpC,IAAQ,IAAI,WAAW,EAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAO,QAAQ,KAAK,EAAM,KAAK,EAAO,WAAW,CAAC;CACtE,OAAO,IAAI,KAAK,CAAC,CAAK,GAAG,EAAE,MAAM,EAAS,SAAS,CAAC;AACtD,GAGa,KACX,MACS;CACT,IAAM,IAAM,IAAI,gBAAgB,EAAa,CAAQ,CAAC;CACtD,IAAI;EACF,IAAM,IAAS,SAAS,cAAc,GAAG;EAMzC,AALA,EAAO,OAAO,GACd,EAAO,WAAW,EAAS,UAC3B,EAAO,MAAM,YACb,SAAS,KAAK,YAAY,CAAM,GAChC,EAAO,MAAM,GACb,EAAO,OAAO;CAChB,UAAU;EAER,OAAO,iBAAiB,IAAI,gBAAgB,CAAG,GAAG,GAAM;CAC1D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationCenterPage.d.ts","sourceRoot":"","sources":["../../../../src/buildmyiq/pages/migration/MigrationCenterPage.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MigrationCenterPage.d.ts","sourceRoot":"","sources":["../../../../src/buildmyiq/pages/migration/MigrationCenterPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAuoB7C,eAAO,MAAM,mBAAmB,EAAE,EA0BjC,CAAC"}
|