@finueva/drive 0.6.0 → 0.8.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/CHANGELOG.md +12 -0
- package/README.md +33 -6
- package/dist/client.d.ts +2 -2
- package/dist/client.js +324 -20
- package/dist/contract.d.ts +514 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +324 -20
- package/dist/server.d.ts +2 -2
- package/dist/server.js +195 -12
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -327,6 +327,101 @@ const MAX_UPLOAD_BYTE_LENGTH$1 = 33554432e4;
|
|
|
327
327
|
const UPLOAD_PART_BYTE_LENGTH$1 = 32 * 1024 * 1024;
|
|
328
328
|
const CONTENT_DIGEST$1 = /^sha256:[0-9a-f]{64}$/;
|
|
329
329
|
const UTF8 = new TextEncoder();
|
|
330
|
+
function isWorkspaceUsage(value) {
|
|
331
|
+
if (!isExactRecord(value, [
|
|
332
|
+
"workspaceId",
|
|
333
|
+
"provider",
|
|
334
|
+
"usedBytes",
|
|
335
|
+
"reservedBytes",
|
|
336
|
+
"limitBytes",
|
|
337
|
+
"availableBytes",
|
|
338
|
+
"accounting",
|
|
339
|
+
"reservedBytesIncludeUnresolvedUploads",
|
|
340
|
+
"unresolvedReservedBytes",
|
|
341
|
+
"warnings"
|
|
342
|
+
]) || typeof value.workspaceId !== "string" || !WORKSPACE_ID$1.test(value.workspaceId) || value.provider !== "managed" || value.accounting !== "current-versions-and-reservations" || value.reservedBytesIncludeUnresolvedUploads !== true || !Array.isArray(value.warnings) || value.warnings.length > 1 || value.warnings.some((warning) => warning !== "unresolved-archive-ownership") || ![
|
|
343
|
+
value.usedBytes,
|
|
344
|
+
value.reservedBytes,
|
|
345
|
+
value.limitBytes,
|
|
346
|
+
value.availableBytes,
|
|
347
|
+
value.unresolvedReservedBytes
|
|
348
|
+
].every((bytes) => typeof bytes === "string" && /^(0|[1-9][0-9]{0,18})$/.test(bytes))) return false;
|
|
349
|
+
const available = BigInt(value.limitBytes) - BigInt(value.usedBytes) - BigInt(value.reservedBytes);
|
|
350
|
+
const valid = BigInt(value.availableBytes) === (available > 0n ? available : 0n) && BigInt(value.unresolvedReservedBytes) <= BigInt(value.reservedBytes) && (value.unresolvedReservedBytes === "0" || value.warnings.length === 1);
|
|
351
|
+
if (valid) Object.freeze(value.warnings);
|
|
352
|
+
return valid;
|
|
353
|
+
}
|
|
354
|
+
function isWorkspaceDiscoveryPage(value) {
|
|
355
|
+
if (!isExactRecord(value, ["items", "nextCursor"]) || !Array.isArray(value.items) || value.items.length > 50 || !(value.nextCursor === null || typeof value.nextCursor === "string" && value.nextCursor.length > 0 && value.nextCursor.length <= 2048 && /^[A-Za-z0-9_.-]+$/.test(value.nextCursor)) || value.items.length === 0 && value.nextCursor !== null) return false;
|
|
356
|
+
const ids = new Set();
|
|
357
|
+
const valid = value.items.every((item) => {
|
|
358
|
+
if (!isExactRecord(item, [
|
|
359
|
+
"workspaceId",
|
|
360
|
+
"itemId",
|
|
361
|
+
"parentId",
|
|
362
|
+
"type",
|
|
363
|
+
"name",
|
|
364
|
+
"lifecycleState",
|
|
365
|
+
"revision",
|
|
366
|
+
"currentVersion",
|
|
367
|
+
"volumeId",
|
|
368
|
+
"provider",
|
|
369
|
+
"createdAtEpochMilliseconds",
|
|
370
|
+
"modifiedAtEpochMilliseconds",
|
|
371
|
+
"creatorUserId",
|
|
372
|
+
"etag",
|
|
373
|
+
"trashedAtEpochMilliseconds",
|
|
374
|
+
"purgeAfterEpochMilliseconds"
|
|
375
|
+
]) || item.lifecycleState !== "active" && item.lifecycleState !== "trashed" || typeof item.volumeId !== "string" || !VOLUME_ID.test(item.volumeId) || item.provider !== "managed" || item.creatorUserId !== null && (typeof item.creatorUserId !== "string" || !AUTH_ID$1.test(item.creatorUserId)) || ![
|
|
376
|
+
item.createdAtEpochMilliseconds,
|
|
377
|
+
item.modifiedAtEpochMilliseconds,
|
|
378
|
+
item.trashedAtEpochMilliseconds,
|
|
379
|
+
item.purgeAfterEpochMilliseconds
|
|
380
|
+
].every((date) => date === null || isSafeInteger$1(date))) return false;
|
|
381
|
+
const metadata = {
|
|
382
|
+
workspaceId: item.workspaceId,
|
|
383
|
+
itemId: item.itemId,
|
|
384
|
+
parentId: item.parentId,
|
|
385
|
+
type: item.type,
|
|
386
|
+
name: item.name,
|
|
387
|
+
lifecycleState: "active",
|
|
388
|
+
revision: item.revision,
|
|
389
|
+
currentVersion: item.currentVersion
|
|
390
|
+
};
|
|
391
|
+
if (typeof metadata.workspaceId !== "string" || !WORKSPACE_ID$1.test(metadata.workspaceId) || typeof metadata.itemId !== "string" || !ITEM_ID$1.test(metadata.itemId) || metadata.parentId === null || metadata.parentId === metadata.itemId || !isManagedItemMetadata(metadata, metadata.workspaceId, metadata.itemId) || item.etag !== `"drive.item.v1.${metadata.revision}"` || ids.has(metadata.itemId)) return false;
|
|
392
|
+
if (item.lifecycleState === "active" ? item.trashedAtEpochMilliseconds !== null || item.purgeAfterEpochMilliseconds !== null : !isSafeInteger$1(item.trashedAtEpochMilliseconds) || !isSafeInteger$1(item.purgeAfterEpochMilliseconds) || item.purgeAfterEpochMilliseconds <= item.trashedAtEpochMilliseconds) return false;
|
|
393
|
+
ids.add(metadata.itemId);
|
|
394
|
+
return true;
|
|
395
|
+
});
|
|
396
|
+
if (valid) {
|
|
397
|
+
for (const item of value.items) Object.freeze(item);
|
|
398
|
+
Object.freeze(value.items);
|
|
399
|
+
Object.freeze(value);
|
|
400
|
+
}
|
|
401
|
+
return valid;
|
|
402
|
+
}
|
|
403
|
+
function isCurrentWorkspaceSources(value) {
|
|
404
|
+
if (!isExactRecord(value, [
|
|
405
|
+
"workspace",
|
|
406
|
+
"volumes",
|
|
407
|
+
"knownProviders",
|
|
408
|
+
"externalConnectionsSupported"
|
|
409
|
+
]) || !isCurrentWorkspace(value.workspace) || !Array.isArray(value.volumes) || value.volumes.length !== 1 || !Array.isArray(value.knownProviders) || value.externalConnectionsSupported !== false) return false;
|
|
410
|
+
const volume = value.volumes[0];
|
|
411
|
+
const providers = [
|
|
412
|
+
"managed",
|
|
413
|
+
"google-drive",
|
|
414
|
+
"onedrive",
|
|
415
|
+
"dropbox",
|
|
416
|
+
"s3-compatible"
|
|
417
|
+
];
|
|
418
|
+
return isExactRecord(volume, [
|
|
419
|
+
"volumeId",
|
|
420
|
+
"rootItemId",
|
|
421
|
+
"provider",
|
|
422
|
+
"name"
|
|
423
|
+
]) && volume.volumeId === value.workspace.rootVolumeId && volume.rootItemId === value.workspace.rootItemId && volume.provider === "managed" && volume.name === "Files" && value.knownProviders.length === providers.length && value.knownProviders.every((provider, index) => provider === providers[index]);
|
|
424
|
+
}
|
|
330
425
|
function isCurrentWorkspace(value) {
|
|
331
426
|
if (!isExactRecord(value, [
|
|
332
427
|
"workspaceId",
|
|
@@ -584,12 +679,14 @@ function isUploadStatus(value, afterPartNumber, limit) {
|
|
|
584
679
|
"nextAfterPartNumber",
|
|
585
680
|
"expiresAtEpochMilliseconds",
|
|
586
681
|
"ready"
|
|
587
|
-
]) || typeof value.itemId !== "string" || !ITEM_ID$1.test(value.itemId) || typeof value.versionId !== "string" || !VERSION_ID$1.test(value.versionId) || typeof value.uploadId !== "string" || !UPLOAD_ID$1.test(value.uploadId) || value.mode !== "presigned-multipart" && value.mode !== "server-mediated-zero-byte" || ![
|
|
682
|
+
], ["verification"]) || typeof value.itemId !== "string" || !ITEM_ID$1.test(value.itemId) || typeof value.versionId !== "string" || !VERSION_ID$1.test(value.versionId) || typeof value.uploadId !== "string" || !UPLOAD_ID$1.test(value.uploadId) || value.mode !== "presigned-multipart" && value.mode !== "server-mediated-zero-byte" || ![
|
|
588
683
|
"initiating",
|
|
589
684
|
"recovery-required",
|
|
590
685
|
"uploading",
|
|
591
686
|
"completing",
|
|
592
687
|
"provider-completed",
|
|
688
|
+
"verifying",
|
|
689
|
+
"failed",
|
|
593
690
|
"ready",
|
|
594
691
|
"aborting",
|
|
595
692
|
"aborted"
|
|
@@ -599,18 +696,38 @@ function isUploadStatus(value, afterPartNumber, limit) {
|
|
|
599
696
|
"maxParts"
|
|
600
697
|
]) || value.partPolicy.partByteLength !== UPLOAD_PART_BYTE_LENGTH$1 || !isSafeInteger$1(value.partPolicy.partCount) || value.partPolicy.partCount > 1e4 || value.partPolicy.maxParts !== 1e4 || (value.mode === "server-mediated-zero-byte" ? value.partPolicy.partCount !== 0 : value.partPolicy.partCount < 1) || !Array.isArray(value.confirmedParts) || value.confirmedParts.length > limit || !isSafeInteger$1(value.expiresAtEpochMilliseconds)) return false;
|
|
601
698
|
let previousPartNumber = afterPartNumber;
|
|
699
|
+
if (value.verification !== void 0) {
|
|
700
|
+
const progress = value.verification;
|
|
701
|
+
if (!isExactRecord(progress, [
|
|
702
|
+
"state",
|
|
703
|
+
"verifiedByteLength",
|
|
704
|
+
"totalByteLength",
|
|
705
|
+
"revision"
|
|
706
|
+
]) || ![
|
|
707
|
+
"pending",
|
|
708
|
+
"verified",
|
|
709
|
+
"failed"
|
|
710
|
+
].includes(String(progress.state)) || !isSafeInteger$1(progress.verifiedByteLength) || !isSafeInteger$1(progress.totalByteLength) || progress.totalByteLength > MAX_UPLOAD_BYTE_LENGTH$1 || progress.verifiedByteLength > progress.totalByteLength || !isSafeInteger$1(progress.revision) || progress.state === "verified" && progress.verifiedByteLength !== progress.totalByteLength) return false;
|
|
711
|
+
Object.freeze(progress);
|
|
712
|
+
}
|
|
713
|
+
if (["verifying", "failed"].includes(String(value.lifecycle)) && value.verification === void 0) return false;
|
|
602
714
|
for (const part of value.confirmedParts) {
|
|
603
715
|
if (!isExactRecord(part, ["partNumber", "checksumSha256"]) || !isSafeInteger$1(part.partNumber) || part.partNumber <= previousPartNumber || part.partNumber > value.partPolicy.partCount || !isPartChecksum$1(part.checksumSha256)) return false;
|
|
604
716
|
previousPartNumber = part.partNumber;
|
|
605
717
|
}
|
|
606
|
-
if (!(value.nextAfterPartNumber === null || isSafeInteger$1(value.nextAfterPartNumber) && value.confirmedParts.length === limit && value.nextAfterPartNumber === previousPartNumber) || value.mode === "server-mediated-zero-byte" && (value.confirmedParts.length !== 0 || value.nextAfterPartNumber !== null) || value.lifecycle === "ready" !== (value.ready !== null) || value.ready !== null && (!isReadyUpload(value.ready, { uploadId: value.uploadId }) || value.ready.itemId !== value.itemId || value.ready.versionId !== value.versionId
|
|
718
|
+
if (!(value.nextAfterPartNumber === null || isSafeInteger$1(value.nextAfterPartNumber) && value.confirmedParts.length === limit && value.nextAfterPartNumber === previousPartNumber) || value.mode === "server-mediated-zero-byte" && (value.confirmedParts.length !== 0 || value.nextAfterPartNumber !== null) || value.lifecycle === "ready" !== (value.ready !== null) || value.ready !== null && (!isReadyUpload(value.ready, { uploadId: value.uploadId }) || value.ready.itemId !== value.itemId || value.ready.versionId !== value.versionId || !isExactRecord(value.verification, [
|
|
719
|
+
"state",
|
|
720
|
+
"verifiedByteLength",
|
|
721
|
+
"totalByteLength",
|
|
722
|
+
"revision"
|
|
723
|
+
]) || value.verification.state !== "verified" || value.verification.totalByteLength !== value.ready.byteLength)) return false;
|
|
607
724
|
Object.freeze(value.partPolicy);
|
|
608
725
|
for (const part of value.confirmedParts) Object.freeze(part);
|
|
609
726
|
Object.freeze(value.confirmedParts);
|
|
610
727
|
Object.freeze(value);
|
|
611
728
|
return true;
|
|
612
729
|
}
|
|
613
|
-
function isUploadPartDescriptor(value, expectedPartNumber,
|
|
730
|
+
function isUploadPartDescriptor(value, expectedPartNumber, allowInsecureHttp, contentMd5) {
|
|
614
731
|
if (!isExactRecord(value, [
|
|
615
732
|
"url",
|
|
616
733
|
"method",
|
|
@@ -618,7 +735,7 @@ function isUploadPartDescriptor(value, expectedPartNumber, checksumSha256, allow
|
|
|
618
735
|
"partNumber",
|
|
619
736
|
"expectedByteLength",
|
|
620
737
|
"expiresAtEpochMilliseconds"
|
|
621
|
-
]) || !isSignedTransferUrl(value.url, allowInsecureHttp) || value.method !== "PUT" || !isExactRecord(value.headers, ["
|
|
738
|
+
]) || !isSignedTransferUrl(value.url, allowInsecureHttp) || value.method !== "PUT" || !contentMd5 || !isExactRecord(value.headers, ["content-md5"]) || value.headers["content-md5"] !== contentMd5 || value.partNumber !== expectedPartNumber || !isSafeInteger$1(value.expectedByteLength) || value.expectedByteLength < 1 || value.expectedByteLength > UPLOAD_PART_BYTE_LENGTH$1 || !isSafeInteger$1(value.expiresAtEpochMilliseconds) || value.expiresAtEpochMilliseconds <= Date.now()) return false;
|
|
622
739
|
Object.freeze(value.headers);
|
|
623
740
|
Object.freeze(value);
|
|
624
741
|
return true;
|
|
@@ -642,6 +759,19 @@ function isReadyUpload(value, expected) {
|
|
|
642
759
|
Object.freeze(value);
|
|
643
760
|
return true;
|
|
644
761
|
}
|
|
762
|
+
function isPendingUpload(value, uploadId) {
|
|
763
|
+
if (!isExactRecord(value, [
|
|
764
|
+
"itemId",
|
|
765
|
+
"versionId",
|
|
766
|
+
"uploadId",
|
|
767
|
+
"state",
|
|
768
|
+
"verifiedByteLength",
|
|
769
|
+
"totalByteLength",
|
|
770
|
+
"verificationRevision"
|
|
771
|
+
]) || typeof value.itemId !== "string" || !ITEM_ID$1.test(value.itemId) || typeof value.versionId !== "string" || !VERSION_ID$1.test(value.versionId) || value.uploadId !== uploadId || value.state !== "verifying" || !isSafeInteger$1(value.verifiedByteLength) || !isSafeInteger$1(value.totalByteLength) || value.totalByteLength > MAX_UPLOAD_BYTE_LENGTH$1 || value.verifiedByteLength > value.totalByteLength || !isSafeInteger$1(value.verificationRevision)) return false;
|
|
772
|
+
Object.freeze(value);
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
645
775
|
function isPartChecksum$1(value) {
|
|
646
776
|
return typeof value === "string" && /^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw048]=$/.test(value);
|
|
647
777
|
}
|
|
@@ -781,9 +911,9 @@ function isSafeCapabilityUrl(value) {
|
|
|
781
911
|
return false;
|
|
782
912
|
}
|
|
783
913
|
}
|
|
784
|
-
function isExactRecord(value, keys) {
|
|
914
|
+
function isExactRecord(value, keys, optional = []) {
|
|
785
915
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
786
|
-
return Object.keys(value).
|
|
916
|
+
return Object.keys(value).every((key) => keys.includes(key) || optional.includes(key)) && keys.every((key) => Object.hasOwn(value, key));
|
|
787
917
|
}
|
|
788
918
|
//#endregion
|
|
789
919
|
//#region src/internal/client/request.ts
|
|
@@ -811,6 +941,29 @@ function validateCurrentWorkspaceInput(value) {
|
|
|
811
941
|
const signal = validateSignal(captureRecord(value === void 0 ? {} : value, [], ["signal"]).signal);
|
|
812
942
|
return signal === void 0 ? {} : { signal };
|
|
813
943
|
}
|
|
944
|
+
function validateWorkspaceDiscoveryInput(value, list) {
|
|
945
|
+
const input = captureRecord(value, ["workspaceId"], list ? [
|
|
946
|
+
"signal",
|
|
947
|
+
"view",
|
|
948
|
+
"kind",
|
|
949
|
+
"creatorUserId",
|
|
950
|
+
"limit",
|
|
951
|
+
"cursor"
|
|
952
|
+
] : ["signal"]);
|
|
953
|
+
const signal = validateSignal(input.signal);
|
|
954
|
+
if (typeof input.workspaceId !== "string" || !WORKSPACE_ID.test(input.workspaceId) || input.view !== void 0 && input.view !== "recent" && input.view !== "shared" && input.view !== "trash" || input.kind !== void 0 && input.kind !== "file" && input.kind !== "folder" || input.creatorUserId !== void 0 && (typeof input.creatorUserId !== "string" || !AUTH_ID.test(input.creatorUserId)) || input.limit !== void 0 && (typeof input.limit !== "number" || !Number.isInteger(input.limit) || input.limit < 1 || input.limit > 50) || input.cursor !== void 0 && (typeof input.cursor !== "string" || input.cursor.length < 1 || input.cursor.length > 2048 || !/^[A-Za-z0-9_.-]+$/.test(input.cursor))) throw new DriveError("invalid_input");
|
|
955
|
+
return {
|
|
956
|
+
workspaceId: input.workspaceId,
|
|
957
|
+
signal,
|
|
958
|
+
query: {
|
|
959
|
+
...input.view === void 0 ? {} : { view: input.view },
|
|
960
|
+
...input.kind === void 0 ? {} : { kind: input.kind },
|
|
961
|
+
...input.creatorUserId === void 0 ? {} : { creatorUserId: input.creatorUserId },
|
|
962
|
+
...input.limit === void 0 ? {} : { limit: input.limit },
|
|
963
|
+
...input.cursor === void 0 ? {} : { cursor: input.cursor }
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}
|
|
814
967
|
function validateResourceInput(value) {
|
|
815
968
|
const input = captureRecord(value, ["workspaceId", "itemId"], ["signal"]);
|
|
816
969
|
const workspaceId = input.workspaceId;
|
|
@@ -1112,14 +1265,17 @@ function validateCreateUploadPartDescriptorInput(value) {
|
|
|
1112
1265
|
"workspaceId",
|
|
1113
1266
|
"uploadId",
|
|
1114
1267
|
"partNumber",
|
|
1115
|
-
"checksumSha256"
|
|
1268
|
+
"checksumSha256",
|
|
1269
|
+
"contentMd5"
|
|
1116
1270
|
], ["signal"]);
|
|
1117
1271
|
const upload = validateUploadPath(input.workspaceId, input.uploadId, input.signal);
|
|
1118
1272
|
if (!isPartNumber(input.partNumber) || !isPartChecksum(input.checksumSha256)) throw new DriveError("invalid_input");
|
|
1273
|
+
if (typeof input.contentMd5 !== "string" || !/^[A-Za-z0-9+/]{21}[AQgw]==$/.test(input.contentMd5)) throw new DriveError("invalid_input");
|
|
1119
1274
|
return {
|
|
1120
1275
|
...upload,
|
|
1121
1276
|
partNumber: input.partNumber,
|
|
1122
|
-
checksumSha256: input.checksumSha256
|
|
1277
|
+
checksumSha256: input.checksumSha256,
|
|
1278
|
+
contentMd5: input.contentMd5
|
|
1123
1279
|
};
|
|
1124
1280
|
}
|
|
1125
1281
|
function validateRecordUploadPartInput(value) {
|
|
@@ -1945,6 +2101,9 @@ function createDriveClientInternal(config) {
|
|
|
1945
2101
|
function createDriveOperations(runtime) {
|
|
1946
2102
|
return Object.freeze({
|
|
1947
2103
|
getCurrentWorkspace: (input) => getCurrentWorkspace(runtime, input),
|
|
2104
|
+
listWorkspaceItems: (input) => listWorkspaceItems(runtime, input),
|
|
2105
|
+
getWorkspaceUsage: (input) => getWorkspaceUsage(runtime, input),
|
|
2106
|
+
getCurrentWorkspaceSources: (input) => getCurrentWorkspaceSources(runtime, input),
|
|
1948
2107
|
getItem: (input) => getItem(runtime, input),
|
|
1949
2108
|
searchWorkspaceItems: (input) => searchWorkspaceItems(runtime, input),
|
|
1950
2109
|
listFolderChildren: (input) => listFolderChildren(runtime, input),
|
|
@@ -2143,6 +2302,29 @@ function streamWithOperationLifetime(source, expectedLength, signal) {
|
|
|
2143
2302
|
}
|
|
2144
2303
|
});
|
|
2145
2304
|
}
|
|
2305
|
+
async function getCurrentWorkspaceSources(runtime, input) {
|
|
2306
|
+
return execute(runtime, validateCurrentWorkspaceInput(input).signal, null, (api, requestOptions) => api.GET("/api/v1/workspaces/current/sources", {
|
|
2307
|
+
...operationOptions("getCurrentWorkspaceSources", { params: {} }),
|
|
2308
|
+
...requestOptions
|
|
2309
|
+
}), [200], isCurrentWorkspaceSources, false, CURRENT_WORKSPACE_ERROR_CODES);
|
|
2310
|
+
}
|
|
2311
|
+
async function listWorkspaceItems(runtime, input) {
|
|
2312
|
+
const validated = validateWorkspaceDiscoveryInput(input, true);
|
|
2313
|
+
return execute(runtime, validated.signal, null, (api, options) => api.GET("/api/v1/workspaces/{workspaceId}/items", {
|
|
2314
|
+
...operationOptions("listWorkspaceItems", { params: {
|
|
2315
|
+
path: { workspaceId: validated.workspaceId },
|
|
2316
|
+
query: validated.query
|
|
2317
|
+
} }),
|
|
2318
|
+
...options
|
|
2319
|
+
}), [200], (value) => isWorkspaceDiscoveryPage(value) && value.items.length <= (validated.query.limit ?? 25) && value.items.every((item, index, items) => item.workspaceId === validated.workspaceId && item.lifecycleState === (validated.query.view === "trash" ? "trashed" : "active") && ((validated.query.view ?? "recent") !== "recent" || item.modifiedAtEpochMilliseconds !== null) && (validated.query.kind === void 0 || item.type === validated.query.kind) && (validated.query.creatorUserId === void 0 || item.creatorUserId === validated.query.creatorUserId) && (index === 0 || ((validated.query.view ?? "recent") === "recent" ? items[index - 1].modifiedAtEpochMilliseconds > item.modifiedAtEpochMilliseconds || items[index - 1].modifiedAtEpochMilliseconds === item.modifiedAtEpochMilliseconds && items[index - 1].itemId < item.itemId : items[index - 1].itemId < item.itemId))), false, SEARCH_WORKSPACE_ITEMS_ERROR_CODES);
|
|
2320
|
+
}
|
|
2321
|
+
async function getWorkspaceUsage(runtime, input) {
|
|
2322
|
+
const validated = validateWorkspaceDiscoveryInput(input, false);
|
|
2323
|
+
return execute(runtime, validated.signal, null, (api, options) => api.GET("/api/v1/workspaces/{workspaceId}/usage", {
|
|
2324
|
+
...operationOptions("getWorkspaceUsage", { params: { path: { workspaceId: validated.workspaceId } } }),
|
|
2325
|
+
...options
|
|
2326
|
+
}), [200], (value) => isWorkspaceUsage(value) && value.workspaceId === validated.workspaceId, false, SEARCH_WORKSPACE_ITEMS_ERROR_CODES);
|
|
2327
|
+
}
|
|
2146
2328
|
async function getCurrentWorkspace(runtime, input) {
|
|
2147
2329
|
return execute(runtime, validateCurrentWorkspaceInput(input).signal, null, (api, requestOptions) => api.GET("/api/v1/workspaces/current", {
|
|
2148
2330
|
...operationOptions("getCurrentWorkspace", { params: {} }),
|
|
@@ -2398,7 +2580,7 @@ async function getUploadStatus(runtime, input) {
|
|
|
2398
2580
|
}
|
|
2399
2581
|
} }),
|
|
2400
2582
|
...requestOptions
|
|
2401
|
-
}), [200], (value) => isUploadStatus(value, afterPartNumber, limit), false, STATUS_ERROR_CODES);
|
|
2583
|
+
}), [200], (value) => isUploadStatus(value, afterPartNumber, limit) && value.uploadId === validated.uploadId, false, STATUS_ERROR_CODES);
|
|
2402
2584
|
}
|
|
2403
2585
|
async function createUploadPartDescriptor(runtime, input) {
|
|
2404
2586
|
const validated = validateCreateUploadPartDescriptorInput(input);
|
|
@@ -2410,11 +2592,12 @@ async function createUploadPartDescriptor(runtime, input) {
|
|
|
2410
2592
|
} },
|
|
2411
2593
|
body: {
|
|
2412
2594
|
partNumber: validated.partNumber,
|
|
2413
|
-
checksumSha256: validated.checksumSha256
|
|
2595
|
+
checksumSha256: validated.checksumSha256,
|
|
2596
|
+
contentMd5: validated.contentMd5
|
|
2414
2597
|
}
|
|
2415
2598
|
}),
|
|
2416
2599
|
...requestOptions
|
|
2417
|
-
}), [200], (value) => isUploadPartDescriptor(value, validated.partNumber,
|
|
2600
|
+
}), [200], (value) => isUploadPartDescriptor(value, validated.partNumber, new URL(runtime.baseUrl).protocol === "http:", validated.contentMd5), false, TRANSFER_ERROR_CODES);
|
|
2418
2601
|
}
|
|
2419
2602
|
async function recordUploadPart(runtime, input) {
|
|
2420
2603
|
const validated = validateRecordUploadPartInput(input);
|
|
@@ -2446,7 +2629,7 @@ async function completeUpload(runtime, input) {
|
|
|
2446
2629
|
header: { "Idempotency-Key": validated.idempotencyKey }
|
|
2447
2630
|
} }),
|
|
2448
2631
|
...requestOptions
|
|
2449
|
-
}), [200], (value) => isReadyUpload(value, { uploadId: validated.uploadId }), false, COMPLETE_UPLOAD_ERROR_CODES);
|
|
2632
|
+
}), [200, 202], (value, status) => status === 202 ? isPendingUpload(value, validated.uploadId) : isReadyUpload(value, { uploadId: validated.uploadId }), false, COMPLETE_UPLOAD_ERROR_CODES);
|
|
2450
2633
|
}
|
|
2451
2634
|
async function abortUpload(runtime, input) {
|
|
2452
2635
|
const validated = validateAbortUploadInput(input);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AbortUploadInput, CompleteUploadInput, CreateDownloadInput, CreateFolderInput, CreateItemPermissionInput, CreateUploadInput, CreateUploadPartDescriptorInput, CurrentWorkspace, DeleteItemInput, DownloadItemResult, DriveClient, DriveClientConfig, DriveCredentialContext, DriveCredentialProvider, DriveOperationResult, DriveOperations, DriveResponseValidators, DriveServerClient, DriveServerClientConfig, EffectivePermissionAction, EffectivePermissionResponse, FolderItem, FolderPage, GetCurrentWorkspaceInput, GetItemInput, GetItemVersionInput, GetUploadStatusInput, ListFolderChildrenInput, ListItemPermissionsInput, ListItemVersionsInput, ManagedDownloadDescriptor, ManagedDownloadRestorePending, ManagedItemMetadata, ManagedItemVersion, ManagedItemVersionPage, ManagedItemVersionResource, ManagedItemVersionRestoreResult, ManagedLifecycleItem, PermissionAction, PermissionGrant, PermissionGrantee, PermissionMutation, PermissionPage, ProtectionClassification, ReadEffectiveItemPermissionsInput, ReadyUpload, RecordUploadPartInput, RestoreItemInput, RestoreItemVersionInput, RevokeItemPermissionInput, SearchWorkspaceItemsInput, TrashItemInput, UpdateItemInput, UpdateItemPermissionInput, UploadConfirmedPart, UploadFileInput, UploadFilePhase, UploadFileProgress, UploadFileProgressCallback, UploadPartDescriptor, UploadPartResult, UploadSession, UploadStatus, WorkspaceItemSearchItem, WorkspaceItemSearchPage };
|
|
1
|
+
import { $ as RestoreItemVersionInput, A as ListFolderChildrenInput, B as ManagedItemVersionRestoreResult, C as FolderItem, D as GetItemVersionInput, E as GetItemInput, F as ManagedDownloadRestorePending, G as PermissionGrantee, H as PendingUpload, I as ManagedItemMetadata, J as ProtectionClassification, K as PermissionMutation, L as ManagedItemVersion, M as ListItemVersionsInput, N as ListWorkspaceItemsInput, O as GetUploadStatusInput, P as ManagedDownloadDescriptor, Q as RestoreItemInput, R as ManagedItemVersionPage, S as EffectivePermissionResponse, T as GetCurrentWorkspaceInput, U as PermissionAction, V as ManagedLifecycleItem, W as PermissionGrant, X as ReadyUpload, Y as ReadEffectiveItemPermissionsInput, Z as RecordUploadPartInput, _ as DriveOperations, _t as WorkspaceItemSearchItem, a as CreateItemPermissionInput, at as UploadCompletion, b as DriveServerClientConfig, c as CurrentWorkspace, ct as UploadFilePhase, d as DownloadItemResult, dt as UploadPartDescriptor, et as RevokeItemPermissionInput, f as DriveClient, ft as UploadPartResult, g as DriveOperationResult, gt as WorkspaceDiscoveryPage, h as DriveCredentialProvider, ht as WorkspaceDiscoveryItem, i as CreateFolderInput, it as UpdateItemPermissionInput, j as ListItemPermissionsInput, k as GetWorkspaceUsageInput, l as CurrentWorkspaceSources, lt as UploadFileProgress, m as DriveCredentialContext, mt as UploadStatus, n as CompleteUploadInput, nt as TrashItemInput, o as CreateUploadInput, ot as UploadConfirmedPart, p as DriveClientConfig, pt as UploadSession, q as PermissionPage, r as CreateDownloadInput, rt as UpdateItemInput, s as CreateUploadPartDescriptorInput, st as UploadFileInput, t as AbortUploadInput, tt as SearchWorkspaceItemsInput, u as DeleteItemInput, ut as UploadFileProgressCallback, v as DriveResponseValidators, vt as WorkspaceItemSearchPage, w as FolderPage, x as EffectivePermissionAction, y as DriveServerClient, yt as WorkspaceUsage, z as ManagedItemVersionResource } from "./contract.js";
|
|
2
|
+
export { AbortUploadInput, CompleteUploadInput, CreateDownloadInput, CreateFolderInput, CreateItemPermissionInput, CreateUploadInput, CreateUploadPartDescriptorInput, CurrentWorkspace, CurrentWorkspaceSources, DeleteItemInput, DownloadItemResult, DriveClient, DriveClientConfig, DriveCredentialContext, DriveCredentialProvider, DriveOperationResult, DriveOperations, DriveResponseValidators, DriveServerClient, DriveServerClientConfig, EffectivePermissionAction, EffectivePermissionResponse, FolderItem, FolderPage, GetCurrentWorkspaceInput, GetItemInput, GetItemVersionInput, GetUploadStatusInput, GetWorkspaceUsageInput, ListFolderChildrenInput, ListItemPermissionsInput, ListItemVersionsInput, ListWorkspaceItemsInput, ManagedDownloadDescriptor, ManagedDownloadRestorePending, ManagedItemMetadata, ManagedItemVersion, ManagedItemVersionPage, ManagedItemVersionResource, ManagedItemVersionRestoreResult, ManagedLifecycleItem, PendingUpload, PermissionAction, PermissionGrant, PermissionGrantee, PermissionMutation, PermissionPage, ProtectionClassification, ReadEffectiveItemPermissionsInput, ReadyUpload, RecordUploadPartInput, RestoreItemInput, RestoreItemVersionInput, RevokeItemPermissionInput, SearchWorkspaceItemsInput, TrashItemInput, UpdateItemInput, UpdateItemPermissionInput, UploadCompletion, UploadConfirmedPart, UploadFileInput, UploadFilePhase, UploadFileProgress, UploadFileProgressCallback, UploadPartDescriptor, UploadPartResult, UploadSession, UploadStatus, WorkspaceDiscoveryItem, WorkspaceDiscoveryPage, WorkspaceItemSearchItem, WorkspaceItemSearchPage, WorkspaceUsage };
|