@finueva/drive 0.2.0 → 0.5.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 +21 -0
- package/README.md +67 -9
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1809 -28
- package/dist/contract.d.ts +3046 -443
- package/dist/core.d.ts +3 -1
- package/dist/core.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1809 -28
- package/dist/server.d.ts +3 -3
- package/dist/server.js +1062 -25
- package/dist/types.d.ts +2 -2
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @finueva/drive
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2ff64ff: Add authorized managed download descriptors, ranged streaming, HEAD metadata, and visible cold restore operations.
|
|
8
|
+
- 785cea5: Add authorized exact managed item-version lookup across browser, Worker, and Node clients.
|
|
9
|
+
- e5cc9cb: Add authorized exact managed-item metadata reads across browser, Worker, and Node clients.
|
|
10
|
+
- fa7c00b: Add qualified workspace item search across browser, Worker, and Node clients.
|
|
11
|
+
|
|
12
|
+
## 0.4.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- c1755b1: Add strict managed-item rename, move, trash, restore, permanent deletion, version listing, and prior-version restore operations across browser, Worker, and Node clients.
|
|
17
|
+
|
|
18
|
+
## 0.3.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 90e29ff: Add all six strict upload controls and resumable browser direct-`Blob` orchestration with zero-byte completion, bounded incremental SHA-256 hashing, isolated archive PUTs, lost-response reconciliation, progress, and cancellation cleanup.
|
|
23
|
+
|
|
3
24
|
## 0.2.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ The package is ESM-only. Node.js 22 is the exact minimum; package CI qualifies N
|
|
|
6
6
|
|
|
7
7
|
## Exports
|
|
8
8
|
|
|
9
|
-
| Import | Runtime
|
|
10
|
-
| ----------------------- |
|
|
11
|
-
| `@finueva/drive` | Browser-safe client factory, errors, and curated types
|
|
12
|
-
| `@finueva/drive/client` | Browser-safe client factory
|
|
13
|
-
| `@finueva/drive/server` | Request-scoped Worker and Node client factory
|
|
14
|
-
| `@finueva/drive/core` | Reviewed error values only
|
|
15
|
-
| `@finueva/drive/types` | Curated workspace,
|
|
9
|
+
| Import | Runtime |
|
|
10
|
+
| ----------------------- | ---------------------------------------------------------------------- |
|
|
11
|
+
| `@finueva/drive` | Browser-safe client factory, errors, and curated types |
|
|
12
|
+
| `@finueva/drive/client` | Browser-safe client factory |
|
|
13
|
+
| `@finueva/drive/server` | Request-scoped Worker and Node low-level client factory |
|
|
14
|
+
| `@finueva/drive/core` | Reviewed error values only |
|
|
15
|
+
| `@finueva/drive/types` | Curated workspace, search, item, version, permission, and upload types |
|
|
16
16
|
|
|
17
17
|
## Browser
|
|
18
18
|
|
|
@@ -31,6 +31,24 @@ const page = await drive.listFolderChildren({
|
|
|
31
31
|
itemId: workspace.rootItemId,
|
|
32
32
|
limit: 50,
|
|
33
33
|
});
|
|
34
|
+
const matches = await drive.searchWorkspaceItems({
|
|
35
|
+
workspaceId: workspace.workspaceId,
|
|
36
|
+
query: "Project",
|
|
37
|
+
limit: 50,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const uploaded = await drive.uploadFile({
|
|
41
|
+
workspaceId: workspace.workspaceId,
|
|
42
|
+
parentItemId: workspace.rootItemId,
|
|
43
|
+
source: file, // Blob; File is supported without being required
|
|
44
|
+
displayFilename: file.name,
|
|
45
|
+
mediaType: file.type || "application/octet-stream",
|
|
46
|
+
idempotencyKey: crypto.randomUUID(),
|
|
47
|
+
completionIdempotencyKey: crypto.randomUUID(),
|
|
48
|
+
onProgress: ({ phase, confirmedByteLength, totalByteLength }) => {
|
|
49
|
+
renderProgress(phase, confirmedByteLength, totalByteLength);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
34
52
|
```
|
|
35
53
|
|
|
36
54
|
The provider runs once for every request. The SDK sends its result only as `Authorization: Bearer`, always sets `credentials: "omit"` and `cache: "no-store"`, and never reads cookies. Configuration does not accept default headers. Credential acquisition, Fetch, and response handling share one bounded request deadline: 30 seconds by default, configurable from 1 millisecond through 120 seconds.
|
|
@@ -48,28 +66,68 @@ const drive = createDriveServerClient({
|
|
|
48
66
|
|
|
49
67
|
Create a client per request when using user authority. A fixed `credential` string is accepted for an explicitly scoped credential, but the SDK does not create, refresh, persist, or infer sessions, cookies, provider tokens, or service authority.
|
|
50
68
|
|
|
69
|
+
The server client exposes all 24 Native Drive operations plus streaming `downloadItem`, but intentionally has no Blob-only `uploadFile` method. The package root and browser client add `uploadFile`, for 26 methods total.
|
|
70
|
+
|
|
51
71
|
## Operations
|
|
52
72
|
|
|
53
73
|
Methods use the Native API operation IDs:
|
|
54
74
|
|
|
55
75
|
- `getCurrentWorkspace`
|
|
76
|
+
- `getItem`
|
|
77
|
+
- `searchWorkspaceItems`
|
|
56
78
|
- `listFolderChildren`
|
|
57
79
|
- `createFolder`
|
|
80
|
+
- `updateItem`
|
|
81
|
+
- `trashItem`
|
|
82
|
+
- `restoreItem`
|
|
83
|
+
- `deleteItem`
|
|
84
|
+
- `listItemVersions`
|
|
85
|
+
- `getItemVersion`
|
|
86
|
+
- `restoreItemVersion`
|
|
87
|
+
- `createDownload`
|
|
88
|
+
- `downloadItem` (high-level direct streaming)
|
|
58
89
|
- `listItemPermissions`
|
|
59
90
|
- `readEffectiveItemPermissions`
|
|
60
91
|
- `createItemPermission`
|
|
61
92
|
- `updateItemPermission`
|
|
62
93
|
- `revokeItemPermission`
|
|
63
94
|
- `createUpload`
|
|
95
|
+
- `getUploadStatus`
|
|
96
|
+
- `createUploadPartDescriptor`
|
|
97
|
+
- `recordUploadPart`
|
|
98
|
+
- `completeUpload`
|
|
64
99
|
- `abortUpload`
|
|
100
|
+
- `uploadFile` (high-level orchestration)
|
|
65
101
|
|
|
66
102
|
`getCurrentWorkspace` maps the credential's selected Auth context to the provisioned Drive workspace and canonical managed root. It accepts only an optional `{ signal }` input, never provisions as a side effect, and returns no entitlement, credential, or private persistence fields.
|
|
67
103
|
|
|
68
|
-
|
|
104
|
+
`getItem` reads one active managed item under exact `items:metadata:read` authority. It conceals absent, cross-workspace, unauthorized, tombstoned, ancestor-tombstoned, and unpublished file items as not found. Results expose exact `workspaceId`, `itemId`, nullable `parentId`, `type`, `name`, `lifecycleState`, `revision`, and `currentVersion`. Folder metadata returns `currentVersion: null`; published files return only the current immutable version ID, state, byte length, untrusted media type, and untrusted protection classification. The strong item ETag matches the returned item revision. Digests, archive/cache state, provider keys, upload state, and content authority are not exposed.
|
|
105
|
+
|
|
106
|
+
`searchWorkspaceItems` searches active managed metadata in one workspace by a required NFC, case-sensitive name prefix. The prefix is 1 through 64 Unicode code points, at most 255 UTF-8 bytes, and excludes C0/C1 controls plus U+2028/U+2029. Results are exact frozen `{ items, nextCursor }` pages of at most the requested limit or 50 by default, in binary name then item-ID order. Each item adds exact `volumeId` and `provider: "managed"` fields to the `getItem` metadata shape; folders require `currentVersion: null` and files require current-version metadata. Cursors use the existing opaque syntax and an empty page cannot carry a continuation.
|
|
107
|
+
|
|
108
|
+
Every mutation requires the API's explicit idempotency key when the operation defines one. Item lifecycle mutations also require the current strong item ETag as `ifMatch`; grant mutations use their documented collection or grant precondition. Mutations are never retried automatically. Sparse updates omit `undefined` properties and preserve explicit `null` expiry.
|
|
69
109
|
|
|
70
110
|
Successful calls return `{ data, status, requestId, validators }`. A successful response must carry one valid `X-Request-ID`; canonical API errors must carry the same request ID in their header and body. Any missing, malformed, or mismatched value is an `invalid_response`. The only exposed validators are `etag`, `permissionCollectionEtag`, and `permissionGrantEtag`.
|
|
71
111
|
|
|
72
|
-
`
|
|
112
|
+
`updateItem` renames and moves one stable item ID. A move immediately changes inherited-grant ancestry; Drive does not copy grants to the item. `trashItem` retains a 30-day tombstone, `restoreItem` requires the original parent to remain active, and `deleteItem` starts permanent archive cleanup only after retention expires and no hold applies. Permanent deletion is currently bounded to at most 25 subtree items and 25 total versions; larger trees fail unavailable until a durable workflow exists. Exact retries resume retained deletion checkpoints and never trigger blind provider duplication.
|
|
113
|
+
|
|
114
|
+
`listItemVersions` returns only immutable `current` and `superseded` managed version projections in pages of at most 50 using an opaque encrypted cursor. `getItemVersion` returns a strict frozen `ManagedItemVersionResource` containing the requested `workspaceId`, `itemId`, and `versionId` plus those version fields; all three response IDs must match the request. It conceals clean absence, valid wrong-item identity, unpublished history, and deleting or deleted history, while malformed retained state is unavailable. `restoreItemVersion` atomically makes one selected superseded version current, demotes the previous current version, advances the item revision, and never copies or overwrites archive bytes.
|
|
115
|
+
|
|
116
|
+
`createDownload` returns a short-lived archive descriptor for the current or an explicit immutable version, one visible `restore-pending` result for cold content, or a no-body `304` operation result whose validators retain the source ETag. Full, closed, open, and suffix ranges use the selected archive object's strong ETag; malformed or multiple ranges are served as full representations, while valid non-overlapping ranges fail with `range_not_satisfiable`. `downloadItem` follows a descriptor with no Drive credential, ambient browser credentials, or referrer and returns the provider body as a backpressured `Response`; it preserves the same `304` and cold-restore results without a provider request. It validates exact status, ETag, identity encoding, length, and `Content-Range`, cancels malformed upstream bodies, and keeps caller cancellation/deadline authority active until the stream closes or is cancelled. It never returns Blob, ArrayBuffer, text, or base64 whole-file convenience values.
|
|
117
|
+
|
|
118
|
+
The six low-level upload methods map directly to the Native API. `createUpload` accepts `callerDeclaredContentDigest`, an ordinary whole-file `sha256:{64 lowercase hex}` value calculated or supplied by the caller. It is untrusted metadata, not provider verification evidence. `getUploadStatus` returns one bounded confirmed-part page and the current lifecycle/revision. Descriptor issuance accepts one base64 SHA-256 part checksum, `recordUploadPart` records exact provider ETag/checksum evidence and revision, `completeUpload` returns only a server-verified `ready` result, and `abortUpload` returns bodyless `204` success.
|
|
119
|
+
|
|
120
|
+
Provider part checksums and the provider's multipart composite checksum are verified server-side before publication. They are deliberately distinct from `callerDeclaredContentDigest`: multipart composite SHA-256 is not the ordinary SHA-256 of the complete file. Every low-level control obtains one credential, sends one request, validates exact IDs, checksums, ETags, and safe-integer bounds at runtime, and never retries automatically. `upload_recovery_required` is preserved as a canonical `DriveError` code.
|
|
121
|
+
|
|
122
|
+
`uploadFile` is the browser-safe direct-byte path for a Web `Blob` or `File`. It accepts zero-byte input, hashes the empty input correctly, accepts the server-mediated zero-byte mode, skips part transfer, and completes normally. Nonempty input is incrementally hashed in slices no larger than 32 MiB and is never materialized as a complete `ArrayBuffer`, Blob copy, base64 string, or SDK request body. The fixed policy permits at most 10,000 parts and 312.5 GiB.
|
|
123
|
+
|
|
124
|
+
Each nonempty slice is sent directly to the exact descriptor URL. The request includes only descriptor-required headers, uses `credentials: "omit"`, `cache: "no-store"`, `redirect: "error"`, and `referrerPolicy: "no-referrer"`, and shares the configured cancellation/deadline bound. The archive CORS policy must expose both `ETag` and `x-amz-checksum-sha256`; missing, malformed, or mismatched values fail closed. Drive authorization, cookies, default headers, and file metadata never enter the archive request.
|
|
125
|
+
|
|
126
|
+
Repeating `uploadFile` with the same creation and completion idempotency keys explicitly resumes the retained session. After create/replay, the SDK reads status in pages of 100, bounded to 100 pages and 10,000 parts; validates session identity, mode, policy, lifecycle, revision, and pagination; re-hashes the supplied source; compares every confirmed part checksum; skips exact confirmed parts; and continues from the current revision. A matching `ready` status returns its exact ready projection. `completing` and `provider-completed` replay completion. Recovery-required and aborted states fail without pretending to resume.
|
|
127
|
+
|
|
128
|
+
There is no automatic network or provider retry. If a part-record callback response may have been lost, the SDK performs one bounded status reconciliation before either accepting the confirmed part or recording the same provider evidence once more; it never blindly re-uploads the bytes. If a completion response may have been lost, one status reconciliation returns success only when `ready` is proven. Other transient failures preserve the session for an explicit repeat until server expiry.
|
|
129
|
+
|
|
130
|
+
Progress values are frozen and limited to `preparing`, `uploading`, and `completing`, with truthful server-confirmed bytes and part counts, including resumed parts. Observer exceptions are isolated from transfer state. Reaching all confirmed bytes enters `completing`; only a resolved or status-proven `ready` result is success. Caller cancellation after session creation makes one bounded best-effort abort with fresh control-plane authority. Ordinary API or archive failures do not auto-abort.
|
|
73
131
|
|
|
74
132
|
## Errors
|
|
75
133
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
`@finueva/drive` bundles runtime code from these packages.
|
|
4
4
|
|
|
5
|
+
## @noble/hashes 2.3.0
|
|
6
|
+
|
|
7
|
+
Source: https://github.com/paulmillr/noble-hashes
|
|
8
|
+
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2022 Paul Miller (https://paulmillr.com)
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in
|
|
21
|
+
all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
|
+
THE SOFTWARE.
|
|
30
|
+
|
|
5
31
|
## openapi-fetch 0.17.0
|
|
6
32
|
|
|
7
33
|
Source: https://github.com/openapi-ts/openapi-typescript
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as UpdateItemInput, A as ListItemVersionsInput, C as FolderPage, D as GetUploadStatusInput, E as GetItemVersionInput, F as ManagedItemVersionPage, I as ManagedItemVersionResource, J as RestoreItemInput, K as ReadyUpload, L as ManagedItemVersionRestoreResult, M as ManagedDownloadRestorePending, N as ManagedItemMetadata, O as ListFolderChildrenInput, P as ManagedItemVersion, Q as TrashItemInput, R as ManagedLifecycleItem, S as FolderItem, T as GetItemInput, W as ProtectionClassification, Y as RestoreItemVersionInput, Z as SearchWorkspaceItemsInput, at as UploadFileProgressCallback, c as CurrentWorkspace, ct as UploadSession, d as DriveClient, dt as WorkspaceItemSearchPage, f as DriveClientConfig, it as UploadFileProgress, j as ManagedDownloadDescriptor, l as DeleteItemInput, lt as UploadStatus, m as DriveCredentialProvider, n as CompleteUploadInput, nt as UploadFileInput, o as CreateUploadInput, ot as UploadPartDescriptor, q as RecordUploadPartInput, r as CreateDownloadInput, rt as UploadFilePhase, s as CreateUploadPartDescriptorInput, st as UploadPartResult, t as AbortUploadInput, tt as UploadConfirmedPart, u as DownloadItemResult, ut as WorkspaceItemSearchItem, w as GetCurrentWorkspaceInput } from "./contract.js";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
3
|
declare function createDriveClient(config: DriveClientConfig): DriveClient;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { type AbortUploadInput, type
|
|
5
|
+
export { type AbortUploadInput, type CompleteUploadInput, type CreateDownloadInput, type CreateUploadInput, type CreateUploadPartDescriptorInput, type CurrentWorkspace, type DeleteItemInput, type DownloadItemResult, type DriveClient, type DriveClientConfig, type DriveCredentialProvider, type FolderItem, type FolderPage, type GetCurrentWorkspaceInput, type GetItemInput, type GetItemVersionInput, type GetUploadStatusInput, type ListFolderChildrenInput, type ListItemVersionsInput, type ManagedDownloadDescriptor, type ManagedDownloadRestorePending, type ManagedItemMetadata, type ManagedItemVersion, type ManagedItemVersionPage, type ManagedItemVersionResource, type ManagedItemVersionRestoreResult, type ManagedLifecycleItem, type ProtectionClassification, type ReadyUpload, type RecordUploadPartInput, type RestoreItemInput, type RestoreItemVersionInput, type SearchWorkspaceItemsInput, type TrashItemInput, type UpdateItemInput, type UploadConfirmedPart, type UploadFileInput, type UploadFilePhase, type UploadFileProgress, type UploadFileProgressCallback, type UploadPartDescriptor, type UploadPartResult, type UploadSession, type UploadStatus, type WorkspaceItemSearchItem, type WorkspaceItemSearchPage, createDriveClient };
|