@putdotio/sdk 10.4.0 → 10.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -474,21 +474,24 @@ const OAuthRegeneratedTokenEnvelopeSchema = Schema.Struct({
474
474
  access_token: Schema.String,
475
475
  status: Schema.Literal("OK")
476
476
  });
477
+ const OAuthAppIdSchema = Schema.Int.check(Schema.isGreaterThan(0));
478
+ const OAuthAppDescriptionSchema = Schema.String.check(Schema.isMinLength(10));
479
+ const OAuthAppUrlSchema = Schema.String.check(Schema.isMaxLength(255));
477
480
  const OAuthAppCreateInputSchema = Schema.Struct({
478
- callback: Schema.String,
479
- description: Schema.String,
481
+ callback: OAuthAppUrlSchema,
482
+ description: OAuthAppDescriptionSchema,
480
483
  hidden: Schema.optional(Schema.Boolean),
481
484
  icon: Schema.optional(Schema.instanceOf(Blob)),
482
- name: Schema.String,
483
- website: Schema.String
485
+ name: Schema.String.check(Schema.isMinLength(5)),
486
+ website: OAuthAppUrlSchema
484
487
  });
485
488
  const OAuthAppUpdateInputSchema = Schema.Struct({
486
- callback: Schema.String,
487
- description: Schema.String,
489
+ callback: OAuthAppUrlSchema,
490
+ description: OAuthAppDescriptionSchema,
488
491
  hidden: Schema.optional(Schema.Boolean),
489
492
  icon: Schema.optional(Schema.instanceOf(Blob)),
490
- id: Schema.Int,
491
- website: Schema.String
493
+ id: OAuthAppIdSchema,
494
+ website: OAuthAppUrlSchema
492
495
  });
493
496
  const OAuthSetIconInputSchema = Schema.Struct({ icon: Schema.instanceOf(Blob) });
494
497
  const QueryOAuthAppsErrorSpec = definePutioOperationErrorSpec({
@@ -573,46 +576,60 @@ const queryOAuthApps = () => requestJson(OAuthAppsEnvelopeSchema, {
573
576
  method: "GET",
574
577
  path: "/v2/oauth/apps"
575
578
  }).pipe(selectJsonField("apps"), withOperationErrors(QueryOAuthAppsErrorSpec));
576
- const getOAuthApp = (id, options) => requestJson(OAuthAppWithTokenSchema, {
579
+ const getOAuthApp = (id, options) => Schema.decodeUnknownEffect(Schema.Struct({
580
+ edit: Schema.optional(Schema.Boolean),
581
+ id: OAuthAppIdSchema
582
+ }))({
583
+ edit: options?.edit,
584
+ id
585
+ }).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OAuthAppWithTokenSchema, {
577
586
  method: "GET",
578
- path: options?.edit ? `/v2/oauth/apps/${encodePathSegment(id)}/edit` : `/v2/oauth/apps/${encodePathSegment(id)}`
579
- }).pipe(withOperationErrors(GetOAuthAppErrorSpec));
587
+ path: decodedInput.edit ? `/v2/oauth/apps/${encodePathSegment(decodedInput.id)}/edit` : `/v2/oauth/apps/${encodePathSegment(decodedInput.id)}`
588
+ })), withOperationErrors(GetOAuthAppErrorSpec));
580
589
  const setOAuthAppIcon = (id, input) => {
581
- const formData = new FormData();
582
- formData.append("icon", input.icon);
583
- return requestJson(OkResponseSchema, {
584
- body: {
585
- type: "form-data",
586
- value: formData
587
- },
588
- method: "POST",
589
- path: `/v2/oauth/apps/${encodePathSegment(id)}/icon`
590
- });
590
+ return Schema.decodeUnknownEffect(Schema.Struct({
591
+ id: OAuthAppIdSchema,
592
+ input: OAuthSetIconInputSchema
593
+ }))({
594
+ id,
595
+ input
596
+ }).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => {
597
+ const formData = new FormData();
598
+ formData.append("icon", decodedInput.input.icon);
599
+ return requestJson(OkResponseSchema, {
600
+ body: {
601
+ type: "form-data",
602
+ value: formData
603
+ },
604
+ method: "POST",
605
+ path: `/v2/oauth/apps/${encodePathSegment(decodedInput.id)}/icon`
606
+ });
607
+ }));
591
608
  };
592
- const createOAuthApp = (input) => requestJson(OAuthAppEnvelopeSchema, {
609
+ const createOAuthApp = (input) => Schema.decodeUnknownEffect(OAuthAppCreateInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OAuthAppEnvelopeSchema, {
593
610
  body: {
594
611
  type: "form-data",
595
- value: makeCreateOAuthAppFormData(input)
612
+ value: makeCreateOAuthAppFormData(decodedInput)
596
613
  },
597
614
  method: "POST",
598
615
  path: "/v2/oauth/apps/register"
599
- }).pipe(withOperationErrors(CreateOAuthAppErrorSpec));
600
- const updateOAuthApp = (input) => requestJson(OAuthAppWithTokenSchema, {
616
+ })), withOperationErrors(CreateOAuthAppErrorSpec));
617
+ const updateOAuthApp = (input) => Schema.decodeUnknownEffect(OAuthAppUpdateInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OAuthAppWithTokenSchema, {
601
618
  body: {
602
619
  type: "form-data",
603
- value: makeUpdateOAuthAppFormData(input)
620
+ value: makeUpdateOAuthAppFormData(decodedInput)
604
621
  },
605
622
  method: "POST",
606
- path: `/v2/oauth/apps/${encodePathSegment(input.id)}`
607
- }).pipe(withOperationErrors(UpdateOAuthAppErrorSpec));
608
- const deleteOAuthApp = (id) => requestJson(OkResponseSchema, {
623
+ path: `/v2/oauth/apps/${encodePathSegment(decodedInput.id)}`
624
+ })), withOperationErrors(UpdateOAuthAppErrorSpec));
625
+ const deleteOAuthApp = (id) => Schema.decodeUnknownEffect(OAuthAppIdSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
609
626
  method: "POST",
610
- path: `/v2/oauth/apps/${encodePathSegment(id)}/delete`
611
- }).pipe(withOperationErrors(DeleteOAuthAppErrorSpec));
612
- const regenerateOAuthAppToken = (id) => requestJson(OAuthRegeneratedTokenEnvelopeSchema, {
627
+ path: `/v2/oauth/apps/${encodePathSegment(decodedId)}/delete`
628
+ })), withOperationErrors(DeleteOAuthAppErrorSpec));
629
+ const regenerateOAuthAppToken = (id) => Schema.decodeUnknownEffect(OAuthAppIdSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OAuthRegeneratedTokenEnvelopeSchema, {
613
630
  method: "POST",
614
- path: `/v2/oauth/apps/${encodePathSegment(id)}/regenerate_token`
615
- }).pipe(selectJsonField("access_token"), withOperationErrors(RegenerateOAuthAppTokenErrorSpec));
631
+ path: `/v2/oauth/apps/${encodePathSegment(decodedId)}/regenerate_token`
632
+ })), selectJsonField("access_token"), withOperationErrors(RegenerateOAuthAppTokenErrorSpec));
616
633
  const getPopularOAuthApps = () => requestJson(PopularOAuthAppsEnvelopeSchema, {
617
634
  method: "GET",
618
635
  path: "/v2/oauth/apps/popular"
@@ -1366,6 +1383,16 @@ const deleteConfigKey = (key) => Schema.decodeUnknownEffect(ConfigKeySchema)(key
1366
1383
  path: `/v2/config/${encodePathSegment(decodedKey)}`
1367
1384
  })));
