@putdotio/sdk 15.1.0 → 16.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 +40 -4
- package/dist/{forms-CbYS70jk.js → forms-DQ34jmDg.js} +92 -56
- package/dist/forms-DQ34jmDg.js.map +1 -0
- package/dist/{index-BOD2bQhk.d.ts → index-Bsp5xXc1.d.ts} +12935 -8052
- package/dist/index.d.ts +2 -2
- package/dist/index.js +166 -160
- package/dist/index.js.map +1 -1
- package/dist/utilities.d.ts +3 -3
- package/dist/utilities.js +3 -3
- package/dist/utilities.js.map +1 -1
- package/package.json +5 -3
- package/dist/forms-CbYS70jk.js.map +0 -1
package/README.md
CHANGED
|
@@ -75,6 +75,8 @@ const account = await sdk.account.getInfo({});
|
|
|
75
75
|
sdk.setAccessToken(undefined);
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
`accessToken` and `setAccessToken(...)` take a string or an Effect `Redacted<string>`. The SDK stores the token as `Redacted`, so `PutioSdkConfig` never prints it, and unwraps it only to build the `Authorization` header.
|
|
79
|
+
|
|
78
80
|
The token is snapshotted when each Promise-client operation is invoked. Token changes apply to subsequent operations; an operation already in flight keeps the snapshot it started with. Base, upload, and web app URLs remain fixed from client creation.
|
|
79
81
|
|
|
80
82
|
Authorization-code clients can exchange a code without configuring a default access token:
|
|
@@ -127,14 +129,21 @@ const sdk = createPutioSdkEffectClient();
|
|
|
127
129
|
|
|
128
130
|
const program = sdk.files
|
|
129
131
|
.list(0, {
|
|
132
|
+
breadcrumbs: 1,
|
|
130
133
|
per_page: 20,
|
|
131
|
-
total: 1,
|
|
132
134
|
})
|
|
133
135
|
.pipe(Effect.provide(putioSdkLiveLayer({ accessToken: userAccessToken })));
|
|
134
136
|
|
|
135
|
-
const
|
|
137
|
+
const { breadcrumbs, files } = await Effect.runPromise(program);
|
|
136
138
|
```
|
|
137
139
|
|
|
140
|
+
A field the query asks for is required in the result type, and the call fails with
|
|
141
|
+
`PutioContractError` when the response leaves it out: `breadcrumbs` on `files.list` and
|
|
142
|
+
`sharing.publicAccess.listFiles`, `cursor` and `total` on `transfers.list` with `per_page`, and the
|
|
143
|
+
flags of `account.getInfo`, `files.get`, and `files.getChild`. One flag is exempt: `intercom` leaves
|
|
144
|
+
`user_hash` optional. The Effect client, the `PutioSdk` service, and the Promise client share these
|
|
145
|
+
checks and result types.
|
|
146
|
+
|
|
138
147
|
Effect workflows can also depend on the SDK as a service:
|
|
139
148
|
|
|
140
149
|
```ts
|
|
@@ -145,6 +154,8 @@ const serviceProgram = Effect.gen(function* () {
|
|
|
145
154
|
```
|
|
146
155
|
|
|
147
156
|
`makePutioSdkLiveClientLayer(...)` provides the SDK service, SDK config, and default fetch-backed transport.
|
|
157
|
+
`PutioSdk` methods need no further services: `makePutioSdkEffectClientLayer()` reads `PutioSdkConfig` and `PutioHttpClient` once and provides them to every operation, so a test can replace `PutioSdk` alone.
|
|
158
|
+
The free domain functions and `createPutioSdkEffectClient()` keep requiring both services.
|
|
148
159
|
`putioSdkLiveLayer(...)` provides both the SDK config and the default fetch-backed transport.
|
|
149
160
|
Use `putioSdkLayer(...)` with `makePutioFetchLayer(...)` or your own `PutioHttpClient` service when you want to supply custom transport.
|
|
150
161
|
|
|
@@ -211,6 +222,20 @@ polyfills or adapters instead of patching the SDK surface.
|
|
|
211
222
|
Backend error bodies parse into `PutioErrorEnvelopeSchema` in
|
|
212
223
|
[src/core/errors.ts](./src/core/errors.ts); current backend errors carry metadata in `extra`.
|
|
213
224
|
|
|
225
|
+
Each error tag names who has to act, and each has an `isPutio*` guard:
|
|
226
|
+
|
|
227
|
+
| Tag | Meaning | Who acts |
|
|
228
|
+
| -------------------------------------------------------- | ------------------------------------------------------------------ | ---------------------- |
|
|
229
|
+
| `PutioValidationError` | Your arguments are invalid, or a value fails the schema you passed | You fix the call |
|
|
230
|
+
| `PutioConfigurationError` | The client options are missing or invalid, such as no access token | You fix the setup |
|
|
231
|
+
| `PutioContractError` | A 2xx response was not JSON or did not match the expected shape | Report it; retry later |
|
|
232
|
+
| `PutioTransportError` | The request or the response body read failed | Retry |
|
|
233
|
+
| `PutioApiError`, `PutioAuthError`, `PutioRateLimitError` | put.io answered with an error status | Read `status`, `body` |
|
|
234
|
+
| `PutioOperationError` | An error status the operation documents | Branch on `operation` |
|
|
235
|
+
|
|
236
|
+
`PutioContractError.missingField` names a field you requested with a query flag, such as
|
|
237
|
+
`stream_url`, that the response left out.
|
|
238
|
+
|
|
214
239
|
Promise consumers receive tagged SDK error objects:
|
|
215
240
|
|
|
216
241
|
```ts
|
|
@@ -226,7 +251,7 @@ const sdk = createPutioSdkPromiseClient({
|
|
|
226
251
|
|
|
227
252
|
try {
|
|
228
253
|
await sdk.files.createFolder({
|
|
229
|
-
name: "",
|
|
254
|
+
name: "Downloads",
|
|
230
255
|
parent_id: 0,
|
|
231
256
|
});
|
|
232
257
|
} catch (error) {
|
|
@@ -259,7 +284,7 @@ import { PutioSdk, makePutioSdkLiveClientLayer } from "@putdotio/sdk";
|
|
|
259
284
|
const handled = Effect.gen(function* () {
|
|
260
285
|
const sdk = yield* PutioSdk;
|
|
261
286
|
return yield* sdk.files.createFolder({
|
|
262
|
-
name: "",
|
|
287
|
+
name: "Downloads",
|
|
263
288
|
parent_id: 0,
|
|
264
289
|
});
|
|
265
290
|
}).pipe(
|
|
@@ -301,6 +326,17 @@ const upload = await sdk.files.upload({
|
|
|
301
326
|
});
|
|
302
327
|
```
|
|
303
328
|
|
|
329
|
+
## Bulk Selections
|
|
330
|
+
|
|
331
|
+
Bulk operations take file IDs or a list cursor, and reject a selection that has neither before
|
|
332
|
+
sending a request:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
await sdk.downloadLinks.create({ ids: [fileId] });
|
|
336
|
+
await sdk.sharing.clone({ cursor, excludeIds: [skippedFileId], parentId: 0 });
|
|
337
|
+
await sdk.zips.create({ file_ids: [fileId] });
|
|
338
|
+
```
|
|
339
|
+
|
|
304
340
|
## Endpoint Coverage
|
|
305
341
|
|
|
306
342
|
The SDK covers the supported public put.io API surface. It leaves out admin,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Data, Effect, Layer, Predicate, Schema, Struct } from "effect";
|
|
1
|
+
import { Context, Data, Effect, Layer, Predicate, Redacted, Schema, Struct } from "effect";
|
|
2
2
|
import { dual, flow } from "effect/Function";
|
|
3
3
|
// src/core/errors.ts
|
|
4
4
|
const PutioErrorEnvelopeSchema = Schema.Struct({
|
|
@@ -34,7 +34,7 @@ const PutioOperationErrorReasonSchema = Schema.Union([Schema.Struct({
|
|
|
34
34
|
errorType: Schema.String
|
|
35
35
|
}), Schema.Struct({
|
|
36
36
|
kind: Schema.Literal("status_code"),
|
|
37
|
-
statusCode: Schema.
|
|
37
|
+
statusCode: Schema.Int
|
|
38
38
|
})]);
|
|
39
39
|
const toOperationReason = (contract) => {
|
|
40
40
|
if (contract.errorType !== void 0) return {
|
|
@@ -46,16 +46,21 @@ const toOperationReason = (contract) => {
|
|
|
46
46
|
statusCode: contract.statusCode
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
var
|
|
49
|
+
const CauseErrorFields = { cause: Schema.Defect() };
|
|
50
|
+
var PutioTransportError = class extends Schema.TaggedError()("PutioTransportError", { ...CauseErrorFields }) {};
|
|
51
|
+
var PutioConfigurationError = class extends Schema.TaggedError()("PutioConfigurationError", { ...CauseErrorFields }) {};
|
|
52
|
+
var PutioValidationError = class extends Schema.TaggedError()("PutioValidationError", { ...CauseErrorFields }) {};
|
|
53
|
+
var PutioContractError = class extends Schema.TaggedError()("PutioContractError", {
|
|
54
|
+
cause: Schema.optional(Schema.Defect()),
|
|
55
|
+
missingField: Schema.optional(Schema.String)
|
|
56
|
+
}) {};
|
|
52
57
|
const RateLimitHeaderFields = {
|
|
53
58
|
action: Schema.optional(Schema.String),
|
|
54
59
|
id: Schema.optional(Schema.String),
|
|
55
60
|
limit: Schema.optional(Schema.String),
|
|
56
61
|
remaining: Schema.optional(Schema.String),
|
|
57
62
|
retryAfter: Schema.optional(Schema.String),
|
|
58
|
-
retryAfterSeconds: Schema.optional(Schema.
|
|
63
|
+
retryAfterSeconds: Schema.optional(Schema.Finite),
|
|
59
64
|
reset: Schema.optional(Schema.String)
|
|
60
65
|
};
|
|
61
66
|
const PutioResponseErrorFields = {
|
|
@@ -74,31 +79,35 @@ const definePutioOperationErrorSpec = (spec) => spec;
|
|
|
74
79
|
const decodePutioErrorEnvelope = Schema.decodeUnknownEffect(PutioErrorEnvelopeSchema);
|
|
75
80
|
const isPutioErrorEnvelopeValue = Schema.is(PutioErrorEnvelopeSchema);
|
|
76
81
|
const isPutioErrorEnvelope = (value) => isPutioErrorEnvelopeValue(value);
|
|
77
|
-
const
|
|
78
|
-
body:
|
|
79
|
-
status:
|
|
80
|
-
};
|
|
81
|
-
const PutioApiErrorValueSchema = Schema.Struct({
|
|
82
|
-
_tag: Schema.Literal("PutioApiError"),
|
|
83
|
-
...responseErrorFields
|
|
84
|
-
});
|
|
85
|
-
const PutioAuthErrorValueSchema = Schema.Struct({
|
|
86
|
-
_tag: Schema.Literal("PutioAuthError"),
|
|
87
|
-
...responseErrorFields
|
|
88
|
-
});
|
|
89
|
-
const PutioRateLimitErrorValueSchema = Schema.Struct({
|
|
90
|
-
_tag: Schema.Literal("PutioRateLimitError"),
|
|
91
|
-
...responseErrorFields,
|
|
92
|
-
...RateLimitHeaderFields
|
|
93
|
-
});
|
|
94
|
-
const PutioOperationErrorValueSchema = Schema.Struct({
|
|
95
|
-
_tag: Schema.Literal("PutioOperationError"),
|
|
96
|
-
...responseErrorFields,
|
|
82
|
+
const PutioOperationErrorValueSchema = Schema.TaggedStruct("PutioOperationError", {
|
|
83
|
+
body: PutioResponseErrorFields.body,
|
|
84
|
+
status: PutioResponseErrorFields.status,
|
|
97
85
|
contract: PutioKnownOperationErrorContractSchema,
|
|
98
86
|
domain: Schema.String,
|
|
99
87
|
operation: Schema.String,
|
|
100
88
|
reason: PutioOperationErrorReasonSchema
|
|
101
89
|
});
|
|
90
|
+
const CauseErrorValueFields = { cause: Schema.optional(Schema.Defect()) };
|
|
91
|
+
const PutioTransportErrorValueSchema = Schema.Struct({
|
|
92
|
+
...PutioTransportError.fields,
|
|
93
|
+
...CauseErrorValueFields
|
|
94
|
+
});
|
|
95
|
+
const PutioConfigurationErrorValueSchema = Schema.Struct({
|
|
96
|
+
...PutioConfigurationError.fields,
|
|
97
|
+
...CauseErrorValueFields
|
|
98
|
+
});
|
|
99
|
+
const PutioValidationErrorValueSchema = Schema.Struct({
|
|
100
|
+
...PutioValidationError.fields,
|
|
101
|
+
...CauseErrorValueFields
|
|
102
|
+
});
|
|
103
|
+
const PutioContractErrorValueSchema = Schema.Struct(PutioContractError.fields);
|
|
104
|
+
const PutioApiErrorValueSchema = Schema.Struct(PutioApiError.fields);
|
|
105
|
+
const PutioAuthErrorValueSchema = Schema.Struct(PutioAuthError.fields);
|
|
106
|
+
const PutioRateLimitErrorValueSchema = Schema.Struct(PutioRateLimitError.fields);
|
|
107
|
+
const isPutioTransportError = Schema.is(PutioTransportErrorValueSchema);
|
|
108
|
+
const isPutioConfigurationError = Schema.is(PutioConfigurationErrorValueSchema);
|
|
109
|
+
const isPutioValidationError = Schema.is(PutioValidationErrorValueSchema);
|
|
110
|
+
const isPutioContractError = Schema.is(PutioContractErrorValueSchema);
|
|
102
111
|
const isPutioApiError = Schema.is(PutioApiErrorValueSchema);
|
|
103
112
|
const isPutioAuthError = Schema.is(PutioAuthErrorValueSchema);
|
|
104
113
|
const isPutioRateLimitError = Schema.is(PutioRateLimitErrorValueSchema);
|
|
@@ -133,7 +142,8 @@ const responseRateLimitHeaders = (headers) => {
|
|
|
133
142
|
reset: getHeader(headers, "x-ratelimit-reset")
|
|
134
143
|
};
|
|
135
144
|
};
|
|
136
|
-
const
|
|
145
|
+
const mapValidationError = (cause) => new PutioValidationError({ cause });
|
|
146
|
+
const mapContractError = (cause) => new PutioContractError({ cause });
|
|
137
147
|
const mapConfigurationError = (cause) => new PutioConfigurationError({ cause });
|
|
138
148
|
const mapTransportError = (cause) => new PutioTransportError({ cause });
|
|
139
149
|
const toPutioResponseError = (status, headers, body, cause) => {
|
|
@@ -171,12 +181,15 @@ const withOperationErrors = dual(2, (effect, spec) => effect.pipe(Effect.mapErro
|
|
|
171
181
|
// src/core/validation.ts
|
|
172
182
|
const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));
|
|
173
183
|
const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));
|
|
174
|
-
const
|
|
184
|
+
const NonNegativeNumberSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
185
|
+
const decodeAndRun = (schema, input, run) => Schema.decodeUnknownEffect(schema, { onExcessProperty: "error" })(input).pipe(Effect.mapError(mapValidationError), Effect.flatMap(run));
|
|
175
186
|
const decodeAndRunRedacted = (domain, operation) => (schema, input, run) => Schema.decodeUnknownEffect(schema, { onExcessProperty: "error" })(input).pipe(Effect.mapError(() => new PutioValidationError({ cause: {
|
|
176
187
|
domain,
|
|
177
188
|
operation,
|
|
178
189
|
reason: "Invalid request input"
|
|
179
190
|
} })), Effect.flatMap(run));
|
|
191
|
+
const failMissingField = (field) => Effect.fail(new PutioContractError({ missingField: field }));
|
|
192
|
+
const requireRequestedBreadcrumbs = (query) => (effect) => effect.pipe(Effect.filterOrElse((response) => query.breadcrumbs !== 1 || response.breadcrumbs !== void 0, () => failMissingField("breadcrumbs")));
|
|
180
193
|
const cursorSelectionSchema = (fields) => Schema.Struct({
|
|
181
194
|
cursor: Schema.optional(NonEmptyStringSchema),
|
|
182
195
|
excludeIds: Schema.optional(Schema.Array(PositiveIntegerSchema)),
|
|
@@ -187,11 +200,25 @@ const cursorSelectionSchema = (fields) => Schema.Struct({
|
|
|
187
200
|
const DEFAULT_PUTIO_API_BASE_URL = "https://api.put.io";
|
|
188
201
|
const DEFAULT_PUTIO_UPLOAD_BASE_URL = "https://upload.put.io";
|
|
189
202
|
const DEFAULT_PUTIO_WEB_APP_URL = "https://app.put.io";
|
|
203
|
+
// src/core/response-body.ts
|
|
204
|
+
const isSuccessStatus = (status) => status >= 200 && status < 300;
|
|
205
|
+
const unparsableJsonBodyError = (status, headers) => isSuccessStatus(status) ? mapContractError(/* @__PURE__ */ new SyntaxError("The HTTP response body is not valid JSON")) : toPutioResponseError(status, headers, fallbackPutioErrorEnvelope(status), /* @__PURE__ */ new SyntaxError("The HTTP error response body is not valid JSON"));
|
|
206
|
+
// src/core/secrets.ts
|
|
207
|
+
const revealSecret = (secret) => Predicate.isString(secret) ? Effect.succeed(secret) : Effect.try({
|
|
208
|
+
try: () => Redacted.value(secret),
|
|
209
|
+
catch: mapConfigurationError
|
|
210
|
+
});
|
|
211
|
+
const revealAccessToken = (accessToken) => accessToken === void 0 ? Effect.undefined : revealSecret(accessToken).pipe(Effect.map((token) => token === "" ? void 0 : token));
|
|
190
212
|
// src/core/http.ts
|
|
191
|
-
var PutioSdkConfig = class extends Context.Service()("PutioSdkConfig") {};
|
|
192
|
-
var PutioHttpClient = class extends Context.Service()("PutioHttpClient") {};
|
|
213
|
+
var PutioSdkConfig = class extends Context.Service()("@putdotio/sdk/PutioSdkConfig") {};
|
|
214
|
+
var PutioHttpClient = class extends Context.Service()("@putdotio/sdk/PutioHttpClient") {};
|
|
215
|
+
const redactPutioSecret = (secret) => {
|
|
216
|
+
if (secret === void 0) return;
|
|
217
|
+
if (Predicate.isString(secret)) return secret === "" ? void 0 : Redacted.make(secret);
|
|
218
|
+
return secret;
|
|
219
|
+
};
|
|
193
220
|
const normalizePutioSdkOptions = (config) => ({
|
|
194
|
-
accessToken: config.accessToken,
|
|
221
|
+
accessToken: redactPutioSecret(config.accessToken),
|
|
195
222
|
baseUrl: config.baseUrl ?? "https://api.put.io",
|
|
196
223
|
headers: config.headers,
|
|
197
224
|
uploadBaseUrl: config.uploadBaseUrl ?? "https://upload.put.io",
|
|
@@ -200,6 +227,7 @@ const normalizePutioSdkOptions = (config) => ({
|
|
|
200
227
|
const putioSdkLayer = (config) => Layer.succeed(PutioSdkConfig, normalizePutioSdkOptions(config));
|
|
201
228
|
const putioSdkLiveLayer = (config) => Layer.mergeAll(putioSdkLayer(config), makePutioFetchLayer());
|
|
202
229
|
const makePutioFetchLayer = (fetchImplementation = globalThis.fetch) => Layer.succeed(PutioHttpClient, makePutioFetchClient(fetchImplementation));
|
|
230
|
+
const decodeJsonText = Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
203
231
|
const makePutioFetchClient = (fetchImplementation = globalThis.fetch) => ({ execute: (request) => Effect.suspend(() => {
|
|
204
232
|
const controller = new AbortController();
|
|
205
233
|
const read = (body) => Effect.tryPromise({
|
|
@@ -208,7 +236,7 @@ const makePutioFetchClient = (fetchImplementation = globalThis.fetch) => ({ exec
|
|
|
208
236
|
}).pipe(Effect.onInterrupt(() => Effect.sync(() => controller.abort())));
|
|
209
237
|
return read(async () => {
|
|
210
238
|
const response = await fetchImplementation(request.url, {
|
|
211
|
-
body: request.body,
|
|
239
|
+
body: request.body ?? null,
|
|
212
240
|
headers: request.headers,
|
|
213
241
|
method: request.method,
|
|
214
242
|
signal: controller.signal
|
|
@@ -216,7 +244,7 @@ const makePutioFetchClient = (fetchImplementation = globalThis.fetch) => ({ exec
|
|
|
216
244
|
return {
|
|
217
245
|
arrayBuffer: read(() => response.arrayBuffer()),
|
|
218
246
|
headers: response.headers,
|
|
219
|
-
json:
|
|
247
|
+
json: read(() => response.text()).pipe(Effect.flatMap((text) => decodeJsonText(text).pipe(Effect.mapError(() => unparsableJsonBodyError(response.status, response.headers))))),
|
|
220
248
|
status: response.status
|
|
221
249
|
};
|
|
222
250
|
});
|
|
@@ -227,9 +255,9 @@ const dotSegmentPattern = /^(?:\.|%2e){1,2}$/i;
|
|
|
227
255
|
const parserRewrittenPattern = /[\\\p{Cc}]|^ | $/u;
|
|
228
256
|
const normalizeApiPath = (path) => {
|
|
229
257
|
if (absoluteUrlPattern.test(path)) throw mapConfigurationError("SDK API request paths must be relative to the configured baseUrl");
|
|
230
|
-
if (parserRewrittenPattern.test(path)) throw
|
|
258
|
+
if (parserRewrittenPattern.test(path)) throw mapValidationError("SDK API request paths must not contain backslashes, control characters, or edge spaces");
|
|
231
259
|
const [pathname = ""] = path.split(/[?#]/, 1);
|
|
232
|
-
if (pathname.split("/").some((segment) => dotSegmentPattern.test(segment))) throw
|
|
260
|
+
if (pathname.split("/").some((segment) => dotSegmentPattern.test(segment))) throw mapValidationError("SDK API request paths must not contain dot segments");
|
|
233
261
|
return path.startsWith("/") ? path : `/${path}`;
|
|
234
262
|
};
|
|
235
263
|
const buildPutioUrl = (baseUrl, path, query) => {
|
|
@@ -241,21 +269,18 @@ const buildPutioUrl = (baseUrl, path, query) => {
|
|
|
241
269
|
};
|
|
242
270
|
const mapUrlBuildError = (cause) => cause instanceof PutioConfigurationError || cause instanceof PutioValidationError ? cause : mapConfigurationError(cause);
|
|
243
271
|
const OkResponseSchema = Schema.Struct({ status: Schema.Literal("OK") });
|
|
244
|
-
const
|
|
245
|
-
const decodeSuccessJson = (schema, response) => response.json.pipe(Effect.flatMap((json) => Schema.decodeUnknownEffect(schema)(json).pipe(Effect.mapError(mapDecodeErrorToValidationError))));
|
|
272
|
+
const decodeSuccessJson = (schema, response) => response.json.pipe(Effect.flatMap((json) => Schema.decodeUnknownEffect(schema)(json).pipe(Effect.mapError(mapContractError))));
|
|
246
273
|
const decodeFailure = (response, headers) => response.json.pipe(Effect.flatMap(parseErrorBody(response.status)), Effect.map((body) => toPutioResponseError(response.status, headers, body)));
|
|
247
274
|
const resolveAuthorization = (config, auth) => {
|
|
248
275
|
const resolvedAuth = auth ?? { type: "config-token" };
|
|
249
276
|
switch (resolvedAuth.type) {
|
|
250
|
-
case "none": return Effect.
|
|
251
|
-
case "token": return Effect.
|
|
252
|
-
case "basic": return Effect.try({
|
|
253
|
-
try: () => `Basic ${btoa(`${resolvedAuth.username}:${
|
|
277
|
+
case "none": return Effect.undefined;
|
|
278
|
+
case "token": return revealSecret(resolvedAuth.token).pipe(Effect.map((token) => `Token ${token}`));
|
|
279
|
+
case "basic": return revealSecret(resolvedAuth.password).pipe(Effect.flatMap((password) => Effect.try({
|
|
280
|
+
try: () => `Basic ${btoa(`${resolvedAuth.username}:${password}`)}`,
|
|
254
281
|
catch: mapConfigurationError
|
|
255
|
-
});
|
|
256
|
-
case "config-token":
|
|
257
|
-
if (!config.accessToken) return Effect.fail(mapConfigurationError("This endpoint requires an access token, but PutioSdkConfig.accessToken is missing"));
|
|
258
|
-
return Effect.succeed(`Token ${config.accessToken}`);
|
|
282
|
+
})));
|
|
283
|
+
case "config-token": return revealAccessToken(config.accessToken).pipe(Effect.flatMap((token) => token === void 0 ? Effect.fail(mapConfigurationError("This endpoint requires an access token, but PutioSdkConfig.accessToken is missing")) : Effect.succeed(`Token ${token}`)));
|
|
259
284
|
}
|
|
260
285
|
};
|
|
261
286
|
const normalizeFormValue = (value) => {
|
|
@@ -266,29 +291,40 @@ const normalizeFormValue = (value) => {
|
|
|
266
291
|
};
|
|
267
292
|
const withBody = (body) => {
|
|
268
293
|
switch (body.type) {
|
|
269
|
-
case "none": return Effect.
|
|
294
|
+
case "none": return Effect.undefined;
|
|
270
295
|
case "json": return Effect.try({
|
|
271
296
|
try: () => JSON.stringify(body.value),
|
|
272
|
-
catch:
|
|
297
|
+
catch: mapValidationError
|
|
273
298
|
});
|
|
274
299
|
case "form": return Effect.succeed(new URLSearchParams(Object.entries(body.value).flatMap(([key, value]) => value === void 0 ? [] : [[key, normalizeFormValue(value)]])));
|
|
275
300
|
case "form-data": return Effect.succeed(body.value);
|
|
276
301
|
}
|
|
277
302
|
};
|
|
278
|
-
const
|
|
303
|
+
const buildRequestHeaders = (requestHeaders, configHeaders, authorization, bodyType) => {
|
|
279
304
|
const headers = new Headers(configHeaders);
|
|
280
305
|
headers.delete("authorization");
|
|
281
|
-
new Headers(
|
|
282
|
-
const body = options.body ?? { type: "none" };
|
|
306
|
+
new Headers(requestHeaders).forEach((value, name) => headers.set(name, value));
|
|
283
307
|
if (!headers.has("accept")) headers.set("accept", "application/json");
|
|
284
308
|
if (authorization) headers.set("authorization", authorization);
|
|
285
|
-
if (
|
|
286
|
-
return
|
|
287
|
-
|
|
309
|
+
if (bodyType === "json" && !headers.has("content-type")) headers.set("content-type", "application/json");
|
|
310
|
+
return headers;
|
|
311
|
+
};
|
|
312
|
+
const makeRequest = Effect.fnUntraced(function* (url, options, configHeaders, authorization) {
|
|
313
|
+
const body = options.body ?? { type: "none" };
|
|
314
|
+
const headers = yield* Effect.try({
|
|
315
|
+
try: () => buildRequestHeaders(options.headers, configHeaders, authorization, body.type),
|
|
316
|
+
catch: () => mapConfigurationError("SDK request headers must be valid HTTP header values")
|
|
317
|
+
});
|
|
318
|
+
const requestBody = yield* withBody(body);
|
|
319
|
+
const request = {
|
|
288
320
|
headers,
|
|
289
321
|
method: options.method,
|
|
290
322
|
url
|
|
291
323
|
};
|
|
324
|
+
return requestBody === void 0 ? request : {
|
|
325
|
+
...request,
|
|
326
|
+
body: requestBody
|
|
327
|
+
};
|
|
292
328
|
});
|
|
293
329
|
const executeRequest = Effect.fn("PutioSdk.executeRequest")(function* (options) {
|
|
294
330
|
yield* Effect.annotateCurrentSpan("http.request.method", options.method);
|
|
@@ -296,7 +332,7 @@ const executeRequest = Effect.fn("PutioSdk.executeRequest")(function* (options)
|
|
|
296
332
|
const httpClient = yield* PutioHttpClient;
|
|
297
333
|
const authorization = yield* resolveAuthorization(config, options.auth);
|
|
298
334
|
const url = yield* Effect.try({
|
|
299
|
-
try: () => buildPutioUrl(options.baseUrl ?? config.baseUrl
|
|
335
|
+
try: () => buildPutioUrl(options.baseUrl ?? config.baseUrl, options.path, options.query),
|
|
300
336
|
catch: mapUrlBuildError
|
|
301
337
|
});
|
|
302
338
|
const request = yield* makeRequest(url, options, config.headers, authorization);
|
|
@@ -317,6 +353,6 @@ function toCursorSelectionForm(selection, idsFieldName = "file_ids") {
|
|
|
317
353
|
[idsFieldName]: joinCsv(selection.ids)
|
|
318
354
|
};
|
|
319
355
|
}
|
|
320
|
-
export {
|
|
356
|
+
export { mapContractError as $, requireRequestedBreadcrumbs as A, decodePutioErrorEnvelope as B, NonEmptyStringSchema as C, decodeAndRun as D, cursorSelectionSchema as E, PutioErrorEnvelopeSchema as F, isPutioConfigurationError as G, fallbackPutioErrorEnvelope as H, PutioOperationError as I, isPutioOperationError as J, isPutioContractError as K, PutioRateLimitError as L, PutioAuthError as M, PutioConfigurationError as N, decodeAndRunRedacted as O, PutioContractError as P, mapConfigurationError as Q, PutioTransportError as R, DEFAULT_PUTIO_WEB_APP_URL as S, PositiveIntegerSchema as T, isPutioApiError as U, definePutioOperationErrorSpec as V, isPutioAuthError as W, isPutioTransportError as X, isPutioRateLimitError as Y, isPutioValidationError as Z, selectJsonField as _, PutioSdkConfig as a, withOperationErrors as at, DEFAULT_PUTIO_API_BASE_URL as b, makePutioFetchClient as c, putioSdkLayer as d, mapTransportError as et, putioSdkLiveLayer as f, requestVoid as g, requestText as h, PutioHttpClient as i, toPutioResponseError as it, PutioApiError as j, failMissingField as k, makePutioFetchLayer as l, requestJson as m, toCursorSelectionForm as n, parseErrorBody as nt, buildPutioUrl as o, requestArrayBuffer as p, isPutioErrorEnvelope as q, OkResponseSchema as r, responseRateLimitHeaders as rt, encodePathSegment as s, joinCsv as t, mapValidationError as tt, normalizePutioSdkOptions as u, selectJsonFields as v, NonNegativeNumberSchema as w, DEFAULT_PUTIO_UPLOAD_BASE_URL as x, revealAccessToken as y, PutioValidationError as z };
|
|
321
357
|
|
|
322
|
-
//# sourceMappingURL=forms-
|
|
358
|
+
//# sourceMappingURL=forms-DQ34jmDg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms-DQ34jmDg.js","names":[],"sources":["../src/core/errors.ts","../src/core/validation.ts","../src/core/defaults.ts","../src/core/response-body.ts","../src/core/secrets.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 | undefined;\n readonly error_type?: [ContractErrorType<TContract>] extends [never]\n ? string | undefined\n : ContractErrorType<TContract> | undefined;\n readonly status_code?: [ContractStatusCode<TContract>] extends [never]\n ? number | undefined\n : ContractStatusCode<TContract> | undefined;\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.Int,\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\nconst CauseErrorFields = {\n cause: Schema.Defect(),\n};\n\nexport class PutioTransportError extends Schema.TaggedError<\n PutioTransportError,\n { readonly brand: unique symbol }\n>()(\"PutioTransportError\", { ...CauseErrorFields }) {}\n\nexport class PutioConfigurationError extends Schema.TaggedError<\n PutioConfigurationError,\n { readonly brand: unique symbol }\n>()(\"PutioConfigurationError\", { ...CauseErrorFields }) {}\n\nexport class PutioValidationError extends Schema.TaggedError<\n PutioValidationError,\n { readonly brand: unique symbol }\n>()(\"PutioValidationError\", { ...CauseErrorFields }) {}\n\nexport class PutioContractError extends Schema.TaggedError<\n PutioContractError,\n { readonly brand: unique symbol }\n>()(\"PutioContractError\", {\n cause: Schema.optional(Schema.Defect()),\n missingField: Schema.optional(Schema.String),\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 retryAfterSeconds: Schema.optional(Schema.Finite),\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<\n PutioApiError,\n { readonly brand: unique symbol }\n>()(\"PutioApiError\", {\n ...PutioResponseErrorFields,\n}) {}\n\nexport class PutioAuthError extends Schema.TaggedError<\n PutioAuthError,\n { readonly brand: unique symbol }\n>()(\"PutioAuthError\", {\n ...PutioResponseErrorFields,\n}) {}\n\nexport class PutioRateLimitError extends Schema.TaggedError<\n PutioRateLimitError,\n { readonly brand: unique symbol }\n>()(\"PutioRateLimitError\", { ...PutioResponseErrorFields, ...RateLimitHeaderFields }) {}\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 | PutioContractError\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 PutioOperationErrorValueSchema = Schema.TaggedStruct(\"PutioOperationError\", {\n body: PutioResponseErrorFields.body,\n status: PutioResponseErrorFields.status,\n contract: PutioKnownOperationErrorContractSchema,\n domain: Schema.String,\n operation: Schema.String,\n reason: PutioOperationErrorReasonSchema,\n});\n\nconst CauseErrorValueFields = {\n cause: Schema.optional(Schema.Defect()),\n};\n\nconst PutioTransportErrorValueSchema = Schema.Struct({\n ...PutioTransportError.fields,\n ...CauseErrorValueFields,\n});\n\nconst PutioConfigurationErrorValueSchema = Schema.Struct({\n ...PutioConfigurationError.fields,\n ...CauseErrorValueFields,\n});\n\nconst PutioValidationErrorValueSchema = Schema.Struct({\n ...PutioValidationError.fields,\n ...CauseErrorValueFields,\n});\n\nconst PutioContractErrorValueSchema = Schema.Struct(PutioContractError.fields);\n\nconst PutioApiErrorValueSchema = Schema.Struct(PutioApiError.fields);\n\nconst PutioAuthErrorValueSchema = Schema.Struct(PutioAuthError.fields);\n\nconst PutioRateLimitErrorValueSchema = Schema.Struct(PutioRateLimitError.fields);\n\nexport type PutioTransportErrorValue = typeof PutioTransportErrorValueSchema.Type;\n\nexport type PutioConfigurationErrorValue = typeof PutioConfigurationErrorValueSchema.Type;\n\nexport type PutioValidationErrorValue = typeof PutioValidationErrorValueSchema.Type;\n\nexport type PutioContractErrorValue = typeof PutioContractErrorValueSchema.Type;\n\nexport type PutioApiErrorValue = typeof PutioApiErrorValueSchema.Type;\n\nexport type PutioAuthErrorValue = typeof PutioAuthErrorValueSchema.Type;\n\nexport type PutioRateLimitErrorValue = typeof PutioRateLimitErrorValueSchema.Type;\n\nexport type PutioOperationErrorValue = typeof PutioOperationErrorValueSchema.Type;\n\nexport const isPutioTransportError = Schema.is(PutioTransportErrorValueSchema);\n\nexport const isPutioConfigurationError = Schema.is(PutioConfigurationErrorValueSchema);\n\nexport const isPutioValidationError = Schema.is(PutioValidationErrorValueSchema);\n\nexport const isPutioContractError = Schema.is(PutioContractErrorValueSchema);\n\nexport const isPutioApiError = Schema.is(PutioApiErrorValueSchema);\n\nexport const isPutioAuthError = Schema.is(PutioAuthErrorValueSchema);\n\nexport const isPutioRateLimitError = Schema.is(PutioRateLimitErrorValueSchema);\n\nexport const isPutioOperationError = Schema.is(PutioOperationErrorValueSchema);\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\nconst deltaSecondsPattern = /^\\d+$/;\n\nconst httpDatePattern =\n /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), \\d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d{4} \\d{2}:\\d{2}:\\d{2} GMT$/;\n\nconst parseRetryAfterSeconds = (value: string | undefined): number | undefined => {\n const trimmed = value?.trim();\n\n if (trimmed === undefined) {\n return undefined;\n }\n\n if (deltaSecondsPattern.test(trimmed)) {\n const seconds = Number(trimmed);\n\n return Number.isSafeInteger(seconds) ? seconds : undefined;\n }\n\n if (!httpDatePattern.test(trimmed)) {\n return undefined;\n }\n\n const retryAt = Date.parse(trimmed);\n\n return Number.isNaN(retryAt) ? undefined : Math.max(0, Math.ceil((retryAt - Date.now()) / 1000));\n};\n\nexport const responseRateLimitHeaders = (headers: Headers) => {\n const retryAfter = getHeader(headers, \"retry-after\");\n\n return {\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,\n retryAfterSeconds: parseRetryAfterSeconds(retryAfter),\n reset: getHeader(headers, \"x-ratelimit-reset\"),\n };\n};\n\nexport const mapValidationError = (cause: unknown) => new PutioValidationError({ cause });\n\nexport const mapContractError = (cause: unknown) => new PutioContractError({ 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 { mapValidationError, PutioContractError, PutioValidationError } from \"./errors.js\";\n\nexport const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));\nexport const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));\nexport const NonNegativeNumberSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));\n\nexport const decodeAndRun = <S extends Schema.Top, A, E, R>(\n schema: S,\n input: S[\"Encoded\"],\n run: (decoded: S[\"Type\"]) => Effect.Effect<A, E, R>,\n) =>\n Schema.decodeUnknownEffect(schema, { onExcessProperty: \"error\" })(input).pipe(\n Effect.mapError(mapValidationError),\n Effect.flatMap(run),\n );\n\nexport const decodeAndRunRedacted =\n (domain: string, operation: string) =>\n <S extends Schema.Top, A, E, R>(\n schema: S,\n input: S[\"Encoded\"],\n run: (decoded: S[\"Type\"]) => Effect.Effect<A, E, R>,\n ) =>\n Schema.decodeUnknownEffect(schema, { onExcessProperty: \"error\" })(input).pipe(\n Effect.mapError(\n () =>\n new PutioValidationError({\n cause: { domain, operation, reason: \"Invalid request input\" },\n }),\n ),\n Effect.flatMap(run),\n );\n\nexport const failMissingField = (field: string): Effect.Effect<never, PutioContractError> =>\n Effect.fail(new PutioContractError({ missingField: field }));\n\nexport const requireRequestedBreadcrumbs =\n (query: { readonly breadcrumbs?: 1 | undefined }) =>\n <A extends { readonly breadcrumbs?: unknown }, E, R>(\n effect: Effect.Effect<A, E, R>,\n ): Effect.Effect<A, E | PutioContractError, R> =>\n effect.pipe(\n Effect.filterOrElse(\n (response) => query.breadcrumbs !== 1 || response.breadcrumbs !== undefined,\n () => failMissingField(\"breadcrumbs\"),\n ),\n );\n\ntype CursorOrIdsSelection = {\n readonly cursor?: string | undefined;\n readonly ids?: ReadonlyArray<number> | undefined;\n};\n\nexport type CursorSelection<TFields extends CursorOrIdsSelection> =\n | (TFields & { readonly cursor: string })\n | (TFields & { readonly ids: ReadonlyArray<number> });\n\nexport const cursorSelectionSchema = <const TFields extends Schema.Struct.Fields>(\n fields: TFields,\n) =>\n Schema.Struct({\n cursor: Schema.optional(NonEmptyStringSchema),\n excludeIds: Schema.optional(Schema.Array(PositiveIntegerSchema)),\n ids: Schema.optional(Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1))),\n ...fields,\n }).check(\n Schema.makeFilter(\n (input: CursorOrIdsSelection) => input.cursor !== undefined || input.ids !== 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 {\n fallbackPutioErrorEnvelope,\n mapContractError,\n type PutioSdkError,\n toPutioResponseError,\n} from \"./errors.js\";\n\nexport const isSuccessStatus = (status: number) => status >= 200 && status < 300;\n\nexport const unparsableJsonBodyError = (status: number, headers: Headers): PutioSdkError =>\n isSuccessStatus(status)\n ? mapContractError(new SyntaxError(\"The HTTP response body is not valid JSON\"))\n : toPutioResponseError(\n status,\n headers,\n fallbackPutioErrorEnvelope(status),\n new SyntaxError(\"The HTTP error response body is not valid JSON\"),\n );\n","import { Effect, Predicate, Redacted } from \"effect\";\n\nimport { mapConfigurationError, type PutioConfigurationError } from \"./errors.js\";\n\nexport const revealSecret = (\n secret: string | Redacted.Redacted<string>,\n): Effect.Effect<string, PutioConfigurationError> =>\n Predicate.isString(secret)\n ? Effect.succeed(secret)\n : Effect.try({\n try: () => Redacted.value(secret),\n catch: mapConfigurationError,\n });\n\nexport const revealAccessToken = (\n accessToken: Redacted.Redacted<string> | undefined,\n): Effect.Effect<string | undefined, PutioConfigurationError> =>\n accessToken === undefined\n ? Effect.undefined\n : revealSecret(accessToken).pipe(Effect.map((token) => (token === \"\" ? undefined : token)));\n","import { Context, Effect, Layer, Predicate, Redacted, 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 mapConfigurationError,\n mapContractError,\n mapTransportError,\n mapValidationError,\n parseErrorBody,\n PutioConfigurationError,\n type PutioSdkError,\n PutioValidationError,\n toPutioResponseError,\n} from \"./errors.js\";\nimport { isSuccessStatus, unparsableJsonBodyError } from \"./response-body.js\";\nimport { revealAccessToken, revealSecret } from \"./secrets.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 type PutioSecret = string | Redacted.Redacted<string>;\n\nexport interface PutioSdkOptions {\n readonly accessToken?: PutioSecret | undefined;\n readonly baseUrl?: string | URL | undefined;\n readonly headers?: HeadersInit | undefined;\n readonly uploadBaseUrl?: string | URL | undefined;\n readonly webAppUrl?: string | URL | undefined;\n}\n\nexport interface PutioSdkResolvedConfig {\n readonly accessToken: Redacted.Redacted<string> | undefined;\n readonly baseUrl: string | URL;\n readonly headers: HeadersInit | undefined;\n readonly uploadBaseUrl: string | URL;\n readonly webAppUrl: string | URL;\n}\n\nexport class PutioSdkConfig extends Context.Service<PutioSdkConfig, PutioSdkResolvedConfig>()(\n \"@putdotio/sdk/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 \"@putdotio/sdk/PutioHttpClient\",\n) {}\n\nexport type PutioSdkContext = PutioSdkConfig | PutioHttpClient;\n\nconst redactPutioSecret = (\n secret: PutioSecret | undefined,\n): Redacted.Redacted<string> | undefined => {\n if (secret === undefined) {\n return undefined;\n }\n\n if (Predicate.isString(secret)) {\n return secret === \"\" ? undefined : Redacted.make(secret);\n }\n\n return secret;\n};\n\nexport const normalizePutioSdkOptions = (config: PutioSdkOptions): PutioSdkResolvedConfig => ({\n accessToken: redactPutioSecret(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\nconst decodeJsonText = Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown));\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 ?? null,\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: read(() => response.text()).pipe(\n Effect.flatMap((text) =>\n decodeJsonText(text).pipe(\n Effect.mapError(() => unparsableJsonBodyError(response.status, response.headers)),\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 dotSegmentPattern = /^(?:\\.|%2e){1,2}$/i;\n\nconst parserRewrittenPattern = /[\\\\\\p{Cc}]|^ | $/u;\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 if (parserRewrittenPattern.test(path)) {\n throw mapValidationError(\n \"SDK API request paths must not contain backslashes, control characters, or edge spaces\",\n );\n }\n\n const [pathname = \"\"] = path.split(/[?#]/, 1);\n\n if (pathname.split(\"/\").some((segment) => dotSegmentPattern.test(segment))) {\n throw mapValidationError(\"SDK API request paths must not contain dot segments\");\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 instanceof PutioValidationError\n ? cause\n : 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: PutioSecret }\n | { readonly type: \"basic\"; readonly username: string; readonly password: PutioSecret }\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 | undefined;\n readonly query?: PutioQuery | undefined;\n readonly headers?: HeadersInit | undefined;\n readonly auth?: PutioAuth | undefined;\n readonly body?: PutioRequestBody | undefined;\n}\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(Effect.mapError(mapContractError)),\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: PutioSdkResolvedConfig,\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.undefined;\n case \"token\":\n return revealSecret(resolvedAuth.token).pipe(Effect.map((token) => `Token ${token}`));\n case \"basic\":\n return revealSecret(resolvedAuth.password).pipe(\n Effect.flatMap((password) =>\n Effect.try({\n try: () => `Basic ${btoa(`${resolvedAuth.username}:${password}`)}`,\n catch: mapConfigurationError,\n }),\n ),\n );\n case \"config-token\":\n return revealAccessToken(config.accessToken).pipe(\n Effect.flatMap((token) =>\n token === undefined\n ? Effect.fail(\n mapConfigurationError(\n \"This endpoint requires an access token, but PutioSdkConfig.accessToken is missing\",\n ),\n )\n : Effect.succeed(`Token ${token}`),\n ),\n );\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.undefined;\n case \"json\":\n return Effect.try({\n try: () => JSON.stringify(body.value),\n catch: mapValidationError,\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 buildRequestHeaders = (\n requestHeaders: HeadersInit | undefined,\n configHeaders: HeadersInit | undefined,\n authorization: string | undefined,\n bodyType: PutioRequestBody[\"type\"] | \"none\",\n): Headers => {\n const headers = new Headers(configHeaders);\n headers.delete(\"authorization\");\n new Headers(requestHeaders).forEach((value, name) => headers.set(name, value));\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 (bodyType === \"json\" && !headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n\n return headers;\n};\n\nconst makeRequest = Effect.fnUntraced(function* (\n url: string,\n options: PutioRequestOptions,\n configHeaders: HeadersInit | undefined,\n authorization?: string,\n) {\n const body = options.body ?? { type: \"none\" as const };\n\n const headers = yield* Effect.try({\n try: () => buildRequestHeaders(options.headers, configHeaders, authorization, body.type),\n catch: () => mapConfigurationError(\"SDK request headers must be valid HTTP header values\"),\n });\n\n const requestBody = yield* withBody(body);\n\n const request: PutioHttpRequest = { headers, method: options.method, url };\n\n return requestBody === undefined ? request : { ...request, body: requestBody };\n});\n\nconst executeRequest = Effect.fn(\"PutioSdk.executeRequest\")(function* (\n options: PutioRequestOptions,\n) {\n yield* Effect.annotateCurrentSpan(\"http.request.method\", options.method);\n\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: () => buildPutioUrl(options.baseUrl ?? config.baseUrl, options.path, options.query),\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.ignore(response.arrayBuffer)\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 | undefined;\n readonly excludeIds?: ReadonlyArray<TValue> | undefined;\n readonly ids?: ReadonlyArray<TValue> | undefined;\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 | undefined;\n readonly exclude_ids?: string | undefined;\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,SAAS,OAAO,SAAS,OAAO,OAAO;AACzC,CAAC;AA+ED,MAAM,wBACJ,UACA,UAC6D;CAC7D,IAAI,SAAS,eAAe,KAAA,KAAa,CAAC,OAAO,GAAG,SAAS,UAAU,CAAC,CAAC,MAAM,IAAI,GACjF,OAAO;CAGT,IAAI,SAAS,cAAc,KAAA,GAAW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