@distilled.cloud/mailchimp 0.0.0 → 1.0.0-rc.19

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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +102 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +59 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +68 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +44 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +10 -0
  16. package/lib/index.lazy.js +10 -0
  17. package/lib/index.lazy.js.map +1 -0
  18. package/lib/pagination.d.ts +11 -0
  19. package/lib/pagination.d.ts.map +1 -0
  20. package/lib/pagination.js +1 -0
  21. package/lib/protocol.d.ts +25 -0
  22. package/lib/protocol.d.ts.map +1 -0
  23. package/lib/protocol.js +1 -0
  24. package/lib/retry.d.ts +53 -0
  25. package/lib/retry.d.ts.map +1 -0
  26. package/lib/retry.js +1 -0
  27. package/lib/services/index.d.ts +3 -0
  28. package/lib/services/index.d.ts.map +1 -0
  29. package/lib/services/index.js +2 -0
  30. package/lib/services/marketing.d.ts +24805 -0
  31. package/lib/services/marketing.d.ts.map +1 -0
  32. package/lib/services/marketing.js +409 -0
  33. package/lib/services/marketing.js.map +1 -0
  34. package/lib/services/transactional.d.ts +3805 -0
  35. package/lib/services/transactional.d.ts.map +1 -0
  36. package/lib/services/transactional.js +143 -0
  37. package/lib/services/transactional.js.map +1 -0
  38. package/lib/services.lazy/index.js +3 -0
  39. package/lib/services.lazy/marketing.js +3 -0
  40. package/lib/services.lazy/transactional.js +4 -0
  41. package/lib/subscriber-hash.d.ts +11 -0
  42. package/lib/subscriber-hash.d.ts.map +1 -0
  43. package/lib/subscriber-hash.js +2 -0
  44. package/lib/subscriber-hash.js.map +1 -0
  45. package/lib/traits.d.ts +7 -0
  46. package/lib/traits.d.ts.map +1 -0
  47. package/lib/traits.js +1 -0
  48. package/package.json +88 -2
  49. package/src/credentials.ts +156 -0
  50. package/src/errors.ts +81 -0
  51. package/src/index.ts +50 -0
  52. package/src/pagination.ts +69 -0
  53. package/src/protocol.ts +196 -0
  54. package/src/retry.ts +72 -0
  55. package/src/services/index.ts +3 -0
  56. package/src/services/marketing.ts +43348 -0
  57. package/src/services/transactional.ts +7512 -0
  58. package/src/subscriber-hash.ts +87 -0
  59. package/src/traits.ts +40 -0