1368
1385
  //#endregion
1386
+ //#region src/core/validation.ts
1387
+ const PositiveIntegerSchema = Schema.Int.check(Schema.isGreaterThan(0));
1388
+ const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1));
1389
+ const decodeAndRun = (schema, input, run) => Schema.decodeUnknownEffect(schema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap(run));
1390
+ const makeCursorSelectionSchema = (idsField, excludeIdsField) => Schema.Struct({
1391
+ cursor: Schema.optional(NonEmptyStringSchema),
1392
+ [excludeIdsField]: Schema.optional(Schema.Array(PositiveIntegerSchema)),
1393
+ [idsField]: Schema.optional(Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1)))
1394
+ }).check(Schema.makeFilter((input) => input.cursor !== void 0 || input[idsField] !== void 0, { expected: "a non-empty cursor or file ID selection" }));
1395
+ //#endregion
1369
1396
  //#region src/domains/download-links.ts
1370
1397
  const DownloadLinksStatusSchema = Schema.Literals([
1371
1398
  "NEW",
@@ -1373,11 +1400,7 @@ const DownloadLinksStatusSchema = Schema.Literals([
1373
1400
  "DONE",
1374
1401
  "ERROR"
1375
1402
  ]);
1376
- const DownloadLinksCreateInputSchema = Schema.Struct({
1377
- cursor: Schema.optional(Schema.String),
1378
- excludeIds: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))),
1379
- ids: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))))
1380
- });
1403
+ const DownloadLinksCreateInputSchema = makeCursorSelectionSchema("ids", "excludeIds");
1381
1404
  const DownloadLinksPayloadSchema = Schema.Struct({
1382
1405
  download_links: Schema.Array(Schema.String),
1383
1406
  media_links: Schema.Array(Schema.String),
@@ -1452,18 +1475,18 @@ const GetDownloadLinksErrorSpec = definePutioOperationErrorSpec({
1452
1475
  { statusCode: 404 }
1453
1476
  ]
1454
1477
  });
1455
- const createDownloadLinks = (input = {}) => requestJson(DownloadLinksCreateEnvelopeSchema, {
1478
+ const createDownloadLinks = (input = {}) => Schema.decodeUnknownEffect(DownloadLinksCreateInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(DownloadLinksCreateEnvelopeSchema, {
1456
1479
  body: {
1457
1480
  type: "form",
1458
- value: toCursorSelectionForm(input)
1481
+ value: toCursorSelectionForm(decodedInput)
1459
1482
  },
1460
1483
  method: "POST",
1461
1484
  path: "/v2/download_links/create"
1462
- }).pipe(selectJsonFields("id"), withOperationErrors(CreateDownloadLinksErrorSpec));
1463
- const getDownloadLinks = (id) => requestJson(DownloadLinksInfoSchema, {
1485
+ })), selectJsonFields("id"), withOperationErrors(CreateDownloadLinksErrorSpec));
1486
+ const getDownloadLinks = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(DownloadLinksInfoSchema, {
1464
1487
  method: "GET",
1465
- path: `/v2/download_links/${encodePathSegment(id)}`
1466
- }).pipe(withOperationErrors(GetDownloadLinksErrorSpec));
1488
+ path: `/v2/download_links/${encodePathSegment(decodedId)}`
1489
+ })), withOperationErrors(GetDownloadLinksErrorSpec));
1467
1490
  //#endregion
1468
1491
  //#region src/domains/events.ts
1469
1492
  const HistoryEventBaseSchema = Schema.Struct({
@@ -1612,23 +1635,23 @@ const GetEventTorrentErrorSpec = definePutioOperationErrorSpec({
1612
1635
  { statusCode: 500 }
1613
1636
  ]
1614
1637
  });
1615
- const listEvents = (query = {}) => requestJson(EventsListEnvelopeSchema, {
1638
+ const listEvents = (query = {}) => Schema.decodeUnknownEffect(EventsListQuerySchema)(query).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedQuery) => requestJson(EventsListEnvelopeSchema, {
1616
1639
  method: "GET",
1617
1640
  path: "/v2/events/list",
1618
- query
1619
- }).pipe(withOperationErrors(ListEventsErrorSpec));
1620
- const deleteEvent = (id) => requestJson(OkResponseSchema, {
1641
+ query: decodedQuery
1642
+ })), withOperationErrors(ListEventsErrorSpec));
1643
+ const deleteEvent = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
1621
1644
  method: "POST",
1622
- path: `/v2/events/delete/${encodePathSegment(id)}`
1623
- }).pipe(withOperationErrors(DeleteEventErrorSpec));
1645
+ path: `/v2/events/delete/${encodePathSegment(decodedId)}`
1646
+ })), withOperationErrors(DeleteEventErrorSpec));
1624
1647
  const clearEvents = () => requestJson(OkResponseSchema, {
1625
1648
  method: "POST",
1626
1649
  path: "/v2/events/delete"
1627
1650
  }).pipe(withOperationErrors(ClearEventsErrorSpec));
