@putdotio/sdk 9.1.8 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -36
- package/dist/{forms-BoZMwEUj.js → forms-NEv3jqmj.js} +49 -11
- package/dist/forms-NEv3jqmj.js.map +1 -0
- package/dist/index-Bdf0QH3l.d.ts +7355 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +584 -350
- package/dist/index.js.map +1 -1
- package/dist/utilities.d.ts +2 -2
- package/dist/utilities.js +12 -12
- package/dist/utilities.js.map +1 -1
- package/package.json +20 -14
- package/dist/forms-BoZMwEUj.js.map +0 -1
- package/dist/index-Irv7Wz_0.d.ts +0 -7473
package/dist/utilities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $f as PutioErrorEnvelope, Xf as PutioApiError, Zf as PutioAuthError, mo as FileBroad, np as PutioKnownOperationErrorContract, rp as PutioOperationError, sp as PutioRateLimitError } from "./index-Bdf0QH3l.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/date.d.ts
|
|
4
4
|
declare const ensureUTC: (date?: unknown) => string;
|
|
@@ -73,7 +73,7 @@ declare class LocalizedError extends Error {
|
|
|
73
73
|
readonly meta: Record<string, unknown>;
|
|
74
74
|
constructor(params: LocalizedErrorParams);
|
|
75
75
|
}
|
|
76
|
-
type StatusAndBodyError = PutioApiError | PutioAuthError | PutioRateLimitError | PutioOperationError<string, string,
|
|
76
|
+
type StatusAndBodyError = PutioApiError | PutioAuthError | PutioRateLimitError | PutioOperationError<string, string, PutioKnownOperationErrorContract>;
|
|
77
77
|
type PutioLocalizableError = {
|
|
78
78
|
readonly _tag?: string;
|
|
79
79
|
readonly body: PutioErrorEnvelope;
|
package/dist/utilities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as buildPutioUrl, t as joinCsv } from "./forms-
|
|
1
|
+
import { a as buildPutioUrl, j as isPutioErrorEnvelope, o as encodePathSegment, t as joinCsv } from "./forms-NEv3jqmj.js";
|
|
2
2
|
//#region src/utilities/date.ts
|
|
3
3
|
const LONG_DATE_FORMATTER = new Intl.DateTimeFormat("en-US", {
|
|
4
4
|
dateStyle: "long",
|
|
@@ -162,13 +162,13 @@ var FileURLProvider = class {
|
|
|
162
162
|
this.token = token;
|
|
163
163
|
}
|
|
164
164
|
getDownloadURL(fileOrFileId) {
|
|
165
|
-
if (typeof fileOrFileId === "number") return buildPutioUrl(this.baseURL, `/v2/files/${fileOrFileId}/download`, { oauth_token: this.token });
|
|
165
|
+
if (typeof fileOrFileId === "number") return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(fileOrFileId)}/download`, { oauth_token: this.token });
|
|
166
166
|
if (fileOrFileId.file_type === "FOLDER") return null;
|
|
167
|
-
return buildPutioUrl(this.baseURL, `/v2/files/${fileOrFileId.id}/download`, { oauth_token: this.token });
|
|
167
|
+
return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(fileOrFileId.id)}/download`, { oauth_token: this.token });
|
|
168
168
|
}
|
|
169
169
|
getHLSStreamURL(file, params = {}) {
|
|
170
170
|
if (!isVideoFile(file)) return null;
|
|
171
|
-
return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/hls/media.m3u8`, {
|
|
171
|
+
return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/hls/media.m3u8`, {
|
|
172
172
|
max_subtitle_count: params.maxSubtitleCount,
|
|
173
173
|
oauth_token: this.token,
|
|
174
174
|
original: params.playOriginal ? 1 : void 0,
|
|
@@ -177,22 +177,22 @@ var FileURLProvider = class {
|
|
|
177
177
|
}
|
|
178
178
|
getMP4DownloadURL(file) {
|
|
179
179
|
if (!isVideoFile(file) || !file.is_mp4_available) return null;
|
|
180
|
-
return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/mp4/download`, { oauth_token: this.token });
|
|
180
|
+
return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/mp4/download`, { oauth_token: this.token });
|
|
181
181
|
}
|
|
182
182
|
getMP4StreamURL(file) {
|
|
183
183
|
if (!isVideoFile(file) || !file.is_mp4_available) return null;
|
|
184
|
-
return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/mp4/stream`, { oauth_token: this.token });
|
|
184
|
+
return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/mp4/stream`, { oauth_token: this.token });
|
|
185
185
|
}
|
|
186
186
|
getStreamURL(file) {
|
|
187
187
|
switch (getFileRenderType(file)) {
|
|
188
|
-
case "audio": return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/stream.mp3`, { oauth_token: this.token });
|
|
189
|
-
case "video": return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/stream`, { oauth_token: this.token });
|
|
188
|
+
case "audio": return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/stream.mp3`, { oauth_token: this.token });
|
|
189
|
+
case "video": return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/stream`, { oauth_token: this.token });
|
|
190
190
|
default: return null;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
getXSPFURL(file) {
|
|
194
194
|
if (!isVideoFile(file)) return null;
|
|
195
|
-
return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/xspf`, { oauth_token: this.token });
|
|
195
|
+
return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/xspf`, { oauth_token: this.token });
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
//#endregion
|
|
@@ -210,10 +210,10 @@ var LocalizedError = class extends Error {
|
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
212
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
213
|
-
const
|
|
213
|
+
const isLocalizablePutioErrorEnvelope = (value) => isObject(value) && ("status_code" in value || "error_type" in value || "error_message" in value) && isPutioErrorEnvelope(value);
|
|
214
214
|
const isPutioErrorWithBody = (value) => isObject(value) && "body" in value && isPutioErrorEnvelope(value.body);
|
|
215
215
|
const normalizePutioError = (error) => {
|
|
216
|
-
if (
|
|
216
|
+
if (isLocalizablePutioErrorEnvelope(error)) return {
|
|
217
217
|
_tag: "PutioErrorEnvelope",
|
|
218
218
|
body: error,
|
|
219
219
|
status: error.status_code
|
|
@@ -229,7 +229,7 @@ const isErrorLocalizer = (fn) => {
|
|
|
229
229
|
};
|
|
230
230
|
const createLocalizeError = (globalLocalizers) => (error, scopedLocalizers = []) => {
|
|
231
231
|
const localizers = [...scopedLocalizers, ...globalLocalizers];
|
|
232
|
-
if (isPutioErrorWithBody(error) ||
|
|
232
|
+
if (isPutioErrorWithBody(error) || isLocalizablePutioErrorEnvelope(error)) {
|
|
233
233
|
const apiError = normalizePutioError(error);
|
|
234
234
|
const byErrorType = localizers.find((localizer) => localizer.kind === "api_error_type" && localizer.error_type === apiError.body.error_type);
|
|
235
235
|
if (byErrorType) return new LocalizedError({
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","names":[],"sources":["../src/utilities/date.ts","../src/utilities/duration.ts","../src/utilities/file-render-type.ts","../src/utilities/file-size.ts","../src/utilities/file-url-provider.ts","../src/utilities/localized-error.ts","../src/utilities/string.ts"],"sourcesContent":["const LONG_DATE_FORMATTER = new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n});\n\nconst RELATIVE_TIME_FORMATTER = new Intl.RelativeTimeFormat(\"en\", {\n numeric: \"always\",\n});\n\nconst ensureDate = (value: unknown): Date => {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === \"string\") {\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return new Date(`${value}T00:00:00.000Z`);\n }\n\n return new Date(value.endsWith(\"Z\") ? value : `${value}Z`);\n }\n\n return new Date();\n};\n\nconst toRelativeUnit = (secondsDelta: number) => {\n const absoluteSeconds = Math.abs(secondsDelta);\n\n if (absoluteSeconds >= 60 * 60 * 24 * 365) {\n return { unit: \"year\" as const, value: Math.round(secondsDelta / (60 * 60 * 24 * 365)) };\n }\n\n if (absoluteSeconds >= 60 * 60 * 24 * 30) {\n return { unit: \"month\" as const, value: Math.round(secondsDelta / (60 * 60 * 24 * 30)) };\n }\n\n if (absoluteSeconds >= 60 * 60 * 24) {\n return { unit: \"day\" as const, value: Math.round(secondsDelta / (60 * 60 * 24)) };\n }\n\n if (absoluteSeconds >= 60 * 60) {\n return { unit: \"hour\" as const, value: Math.round(secondsDelta / (60 * 60)) };\n }\n\n if (absoluteSeconds >= 60) {\n return { unit: \"minute\" as const, value: Math.round(secondsDelta / 60) };\n }\n\n return { unit: \"second\" as const, value: Math.round(secondsDelta) };\n};\n\nexport const ensureUTC = (date: unknown = null): string => ensureDate(date).toISOString();\n\nexport const toTimeAgo = (date: unknown = null): string => {\n if (!date) {\n return \"N/A\";\n }\n\n const target = ensureDate(date);\n const secondsDelta = Math.round((target.getTime() - Date.now()) / 1000);\n const { unit, value } = toRelativeUnit(secondsDelta);\n return RELATIVE_TIME_FORMATTER.format(value, unit);\n};\n\nexport const formatDate = (\n date: unknown = null,\n format: \"LL\" | Intl.DateTimeFormatOptions = \"LL\",\n): string => {\n if (!date) {\n return \"N/A\";\n }\n\n const normalizedDate = ensureDate(date);\n\n if (format === \"LL\") {\n return LONG_DATE_FORMATTER.format(normalizedDate);\n }\n\n return new Intl.DateTimeFormat(\"en-US\", {\n timeZone: \"UTC\",\n ...format,\n }).format(normalizedDate);\n};\n\nexport const daysDiff = (date1: unknown, date2: unknown): number => {\n const day1 = ensureDate(date1);\n const day2 = ensureDate(date2);\n\n const utcDay1 = Date.UTC(day1.getUTCFullYear(), day1.getUTCMonth(), day1.getUTCDate());\n const utcDay2 = Date.UTC(day2.getUTCFullYear(), day2.getUTCMonth(), day2.getUTCDate());\n\n return Math.abs(Math.round((utcDay2 - utcDay1) / (1000 * 60 * 60 * 24)));\n};\n\nexport const daysDiffFromNow = (date: unknown = null): number => {\n if (!date) {\n return 0;\n }\n\n return daysDiff(date, new Date());\n};\n\nexport const getUnixTimestamp = (date: unknown): number =>\n Math.floor(ensureDate(date).getTime() / 1000);\n","const normalizeNumber = (value: unknown): number => (typeof value === \"number\" ? value : 0);\n\nconst formatPadded = (value: number): string => String(value).padStart(2, \"0\");\n\nexport const secondsToDuration = (seconds: unknown): string => {\n const normalizedSeconds = Math.floor(normalizeNumber(seconds));\n\n if (normalizedSeconds <= 0) {\n return \"00:00\";\n }\n\n const days = Math.floor(normalizedSeconds / 86_400);\n const hours = Math.floor((normalizedSeconds % 86_400) / 3_600);\n const minutes = Math.floor((normalizedSeconds % 3_600) / 60);\n const remainingSeconds = normalizedSeconds % 60;\n\n if (days > 0) {\n return [days, hours, minutes, remainingSeconds].map(formatPadded).join(\":\");\n }\n\n if (normalizedSeconds >= 3_600) {\n return [Math.floor(normalizedSeconds / 3_600), minutes, remainingSeconds]\n .map(formatPadded)\n .join(\":\");\n }\n\n return [minutes, remainingSeconds].map(formatPadded).join(\":\");\n};\n\nexport const secondsToReadableDuration = (seconds: unknown): string => {\n const normalizedSeconds = Math.floor(normalizeNumber(seconds));\n\n if (normalizedSeconds <= 0) {\n return \"N/A\";\n }\n\n if (normalizedSeconds < 60) {\n return `${normalizedSeconds} s`;\n }\n\n if (normalizedSeconds >= 86_400) {\n const days = Math.floor(normalizedSeconds / 86_400);\n const roundedHours = Math.round((normalizedSeconds - days * 86_400) / 3_600);\n\n if (roundedHours === 24) {\n return `${days + 1}d`;\n }\n\n return roundedHours > 0 ? `${days}d ${roundedHours}h` : `${days}d`;\n }\n\n if (normalizedSeconds >= 3_600) {\n const hours = Math.floor(normalizedSeconds / 3_600);\n const roundedMinutes = Math.round((normalizedSeconds - hours * 3_600) / 60);\n return roundedMinutes > 0 ? `${hours}h ${roundedMinutes}m` : `${hours}h`;\n }\n\n const roundedMinutes = Math.round(normalizedSeconds / 60);\n const remainingSeconds = normalizedSeconds - roundedMinutes * 60;\n return remainingSeconds > 0 ? `${roundedMinutes}m ${remainingSeconds}s` : `${roundedMinutes}m`;\n};\n","import type { FileBroad } from \"../domains/files.js\";\n\nexport type FileRenderType =\n | \"archive\"\n | \"audio\"\n | \"epub\"\n | \"folder\"\n | \"image\"\n | \"other\"\n | \"pdf\"\n | \"text\"\n | \"text/markdown\"\n | \"video\";\n\nexport type FileRenderTypeInput = Pick<FileBroad, \"content_type\" | \"extension\" | \"file_type\">;\n\nexport const getFileRenderType = (file: FileRenderTypeInput): FileRenderType => {\n const { content_type, extension, file_type } = file;\n\n if (typeof content_type !== \"string\") {\n return \"other\";\n }\n\n if (content_type === \"application/x-directory\") {\n return \"folder\";\n }\n\n if (content_type.startsWith(\"audio\") || file_type === \"AUDIO\") {\n return \"audio\";\n }\n\n if (content_type.startsWith(\"video\")) {\n return \"video\";\n }\n\n if (content_type.startsWith(\"image\")) {\n return \"image\";\n }\n\n if (content_type === \"application/pdf\") {\n return \"pdf\";\n }\n\n if (content_type === \"application/epub+zip\") {\n return \"epub\";\n }\n\n if (content_type === \"application/zip\" || content_type === \"application/x-rar\") {\n return \"archive\";\n }\n\n if (\n content_type.startsWith(\"text\") ||\n content_type.startsWith(\"application/x-subrip\") ||\n file_type === \"TEXT\"\n ) {\n if (content_type.endsWith(\"/markdown\") || extension === \"md\") {\n return \"text/markdown\";\n }\n\n return \"text\";\n }\n\n return \"other\";\n};\n","export interface HumanFileSizeOptions {\n readonly decimals?: number;\n readonly unitSeparator?: string;\n}\n\nconst FILE_SIZE_UNITS = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"] as const;\n\nexport const toHumanFileSize = (\n fileSizeInBytes: string | number,\n options: HumanFileSizeOptions = {},\n): string => {\n const { decimals = 1, unitSeparator = \" \" } = options;\n const parsed =\n typeof fileSizeInBytes === \"string\" ? Number.parseInt(fileSizeInBytes, 10) : fileSizeInBytes;\n\n if (!Number.isFinite(parsed) || parsed <= 0) {\n return `0${unitSeparator}B`;\n }\n\n const exponent = Math.min(\n Math.floor(Math.log(parsed) / Math.log(1024)),\n FILE_SIZE_UNITS.length - 1,\n );\n const normalized = parsed / 1024 ** exponent;\n const fractionDigits = normalized % 1 === 0 ? 0 : decimals;\n\n return `${normalized.toFixed(fractionDigits)}${unitSeparator}${FILE_SIZE_UNITS[exponent]}`;\n};\n","import { joinCsv } from \"../core/forms.js\";\nimport { buildPutioUrl } from \"../core/http.js\";\nimport type { FileBroad } from \"../domains/files.js\";\nimport { getFileRenderType, type FileRenderTypeInput } from \"./file-render-type.js\";\n\nexport type FileUrlProviderInput = Pick<\n FileBroad,\n \"content_type\" | \"extension\" | \"file_type\" | \"id\" | \"is_mp4_available\"\n>;\n\nconst normalizeApiBaseUrl = (apiURL: string): string =>\n apiURL.endsWith(\"/v2\") ? apiURL.slice(0, -3) : apiURL;\n\nconst isVideoFile = (file: FileRenderTypeInput): boolean => getFileRenderType(file) === \"video\";\n\nexport class FileURLProvider {\n readonly apiURL: string;\n\n readonly token: string;\n\n readonly baseURL: string;\n\n constructor(apiURL: string, token: string) {\n this.baseURL = normalizeApiBaseUrl(apiURL);\n this.apiURL = `${this.baseURL}/v2`;\n this.token = token;\n }\n\n getDownloadURL(fileOrFileId: FileUrlProviderInput | number): string | null {\n if (typeof fileOrFileId === \"number\") {\n return buildPutioUrl(this.baseURL, `/v2/files/${fileOrFileId}/download`, {\n oauth_token: this.token,\n });\n }\n\n if (fileOrFileId.file_type === \"FOLDER\") {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${fileOrFileId.id}/download`, {\n oauth_token: this.token,\n });\n }\n\n getHLSStreamURL(\n file: FileUrlProviderInput,\n params: {\n readonly maxSubtitleCount?: number;\n readonly playOriginal?: boolean;\n readonly subtitleLanguages?: ReadonlyArray<string>;\n } = {},\n ): string | null {\n if (!isVideoFile(file)) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/hls/media.m3u8`, {\n max_subtitle_count: params.maxSubtitleCount,\n oauth_token: this.token,\n original: params.playOriginal ? 1 : undefined,\n subtitle_languages: joinCsv(params.subtitleLanguages),\n });\n }\n\n getMP4DownloadURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file) || !file.is_mp4_available) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/mp4/download`, {\n oauth_token: this.token,\n });\n }\n\n getMP4StreamURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file) || !file.is_mp4_available) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/mp4/stream`, {\n oauth_token: this.token,\n });\n }\n\n getStreamURL(file: FileUrlProviderInput): string | null {\n switch (getFileRenderType(file)) {\n case \"audio\":\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/stream.mp3`, {\n oauth_token: this.token,\n });\n case \"video\":\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/stream`, {\n oauth_token: this.token,\n });\n default:\n return null;\n }\n }\n\n getXSPFURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file)) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${file.id}/xspf`, {\n oauth_token: this.token,\n });\n }\n}\n","import {\n PutioApiError,\n PutioAuthError,\n type PutioErrorEnvelope,\n PutioOperationError,\n PutioRateLimitError,\n type PutioKnownErrorContract,\n} from \"../core/errors.js\";\n\nexport type LocalizedErrorRecoverySuggestionTypeInstruction = {\n readonly type: \"instruction\";\n readonly description: string;\n};\n\nexport type LocalizedErrorRecoverySuggestionTypeAction = {\n readonly type: \"action\";\n readonly description: string;\n readonly trigger: {\n readonly label: string;\n readonly callback: () => void;\n };\n};\n\nexport type LocalizedErrorRecoverySuggestionTypeCaptcha = {\n readonly type: \"captcha\";\n readonly description: string;\n};\n\nexport type LocalizedErrorRecoverySuggestion =\n | LocalizedErrorRecoverySuggestionTypeInstruction\n | LocalizedErrorRecoverySuggestionTypeAction\n | LocalizedErrorRecoverySuggestionTypeCaptcha;\n\nexport interface LocalizedErrorParams {\n readonly message: string;\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n readonly underlyingError: unknown;\n readonly meta?: Record<string, unknown>;\n}\n\nexport class LocalizedError extends Error {\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n\n readonly underlyingError: unknown;\n\n readonly meta: Record<string, unknown>;\n\n constructor(params: LocalizedErrorParams) {\n super(params.message);\n this.name = \"LocalizedError\";\n this.recoverySuggestion = params.recoverySuggestion;\n this.underlyingError = params.underlyingError;\n this.meta = params.meta ?? {};\n }\n}\n\ntype StatusAndBodyError =\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError\n | PutioOperationError<string, string, PutioKnownErrorContract>;\n\nexport type PutioLocalizableError = {\n readonly _tag?: string;\n readonly body: PutioErrorEnvelope;\n readonly status?: number;\n};\n\nexport type PutioErrorWithBody = StatusAndBodyError;\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isPutioErrorEnvelope = (value: unknown): value is PutioErrorEnvelope =>\n isObject(value) && (\"status_code\" in value || \"error_type\" in value || \"error_message\" in value);\n\nconst isPutioErrorWithBody = (value: unknown): value is PutioLocalizableError =>\n isObject(value) && \"body\" in value && isPutioErrorEnvelope(value.body);\n\nconst normalizePutioError = (\n error: PutioErrorEnvelope | PutioLocalizableError,\n): PutioLocalizableError => {\n if (isPutioErrorEnvelope(error)) {\n return {\n _tag: \"PutioErrorEnvelope\",\n body: error,\n status: error.status_code,\n };\n }\n\n return error;\n};\n\nexport type LocalizeErrorFn<E> = (\n error: E,\n) => Pick<LocalizedErrorParams, \"message\" | \"recoverySuggestion\" | \"meta\">;\n\nexport type APIErrorByStatusCodeLocalizer = {\n readonly kind: \"api_status_code\";\n readonly status_code: number;\n readonly localize: LocalizeErrorFn<PutioLocalizableError>;\n};\n\nexport type APIErrorByErrorTypeLocalizer = {\n readonly kind: \"api_error_type\";\n readonly error_type: string;\n readonly localize: LocalizeErrorFn<PutioLocalizableError>;\n};\n\nexport type MatchConditionLocalizer<E> = {\n readonly kind: \"match_condition\";\n readonly match: (error: E) => boolean;\n readonly localize: LocalizeErrorFn<E>;\n};\n\nexport type GenericErrorLocalizer = {\n readonly kind: \"generic\";\n readonly localize: LocalizeErrorFn<unknown>;\n};\n\nexport type ErrorLocalizer<E> =\n | APIErrorByStatusCodeLocalizer\n | APIErrorByErrorTypeLocalizer\n | MatchConditionLocalizer<E>\n | GenericErrorLocalizer;\n\nexport type ErrorLocalizerFn = (error: unknown) => LocalizedError;\n\nexport const isErrorLocalizer = (fn: unknown): fn is ErrorLocalizerFn => {\n try {\n return typeof fn === \"function\" && fn(new Error(\"test\")) instanceof LocalizedError;\n } catch {\n return false;\n }\n};\n\nexport const createLocalizeError =\n <GlobalError>(globalLocalizers: ReadonlyArray<ErrorLocalizer<GlobalError>>) =>\n <ScopedError extends GlobalError>(\n error: ScopedError,\n scopedLocalizers: ReadonlyArray<ErrorLocalizer<ScopedError>> = [],\n ): LocalizedError => {\n const localizers = [...scopedLocalizers, ...globalLocalizers];\n\n if (isPutioErrorWithBody(error) || isPutioErrorEnvelope(error)) {\n const apiError = normalizePutioError(error);\n\n const byErrorType = localizers.find(\n (localizer): localizer is APIErrorByErrorTypeLocalizer =>\n localizer.kind === \"api_error_type\" && localizer.error_type === apiError.body.error_type,\n );\n\n if (byErrorType) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byErrorType.localize(apiError),\n });\n }\n\n const byMatchCondition = localizers.find(\n (localizer): localizer is MatchConditionLocalizer<ScopedError> =>\n localizer.kind === \"match_condition\" && localizer.match(error),\n );\n\n if (byMatchCondition) {\n return new LocalizedError({\n underlyingError: error,\n ...byMatchCondition.localize(error),\n });\n }\n\n const byStatusCode = localizers.find(\n (localizer): localizer is APIErrorByStatusCodeLocalizer =>\n localizer.kind === \"api_status_code\" &&\n localizer.status_code === apiError.body.status_code,\n );\n\n if (byStatusCode) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byStatusCode.localize(apiError),\n });\n }\n }\n\n const byMatchCondition = localizers.find(\n (localizer): localizer is MatchConditionLocalizer<ScopedError> =>\n localizer.kind === \"match_condition\" && localizer.match(error),\n );\n\n if (byMatchCondition) {\n return new LocalizedError({\n underlyingError: error,\n ...byMatchCondition.localize(error),\n });\n }\n\n const genericLocalizer = localizers.find(\n (localizer): localizer is GenericErrorLocalizer => localizer.kind === \"generic\",\n );\n\n if (genericLocalizer) {\n return new LocalizedError({\n underlyingError: error,\n ...genericLocalizer.localize(error),\n });\n }\n\n throw new Error(`No localizer found for error: ${String(error)}`);\n };\n","export const dotsToSpaces = (input: string): string => input.split(\".\").join(\" \");\n\nexport const truncate = (\n input: string,\n options: {\n readonly length: number;\n readonly ellipsis?: string;\n },\n): string => {\n const { ellipsis = \"...\", length } = options;\n\n if (input.length <= length) {\n return input;\n }\n\n return `${input.slice(0, length)}${ellipsis}`;\n};\n\nexport const truncateMiddle = (\n input: string,\n options: {\n readonly frontLength: number;\n readonly backLength: number;\n readonly ellipsis?: string;\n },\n): string => {\n const { backLength, ellipsis = \"...\", frontLength } = options;\n const preservedLength = frontLength + backLength;\n\n if (input.length <= preservedLength) {\n return input;\n }\n\n return `${input.slice(0, frontLength)}${ellipsis}${input.slice(input.length - backLength)}`;\n};\n"],"mappings":";;AAAA,MAAM,sBAAsB,IAAI,KAAK,eAAe,SAAS;CAC3D,WAAW;CACX,UAAU;CACX,CAAC;AAEF,MAAM,0BAA0B,IAAI,KAAK,mBAAmB,MAAM,EAChE,SAAS,UACV,CAAC;AAEF,MAAM,cAAc,UAAyB;AAC3C,KAAI,iBAAiB,KACnB,QAAO;AAGT,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,sBAAsB,KAAK,MAAM,CACnC,wBAAO,IAAI,KAAK,GAAG,MAAM,gBAAgB;AAG3C,SAAO,IAAI,KAAK,MAAM,SAAS,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG;;AAG5D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;AAED,KAAI,iBACF,QAAO,IAAI,eAAe;EACxB,iBAAiB;EACjB,GAAG,iBAAiB,SAAS,MAAM;EACpC,CAAC;CAGJ,MAAM,mBAAmB,WAAW,MACjC,cAAkD,UAAU,SAAS,UACvE;AAED,KAAI,iBACF,QAAO,IAAI,eAAe;EACxB,iBAAiB;EACjB,GAAG,iBAAiB,SAAS,MAAM;EACpC,CAAC;AAGJ,OAAM,IAAI,MAAM,iCAAiC,OAAO,MAAM,GAAG;;;;AChNrE,MAAa,gBAAgB,UAA0B,MAAM,MAAM,IAAI,CAAC,KAAK,IAAI;AAEjF,MAAa,YACX,OACA,YAIW;CACX,MAAM,EAAE,WAAW,OAAO,WAAW;AAErC,KAAI,MAAM,UAAU,OAClB,QAAO;AAGT,QAAO,GAAG,MAAM,MAAM,GAAG,OAAO,GAAG;;AAGrC,MAAa,kBACX,OACA,YAKW;CACX,MAAM,EAAE,YAAY,WAAW,OAAO,gBAAgB;CACtD,MAAM,kBAAkB,cAAc;AAEtC,KAAI,MAAM,UAAU,gBAClB,QAAO;AAGT,QAAO,GAAG,MAAM,MAAM,GAAG,YAAY,GAAG,WAAW,MAAM,MAAM,MAAM,SAAS,WAAW"}
|
|
1
|
+
{"version":3,"file":"utilities.js","names":[],"sources":["../src/utilities/date.ts","../src/utilities/duration.ts","../src/utilities/file-render-type.ts","../src/utilities/file-size.ts","../src/utilities/file-url-provider.ts","../src/utilities/localized-error.ts","../src/utilities/string.ts"],"sourcesContent":["const LONG_DATE_FORMATTER = new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n});\n\nconst RELATIVE_TIME_FORMATTER = new Intl.RelativeTimeFormat(\"en\", {\n numeric: \"always\",\n});\n\nconst ensureDate = (value: unknown): Date => {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === \"string\") {\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n return new Date(`${value}T00:00:00.000Z`);\n }\n\n return new Date(value.endsWith(\"Z\") ? value : `${value}Z`);\n }\n\n return new Date();\n};\n\nconst toRelativeUnit = (secondsDelta: number) => {\n const absoluteSeconds = Math.abs(secondsDelta);\n\n if (absoluteSeconds >= 60 * 60 * 24 * 365) {\n return { unit: \"year\" as const, value: Math.round(secondsDelta / (60 * 60 * 24 * 365)) };\n }\n\n if (absoluteSeconds >= 60 * 60 * 24 * 30) {\n return { unit: \"month\" as const, value: Math.round(secondsDelta / (60 * 60 * 24 * 30)) };\n }\n\n if (absoluteSeconds >= 60 * 60 * 24) {\n return { unit: \"day\" as const, value: Math.round(secondsDelta / (60 * 60 * 24)) };\n }\n\n if (absoluteSeconds >= 60 * 60) {\n return { unit: \"hour\" as const, value: Math.round(secondsDelta / (60 * 60)) };\n }\n\n if (absoluteSeconds >= 60) {\n return { unit: \"minute\" as const, value: Math.round(secondsDelta / 60) };\n }\n\n return { unit: \"second\" as const, value: Math.round(secondsDelta) };\n};\n\nexport const ensureUTC = (date: unknown = null): string => ensureDate(date).toISOString();\n\nexport const toTimeAgo = (date: unknown = null): string => {\n if (!date) {\n return \"N/A\";\n }\n\n const target = ensureDate(date);\n const secondsDelta = Math.round((target.getTime() - Date.now()) / 1000);\n const { unit, value } = toRelativeUnit(secondsDelta);\n return RELATIVE_TIME_FORMATTER.format(value, unit);\n};\n\nexport const formatDate = (\n date: unknown = null,\n format: \"LL\" | Intl.DateTimeFormatOptions = \"LL\",\n): string => {\n if (!date) {\n return \"N/A\";\n }\n\n const normalizedDate = ensureDate(date);\n\n if (format === \"LL\") {\n return LONG_DATE_FORMATTER.format(normalizedDate);\n }\n\n return new Intl.DateTimeFormat(\"en-US\", {\n timeZone: \"UTC\",\n ...format,\n }).format(normalizedDate);\n};\n\nexport const daysDiff = (date1: unknown, date2: unknown): number => {\n const day1 = ensureDate(date1);\n const day2 = ensureDate(date2);\n\n const utcDay1 = Date.UTC(day1.getUTCFullYear(), day1.getUTCMonth(), day1.getUTCDate());\n const utcDay2 = Date.UTC(day2.getUTCFullYear(), day2.getUTCMonth(), day2.getUTCDate());\n\n return Math.abs(Math.round((utcDay2 - utcDay1) / (1000 * 60 * 60 * 24)));\n};\n\nexport const daysDiffFromNow = (date: unknown = null): number => {\n if (!date) {\n return 0;\n }\n\n return daysDiff(date, new Date());\n};\n\nexport const getUnixTimestamp = (date: unknown): number =>\n Math.floor(ensureDate(date).getTime() / 1000);\n","const normalizeNumber = (value: unknown): number => (typeof value === \"number\" ? value : 0);\n\nconst formatPadded = (value: number): string => String(value).padStart(2, \"0\");\n\nexport const secondsToDuration = (seconds: unknown): string => {\n const normalizedSeconds = Math.floor(normalizeNumber(seconds));\n\n if (normalizedSeconds <= 0) {\n return \"00:00\";\n }\n\n const days = Math.floor(normalizedSeconds / 86_400);\n const hours = Math.floor((normalizedSeconds % 86_400) / 3_600);\n const minutes = Math.floor((normalizedSeconds % 3_600) / 60);\n const remainingSeconds = normalizedSeconds % 60;\n\n if (days > 0) {\n return [days, hours, minutes, remainingSeconds].map(formatPadded).join(\":\");\n }\n\n if (normalizedSeconds >= 3_600) {\n return [Math.floor(normalizedSeconds / 3_600), minutes, remainingSeconds]\n .map(formatPadded)\n .join(\":\");\n }\n\n return [minutes, remainingSeconds].map(formatPadded).join(\":\");\n};\n\nexport const secondsToReadableDuration = (seconds: unknown): string => {\n const normalizedSeconds = Math.floor(normalizeNumber(seconds));\n\n if (normalizedSeconds <= 0) {\n return \"N/A\";\n }\n\n if (normalizedSeconds < 60) {\n return `${normalizedSeconds} s`;\n }\n\n if (normalizedSeconds >= 86_400) {\n const days = Math.floor(normalizedSeconds / 86_400);\n const roundedHours = Math.round((normalizedSeconds - days * 86_400) / 3_600);\n\n if (roundedHours === 24) {\n return `${days + 1}d`;\n }\n\n return roundedHours > 0 ? `${days}d ${roundedHours}h` : `${days}d`;\n }\n\n if (normalizedSeconds >= 3_600) {\n const hours = Math.floor(normalizedSeconds / 3_600);\n const roundedMinutes = Math.round((normalizedSeconds - hours * 3_600) / 60);\n return roundedMinutes > 0 ? `${hours}h ${roundedMinutes}m` : `${hours}h`;\n }\n\n const roundedMinutes = Math.round(normalizedSeconds / 60);\n const remainingSeconds = normalizedSeconds - roundedMinutes * 60;\n return remainingSeconds > 0 ? `${roundedMinutes}m ${remainingSeconds}s` : `${roundedMinutes}m`;\n};\n","import type { FileBroad } from \"../domains/files.js\";\n\nexport type FileRenderType =\n | \"archive\"\n | \"audio\"\n | \"epub\"\n | \"folder\"\n | \"image\"\n | \"other\"\n | \"pdf\"\n | \"text\"\n | \"text/markdown\"\n | \"video\";\n\nexport type FileRenderTypeInput = Pick<FileBroad, \"content_type\" | \"extension\" | \"file_type\">;\n\nexport const getFileRenderType = (file: FileRenderTypeInput): FileRenderType => {\n const { content_type, extension, file_type } = file;\n\n if (typeof content_type !== \"string\") {\n return \"other\";\n }\n\n if (content_type === \"application/x-directory\") {\n return \"folder\";\n }\n\n if (content_type.startsWith(\"audio\") || file_type === \"AUDIO\") {\n return \"audio\";\n }\n\n if (content_type.startsWith(\"video\")) {\n return \"video\";\n }\n\n if (content_type.startsWith(\"image\")) {\n return \"image\";\n }\n\n if (content_type === \"application/pdf\") {\n return \"pdf\";\n }\n\n if (content_type === \"application/epub+zip\") {\n return \"epub\";\n }\n\n if (content_type === \"application/zip\" || content_type === \"application/x-rar\") {\n return \"archive\";\n }\n\n if (\n content_type.startsWith(\"text\") ||\n content_type.startsWith(\"application/x-subrip\") ||\n file_type === \"TEXT\"\n ) {\n if (content_type.endsWith(\"/markdown\") || extension === \"md\") {\n return \"text/markdown\";\n }\n\n return \"text\";\n }\n\n return \"other\";\n};\n","export interface HumanFileSizeOptions {\n readonly decimals?: number;\n readonly unitSeparator?: string;\n}\n\nconst FILE_SIZE_UNITS = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"] as const;\n\nexport const toHumanFileSize = (\n fileSizeInBytes: string | number,\n options: HumanFileSizeOptions = {},\n): string => {\n const { decimals = 1, unitSeparator = \" \" } = options;\n const parsed =\n typeof fileSizeInBytes === \"string\" ? Number.parseInt(fileSizeInBytes, 10) : fileSizeInBytes;\n\n if (!Number.isFinite(parsed) || parsed <= 0) {\n return `0${unitSeparator}B`;\n }\n\n const exponent = Math.min(\n Math.floor(Math.log(parsed) / Math.log(1024)),\n FILE_SIZE_UNITS.length - 1,\n );\n const normalized = parsed / 1024 ** exponent;\n const fractionDigits = normalized % 1 === 0 ? 0 : decimals;\n\n return `${normalized.toFixed(fractionDigits)}${unitSeparator}${FILE_SIZE_UNITS[exponent]}`;\n};\n","import { joinCsv } from \"../core/forms.js\";\nimport { buildPutioUrl, encodePathSegment } from \"../core/http.js\";\nimport type { FileBroad } from \"../domains/files.js\";\nimport { getFileRenderType, type FileRenderTypeInput } from \"./file-render-type.js\";\n\nexport type FileUrlProviderInput = Pick<\n FileBroad,\n \"content_type\" | \"extension\" | \"file_type\" | \"id\" | \"is_mp4_available\"\n>;\n\nconst normalizeApiBaseUrl = (apiURL: string): string =>\n apiURL.endsWith(\"/v2\") ? apiURL.slice(0, -3) : apiURL;\n\nconst isVideoFile = (file: FileRenderTypeInput): boolean => getFileRenderType(file) === \"video\";\n\nexport class FileURLProvider {\n readonly apiURL: string;\n\n readonly token: string;\n\n readonly baseURL: string;\n\n constructor(apiURL: string, token: string) {\n this.baseURL = normalizeApiBaseUrl(apiURL);\n this.apiURL = `${this.baseURL}/v2`;\n this.token = token;\n }\n\n getDownloadURL(fileOrFileId: FileUrlProviderInput | number): string | null {\n if (typeof fileOrFileId === \"number\") {\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(fileOrFileId)}/download`, {\n oauth_token: this.token,\n });\n }\n\n if (fileOrFileId.file_type === \"FOLDER\") {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(fileOrFileId.id)}/download`, {\n oauth_token: this.token,\n });\n }\n\n getHLSStreamURL(\n file: FileUrlProviderInput,\n params: {\n readonly maxSubtitleCount?: number;\n readonly playOriginal?: boolean;\n readonly subtitleLanguages?: ReadonlyArray<string>;\n } = {},\n ): string | null {\n if (!isVideoFile(file)) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/hls/media.m3u8`, {\n max_subtitle_count: params.maxSubtitleCount,\n oauth_token: this.token,\n original: params.playOriginal ? 1 : undefined,\n subtitle_languages: joinCsv(params.subtitleLanguages),\n });\n }\n\n getMP4DownloadURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file) || !file.is_mp4_available) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/mp4/download`, {\n oauth_token: this.token,\n });\n }\n\n getMP4StreamURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file) || !file.is_mp4_available) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/mp4/stream`, {\n oauth_token: this.token,\n });\n }\n\n getStreamURL(file: FileUrlProviderInput): string | null {\n switch (getFileRenderType(file)) {\n case \"audio\":\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/stream.mp3`, {\n oauth_token: this.token,\n });\n case \"video\":\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/stream`, {\n oauth_token: this.token,\n });\n default:\n return null;\n }\n }\n\n getXSPFURL(file: FileUrlProviderInput): string | null {\n if (!isVideoFile(file)) {\n return null;\n }\n\n return buildPutioUrl(this.baseURL, `/v2/files/${encodePathSegment(file.id)}/xspf`, {\n oauth_token: this.token,\n });\n }\n}\n","import {\n PutioApiError,\n PutioAuthError,\n type PutioErrorEnvelope,\n isPutioErrorEnvelope,\n PutioOperationError,\n PutioRateLimitError,\n type PutioKnownOperationErrorContract,\n} from \"../core/errors.js\";\n\nexport type LocalizedErrorRecoverySuggestionTypeInstruction = {\n readonly type: \"instruction\";\n readonly description: string;\n};\n\nexport type LocalizedErrorRecoverySuggestionTypeAction = {\n readonly type: \"action\";\n readonly description: string;\n readonly trigger: {\n readonly label: string;\n readonly callback: () => void;\n };\n};\n\nexport type LocalizedErrorRecoverySuggestionTypeCaptcha = {\n readonly type: \"captcha\";\n readonly description: string;\n};\n\nexport type LocalizedErrorRecoverySuggestion =\n | LocalizedErrorRecoverySuggestionTypeInstruction\n | LocalizedErrorRecoverySuggestionTypeAction\n | LocalizedErrorRecoverySuggestionTypeCaptcha;\n\nexport interface LocalizedErrorParams {\n readonly message: string;\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n readonly underlyingError: unknown;\n readonly meta?: Record<string, unknown>;\n}\n\nexport class LocalizedError extends Error {\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n\n readonly underlyingError: unknown;\n\n readonly meta: Record<string, unknown>;\n\n constructor(params: LocalizedErrorParams) {\n super(params.message);\n this.name = \"LocalizedError\";\n this.recoverySuggestion = params.recoverySuggestion;\n this.underlyingError = params.underlyingError;\n this.meta = params.meta ?? {};\n }\n}\n\ntype StatusAndBodyError =\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError\n | PutioOperationError<string, string, PutioKnownOperationErrorContract>;\n\nexport type PutioLocalizableError = {\n readonly _tag?: string;\n readonly body: PutioErrorEnvelope;\n readonly status?: number;\n};\n\nexport type PutioErrorWithBody = StatusAndBodyError;\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === \"object\" && value !== null;\n\nconst isLocalizablePutioErrorEnvelope = (value: unknown): value is PutioErrorEnvelope =>\n isObject(value) &&\n (\"status_code\" in value || \"error_type\" in value || \"error_message\" in value) &&\n isPutioErrorEnvelope(value);\n\nconst isPutioErrorWithBody = (value: unknown): value is PutioLocalizableError =>\n isObject(value) && \"body\" in value && isPutioErrorEnvelope(value.body);\n\nconst normalizePutioError = (\n error: PutioErrorEnvelope | PutioLocalizableError,\n): PutioLocalizableError => {\n if (isLocalizablePutioErrorEnvelope(error)) {\n return {\n _tag: \"PutioErrorEnvelope\",\n body: error,\n status: error.status_code,\n };\n }\n\n return error;\n};\n\nexport type LocalizeErrorFn<E> = (\n error: E,\n) => Pick<LocalizedErrorParams, \"message\" | \"recoverySuggestion\" | \"meta\">;\n\nexport type APIErrorByStatusCodeLocalizer = {\n readonly kind: \"api_status_code\";\n readonly status_code: number;\n readonly localize: LocalizeErrorFn<PutioLocalizableError>;\n};\n\nexport type APIErrorByErrorTypeLocalizer = {\n readonly kind: \"api_error_type\";\n readonly error_type: string;\n readonly localize: LocalizeErrorFn<PutioLocalizableError>;\n};\n\nexport type MatchConditionLocalizer<E> = {\n readonly kind: \"match_condition\";\n readonly match: (error: E) => boolean;\n readonly localize: LocalizeErrorFn<E>;\n};\n\nexport type GenericErrorLocalizer = {\n readonly kind: \"generic\";\n readonly localize: LocalizeErrorFn<unknown>;\n};\n\nexport type ErrorLocalizer<E> =\n | APIErrorByStatusCodeLocalizer\n | APIErrorByErrorTypeLocalizer\n | MatchConditionLocalizer<E>\n | GenericErrorLocalizer;\n\nexport type ErrorLocalizerFn = (error: unknown) => LocalizedError;\n\nexport const isErrorLocalizer = (fn: unknown): fn is ErrorLocalizerFn => {\n try {\n return typeof fn === \"function\" && fn(new Error(\"test\")) instanceof LocalizedError;\n } catch {\n return false;\n }\n};\n\nexport const createLocalizeError =\n <GlobalError>(globalLocalizers: ReadonlyArray<ErrorLocalizer<GlobalError>>) =>\n <ScopedError extends GlobalError>(\n error: ScopedError,\n scopedLocalizers: ReadonlyArray<ErrorLocalizer<ScopedError>> = [],\n ): LocalizedError => {\n const localizers = [...scopedLocalizers, ...globalLocalizers];\n\n if (isPutioErrorWithBody(error) || isLocalizablePutioErrorEnvelope(error)) {\n const apiError = normalizePutioError(error);\n\n const byErrorType = localizers.find(\n (localizer): localizer is APIErrorByErrorTypeLocalizer =>\n localizer.kind === \"api_error_type\" && localizer.error_type === apiError.body.error_type,\n );\n\n if (byErrorType) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byErrorType.localize(apiError),\n });\n }\n\n const byMatchCondition = localizers.find(\n (localizer): localizer is MatchConditionLocalizer<ScopedError> =>\n localizer.kind === \"match_condition\" && localizer.match(error),\n );\n\n if (byMatchCondition) {\n return new LocalizedError({\n underlyingError: error,\n ...byMatchCondition.localize(error),\n });\n }\n\n const byStatusCode = localizers.find(\n (localizer): localizer is APIErrorByStatusCodeLocalizer =>\n localizer.kind === \"api_status_code\" &&\n localizer.status_code === apiError.body.status_code,\n );\n\n if (byStatusCode) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byStatusCode.localize(apiError),\n });\n }\n }\n\n const byMatchCondition = localizers.find(\n (localizer): localizer is MatchConditionLocalizer<ScopedError> =>\n localizer.kind === \"match_condition\" && localizer.match(error),\n );\n\n if (byMatchCondition) {\n return new LocalizedError({\n underlyingError: error,\n ...byMatchCondition.localize(error),\n });\n }\n\n const genericLocalizer = localizers.find(\n (localizer): localizer is GenericErrorLocalizer => localizer.kind === \"generic\",\n );\n\n if (genericLocalizer) {\n return new LocalizedError({\n underlyingError: error,\n ...genericLocalizer.localize(error),\n });\n }\n\n throw new Error(`No localizer found for error: ${String(error)}`);\n };\n","export const dotsToSpaces = (input: string): string => input.split(\".\").join(\" \");\n\nexport const truncate = (\n input: string,\n options: {\n readonly length: number;\n readonly ellipsis?: string;\n },\n): string => {\n const { ellipsis = \"...\", length } = options;\n\n if (input.length <= length) {\n return input;\n }\n\n return `${input.slice(0, length)}${ellipsis}`;\n};\n\nexport const truncateMiddle = (\n input: string,\n options: {\n readonly frontLength: number;\n readonly backLength: number;\n readonly ellipsis?: string;\n },\n): string => {\n const { backLength, ellipsis = \"...\", frontLength } = options;\n const preservedLength = frontLength + backLength;\n\n if (input.length <= preservedLength) {\n return input;\n }\n\n return `${input.slice(0, frontLength)}${ellipsis}${input.slice(input.length - backLength)}`;\n};\n"],"mappings":";;AAAA,MAAM,sBAAsB,IAAI,KAAK,eAAe,SAAS;CAC3D,WAAW;CACX,UAAU;CACX,CAAC;AAEF,MAAM,0BAA0B,IAAI,KAAK,mBAAmB,MAAM,EAChE,SAAS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
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Effect-first TypeScript SDK for the put.io API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "put.io <devs@put.io>",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/putdotio/putio-sdk-typescript.git"
|
|
17
|
+
},
|
|
14
18
|
"files": [
|
|
15
19
|
"dist"
|
|
16
20
|
],
|
|
@@ -32,37 +36,39 @@
|
|
|
32
36
|
"access": "public"
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
39
|
+
"bootstrap:live-fixtures": "node ./scripts/bootstrap-live-fixtures.mts",
|
|
35
40
|
"bootstrap:tokens": "node ./scripts/bootstrap-tokens.mts",
|
|
36
41
|
"build": "vp pack",
|
|
37
42
|
"check": "vp check .",
|
|
38
43
|
"clean": "rm -rf .live-build .turbo coverage dist",
|
|
39
44
|
"coverage": "vp test --coverage --passWithNoTests",
|
|
40
45
|
"dev": "vp pack --watch",
|
|
46
|
+
"lint:package": "vp pack && publint --pack pnpm && attw --pack . --profile esm-only",
|
|
47
|
+
"lint:unused": "knip",
|
|
48
|
+
"lint:unused:prod": "vp pack && knip --production",
|
|
49
|
+
"prepare": "./scripts/prepare-effect.sh",
|
|
41
50
|
"prepack": "vp pack",
|
|
51
|
+
"secrets:setup": "OP_ACCOUNT=putdotio.1password.com op whoami >/dev/null && OP_ACCOUNT=putdotio.1password.com op inject -f -i .env.example -o .env.local",
|
|
52
|
+
"secrets:clean": "rm -f .env.local .env.local.* .env.local.swp",
|
|
42
53
|
"test": "vp test --passWithNoTests",
|
|
43
54
|
"test:live": "vp pack && vp test run --config vitest.live.config.ts",
|
|
44
|
-
"test:live:consumer": "vp pack && vp test run --config vitest.live.config.ts test/live/consumer.test.ts",
|
|
45
55
|
"verify": "vp check . && vp pack && vp test --passWithNoTests && vp test --coverage --passWithNoTests"
|
|
46
56
|
},
|
|
47
57
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"effect": "3.19.19"
|
|
58
|
+
"effect": "4.0.0-beta.66"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
61
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
52
62
|
"@types/node": "^24.0.0",
|
|
53
|
-
"@vitest/coverage-v8": "4.1.
|
|
63
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
64
|
+
"is-ci": "^4.1.0",
|
|
65
|
+
"knip": "^6.14.0",
|
|
66
|
+
"publint": "^0.3.21",
|
|
54
67
|
"typescript": "^5.9.3",
|
|
55
|
-
"vite-plus": "^0.1.
|
|
56
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
|
|
68
|
+
"vite-plus": "^0.1.20"
|
|
57
69
|
},
|
|
58
70
|
"engines": {
|
|
59
71
|
"node": ">=24.14.0 <25"
|
|
60
72
|
},
|
|
61
|
-
"packageManager": "pnpm@
|
|
62
|
-
"pnpm": {
|
|
63
|
-
"overrides": {
|
|
64
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.14",
|
|
65
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
73
|
+
"packageManager": "pnpm@11.0.0"
|
|
68
74
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"forms-BoZMwEUj.js","names":[],"sources":["../src/core/errors.ts","../src/core/defaults.ts","../src/core/http.ts","../src/core/forms.ts"],"sourcesContent":["import { Headers } from \"@effect/platform\";\nimport { Data, Effect, Option, Schema } from \"effect\";\n\nexport const PutioErrorEnvelopeSchema = Schema.Struct({\n error_message: Schema.optional(Schema.String),\n error_type: Schema.optional(Schema.String),\n status_code: Schema.optional(Schema.Number.pipe(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> {\n readonly errorType?: TType;\n readonly statusCode?: TStatus;\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\nexport type PutioTypedErrorEnvelope<TContract extends PutioKnownErrorContract> = Omit<\n PutioErrorEnvelope,\n \"error_message\" | \"error_type\" | \"status_code\"\n> & {\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\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 OperationContractOf<TSpec extends PutioOperationErrorSpec> = TSpec[\"knownErrors\"][number];\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\ntype PutioMatchableKnownErrorContract =\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 Extract<TContract, PutioMatchableKnownErrorContract> => {\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 error._tag === \"PutioApiError\" || error._tag === \"PutioAuthError\";\n\nfunction toOperationReason<TType extends string>(contract: {\n readonly errorType: TType;\n readonly statusCode?: number;\n}): {\n readonly kind: \"error_type\";\n readonly errorType: TType;\n};\nfunction toOperationReason<TStatus extends number>(contract: {\n readonly errorType?: undefined;\n readonly statusCode: TStatus;\n}): {\n readonly kind: \"status_code\";\n readonly statusCode: TStatus;\n};\nfunction toOperationReason(contract: PutioMatchableKnownErrorContract) {\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\nexport class PutioApiError extends Data.TaggedError(\"PutioApiError\")<{\n readonly status: number;\n readonly body: PutioErrorEnvelope;\n}> {}\n\nexport class PutioAuthError extends Data.TaggedError(\"PutioAuthError\")<{\n readonly status: number;\n readonly body: PutioErrorEnvelope;\n}> {}\n\nexport class PutioRateLimitError extends Data.TaggedError(\"PutioRateLimitError\")<{\n readonly status: number;\n readonly body: PutioErrorEnvelope;\n readonly action?: string;\n readonly id?: string;\n readonly limit?: string;\n readonly remaining?: string;\n readonly retryAfter?: string;\n readonly reset?: string;\n}> {}\n\nexport class PutioOperationError<\n TDomain extends string,\n TOperation extends string,\n TContract extends PutioKnownErrorContract,\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 =\n | PutioConfigurationError\n | PutioTransportError\n | PutioValidationError\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError;\n\nexport type PutioOperationErrorFromSpec<TSpec extends PutioOperationErrorSpec> =\n PutioOperationError<TSpec[\"domain\"], TSpec[\"operation\"], OperationContractOf<TSpec>>;\n\nexport type PutioOperationFailure<TSpec extends PutioOperationErrorSpec> =\n | PutioUnhandledSdkError\n | PutioOperationErrorFromSpec<TSpec>;\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.decodeUnknown(PutioErrorEnvelopeSchema);\n\nexport const fallbackPutioErrorEnvelope = (status: number): PutioErrorEnvelope => ({\n error_message: `put.io API request failed with status ${status}`,\n status_code: status,\n});\n\nexport const responseRateLimitHeaders = (headers: Headers.Headers) => ({\n action: Option.getOrUndefined(Headers.get(headers, \"x-ratelimit-action\")),\n id: Option.getOrUndefined(Headers.get(headers, \"x-ratelimit-id\")),\n limit: Option.getOrUndefined(Headers.get(headers, \"x-ratelimit-limit\")),\n remaining: Option.getOrUndefined(Headers.get(headers, \"x-ratelimit-remaining\")),\n retryAfter: Option.getOrUndefined(Headers.get(headers, \"retry-after\")),\n reset: Option.getOrUndefined(Headers.get(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 makeResponseError = (\n status: number,\n headers: Headers.Headers,\n body: PutioErrorEnvelope,\n): PutioSdkError => {\n if (status === 429) {\n return new PutioRateLimitError({\n status,\n body,\n ...responseRateLimitHeaders(headers),\n });\n }\n\n if (status === 401 || status === 403) {\n return new PutioAuthError({ status, body });\n }\n\n return new PutioApiError({ status, body });\n};\n\nexport const parseErrorBody = (status: number, json: unknown) =>\n decodePutioErrorEnvelope(json).pipe(\n Effect.orElseSucceed(() => fallbackPutioErrorEnvelope(status)),\n );\n\nexport function withOperationErrors<\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<A, E | PutioOperationError<TDomain, TOperation, TContracts[number]>, R>;\nexport function withOperationErrors<\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<A, E | PutioOperationError<TDomain, TOperation, TContracts[number]>, R>;\nexport function withOperationErrors<\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 effectOrSpec: Effect.Effect<A, E, R> | PutioOperationErrorSpec<TDomain, TOperation, TContracts>,\n maybeSpec?: PutioOperationErrorSpec<TDomain, TOperation, TContracts>,\n):\n | Effect.Effect<A, E | PutioOperationError<TDomain, TOperation, TContracts[number]>, R>\n | (<A2, E2 extends PutioSdkError, R2>(\n effect: Effect.Effect<A2, E2, R2>,\n ) => Effect.Effect<A2, E2 | PutioOperationError<TDomain, TOperation, TContracts[number]>, R2>) {\n if (maybeSpec === undefined) {\n const spec = effectOrSpec as PutioOperationErrorSpec<TDomain, TOperation, TContracts>;\n\n return <A2, E2 extends PutioSdkError, R2>(effect: Effect.Effect<A2, E2, R2>) =>\n withOperationErrors(effect, spec);\n }\n\n const effect = effectOrSpec as Effect.Effect<A, E, R>;\n const spec = maybeSpec;\n\n return effect.pipe(\n Effect.mapError((error) => {\n if (!isMatchableApiError(error)) {\n return error;\n }\n\n const contract = spec.knownErrors.find((candidate) => isKnownContractMatch(candidate, error));\n\n if (!contract) {\n return error;\n }\n\n return new PutioOperationError({\n body: error.body as PutioTypedErrorEnvelope<TContracts[number]>,\n contract,\n domain: spec.domain,\n operation: spec.operation,\n reason: toOperationReason(contract),\n status: error.status,\n });\n }),\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 FetchHttpClient,\n Headers,\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from \"@effect/platform\";\nimport { Context, Effect, Layer, Schema } 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 makeResponseError,\n mapConfigurationError,\n mapDecodeErrorToValidationError,\n mapTransportError,\n parseErrorBody,\n type PutioSdkError,\n} from \"./errors.js\";\n\nexport type PutioQueryValue = string | number | boolean | null | undefined;\n\nexport type PutioQuery = Readonly<Record<string, PutioQueryValue>>;\n\nexport interface PutioSdkConfigShape {\n readonly accessToken?: string;\n readonly baseUrl?: string | URL;\n readonly uploadBaseUrl?: string | URL;\n readonly webAppUrl?: string | URL;\n}\n\nexport class PutioSdkConfig extends Context.Tag(\"PutioSdkConfig\")<\n PutioSdkConfig,\n PutioSdkConfigShape\n>() {}\n\nexport type PutioSdkContext = PutioSdkConfig | HttpClient.HttpClient;\n\nexport const makePutioSdkConfig = (config: PutioSdkConfigShape): PutioSdkConfigShape => ({\n accessToken: config.accessToken,\n baseUrl: config.baseUrl ?? DEFAULT_PUTIO_API_BASE_URL,\n uploadBaseUrl: config.uploadBaseUrl ?? DEFAULT_PUTIO_UPLOAD_BASE_URL,\n webAppUrl: config.webAppUrl ?? DEFAULT_PUTIO_WEB_APP_URL,\n});\n\nexport const makePutioSdkLayer = (config: PutioSdkConfigShape) =>\n Layer.succeed(PutioSdkConfig, makePutioSdkConfig(config));\n\nexport const makePutioSdkLiveLayer = (config: PutioSdkConfigShape) =>\n Layer.mergeAll(makePutioSdkLayer(config), FetchHttpClient.layer);\n\nexport const buildPutioUrl = (baseUrl: string | URL, path: string, query?: PutioQuery): string => {\n const url = new URL(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\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 PutioRequestBody =\n | { readonly type: \"none\" }\n | { readonly type: \"json\"; readonly value: unknown }\n | { readonly type: \"form\"; readonly value: Record<string, unknown> }\n | { readonly type: \"form-data\"; readonly value: FormData };\n\ninterface PutioRequestOptions {\n readonly method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n readonly path: string;\n readonly baseUrl?: string | URL;\n readonly query?: PutioQuery;\n readonly headers?: Headers.Input;\n readonly auth?: PutioAuth;\n readonly body?: PutioRequestBody;\n}\n\nconst isSuccessStatus = (status: number) => status >= 200 && status < 300;\n\nconst decodeSuccessJson = <A, I, R>(\n schema: Schema.Schema<A, I, R>,\n response: HttpClientResponse.HttpClientResponse,\n) =>\n HttpClientResponse.schemaBodyJson(schema)(response).pipe(\n Effect.mapError(mapDecodeErrorToValidationError),\n );\n\nconst decodeFailure = (response: HttpClientResponse.HttpClientResponse, headers: Headers.Headers) =>\n response.json.pipe(\n Effect.flatMap((json) => parseErrorBody(response.status, json)),\n Effect.orElseSucceed(() => fallbackPutioErrorEnvelope(response.status)),\n Effect.map((body) => makeResponseError(response.status, headers, body)),\n );\n\nconst toBasicAuthorization = (username: string, password: string) => {\n if (typeof globalThis.btoa === \"function\") {\n return `Basic ${globalThis.btoa(`${username}:${password}`)}`;\n }\n\n throw mapConfigurationError(\n \"This runtime does not provide btoa(), so Basic auth cannot be encoded safely\",\n );\n};\n\nconst resolveAuthorization = (\n config: PutioSdkConfigShape,\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: () => toBasicAuthorization(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: unknown): string => {\n if (value === null || value === undefined) {\n return \"\";\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n\n return JSON.stringify(value);\n};\n\nconst withBody = (\n request: HttpClientRequest.HttpClientRequest,\n body: PutioRequestBody,\n): Effect.Effect<HttpClientRequest.HttpClientRequest, PutioSdkError> => {\n switch (body.type) {\n case \"none\":\n return Effect.succeed(request);\n case \"json\":\n return HttpClientRequest.bodyJson(request, body.value).pipe(\n Effect.mapError(mapDecodeErrorToValidationError),\n );\n case \"form\":\n return Effect.succeed(\n HttpClientRequest.bodyUrlParams(\n request,\n Object.fromEntries(\n Object.entries(body.value).flatMap(([key, value]) =>\n value === undefined ? [] : [[key, normalizeFormValue(value)]],\n ),\n ),\n ),\n );\n case \"form-data\":\n return Effect.succeed(HttpClientRequest.bodyFormData(request, body.value));\n }\n};\n\nconst makeRequest = (url: string, options: PutioRequestOptions, authorization?: string) =>\n Effect.gen(function* () {\n const headers = authorization\n ? Headers.set(Headers.fromInput(options.headers), \"authorization\", authorization)\n : Headers.fromInput(options.headers);\n\n const body = options.body ?? { type: \"none\" as const };\n const request = HttpClientRequest.make(options.method)(url, {\n acceptJson: true,\n headers,\n });\n\n return yield* withBody(request, body);\n });\n\nconst executeRequest = (options: PutioRequestOptions) =>\n Effect.gen(function* () {\n const config = yield* PutioSdkConfig;\n const authorization = yield* resolveAuthorization(config, options.auth);\n const url = buildPutioUrl(\n options.baseUrl ?? config.baseUrl ?? DEFAULT_PUTIO_API_BASE_URL,\n options.path,\n options.query,\n );\n const request = yield* makeRequest(url, options, authorization);\n\n return yield* HttpClient.execute(request).pipe(Effect.mapError(mapTransportError));\n });\n\nexport const requestJson = <A, I, R>(\n schema: Schema.Schema<A, I, R>,\n options: PutioRequestOptions,\n): Effect.Effect<A, PutioSdkError, PutioSdkContext | R> =>\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 Record<K, unknown>, E, R>(effect: Effect.Effect<A, E, R>): 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 Record<K[number], unknown>, E, R>(\n effect: Effect.Effect<A, E, R>,\n ): Effect.Effect<Pick<A, K[number]>, E, R> =>\n effect.pipe(\n Effect.map(\n (value) =>\n Object.fromEntries(fields.map((field) => [field, value[field]])) as Pick<A, K[number]>,\n ),\n );\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(\n Effect.mapError(mapTransportError),\n Effect.map((buffer) => new Uint8Array(buffer)),\n )\n : decodeFailure(response, response.headers).pipe(Effect.flatMap(Effect.fail)),\n ),\n );\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\nexport const toCursorSelectionForm = <\n TValue extends CsvValue,\n const TIdsFieldName extends string = \"file_ids\",\n>(\n selection: CursorSelectionInput<TValue>,\n idsFieldName?: TIdsFieldName,\n): {\n readonly cursor?: string;\n readonly exclude_ids?: string;\n} & Record<TIdsFieldName, string | undefined> => {\n const resolvedIdsFieldName = (idsFieldName ?? \"file_ids\") as TIdsFieldName;\n\n return {\n cursor: selection.cursor,\n exclude_ids: joinCsv(selection.excludeIds),\n [resolvedIdsFieldName]: joinCsv(selection.ids),\n } as {\n readonly cursor?: string;\n readonly exclude_ids?: string;\n } & Record<TIdsFieldName, string | undefined>;\n};\n"],"mappings":";;;AAGA,MAA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