@worldlabsai/client 0.1.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/LICENSE +202 -0
- package/README.md +109 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +31 -0
- package/dist/client.js.map +1 -0
- package/dist/core/assets.d.ts +138 -0
- package/dist/core/assets.d.ts.map +1 -0
- package/dist/core/assets.js +104 -0
- package/dist/core/assets.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/operations.d.ts +52 -0
- package/dist/core/operations.d.ts.map +1 -0
- package/dist/core/operations.js +81 -0
- package/dist/core/operations.js.map +1 -0
- package/dist/core/sleep.d.ts +7 -0
- package/dist/core/sleep.d.ts.map +1 -0
- package/dist/core/sleep.js +23 -0
- package/dist/core/sleep.js.map +1 -0
- package/dist/core/tasks.d.ts +27 -0
- package/dist/core/tasks.d.ts.map +1 -0
- package/dist/core/tasks.js +26 -0
- package/dist/core/tasks.js.map +1 -0
- package/dist/core/transport.d.ts +84 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/transport.js +171 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/generated/developer-api.gen.d.ts +2760 -0
- package/dist/generated/developer-api.gen.d.ts.map +1 -0
- package/dist/generated/developer-api.gen.js +6 -0
- package/dist/generated/developer-api.gen.js.map +1 -0
- package/dist/generated/tasks.gen.d.ts +153 -0
- package/dist/generated/tasks.gen.d.ts.map +1 -0
- package/dist/generated/tasks.gen.js +80 -0
- package/dist/generated/tasks.gen.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/examples/posing.ts +62 -0
- package/package.json +49 -0
- package/src/client.ts +55 -0
- package/src/core/assets.ts +162 -0
- package/src/core/index.ts +27 -0
- package/src/core/operations.ts +114 -0
- package/src/core/sleep.ts +22 -0
- package/src/core/tasks.ts +45 -0
- package/src/core/transport.ts +246 -0
- package/src/generated/developer-api.gen.ts +2760 -0
- package/src/generated/tasks.gen.ts +110 -0
- package/src/index.ts +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# @worldlabsai/client
|
|
2
|
+
|
|
3
|
+
Upload images, submit World Labs tasks, and retrieve typed results with the
|
|
4
|
+
World Labs Developer API client for JavaScript and TypeScript.
|
|
5
|
+
|
|
6
|
+
**Zero runtime dependencies.** The client uses the standard Fetch API and ships
|
|
7
|
+
as ES modules. It supports Node.js 22+ and other Fetch-compatible runtimes.
|
|
8
|
+
Keep API keys on your server, out of browser bundles.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Install with `npm install @worldlabsai/client`.
|
|
13
|
+
|
|
14
|
+
Methods marked `@beta` require beta access for your World Labs account.
|
|
15
|
+
Use a World Labs Developer API key to authenticate API requests.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
The client provides `assets` for uploads, `tasks` for submissions, and
|
|
20
|
+
`operations` for results. This example combines them to estimate camera poses
|
|
21
|
+
and depth from a local `frame.png`, with `WLT_API_KEY` set on the server:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { readFile } from "node:fs/promises";
|
|
25
|
+
import { assetRef, createClient } from "@worldlabsai/client";
|
|
26
|
+
|
|
27
|
+
const apiKey = process.env.WLT_API_KEY;
|
|
28
|
+
if (!apiKey) throw new Error("Set WLT_API_KEY before running this example");
|
|
29
|
+
|
|
30
|
+
const wl = createClient({ apiKey });
|
|
31
|
+
const image = await wl.assets.upload(await readFile("./frame.png"), {
|
|
32
|
+
displayName: "frame.png",
|
|
33
|
+
mimeType: "image/png",
|
|
34
|
+
});
|
|
35
|
+
const operation = await wl.tasks.images2PosedRGBD({
|
|
36
|
+
frames: [{ imageAsset: assetRef(image) }],
|
|
37
|
+
});
|
|
38
|
+
const result = await wl.operations.wait(operation, {
|
|
39
|
+
signal: AbortSignal.timeout(120_000),
|
|
40
|
+
});
|
|
41
|
+
if (result.error) throw new Error(result.error.message ?? "Task failed");
|
|
42
|
+
|
|
43
|
+
for (const { camera, depth } of result.response?.results ?? []) {
|
|
44
|
+
console.log(camera.extrinsics.position, depth.depthAsset.url);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`assetRef` converts an uploaded asset into a task input. Task methods infer the
|
|
49
|
+
operation's response type, which `operations.wait` preserves. Other tasks use
|
|
50
|
+
the same submission and polling pattern.
|
|
51
|
+
|
|
52
|
+
See [`examples/`](examples/) for runnable scripts.
|
|
53
|
+
[`posing.ts`](examples/posing.ts) accepts a local file or a downloadable image
|
|
54
|
+
URL and documents its environment variables.
|
|
55
|
+
|
|
56
|
+
## Operations and errors
|
|
57
|
+
|
|
58
|
+
A finished task can still have `result.error`; check that field before using
|
|
59
|
+
`result.response`, as in the example above.
|
|
60
|
+
|
|
61
|
+
HTTP failures reject with `ApiError`. Its `response.status` and `body` provide
|
|
62
|
+
the status code and error details. Network failures and aborts reject with the
|
|
63
|
+
underlying error.
|
|
64
|
+
|
|
65
|
+
Aborting stops the local request or polling; it does not cancel the server-side
|
|
66
|
+
task. Keep `operation.id` to check its status later with `operations.get(id)`.
|
|
67
|
+
Polling has no default overall timeout. `pollIntervalMs` sets the pause between
|
|
68
|
+
incomplete polls and defaults to 1,000 milliseconds.
|
|
69
|
+
|
|
70
|
+
`operations.wait` retries HTTP 502, 503, and 504 polling failures up to three
|
|
71
|
+
times in a row, with `pollIntervalMs` between attempts. A successful poll resets
|
|
72
|
+
the retry count. Other failures, including HTTP 429 rate limits, reject without
|
|
73
|
+
retrying.
|
|
74
|
+
|
|
75
|
+
Task submissions retry network failures and HTTP 429, 502, 503, and 504 up to
|
|
76
|
+
three times. Every attempt sends the same idempotency key and body. Retries use
|
|
77
|
+
exponential backoff with jitter and wait at least as long as `Retry-After` when
|
|
78
|
+
the server supplies it. Aborting the submission also stops retries. Validation
|
|
79
|
+
and authentication failures are not retried.
|
|
80
|
+
|
|
81
|
+
If you call the task method again yourself, reuse its `idempotencyKey`. Each
|
|
82
|
+
method call otherwise generates a new key. Passing `{ wait: true }` when
|
|
83
|
+
submitting asks the server to wait up to its own limit; it can still return an
|
|
84
|
+
unfinished operation.
|
|
85
|
+
|
|
86
|
+
## Client options
|
|
87
|
+
|
|
88
|
+
Uploads accept bytes or a `Blob`. Set `mimeType` for byte arrays or a `Blob`
|
|
89
|
+
without a type. Signed storage uploads use the configured `fetch` but bypass
|
|
90
|
+
API middleware and API-key authentication.
|
|
91
|
+
|
|
92
|
+
| Option | Use |
|
|
93
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| `apiKey` | Your Developer API key, or a function that returns a key or a promise of one before each API request. |
|
|
95
|
+
| `baseUrl` | API base URL. Defaults to `https://api.atlas-beta.worldlabs.ai`. |
|
|
96
|
+
| `fetch` | Custom Fetch implementation for API requests and uploads. Defaults to `globalThis.fetch`. |
|
|
97
|
+
| `middleware` | Wrap API requests for logging or retries. The first supplied middleware runs outermost, after API-key authentication. |
|
|
98
|
+
|
|
99
|
+
An empty key or a rejected key provider stops the request before it is sent.
|
|
100
|
+
Retry middleware must clone a request before sending it so its body can be
|
|
101
|
+
sent again, and preserve the `Idempotency-Key` across attempts.
|
|
102
|
+
|
|
103
|
+
See the [World Labs API documentation](https://docs.worldlabs.ai/) for API
|
|
104
|
+
access and usage. JSDoc and TypeScript declarations in the package describe
|
|
105
|
+
individual methods and options.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
Copyright 2026 World Labs. Licensed under the [Apache License, Version 2.0](LICENSE).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createAssets, createOperations } from "./core/index.ts";
|
|
2
|
+
import type { ApiKey, Fetch, Middleware } from "./core/index.ts";
|
|
3
|
+
import { createTasks } from "./generated/tasks.gen.ts";
|
|
4
|
+
/** Developer API origin used when `ClientOptions.baseUrl` is omitted. */
|
|
5
|
+
export declare const DEFAULT_BASE_URL = "https://api.atlas-beta.worldlabs.ai";
|
|
6
|
+
/** Configuration for a {@link WorldLabsClient}. */
|
|
7
|
+
export interface ClientOptions {
|
|
8
|
+
/** Key, or a provider resolved before each API request. Omit only when middleware handles auth. */
|
|
9
|
+
apiKey?: ApiKey;
|
|
10
|
+
/** Developer API origin. Defaults to {@link DEFAULT_BASE_URL}. */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Fetch implementation for API requests and uploads. Defaults to `globalThis.fetch`. */
|
|
13
|
+
fetch?: Fetch;
|
|
14
|
+
/** Wraps API requests after API-key auth, outermost first. Signed uploads bypass middleware. */
|
|
15
|
+
middleware?: Middleware[];
|
|
16
|
+
}
|
|
17
|
+
/** Client returned by {@link createClient}; reuse it across requests. */
|
|
18
|
+
export interface WorldLabsClient {
|
|
19
|
+
/** Upload images and manage stored assets. */
|
|
20
|
+
assets: ReturnType<typeof createAssets>;
|
|
21
|
+
/** Check task status and wait for results. */
|
|
22
|
+
operations: ReturnType<typeof createOperations>;
|
|
23
|
+
/** Submit tasks with typed inputs and responses. */
|
|
24
|
+
tasks: ReturnType<typeof createTasks>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a client for the World Labs Developer API.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Authentication, API origin, fetch, and middleware settings.
|
|
30
|
+
* @returns Asset uploads, task submission, and operation polling methods.
|
|
31
|
+
* @throws {Error} If no API key and no middleware are supplied.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createClient: (options: ClientOptions) => WorldLabsClient;
|
|
34
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAc,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAElF,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,wCAAwC,CAAC;AAEtE,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gGAAgG;IAChG,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,8CAA8C;IAC9C,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAChD,oDAAoD;IACpD,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;CACvC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,aAAa,KAAG,eAkBrD,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { apiKeyAuth, createAssets, createOperations, createTransport } from "./core/index.js";
|
|
2
|
+
import { assetsPath, createTasks, operationPath } from "./generated/tasks.gen.js";
|
|
3
|
+
/** Developer API origin used when `ClientOptions.baseUrl` is omitted. */
|
|
4
|
+
export const DEFAULT_BASE_URL = "https://api.atlas-beta.worldlabs.ai";
|
|
5
|
+
/**
|
|
6
|
+
* Create a client for the World Labs Developer API.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Authentication, API origin, fetch, and middleware settings.
|
|
9
|
+
* @returns Asset uploads, task submission, and operation polling methods.
|
|
10
|
+
* @throws {Error} If no API key and no middleware are supplied.
|
|
11
|
+
*/
|
|
12
|
+
export const createClient = (options) => {
|
|
13
|
+
const middleware = [
|
|
14
|
+
...(options.apiKey === undefined ? [] : [apiKeyAuth(options.apiKey)]),
|
|
15
|
+
...(options.middleware ?? []),
|
|
16
|
+
];
|
|
17
|
+
if (middleware.length === 0) {
|
|
18
|
+
throw new Error("createClient needs an apiKey or middleware that authenticates requests");
|
|
19
|
+
}
|
|
20
|
+
const transport = createTransport({
|
|
21
|
+
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
22
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
23
|
+
middleware,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
assets: createAssets(transport, assetsPath),
|
|
27
|
+
operations: createOperations(transport, operationPath),
|
|
28
|
+
tasks: createTasks(transport),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAElF,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,qCAAqC,CAAC;AAwBtE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAsB,EAAmB,EAAE;IACtE,MAAM,UAAU,GAAG;QACjB,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;KAC9B,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC5F,CAAC;IACD,MAAM,SAAS,GAAG,eAAe,CAAC;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,gBAAgB;QAC5C,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,UAAU;KACX,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC;QAC3C,UAAU,EAAE,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;QACtD,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC;KAC9B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Asset, AssetCreate, CompleteUploadRequest, TaskAsset } from "../generated/developer-api.gen.ts";
|
|
2
|
+
import type { Transport } from "./transport.ts";
|
|
3
|
+
/** Settings for uploading asset bytes. */
|
|
4
|
+
export interface UploadOptions extends Pick<RequestInit, "signal"> {
|
|
5
|
+
/** Name shown for the asset. */
|
|
6
|
+
displayName: string;
|
|
7
|
+
/** Overrides `Blob.type`. Required for byte arrays or a `Blob` without a type. */
|
|
8
|
+
mimeType?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Pagination and cancellation settings for listing assets. */
|
|
11
|
+
export interface ListAssetsOptions extends Pick<RequestInit, "signal"> {
|
|
12
|
+
/** Maximum number of assets to return. */
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
/** `nextPageToken` from the previous list response. Omit for the first page. */
|
|
15
|
+
pageToken?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Return the id an asset is addressed by in task requests. */
|
|
18
|
+
export declare const assetId: (asset: Asset) => string;
|
|
19
|
+
/** Convert an asset resource into a task media reference. */
|
|
20
|
+
export declare const assetRef: (asset: Asset) => TaskAsset;
|
|
21
|
+
/**
|
|
22
|
+
* Create asset upload and management methods.
|
|
23
|
+
* @param transport - Authenticated API transport, with a separate fetch for signed uploads.
|
|
24
|
+
* @param assetsPath - Asset collection route. Item routes append an `{asset}` placeholder.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createAssets: (transport: Transport, assetsPath: string) => {
|
|
27
|
+
/**
|
|
28
|
+
* Finalize an asset after its bytes have been uploaded.
|
|
29
|
+
* @param id - Asset ID from {@link assetId}.
|
|
30
|
+
* @returns The updated asset resource.
|
|
31
|
+
*/
|
|
32
|
+
completeUpload: (id: string, body?: CompleteUploadRequest, options?: Pick<RequestInit, "signal">) => Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
mimeType: string;
|
|
36
|
+
state?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetState"];
|
|
37
|
+
width?: number | null;
|
|
38
|
+
height?: number | null;
|
|
39
|
+
sizeBytes?: string | null;
|
|
40
|
+
checksum?: string | null;
|
|
41
|
+
createTime?: string | null;
|
|
42
|
+
type?: string | null;
|
|
43
|
+
parts?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetPart"][];
|
|
44
|
+
structure?: {
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
} | null;
|
|
47
|
+
producedBy?: import("../generated/developer-api.gen.ts").components["schemas"]["ProducedBy"] | null;
|
|
48
|
+
contentPath?: string | null;
|
|
49
|
+
}>;
|
|
50
|
+
/** Create an asset record. Use `upload` to create and upload a single file in one call. */
|
|
51
|
+
create: (asset: AssetCreate, options?: Pick<RequestInit, "signal">) => Promise<{
|
|
52
|
+
id: string;
|
|
53
|
+
displayName: string;
|
|
54
|
+
mimeType: string;
|
|
55
|
+
state?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetState"];
|
|
56
|
+
width?: number | null;
|
|
57
|
+
height?: number | null;
|
|
58
|
+
sizeBytes?: string | null;
|
|
59
|
+
checksum?: string | null;
|
|
60
|
+
createTime?: string | null;
|
|
61
|
+
type?: string | null;
|
|
62
|
+
parts?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetPart"][];
|
|
63
|
+
structure?: {
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
} | null;
|
|
66
|
+
producedBy?: import("../generated/developer-api.gen.ts").components["schemas"]["ProducedBy"] | null;
|
|
67
|
+
contentPath?: string | null;
|
|
68
|
+
uploads?: import("../generated/developer-api.gen.ts").components["schemas"]["UploadGrant"][];
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a temporary signed URL for reading an asset's stored bytes.
|
|
72
|
+
* @param id - Asset ID from {@link assetId}.
|
|
73
|
+
*/
|
|
74
|
+
createReadUrl: (id: string, options?: Pick<RequestInit, "signal">) => Promise<{
|
|
75
|
+
readUrl: string;
|
|
76
|
+
expiresAt: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Soft-delete an asset.
|
|
80
|
+
* @param id - Asset ID from {@link assetId}.
|
|
81
|
+
*/
|
|
82
|
+
delete: (id: string, options?: Pick<RequestInit, "signal">) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Fetch asset metadata.
|
|
85
|
+
* @param id - Asset ID from {@link assetId}.
|
|
86
|
+
*/
|
|
87
|
+
get: (id: string, options?: Pick<RequestInit, "signal">) => Promise<{
|
|
88
|
+
id: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
mimeType: string;
|
|
91
|
+
state?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetState"];
|
|
92
|
+
width?: number | null;
|
|
93
|
+
height?: number | null;
|
|
94
|
+
sizeBytes?: string | null;
|
|
95
|
+
checksum?: string | null;
|
|
96
|
+
createTime?: string | null;
|
|
97
|
+
type?: string | null;
|
|
98
|
+
parts?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetPart"][];
|
|
99
|
+
structure?: {
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
} | null;
|
|
102
|
+
producedBy?: import("../generated/developer-api.gen.ts").components["schemas"]["ProducedBy"] | null;
|
|
103
|
+
contentPath?: string | null;
|
|
104
|
+
}>;
|
|
105
|
+
/** Return one page of assets. Pass the response's `nextPageToken` to retrieve the next page. */
|
|
106
|
+
list: ({ pageSize, pageToken, ...options }?: ListAssetsOptions) => Promise<{
|
|
107
|
+
assets?: import("../generated/developer-api.gen.ts").components["schemas"]["Asset"][];
|
|
108
|
+
nextPageToken?: string;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Create an asset, upload the bytes, and mark the upload complete.
|
|
112
|
+
*
|
|
113
|
+
* @param data - Bytes to upload. A `Blob` supplies its own MIME type when present.
|
|
114
|
+
* @param options - Display name, MIME type, and cancellation settings.
|
|
115
|
+
* @returns The completed asset. Pass it to {@link assetRef} to use it in a task.
|
|
116
|
+
* @throws {Error} If neither `mimeType` nor the input `Blob` supplies a MIME type.
|
|
117
|
+
* @throws {ApiError} If an API request or storage upload fails with a non-2xx status.
|
|
118
|
+
*/
|
|
119
|
+
upload: (data: Blob | BufferSource, { displayName, mimeType, signal }: UploadOptions) => Promise<{
|
|
120
|
+
id: string;
|
|
121
|
+
displayName: string;
|
|
122
|
+
mimeType: string;
|
|
123
|
+
state?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetState"];
|
|
124
|
+
width?: number | null;
|
|
125
|
+
height?: number | null;
|
|
126
|
+
sizeBytes?: string | null;
|
|
127
|
+
checksum?: string | null;
|
|
128
|
+
createTime?: string | null;
|
|
129
|
+
type?: string | null;
|
|
130
|
+
parts?: import("../generated/developer-api.gen.ts").components["schemas"]["AssetPart"][];
|
|
131
|
+
structure?: {
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
} | null;
|
|
134
|
+
producedBy?: import("../generated/developer-api.gen.ts").components["schemas"]["ProducedBy"] | null;
|
|
135
|
+
contentPath?: string | null;
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/core/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,qBAAqB,EAKrB,SAAS,EACV,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,0CAA0C;AAC1C,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAChE,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IACpE,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,eAAO,MAAM,OAAO,GAAI,OAAO,KAAK,KAAG,MAAkB,CAAC;AAE1D,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,KAAG,SAA0C,CAAC;AAWnF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,EAAE,YAAY,MAAM;IAuBjE;;;;OAIG;yBAhBC,MAAM,SACJ,qBAAqB,YAClB,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;;;;gBAoGqrI,iEAAsB;;;;;;;gBAAmsC,iEAAsB;;;;qBAAiU,iEAAsB;;;IAnF/xL,2FAA2F;oBACrE,WAAW,YAAW,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;;;;gBAkFomoC,iEAAsB;;;;;;;gBAAmsC,iEAAsB;;;;qBAAiU,iEAAsB;;kBAA6rB,iEAAsB;;IA/Ep8sC;;;OAGG;wBACuB,MAAM,YAAW,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;;;;IAOtE;;;OAGG;iBACgB,MAAM,YAAW,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAI/D;;;OAGG;cACa,MAAM,YAAW,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;;;;gBAwD6pI,iEAAsB;;;;;;;gBAAmsC,iEAAsB;;;;qBAAiU,iEAAsB;;;IArD/xL,gGAAgG;iDAC9C,iBAAiB;iBAoDg+jD,iEAAsB;;;IA9CzjkD;;;;;;;;OAQG;mBACkB,IAAI,GAAG,YAAY,qCAAqC,aAAa;;;;gBAqC+nI,iEAAsB;;;;;;;gBAAmsC,iEAAsB;;;;qBAAiU,iEAAsB;;;CADlyL,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ApiError } from "./transport.js";
|
|
2
|
+
/** Return the id an asset is addressed by in task requests. */
|
|
3
|
+
export const assetId = (asset) => asset.id;
|
|
4
|
+
/** Convert an asset resource into a task media reference. */
|
|
5
|
+
export const assetRef = (asset) => ({ assetId: assetId(asset) });
|
|
6
|
+
const toBlob = (data, mimeType) => {
|
|
7
|
+
if (data instanceof Blob) {
|
|
8
|
+
return mimeType === undefined || mimeType === data.type
|
|
9
|
+
? data
|
|
10
|
+
: new Blob([data], { type: mimeType });
|
|
11
|
+
}
|
|
12
|
+
return new Blob([data], { type: mimeType ?? "" });
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create asset upload and management methods.
|
|
16
|
+
* @param transport - Authenticated API transport, with a separate fetch for signed uploads.
|
|
17
|
+
* @param assetsPath - Asset collection route. Item routes append an `{asset}` placeholder.
|
|
18
|
+
*/
|
|
19
|
+
export const createAssets = (transport, assetsPath) => {
|
|
20
|
+
const itemPath = `${assetsPath}/{asset}`;
|
|
21
|
+
const create = async (asset, signal) => await transport.request(assetsPath, {
|
|
22
|
+
body: { asset },
|
|
23
|
+
method: "POST",
|
|
24
|
+
...(signal ? { signal } : {}),
|
|
25
|
+
});
|
|
26
|
+
const completeUpload = async (id, body = {}, options = {}) => await transport.request(`${itemPath}:completeUpload`, {
|
|
27
|
+
body,
|
|
28
|
+
method: "POST",
|
|
29
|
+
params: { asset: id },
|
|
30
|
+
...options,
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
/**
|
|
34
|
+
* Finalize an asset after its bytes have been uploaded.
|
|
35
|
+
* @param id - Asset ID from {@link assetId}.
|
|
36
|
+
* @returns The updated asset resource.
|
|
37
|
+
*/
|
|
38
|
+
completeUpload,
|
|
39
|
+
/** Create an asset record. Use `upload` to create and upload a single file in one call. */
|
|
40
|
+
create: async (asset, options = {}) => await create(asset, options.signal),
|
|
41
|
+
/**
|
|
42
|
+
* Create a temporary signed URL for reading an asset's stored bytes.
|
|
43
|
+
* @param id - Asset ID from {@link assetId}.
|
|
44
|
+
*/
|
|
45
|
+
createReadUrl: async (id, options = {}) => await transport.request(`${itemPath}:createReadUrl`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
params: { asset: id },
|
|
48
|
+
...options,
|
|
49
|
+
}),
|
|
50
|
+
/**
|
|
51
|
+
* Soft-delete an asset.
|
|
52
|
+
* @param id - Asset ID from {@link assetId}.
|
|
53
|
+
*/
|
|
54
|
+
delete: async (id, options = {}) => {
|
|
55
|
+
await transport.request(itemPath, { method: "DELETE", params: { asset: id }, ...options });
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Fetch asset metadata.
|
|
59
|
+
* @param id - Asset ID from {@link assetId}.
|
|
60
|
+
*/
|
|
61
|
+
get: async (id, options = {}) => await transport.request(itemPath, { params: { asset: id }, ...options }),
|
|
62
|
+
/** Return one page of assets. Pass the response's `nextPageToken` to retrieve the next page. */
|
|
63
|
+
list: async ({ pageSize, pageToken, ...options } = {}) => await transport.request(assetsPath, {
|
|
64
|
+
query: { pageSize, pageToken },
|
|
65
|
+
...options,
|
|
66
|
+
}),
|
|
67
|
+
/**
|
|
68
|
+
* Create an asset, upload the bytes, and mark the upload complete.
|
|
69
|
+
*
|
|
70
|
+
* @param data - Bytes to upload. A `Blob` supplies its own MIME type when present.
|
|
71
|
+
* @param options - Display name, MIME type, and cancellation settings.
|
|
72
|
+
* @returns The completed asset. Pass it to {@link assetRef} to use it in a task.
|
|
73
|
+
* @throws {Error} If neither `mimeType` nor the input `Blob` supplies a MIME type.
|
|
74
|
+
* @throws {ApiError} If an API request or storage upload fails with a non-2xx status.
|
|
75
|
+
*/
|
|
76
|
+
upload: async (data, { displayName, mimeType, signal }) => {
|
|
77
|
+
const blob = toBlob(data, mimeType);
|
|
78
|
+
if (blob.type === "") {
|
|
79
|
+
throw new Error("upload needs a mimeType when the data does not carry one");
|
|
80
|
+
}
|
|
81
|
+
const init = signal ? { signal } : {};
|
|
82
|
+
const created = await create({ displayName }, signal);
|
|
83
|
+
const id = assetId(created);
|
|
84
|
+
const ticket = await transport.request(`${itemPath}:createUploadUrl`, {
|
|
85
|
+
body: { contentLength: blob.size, contentType: blob.type },
|
|
86
|
+
method: "POST",
|
|
87
|
+
params: { asset: id },
|
|
88
|
+
...init,
|
|
89
|
+
});
|
|
90
|
+
// The signed URL belongs to the storage host: no base URL, no API auth.
|
|
91
|
+
const stored = await transport.fetch(new Request(ticket.uploadUrl, {
|
|
92
|
+
body: blob,
|
|
93
|
+
headers: ticket.headers ?? {},
|
|
94
|
+
method: ticket.method,
|
|
95
|
+
...init,
|
|
96
|
+
}));
|
|
97
|
+
if (!stored.ok) {
|
|
98
|
+
throw new ApiError(stored, await stored.text());
|
|
99
|
+
}
|
|
100
|
+
return await completeUpload(id, { sizeBytes: blob.size }, init);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/core/assets.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { assetId, assetRef, createAssets, type ListAssetsOptions, type UploadOptions, } from "./assets.ts";
|
|
2
|
+
export { createOperations, type DoneOperation, type Operation, waitForOperation, type WaitOptions, } from "./operations.ts";
|
|
3
|
+
export { type SubmitOptions, submitTask } from "./tasks.ts";
|
|
4
|
+
export { ApiError, type ApiKey, apiKeyAuth, createTransport, type Fetch, type Middleware, type RequestOptions, type Transport, type TransportOptions, withHeader, } from "./transport.ts";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,KAAK,MAAM,EACX,UAAU,EACV,eAAe,EACf,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,UAAU,GACX,MAAM,gBAAgB,CAAC"}
|