1628
- const getEventTorrent = (id) => requestArrayBuffer({
1651
+ const getEventTorrent = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestArrayBuffer({
1629
1652
  method: "GET",
1630
- path: `/v2/events/${encodePathSegment(id)}/torrent`
1631
- }).pipe(withOperationErrors(GetEventTorrentErrorSpec));
1653
+ path: `/v2/events/${encodePathSegment(decodedId)}/torrent`
1654
+ })), withOperationErrors(GetEventTorrentErrorSpec));
1632
1655
  //#endregion
1633
1656
  //#region src/domains/family.ts
1634
1657
  const NonNegativeIntegerSchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
@@ -1747,14 +1770,14 @@ const createFamilyInvite = () => requestJson(FamilyCreateInviteEnvelopeSchema, {
1747
1770
  method: "POST",
1748
1771
  path: "/v2/family/sub_account"
1749
1772
  }).pipe(selectJsonFields("code"), withOperationErrors(CreateFamilyInviteErrorSpec));
1750
- const removeFamilyMember = (username) => requestJson(OkResponseSchema, {
1773
+ const removeFamilyMember = (username) => Schema.decodeUnknownEffect(NonEmptyStringSchema)(username).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedUsername) => requestJson(OkResponseSchema, {
1751
1774
  method: "DELETE",
1752
- path: `/v2/family/sub_account/${encodePathSegment(username)}`
1753
- }).pipe(Effect.asVoid, withOperationErrors(RemoveFamilyMemberErrorSpec));
1754
- const joinFamily = (inviteCode) => requestJson(OkResponseSchema, {
1775
+ path: `/v2/family/sub_account/${encodePathSegment(decodedUsername)}`
1776
+ })), Effect.asVoid, withOperationErrors(RemoveFamilyMemberErrorSpec));
1777
+ const joinFamily = (inviteCode) => Schema.decodeUnknownEffect(NonEmptyStringSchema)(inviteCode).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInviteCode) => requestJson(OkResponseSchema, {
1755
1778
  method: "POST",
1756
- path: `/v2/family/join/${encodePathSegment(inviteCode)}`
1757
- }).pipe(Effect.asVoid, withOperationErrors(JoinFamilyErrorSpec));
1779
+ path: `/v2/family/join/${encodePathSegment(decodedInviteCode)}`
1780
+ })), Effect.asVoid, withOperationErrors(JoinFamilyErrorSpec));
1758
1781
  //#endregion
1759
1782
  //#region src/domains/ifttt.ts
1760
1783
  const IFTTTStatusEnvelopeSchema = Schema.Struct({
@@ -2980,14 +3003,15 @@ const FriendSharedFolderErrorSpec = definePutioOperationErrorSpec({
2980
3003
  { statusCode: 404 }
2981
3004
  ]
2982
3005
  });
3006
+ const decodeUsername = (username) => Schema.decodeUnknownEffect(NonEmptyStringSchema)(username).pipe(Effect.mapError(mapDecodeErrorToValidationError));
2983
3007
  const listFriends = () => requestJson(FriendsListEnvelopeSchema, {
2984
3008
  method: "GET",
2985
3009
  path: "/v2/friends/list"
2986
3010
  }).pipe(selectJsonFields("friends", "total"), withOperationErrors(ListFriendsErrorSpec));
2987
- const searchFriends = (username) => requestJson(FriendSearchEnvelopeSchema, {
3011
+ const searchFriends = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(FriendSearchEnvelopeSchema, {
2988
3012
  method: "GET",
2989
- path: `/v2/friends/user-search/${encodePathSegment(username)}`
2990
- }).pipe(selectJsonField("users"), withOperationErrors(SearchFriendsErrorSpec));
3013
+ path: `/v2/friends/user-search/${encodePathSegment(decodedUsername)}`
3014
+ })), selectJsonField("users"), withOperationErrors(SearchFriendsErrorSpec));
2991
3015
  const listWaitingRequests = () => requestJson(FriendRequestsEnvelopeSchema, {
2992
3016
  method: "GET",
2993
3017
  path: "/v2/friends/waiting-requests"
@@ -3000,26 +3024,26 @@ const listSentRequests = () => requestJson(FriendRequestsEnvelopeSchema, {
3000
3024
  method: "GET",
3001
3025
  path: "/v2/friends/sent-requests"
3002
3026
  }).pipe(selectJsonField("friends"), withOperationErrors(ListSentRequestsErrorSpec));
3003
- const sendFriendRequest = (username) => requestJson(OkResponseSchema, {
3027
+ const sendFriendRequest = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(OkResponseSchema, {
3004
3028
  method: "POST",
3005
- path: `/v2/friends/${encodePathSegment(username)}/request`
3006
- }).pipe(withOperationErrors(SendFriendRequestErrorSpec));
3007
- const removeFriend = (username) => requestJson(OkResponseSchema, {
3029
+ path: `/v2/friends/${encodePathSegment(decodedUsername)}/request`
3030
+ })), withOperationErrors(SendFriendRequestErrorSpec));
3031
+ const removeFriend = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(OkResponseSchema, {
3008
3032
  method: "POST",
3009
- path: `/v2/friends/${encodePathSegment(username)}/unfriend`
3010
- }).pipe(withOperationErrors(RemoveFriendErrorSpec));
3011
- const approveFriendRequest = (username) => requestJson(OkResponseSchema, {
3033
+ path: `/v2/friends/${encodePathSegment(decodedUsername)}/unfriend`
3034
+ })), withOperationErrors(RemoveFriendErrorSpec));
3035
+ const approveFriendRequest = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(OkResponseSchema, {
3012
3036
  method: "POST",
3013
- path: `/v2/friends/${encodePathSegment(username)}/approve`
3014
- }).pipe(withOperationErrors(ApproveFriendRequestErrorSpec));
3015
- const denyFriendRequest = (username) => requestJson(OkResponseSchema, {
3037
+ path: `/v2/friends/${encodePathSegment(decodedUsername)}/approve`
3038
+ })), withOperationErrors(ApproveFriendRequestErrorSpec));
3039
+ const denyFriendRequest = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(OkResponseSchema, {
3016
3040
  method: "POST",
3017
- path: `/v2/friends/${encodePathSegment(username)}/deny`
3018
- }).pipe(withOperationErrors(DenyFriendRequestErrorSpec));
3019
- const getFriendSharedFolder = (username) => requestJson(FriendSharedFolderEnvelopeSchema, {
3041
+ path: `/v2/friends/${encodePathSegment(decodedUsername)}/deny`
3042
+ })), withOperationErrors(DenyFriendRequestErrorSpec));
3043
+ const getFriendSharedFolder = (username) => decodeUsername(username).pipe(Effect.flatMap((decodedUsername) => requestJson(FriendSharedFolderEnvelopeSchema, {
3020
3044
  method: "GET",
3021
- path: `/v2/friends/${encodePathSegment(username)}/files`
3022
- }).pipe(selectJsonField("file"), withOperationErrors(FriendSharedFolderErrorSpec));
3045
+ path: `/v2/friends/${encodePathSegment(decodedUsername)}/files`
3046
+ })), selectJsonField("file"), withOperationErrors(FriendSharedFolderErrorSpec));
3023
3047
  //#endregion
