@putdotio/sdk 13.3.2 → 14.0.1
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/README.md +6 -93
- package/dist/{forms-D5duroB1.js → forms-B9-NYUR5.js} +99 -80
- package/dist/forms-B9-NYUR5.js.map +1 -0
- package/dist/{index-C10OQIHs.d.ts → index-DJs7suHM.d.ts} +264 -365
- package/dist/index.d.ts +2 -2
- package/dist/index.js +488 -638
- package/dist/index.js.map +1 -1
- package/dist/utilities.d.ts +17 -15
- package/dist/utilities.js +41 -52
- package/dist/utilities.js.map +1 -1
- package/package.json +7 -5
- package/dist/forms-D5duroB1.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<h1>putio-sdk-typescript</h1>
|
|
7
7
|
|
|
8
8
|
<p>
|
|
9
|
-
TypeScript SDK for the <a href="https://
|
|
9
|
+
TypeScript SDK for the <a href="https://devs.put.io/api">put.io API</a>
|
|
10
10
|
</p>
|
|
11
11
|
<p>
|
|
12
12
|
Domain-first, schema-validated at the boundary, and built on standard Web APIs.
|
|
@@ -94,24 +94,6 @@ The exchange uses a form-encoded `POST` and never sends a configured bearer toke
|
|
|
94
94
|
failures are exposed as `OAuthAuthorizationCodeExchangeError`; client secrets and codes are not
|
|
95
95
|
included in validation errors.
|
|
96
96
|
|
|
97
|
-
## App-Specific Passwords
|
|
98
|
-
|
|
99
|
-
Create and manage passwords for apps that use put.io basic authentication:
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
const created = await sdk.account.appSpecificPasswords.create({
|
|
103
|
-
note: "Media server",
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
savePasswordSecurely(created.password);
|
|
107
|
-
|
|
108
|
-
const passwords = await sdk.account.appSpecificPasswords.list();
|
|
109
|
-
await sdk.account.appSpecificPasswords.delete(created.id);
|
|
110
|
-
await sdk.account.appSpecificPasswords.deleteAll();
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
The plaintext `password` is returned only by `create`. List results contain metadata instead, including a nullable `last_used_at` timestamp and a null or masked `ip_address`.
|
|
114
|
-
|
|
115
97
|
## Utilities
|
|
116
98
|
|
|
117
99
|
Shared formatting, URL, and error-localization helpers are available from the utilities subpath:
|
|
@@ -138,7 +120,7 @@ import {
|
|
|
138
120
|
PutioSdk,
|
|
139
121
|
createPutioSdkEffectClient,
|
|
140
122
|
makePutioSdkLiveClientLayer,
|
|
141
|
-
|
|
123
|
+
putioSdkLiveLayer,
|
|
142
124
|
} from "@putdotio/sdk";
|
|
143
125
|
|
|
144
126
|
const sdk = createPutioSdkEffectClient();
|
|
@@ -148,7 +130,7 @@ const program = sdk.files
|
|
|
148
130
|
per_page: 20,
|
|
149
131
|
total: 1,
|
|
150
132
|
})
|
|
151
|
-
.pipe(Effect.provide(
|
|
133
|
+
.pipe(Effect.provide(putioSdkLiveLayer({ accessToken: userAccessToken })));
|
|
152
134
|
|
|
153
135
|
const result = await Effect.runPromise(program);
|
|
154
136
|
```
|
|
@@ -163,10 +145,10 @@ const serviceProgram = Effect.gen(function* () {
|
|
|
163
145
|
```
|
|
164
146
|
|
|
165
147
|
`makePutioSdkLiveClientLayer(...)` provides the SDK service, SDK config, and default fetch-backed transport.
|
|
166
|
-
`
|
|
167
|
-
Use `
|
|
148
|
+
`putioSdkLiveLayer(...)` provides both the SDK config and the default fetch-backed transport.
|
|
149
|
+
Use `putioSdkLayer(...)` with `makePutioFetchLayer(...)` or your own `PutioHttpClient` service when you want to supply custom transport.
|
|
168
150
|
|
|
169
|
-
##
|
|
151
|
+
## Clients
|
|
170
152
|
|
|
171
153
|
Both client styles expose the same domain surface.
|
|
172
154
|
|
|
@@ -288,9 +270,6 @@ const playlistUrl = await sdk.files.getHlsStreamUrl(fileId, {
|
|
|
288
270
|
|
|
289
271
|
const vlcPlaylistUrl = await sdk.files.getXspfPlaylistUrl(fileId, { downloadToken });
|
|
290
272
|
|
|
291
|
-
// The master playlist put.io would serve, for inspecting the selected
|
|
292
|
-
// variant's CODECS and VIDEO-RANGE. `playOriginal` picks the original
|
|
293
|
-
// file over the MP4 conversion.
|
|
294
273
|
const masterPlaylist = await sdk.files.getHlsMasterPlaylist(fileId, {
|
|
295
274
|
playOriginal: false,
|
|
296
275
|
});
|
|
@@ -307,72 +286,6 @@ The SDK covers the supported public put.io API surface. It leaves out admin,
|
|
|
307
286
|
private, and service-to-service routes, browser page and callback routes, and
|
|
308
287
|
aliases of routes it already covers.
|
|
309
288
|
|
|
310
|
-
## File Lookup and Mutations
|
|
311
|
-
|
|
312
|
-
Named-child lookup avoids listing an entire folder and preserves the same query-conditioned fields as
|
|
313
|
-
`files.get`:
|
|
314
|
-
|
|
315
|
-
```ts
|
|
316
|
-
const child = await sdk.files.getChild({
|
|
317
|
-
parentId: folderId,
|
|
318
|
-
name: "movie.mp4",
|
|
319
|
-
query: { stream_url: 1 },
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
await sdk.files.touch({ fileIds: [child.id], updatedAt: new Date() });
|
|
323
|
-
const copy = await sdk.files.copy({ fileId: child.id, parentId: 0, name: "movie copy.mp4" });
|
|
324
|
-
const writableUserId = await sdk.files.canWrite(copy.id);
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
`canWrite` resolves the user ID returned by the backend when the file is writable. A non-writable,
|
|
328
|
-
missing, or payment-gated file rejects with the corresponding typed SDK error rather than returning
|
|
329
|
-
`false`.
|
|
330
|
-
|
|
331
|
-
## Transfer Torrent Operations
|
|
332
|
-
|
|
333
|
-
Torrent-backed transfers expose their original metainfo bytes and tracker mutation:
|
|
334
|
-
|
|
335
|
-
```ts
|
|
336
|
-
const torrent = await sdk.transfers.getTorrent(transferId);
|
|
337
|
-
|
|
338
|
-
await sdk.transfers.addTrackers({
|
|
339
|
-
transferId,
|
|
340
|
-
trackers: ["udp://tracker.example:80", "https://tracker.example/announce"],
|
|
341
|
-
});
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
`getTorrent` rejects for magnet-backed or non-torrent transfers. `remove` takes exactly one selector:
|
|
345
|
-
|
|
346
|
-
```ts
|
|
347
|
-
await sdk.transfers.remove({ ids: [transferId] });
|
|
348
|
-
await sdk.transfers.remove({ filter: "completed" });
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
## Folder Sort and Podcast Feeds
|
|
352
|
-
|
|
353
|
-
Folder sort settings persist per folder and apply to subsequent file listings:
|
|
354
|
-
|
|
355
|
-
```ts
|
|
356
|
-
await sdk.files.setSort({
|
|
357
|
-
fileId: folderId,
|
|
358
|
-
sortBy: "MODIFIED_DESC",
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
await sdk.files.resetSortSettings();
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
`resetSortSettings()` clears the saved sort setting for every folder, including the root folder.
|
|
365
|
-
|
|
366
|
-
Podcast links can target a folder and an explicit non-empty selection of feed types. Omit
|
|
367
|
-
`types` to request the API defaults:
|
|
368
|
-
|
|
369
|
-
```ts
|
|
370
|
-
const { links, token } = await sdk.podcast.getLinks({
|
|
371
|
-
parentId: folderId,
|
|
372
|
-
types: ["audio", "mp4"],
|
|
373
|
-
});
|
|
374
|
-
```
|
|
375
|
-
|
|
376
289
|
## TanStack Query
|
|
377
290
|
|
|
378
291
|
The Promise client plugs into TanStack Query directly; wrap Effect programs in `Effect.runPromise`:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Context, Data, Effect, Layer, Predicate, Schema } from "effect";
|
|
1
|
+
import { Context, Data, Effect, Layer, Predicate, Schema, Struct } from "effect";
|
|
2
|
+
import { dual, flow } from "effect/Function";
|
|
2
3
|
// src/core/errors.ts
|
|
3
4
|
const PutioErrorEnvelopeSchema = Schema.Struct({
|
|
4
5
|
status: Schema.optional(Schema.String),
|
|
@@ -20,19 +21,22 @@ const isKnownContractMatch = (contract, error) => {
|
|
|
20
21
|
if (contract.statusCode !== void 0) return error.status === contract.statusCode;
|
|
21
22
|
return false;
|
|
22
23
|
};
|
|
23
|
-
const isMatchableApiError = (error) => error
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
24
|
+
const isMatchableApiError = (error) => Predicate.isTagged(error, "PutioApiError") || Predicate.isTagged(error, "PutioAuthError");
|
|
25
|
+
const PutioKnownOperationErrorContractSchema = Schema.Union([Schema.Struct({
|
|
26
|
+
errorType: Schema.String,
|
|
27
|
+
statusCode: Schema.optional(Schema.Int)
|
|
28
|
+
}), Schema.Struct({
|
|
29
|
+
errorType: Schema.optional(Schema.Undefined),
|
|
30
|
+
statusCode: Schema.Int
|
|
31
|
+
})]);
|
|
32
|
+
const PutioOperationErrorReasonSchema = Schema.Union([Schema.Struct({
|
|
33
|
+
kind: Schema.Literal("error_type"),
|
|
34
|
+
errorType: Schema.String
|
|
35
|
+
}), Schema.Struct({
|
|
36
|
+
kind: Schema.Literal("status_code"),
|
|
37
|
+
statusCode: Schema.Number
|
|
38
|
+
})]);
|
|
39
|
+
const toOperationReason = (contract) => {
|
|
36
40
|
if (contract.errorType !== void 0) return {
|
|
37
41
|
kind: "error_type",
|
|
38
42
|
errorType: contract.errorType
|
|
@@ -41,10 +45,18 @@ function toOperationReason(contract) {
|
|
|
41
45
|
kind: "status_code",
|
|
42
46
|
statusCode: contract.statusCode
|
|
43
47
|
};
|
|
44
|
-
}
|
|
48
|
+
};
|
|
45
49
|
var PutioTransportError = class extends Data.TaggedError("PutioTransportError") {};
|
|
46
50
|
var PutioConfigurationError = class extends Data.TaggedError("PutioConfigurationError") {};
|
|
47
51
|
var PutioValidationError = class extends Data.TaggedError("PutioValidationError") {};
|
|
52
|
+
const RateLimitHeaderFields = {
|
|
53
|
+
action: Schema.optional(Schema.String),
|
|
54
|
+
id: Schema.optional(Schema.String),
|
|
55
|
+
limit: Schema.optional(Schema.String),
|
|
56
|
+
remaining: Schema.optional(Schema.String),
|
|
57
|
+
retryAfter: Schema.optional(Schema.String),
|
|
58
|
+
reset: Schema.optional(Schema.String)
|
|
59
|
+
};
|
|
48
60
|
const PutioResponseErrorFields = {
|
|
49
61
|
status: Schema.Int,
|
|
50
62
|
body: PutioErrorEnvelopeSchema,
|
|
@@ -54,22 +66,42 @@ var PutioApiError = class extends Schema.TaggedError()("PutioApiError", { ...Put
|
|
|
54
66
|
var PutioAuthError = class extends Schema.TaggedError()("PutioAuthError", { ...PutioResponseErrorFields }) {};
|
|
55
67
|
var PutioRateLimitError = class extends Schema.TaggedError()("PutioRateLimitError", {
|
|
56
68
|
...PutioResponseErrorFields,
|
|
57
|
-
|
|
58
|
-
id: Schema.optional(Schema.String),
|
|
59
|
-
limit: Schema.optional(Schema.String),
|
|
60
|
-
remaining: Schema.optional(Schema.String),
|
|
61
|
-
retryAfter: Schema.optional(Schema.String),
|
|
62
|
-
reset: Schema.optional(Schema.String)
|
|
69
|
+
...RateLimitHeaderFields
|
|
63
70
|
}) {};
|
|
64
71
|
var PutioOperationError = class extends Data.TaggedError("PutioOperationError") {};
|
|
65
72
|
const definePutioOperationErrorSpec = (spec) => spec;
|
|
66
73
|
const decodePutioErrorEnvelope = Schema.decodeUnknownEffect(PutioErrorEnvelopeSchema);
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
const isPutioErrorEnvelopeValue = Schema.is(PutioErrorEnvelopeSchema);
|
|
75
|
+
const isPutioErrorEnvelope = (value) => isPutioErrorEnvelopeValue(value);
|
|
76
|
+
const responseErrorFields = {
|
|
77
|
+
body: PutioErrorEnvelopeSchema,
|
|
78
|
+
status: Schema.Number
|
|
79
|
+
};
|
|
80
|
+
const isPutioApiErrorValue = Schema.is(Schema.Struct({
|
|
81
|
+
_tag: Schema.Literal("PutioApiError"),
|
|
82
|
+
...responseErrorFields
|
|
83
|
+
}));
|
|
84
|
+
const isPutioAuthErrorValue = Schema.is(Schema.Struct({
|
|
85
|
+
_tag: Schema.Literal("PutioAuthError"),
|
|
86
|
+
...responseErrorFields
|
|
87
|
+
}));
|
|
88
|
+
const isPutioRateLimitErrorValue = Schema.is(Schema.Struct({
|
|
89
|
+
_tag: Schema.Literal("PutioRateLimitError"),
|
|
90
|
+
...responseErrorFields,
|
|
91
|
+
...RateLimitHeaderFields
|
|
92
|
+
}));
|
|
93
|
+
const isPutioOperationErrorValue = Schema.is(Schema.Struct({
|
|
94
|
+
_tag: Schema.Literal("PutioOperationError"),
|
|
95
|
+
...responseErrorFields,
|
|
96
|
+
contract: PutioKnownOperationErrorContractSchema,
|
|
97
|
+
domain: Schema.String,
|
|
98
|
+
operation: Schema.String,
|
|
99
|
+
reason: PutioOperationErrorReasonSchema
|
|
100
|
+
}));
|
|
101
|
+
const isPutioApiError = (value) => isPutioApiErrorValue(value);
|
|
102
|
+
const isPutioAuthError = (value) => isPutioAuthErrorValue(value);
|
|
103
|
+
const isPutioRateLimitError = (value) => isPutioRateLimitErrorValue(value);
|
|
104
|
+
const isPutioOperationError = (value) => isPutioOperationErrorValue(value);
|
|
73
105
|
const fallbackPutioErrorEnvelope = (status) => ({
|
|
74
106
|
error_message: `put.io API request failed with status ${status}`,
|
|
75
107
|
status_code: status
|
|
@@ -86,7 +118,7 @@ const responseRateLimitHeaders = (headers) => ({
|
|
|
86
118
|
const mapDecodeErrorToValidationError = (cause) => new PutioValidationError({ cause });
|
|
87
119
|
const mapConfigurationError = (cause) => new PutioConfigurationError({ cause });
|
|
88
120
|
const mapTransportError = (cause) => new PutioTransportError({ cause });
|
|
89
|
-
const
|
|
121
|
+
const toPutioResponseError = (status, headers, body, cause) => {
|
|
90
122
|
if (status === 429) return new PutioRateLimitError({
|
|
91
123
|
status,
|
|
92
124
|
body,
|
|
@@ -104,28 +136,30 @@ const makeResponseError = (status, headers, body, cause) => {
|
|
|
104
136
|
cause
|
|
105
137
|
});
|
|
106
138
|
};
|
|
107
|
-
const parseErrorBody = (status
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
const parseErrorBody = (status) => flow(decodePutioErrorEnvelope, Effect.orElseSucceed(() => fallbackPutioErrorEnvelope(status)));
|
|
140
|
+
const withOperationErrors = dual(2, (effect, spec) => effect.pipe(Effect.mapError((error) => {
|
|
141
|
+
if (!isMatchableApiError(error)) return error;
|
|
142
|
+
const contract = spec.knownErrors.find((candidate) => isKnownContractMatch(candidate, error));
|
|
143
|
+
if (!contract) return error;
|
|
144
|
+
return new PutioOperationError({
|
|
145
|
+
body: error.body,
|
|
146
|
+
contract,
|
|
147
|
+
domain: spec.domain,
|
|
148
|
+
operation: spec.operation,
|
|
149
|
+
reason: toOperationReason(contract),
|
|
150
|
+
status: error.status
|
|
151
|
+
});
|
|
152
|
+
})));
|
|
153
|
+
// src/core/validation.ts
|
|
154
|
+
const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));
|
|
155
|
+
const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));
|
|
156
|
+
const decodeAndRun = (schema, input, run) => Schema.decodeUnknownEffect(schema, { onExcessProperty: "error" })(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap(run));
|
|
157
|
+
const cursorSelectionSchema = (idsField, excludeIdsField, fields) => Schema.Struct({
|
|
158
|
+
cursor: Schema.optional(NonEmptyStringSchema),
|
|
159
|
+
[excludeIdsField]: Schema.optional(Schema.Array(PositiveIntegerSchema)),
|
|
160
|
+
[idsField]: Schema.optional(Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1))),
|
|
161
|
+
...fields
|
|
162
|
+
}).check(Schema.makeFilter((input) => input.cursor !== void 0 || input[idsField] !== void 0, { expected: "a non-empty cursor or file ID selection" }));
|
|
129
163
|
// src/core/defaults.ts
|
|
130
164
|
const DEFAULT_PUTIO_API_BASE_URL = "https://api.put.io";
|
|
131
165
|
const DEFAULT_PUTIO_UPLOAD_BASE_URL = "https://upload.put.io";
|
|
@@ -133,15 +167,15 @@ const DEFAULT_PUTIO_WEB_APP_URL = "https://app.put.io";
|
|
|
133
167
|
// src/core/http.ts
|
|
134
168
|
var PutioSdkConfig = class extends Context.Service()("PutioSdkConfig") {};
|
|
135
169
|
var PutioHttpClient = class extends Context.Service()("PutioHttpClient") {};
|
|
136
|
-
const
|
|
170
|
+
const normalizePutioSdkOptions = (config) => ({
|
|
137
171
|
accessToken: config.accessToken,
|
|
138
172
|
baseUrl: config.baseUrl ?? "https://api.put.io",
|
|
139
173
|
headers: config.headers,
|
|
140
174
|
uploadBaseUrl: config.uploadBaseUrl ?? "https://upload.put.io",
|
|
141
175
|
webAppUrl: config.webAppUrl ?? "https://app.put.io"
|
|
142
176
|
});
|
|
143
|
-
const
|
|
144
|
-
const
|
|
177
|
+
const putioSdkLayer = (config) => Layer.succeed(PutioSdkConfig, normalizePutioSdkOptions(config));
|
|
178
|
+
const putioSdkLiveLayer = (config) => Layer.mergeAll(putioSdkLayer(config), makePutioFetchLayer());
|
|
145
179
|
const makePutioFetchLayer = (fetchImplementation = globalThis.fetch) => Layer.succeed(PutioHttpClient, makePutioFetchClient(fetchImplementation));
|
|
146
180
|
const makePutioFetchClient = (fetchImplementation = globalThis.fetch) => ({ execute: (request) => Effect.suspend(() => {
|
|
147
181
|
const controller = new AbortController();
|
|
@@ -159,7 +193,7 @@ const makePutioFetchClient = (fetchImplementation = globalThis.fetch) => ({ exec
|
|
|
159
193
|
return {
|
|
160
194
|
arrayBuffer: read(() => response.arrayBuffer()),
|
|
161
195
|
headers: response.headers,
|
|
162
|
-
json: isSuccessStatus(response.status) ? read(() => response.json()) : read(() => response.text()).pipe(Effect.flatMap((text) => Schema.decodeUnknownEffect(Schema.
|
|
196
|
+
json: isSuccessStatus(response.status) ? read(() => response.json()) : read(() => response.text()).pipe(Effect.flatMap((text) => Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(Effect.mapError(() => toPutioResponseError(response.status, response.headers, fallbackPutioErrorEnvelope(response.status), /* @__PURE__ */ new SyntaxError("The HTTP error response body is not valid JSON")))))),
|
|
163
197
|
status: response.status
|
|
164
198
|
};
|
|
165
199
|
});
|
|
@@ -181,18 +215,14 @@ const mapUrlBuildError = (cause) => cause instanceof PutioConfigurationError ? c
|
|
|
181
215
|
const OkResponseSchema = Schema.Struct({ status: Schema.Literal("OK") });
|
|
182
216
|
const isSuccessStatus = (status) => status >= 200 && status < 300;
|
|
183
217
|
const decodeSuccessJson = (schema, response) => response.json.pipe(Effect.flatMap((json) => Schema.decodeUnknownEffect(schema)(json).pipe(Effect.mapError(mapDecodeErrorToValidationError))));
|
|
184
|
-
const decodeFailure = (response, headers) => response.json.pipe(Effect.flatMap(
|
|
185
|
-
const toBasicAuthorization = (username, password) => {
|
|
186
|
-
if (typeof globalThis.btoa === "function") return `Basic ${globalThis.btoa(`${username}:${password}`)}`;
|
|
187
|
-
throw mapConfigurationError("This runtime does not provide btoa(), so Basic auth cannot be encoded safely");
|
|
188
|
-
};
|
|
218
|
+
const decodeFailure = (response, headers) => response.json.pipe(Effect.flatMap(parseErrorBody(response.status)), Effect.map((body) => toPutioResponseError(response.status, headers, body)));
|
|
189
219
|
const resolveAuthorization = (config, auth) => {
|
|
190
220
|
const resolvedAuth = auth ?? { type: "config-token" };
|
|
191
221
|
switch (resolvedAuth.type) {
|
|
192
222
|
case "none": return Effect.succeed(void 0);
|
|
193
223
|
case "token": return Effect.succeed(`Token ${resolvedAuth.token}`);
|
|
194
224
|
case "basic": return Effect.try({
|
|
195
|
-
try: () =>
|
|
225
|
+
try: () => `Basic ${btoa(`${resolvedAuth.username}:${resolvedAuth.password}`)}`,
|
|
196
226
|
catch: mapConfigurationError
|
|
197
227
|
});
|
|
198
228
|
case "config-token":
|
|
@@ -201,9 +231,9 @@ const resolveAuthorization = (config, auth) => {
|
|
|
201
231
|
}
|
|
202
232
|
};
|
|
203
233
|
const normalizeFormValue = (value) => {
|
|
204
|
-
if (value === null
|
|
205
|
-
if (
|
|
206
|
-
if (
|
|
234
|
+
if (value === null) return "";
|
|
235
|
+
if (Predicate.isString(value)) return value;
|
|
236
|
+
if (Predicate.isNumber(value) || Predicate.isBoolean(value)) return String(value);
|
|
207
237
|
return JSON.stringify(value);
|
|
208
238
|
};
|
|
209
239
|
const withBody = (body) => {
|
|
@@ -245,30 +275,19 @@ const executeRequest = (options) => Effect.gen(function* () {
|
|
|
245
275
|
});
|
|
246
276
|
const requestJson = (schema, options) => executeRequest(options).pipe(Effect.flatMap((response) => isSuccessStatus(response.status) ? decodeSuccessJson(schema, response) : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail))));
|
|
247
277
|
const selectJsonField = (field) => (effect) => effect.pipe(Effect.map((value) => value[field]));
|
|
248
|
-
const selectJsonFields = (...fields) => (effect) => effect.pipe(Effect.map((value) =>
|
|
278
|
+
const selectJsonFields = (...fields) => (effect) => effect.pipe(Effect.map((value) => Struct.pick(value, fields)));
|
|
249
279
|
const requestArrayBuffer = (options) => executeRequest(options).pipe(Effect.flatMap((response) => isSuccessStatus(response.status) ? response.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer))) : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail))));
|
|
250
280
|
const requestText = (options) => requestArrayBuffer(options).pipe(Effect.map((bytes) => new TextDecoder().decode(bytes)));
|
|
251
281
|
const requestVoid = (options) => executeRequest(options).pipe(Effect.flatMap((response) => isSuccessStatus(response.status) ? Effect.void : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail))));
|
|
252
|
-
// src/core/validation.ts
|
|
253
|
-
const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));
|
|
254
|
-
const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));
|
|
255
|
-
const decodeAndRun = (schema, input, run) => Schema.decodeUnknownEffect(schema, { onExcessProperty: "error" })(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap(run));
|
|
256
|
-
const makeCursorSelectionSchema = (idsField, excludeIdsField, fields) => Schema.Struct({
|
|
257
|
-
cursor: Schema.optional(NonEmptyStringSchema),
|
|
258
|
-
[excludeIdsField]: Schema.optional(Schema.Array(PositiveIntegerSchema)),
|
|
259
|
-
[idsField]: Schema.optional(Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1))),
|
|
260
|
-
...fields
|
|
261
|
-
}).check(Schema.makeFilter((input) => input.cursor !== void 0 || input[idsField] !== void 0, { expected: "a non-empty cursor or file ID selection" }));
|
|
262
282
|
// src/core/forms.ts
|
|
263
283
|
const joinCsv = (values) => values && values.length > 0 ? values.join(",") : void 0;
|
|
264
|
-
|
|
265
|
-
const resolvedIdsFieldName = idsFieldName ?? "file_ids";
|
|
284
|
+
function toCursorSelectionForm(selection, idsFieldName = "file_ids") {
|
|
266
285
|
return {
|
|
267
286
|
cursor: selection.cursor,
|
|
268
287
|
exclude_ids: joinCsv(selection.excludeIds),
|
|
269
|
-
[
|
|
288
|
+
[idsFieldName]: joinCsv(selection.ids)
|
|
270
289
|
};
|
|
271
|
-
}
|
|
272
|
-
export { PutioOperationError as A, isPutioOperationError as B,
|
|
290
|
+
}
|
|
291
|
+
export { PutioOperationError as A, isPutioOperationError as B, PositiveIntegerSchema as C, PutioAuthError as D, PutioApiError as E, definePutioOperationErrorSpec as F, parseErrorBody as G, mapConfigurationError as H, fallbackPutioErrorEnvelope as I, withOperationErrors as J, responseRateLimitHeaders as K, isPutioApiError as L, PutioTransportError as M, PutioValidationError as N, PutioConfigurationError as O, decodePutioErrorEnvelope as P, isPutioAuthError as R, NonEmptyStringSchema as S, decodeAndRun as T, mapDecodeErrorToValidationError as U, isPutioRateLimitError as V, mapTransportError as W, selectJsonField as _, PutioSdkConfig as a, DEFAULT_PUTIO_UPLOAD_BASE_URL as b, makePutioFetchClient as c, putioSdkLayer as d, putioSdkLiveLayer as f, requestVoid as g, requestText as h, PutioHttpClient as i, PutioRateLimitError as j, PutioErrorEnvelopeSchema as k, makePutioFetchLayer as l, requestJson as m, toCursorSelectionForm as n, buildPutioUrl as o, requestArrayBuffer as p, toPutioResponseError as q, OkResponseSchema as r, encodePathSegment as s, joinCsv as t, normalizePutioSdkOptions as u, selectJsonFields as v, cursorSelectionSchema as w, DEFAULT_PUTIO_WEB_APP_URL as x, DEFAULT_PUTIO_API_BASE_URL as y, isPutioErrorEnvelope as z };
|
|
273
292
|
|
|
274
|
-
//# sourceMappingURL=forms-
|
|
293
|
+
//# sourceMappingURL=forms-B9-NYUR5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms-B9-NYUR5.js","names":[],"sources":["../src/core/errors.ts","../src/core/validation.ts","../src/core/defaults.ts","../src/core/http.ts","../src/core/forms.ts"],"sourcesContent":["import { Data, Effect, Predicate, Schema } from \"effect\";\nimport { dual, flow } from \"effect/Function\";\n\nexport const PutioErrorEnvelopeSchema = Schema.Struct({\n status: Schema.optional(Schema.String),\n error: Schema.optional(Schema.String),\n error_message: Schema.optional(Schema.String),\n error_type: Schema.optional(Schema.String),\n error_uri: Schema.optional(Schema.String),\n error_id: Schema.optional(Schema.NullOr(Schema.String)),\n extra: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n status_code: Schema.optional(Schema.Int),\n details: Schema.optional(Schema.Unknown),\n});\n\nexport type PutioErrorEnvelope = Schema.Schema.Type<typeof PutioErrorEnvelopeSchema>;\n\nexport interface PutioKnownErrorContract<\n TType extends string = string,\n TStatus extends number = number,\n TBody extends PutioErrorEnvelope = PutioErrorEnvelope,\n> {\n readonly bodySchema?: Schema.Schema<TBody> | undefined;\n readonly errorType?: TType | undefined;\n readonly statusCode?: TStatus | undefined;\n}\n\ntype ContractErrorType<TContract extends PutioKnownErrorContract> =\n TContract extends PutioKnownErrorContract<infer TType, number> ? TType : never;\n\ntype ContractStatusCode<TContract extends PutioKnownErrorContract> =\n TContract extends PutioKnownErrorContract<string, infer TStatus> ? TStatus : never;\n\ntype ContractBody<TContract extends PutioKnownErrorContract> = TContract extends {\n readonly bodySchema: Schema.Schema<infer TBody extends PutioErrorEnvelope>;\n}\n ? TBody\n : PutioErrorEnvelope;\n\nexport type PutioTypedErrorEnvelope<TContract extends PutioKnownErrorContract> =\n TContract extends PutioKnownErrorContract\n ? Omit<ContractBody<TContract>, \"error_message\" | \"error_type\" | \"status_code\"> & {\n readonly error_message?: string;\n readonly error_type?: [ContractErrorType<TContract>] extends [never]\n ? string\n : ContractErrorType<TContract>;\n readonly status_code?: [ContractStatusCode<TContract>] extends [never]\n ? number\n : ContractStatusCode<TContract>;\n }\n : never;\n\nexport interface PutioOperationErrorSpec<\n TDomain extends string = string,\n TOperation extends string = string,\n TContracts extends ReadonlyArray<PutioKnownErrorContract> =\n ReadonlyArray<PutioKnownErrorContract>,\n> {\n readonly domain: TDomain;\n readonly operation: TOperation;\n readonly knownErrors: TContracts;\n}\n\ntype KnownOperationContractOf<TContracts extends ReadonlyArray<PutioKnownErrorContract>> = Extract<\n TContracts[number],\n PutioKnownOperationErrorContract\n>;\n\ntype PutioOperationErrorReason<TContract extends PutioKnownErrorContract> = TContract extends {\n readonly errorType: infer TType extends string;\n}\n ? {\n readonly kind: \"error_type\";\n readonly errorType: TType;\n }\n : TContract extends { readonly statusCode: infer TStatus extends number }\n ? {\n readonly kind: \"status_code\";\n readonly statusCode: TStatus;\n }\n : never;\n\nexport type PutioKnownOperationErrorContract =\n | {\n readonly errorType: string;\n readonly statusCode?: number;\n }\n | {\n readonly errorType?: undefined;\n readonly statusCode: number;\n };\n\nconst isKnownContractMatch = <TContract extends PutioKnownErrorContract>(\n contract: TContract,\n error: PutioApiError | PutioAuthError,\n): contract is TContract & PutioKnownOperationErrorContract => {\n if (contract.bodySchema !== undefined && !Schema.is(contract.bodySchema)(error.body)) {\n return false;\n }\n\n if (contract.errorType !== undefined) {\n if (error.body.error_type !== contract.errorType) {\n return false;\n }\n\n return contract.statusCode === undefined || error.status === contract.statusCode;\n }\n\n if (contract.statusCode !== undefined) {\n return error.status === contract.statusCode;\n }\n\n return false;\n};\n\nconst isMatchableApiError = (error: PutioSdkError): error is PutioApiError | PutioAuthError =>\n Predicate.isTagged(error, \"PutioApiError\") || Predicate.isTagged(error, \"PutioAuthError\");\n\nconst PutioKnownOperationErrorContractSchema = Schema.Union([\n Schema.Struct({\n errorType: Schema.String,\n statusCode: Schema.optional(Schema.Int),\n }),\n Schema.Struct({\n errorType: Schema.optional(Schema.Undefined),\n statusCode: Schema.Int,\n }),\n]);\n\nconst PutioOperationErrorReasonSchema = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"error_type\"),\n errorType: Schema.String,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"status_code\"),\n statusCode: Schema.Number,\n }),\n]);\n\nconst toOperationReason = (\n contract: PutioKnownOperationErrorContract,\n): PutioOperationErrorReason<PutioKnownOperationErrorContract> => {\n if (contract.errorType !== undefined) {\n return {\n kind: \"error_type\",\n errorType: contract.errorType,\n };\n }\n\n return {\n kind: \"status_code\",\n statusCode: contract.statusCode,\n };\n};\n\nexport class PutioTransportError extends Data.TaggedError(\"PutioTransportError\")<{\n readonly cause: unknown;\n}> {}\n\nexport class PutioConfigurationError extends Data.TaggedError(\"PutioConfigurationError\")<{\n readonly cause: unknown;\n}> {}\n\nexport class PutioValidationError extends Data.TaggedError(\"PutioValidationError\")<{\n readonly cause: unknown;\n}> {}\n\nconst RateLimitHeaderFields = {\n action: Schema.optional(Schema.String),\n id: Schema.optional(Schema.String),\n limit: Schema.optional(Schema.String),\n remaining: Schema.optional(Schema.String),\n retryAfter: Schema.optional(Schema.String),\n reset: Schema.optional(Schema.String),\n};\n\nconst PutioResponseErrorFields = {\n status: Schema.Int,\n body: PutioErrorEnvelopeSchema,\n cause: Schema.optional(Schema.Defect()),\n};\n\nexport class PutioApiError extends Schema.TaggedError<PutioApiError>()(\"PutioApiError\", {\n ...PutioResponseErrorFields,\n}) {}\n\nexport class PutioAuthError extends Schema.TaggedError<PutioAuthError>()(\"PutioAuthError\", {\n ...PutioResponseErrorFields,\n}) {}\n\nexport class PutioRateLimitError extends Schema.TaggedError<PutioRateLimitError>()(\n \"PutioRateLimitError\",\n { ...PutioResponseErrorFields, ...RateLimitHeaderFields },\n) {}\n\nexport class PutioOperationError<\n TDomain extends string,\n TOperation extends string,\n TContract extends PutioKnownOperationErrorContract,\n> extends Data.TaggedError(\"PutioOperationError\")<{\n readonly body: PutioTypedErrorEnvelope<TContract>;\n readonly contract: TContract;\n readonly domain: TDomain;\n readonly operation: TOperation;\n readonly reason: PutioOperationErrorReason<TContract>;\n readonly status: number;\n}> {}\n\nexport type PutioSdkError =\n | PutioConfigurationError\n | PutioTransportError\n | PutioValidationError\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError;\n\nexport type PutioUnhandledSdkError = PutioSdkError;\n\nexport type PutioOperationErrorFromSpec<TSpec extends PutioOperationErrorSpec> =\n PutioOperationError<\n TSpec[\"domain\"],\n TSpec[\"operation\"],\n KnownOperationContractOf<TSpec[\"knownErrors\"]>\n >;\n\nexport type PutioOperationFailure<TSpec extends PutioOperationErrorSpec> =\n | PutioUnhandledSdkError\n | PutioOperationErrorFromSpec<TSpec>;\n\nexport type AnyPutioOperationError = PutioOperationError<\n string,\n string,\n PutioKnownOperationErrorContract\n>;\n\nexport const definePutioOperationErrorSpec = <\n const TDomain extends string,\n const TOperation extends string,\n const TContracts extends ReadonlyArray<PutioKnownErrorContract>,\n>(\n spec: PutioOperationErrorSpec<TDomain, TOperation, TContracts>,\n) => spec;\n\nexport const decodePutioErrorEnvelope = Schema.decodeUnknownEffect(PutioErrorEnvelopeSchema);\n\nconst isPutioErrorEnvelopeValue = Schema.is(PutioErrorEnvelopeSchema);\n\nexport const isPutioErrorEnvelope = (value: unknown): value is PutioErrorEnvelope =>\n isPutioErrorEnvelopeValue(value);\n\nconst responseErrorFields = {\n body: PutioErrorEnvelopeSchema,\n status: Schema.Number,\n};\n\nconst isPutioApiErrorValue = Schema.is(\n Schema.Struct({ _tag: Schema.Literal(\"PutioApiError\"), ...responseErrorFields }),\n);\n\nconst isPutioAuthErrorValue = Schema.is(\n Schema.Struct({ _tag: Schema.Literal(\"PutioAuthError\"), ...responseErrorFields }),\n);\n\nconst isPutioRateLimitErrorValue = Schema.is(\n Schema.Struct({\n _tag: Schema.Literal(\"PutioRateLimitError\"),\n ...responseErrorFields,\n ...RateLimitHeaderFields,\n }),\n);\n\nconst isPutioOperationErrorValue = Schema.is(\n Schema.Struct({\n _tag: Schema.Literal(\"PutioOperationError\"),\n ...responseErrorFields,\n contract: PutioKnownOperationErrorContractSchema,\n domain: Schema.String,\n operation: Schema.String,\n reason: PutioOperationErrorReasonSchema,\n }),\n);\n\nexport const isPutioApiError = (value: unknown): value is PutioApiError =>\n isPutioApiErrorValue(value);\n\nexport const isPutioAuthError = (value: unknown): value is PutioAuthError =>\n isPutioAuthErrorValue(value);\n\nexport const isPutioRateLimitError = (value: unknown): value is PutioRateLimitError =>\n isPutioRateLimitErrorValue(value);\n\nexport const isPutioOperationError = (value: unknown): value is AnyPutioOperationError =>\n isPutioOperationErrorValue(value);\n\nexport const fallbackPutioErrorEnvelope = (status: number): PutioErrorEnvelope => ({\n error_message: `put.io API request failed with status ${status}`,\n status_code: status,\n});\n\nconst getHeader = (headers: Headers, name: string): string | undefined =>\n headers.get(name) ?? undefined;\n\nexport const responseRateLimitHeaders = (headers: Headers) => ({\n action: getHeader(headers, \"x-ratelimit-action\"),\n id: getHeader(headers, \"x-ratelimit-id\"),\n limit: getHeader(headers, \"x-ratelimit-limit\"),\n remaining: getHeader(headers, \"x-ratelimit-remaining\"),\n retryAfter: getHeader(headers, \"retry-after\"),\n reset: getHeader(headers, \"x-ratelimit-reset\"),\n});\n\nexport const mapDecodeErrorToValidationError = (cause: unknown) =>\n new PutioValidationError({ cause });\n\nexport const mapConfigurationError = (cause: unknown) => new PutioConfigurationError({ cause });\n\nexport const mapTransportError = (cause: unknown) => new PutioTransportError({ cause });\n\nexport const toPutioResponseError = (\n status: number,\n headers: Headers,\n body: PutioErrorEnvelope,\n cause?: unknown,\n): PutioSdkError => {\n if (status === 429) {\n return new PutioRateLimitError({\n status,\n body,\n ...responseRateLimitHeaders(headers),\n cause,\n });\n }\n\n if (status === 401 || status === 403) {\n return new PutioAuthError({ status, body, cause });\n }\n\n return new PutioApiError({ status, body, cause });\n};\n\nexport const parseErrorBody = (status: number) =>\n flow(\n decodePutioErrorEnvelope,\n Effect.orElseSucceed(() => fallbackPutioErrorEnvelope(status)),\n );\n\nexport const withOperationErrors: {\n <\n const TDomain extends string,\n const TOperation extends string,\n const TContracts extends ReadonlyArray<PutioKnownErrorContract>,\n >(\n spec: PutioOperationErrorSpec<TDomain, TOperation, TContracts>,\n ): <A, E extends PutioSdkError, R>(\n effect: Effect.Effect<A, E, R>,\n ) => Effect.Effect<\n A,\n E | PutioOperationError<TDomain, TOperation, KnownOperationContractOf<TContracts>>,\n R\n >;\n <\n A,\n E extends PutioSdkError,\n R,\n const TDomain extends string,\n const TOperation extends string,\n const TContracts extends ReadonlyArray<PutioKnownErrorContract>,\n >(\n effect: Effect.Effect<A, E, R>,\n spec: PutioOperationErrorSpec<TDomain, TOperation, TContracts>,\n ): Effect.Effect<\n A,\n E | PutioOperationError<TDomain, TOperation, KnownOperationContractOf<TContracts>>,\n R\n >;\n} = dual(\n 2,\n <A, E extends PutioSdkError, R>(\n effect: Effect.Effect<A, E, R>,\n spec: PutioOperationErrorSpec,\n ): Effect.Effect<A, E | AnyPutioOperationError, R> =>\n effect.pipe(\n Effect.mapError((error) => {\n if (!isMatchableApiError(error)) {\n return error;\n }\n\n const contract = spec.knownErrors.find((candidate) =>\n isKnownContractMatch(candidate, error),\n );\n\n if (!contract) {\n return error;\n }\n\n return new PutioOperationError({\n body: error.body,\n contract,\n domain: spec.domain,\n operation: spec.operation,\n reason: toOperationReason(contract),\n status: error.status,\n });\n }),\n ),\n);\n","import { Effect, Schema } from \"effect\";\n\nimport { mapDecodeErrorToValidationError } from \"./errors.js\";\n\nexport const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));\nexport const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));\n\nexport const decodeAndRun = <S extends Schema.Top, I, A, E, R>(\n schema: S,\n input: I,\n run: (decoded: S[\"Type\"]) => Effect.Effect<A, E, R>,\n) =>\n Schema.decodeUnknownEffect(schema, { onExcessProperty: \"error\" })(input).pipe(\n Effect.mapError(mapDecodeErrorToValidationError),\n Effect.flatMap(run),\n );\n\ntype CursorSelectionFields = {\n readonly cursor?: string;\n} & Readonly<Record<string, ReadonlyArray<number> | string | undefined>>;\n\nexport const cursorSelectionSchema = <\n const TIdsField extends string,\n const TExcludeIdsField extends string,\n const TFields extends Schema.Struct.Fields,\n>(\n idsField: TIdsField,\n excludeIdsField: TExcludeIdsField,\n fields: TFields,\n) =>\n Schema.Struct({\n cursor: Schema.optional(NonEmptyStringSchema),\n [excludeIdsField]: Schema.optional(Schema.Array(PositiveIntegerSchema)),\n [idsField]: Schema.optional(Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1))),\n ...fields,\n }).check(\n Schema.makeFilter(\n (input: CursorSelectionFields) => input.cursor !== undefined || input[idsField] !== undefined,\n { expected: \"a non-empty cursor or file ID selection\" },\n ),\n );\n","export const DEFAULT_PUTIO_API_BASE_URL = \"https://api.put.io\";\nexport const DEFAULT_PUTIO_UPLOAD_BASE_URL = \"https://upload.put.io\";\nexport const DEFAULT_PUTIO_WEB_APP_URL = \"https://app.put.io\";\n","import { Context, Effect, Layer, Predicate, Schema, Struct } from \"effect\";\n\nimport {\n DEFAULT_PUTIO_API_BASE_URL,\n DEFAULT_PUTIO_UPLOAD_BASE_URL,\n DEFAULT_PUTIO_WEB_APP_URL,\n} from \"./defaults.js\";\nimport {\n fallbackPutioErrorEnvelope,\n mapConfigurationError,\n mapDecodeErrorToValidationError,\n mapTransportError,\n parseErrorBody,\n PutioConfigurationError,\n type PutioSdkError,\n toPutioResponseError,\n} from \"./errors.js\";\n\nexport type PutioQueryValue = string | number | boolean | null | undefined;\n\nexport type PutioQuery = Readonly<Record<string, PutioQueryValue>>;\n\nexport type PutioPathSegment = string | number | boolean;\n\nexport interface PutioSdkOptions {\n readonly accessToken?: string;\n readonly baseUrl?: string | URL;\n readonly headers?: HeadersInit;\n readonly uploadBaseUrl?: string | URL;\n readonly webAppUrl?: string | URL;\n}\n\nexport class PutioSdkConfig extends Context.Service<PutioSdkConfig, PutioSdkOptions>()(\n \"PutioSdkConfig\",\n) {}\n\nexport interface PutioHttpRequest {\n readonly body?: BodyInit;\n readonly headers: Headers;\n readonly method: PutioRequestMethod;\n readonly url: string;\n}\n\nexport interface PutioHttpResponse {\n readonly arrayBuffer: Effect.Effect<ArrayBuffer, PutioSdkError>;\n readonly headers: Headers;\n readonly json: Effect.Effect<unknown, PutioSdkError>;\n readonly status: number;\n}\n\nexport interface PutioHttpClientService {\n readonly execute: (request: PutioHttpRequest) => Effect.Effect<PutioHttpResponse, PutioSdkError>;\n}\n\nexport class PutioHttpClient extends Context.Service<PutioHttpClient, PutioHttpClientService>()(\n \"PutioHttpClient\",\n) {}\n\nexport type PutioSdkContext = PutioSdkConfig | PutioHttpClient;\n\nexport const normalizePutioSdkOptions = (config: PutioSdkOptions): PutioSdkOptions => ({\n accessToken: config.accessToken,\n baseUrl: config.baseUrl ?? DEFAULT_PUTIO_API_BASE_URL,\n headers: config.headers,\n uploadBaseUrl: config.uploadBaseUrl ?? DEFAULT_PUTIO_UPLOAD_BASE_URL,\n webAppUrl: config.webAppUrl ?? DEFAULT_PUTIO_WEB_APP_URL,\n});\n\nexport const putioSdkLayer = (config: PutioSdkOptions) =>\n Layer.succeed(PutioSdkConfig, normalizePutioSdkOptions(config));\n\nexport const putioSdkLiveLayer = (config: PutioSdkOptions) =>\n Layer.mergeAll(putioSdkLayer(config), makePutioFetchLayer());\n\nexport const makePutioFetchLayer = (\n fetchImplementation: typeof globalThis.fetch = globalThis.fetch,\n) => Layer.succeed(PutioHttpClient, makePutioFetchClient(fetchImplementation));\n\nexport const makePutioFetchClient = (\n fetchImplementation: typeof globalThis.fetch = globalThis.fetch,\n): PutioHttpClientService => ({\n execute: (request) =>\n Effect.suspend(() => {\n const controller = new AbortController();\n\n const read = <A>(body: () => Promise<A>) =>\n Effect.tryPromise({ try: body, catch: mapTransportError }).pipe(\n Effect.onInterrupt(() => Effect.sync(() => controller.abort())),\n );\n\n return read(async () => {\n const response = await fetchImplementation(request.url, {\n body: request.body,\n headers: request.headers,\n method: request.method,\n signal: controller.signal,\n });\n\n return {\n arrayBuffer: read(() => response.arrayBuffer()),\n headers: response.headers,\n json: isSuccessStatus(response.status)\n ? read(() => response.json())\n : read(() => response.text()).pipe(\n Effect.flatMap((text) =>\n Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(\n Effect.mapError(() =>\n toPutioResponseError(\n response.status,\n response.headers,\n fallbackPutioErrorEnvelope(response.status),\n new SyntaxError(\"The HTTP error response body is not valid JSON\"),\n ),\n ),\n ),\n ),\n ),\n status: response.status,\n };\n });\n }),\n});\n\nexport const encodePathSegment = (value: PutioPathSegment): string =>\n encodeURIComponent(String(value));\n\nconst absoluteUrlPattern = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i;\n\nconst normalizeApiPath = (path: string): string => {\n if (absoluteUrlPattern.test(path)) {\n throw mapConfigurationError(\"SDK API request paths must be relative to the configured baseUrl\");\n }\n\n return path.startsWith(\"/\") ? path : `/${path}`;\n};\n\nexport const buildPutioUrl = (baseUrl: string | URL, path: string, query?: PutioQuery): string => {\n const url = new URL(normalizeApiPath(path), baseUrl);\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n return url.toString();\n};\n\nconst mapUrlBuildError = (cause: unknown) =>\n cause instanceof PutioConfigurationError ? cause : mapConfigurationError(cause);\n\nexport const OkResponseSchema = Schema.Struct({\n status: Schema.Literal(\"OK\"),\n});\n\nexport type PutioAuth =\n | { readonly type: \"config-token\" }\n | { readonly type: \"token\"; readonly token: string }\n | { readonly type: \"basic\"; readonly username: string; readonly password: string }\n | { readonly type: \"none\" };\n\ntype PutioRequestMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ntype PutioRequestBody =\n | { readonly type: \"none\" }\n | { readonly type: \"json\"; readonly value: unknown }\n | { readonly type: \"form\"; readonly value: Readonly<Record<string, Schema.Json | undefined>> }\n | { readonly type: \"form-data\"; readonly value: FormData };\n\ninterface PutioRequestOptions {\n readonly method: PutioRequestMethod;\n readonly path: string;\n readonly baseUrl?: string | URL;\n readonly query?: PutioQuery;\n readonly headers?: HeadersInit;\n readonly auth?: PutioAuth;\n readonly body?: PutioRequestBody;\n}\n\nconst isSuccessStatus = (status: number) => status >= 200 && status < 300;\n\nconst decodeSuccessJson = <S extends Schema.Top>(schema: S, response: PutioHttpResponse) =>\n response.json.pipe(\n Effect.flatMap((json) =>\n Schema.decodeUnknownEffect(schema)(json).pipe(\n Effect.mapError(mapDecodeErrorToValidationError),\n ),\n ),\n );\n\nconst decodeFailure = (response: PutioHttpResponse, headers: Headers) =>\n response.json.pipe(\n Effect.flatMap(parseErrorBody(response.status)),\n Effect.map((body) => toPutioResponseError(response.status, headers, body)),\n );\n\nconst resolveAuthorization = (\n config: PutioSdkOptions,\n auth: PutioAuth | undefined,\n): Effect.Effect<string | undefined, PutioSdkError> => {\n const resolvedAuth = auth ?? { type: \"config-token\" as const };\n\n switch (resolvedAuth.type) {\n case \"none\":\n return Effect.succeed(undefined);\n case \"token\":\n return Effect.succeed(`Token ${resolvedAuth.token}`);\n case \"basic\":\n return Effect.try({\n try: () => `Basic ${btoa(`${resolvedAuth.username}:${resolvedAuth.password}`)}`,\n catch: mapConfigurationError,\n });\n case \"config-token\":\n if (!config.accessToken) {\n return Effect.fail(\n mapConfigurationError(\n \"This endpoint requires an access token, but PutioSdkConfig.accessToken is missing\",\n ),\n );\n }\n\n return Effect.succeed(`Token ${config.accessToken}`);\n }\n};\n\nconst normalizeFormValue = (value: Schema.Json): string => {\n if (value === null) {\n return \"\";\n }\n\n if (Predicate.isString(value)) {\n return value;\n }\n\n if (Predicate.isNumber(value) || Predicate.isBoolean(value)) {\n return String(value);\n }\n\n return JSON.stringify(value);\n};\n\nconst withBody = (body: PutioRequestBody): Effect.Effect<BodyInit | undefined, PutioSdkError> => {\n switch (body.type) {\n case \"none\":\n return Effect.succeed(undefined);\n case \"json\":\n return Effect.try({\n try: () => JSON.stringify(body.value),\n catch: mapDecodeErrorToValidationError,\n });\n case \"form\":\n return Effect.succeed(\n new URLSearchParams(\n Object.entries(body.value).flatMap(([key, value]) =>\n value === undefined ? [] : [[key, normalizeFormValue(value)]],\n ),\n ),\n );\n case \"form-data\":\n return Effect.succeed(body.value);\n }\n};\n\nconst makeRequest = (\n url: string,\n options: PutioRequestOptions,\n configHeaders: HeadersInit | undefined,\n authorization?: string,\n) =>\n Effect.gen(function* () {\n const headers = new Headers(configHeaders);\n headers.delete(\"authorization\");\n new Headers(options.headers).forEach((value, name) => headers.set(name, value));\n\n const body = options.body ?? { type: \"none\" as const };\n\n if (!headers.has(\"accept\")) {\n headers.set(\"accept\", \"application/json\");\n }\n\n if (authorization) {\n headers.set(\"authorization\", authorization);\n }\n\n if (body.type === \"json\" && !headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n\n return {\n body: yield* withBody(body),\n headers,\n method: options.method,\n url,\n };\n });\n\nconst executeRequest = (options: PutioRequestOptions) =>\n Effect.gen(function* () {\n const config = yield* PutioSdkConfig;\n const httpClient = yield* PutioHttpClient;\n const authorization = yield* resolveAuthorization(config, options.auth);\n\n const url = yield* Effect.try({\n try: () =>\n buildPutioUrl(\n options.baseUrl ?? config.baseUrl ?? DEFAULT_PUTIO_API_BASE_URL,\n options.path,\n options.query,\n ),\n catch: mapUrlBuildError,\n });\n\n const request = yield* makeRequest(url, options, config.headers, authorization);\n\n return yield* httpClient.execute(request);\n });\n\nexport const requestJson = <S extends Schema.Top>(\n schema: S,\n options: PutioRequestOptions,\n): Effect.Effect<S[\"Type\"], PutioSdkError, PutioSdkContext | S[\"DecodingServices\"]> =>\n executeRequest(options).pipe(\n Effect.flatMap((response) =>\n isSuccessStatus(response.status)\n ? decodeSuccessJson(schema, response)\n : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail)),\n ),\n );\n\nexport const selectJsonField =\n <K extends string>(field: K) =>\n <A extends { readonly [P in K]: unknown }, E, R>(\n effect: Effect.Effect<A, E, R>,\n ): Effect.Effect<A[K], E, R> =>\n effect.pipe(Effect.map((value) => value[field]));\n\nexport const selectJsonFields =\n <const K extends readonly string[]>(...fields: K) =>\n <A extends { readonly [P in K[number]]: unknown }, E, R>(\n effect: Effect.Effect<A, E, R>,\n ): Effect.Effect<Pick<A, K[number]>, E, R> =>\n effect.pipe(Effect.map((value) => Struct.pick(value, fields)));\n\nexport const requestArrayBuffer = (\n options: PutioRequestOptions,\n): Effect.Effect<Uint8Array, PutioSdkError, PutioSdkContext> =>\n executeRequest(options).pipe(\n Effect.flatMap((response) =>\n isSuccessStatus(response.status)\n ? response.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer)))\n : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail)),\n ),\n );\n\nexport const requestText = (\n options: PutioRequestOptions,\n): Effect.Effect<string, PutioSdkError, PutioSdkContext> =>\n requestArrayBuffer(options).pipe(Effect.map((bytes) => new TextDecoder().decode(bytes)));\n\nexport const requestVoid = (\n options: PutioRequestOptions,\n): Effect.Effect<void, PutioSdkError, PutioSdkContext> =>\n executeRequest(options).pipe(\n Effect.flatMap((response) =>\n isSuccessStatus(response.status)\n ? Effect.void\n : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail)),\n ),\n );\n","type CsvValue = string | number;\n\nexport interface CursorSelectionInput<TValue extends CsvValue = number> {\n readonly cursor?: string;\n readonly excludeIds?: ReadonlyArray<TValue>;\n readonly ids?: ReadonlyArray<TValue>;\n}\n\nexport const joinCsv = <TValue extends CsvValue>(\n values: ReadonlyArray<TValue> | undefined,\n): string | undefined => (values && values.length > 0 ? values.join(\",\") : undefined);\n\ntype CursorSelectionForm<TIdsFieldName extends string> = {\n readonly cursor?: string;\n readonly exclude_ids?: string;\n} & Record<TIdsFieldName, string | undefined>;\n\nexport function toCursorSelectionForm<TValue extends CsvValue>(\n selection: CursorSelectionInput<TValue>,\n): CursorSelectionForm<\"file_ids\">;\nexport function toCursorSelectionForm<TValue extends CsvValue, const TIdsFieldName extends string>(\n selection: CursorSelectionInput<TValue>,\n idsFieldName: TIdsFieldName,\n): CursorSelectionForm<TIdsFieldName>;\nexport function toCursorSelectionForm(\n selection: CursorSelectionInput<CsvValue>,\n idsFieldName = \"file_ids\",\n): CursorSelectionForm<string> {\n return {\n cursor: selection.cursor,\n exclude_ids: joinCsv(selection.excludeIds),\n [idsFieldName]: joinCsv(selection.ids),\n };\n}\n"],"mappings":";;;AAGA,MAAa,2BAA2B,OAAO,OAAO;CACpD,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,eAAe,OAAO,SAAS,OAAO,MAAM;CAC5C,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,UAAU,OAAO,SAAS,OAAO,OAAO,OAAO,MAAM,CAAC;CACtD,OAAO,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC;CACnE,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC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