@@ -0,0 +1,3 @@
1
+ import{$L}from"../_bundle/lazy.js";
2
+ const{o:$o,e:$e}=/*@__PURE__*/$L("../services/marketing.js","oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooopppppppoooopopopopoooopoooppopopopopooopopopopooooooopoopopopoooppoopppoppooopoooooopopopoooopooopoopopoooopooooopoooopppooooopoopppppppppoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",202493,29733);
3
+ export const addCartLineItem=$o(),addFeedback=$o(),addListMember=$o(),addListMergeField=$o(),addOrderLineItem=$o(),addProductImage=$o(),addProductVariant=$o(),addProductVariants=$o(),addPromoCode=$o(),addPromoRules=$o(),addStore=$o(),addStoreCart=$o(),addStoreCustomer=$o(),addStoreOrder=$o(),addStoreProduct=$o(),addWorkflowEmailSubscriber=$o(),archiveAutomation=$o(),archiveContact=$o(),batchListMembers=$o(),batchSegmentMembers=$o(),cancelCampaignSend=$o(),cancelSmsCampaignSend=$o(),createAccountExport=$o(),createAudienceContact=$o(),createAutomation=$o(),createBatchWebhook=$o(),createCampaign=$o(),createCampaignFolder=$o(),createConnectedSite=$o(),createEmail=$o(),createFolder=$o(),createInterestCategoryInterest=$o(),createLandingPage=$o(),createList=$o(),createListInterestCategory=$o(),createListMemberEvent=$o(),createListMemberNote=$o(),createListWebhook=$o(),createOrUpdateStoreProduct=$o(),createResend=$o(),createSegment=$o(),createSegmentMember=$o(),createSmsCampaign=$o(),createSurvey=$o(),createTemplate=$o(),createTemplateFolder=$o(),createVerifiedDomain=$o(),deleteBatchWebhook=$o(),deleteCampaign=$o(),deleteCampaignFolder=$o(),deleteCartLineItem=$o(),deleteConnectedSite=$o(),deleteDomain=$o(),deleteFeedbackMessage=$o(),deleteFile=$o(),deleteFolder=$o(),deleteInterestCategory=$o(),deleteInterestCategoryInterest=$o(),deleteList=$o(),deleteListMember=$o(),deleteListMemberNote=$o(),deleteListMemberPermanent=$o(),deleteListMergeField=$o(),deleteListWebhook=$o(),deleteOrder=$o(),deleteOrderLineItem=$o(),deletePage=$o(),deleteProductImage=$o(),deleteProductVariant=$o(),deletePromoCode=$o(),deletePromoRule=$o(),deleteRequest=$o(),deleteSegment=$o(),deleteSmsCampaign=$o(),deleteStore=$o(),deleteStoreCart=$o(),deleteStoreCustomer=$o(),deleteStoreProduct=$o(),deleteSurvey=$o(),deleteTemplate=$o(),deleteTemplateFolder=$o(),deleteWorkflowEmail=$o(),disablePixel=$o(),enablePixel=$o(),forgetContact=$o(),getAccountExports=$o(),getAd=$o(),getAll=$o(),getAllCampaignReports=$o(),getAllCartLineItems=$o(),getAllFacebookAds=$o(),getAllLists=$o(),getAllOrderLineItems=$o(),getAllStoreCustomers=$o(),getAllStoreProducts=$o(),getAllSurveysForList=$o(),getAudienceContactId=$o(),getAudienceId=$o(),getAuthorizedApp=$o(),getAuthorizedApps=$o(),getAutomation=$o(),getAutomations=$o(),getBatch=$o(),getBatches=$o(),getBatchWebhook=$o(),getBatchWebhooks=$o(),getCampaign=$o(),getCampaignAbuseReport=$o(),getCampaignAbuseReports=$o(),getCampaignAdvice=$o(),getCampaignClickDetails=$o(),getCampaignClickDetailsForLink=$o(),getCampaignContent=$o(),getCampaignFolder=$o(),getCampaignFolders=$o(),getCampaignOpenDetails=$o(),getCampaignRecipient=$o(),getCampaignRecipients=$o(),getCampaignReport=$o(),getCampaigns=$o(),getCartLineItem=$o(),getChimpChatter=$o(),getConnectedSite=$o(),getConnectedSites=$o(),getDefaultContentForTemplate=$o(),getDomain=$o(),getDomainPerformanceForCampaign=$o(),getEcommerceProductActivityForCampaign=$o(),getEepurlActivityForCampaign=$o(),getEmailActivityForCampaign=$o(),getEmailActivityForSubscriber=$o(),getFacebookAdProductActivityReport=$o(),getFacebookAdReport=$o(),getFacebookAdsReportAll=$o(),getFeedback=$o(),getFeedbackMessage=$o(),getFile=$o(),getFolder=$o(),getInterestCategory=$o(),getInterestCategoryInterest=$o(),getLandingPageReport=$o(),getLandingPageReportsAll=$o(),getList=$o(),getListAbuseReportDetails=$o(),getListAbuseReports=$o(),getListClients=$o(),getListGrowthHistory=$o(),getListGrowthHistoryByMonth=$o(),getListInterestCategories=$o(),getListLocations=$o(),getListMember=$o(),getListMemberActivity=$o(),getListMemberActivityFeed=$o(),getListMemberEvents=$o(),getListMemberGoals=$o(),getListMemberNote=$o(),getListMemberNotes=$o(),getListMembersInfo=$o(),getListMemberTags=$o(),getListMergeField=$o(),getListMergeFields=$o(),getListRecentActivity=$o(),getListSignupForms=$o(),getListWebhook=$o(),getListWebhooks=$o(),getLocationsForCampaign=$o(),getOrder=$o(),getOrderLineItem=$o(),getPage=$o(),getPageContent=$o(),getPing=$o(),getProductImage=$o(),getProductImages=$o(),getProductVariant=$o(),getProductVariants=$o(),getPromoCode=$o(),getPromoCodes=$o(),getPromoRule=$o(),getRemovedWorkflowEmailSubscriber=$o(),getRoot=$o(),getSegment=$o(),getSegmentMembersList=$o(),getSendChecklist=$o(),getSmsCampaign=$o(),getSmsCampaignContent=$o(),getSmsCampaigns=$o(),getStore=$o(),getStoreCart=$o(),getStoreCarts=$o(),getStoreCustomer=$o(),getStoreOrders=$o(),getStoreProduct=$o(),getSubReportsForCampaign=$o(),getSubscriberInfo=$o(),getSubscriberInfoForOpenedCampaign=$o(),getSubscribersInfo=$o(),getSurvey=$o(),getSurveyQuestionAnswers=$o(),getSurveyQuestionReport=$o(),getSurveyQuestionReportsAll=$o(),getSurveyReport=$o(),getSurveyReportsAll=$o(),getSurveyResponse=$o(),getSurveyResponsesAll=$o(),getTemplate=$o(),getTemplateFolder=$o(),getTemplateFolders=$o(),getTemplates=$o(),getUnsubscribedListForCampaign=$o(),getUnsubscribedListMember=$o(),getVerifiedDomainsAll=$o(),getWorkflowEmail=$o(),getWorkflowEmailSubscriber=$o(),getWorkflowEmailSubscriberQueue=$o(),listAccountExports=$o(),listAllWorkflowEmails=$o(),listAudienceContactList=$o(),listAudiences=$o(),listFiles=$o(),listFolderFiles=$o(),listFolders=$o(),listInterestCategoryInterests=$o(),listOrders=$o(),listPromoRules=$o(),listSegments=$o(),listStores=$o(),listWorkflowEmailSubscribersRemoved=$o(),patchAudienceContact=$o(),pauseAllEmails=$o(),pauseCampaign=$o(),pauseWorkflowEmail=$o(),publishPage=$o(),publishSurvey=$o(),removeSegmentMember=$o(),removeWorkflowEmailSubscriber=$o(),replicateCampaign=$o(),replicateSurvey=$o(),resumeCampaign=$o(),scheduleCampaign=$o(),scheduleSmsCampaign=$o(),searchCampaigns=$o(),searchMembers=$o(),sendCampaign=$o(),sendSmsCampaign=$o(),sendTestEmail=$o(),setCampaignContent=$o(),setListMember=$o(),setOrder=$o(),setSmsCampaignContent=$o(),setStoreCustomer=$o(),startAllEmails=$o(),startBatch=$o(),startWorkflowEmail=$o(),submitDomainVerification=$o(),tagSearch=$o(),triggerCustomerJourneyStep=$o(),unpublishPage=$o(),unpublishSurvey=$o(),unscheduleCampaign=$o(),updateBatchWebhook=$o(),updateCampaign=$o(),updateCampaignFolder=$o(),updateCartLineItem=$o(),updateFeedbackMessage=$o(),updateFile=$o(),updateFolder=$o(),updateInterestCategory=$o(),updateInterestCategoryInterest=$o(),updateList=$o(),updateListMember=$o(),updateListMemberNote=$o(),updateListMemberTags=$o(),updateListMergeField=$o(),updateListSignupForm=$o(),updateListWebhook=$o(),updateOrder=$o(),updateOrderLineItem=$o(),updatePage=$o(),updateProductImage=$o(),updateProductVariant=$o(),updatePromoCode=$o(),updatePromoRule=$o(),updateSegment=$o(),updateSmsCampaign=$o(),updateStore=$o(),updateStoreCart=$o(),updateStoreCustomer=$o(),updateStoreProduct=$o(),updateSurvey=$o(),updateTemplate=$o(),updateTemplateFolder=$o(),updateWorkflowEmail=$o(),uploadFile=$o(),verifyScriptInstallation=$o();
@@ -0,0 +1,4 @@
1
+ import{$L}from"../_bundle/lazy.js";
2
+ const{o:$o,e:$e,E:$E}=/*@__PURE__*/$L("../services/transactional.js","ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",45567,8996);
3
+ export const{BadRequest,Forbidden,NotFound,PaymentRequired,UnprocessableEntity}=$E;
4
+ export const addAllowlistEntry=$o(),addInboundDomain=$o(),addInboundRoute=$o(),addMetadataField=$o(),addReject=$o(),addSenderDomain=$o(),addSmsReject=$o(),addSubaccount=$o(),addTemplate=$o(),addTrackingDomain=$o(),addWebhook=$o(),cancelIpWarmup=$o(),cancelScheduledMessage=$o(),checkInboundDomain=$o(),checkIpCustomDns=$o(),checkSenderDomain=$o(),checkTrackingDomain=$o(),createIpPool=$o(),deleteAllowlistEntry=$o(),deleteInboundDomain=$o(),deleteInboundRoute=$o(),deleteIp=$o(),deleteIpPool=$o(),deleteMetadataField=$o(),deleteReject=$o(),deleteSenderDomain=$o(),deleteSmsReject=$o(),deleteSubaccount=$o(),deleteTag=$o(),deleteTemplate=$o(),deleteTrackingDomain=$o(),deleteWebhook=$o(),exportActivity=$o(),exportAllowlist=$o(),exportRejects=$o(),exportWhitelist=$o(),getAllTagsTimeSeries=$o(),getExport=$o(),getIp=$o(),getIpPool=$o(),getMcTemplate=$o(),getMcTemplateTimeSeries=$o(),getMessage=$o(),getMessageContent=$o(),getSender=$o(),getSenderTimeSeries=$o(),getSubaccount=$o(),getTag=$o(),getTagTimeSeries=$o(),getTemplate=$o(),getTemplateTimeSeries=$o(),getUser=$o(),getWebhook=$o(),listAllowlistEntries=$o(),listExports=$o(),listInboundDomains=$o(),listInboundRoutes=$o(),listIpPools=$o(),listIps=$o(),listMcTemplates=$o(),listMetadataFields=$o(),listRejects=$o(),listScheduledMessages=$o(),listSenderDomains=$o(),listSenders=$o(),listSmsRejects=$o(),listSubaccounts=$o(),listTags=$o(),listTemplates=$o(),listTrackingDomains=$o(),listUserSenders=$o(),listWebhooks=$o(),parseMessage=$o(),pauseSubaccount=$o(),ping=$o(),ping2=$o(),provisionIp=$o(),publishTemplate=$o(),renderMcTemplate=$o(),renderTemplate=$o(),rescheduleMessage=$o(),resumeSubaccount=$o(),searchMessages=$o(),searchMessagesTimeSeries=$o(),sendMcTemplate=$o(),sendMessage=$o(),sendRawInbound=$o(),sendRawMessage=$o(),sendSms=$o(),sendTemplate=$o(),setIpCustomDns=$o(),setIpPool=$o(),startIpWarmup=$o(),updateInboundRoute=$o(),updateMetadataField=$o(),updateSubaccount=$o(),updateTemplate=$o(),updateWebhook=$o(),verifySenderDomain=$o();
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Mailchimp addresses a list member by the MD5 of their lowercased email.
3
+ *
4
+ * Pure TypeScript because Web Crypto has no MD5, and this has to run in a
5
+ * Cloudflare Worker without `node:crypto`.
6
+ */
7
+ /** Lowercase hex MD5 of the UTF-8 bytes of `input`. */
8
+ export declare const md5: (input: string) => string;
9
+ /** The `subscriber_hash` path segment for `email`. */
10
+ export declare const subscriberHash: (email: string) => string;
11
+ //# sourceMappingURL=subscriber-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber-hash.d.ts","sourceRoot":"","sources":["../src/subscriber-hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,uDAAuD;AACvD,eAAO,MAAM,GAAG,UAAW,MAAM,KAAG,MA0DnC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,MAAkC,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21];const t=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745];const md5=n=>{const r=new TextEncoder().encode(n);const i=r.length*8;const a=new Uint8Array((r.length+8>>>6)+1<<6);a.set(r);a[r.length]=128;const o=new DataView(a.buffer);o.setUint32(a.length-8,i>>>0,true);o.setUint32(a.length-4,Math.floor(i/2**32),true);let s=1732584193;let c=4023233417;let l=2562383102;let u=271733878;const d=/* @__PURE__ */ new Uint32Array(16);for(let n=0;n<a.length;n+=64){for(let e=0;e<16;e++)d[e]=o.getUint32(n+e*4,true);let r=s;let i=c;let a=l;let f=u;for(let n=0;n<64;n++){let o;let s;if(n<16){o=i&a|~i&f;s=n}else if(n<32){o=f&i|~f&a;s=(5*n+1)%16}else if(n<48){o=i^a^f;s=(3*n+5)%16}else{o=a^(i|~f);s=7*n%16}o=o+r+t[n]+d[s]>>>0;r=f;f=a;a=i;i=i+(o<<e[n]|o>>>32-e[n])>>>0}s=s+r>>>0;c=c+i>>>0;l=l+a>>>0;u=u+f>>>0}const f=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(16));f.setUint32(0,s,true);f.setUint32(4,c,true);f.setUint32(8,l,true);f.setUint32(12,u,true);let p=``;for(let e=0;e<16;e++)p+=f.getUint8(e).toString(16).padStart(2,`0`);return p};const subscriberHash=e=>md5(e.toLowerCase());export{md5,subscriberHash};
2
+ //# sourceMappingURL=subscriber-hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber-hash.js","names":["S","K","bytes","input","bitLength","padded","view","a0","b0","c0","d0","M","chunk","j","A","B","C","D","i","F","g","out","hex","email"],"sources":["../src/subscriber-hash.ts"],"mappings":"AAOA,MAAMA,EAAI,CACR,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,EAAG,GAAI,GAAI,EAAG,EAAG,GAAI,GAAI,EAAG,EAAG,GAC9F,GAAI,EAAG,EAAG,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAC7F,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,GAAI,EAAG,GAAI,GAAI,EACxC,EAEA,MAAMC,EAAI,CACR,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,SAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,SAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,UAAY,UACtF,EAGA,MAAa,IAAO,GAA0B,CAC5C,MAAMC,EAAQ,IAAI,YAAY,CAAC,CAAC,OAAOC,CAAK,EAC5C,MAAMC,EAAYF,EAAM,OAAS,EACjC,MAAMG,EAAS,IAAI,YAAcH,EAAM,OAAS,IAAO,GAAK,GAAM,CAAC,EACnEG,EAAO,IAAIH,CAAK,EAChB,EAAOA,EAAM,QAAU,IACvB,MAAMI,EAAO,IAAI,SAASD,EAAO,MAAM,EACvCC,EAAK,UAAUD,EAAO,OAAS,EAAGD,IAAc,EAAG,IAAI,EACvDE,EAAK,UAAUD,EAAO,OAAS,EAAG,KAAK,MAAMD,EAAY,GAAK,EAAE,EAAG,IAAI,EAEvE,IAAIG,EAAK,WACT,IAAIC,EAAK,WACT,IAAIC,EAAK,WACT,IAAIC,EAAK,UACT,MAAMC,kBAAI,IAAI,YAAY,EAAE,EAE5B,IAAK,IAAIC,EAAQ,EAAGA,EAAQP,EAAO,OAAQ,GAAS,GAAI,CACtD,IAAK,IAAIQ,EAAI,EAAGA,EAAI,GAAI,IAAK,EAAEA,GAAKP,EAAK,UAAUM,EAAQC,EAAI,EAAG,IAAI,EACtE,IAAIC,EAAIP,EACR,IAAIQ,EAAIP,EACR,IAAIQ,EAAIP,EACR,IAAIQ,EAAIP,EACR,IAAK,IAAIQ,EAAI,EAAGA,EAAI,GAAI,IAAK,CAC3B,IAAIC,EACJ,IAAIC,EACJ,GAAIF,EAAI,GAAI,CACV,EAAKH,EAAIC,EAAM,CAACD,EAAIE,EACpB,EAAIC,CACN,MAAO,GAAIA,EAAI,GAAI,CACjB,EAAKD,EAAIF,EAAM,CAACE,EAAID,EACpB,GAAK,EAAIE,EAAI,GAAK,EACpB,MAAO,GAAIA,EAAI,GAAI,CACjB,EAAIH,EAAIC,EAAIC,EACZ,GAAK,EAAIC,EAAI,GAAK,EACpB,KAAO,CACL,EAAIF,GAAKD,EAAI,CAACE,GACd,EAAK,EAAIC,EAAK,EAChB,CACA,EAAKC,EAAIL,EAAIb,EAAEiB,GAAMP,EAAES,KAAS,EAChC,EAAIH,EACJ,EAAID,EACJ,EAAID,EACJ,EAAKA,GAAMI,GAAKnB,EAAEkB,GAAQC,IAAO,GAAKnB,EAAEkB,MAAY,CACtD,CACA,EAAMX,EAAKO,IAAO,EAClB,EAAMN,EAAKO,IAAO,EAClB,EAAMN,EAAKO,IAAO,EAClB,EAAMN,EAAKO,IAAO,CACpB,CAEA,MAAMI,kBAAM,IAAI,yBAAS,IAAI,YAAY,EAAE,CAAC,EAC5CA,EAAI,UAAU,EAAGd,EAAI,IAAI,EACzBc,EAAI,UAAU,EAAGb,EAAI,IAAI,EACzBa,EAAI,UAAU,EAAGZ,EAAI,IAAI,EACzBY,EAAI,UAAU,GAAIX,EAAI,IAAI,EAC1B,IAAIY,EAAM,GACV,IAAK,IAAIJ,EAAI,EAAGA,EAAI,GAAI,IAAK,GAAOG,EAAI,SAASH,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAG,GAAG,EAChF,OAAOI,CACT,EAGA,MAAa,eAAkB,GAA0B,IAAIC,EAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Mailchimp SDK trait surface: core's protocol traits re-exported so the
3
+ * generated operations import from one place.
4
+ */
5
+ export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, type HttpTrait, type ErrorMatcher, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
6
+ export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
7
+ //# sourceMappingURL=traits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC"}
package/lib/traits.js ADDED
@@ -0,0 +1 @@
1
+ export { traits$Body as Body, traits$FormDataFile as FormDataFile, traits$Header as Header, traits$Http as Http, traits$HttpBody as HttpBody, traits$KeyDictionary as KeyDictionary, traits$Label as Label, traits$Query as Query, traits$RawResponse as RawResponse, traits$RawResponseRoot as RawResponseRoot, traits$ResponseCode as ResponseCode, traits$SensitiveValue as SensitiveValue, traits$UnionCases as UnionCases, traits$applyErrorMatchers as applyErrorMatchers, traits$bodySymbol as bodySymbol, traits$errorMatchersSymbol as errorMatchersSymbol, traits$formDataFileSymbol as formDataFileSymbol, traits$getErrorMatchers as getErrorMatchers, traits$headerSymbol as headerSymbol, traits$httpBodySymbol as httpBodySymbol, traits$httpSymbol as httpSymbol, traits$keyDictionarySymbol as keyDictionarySymbol, traits$labelSymbol as labelSymbol, traits$querySymbol as querySymbol, traits$rawResponseRootSymbol as rawResponseRootSymbol, traits$rawResponseSymbol as rawResponseSymbol, traits$responseCodeSymbol as responseCodeSymbol, traits$sensitiveValueSymbol as sensitiveValueSymbol, traits$unionCasesSymbol as unionCasesSymbol } from "./_bundle/sdk.js";
package/package.json CHANGED
@@ -1,10 +1,96 @@
1
1
  {
2
2
  "name": "@distilled.cloud/mailchimp",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-rc.19",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/alchemy-run/distilled",
8
8
  "directory": "packages/mailchimp"
9
+ },
10
+ "files": [
11
+ "lib",
12
+ "src"
13
+ ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "module": "src/index.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./lib/index.d.ts",
20
+ "bun": "./src/index.ts",
21
+ "worker": "./src/index.ts",
22
+ "distilled-lazy": "./lib/index.lazy.js",
23
+ "default": "./lib/index.js"
24
+ },
25
+ "./Credentials": {
26
+ "types": "./lib/credentials.d.ts",
27
+ "bun": "./src/credentials.ts",
28
+ "worker": "./src/credentials.ts",
29
+ "default": "./lib/credentials.js"
30
+ },
31
+ "./Errors": {
32
+ "types": "./lib/errors.d.ts",
33
+ "bun": "./src/errors.ts",
34
+ "worker": "./src/errors.ts",
35
+ "default": "./lib/errors.js"
36
+ },
37
+ "./Traits": {
38
+ "types": "./lib/traits.d.ts",
39
+ "bun": "./src/traits.ts",
40
+ "worker": "./src/traits.ts",
41
+ "default": "./lib/traits.js"
42
+ },
43
+ "./Pagination": {
44
+ "types": "./lib/pagination.d.ts",
45
+ "bun": "./src/pagination.ts",
46
+ "worker": "./src/pagination.ts",
47
+ "default": "./lib/pagination.js"
48
+ },
49
+ "./Protocol": {
50
+ "types": "./lib/protocol.d.ts",
51
+ "bun": "./src/protocol.ts",
52
+ "worker": "./src/protocol.ts",
53
+ "default": "./lib/protocol.js"
54
+ },
55
+ "./Retry": {
56
+ "types": "./lib/retry.d.ts",
57
+ "bun": "./src/retry.ts",
58
+ "worker": "./src/retry.ts",
59
+ "default": "./lib/retry.js"
60
+ },
61
+ "./SubscriberHash": {
62
+ "types": "./lib/subscriber-hash.d.ts",
63
+ "bun": "./src/subscriber-hash.ts",
64
+ "worker": "./src/subscriber-hash.ts",
65
+ "default": "./lib/subscriber-hash.js"
66
+ },
67
+ "./*": {
68
+ "types": "./lib/services/*.d.ts",
69
+ "bun": "./src/services/*.ts",
70
+ "worker": "./src/services/*.ts",
71
+ "distilled-lazy": "./lib/services.lazy/*.js",
72
+ "default": "./lib/services/*.js"
73
+ }
74
+ },
75
+ "dependencies": {
76
+ "@distilled.cloud/core": "1.0.0-rc.19"
77
+ },
78
+ "devDependencies": {
79
+ "@distilled.cloud/dev": "0.0.0",
80
+ "@types/node": "26.6.5"
81
+ },
82
+ "peerDependencies": {
83
+ "effect": "^4.1.2"
84
+ },
85
+ "distilled": {
86
+ "generatedAt": "2026-11-11"
87
+ },
88
+ "scripts": {
89
+ "build": "tsrs -b",
90
+ "convert": "node --conditions=bun scripts/convert.ts",
91
+ "generate": "node --conditions=bun scripts/generate.ts",
92
+ "typecheck": "tsrs -p tsconfig.json",
93
+ "specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-mailchimp",
94
+ "specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-mailchimp"
9
95
  }