3024
3048
  //#region src/domains/payment.ts
3025
3049
  const PaymentPlanTypeSchema = Schema.Literals(["onetime", "subscription"]);
@@ -3746,10 +3770,18 @@ const RssFeedParamsSchema = Schema.Struct({
3746
3770
  dont_process_whole_feed: Schema.optional(Schema.Boolean),
3747
3771
  keyword: Schema.optional(Schema.NullOr(Schema.String)),
3748
3772
  parent_dir_id: Schema.optional(Schema.Union([Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), Schema.Literal("newf")])),
3749
- rss_source_url: Schema.String,
3750
- title: Schema.String,
3773
+ rss_source_url: NonEmptyStringSchema,
3774
+ title: NonEmptyStringSchema,
3751
3775
  unwanted_keywords: Schema.optional(Schema.String)
3752
3776
  });
3777
+ const RssFeedUpdateInputSchema = Schema.Struct({
3778
+ id: PositiveIntegerSchema,
3779
+ params: RssFeedParamsSchema
3780
+ });
3781
+ const RssFeedItemRetryInputSchema = Schema.Struct({
3782
+ feedId: PositiveIntegerSchema,
3783
+ itemId: PositiveIntegerSchema
3784
+ });
3753
3785
  const RssFeedItemBaseSchema = Schema.Struct({
3754
3786
  detected_date: Schema.String,
3755
3787
  id: Schema.Int.check(Schema.isGreaterThan(0)),
@@ -3999,54 +4031,60 @@ const listRssFeeds = () => requestJson(RssFeedsEnvelopeSchema, {
3999
4031
  method: "GET",
4000
4032
  path: "/v2/rss/list"
4001
4033
  }).pipe(selectJsonField("feeds"), withOperationErrors(ListRssFeedsErrorSpec));
4002
- const getRssFeed = (id) => requestJson(RssFeedEnvelopeSchema, {
4034
+ const getRssFeed = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(RssFeedEnvelopeSchema, {
4003
4035
  method: "GET",
4004
- path: `/v2/rss/${encodePathSegment(id)}`
4005
- }).pipe(selectJsonField("feed"), withOperationErrors(GetRssFeedErrorSpec));
4006
- const createRssFeed = (params) => requestJson(RssFeedEnvelopeSchema, {
4036
+ path: `/v2/rss/${encodePathSegment(decodedId)}`
4037
+ })), selectJsonField("feed"), withOperationErrors(GetRssFeedErrorSpec));
4038
+ const createRssFeed = (params) => Schema.decodeUnknownEffect(RssFeedParamsSchema)(params).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedParams) => requestJson(RssFeedEnvelopeSchema, {
4007
4039
  body: {
4008
4040
  type: "form",
4009
- value: toCreateBody(params)
4041
+ value: toCreateBody(decodedParams)
4010
4042
  },
4011
4043
  method: "POST",
4012
4044
  path: "/v2/rss/create"
4013
- }).pipe(selectJsonField("feed"), withOperationErrors(CreateRssFeedErrorSpec));
4014
- const updateRssFeed = (id, params) => requestJson(OkResponseSchema, {
4045
+ })), selectJsonField("feed"), withOperationErrors(CreateRssFeedErrorSpec));
4046
+ const updateRssFeed = (id, params) => Schema.decodeUnknownEffect(RssFeedUpdateInputSchema)({
4047
+ id,
4048
+ params
4049
+ }).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OkResponseSchema, {
4015
4050
  body: {
4016
4051
  type: "form",
4017
- value: toUpdateBody(params)
4052
+ value: toUpdateBody(decodedInput.params)
4018
4053
  },
4019
4054
  method: "POST",
4020
- path: `/v2/rss/${encodePathSegment(id)}`
4021
- }).pipe(withOperationErrors(UpdateRssFeedErrorSpec));
4022
- const pauseRssFeed = (id) => requestJson(OkResponseSchema, {
4055
+ path: `/v2/rss/${encodePathSegment(decodedInput.id)}`
4056
+ })), withOperationErrors(UpdateRssFeedErrorSpec));
4057
+ const pauseRssFeed = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
4023
4058
  method: "POST",
4024
- path: `/v2/rss/${encodePathSegment(id)}/pause`
4025
- }).pipe(withOperationErrors(PauseRssFeedErrorSpec));
4026
- const resumeRssFeed = (id) => requestJson(OkResponseSchema, {
4059
+ path: `/v2/rss/${encodePathSegment(decodedId)}/pause`
4060
+ })), withOperationErrors(PauseRssFeedErrorSpec));
4061
+ const resumeRssFeed = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
4027
4062
  method: "POST",
4028
- path: `/v2/rss/${encodePathSegment(id)}/resume`
4029
- }).pipe(withOperationErrors(ResumeRssFeedErrorSpec));
4030
- const deleteRssFeed = (id) => requestJson(OkResponseSchema, {
4063
+ path: `/v2/rss/${encodePathSegment(decodedId)}/resume`
4064
+ })), withOperationErrors(ResumeRssFeedErrorSpec));
4065
+ const deleteRssFeed = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
4031
4066
  method: "POST",
