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

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 +66 -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 +80 -0
  51. package/src/index.ts +50 -0
  52. package/src/pagination.ts +69 -0
  53. package/src/protocol.ts +194 -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,87 @@
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
+
8
+ const S = [
9
+ 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,
10
+ 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,
11
+ 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
12
+ ];
13
+
14
+ const K = [
15
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
16
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
17
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
18
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
19
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
20
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
21
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
22
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
23
+ ];
24
+
25
+ /** Lowercase hex MD5 of the UTF-8 bytes of `input`. */
26
+ export const md5 = (input: string): string => {
27
+ const bytes = new TextEncoder().encode(input);
28
+ const bitLength = bytes.length * 8;
29
+ const padded = new Uint8Array((((bytes.length + 8) >>> 6) + 1) << 6);
30
+ padded.set(bytes);
31
+ padded[bytes.length] = 0x80;
32
+ const view = new DataView(padded.buffer);
33
+ view.setUint32(padded.length - 8, bitLength >>> 0, true);
34
+ view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
35
+
36
+ let a0 = 0x67452301;
37
+ let b0 = 0xefcdab89;
38
+ let c0 = 0x98badcfe;
39
+ let d0 = 0x10325476;
40
+ const M = new Uint32Array(16);
41
+
42
+ for (let chunk = 0; chunk < padded.length; chunk += 64) {
43
+ for (let j = 0; j < 16; j++) M[j] = view.getUint32(chunk + j * 4, true);
44
+ let A = a0;
45
+ let B = b0;
46
+ let C = c0;
47
+ let D = d0;
48
+ for (let i = 0; i < 64; i++) {
49
+ let F: number;
50
+ let g: number;
51
+ if (i < 16) {
52
+ F = (B & C) | (~B & D);
53
+ g = i;
54
+ } else if (i < 32) {
55
+ F = (D & B) | (~D & C);
56
+ g = (5 * i + 1) % 16;
57
+ } else if (i < 48) {
58
+ F = B ^ C ^ D;
59
+ g = (3 * i + 5) % 16;
60
+ } else {
61
+ F = C ^ (B | ~D);
62
+ g = (7 * i) % 16;
63
+ }
64
+ F = (F + A + K[i]! + M[g]!) >>> 0;
65
+ A = D;
66
+ D = C;
67
+ C = B;
68
+ B = (B + ((F << S[i]!) | (F >>> (32 - S[i]!)))) >>> 0;
69
+ }
70
+ a0 = (a0 + A) >>> 0;
71
+ b0 = (b0 + B) >>> 0;
72
+ c0 = (c0 + C) >>> 0;
73
+ d0 = (d0 + D) >>> 0;
74
+ }
75
+
76
+ const out = new DataView(new ArrayBuffer(16));
77
+ out.setUint32(0, a0, true);
78
+ out.setUint32(4, b0, true);
79
+ out.setUint32(8, c0, true);
80
+ out.setUint32(12, d0, true);
81
+ let hex = "";
82
+ for (let i = 0; i < 16; i++) hex += out.getUint8(i).toString(16).padStart(2, "0");
83
+ return hex;
84
+ };
85
+
86
+ /** The `subscriber_hash` path segment for `email`. */
87
+ export const subscriberHash = (email: string): string => md5(email.toLowerCase());
package/src/traits.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Mailchimp SDK trait surface: core's protocol traits re-exported so the
3
+ * generated operations import from one place.
4
+ */
5
+ export {
6
+ Body,
7
+ Header,
8
+ Query,
9
+ Label,
10
+ Http,
11
+ ResponseCode,
12
+ HttpBody,
13
+ FormDataFile,
14
+ KeyDictionary,
15
+ UnionCases,
16
+ applyErrorMatchers,
17
+ getErrorMatchers,
18
+ type HttpTrait,
19
+ type ErrorMatcher,
20
+ bodySymbol,
21
+ headerSymbol,
22
+ querySymbol,
23
+ labelSymbol,
24
+ httpSymbol,
25
+ responseCodeSymbol,
26
+ httpBodySymbol,
27
+ formDataFileSymbol,
28
+ keyDictionarySymbol,
29
+ unionCasesSymbol,
30
+ errorMatchersSymbol,
31
+ } from "@distilled.cloud/core/trait";
32
+
33
+ export {
34
+ SensitiveValue,
35
+ RawResponse,
36
+ RawResponseRoot,
37
+ sensitiveValueSymbol,
38
+ rawResponseSymbol,
39
+ rawResponseRootSymbol,
40
+ } from "@distilled.cloud/core/protocol-rest";