@putdotio/sdk 18.0.0 → 18.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { $m as PutioKnownOperationErrorContract, Hm as PutioApiError, Wm as PutioAuthError, Xm as PutioErrorEnvelope, _c as FileBroad, ah as PutioRateLimitError, eh as PutioOperationError } from "./index-B0tuVLBR.js";
1
+ import { $m as PutioKnownOperationErrorContract, Hm as PutioApiError, Wm as PutioAuthError, Xm as PutioErrorEnvelope, _c as FileBroad, ah as PutioRateLimitError, eh as PutioOperationError } from "./index-B4Vt5XNs.js";
2
2
  import { Schema } from "effect";
3
3
  export type DateInput = Date | string | null | undefined;
4
4
  export declare const ensureUTC: (date?: DateInput) => string;
package/dist/utilities.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as NonEmptyStringSchema, F as PutioErrorEnvelopeSchema, o as buildPutioUrl, s as encodePathSegment, t as joinCsv, tt as mapValidationError } from "./forms-DQ34jmDg.js";
1
+ import { C as NonEmptyStringSchema, F as PutioErrorEnvelopeSchema, o as buildPutioUrl, s as encodePathSegment, t as joinCsv, tt as mapValidationError } from "./forms-BBMvLadC.js";
2
2
  import { Data, Predicate, Result, Schema } from "effect";
3
3
  // src/utilities/date.ts
