@axiom-lattice/client-sdk 4.8.2 → 5.0.0
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/__tests__/export-import.test.js +39 -16
- package/dist/__tests__/export-import.test.js.map +1 -1
- package/dist/export-import.d.ts +11 -14
- package/dist/export-import.d.ts.map +1 -1
- package/dist/export-import.js +45 -30
- package/dist/export-import.js.map +1 -1
- package/dist/index.d.ts +12 -15
- package/dist/index.js +51 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3503,23 +3503,64 @@ var ExportImportClient = class {
|
|
|
3503
3503
|
}
|
|
3504
3504
|
return envelope.data;
|
|
3505
3505
|
}
|
|
3506
|
+
async postJson(url, body) {
|
|
3507
|
+
return fetch(`${this.baseURL}${url}`, {
|
|
3508
|
+
method: "POST",
|
|
3509
|
+
headers: {
|
|
3510
|
+
...this.headers,
|
|
3511
|
+
...this.headerProvider?.()
|
|
3512
|
+
},
|
|
3513
|
+
body: JSON.stringify(body)
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
async readArchive(response) {
|
|
3517
|
+
if (!response.ok) {
|
|
3518
|
+
const envelope = await response.json().catch(() => ({}));
|
|
3519
|
+
throw new Error(
|
|
3520
|
+
envelope.message || envelope.error || `HTTP error! Status: ${response.status}`
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
return {
|
|
3524
|
+
filename: attachmentFilename(response.headers.get("Content-Disposition")),
|
|
3525
|
+
data: new Uint8Array(await response.arrayBuffer())
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3506
3528
|
/** Returns all entity types registered for export. */
|
|
3507
3529
|
getExportableTypes() {
|
|
3508
3530
|
return this.request("/api/tenants/exportable-types");
|
|
3509
3531
|
}
|
|
3510
|
-
/**
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3532
|
+
/**
|
|
3533
|
+
* Runs an export and streams the archive back in the same request.
|
|
3534
|
+
* Returns a dependency-confirmation request instead when the selection
|
|
3535
|
+
* needs cascade additions the caller has not confirmed yet.
|
|
3536
|
+
*/
|
|
3537
|
+
async exportConfig(tenantId, entityTypes, entityIds) {
|
|
3538
|
+
const response = await this.postJson(`/api/tenants/${tenantId}/export`, {
|
|
3539
|
+
entityTypes,
|
|
3540
|
+
...entityIds ? { entityIds } : {}
|
|
3515
3541
|
});
|
|
3542
|
+
const contentType = (response.headers.get("Content-Type") ?? "").toLowerCase();
|
|
3543
|
+
if (!contentType.includes("application/json")) {
|
|
3544
|
+
return this.readArchive(response);
|
|
3545
|
+
}
|
|
3546
|
+
const envelope = await response.json().catch(() => ({}));
|
|
3547
|
+
if (!response.ok || envelope.success === false) {
|
|
3548
|
+
throw new Error(
|
|
3549
|
+
envelope.message || envelope.error || `HTTP error! Status: ${response.status}`
|
|
3550
|
+
);
|
|
3551
|
+
}
|
|
3552
|
+
if (envelope.data === void 0) {
|
|
3553
|
+
throw new Error(envelope.message || envelope.error || "API response contained no data");
|
|
3554
|
+
}
|
|
3555
|
+
return envelope.data;
|
|
3516
3556
|
}
|
|
3517
|
-
/**
|
|
3518
|
-
exportConfigConfirm(tenantId, entityTypes, entityIds) {
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3557
|
+
/** Runs an export after the caller confirmed dependency additions, streaming the archive back. */
|
|
3558
|
+
async exportConfigConfirm(tenantId, entityTypes, entityIds) {
|
|
3559
|
+
const response = await this.postJson(`/api/tenants/${tenantId}/export/confirm`, {
|
|
3560
|
+
entityTypes,
|
|
3561
|
+
...entityIds ? { entityIds } : {}
|
|
3522
3562
|
});
|
|
3563
|
+
return this.readArchive(response);
|
|
3523
3564
|
}
|
|
3524
3565
|
/** Lists selectable entities for the requested export types. */
|
|
3525
3566
|
previewEntities(tenantId, entityTypes) {
|
|
@@ -3528,33 +3569,6 @@ var ExportImportClient = class {
|
|
|
3528
3569
|
{ method: "POST", body: JSON.stringify({ entityTypes }) }
|
|
3529
3570
|
);
|
|
3530
3571
|
}
|
|
3531
|
-
/** Returns the gateway URL for an export download job. */
|
|
3532
|
-
getExportDownloadUrl(tenantId, jobId) {
|
|
3533
|
-
return `${this.baseURL}/api/tenants/${tenantId}/export/${jobId}/download`;
|
|
3534
|
-
}
|
|
3535
|
-
/** Downloads an export archive as raw bytes. */
|
|
3536
|
-
async downloadExport(tenantId, jobId) {
|
|
3537
|
-
const response = await fetch(
|
|
3538
|
-
`${this.baseURL}/api/tenants/${tenantId}/export/${jobId}/download`,
|
|
3539
|
-
{
|
|
3540
|
-
method: "GET",
|
|
3541
|
-
headers: {
|
|
3542
|
-
...this.headers,
|
|
3543
|
-
...this.headerProvider?.()
|
|
3544
|
-
}
|
|
3545
|
-
}
|
|
3546
|
-
);
|
|
3547
|
-
if (!response.ok) {
|
|
3548
|
-
const envelope = await response.json().catch(() => ({}));
|
|
3549
|
-
throw new Error(
|
|
3550
|
-
envelope.message || envelope.error || `HTTP error! Status: ${response.status}`
|
|
3551
|
-
);
|
|
3552
|
-
}
|
|
3553
|
-
return {
|
|
3554
|
-
filename: attachmentFilename(response.headers.get("Content-Disposition")),
|
|
3555
|
-
data: new Uint8Array(await response.arrayBuffer())
|
|
3556
|
-
};
|
|
3557
|
-
}
|
|
3558
3572
|
/** Previews an archive or plain JSON bundle import. */
|
|
3559
3573
|
async importPreview(tenantId, source) {
|
|
3560
3574
|
if (source.archive !== void 0) {
|