10
- }
96
+ }
@@ -0,0 +1,156 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
2
+ /**
3
+ * Mailchimp credentials -- hand-written.
4
+ *
5
+ * One secret, the account's API key, sent as HTTP basic auth with any
6
+ * username. The key also names the account's data centre: `abc123-us21`
7
+ * lives at `https://us21.api.mailchimp.com/3.0`. The document's
8
+ * `server.api.mailchimp.com` host is a placeholder, not an origin.
9
+ *
10
+ * Following the core convention the `Credentials` service holds an *effect*
11
+ * resolving the current config, which the protocol layer runs per request on
12
+ * the calling fiber.
13
+ */
14
+ import * as EffectConfig from "effect/Config";
15
+ import * as Context from "effect/Context";
16
+ import * as Effect from "effect/Effect";
17
+ import * as Layer from "effect/Layer";
18
+ import * as Option from "effect/Option";
19
+ import * as Redacted from "effect/Redacted";
20
+
21
+ export interface Config {
22
+ readonly apiKey: Redacted.Redacted<string>;
23
+ /** Origin including the `/3.0` version segment. */
24
+ readonly apiBaseUrl: string;
25
+ }
26
+
27
+ export class Credentials
28
+ extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config, ConfigError>>()(
29
+ "MailchimpCredentials",
30
+ ) {}
31
+
32
+ /** The data-centre suffix of an API key (`abc123-us21` -> `us21`). */
33
+ export const serverPrefixFromApiKey = (apiKey: string): string | undefined => {
34
+ const dash = apiKey.lastIndexOf("-");
35
+ if (dash < 0) return undefined;
36
+ const dc = apiKey.slice(dash + 1);
37
+ return /^[a-z]+[0-9]+$/i.test(dc) ? dc.toLowerCase() : undefined;
38
+ };
39
+
40
+ export const apiBaseUrlFor = (serverPrefix: string): string =>
41
+ `https://${serverPrefix}.api.mailchimp.com/3.0`;
42
+
43
+ const trimSlash = (url: string): string => url.replace(/\/+$/, "");
44
+
45
+ const resolve = (config: {
46
+ readonly apiKey: string | Redacted.Redacted<string>;
47
+ readonly serverPrefix?: string | undefined;
48
+ readonly apiBaseUrl?: string | undefined;
49
+ }): Effect.Effect<Config, ConfigError> => {
50
+ const apiKey = Redacted.isRedacted(config.apiKey) ? config.apiKey : Redacted.make(config.apiKey);
51
+ if (config.apiBaseUrl !== undefined) {
52
+ return Effect.succeed({ apiKey, apiBaseUrl: trimSlash(config.apiBaseUrl) });
53
+ }
54
+ const server = config.serverPrefix ?? serverPrefixFromApiKey(Redacted.value(apiKey));
55
+ if (server === undefined) {
56
+ return Effect.fail(
57
+ new ConfigError({
58
+ message:
59
+ "Mailchimp API key has no data-centre suffix (expected `<key>-<dc>`, e.g. `...-us21`); pass serverPrefix",
60
+ }),
61
+ );
62
+ }
63
+ return Effect.succeed({ apiKey, apiBaseUrl: apiBaseUrlFor(server) });
64
+ };
65
+
66
+ /**
67
+ * Layer from an API key. The data centre comes from the key's suffix unless
68
+ * `serverPrefix` (e.g. `"us21"`) or a full `apiBaseUrl` is given.
69
+ */
70
+ export const fromApiKey = (config: {
71
+ readonly apiKey: string | Redacted.Redacted<string>;
72
+ readonly serverPrefix?: string;
73
+ readonly apiBaseUrl?: string;
74
+ }): Layer.Layer<Credentials> => Layer.succeed(Credentials, resolve(config));
75
+
76
+ /**
77
+ * Reads `MAILCHIMP_API_KEY` (required) and the optional
78
+ * `MAILCHIMP_SERVER_PREFIX` through Effect `Config`, so it follows whatever
79
+ * `ConfigProvider` is installed -- in a Worker, one built from `env`.
80
+ */
81
+ export const CredentialsFromEnv: Layer.Layer<Credentials> = /*@__PURE__*/ Layer.succeed(
82
+ Credentials,
83
+ Effect.gen(function* () {
84
+ const apiKey = yield* EffectConfig.Redacted("MAILCHIMP_API_KEY");
85
+ const serverPrefix = yield* EffectConfig.option(EffectConfig.String("MAILCHIMP_SERVER_PREFIX"));
86
+ return { apiKey, serverPrefix: Option.getOrUndefined(serverPrefix) };
87
+ }).pipe(
88
+ Effect.mapError(
89
+ (e) =>
90
+ new ConfigError({
91
+ message: `Mailchimp credentials require MAILCHIMP_API_KEY: ${e.message}`,
92
+ }),
93
+ ),
94
+ Effect.flatMap(resolve),
95
+ ),
96
+ );
97
+
98
+ // ------------- Transactional -------------
99
+
100
+ /**
101
+ * The document's `basePath` is `/api/1.3`; Mailchimp's own clients and docs
102
+ * call `/api/1.0`, and the versions answer identically.
103
+ */
104
+ export const DEFAULT_TRANSACTIONAL_API_BASE_URL = "https://mandrillapp.com/api/1.0";
105
+
106
+ export interface TransactionalConfig {
107
+ readonly apiKey: Redacted.Redacted<string>;
108
+ readonly apiBaseUrl: string;
109
+ }
110
+
111
+ /**
112
+ * The Transactional API (formerly Mandrill) has its own key, issued in the
113
+ * Transactional app, so it is a separate service from {@link Credentials}.
114
+ */
115
+ export class TransactionalCredentials
116
+ extends /*@__PURE__*/ Context.Service<
117
+ TransactionalCredentials,
118
+ Effect.Effect<TransactionalConfig, ConfigError>
119
+ >()("MailchimpTransactionalCredentials") {}
120
+
121
+ const resolveTransactional = (config: {
122
+ readonly apiKey: string | Redacted.Redacted<string>;
123
+ readonly apiBaseUrl?: string | undefined;
124
+ }): TransactionalConfig => ({
125
+ apiKey: Redacted.isRedacted(config.apiKey) ? config.apiKey : Redacted.make(config.apiKey),
126
+ apiBaseUrl: trimSlash(config.apiBaseUrl ?? DEFAULT_TRANSACTIONAL_API_BASE_URL),
127
+ });
128
+
129
+ /** Layer from a Transactional API key. */
130
+ export const fromTransactionalApiKey = (config: {
131
+ readonly apiKey: string | Redacted.Redacted<string>;
132
+ readonly apiBaseUrl?: string;
133
+ }): Layer.Layer<TransactionalCredentials> =>
134
+ Layer.succeed(TransactionalCredentials, Effect.succeed(resolveTransactional(config)));
135
+
136
+ /**
137
+ * Reads `MAILCHIMP_TRANSACTIONAL_API_KEY` (or the older `MANDRILL_API_KEY`)
138
+ * through Effect `Config`.
139
+ */
140
+ export const TransactionalCredentialsFromEnv: Layer.Layer<TransactionalCredentials> =
141
+ /*@__PURE__*/ Layer.succeed(
142
+ TransactionalCredentials,
143
+ Effect.gen(function* () {
144
+ const apiKey = yield* EffectConfig.Redacted("MAILCHIMP_TRANSACTIONAL_API_KEY").pipe(
145
+ EffectConfig.orElse(() => EffectConfig.Redacted("MANDRILL_API_KEY")),
146
+ );
147
+ return resolveTransactional({ apiKey });
148
+ }).pipe(
149
+ Effect.mapError(
150
+ (e) =>
151
+ new ConfigError({
152
+ message: `Mailchimp Transactional credentials require MAILCHIMP_TRANSACTIONAL_API_KEY: ${e.message}`,
153
+ }),
154
+ ),
155
+ ),
156
+ );
package/src/errors.ts ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Mailchimp error types.
3
+ *
4
+ * Failures arrive as RFC 7807 problem documents
5
+ * (`{ type, title, status, detail, instance }`) and map by status onto the
6
+ * core classes re-exported here: `NotFound`, `BadRequest`, `Unauthorized`,
7
+ * `Forbidden`, `TooManyRequests` and the 5xx family, the last two retryable.
8
+ */
9
+ export {
10
+ BadGateway,
11
+ BadRequest,
12
+ Conflict,
13
+ ConfigError,
14
+ Forbidden,
15
+ GatewayTimeout,
16
+ InternalServerError,
17
+ Locked,
18
+ NotFound,
19
+ ServiceUnavailable,
20
+ TooManyRequests,
21
+ Unauthorized,
22
+ UnprocessableEntity,
23
+ HTTP_STATUS_MAP,
24
+ DEFAULT_ERRORS,
25
+ API_ERRORS,
26
+ } from "@distilled.cloud/core/errors";
27
+ export type { DefaultErrors } from "@distilled.cloud/core/errors";
28
+
29
+ import * as Category from "@distilled.cloud/core/category";
30
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
31
+
32
+ const ProblemFields = {
33
+ status: Schema.Number,
34
+ /** Problem type URI, e.g. `https://mailchimp.com/developer/marketing/docs/errors/`. */
35
+ type: /*@__PURE__*/ Schema.optional(Schema.String),
36
+ title: /*@__PURE__*/ Schema.optional(Schema.String),
37
+ message: /*@__PURE__*/ Schema.optional(Schema.String),
38
+ instance: /*@__PURE__*/ Schema.optional(Schema.String),
39
+ body: Schema.Unknown,
40
+ };
41
+
42
+ /**
43
+ * A problem document on a status the core map does not cover (405, 414, ...).
44
+ * Not categorised as a server error: those retry, and these never succeed.
45
+ */
46
+ export class MailchimpApiError
47
+ extends /*@__PURE__*/ Schema.TaggedError<MailchimpApiError>()(
48
+ "MailchimpApiError",
49
+ ProblemFields,
50
+ ) {}
51
+
52
+ /** A failure that is not a problem document at all. */
53
+ export class UnknownMailchimpError
54
+ extends /*@__PURE__*/ Schema.TaggedError<UnknownMailchimpError>()(
55
+ "UnknownMailchimpError",
56
+ ProblemFields,
57
+ ).pipe(Category.withServerError) {}
58
+
59
+ /** A 2xx response that does not match the operation's output schema. */
60
+ export class MailchimpParseError
61
+ extends /*@__PURE__*/ Schema.TaggedError<MailchimpParseError>()("MailchimpParseError", {
62
+ body: Schema.Unknown,
63
+ cause: Schema.Unknown,
64
+ }).pipe(Category.withParseError) {}
65
+
66
+ /**
67
+ * A Transactional API failure (`{ status: "error", code, name, message }`)
68
+ * on a status that neither the operation nor the core map covers. `name` is
69
+ * the vendor's discriminator (`Invalid_Key`, `Unknown_Template`).
70
+ */
71
+ export class MailchimpTransactionalError
72
+ extends /*@__PURE__*/ Schema.TaggedError<MailchimpTransactionalError>()(
73
+ "MailchimpTransactionalError",
74
+ {
75
+ status: Schema.Number,
76
+ code: /*@__PURE__*/ Schema.optional(Schema.Number),
77
+ name: /*@__PURE__*/ Schema.optional(Schema.String),
78
+ message: Schema.String,
79
+ body: Schema.Unknown,
80
+ },
81
+ ) {}
package/src/index.ts ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @distilled.cloud/mailchimp -- Mailchimp Marketing and Transactional API SDK
3
+ * for Effect.
4
+ *
5
+ * `./services` is generated by `scripts/generate.ts`; everything else in this
6
+ * folder is hand-written. Marketing operations are exported flat; the
7
+ * Transactional API (formerly Mandrill) is under `Transactional`, with its
8
+ * own key.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import * as Effect from "effect/Effect";
13
+ * import * as FetchHttpClient from "effect/http/FetchHttpClient";
14
+ * import * as Mailchimp from "@distilled.cloud/mailchimp";
15
+ *
16
+ * const program = Mailchimp.setListMember({
17
+ * list_id: "a1b2c3d4e5",
18
+ * subscriber_hash: Mailchimp.subscriberHash("ada@example.com"),
19
+ * email_address: "ada@example.com",
20
+ * status_if_new: "subscribed",
21
+ * }).pipe(
22
+ * Effect.provide(Mailchimp.fromApiKey({ apiKey: "...-us21" })),
23
+ * Effect.provide(FetchHttpClient.layer),
24
+ * );
25
+ *
26
+ * const send = Mailchimp.Transactional.sendMessage({
27
+ * message: { to: [{ email: "ada@example.com" }], subject: "Hi", text: "..." },
28
+ * }).pipe(
29
+ * Effect.provide(Mailchimp.fromTransactionalApiKey({ apiKey: "md-..." })),
30
+ * Effect.provide(FetchHttpClient.layer),
31
+ * );
32
+ * ```
33
+ */
34
+ export * from "./credentials.ts";
35
+ export * as T from "./traits.ts";
36
+ export * as Retry from "./retry.ts";
37
+ export {
38
+ MailchimpProtocol,
39
+ MailchimpTransactionalProtocol,
40
+ type MailchimpOpError,
41
+ type MailchimpOpContext,
42
+ type MailchimpTransactionalOpError,
43
+ type MailchimpTransactionalOpContext,
44
+ } from "./protocol.ts";
45
+ export * from "./errors.ts";
46
+ export { paginateOffset } from "./pagination.ts";
47
+ export { md5, subscriberHash } from "./subscriber-hash.ts";
48
+ export * as Services from "./services/index.ts";
49
+ export * from "./services/marketing.ts";
50
+ export * as Transactional from "./services/transactional.ts";
@@ -0,0 +1,69 @@
1
+ import {
2
+ getPath,
3
+ type PaginatedTrait,
4
+ type PaginationStrategy,
5
+ } from "@distilled.cloud/core/pagination";
6
+ /**
7
+ * Mailchimp pagination -- hand-written.
8
+ *
9
+ * Collections take `count` (default 10, max 1000) and `offset` and answer
10
+ * `{ <collection>: [...], total_items }`, the collection named after the
11
+ * resource. Nothing in the response points at the next page, so the traversal
12
+ * advances `offset` by what it received.
13
+ */
14
+ import * as Effect from "effect/Effect";
15
+ import * as Stream from "effect/Stream";
16
+
17
+ export { getItems } from "@distilled.cloud/core/pagination";
18
+
19
+ const toNumber = (v: unknown): number | undefined =>
20
+ typeof v === "number" && Number.isFinite(v) ? v : undefined;
21
+
22
+ /**
23
+ * Stream of pages using `offset`/`count`.
24
+ *
25
+ * Stops on whichever comes first: `offset` reaching `total_items`, an empty
26
+ * page, or a page shorter than the requested `count` (the only end marker on
27
+ * operations that report no total).
28
+ */
29
+ export const paginateOffset: PaginationStrategy = <
30
+ Input extends Record<string, unknown>,
31
+ Output,
32
+ E,
33
+ R,
34
+ >(
35
+ operation: (input: Input) => Effect.Effect<Output, E, R>,
36
+ input: Input,
37
+ pagination: PaginatedTrait,
38
+ ): Stream.Stream<Output, E, R> => {
39
+ const offsetKey = pagination.inputToken ?? "offset";
40
+ const countKey = pagination.pageSize ?? "count";
41
+ const requested = toNumber(input[countKey]);
42
+
43
+ type State = { offset: number; done: boolean };
44
+
45
+ return Stream.unfold({ offset: toNumber(input[offsetKey]) ?? 0, done: false } as State, (state) =>
46
+ Effect.gen(function* () {
47
+ if (state.done) return undefined;
48
+
49
+ const response = yield* operation({
50
+ ...input,
51
+ [offsetKey]: state.offset,
52
+ } as Input);
53
+
54
+ const total = pagination.outputToken
55
+ ? toNumber(getPath(response, pagination.outputToken))
56
+ : undefined;
57
+ const items = pagination.items ? getPath(response, pagination.items) : undefined;
58
+ const received = Array.isArray(items) ? items.length : 0;
59
+ const next = state.offset + received;
60
+
61
+ const done =
62
+ received === 0 ||
63
+ (total !== undefined && next >= total) ||
64
+ (requested !== undefined && received < requested);
65
+
66
+ return [response, { offset: next, done }] as const;
67
+ }),
68
+ );
69
+ };