4
4
  const LONG_DATE_FORMATTER = new Intl.DateTimeFormat("en-US", {
@@ -8,7 +8,7 @@ const LONG_DATE_FORMATTER = new Intl.DateTimeFormat("en-US", {
8
8
  const RELATIVE_TIME_FORMATTER = new Intl.RelativeTimeFormat("en", { numeric: "always" });
9
9
  const ensureDate = (value) => {
10
10
  if (value === null || value === void 0) return /* @__PURE__ */ new Date();
11
- if (value instanceof Date) return value;
11
+ if (Predicate.isDate(value)) return value;
12
12
  if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
13
13
  return new Date(value.endsWith("Z") ? value : `${value}Z`);
14
14
  };
@@ -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\nexport type DateInput = Date | string | null | undefined;\n\nconst ensureDate = (value: DateInput): Date => {\n if (value === null || value === undefined) {\n return new Date();\n }\n\n if (value instanceof Date) {\n return value;\n }\n\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\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?: DateInput): string => ensureDate(date).toISOString();\n\nexport const toTimeAgo = (date?: DateInput): 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\n return RELATIVE_TIME_FORMATTER.format(value, unit);\n};\n\nexport const formatDate = (\n date?: DateInput,\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: DateInput, date2: DateInput): 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?: DateInput): number => {\n if (!date) {\n return 0;\n }\n\n return daysDiff(date, new Date());\n};\n\nexport const getUnixTimestamp = (date: DateInput): number =>\n Math.floor(ensureDate(date).getTime() / 1000);\n","const formatPadded = (value: number): string => String(value).padStart(2, \"0\");\n\nexport const secondsToDuration = (seconds: number | null | undefined): string => {\n const normalizedSeconds = Math.floor(seconds ?? 0);\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: number | null | undefined): string => {\n const normalizedSeconds = Math.floor(seconds ?? 0);\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\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\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 (content_type === null || content_type === undefined) {\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","import { Predicate } from \"effect\";\n\nexport 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\n const parsed = Predicate.isString(fileSizeInBytes)\n ? Number.parseInt(fileSizeInBytes, 10)\n : 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\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 { Predicate, Result, Schema } from \"effect\";\n\nimport { mapValidationError } from \"../core/errors.js\";\nimport { joinCsv } from \"../core/forms.js\";\nimport { buildPutioUrl, encodePathSegment, type PutioQuery } from \"../core/http.js\";\nimport type { FileBroad } from \"../domains/files.js\";\nimport { NonEmptyStringSchema } from \"../core/validation.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 FileUrlProviderOptionsSchema = Schema.Struct({\n baseUrl: NonEmptyStringSchema,\n downloadToken: NonEmptyStringSchema,\n});\n\nexport type FileUrlProviderOptions = {\n /** The put.io API origin, with or without the trailing `/v2`. */\n readonly baseUrl: string;\n /** The account download token from `getAccountInfo({ download_token: 1 })`, not the OAuth token. */\n readonly downloadToken: string;\n};\n\nconst decodeOptions = (options: FileUrlProviderOptions): FileUrlProviderOptions => {\n const decoded = Schema.decodeResult(FileUrlProviderOptionsSchema, {\n onExcessProperty: \"error\",\n })(options);\n\n if (Result.isFailure(decoded)) {\n throw mapValidationError(decoded.failure);\n }\n\n return decoded.success;\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 /** The account download token from `getAccountInfo({ download_token: 1 })`, not the OAuth token. */\n readonly downloadToken: string;\n\n readonly baseUrl: string;\n\n constructor(options: FileUrlProviderOptions) {\n const { baseUrl, downloadToken } = decodeOptions(options);\n this.baseUrl = normalizeApiBaseUrl(baseUrl);\n this.apiUrl = `${this.baseUrl}/v2`;\n this.downloadToken = downloadToken;\n }\n\n #fileUrl(\n fileId: number,\n resource: string,\n query: PutioQuery = { oauth_token: this.downloadToken },\n ): string {\n return buildPutioUrl(this.baseUrl, `/v2/files/${encodePathSegment(fileId)}/${resource}`, query);\n }\n\n getDownloadUrl(fileOrFileId: FileUrlProviderInput | number): string | null {\n if (Predicate.isNumber(fileOrFileId)) {\n return this.#fileUrl(fileOrFileId, \"download\");\n }\n\n return fileOrFileId.file_type === \"FOLDER\" ? null : this.#fileUrl(fileOrFileId.id, \"download\");\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 this.#fileUrl(file.id, \"hls/media.m3u8\", {\n max_subtitle_count: params.maxSubtitleCount,\n oauth_token: this.downloadToken,\n original: params.playOriginal ? 1 : undefined,\n subtitle_languages: joinCsv(params.subtitleLanguages),\n });\n }\n\n getMp4DownloadUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) && file.is_mp4_available\n ? this.#fileUrl(file.id, \"mp4/download\")\n : null;\n }\n\n getMp4StreamUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) && file.is_mp4_available ? this.#fileUrl(file.id, \"mp4/stream\") : null;\n }\n\n getStreamUrl(file: FileUrlProviderInput): string | null {\n switch (getFileRenderType(file)) {\n case \"audio\":\n return this.#fileUrl(file.id, \"stream.mp3\");\n case \"video\":\n return this.#fileUrl(file.id, \"stream\");\n default:\n return null;\n }\n }\n\n getXspfUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) ? this.#fileUrl(file.id, \"xspf\") : null;\n }\n}\n","import { Data, Predicate, Schema } from \"effect\";\n\nimport {\n PutioApiError,\n PutioAuthError,\n type PutioErrorEnvelope,\n PutioErrorEnvelopeSchema,\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 type LocalizedErrorMeta = Record<string, Schema.Json | undefined>;\n\nexport interface LocalizedErrorParams {\n readonly message: string;\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n readonly underlyingError: unknown;\n readonly meta?: LocalizedErrorMeta;\n}\n\nexport class LocalizedError extends Error {\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n\n readonly underlyingError: unknown;\n\n readonly meta: LocalizedErrorMeta;\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\nexport type PutioErrorWithBody =\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError\n | PutioOperationError<string, string, PutioKnownOperationErrorContract>;\n\nexport type PutioLocalizableError = {\n readonly _tag?: string | undefined;\n readonly body: PutioErrorEnvelope;\n readonly status?: number | undefined;\n};\n\nclass LocalizablePutioErrorEnvelope extends Data.TaggedClass(\"PutioErrorEnvelope\")<{\n readonly body: PutioErrorEnvelope;\n readonly status: number | undefined;\n}> {}\n\nconst isLocalizablePutioErrorEnvelope = Schema.is(\n PutioErrorEnvelopeSchema.check(\n Schema.makeFilter(\n (envelope) =>\n \"status_code\" in envelope || \"error_type\" in envelope || \"error_message\" in envelope,\n { expected: \"a put.io error envelope with a status code, error type, or error message\" },\n ),\n ),\n);\n\nconst isPutioErrorWithBody = Schema.is(Schema.Struct({ body: PutioErrorEnvelopeSchema }));\n\nconst normalizePutioError = (\n error: PutioErrorEnvelope | PutioLocalizableError,\n): PutioLocalizableError => {\n if (isLocalizablePutioErrorEnvelope(error)) {\n return new LocalizablePutioErrorEnvelope({ body: error, status: error.status_code });\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<E = unknown> = (error: E) => LocalizedError;\n\nexport const isErrorLocalizer = (fn: unknown): fn is ErrorLocalizerFn<Error> => {\n try {\n return Predicate.isFunction(fn) && 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 const apiError =\n isPutioErrorWithBody(error) || isLocalizablePutioErrorEnvelope(error)\n ? normalizePutioError(error)\n : undefined;\n\n const byErrorType =\n apiError &&\n localizers.find(\n (localizer): localizer is APIErrorByErrorTypeLocalizer =>\n localizer.kind === \"api_error_type\" && localizer.error_type === apiError.body.error_type,\n );\n\n if (apiError && 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 =\n apiError &&\n 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 (apiError && byStatusCode) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byStatusCode.localize(apiError),\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;AACZ,CAAC;AAED,MAAM,0BAA0B,IAAI,KAAK,mBAAmB,MAAM,EAChE,SAAS,SACX,CAAC;AAID,MAAM,cAAc,UAA2B;CAC7C,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,uBAAO,IAAI,KAAK;CAGlB,IAAI,iBAAiB,MACnB,OAAO;CAGT,IAAI,sBAAsB,KAAK,KAAK,GAClC,uBAAO,IAAI,KAAK,GAAG,MAAM,eAAe;CAG1C,OAAO,IAAI,KAAK,MAAM,SAAS,GAAG,IAAI,QAAQ,GAAG,MAAM,EAAE;AAC3D;AAEA,MAAM,kBAAkB,iBAAyB;CAC/C,MAAM,kBAAkB,KAAK,IAAI,YAAY;CAE7C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;CACnC,CAAC;CAGH,MAAM,mBAAmB,WAAW,MACjC,cAAkD,UAAU,SAAS,SACxE;CAEA,IAAI,kBACF,OAAO,IAAI,eAAe;EACxB,iBAAiB;EACjB,GAAG,iBAAiB,SAAS,KAAK;CACpC,CAAC;CAGH,MAAM,IAAI,MAAM,iCAAiC,OAAO,KAAK,GAAG;AAClE;;ACjNF,MAAa,gBAAgB,UAA0B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;AAEhF,MAAa,YACX,OACA,YAIW;CACX,MAAM,EAAE,WAAW,OAAO,WAAW;CAErC,IAAI,MAAM,UAAU,QAClB,OAAO;CAGT,OAAO,GAAG,MAAM,MAAM,GAAG,MAAM,IAAI;AACrC;AAEA,MAAa,kBACX,OACA,YAKW;CACX,MAAM,EAAE,YAAY,WAAW,OAAO,gBAAgB;CACtD,MAAM,kBAAkB,cAAc;CAEtC,IAAI,MAAM,UAAU,iBAClB,OAAO;CAGT,OAAO,GAAG,MAAM,MAAM,GAAG,WAAW,IAAI,WAAW,MAAM,MAAM,MAAM,SAAS,UAAU;AAC1F"}
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":["import { Predicate } from \"effect\";\n\nconst 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\nexport type DateInput = Date | string | null | undefined;\n\nconst ensureDate = (value: DateInput): Date => {\n if (value === null || value === undefined) {\n return new Date();\n }\n\n if (Predicate.isDate(value)) {\n return value;\n }\n\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\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?: DateInput): string => ensureDate(date).toISOString();\n\nexport const toTimeAgo = (date?: DateInput): 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\n return RELATIVE_TIME_FORMATTER.format(value, unit);\n};\n\nexport const formatDate = (\n date?: DateInput,\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: DateInput, date2: DateInput): 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?: DateInput): number => {\n if (!date) {\n return 0;\n }\n\n return daysDiff(date, new Date());\n};\n\nexport const getUnixTimestamp = (date: DateInput): number =>\n Math.floor(ensureDate(date).getTime() / 1000);\n","const formatPadded = (value: number): string => String(value).padStart(2, \"0\");\n\nexport const secondsToDuration = (seconds: number | null | undefined): string => {\n const normalizedSeconds = Math.floor(seconds ?? 0);\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) / 3600);\n const minutes = Math.floor((normalizedSeconds % 3600) / 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 >= 3600) {\n return [Math.floor(normalizedSeconds / 3600), minutes, remainingSeconds]\n .map(formatPadded)\n .join(\":\");\n }\n\n return [minutes, remainingSeconds].map(formatPadded).join(\":\");\n};\n\nexport const secondsToReadableDuration = (seconds: number | null | undefined): string => {\n const normalizedSeconds = Math.floor(seconds ?? 0);\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) / 3600);\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 >= 3600) {\n const hours = Math.floor(normalizedSeconds / 3600);\n const roundedMinutes = Math.round((normalizedSeconds - hours * 3600) / 60);\n\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\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 (content_type === null || content_type === undefined) {\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","import { Predicate } from \"effect\";\n\nexport 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\n const parsed = Predicate.isString(fileSizeInBytes)\n ? Number.parseInt(fileSizeInBytes, 10)\n : 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\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 { Predicate, Result, Schema } from \"effect\";\n\nimport { mapValidationError } from \"../core/errors.js\";\nimport { joinCsv } from \"../core/forms.js\";\nimport { buildPutioUrl, encodePathSegment } from \"../core/http.js\";\nimport type { PutioQuery } from \"../core/http.js\";\nimport type { FileBroad } from \"../domains/files.js\";\nimport { NonEmptyStringSchema } from \"../core/validation.js\";\nimport { getFileRenderType } from \"./file-render-type.js\";\nimport 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 FileUrlProviderOptionsSchema = Schema.Struct({\n baseUrl: NonEmptyStringSchema,\n downloadToken: NonEmptyStringSchema,\n});\n\nexport type FileUrlProviderOptions = {\n /** The put.io API origin, with or without the trailing `/v2`. */\n readonly baseUrl: string;\n /** The account download token from `getAccountInfo({ download_token: 1 })`, not the OAuth token. */\n readonly downloadToken: string;\n};\n\nconst decodeOptions = (options: FileUrlProviderOptions): FileUrlProviderOptions => {\n const decoded = Schema.decodeResult(FileUrlProviderOptionsSchema, {\n onExcessProperty: \"error\",\n })(options);\n\n if (Result.isFailure(decoded)) {\n throw mapValidationError(decoded.failure);\n }\n\n return decoded.success;\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 /** The account download token from `getAccountInfo({ download_token: 1 })`, not the OAuth token. */\n readonly downloadToken: string;\n\n readonly baseUrl: string;\n\n constructor(options: FileUrlProviderOptions) {\n const { baseUrl, downloadToken } = decodeOptions(options);\n this.baseUrl = normalizeApiBaseUrl(baseUrl);\n this.apiUrl = `${this.baseUrl}/v2`;\n this.downloadToken = downloadToken;\n }\n\n #fileUrl(\n fileId: number,\n resource: string,\n query: PutioQuery = { oauth_token: this.downloadToken },\n ): string {\n return buildPutioUrl(this.baseUrl, `/v2/files/${encodePathSegment(fileId)}/${resource}`, query);\n }\n\n getDownloadUrl(fileOrFileId: FileUrlProviderInput | number): string | null {\n if (Predicate.isNumber(fileOrFileId)) {\n return this.#fileUrl(fileOrFileId, \"download\");\n }\n\n return fileOrFileId.file_type === \"FOLDER\" ? null : this.#fileUrl(fileOrFileId.id, \"download\");\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 this.#fileUrl(file.id, \"hls/media.m3u8\", {\n max_subtitle_count: params.maxSubtitleCount,\n oauth_token: this.downloadToken,\n original: params.playOriginal ? 1 : undefined,\n subtitle_languages: joinCsv(params.subtitleLanguages),\n });\n }\n\n getMp4DownloadUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) && file.is_mp4_available\n ? this.#fileUrl(file.id, \"mp4/download\")\n : null;\n }\n\n getMp4StreamUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) && file.is_mp4_available ? this.#fileUrl(file.id, \"mp4/stream\") : null;\n }\n\n getStreamUrl(file: FileUrlProviderInput): string | null {\n switch (getFileRenderType(file)) {\n case \"audio\":\n return this.#fileUrl(file.id, \"stream.mp3\");\n case \"video\":\n return this.#fileUrl(file.id, \"stream\");\n default:\n return null;\n }\n }\n\n getXspfUrl(file: FileUrlProviderInput): string | null {\n return isVideoFile(file) ? this.#fileUrl(file.id, \"xspf\") : null;\n }\n}\n","import { Data, Predicate, Schema } from \"effect\";\n\nimport { PutioErrorEnvelopeSchema } from \"../core/errors.js\";\nimport type {\n PutioErrorEnvelope,\n PutioKnownOperationErrorContract,\n PutioApiError,\n PutioAuthError,\n PutioOperationError,\n PutioRateLimitError,\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 type LocalizedErrorMeta = Record<string, Schema.Json | undefined>;\n\nexport interface LocalizedErrorParams {\n readonly message: string;\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n readonly underlyingError: unknown;\n readonly meta?: LocalizedErrorMeta;\n}\n\nexport class LocalizedError extends Error {\n readonly recoverySuggestion: LocalizedErrorRecoverySuggestion;\n\n readonly underlyingError: unknown;\n\n readonly meta: LocalizedErrorMeta;\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\nexport type PutioErrorWithBody =\n | PutioApiError\n | PutioAuthError\n | PutioRateLimitError\n | PutioOperationError<string, string, PutioKnownOperationErrorContract>;\n\nexport type PutioLocalizableError = {\n readonly _tag?: string | undefined;\n readonly body: PutioErrorEnvelope;\n readonly status?: number | undefined;\n};\n\nclass LocalizablePutioErrorEnvelope extends Data.TaggedClass(\"PutioErrorEnvelope\")<{\n readonly body: PutioErrorEnvelope;\n readonly status: number | undefined;\n}> {}\n\nconst isLocalizablePutioErrorEnvelope = Schema.is(\n PutioErrorEnvelopeSchema.check(\n Schema.makeFilter(\n (envelope) =>\n \"status_code\" in envelope || \"error_type\" in envelope || \"error_message\" in envelope,\n { expected: \"a put.io error envelope with a status code, error type, or error message\" },\n ),\n ),\n);\n\nconst isPutioErrorWithBody = Schema.is(Schema.Struct({ body: PutioErrorEnvelopeSchema }));\n\nconst normalizePutioError = (\n error: PutioErrorEnvelope | PutioLocalizableError,\n): PutioLocalizableError => {\n if (isLocalizablePutioErrorEnvelope(error)) {\n return new LocalizablePutioErrorEnvelope({ body: error, status: error.status_code });\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<E = unknown> = (error: E) => LocalizedError;\n\nexport const isErrorLocalizer = (fn: unknown): fn is ErrorLocalizerFn<Error> => {\n try {\n return Predicate.isFunction(fn) && 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 const apiError =\n isPutioErrorWithBody(error) || isLocalizablePutioErrorEnvelope(error)\n ? normalizePutioError(error)\n : undefined;\n\n const byErrorType =\n apiError &&\n localizers.find(\n (localizer): localizer is APIErrorByErrorTypeLocalizer =>\n localizer.kind === \"api_error_type\" && localizer.error_type === apiError.body.error_type,\n );\n\n if (apiError && 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 =\n apiError &&\n 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 (apiError && byStatusCode) {\n return new LocalizedError({\n underlyingError: apiError,\n ...byStatusCode.localize(apiError),\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":";;;AAEA,MAAM,sBAAsB,IAAI,KAAK,eAAe,SAAS;CAC3D,WAAW;CACX,UAAU;AACZ,CAAC;AAED,MAAM,0BAA0B,IAAI,KAAK,mBAAmB,MAAM,EAChE,SAAS,SACX,CAAC;AAID,MAAM,cAAc,UAA2B;CAC7C,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,uBAAO,IAAI,KAAK;CAGlB,IAAI,UAAU,OAAO,KAAK,GACxB,OAAO;CAGT,IAAI,sBAAsB,KAAK,KAAK,GAClC,uBAAO,IAAI,KAAK,GAAG,MAAM,eAAe;CAG1C,OAAO,IAAI,KAAK,MAAM,SAAS,GAAG,IAAI,QAAQ,GAAG,MAAM,EAAE;AAC3D;AAEA,MAAM,kBAAkB,iBAAyB;CAC/C,MAAM,kBAAkB,KAAK,IAAI,YAAY;CAE7C,IAAI,mBAAmB,SACrB,OAAO;EAAE,MAAM;EAAiB,OAAO,KAAK,MAAM,eAAgB,OAAmB;CAAE;CAGzF,IAAI,mBAAmB,QACrB,OAAO;EAAE,MAAM;EAAkB,OAAO,KAAK,MAAM,eAAgB,MAAkB;CAAE;CAGzF,IAAI,mBAAmB,OACrB,OAAO;EAAE,MAAM;EAAgB,OAAO,KAAK,MAAM,eAAgB,KAAa;CAAE;CAGlF,IAAI,mBAAmB,MACrB,OAAO;EAAE,MAAM;EAAiB,OAAO,KAAK,MAAM,eAAgB,IAAQ;CAAE;CAG9E,IAAI,mBAAmB,IACrB,OAAO;EAAE,MAAM;EAAmB,OAAO,KAAK,MAAM,eAAe,EAAE;CAAE;CAGzE,OAAO;EAAE,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X,OACA,YAKW;CACX,MAAM,EAAE,YAAY,WAAW,OAAO,gBAAgB;CACtD,MAAM,kBAAkB,cAAc;CAEtC,IAAI,MAAM,UAAU,iBAClB,OAAO;CAGT,OAAO,GAAG,MAAM,MAAM,GAAG,WAAW,IAAI,WAAW,MAAM,MAAM,MAAM,SAAS,UAAU;AAC1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putdotio/sdk",
3
- "version": "18.0.0",
3
+ "version": "18.1.0",
4
4
  "description": "Effect-first TypeScript SDK for the put.io API.",
5
5
  "keywords": [
6
6
  "effect",
@@ -47,8 +47,6 @@
47
47
  "lint:unused": "knip",
48
48
  "lint:unused:prod": "vp pack && knip --production --no-gitignore",
49
49
  "prepack": "vp pack",
50
- "secrets:setup": "bash ./scripts/secrets-setup.sh",
51
- "secrets:clean": "rm -f .env.live-tokens .env.local .env.local.* .env.local.swp",
52
50
  "test": "vp test --passWithNoTests",
53
51
  "test:compat": "node ./scripts/test-compat-node.ts && node ./scripts/test-compat-browser.ts && node ./scripts/test-compat-bun.ts",
54
52
  "test:compat:browser": "node ./scripts/test-compat-browser.ts",
@@ -62,15 +60,14 @@
62
60
  "verify": "vp pack && effect-tsgo vp check . && vp run lint:package && knip && knip --production --no-gitignore && vp run validate:routes:packed && vp test run --coverage --passWithNoTests"
63
61
  },
64
62
  "dependencies": {
65
- "effect": "4.1.5"
63
+ "effect": "4.1.7"
66
64
  },
67
65
  "devDependencies": {
68
66
  "@arethetypeswrong/cli": "^0.18.2",
69
- "@effect/tsgo": "0.73.4",
70
- "@effect/vitest": "4.1.5",
71
- "@oxlint/plugins": "1.91.0",
67
+ "@effect/tsgo": "0.74.1",
68
+ "@effect/vitest": "4.1.7",
72
69
  "@types/node": "^26.1.0",
73
- "@uinaf/oxlint-plugin-no-comments": "1.1.0",
70
+ "@uinaf/oxlint-config": "1.0.5",
74
71
  "@vitest/coverage-v8": "catalog:",
75
72
  "fast-check": "^4.10.2",
76
73
  "knip": "^6.44.2",
@@ -84,5 +81,5 @@
84
81
  "engines": {
85
82
  "node": ">=24.19.0"
86
83
  },
87
- "packageManager": "pnpm@12.23.0"
84
+ "packageManager": "pnpm@12.25.1"
88
85
  }
@@ -1 +0,0 @@
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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