4032
- path: `/v2/rss/${encodePathSegment(id)}/delete`
4033
- }).pipe(withOperationErrors(DeleteRssFeedErrorSpec));
4034
- const listRssFeedItems = (id) => requestJson(RssFeedItemsEnvelopeSchema, {
4067
+ path: `/v2/rss/${encodePathSegment(decodedId)}/delete`
4068
+ })), withOperationErrors(DeleteRssFeedErrorSpec));
4069
+ const listRssFeedItems = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(RssFeedItemsEnvelopeSchema, {
4035
4070
  method: "GET",
4036
- path: `/v2/rss/${encodePathSegment(id)}/items`
4037
- }).pipe(selectJsonFields("feed", "items"), withOperationErrors(ListRssFeedItemsErrorSpec));
4038
- const clearRssFeedLogs = (id) => requestJson(OkResponseSchema, {
4071
+ path: `/v2/rss/${encodePathSegment(decodedId)}/items`
4072
+ })), selectJsonFields("feed", "items"), withOperationErrors(ListRssFeedItemsErrorSpec));
4073
+ const clearRssFeedLogs = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
4039
4074
  method: "POST",
4040
- path: `/v2/rss/${encodePathSegment(id)}/clear-log`
4041
- }).pipe(withOperationErrors(ClearRssFeedLogsErrorSpec));
4042
- const retryRssFeedItem = (feedId, itemId) => requestJson(OkResponseSchema, {
4075
+ path: `/v2/rss/${encodePathSegment(decodedId)}/clear-log`
4076
+ })), withOperationErrors(ClearRssFeedLogsErrorSpec));
4077
+ const retryRssFeedItem = (feedId, itemId) => Schema.decodeUnknownEffect(RssFeedItemRetryInputSchema)({
4078
+ feedId,
4079
+ itemId
4080
+ }).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OkResponseSchema, {
4043
4081
  method: "POST",
4044
- path: `/v2/rss/${encodePathSegment(feedId)}/items/${encodePathSegment(itemId)}/retry`
4045
- }).pipe(withOperationErrors(RetryRssFeedItemErrorSpec));
4046
- const retryAllRssFeedItems = (feedId) => requestJson(OkResponseSchema, {
4082
+ path: `/v2/rss/${encodePathSegment(decodedInput.feedId)}/items/${encodePathSegment(decodedInput.itemId)}/retry`
4083
+ })), withOperationErrors(RetryRssFeedItemErrorSpec));
4084
+ const retryAllRssFeedItems = (feedId) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(feedId).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedFeedId) => requestJson(OkResponseSchema, {
4047
4085
  method: "POST",
4048
- path: `/v2/rss/${encodePathSegment(feedId)}/retry-all`
4049
- }).pipe(withOperationErrors(RetryAllRssFeedItemsErrorSpec));
4086
+ path: `/v2/rss/${encodePathSegment(decodedFeedId)}/retry-all`
4087
+ })), withOperationErrors(RetryAllRssFeedItemsErrorSpec));
4050
4088
  //#endregion
4051
4089
  //#region src/domains/sharing.ts
4052
4090
  const SharingCloneStatusSchema = Schema.Literals([
@@ -4056,10 +4094,10 @@ const SharingCloneStatusSchema = Schema.Literals([
4056
4094
  "ERROR"
4057
4095
  ]);
4058
4096
  const SharingCloneInputSchema = Schema.Struct({
4059
- cursor: Schema.optional(Schema.String),
4060
- excludeIds: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))),
4061
- ids: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))),
4062
- parentId: Schema.optional(Schema.Int)
4097
+ cursor: Schema.optional(NonEmptyStringSchema),
4098
+ excludeIds: Schema.optional(Schema.Array(PositiveIntegerSchema)),
4099
+ ids: Schema.optional(Schema.Array(PositiveIntegerSchema)),
4100
+ parentId: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))
4063
4101
  });
4064
4102
  const SharingCloneEnvelopeSchema = Schema.Struct({
4065
4103
  id: Schema.Int.check(Schema.isGreaterThan(0)),
@@ -4079,11 +4117,11 @@ const SharingCloneInfoSchema = Schema.Union([Schema.Struct({
4079
4117
  })]);
4080
4118
  const SharedFileSchema = FileBroadSchema.pipe(Schema.fieldsAssign({ shared_with: Schema.Union([Schema.Literal("everyone"), Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))]) }));
4081
4119
  const SharingShareInputSchema = Schema.Struct({
4082
- cursor: Schema.optional(Schema.String),
4083
- excludeIds: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))),
4084
- ids: Schema.optional(Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))),
4120
+ cursor: Schema.optional(NonEmptyStringSchema),
4121
+ excludeIds: Schema.optional(Schema.Array(PositiveIntegerSchema)),
4122
+ ids: Schema.optional(Schema.Array(PositiveIntegerSchema)),
4085
4123
  target: Schema.Union([Schema.Struct({ type: Schema.Literal("everyone") }), Schema.Struct({
4086
- friendNames: Schema.Array(Schema.String).check(Schema.isMinLength(1)),
4124
+ friendNames: Schema.Array(NonEmptyStringSchema).check(Schema.isMinLength(1)),
4087
4125
  type: Schema.Literal("friends")
4088
4126
  })])
4089
4127
  });
@@ -4105,8 +4143,8 @@ const SharedFileSharedWithSchema = Schema.Union([Schema.Struct({
4105
4143
  status: Schema.optional(Schema.Literal("OK"))
4106
4144
  })]);
4107
4145
  const SharingUnshareInputSchema = Schema.Struct({
4108
- fileId: Schema.Int.check(Schema.isGreaterThan(0)),
4109
- shares: Schema.optional(Schema.Array(Schema.Union([Schema.Int, Schema.String])))
4146
+ fileId: PositiveIntegerSchema,
4147
+ shares: Schema.optional(Schema.Array(Schema.Union([PositiveIntegerSchema, NonEmptyStringSchema])))
4110
4148
  });
4111
4149
  const PublicShareSchema = Schema.Struct({
4112
4150
  created_at: Schema.String,
@@ -4156,7 +4194,7 @@ const PublicShareListQuerySchema = Schema.Struct({
4156
4194
  hidden: Schema.optional(Schema.Literal(1)),
4157
4195
  media_info_parent: Schema.optional(Schema.Literal(1)),
4158
4196
  mp4_status_parent: Schema.optional(Schema.Literal(1)),
4159
- parent_id: Schema.optional(Schema.Int),
4197
+ parent_id: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
4160
4198
  per_page: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
4161
4199
  sort: Schema.optional(Schema.String),
4162
4200
  sort_by: Schema.optional(Schema.String),
@@ -4164,6 +4202,10 @@ const PublicShareListQuerySchema = Schema.Struct({
4164
4202
  total: Schema.optional(Schema.Literal(1)),
4165
4203
  video_metadata_parent: Schema.optional(Schema.Literal(1))
4166
4204
  });
4205
+ const PublicShareContinueInputSchema = Schema.Struct({
4206
+ cursor: NonEmptyStringSchema,
4207
+ query: Schema.Struct({ per_page: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))) })
4208
+ });
4167
4209
  const CreateSharingCloneErrorSpec = definePutioOperationErrorSpec({
4168
4210
  domain: "sharing",
4169
4211
  operation: "clone",
@@ -4357,90 +4399,86 @@ const GetPublicShareFileUrlErrorSpec = definePutioOperationErrorSpec({
4357
4399
  { statusCode: 404 }
4358
4400
  ]
4359
4401
  });
4360
- const toShareTarget = (target) => {
4361
- if (target.type === "everyone") return Effect.succeed("everyone");
4362
- if (target.friendNames.length === 0) return Effect.fail(new PutioValidationError({ cause: "shareFiles target.friendNames must include at least one friend" }));
4363
- return Effect.succeed(target.friendNames.join(","));
4364
- };
4365
- const cloneSharedFiles = (input = {}) => requestJson(SharingCloneEnvelopeSchema, {
4402
+ const toShareTarget = (target) => target.type === "everyone" ? "everyone" : target.friendNames.join(",");
4403
+ const cloneSharedFiles = (input = {}) => Schema.decodeUnknownEffect(SharingCloneInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(SharingCloneEnvelopeSchema, {
4366
4404
  body: {
4367
4405
  type: "form",
4368
4406
  value: {
4369
- ...toCursorSelectionForm(input),
4370
- parent_id: input.parentId ?? 0
4407
+ ...toCursorSelectionForm(decodedInput),
4408
+ parent_id: decodedInput.parentId ?? 0
4371
4409
  }
4372
4410
  },
4373
4411
  method: "POST",
4374
4412
  path: "/v2/sharing/clone"
4375
- }).pipe(selectJsonFields("id"), withOperationErrors(CreateSharingCloneErrorSpec));
4376
- const getSharingCloneInfo = (id) => requestJson(SharingCloneInfoSchema, {
4413
+ })), selectJsonFields("id"), withOperationErrors(CreateSharingCloneErrorSpec));
4414
+ const getSharingCloneInfo = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(SharingCloneInfoSchema, {
4377
4415
  method: "GET",
4378
- path: `/v2/sharing/clone/${encodePathSegment(id)}`
4379
- }).pipe(withOperationErrors(GetSharingCloneInfoErrorSpec));
4380
- const shareFiles = (input) => Effect.gen(function* () {
4381
- const friends = yield* toShareTarget(input.target);
4382
- return yield* requestJson(OkResponseSchema, {
4383
- body: {
4384
- type: "form",
4385
- value: {
4386
- ...toCursorSelectionForm(input),
4387
- friends
4388
- }
4389
- },
4390
- method: "POST",
4391
- path: "/v2/files/share"
4392
- });
4393
- }).pipe(withOperationErrors(ShareFilesErrorSpec));
4416
+ path: `/v2/sharing/clone/${encodePathSegment(decodedId)}`
4417
+ })), withOperationErrors(GetSharingCloneInfoErrorSpec));
4418
+ const shareFiles = (input) => Schema.decodeUnknownEffect(SharingShareInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OkResponseSchema, {
4419
+ body: {
4420
+ type: "form",
4421
+ value: {
4422
+ ...toCursorSelectionForm(decodedInput),
4423
+ friends: toShareTarget(decodedInput.target)
4424
+ }
4425
+ },
4426
+ method: "POST",
4427
+ path: "/v2/files/share"
4428
+ })), withOperationErrors(ShareFilesErrorSpec));
4394
4429
  const listSharedFiles = () => requestJson(SharedFilesEnvelopeSchema, {
4395
4430
  method: "GET",
4396
4431
  path: "/v2/files/shared"
4397
4432
  }).pipe(selectJsonField("shared"), withOperationErrors(ListSharedFilesErrorSpec));
4398
- const getSharedWith = (fileId) => requestJson(SharedFileSharedWithSchema, {
4433
+ const getSharedWith = (fileId) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(fileId).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedFileId) => requestJson(SharedFileSharedWithSchema, {
4399
4434
  method: "GET",
4400
- path: `/v2/files/${encodePathSegment(fileId)}/shared-with-v2`
4401
- }).pipe(withOperationErrors(GetSharedWithErrorSpec));
4402
- const unshareFile = (input) => requestJson(OkResponseSchema, {
4435
+ path: `/v2/files/${encodePathSegment(decodedFileId)}/shared-with-v2`
4436
+ })), withOperationErrors(GetSharedWithErrorSpec));
4437
+ const unshareFile = (input) => Schema.decodeUnknownEffect(SharingUnshareInputSchema)(input).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(OkResponseSchema, {
4403
4438
  body: {
4404
4439
  type: "form",
4405
- value: { shares: joinCsv(input.shares) ?? "everyone" }
4440
+ value: { shares: joinCsv(decodedInput.shares) ?? "everyone" }
4406
4441
  },
4407
4442
  method: "POST",
4408
- path: `/v2/files/${encodePathSegment(input.fileId)}/unshare`
4409
- }).pipe(withOperationErrors(UnshareFileErrorSpec));
4410
- const createPublicShare = (fileId) => requestJson(PublicShareEnvelopeSchema, {
4443
+ path: `/v2/files/${encodePathSegment(decodedInput.fileId)}/unshare`
4444
+ })), withOperationErrors(UnshareFileErrorSpec));
4445
+ const createPublicShare = (fileId) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(fileId).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedFileId) => requestJson(PublicShareEnvelopeSchema, {
4411
4446
  method: "POST",
4412
- path: `/v2/public_share/${encodePathSegment(fileId)}`
4413
- }).pipe(selectJsonField("public_share"), withOperationErrors(CreatePublicShareErrorSpec));
4447
+ path: `/v2/public_share/${encodePathSegment(decodedFileId)}`
4448
+ })), selectJsonField("public_share"), withOperationErrors(CreatePublicShareErrorSpec));
4414
4449
  const listPublicShares = () => requestJson(PublicSharesEnvelopeSchema, {
4415
4450
  method: "GET",
4416
4451
  path: "/v2/public_share/list"
4417
4452
  }).pipe(selectJsonField("public_shares"), withOperationErrors(ListPublicSharesErrorSpec));
4418
- const deletePublicShare = (id) => requestJson(OkResponseSchema, {
4453
+ const deletePublicShare = (id) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(id).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedId) => requestJson(OkResponseSchema, {
4419
4454
  method: "DELETE",
4420
- path: `/v2/public_share/${encodePathSegment(id)}`
4421
- }).pipe(withOperationErrors(DeletePublicShareErrorSpec));
4455
+ path: `/v2/public_share/${encodePathSegment(decodedId)}`
4456
+ })), withOperationErrors(DeletePublicShareErrorSpec));
4422
4457
  const getPublicShare = () => requestJson(PublicShareEnvelopeSchema, {
4423
4458
  method: "GET",
4424
4459
  path: "/v2/public_share"
4425
4460
  }).pipe(selectJsonField("public_share"), withOperationErrors(GetPublicShareErrorSpec));
4426
- const listPublicShareFiles = (query = {}) => requestJson(PublicShareFileListEnvelopeSchema, {
4461
+ const listPublicShareFiles = (query = {}) => Schema.decodeUnknownEffect(PublicShareListQuerySchema)(query).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedQuery) => requestJson(PublicShareFileListEnvelopeSchema, {
4427
4462
  method: "GET",
4428
4463
  path: "/v2/public_share/files/list",
4464
+ query: decodedQuery
4465
+ })), withOperationErrors(ListPublicShareFilesErrorSpec));
4466
+ const continuePublicShareFiles = (cursor, query = {}) => Schema.decodeUnknownEffect(PublicShareContinueInputSchema)({
4467
+ cursor,
4429
4468
  query
4430
- }).pipe(withOperationErrors(ListPublicShareFilesErrorSpec));
4431
- const continuePublicShareFiles = (cursor, query = {}) => requestJson(PublicShareFileListContinueEnvelopeSchema, {
4469
+ }).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedInput) => requestJson(PublicShareFileListContinueEnvelopeSchema, {
4432
4470
  body: {
4433
4471
  type: "form",
4434
- value: { cursor }
4472
+ value: { cursor: decodedInput.cursor }
4435
4473
  },
4436
4474
  method: "POST",
4437
4475
  path: "/v2/public_share/files/list/continue",
4438
- query
4439
- }).pipe(withOperationErrors(ContinuePublicShareFilesErrorSpec));
4440
- const getPublicShareFileUrl = (fileId) => requestJson(PublicShareFileUrlEnvelopeSchema, {
4476
+ query: decodedInput.query
4477
+ })), withOperationErrors(ContinuePublicShareFilesErrorSpec));
4478
+ const getPublicShareFileUrl = (fileId) => Schema.decodeUnknownEffect(PositiveIntegerSchema)(fileId).pipe(Effect.mapError(mapDecodeErrorToValidationError), Effect.flatMap((decodedFileId) => requestJson(PublicShareFileUrlEnvelopeSchema, {
4441
4479
  method: "GET",
4442
- path: `/v2/public_share/files/${encodePathSegment(fileId)}/url`
4443
- }).pipe(selectJsonField("url"), withOperationErrors(GetPublicShareFileUrlErrorSpec));
4480
+ path: `/v2/public_share/files/${encodePathSegment(decodedFileId)}/url`
4481
+ })), selectJsonField("url"), withOperationErrors(GetPublicShareFileUrlErrorSpec));
4444
4482
  //#endregion
4445
4483
  //#region src/domains/trash.ts
4446
4484
  const TrashFileSchema = Schema.Struct({
@@ -4471,6 +4509,22 @@ const TrashContinueEnvelopeSchema = Schema.Struct({
4471
4509
  files: Schema.Array(TrashFileSchema),
4472
4510
  status: Schema.Literal("OK")
4473
4511
  });
4512
+ const TrashListQuerySchema = Schema.Struct({ per_page: Schema.optional(PositiveIntegerSchema) });
4513
+ const TrashCursorBulkInputSchema = Schema.Struct({
4514
+ cursor: NonEmptyStringSchema,
4515
+ file_ids: Schema.optional(Schema.Never),
4516
+ useCursor: Schema.Literal(true)
4517
+ });
4518
+ const TrashIdsBulkInputSchema = Schema.Struct({
4519
+ cursor: Schema.optional(Schema.Never),
4520
+ file_ids: Schema.Array(PositiveIntegerSchema).check(Schema.isMinLength(1)),
4521
+ useCursor: Schema.optional(Schema.Literal(false))
4522
+ });
4523
+ const TrashBulkInputSchema = Schema.Union([TrashCursorBulkInputSchema, TrashIdsBulkInputSchema]);
4524
+ const TrashContinueInputSchema = Schema.Struct({
4525
+ cursor: NonEmptyStringSchema,
4526
+ query: TrashListQuerySchema
4527
+ });
4474
4528
  const RestrictedReadError = {
4475
4529
  errorType: "invalid_scope",
4476
4530
  statusCode: 401
@@ -4540,46 +4594,48 @@ const EmptyTrashErrorSpec = definePutioOperationErrorSpec({
4540
4594
  }, RestrictedWriteError]
4541
4595
  });
4542
4596
  const toBulkTrashBody = (input) => {
4543
- if (input.useCursor) return {
4597
+ if (input.useCursor === true) return {
4544
4598
  cursor: input.cursor,
4545
4599
  file_ids: void 0
4546
4600
  };
4547
- if (!input.file_ids) throw new Error("trash bulk file_ids are required when useCursor is not set");
4548
4601
  return {
4549
4602
  cursor: void 0,
4550
4603
  file_ids: joinCsv(input.file_ids)
4551
4604
  };
4552
4605
  };
4553
- const listTrash = (query) => requestJson(TrashListEnvelopeSchema, {
4606
+ const listTrash = (query = {}) => decodeAndRun(TrashListQuerySchema, query, (decodedQuery) => requestJson(TrashListEnvelopeSchema, {
4554
4607
  method: "GET",
4555
4608
  path: "/v2/trash/list",
4609
+ query: decodedQuery
4610
+ })).pipe(withOperationErrors(ListTrashErrorSpec));
4611
+ const continueTrash = (cursor, query = {}) => decodeAndRun(TrashContinueInputSchema, {
4612
+ cursor,
4556
4613
  query
4557
- }).pipe(withOperationErrors(ListTrashErrorSpec));
4558
- const continueTrash = (cursor, query) => requestJson(TrashContinueEnvelopeSchema, {
4614
+ }, (decodedInput) => requestJson(TrashContinueEnvelopeSchema, {
4559
4615
  body: {
4560
4616
  type: "form",
4561
- value: { cursor }
4617
+ value: { cursor: decodedInput.cursor }
4562
4618
  },
4563
4619
  method: "POST",
4564
4620
  path: "/v2/trash/list/continue",
4565
- query
4566
- }).pipe(withOperationErrors(ContinueTrashErrorSpec));
4567
- const restoreTrash = (input) => requestJson(OkResponseSchema, {
4621
+ query: decodedInput.query
4622
+ })).pipe(withOperationErrors(ContinueTrashErrorSpec));
4623
+ const restoreTrash = (input) => decodeAndRun(TrashBulkInputSchema, input, (decodedInput) => requestJson(OkResponseSchema, {
4568
4624
  body: {
4569
4625
  type: "form",
4570
- value: toBulkTrashBody(input)
4626
+ value: toBulkTrashBody(decodedInput)
4571
4627
  },
4572
4628
  method: "POST",
4573
4629
  path: "/v2/trash/restore"
4574
- }).pipe(Effect.asVoid, withOperationErrors(RestoreTrashErrorSpec));
4575
- const deleteTrash = (input) => requestJson(OkResponseSchema, {
4630
+ })).pipe(Effect.asVoid, withOperationErrors(RestoreTrashErrorSpec));
4631
+ const deleteTrash = (input) => decodeAndRun(TrashBulkInputSchema, input, (decodedInput) => requestJson(OkResponseSchema, {
4576
4632
  body: {
4577
4633
  type: "form",
4578
- value: toBulkTrashBody(input)
4634
+ value: toBulkTrashBody(decodedInput)
4579
4635
  },
4580
4636
  method: "POST",
4581
4637
  path: "/v2/trash/delete"
4582
- }).pipe(Effect.asVoid, withOperationErrors(DeleteTrashErrorSpec));
4638
+ })).pipe(Effect.asVoid, withOperationErrors(DeleteTrashErrorSpec));
4583
4639
  const emptyTrash = () => requestJson(OkResponseSchema, {
4584
4640
  method: "POST",
4585
4641
  path: "/v2/trash/empty"
@@ -5086,6 +5142,7 @@ const ZipInfoSchema = Schema.Union([
5086
5142
  ZipInfoErrorSchema,
5087
5143
  ZipInfoDoneSchema
5088
5144
  ]);
5145
+ const CreateZipInputSchema = makeCursorSelectionSchema("file_ids", "exclude_ids");
5089
5146
  const FilesReadScopeError = {
5090
5147
  errorType: "invalid_scope",
5091
5148
  statusCode: 401
@@ -5147,26 +5204,26 @@ const listZips = () => requestJson(ZipsListEnvelopeSchema, {
5147
5204
  method: "GET",
5148
5205
  path: "/v2/zips/list"
5149
5206
  }).pipe(selectJsonField("zips"), withOperationErrors(ListZipsErrorSpec));
5150
- const createZip = (input) => requestJson(ZipCreateEnvelopeSchema, {
5207
+ const createZip = (input) => decodeAndRun(CreateZipInputSchema, input, (decodedInput) => requestJson(ZipCreateEnvelopeSchema, {
5151
5208
  body: {
5152
5209
  type: "form",
5153
5210
  value: { ...toCursorSelectionForm({
5154
- cursor: input.cursor,
5155
- excludeIds: input.exclude_ids,
5156
- ids: input.file_ids
5211
+ cursor: decodedInput.cursor,
5212
+ excludeIds: decodedInput.exclude_ids,
5213
+ ids: decodedInput.file_ids
5157
5214
  }) }
5158
5215
  },
5159
5216
  method: "POST",
5160
5217
  path: "/v2/zips/create"
5161
- }).pipe(selectJsonField("zip_id"), withOperationErrors(CreateZipErrorSpec));
5162
- const getZip = (id) => requestJson(ZipInfoSchema, {
5218
+ })).pipe(selectJsonField("zip_id"), withOperationErrors(CreateZipErrorSpec));
5219
+ const getZip = (id) => decodeAndRun(PositiveIntegerSchema, id, (decodedId) => requestJson(ZipInfoSchema, {
5163
5220
  method: "GET",
5164
- path: `/v2/zips/${encodePathSegment(id)}`
5165
- }).pipe(withOperationErrors(GetZipErrorSpec));
5166
- const cancelZip = (id) => requestJson(OkResponseSchema, {
5221
+ path: `/v2/zips/${encodePathSegment(decodedId)}`
5222
+ })).pipe(withOperationErrors(GetZipErrorSpec));
5223
+ const cancelZip = (id) => decodeAndRun(PositiveIntegerSchema, id, (decodedId) => requestJson(OkResponseSchema, {
5167
5224
  method: "GET",
5168
- path: `/v2/zips/${encodePathSegment(id)}/cancel`
5169
- }).pipe(Effect.asVoid, withOperationErrors(CancelZipErrorSpec));
5225
+ path: `/v2/zips/${encodePathSegment(decodedId)}/cancel`
5226
+ })).pipe(Effect.asVoid, withOperationErrors(CancelZipErrorSpec));
5170
5227
  //#endregion
5171
5228
  //#region src/core/client.ts
5172
5229
  const promiseClientRuntimeCache = /* @__PURE__ */ new WeakMap();