@takeal/cusfront-sdk 0.3.20 → 0.5.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +407 -8
  3. package/dist/analytics.cjs +417 -0
  4. package/dist/analytics.cjs.map +1 -0
  5. package/dist/analytics.d.cts +129 -0
  6. package/dist/analytics.d.ts +129 -0
  7. package/dist/analytics.js +403 -0
  8. package/dist/analytics.js.map +1 -0
  9. package/dist/cards-B_aNY35J.d.cts +514 -0
  10. package/dist/cards-Ba1wZttb.d.ts +514 -0
  11. package/dist/deposits-BEc8U80M.d.cts +310 -0
  12. package/dist/deposits-DScyT_D9.d.ts +310 -0
  13. package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
  14. package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
  15. package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
  16. package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
  17. package/dist/index.cjs +939 -77
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +101 -13
  20. package/dist/index.d.ts +101 -13
  21. package/dist/index.js +924 -78
  22. package/dist/index.js.map +1 -1
  23. package/dist/react/index.d.cts +12 -5
  24. package/dist/react/index.d.ts +12 -5
  25. package/dist/resources/attribution.cjs +82 -0
  26. package/dist/resources/attribution.cjs.map +1 -0
  27. package/dist/resources/attribution.d.cts +100 -0
  28. package/dist/resources/attribution.d.ts +100 -0
  29. package/dist/resources/attribution.js +78 -0
  30. package/dist/resources/attribution.js.map +1 -0
  31. package/dist/resources/auth.cjs +81 -15
  32. package/dist/resources/auth.cjs.map +1 -1
  33. package/dist/resources/auth.d.cts +53 -6
  34. package/dist/resources/auth.d.ts +53 -6
  35. package/dist/resources/auth.js +81 -15
  36. package/dist/resources/auth.js.map +1 -1
  37. package/dist/resources/balance.d.cts +1 -1
  38. package/dist/resources/balance.d.ts +1 -1
  39. package/dist/resources/blog.cjs.map +1 -1
  40. package/dist/resources/blog.d.cts +8 -1
  41. package/dist/resources/blog.d.ts +8 -1
  42. package/dist/resources/blog.js.map +1 -1
  43. package/dist/resources/bonus.cjs +28 -0
  44. package/dist/resources/bonus.cjs.map +1 -0
  45. package/dist/resources/bonus.d.cts +121 -0
  46. package/dist/resources/bonus.d.ts +121 -0
  47. package/dist/resources/bonus.js +26 -0
  48. package/dist/resources/bonus.js.map +1 -0
  49. package/dist/resources/branding.d.cts +1 -1
  50. package/dist/resources/branding.d.ts +1 -1
  51. package/dist/resources/cards.cjs +48 -10
  52. package/dist/resources/cards.cjs.map +1 -1
  53. package/dist/resources/cards.d.cts +2 -347
  54. package/dist/resources/cards.d.ts +2 -347
  55. package/dist/resources/cards.js +48 -11
  56. package/dist/resources/cards.js.map +1 -1
  57. package/dist/resources/codes.cjs +20 -0
  58. package/dist/resources/codes.cjs.map +1 -0
  59. package/dist/resources/codes.d.cts +100 -0
  60. package/dist/resources/codes.d.ts +100 -0
  61. package/dist/resources/codes.js +18 -0
  62. package/dist/resources/codes.js.map +1 -0
  63. package/dist/resources/deposits.cjs +28 -3
  64. package/dist/resources/deposits.cjs.map +1 -1
  65. package/dist/resources/deposits.d.cts +3 -176
  66. package/dist/resources/deposits.d.ts +3 -176
  67. package/dist/resources/deposits.js +28 -3
  68. package/dist/resources/deposits.js.map +1 -1
  69. package/dist/resources/devices.d.cts +2 -2
  70. package/dist/resources/devices.d.ts +2 -2
  71. package/dist/resources/documents.cjs +64 -0
  72. package/dist/resources/documents.cjs.map +1 -0
  73. package/dist/resources/documents.d.cts +212 -0
  74. package/dist/resources/documents.d.ts +212 -0
  75. package/dist/resources/documents.js +62 -0
  76. package/dist/resources/documents.js.map +1 -0
  77. package/dist/resources/funding-options.cjs +16 -0
  78. package/dist/resources/funding-options.cjs.map +1 -0
  79. package/dist/resources/funding-options.d.cts +3 -0
  80. package/dist/resources/funding-options.d.ts +3 -0
  81. package/dist/resources/funding-options.js +14 -0
  82. package/dist/resources/funding-options.js.map +1 -0
  83. package/dist/resources/history.cjs +31 -0
  84. package/dist/resources/history.cjs.map +1 -0
  85. package/dist/resources/history.d.cts +95 -0
  86. package/dist/resources/history.d.ts +95 -0
  87. package/dist/resources/history.js +29 -0
  88. package/dist/resources/history.js.map +1 -0
  89. package/dist/resources/me.d.cts +3 -1
  90. package/dist/resources/me.d.ts +3 -1
  91. package/dist/resources/notifications.d.cts +1 -1
  92. package/dist/resources/notifications.d.ts +1 -1
  93. package/dist/resources/push.d.cts +1 -1
  94. package/dist/resources/push.d.ts +1 -1
  95. package/dist/resources/referral.cjs +16 -0
  96. package/dist/resources/referral.cjs.map +1 -0
  97. package/dist/resources/referral.d.cts +58 -0
  98. package/dist/resources/referral.d.ts +58 -0
  99. package/dist/resources/referral.js +14 -0
  100. package/dist/resources/referral.js.map +1 -0
  101. package/dist/resources/sessions.d.cts +1 -1
  102. package/dist/resources/sessions.d.ts +1 -1
  103. package/dist/resources/subscription.cjs +24 -0
  104. package/dist/resources/subscription.cjs.map +1 -0
  105. package/dist/resources/subscription.d.cts +48 -0
  106. package/dist/resources/subscription.d.ts +48 -0
  107. package/dist/resources/subscription.js +22 -0
  108. package/dist/resources/subscription.js.map +1 -0
  109. package/dist/resources/subscriptions.d.cts +1 -1
  110. package/dist/resources/subscriptions.d.ts +1 -1
  111. package/dist/resources/wallet.d.cts +1 -1
  112. package/dist/resources/wallet.d.ts +1 -1
  113. package/dist/telegram.cjs +474 -77
  114. package/dist/telegram.cjs.map +1 -1
  115. package/dist/telegram.d.cts +12 -5
  116. package/dist/telegram.d.ts +12 -5
  117. package/dist/telegram.js +474 -77
  118. package/dist/telegram.js.map +1 -1
  119. package/package.json +46 -1
  120. package/dist/customer-CoxPwe5o.d.cts +0 -32
  121. package/dist/customer-CoxPwe5o.d.ts +0 -32
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.js';
1
+ import { H as HttpClient } from '../http-DeANAoTs.js';
2
2
 
3
3
  /**
4
4
  * Balance resource — `client.balance.*`.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/blog.ts"],"names":[],"mappings":";;;AAmFO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,KAAA,GAAuB,EAAC,EAAsB;AACvD,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,QAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAChD,IAAA,IAAI,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,YAAY,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA;AAC1D,IAAA,IAAI,MAAM,GAAA,EAAK,CAAA,CAAE,GAAA,CAAI,KAAA,EAAO,MAAM,GAAG,CAAA;AACrC,IAAA,IAAI,MAAM,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,MAAM,MAAM,CAAA;AAC9C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACjE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,IAAA,EAAiC;AACzC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAc,eAAe,kBAAA,CAAmB,IAAI,CAAC,CAAA,CAAA,EAAI;AAAA,MACxE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAS,SAAiB,IAAA,EAAsB;AAC9C,IAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACvC,IAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAG,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,EAAA,GAAK,GAAG,GAAG,IAAI,CAAA,CAAA;AAAA,EAC/E;AACF","file":"blog.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Blog resource — `client.blog.*`.\n *\n * Posts are public: these calls work before the user logs in, which is what\n * a marketing page or a Mini App landing screen needs.\n *\n * A post arrives as a **structured document**, not as HTML. `body_blocks` is\n * a flat list of typed nodes; map each `type` onto your own component and the\n * post inherits your site's styling. `body_markdown` is there too if you'd\n * rather run your own renderer.\n *\n * ```ts\n * const { posts } = await client.blog.list({ perPage: 5 });\n * const post = await client.blog.get(posts[0].slug);\n *\n * post.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={b.url} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Inline emphasis (`**bold**`, `[link](url)`) is left as Markdown inside\n * block text — every renderer already knows what to do with it.\n */\n\n/** One node of a post body. Discriminated on `type`. */\nexport type BlogBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\nexport interface BlogPost {\n /** Stable public key — link by this. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering — see the module docs. */\n body_blocks: BlogBlock[];\n tags: string[];\n /** Present only when the post declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n}\n\nexport interface BlogListInput {\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n /** Only posts carrying this tag. */\n tag?: string;\n /** Only posts in this locale. */\n locale?: string;\n}\n\nexport interface BlogList {\n posts: BlogPost[];\n total: number;\n page: number;\n per_page: number;\n}\n\nexport class BlogResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Published posts, newest first. No authentication required. */\n async list(input: BlogListInput = {}): Promise<BlogList> {\n const q = new URLSearchParams();\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n const qs = q.toString();\n return this.http.get<BlogList>(`/blog/posts${qs ? `?${qs}` : \"\"}`, {\n skipAuth: true,\n });\n }\n\n /** One post by slug. No authentication required. */\n async get(slug: string): Promise<BlogPost> {\n return this.http.get<BlogPost>(`/blog/posts/${encodeURIComponent(slug)}`, {\n skipAuth: true,\n });\n }\n\n /**\n * Absolute URL for an image path returned inside a post (`cover_url`, or an\n * image block's `url`). Handy when the app renders on a different origin\n * than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/blog.ts"],"names":[],"mappings":";;;AA0FO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,KAAA,GAAuB,EAAC,EAAsB;AACvD,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,QAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAChD,IAAA,IAAI,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,YAAY,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA;AAC1D,IAAA,IAAI,MAAM,GAAA,EAAK,CAAA,CAAE,GAAA,CAAI,KAAA,EAAO,MAAM,GAAG,CAAA;AACrC,IAAA,IAAI,MAAM,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,MAAM,MAAM,CAAA;AAC9C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACjE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,IAAA,EAAiC;AACzC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAc,eAAe,kBAAA,CAAmB,IAAI,CAAC,CAAA,CAAA,EAAI;AAAA,MACxE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAS,SAAiB,IAAA,EAAsB;AAC9C,IAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACvC,IAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAG,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,EAAA,GAAK,GAAG,GAAG,IAAI,CAAA,CAAA;AAAA,EAC/E;AACF","file":"blog.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Blog resource — `client.blog.*`.\n *\n * @deprecated The blog is a category of Documents now. Use\n * `client.documents.list({ category: \"blog\" })` and `client.documents.get(slug)`:\n * same posts, same slugs, same block shape, plus the folder trail and the\n * version history. `/blog/*` on the API answers for one more release and then\n * goes away; this class goes with it.\n *\n * Posts are public: these calls work before the user logs in, which is what\n * a marketing page or a Mini App landing screen needs.\n *\n * A post arrives as a **structured document**, not as HTML. `body_blocks` is\n * a flat list of typed nodes; map each `type` onto your own component and the\n * post inherits your site's styling. `body_markdown` is there too if you'd\n * rather run your own renderer.\n *\n * ```ts\n * const { posts } = await client.blog.list({ perPage: 5 });\n * const post = await client.blog.get(posts[0].slug);\n *\n * post.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={b.url} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Inline emphasis (`**bold**`, `[link](url)`) is left as Markdown inside\n * block text — every renderer already knows what to do with it.\n */\n\n/** One node of a post body. Discriminated on `type`. */\nexport type BlogBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\nexport interface BlogPost {\n /** Stable public key — link by this. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering — see the module docs. */\n body_blocks: BlogBlock[];\n tags: string[];\n /** Present only when the post declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n}\n\nexport interface BlogListInput {\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n /** Only posts carrying this tag. */\n tag?: string;\n /** Only posts in this locale. */\n locale?: string;\n}\n\nexport interface BlogList {\n posts: BlogPost[];\n total: number;\n page: number;\n per_page: number;\n}\n\n/** @deprecated See the module docs: use `client.documents`. */\nexport class BlogResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Published posts, newest first. No authentication required. */\n async list(input: BlogListInput = {}): Promise<BlogList> {\n const q = new URLSearchParams();\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n const qs = q.toString();\n return this.http.get<BlogList>(`/blog/posts${qs ? `?${qs}` : \"\"}`, {\n skipAuth: true,\n });\n }\n\n /** One post by slug. No authentication required. */\n async get(slug: string): Promise<BlogPost> {\n return this.http.get<BlogPost>(`/blog/posts/${encodeURIComponent(slug)}`, {\n skipAuth: true,\n });\n }\n\n /**\n * Absolute URL for an image path returned inside a post (`cover_url`, or an\n * image block's `url`). Handy when the app renders on a different origin\n * than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
@@ -1,8 +1,14 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.cjs';
1
+ import { H as HttpClient } from '../http-DeANAoTs.cjs';
2
2
 
3
3
  /**
4
4
  * Blog resource — `client.blog.*`.
5
5
  *
6
+ * @deprecated The blog is a category of Documents now. Use
7
+ * `client.documents.list({ category: "blog" })` and `client.documents.get(slug)`:
8
+ * same posts, same slugs, same block shape, plus the folder trail and the
9
+ * version history. `/blog/*` on the API answers for one more release and then
10
+ * goes away; this class goes with it.
11
+ *
6
12
  * Posts are public: these calls work before the user logs in, which is what
7
13
  * a marketing page or a Mini App landing screen needs.
8
14
  *
@@ -94,6 +100,7 @@ interface BlogList {
94
100
  page: number;
95
101
  per_page: number;
96
102
  }
103
+ /** @deprecated See the module docs: use `client.documents`. */
97
104
  declare class BlogResource {
98
105
  private readonly http;
99
106
  constructor(http: HttpClient);
@@ -1,8 +1,14 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.js';
1
+ import { H as HttpClient } from '../http-DeANAoTs.js';
2
2
 
3
3
  /**
4
4
  * Blog resource — `client.blog.*`.
5
5
  *
6
+ * @deprecated The blog is a category of Documents now. Use
7
+ * `client.documents.list({ category: "blog" })` and `client.documents.get(slug)`:
8
+ * same posts, same slugs, same block shape, plus the folder trail and the
9
+ * version history. `/blog/*` on the API answers for one more release and then
10
+ * goes away; this class goes with it.
11
+ *
6
12
  * Posts are public: these calls work before the user logs in, which is what
7
13
  * a marketing page or a Mini App landing screen needs.
8
14
  *
@@ -94,6 +100,7 @@ interface BlogList {
94
100
  page: number;
95
101
  per_page: number;
96
102
  }
103
+ /** @deprecated See the module docs: use `client.documents`. */
97
104
  declare class BlogResource {
98
105
  private readonly http;
99
106
  constructor(http: HttpClient);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/blog.ts"],"names":[],"mappings":";AAmFO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,KAAA,GAAuB,EAAC,EAAsB;AACvD,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,QAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAChD,IAAA,IAAI,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,YAAY,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA;AAC1D,IAAA,IAAI,MAAM,GAAA,EAAK,CAAA,CAAE,GAAA,CAAI,KAAA,EAAO,MAAM,GAAG,CAAA;AACrC,IAAA,IAAI,MAAM,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,MAAM,MAAM,CAAA;AAC9C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACjE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,IAAA,EAAiC;AACzC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAc,eAAe,kBAAA,CAAmB,IAAI,CAAC,CAAA,CAAA,EAAI;AAAA,MACxE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAS,SAAiB,IAAA,EAAsB;AAC9C,IAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACvC,IAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAG,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,EAAA,GAAK,GAAG,GAAG,IAAI,CAAA,CAAA;AAAA,EAC/E;AACF","file":"blog.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Blog resource — `client.blog.*`.\n *\n * Posts are public: these calls work before the user logs in, which is what\n * a marketing page or a Mini App landing screen needs.\n *\n * A post arrives as a **structured document**, not as HTML. `body_blocks` is\n * a flat list of typed nodes; map each `type` onto your own component and the\n * post inherits your site's styling. `body_markdown` is there too if you'd\n * rather run your own renderer.\n *\n * ```ts\n * const { posts } = await client.blog.list({ perPage: 5 });\n * const post = await client.blog.get(posts[0].slug);\n *\n * post.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={b.url} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Inline emphasis (`**bold**`, `[link](url)`) is left as Markdown inside\n * block text — every renderer already knows what to do with it.\n */\n\n/** One node of a post body. Discriminated on `type`. */\nexport type BlogBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\nexport interface BlogPost {\n /** Stable public key — link by this. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering — see the module docs. */\n body_blocks: BlogBlock[];\n tags: string[];\n /** Present only when the post declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n}\n\nexport interface BlogListInput {\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n /** Only posts carrying this tag. */\n tag?: string;\n /** Only posts in this locale. */\n locale?: string;\n}\n\nexport interface BlogList {\n posts: BlogPost[];\n total: number;\n page: number;\n per_page: number;\n}\n\nexport class BlogResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Published posts, newest first. No authentication required. */\n async list(input: BlogListInput = {}): Promise<BlogList> {\n const q = new URLSearchParams();\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n const qs = q.toString();\n return this.http.get<BlogList>(`/blog/posts${qs ? `?${qs}` : \"\"}`, {\n skipAuth: true,\n });\n }\n\n /** One post by slug. No authentication required. */\n async get(slug: string): Promise<BlogPost> {\n return this.http.get<BlogPost>(`/blog/posts/${encodeURIComponent(slug)}`, {\n skipAuth: true,\n });\n }\n\n /**\n * Absolute URL for an image path returned inside a post (`cover_url`, or an\n * image block's `url`). Handy when the app renders on a different origin\n * than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/blog.ts"],"names":[],"mappings":";AA0FO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,KAAA,GAAuB,EAAC,EAAsB;AACvD,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,QAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAChD,IAAA,IAAI,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,YAAY,MAAA,CAAO,KAAA,CAAM,OAAO,CAAC,CAAA;AAC1D,IAAA,IAAI,MAAM,GAAA,EAAK,CAAA,CAAE,GAAA,CAAI,KAAA,EAAO,MAAM,GAAG,CAAA;AACrC,IAAA,IAAI,MAAM,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,MAAM,MAAM,CAAA;AAC9C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACjE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,IAAA,EAAiC;AACzC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAc,eAAe,kBAAA,CAAmB,IAAI,CAAC,CAAA,CAAA,EAAI;AAAA,MACxE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAS,SAAiB,IAAA,EAAsB;AAC9C,IAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACvC,IAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAG,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,EAAA,GAAK,GAAG,GAAG,IAAI,CAAA,CAAA;AAAA,EAC/E;AACF","file":"blog.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Blog resource — `client.blog.*`.\n *\n * @deprecated The blog is a category of Documents now. Use\n * `client.documents.list({ category: \"blog\" })` and `client.documents.get(slug)`:\n * same posts, same slugs, same block shape, plus the folder trail and the\n * version history. `/blog/*` on the API answers for one more release and then\n * goes away; this class goes with it.\n *\n * Posts are public: these calls work before the user logs in, which is what\n * a marketing page or a Mini App landing screen needs.\n *\n * A post arrives as a **structured document**, not as HTML. `body_blocks` is\n * a flat list of typed nodes; map each `type` onto your own component and the\n * post inherits your site's styling. `body_markdown` is there too if you'd\n * rather run your own renderer.\n *\n * ```ts\n * const { posts } = await client.blog.list({ perPage: 5 });\n * const post = await client.blog.get(posts[0].slug);\n *\n * post.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={b.url} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Inline emphasis (`**bold**`, `[link](url)`) is left as Markdown inside\n * block text — every renderer already knows what to do with it.\n */\n\n/** One node of a post body. Discriminated on `type`. */\nexport type BlogBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\nexport interface BlogPost {\n /** Stable public key — link by this. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering — see the module docs. */\n body_blocks: BlogBlock[];\n tags: string[];\n /** Present only when the post declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n}\n\nexport interface BlogListInput {\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n /** Only posts carrying this tag. */\n tag?: string;\n /** Only posts in this locale. */\n locale?: string;\n}\n\nexport interface BlogList {\n posts: BlogPost[];\n total: number;\n page: number;\n per_page: number;\n}\n\n/** @deprecated See the module docs: use `client.documents`. */\nexport class BlogResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Published posts, newest first. No authentication required. */\n async list(input: BlogListInput = {}): Promise<BlogList> {\n const q = new URLSearchParams();\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n const qs = q.toString();\n return this.http.get<BlogList>(`/blog/posts${qs ? `?${qs}` : \"\"}`, {\n skipAuth: true,\n });\n }\n\n /** One post by slug. No authentication required. */\n async get(slug: string): Promise<BlogPost> {\n return this.http.get<BlogPost>(`/blog/posts/${encodeURIComponent(slug)}`, {\n skipAuth: true,\n });\n }\n\n /**\n * Absolute URL for an image path returned inside a post (`cover_url`, or an\n * image block's `url`). Handy when the app renders on a different origin\n * than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // src/resources/bonus.ts
4
+ var BonusResource = class {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** The user's bonuses: balance, where they can go, credits and history. */
9
+ async get(opts = {}) {
10
+ return this.http.get("/me/bonus", { signal: opts.signal });
11
+ }
12
+ /**
13
+ * Work out how bonuses would change a price, at the rate the payment
14
+ * would use. Nothing is held; the numbers may move by the time the user
15
+ * pays if prices, rates or bonuses change.
16
+ */
17
+ async preview(input) {
18
+ const { productId, bonusAmount, ...rest } = input;
19
+ const body = { ...rest };
20
+ if (productId !== void 0) body["product_id"] = productId;
21
+ if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
22
+ return this.http.post("/me/bonus/preview", { body });
23
+ }
24
+ };
25
+
26
+ exports.BonusResource = BonusResource;
27
+ //# sourceMappingURL=bonus.cjs.map
28
+ //# sourceMappingURL=bonus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/bonus.ts"],"names":[],"mappings":";;;AAiHO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAyB;AACnE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,WAAA,EAAa,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ,KAAA,EAAiD;AAC7D,IAAA,MAAM,EAAE,SAAA,EAAW,WAAA,EAAa,GAAG,MAAK,GAAI,KAAA;AAC5C,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,IAAA,IAAI,WAAA,KAAgB,MAAA,EAAW,IAAA,CAAK,cAAc,CAAA,GAAI,WAAA;AACtD,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,mBAAA,EAAqB,EAAE,MAAM,CAAA;AAAA,EACnE;AACF","file":"bonus.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Bonus resource — `client.bonus.*`.\n *\n * Bonuses are a discount on the platform's services, not money. They pay\n * for part of a new card's price or of the subscription fee, and bonuses\n * that came with a payment can also be added on top of a top-up. Spending\n * happens on the operation itself: `useBonus` / `bonusAmount` on\n * `cards.create`, `use_bonus` / `bonus_amount` on `deposits.initiate`, and\n * the subscription fee takes them on its own.\n *\n * Show the balance as a number of bonuses and nothing else: no money\n * figure next to it. Money belongs next to a price only (\"was / now\",\n * \"N bonuses will be used\"), which is what {@link BonusResource.preview}\n * works out on the server.\n *\n * Mirrors `GET /me/bonus` and `POST /me/bonus/preview`.\n */\n\n/** What bonuses can pay for. */\nexport type BonusPurpose = \"card_issuance\" | \"subscription\" | \"deposit\";\n\n/** One credit of bonuses and what is left of it. */\nexport interface BonusLot {\n id: string;\n /** Where the bonuses came from, e.g. `manual`. */\n source: string;\n /** True when they came without a payment: a card or the subscription only, never a top-up. */\n restricted: boolean;\n /** Bonuses credited, decimal string. */\n amount: string;\n /** Bonuses left, decimal string. */\n remaining: string;\n /** When what is left expires; `null` = never. */\n expires_at: string | null;\n created_at: string;\n}\n\n/** One change to the bonus balance. */\nexport interface BonusMovement {\n id: string;\n /** `credit`, `debit` (taken back by support), `spend` or `expire`. */\n kind: \"credit\" | \"debit\" | \"spend\" | \"expire\" | (string & {});\n /** For a `spend`: what the bonuses went towards. */\n purpose: BonusPurpose | null;\n /** `posted`, or `reserved` while the payment they are held for goes through. */\n status: \"posted\" | \"reserved\" | (string & {});\n /** Bonuses, decimal string, always positive. */\n units: string;\n /** For a spend: the price the bonuses went against (a top-up: the amount paid). */\n price: string | null;\n /** For a spend: what the bonuses covered (a top-up: what they added). */\n value: string | null;\n /** Currency of `price` and `value`. */\n currency: string | null;\n /** The card, deposit or subscription paid for. */\n operation_id: string | null;\n created_at: string;\n}\n\n/** Where bonuses may go right now. */\nexport interface BonusTarget {\n purpose: BonusPurpose;\n /** Bonuses that may go towards it, decimal string. */\n available: string;\n /** Largest share of a price bonuses may cover, basis points (10000 = all). */\n share_bps: number;\n}\n\n/** `GET /me/bonus`. */\nexport interface BonusWallet {\n /** Bonuses the user can use now. Show it on its own, without a money figure. */\n balance: string;\n /** Bonuses held for a payment still going through. */\n pending: string;\n /** One bonus is a discount of one unit of this currency. For prices only. */\n unit_currency: string;\n spend_on: BonusTarget[];\n /** Credits with bonuses left, the soonest to expire first. */\n lots: BonusLot[];\n /** Latest changes, newest first. */\n history: BonusMovement[];\n}\n\nexport interface BonusPreviewInput {\n purpose: BonusPurpose;\n /** The price as shown, or for `deposit` the amount paid; decimal string. */\n amount: string;\n /** ISO 4217 code of `amount`. */\n currency: string;\n /** For `card_issuance`: the product, which may cap the bonus share. */\n productId?: string;\n /** The most bonuses to use; omit to use as many as allowed. */\n bonusAmount?: string;\n}\n\n/** How bonuses change one price. All amounts are decimal strings in `currency`. */\nexport interface BonusPreview {\n purpose: BonusPurpose;\n /** The price before bonuses (\"was\"); for `deposit`, the amount paid. */\n amount: string;\n /** Bonuses that would be used. */\n bonus_units: string;\n /** What they cover (or, for `deposit`, add). */\n bonus_value: string;\n /** What is left to pay (\"now\"); for `deposit`, the amount paid. */\n due: string;\n /** For `deposit`: what reaches the wallet. `null` otherwise. */\n credited: string | null;\n currency: string;\n}\n\nexport class BonusResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's bonuses: balance, where they can go, credits and history. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<BonusWallet> {\n return this.http.get<BonusWallet>(\"/me/bonus\", { signal: opts.signal });\n }\n\n /**\n * Work out how bonuses would change a price, at the rate the payment\n * would use. Nothing is held; the numbers may move by the time the user\n * pays if prices, rates or bonuses change.\n */\n async preview(input: BonusPreviewInput): Promise<BonusPreview> {\n const { productId, bonusAmount, ...rest } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n return this.http.post<BonusPreview>(\"/me/bonus/preview\", { body });\n }\n}\n"]}
@@ -0,0 +1,121 @@
1
+ import { H as HttpClient } from '../http-DeANAoTs.cjs';
2
+
3
+ /**
4
+ * Bonus resource — `client.bonus.*`.
5
+ *
6
+ * Bonuses are a discount on the platform's services, not money. They pay
7
+ * for part of a new card's price or of the subscription fee, and bonuses
8
+ * that came with a payment can also be added on top of a top-up. Spending
9
+ * happens on the operation itself: `useBonus` / `bonusAmount` on
10
+ * `cards.create`, `use_bonus` / `bonus_amount` on `deposits.initiate`, and
11
+ * the subscription fee takes them on its own.
12
+ *
13
+ * Show the balance as a number of bonuses and nothing else: no money
14
+ * figure next to it. Money belongs next to a price only ("was / now",
15
+ * "N bonuses will be used"), which is what {@link BonusResource.preview}
16
+ * works out on the server.
17
+ *
18
+ * Mirrors `GET /me/bonus` and `POST /me/bonus/preview`.
19
+ */
20
+ /** What bonuses can pay for. */
21
+ type BonusPurpose = "card_issuance" | "subscription" | "deposit";
22
+ /** One credit of bonuses and what is left of it. */
23
+ interface BonusLot {
24
+ id: string;
25
+ /** Where the bonuses came from, e.g. `manual`. */
26
+ source: string;
27
+ /** True when they came without a payment: a card or the subscription only, never a top-up. */
28
+ restricted: boolean;
29
+ /** Bonuses credited, decimal string. */
30
+ amount: string;
31
+ /** Bonuses left, decimal string. */
32
+ remaining: string;
33
+ /** When what is left expires; `null` = never. */
34
+ expires_at: string | null;
35
+ created_at: string;
36
+ }
37
+ /** One change to the bonus balance. */
38
+ interface BonusMovement {
39
+ id: string;
40
+ /** `credit`, `debit` (taken back by support), `spend` or `expire`. */
41
+ kind: "credit" | "debit" | "spend" | "expire" | (string & {});
42
+ /** For a `spend`: what the bonuses went towards. */
43
+ purpose: BonusPurpose | null;
44
+ /** `posted`, or `reserved` while the payment they are held for goes through. */
45
+ status: "posted" | "reserved" | (string & {});
46
+ /** Bonuses, decimal string, always positive. */
47
+ units: string;
48
+ /** For a spend: the price the bonuses went against (a top-up: the amount paid). */
49
+ price: string | null;
50
+ /** For a spend: what the bonuses covered (a top-up: what they added). */
51
+ value: string | null;
52
+ /** Currency of `price` and `value`. */
53
+ currency: string | null;
54
+ /** The card, deposit or subscription paid for. */
55
+ operation_id: string | null;
56
+ created_at: string;
57
+ }
58
+ /** Where bonuses may go right now. */
59
+ interface BonusTarget {
60
+ purpose: BonusPurpose;
61
+ /** Bonuses that may go towards it, decimal string. */
62
+ available: string;
63
+ /** Largest share of a price bonuses may cover, basis points (10000 = all). */
64
+ share_bps: number;
65
+ }
66
+ /** `GET /me/bonus`. */
67
+ interface BonusWallet {
68
+ /** Bonuses the user can use now. Show it on its own, without a money figure. */
69
+ balance: string;
70
+ /** Bonuses held for a payment still going through. */
71
+ pending: string;
72
+ /** One bonus is a discount of one unit of this currency. For prices only. */
73
+ unit_currency: string;
74
+ spend_on: BonusTarget[];
75
+ /** Credits with bonuses left, the soonest to expire first. */
76
+ lots: BonusLot[];
77
+ /** Latest changes, newest first. */
78
+ history: BonusMovement[];
79
+ }
80
+ interface BonusPreviewInput {
81
+ purpose: BonusPurpose;
82
+ /** The price as shown, or for `deposit` the amount paid; decimal string. */
83
+ amount: string;
84
+ /** ISO 4217 code of `amount`. */
85
+ currency: string;
86
+ /** For `card_issuance`: the product, which may cap the bonus share. */
87
+ productId?: string;
88
+ /** The most bonuses to use; omit to use as many as allowed. */
89
+ bonusAmount?: string;
90
+ }
91
+ /** How bonuses change one price. All amounts are decimal strings in `currency`. */
92
+ interface BonusPreview {
93
+ purpose: BonusPurpose;
94
+ /** The price before bonuses ("was"); for `deposit`, the amount paid. */
95
+ amount: string;
96
+ /** Bonuses that would be used. */
97
+ bonus_units: string;
98
+ /** What they cover (or, for `deposit`, add). */
99
+ bonus_value: string;
100
+ /** What is left to pay ("now"); for `deposit`, the amount paid. */
101
+ due: string;
102
+ /** For `deposit`: what reaches the wallet. `null` otherwise. */
103
+ credited: string | null;
104
+ currency: string;
105
+ }
106
+ declare class BonusResource {
107
+ private readonly http;
108
+ constructor(http: HttpClient);
109
+ /** The user's bonuses: balance, where they can go, credits and history. */
110
+ get(opts?: {
111
+ signal?: AbortSignal;
112
+ }): Promise<BonusWallet>;
113
+ /**
114
+ * Work out how bonuses would change a price, at the rate the payment
115
+ * would use. Nothing is held; the numbers may move by the time the user
116
+ * pays if prices, rates or bonuses change.
117
+ */
118
+ preview(input: BonusPreviewInput): Promise<BonusPreview>;
119
+ }
120
+
121
+ export { type BonusLot, type BonusMovement, type BonusPreview, type BonusPreviewInput, type BonusPurpose, BonusResource, type BonusTarget, type BonusWallet };
@@ -0,0 +1,121 @@
1
+ import { H as HttpClient } from '../http-DeANAoTs.js';
2
+
3
+ /**
4
+ * Bonus resource — `client.bonus.*`.
5
+ *
6
+ * Bonuses are a discount on the platform's services, not money. They pay
7
+ * for part of a new card's price or of the subscription fee, and bonuses
8
+ * that came with a payment can also be added on top of a top-up. Spending
9
+ * happens on the operation itself: `useBonus` / `bonusAmount` on
10
+ * `cards.create`, `use_bonus` / `bonus_amount` on `deposits.initiate`, and
11
+ * the subscription fee takes them on its own.
12
+ *
13
+ * Show the balance as a number of bonuses and nothing else: no money
14
+ * figure next to it. Money belongs next to a price only ("was / now",
15
+ * "N bonuses will be used"), which is what {@link BonusResource.preview}
16
+ * works out on the server.
17
+ *
18
+ * Mirrors `GET /me/bonus` and `POST /me/bonus/preview`.
19
+ */
20
+ /** What bonuses can pay for. */
21
+ type BonusPurpose = "card_issuance" | "subscription" | "deposit";
22
+ /** One credit of bonuses and what is left of it. */
23
+ interface BonusLot {
24
+ id: string;
25
+ /** Where the bonuses came from, e.g. `manual`. */
26
+ source: string;
27
+ /** True when they came without a payment: a card or the subscription only, never a top-up. */
28
+ restricted: boolean;
29
+ /** Bonuses credited, decimal string. */
30
+ amount: string;
31
+ /** Bonuses left, decimal string. */
32
+ remaining: string;
33
+ /** When what is left expires; `null` = never. */
34
+ expires_at: string | null;
35
+ created_at: string;
36
+ }
37
+ /** One change to the bonus balance. */
38
+ interface BonusMovement {
39
+ id: string;
40
+ /** `credit`, `debit` (taken back by support), `spend` or `expire`. */
41
+ kind: "credit" | "debit" | "spend" | "expire" | (string & {});
42
+ /** For a `spend`: what the bonuses went towards. */
43
+ purpose: BonusPurpose | null;
44
+ /** `posted`, or `reserved` while the payment they are held for goes through. */
45
+ status: "posted" | "reserved" | (string & {});
46
+ /** Bonuses, decimal string, always positive. */
47
+ units: string;
48
+ /** For a spend: the price the bonuses went against (a top-up: the amount paid). */
49
+ price: string | null;
50
+ /** For a spend: what the bonuses covered (a top-up: what they added). */
51
+ value: string | null;
52
+ /** Currency of `price` and `value`. */
53
+ currency: string | null;
54
+ /** The card, deposit or subscription paid for. */
55
+ operation_id: string | null;
56
+ created_at: string;
57
+ }
58
+ /** Where bonuses may go right now. */
59
+ interface BonusTarget {
60
+ purpose: BonusPurpose;
61
+ /** Bonuses that may go towards it, decimal string. */
62
+ available: string;
63
+ /** Largest share of a price bonuses may cover, basis points (10000 = all). */
64
+ share_bps: number;
65
+ }
66
+ /** `GET /me/bonus`. */
67
+ interface BonusWallet {
68
+ /** Bonuses the user can use now. Show it on its own, without a money figure. */
69
+ balance: string;
70
+ /** Bonuses held for a payment still going through. */
71
+ pending: string;
72
+ /** One bonus is a discount of one unit of this currency. For prices only. */
73
+ unit_currency: string;
74
+ spend_on: BonusTarget[];
75
+ /** Credits with bonuses left, the soonest to expire first. */
76
+ lots: BonusLot[];
77
+ /** Latest changes, newest first. */
78
+ history: BonusMovement[];
79
+ }
80
+ interface BonusPreviewInput {
81
+ purpose: BonusPurpose;
82
+ /** The price as shown, or for `deposit` the amount paid; decimal string. */
83
+ amount: string;
84
+ /** ISO 4217 code of `amount`. */
85
+ currency: string;
86
+ /** For `card_issuance`: the product, which may cap the bonus share. */
87
+ productId?: string;
88
+ /** The most bonuses to use; omit to use as many as allowed. */
89
+ bonusAmount?: string;
90
+ }
91
+ /** How bonuses change one price. All amounts are decimal strings in `currency`. */
92
+ interface BonusPreview {
93
+ purpose: BonusPurpose;
94
+ /** The price before bonuses ("was"); for `deposit`, the amount paid. */
95
+ amount: string;
96
+ /** Bonuses that would be used. */
97
+ bonus_units: string;
98
+ /** What they cover (or, for `deposit`, add). */
99
+ bonus_value: string;
100
+ /** What is left to pay ("now"); for `deposit`, the amount paid. */
101
+ due: string;
102
+ /** For `deposit`: what reaches the wallet. `null` otherwise. */
103
+ credited: string | null;
104
+ currency: string;
105
+ }
106
+ declare class BonusResource {
107
+ private readonly http;
108
+ constructor(http: HttpClient);
109
+ /** The user's bonuses: balance, where they can go, credits and history. */
110
+ get(opts?: {
111
+ signal?: AbortSignal;
112
+ }): Promise<BonusWallet>;
113
+ /**
114
+ * Work out how bonuses would change a price, at the rate the payment
115
+ * would use. Nothing is held; the numbers may move by the time the user
116
+ * pays if prices, rates or bonuses change.
117
+ */
118
+ preview(input: BonusPreviewInput): Promise<BonusPreview>;
119
+ }
120
+
121
+ export { type BonusLot, type BonusMovement, type BonusPreview, type BonusPreviewInput, type BonusPurpose, BonusResource, type BonusTarget, type BonusWallet };
@@ -0,0 +1,26 @@
1
+ // src/resources/bonus.ts
2
+ var BonusResource = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** The user's bonuses: balance, where they can go, credits and history. */
7
+ async get(opts = {}) {
8
+ return this.http.get("/me/bonus", { signal: opts.signal });
9
+ }
10
+ /**
11
+ * Work out how bonuses would change a price, at the rate the payment
12
+ * would use. Nothing is held; the numbers may move by the time the user
13
+ * pays if prices, rates or bonuses change.
14
+ */
15
+ async preview(input) {
16
+ const { productId, bonusAmount, ...rest } = input;
17
+ const body = { ...rest };
18
+ if (productId !== void 0) body["product_id"] = productId;
19
+ if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
20
+ return this.http.post("/me/bonus/preview", { body });
21
+ }
22
+ };
23
+
24
+ export { BonusResource };
25
+ //# sourceMappingURL=bonus.js.map
26
+ //# sourceMappingURL=bonus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/bonus.ts"],"names":[],"mappings":";AAiHO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAyB;AACnE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,WAAA,EAAa,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ,KAAA,EAAiD;AAC7D,IAAA,MAAM,EAAE,SAAA,EAAW,WAAA,EAAa,GAAG,MAAK,GAAI,KAAA;AAC5C,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,IAAA,IAAI,WAAA,KAAgB,MAAA,EAAW,IAAA,CAAK,cAAc,CAAA,GAAI,WAAA;AACtD,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,mBAAA,EAAqB,EAAE,MAAM,CAAA;AAAA,EACnE;AACF","file":"bonus.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Bonus resource — `client.bonus.*`.\n *\n * Bonuses are a discount on the platform's services, not money. They pay\n * for part of a new card's price or of the subscription fee, and bonuses\n * that came with a payment can also be added on top of a top-up. Spending\n * happens on the operation itself: `useBonus` / `bonusAmount` on\n * `cards.create`, `use_bonus` / `bonus_amount` on `deposits.initiate`, and\n * the subscription fee takes them on its own.\n *\n * Show the balance as a number of bonuses and nothing else: no money\n * figure next to it. Money belongs next to a price only (\"was / now\",\n * \"N bonuses will be used\"), which is what {@link BonusResource.preview}\n * works out on the server.\n *\n * Mirrors `GET /me/bonus` and `POST /me/bonus/preview`.\n */\n\n/** What bonuses can pay for. */\nexport type BonusPurpose = \"card_issuance\" | \"subscription\" | \"deposit\";\n\n/** One credit of bonuses and what is left of it. */\nexport interface BonusLot {\n id: string;\n /** Where the bonuses came from, e.g. `manual`. */\n source: string;\n /** True when they came without a payment: a card or the subscription only, never a top-up. */\n restricted: boolean;\n /** Bonuses credited, decimal string. */\n amount: string;\n /** Bonuses left, decimal string. */\n remaining: string;\n /** When what is left expires; `null` = never. */\n expires_at: string | null;\n created_at: string;\n}\n\n/** One change to the bonus balance. */\nexport interface BonusMovement {\n id: string;\n /** `credit`, `debit` (taken back by support), `spend` or `expire`. */\n kind: \"credit\" | \"debit\" | \"spend\" | \"expire\" | (string & {});\n /** For a `spend`: what the bonuses went towards. */\n purpose: BonusPurpose | null;\n /** `posted`, or `reserved` while the payment they are held for goes through. */\n status: \"posted\" | \"reserved\" | (string & {});\n /** Bonuses, decimal string, always positive. */\n units: string;\n /** For a spend: the price the bonuses went against (a top-up: the amount paid). */\n price: string | null;\n /** For a spend: what the bonuses covered (a top-up: what they added). */\n value: string | null;\n /** Currency of `price` and `value`. */\n currency: string | null;\n /** The card, deposit or subscription paid for. */\n operation_id: string | null;\n created_at: string;\n}\n\n/** Where bonuses may go right now. */\nexport interface BonusTarget {\n purpose: BonusPurpose;\n /** Bonuses that may go towards it, decimal string. */\n available: string;\n /** Largest share of a price bonuses may cover, basis points (10000 = all). */\n share_bps: number;\n}\n\n/** `GET /me/bonus`. */\nexport interface BonusWallet {\n /** Bonuses the user can use now. Show it on its own, without a money figure. */\n balance: string;\n /** Bonuses held for a payment still going through. */\n pending: string;\n /** One bonus is a discount of one unit of this currency. For prices only. */\n unit_currency: string;\n spend_on: BonusTarget[];\n /** Credits with bonuses left, the soonest to expire first. */\n lots: BonusLot[];\n /** Latest changes, newest first. */\n history: BonusMovement[];\n}\n\nexport interface BonusPreviewInput {\n purpose: BonusPurpose;\n /** The price as shown, or for `deposit` the amount paid; decimal string. */\n amount: string;\n /** ISO 4217 code of `amount`. */\n currency: string;\n /** For `card_issuance`: the product, which may cap the bonus share. */\n productId?: string;\n /** The most bonuses to use; omit to use as many as allowed. */\n bonusAmount?: string;\n}\n\n/** How bonuses change one price. All amounts are decimal strings in `currency`. */\nexport interface BonusPreview {\n purpose: BonusPurpose;\n /** The price before bonuses (\"was\"); for `deposit`, the amount paid. */\n amount: string;\n /** Bonuses that would be used. */\n bonus_units: string;\n /** What they cover (or, for `deposit`, add). */\n bonus_value: string;\n /** What is left to pay (\"now\"); for `deposit`, the amount paid. */\n due: string;\n /** For `deposit`: what reaches the wallet. `null` otherwise. */\n credited: string | null;\n currency: string;\n}\n\nexport class BonusResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's bonuses: balance, where they can go, credits and history. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<BonusWallet> {\n return this.http.get<BonusWallet>(\"/me/bonus\", { signal: opts.signal });\n }\n\n /**\n * Work out how bonuses would change a price, at the rate the payment\n * would use. Nothing is held; the numbers may move by the time the user\n * pays if prices, rates or bonuses change.\n */\n async preview(input: BonusPreviewInput): Promise<BonusPreview> {\n const { productId, bonusAmount, ...rest } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n return this.http.post<BonusPreview>(\"/me/bonus/preview\", { body });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.cjs';
1
+ import { H as HttpClient } from '../http-DeANAoTs.cjs';
2
2
 
3
3
  /**
4
4
  * Branding resource — `client.branding.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.js';
1
+ import { H as HttpClient } from '../http-DeANAoTs.js';
2
2
 
3
3
  /**
4
4
  * Branding resource — `client.branding.*`.
@@ -1,6 +1,26 @@
1
1
  'use strict';
2
2
 
3
3
  // src/resources/cards.ts
4
+ function cardRequestBody(input) {
5
+ const {
6
+ productId,
7
+ name,
8
+ designId,
9
+ useBonus,
10
+ bonusAmount,
11
+ promoCode,
12
+ initial_amount: _ignored,
13
+ ...rest
14
+ } = input;
15
+ const body = { ...rest };
16
+ if (productId !== void 0) body["product_id"] = productId;
17
+ if (name !== void 0) body["name"] = name;
18
+ if (designId !== void 0) body["design_id"] = designId;
19
+ if (useBonus !== void 0) body["use_bonus"] = useBonus;
20
+ if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
21
+ if (promoCode !== void 0) body["promo_code"] = promoCode;
22
+ return body;
23
+ }
4
24
  var CardsResource = class {
5
25
  constructor(http) {
6
26
  this.http = http;
@@ -12,21 +32,19 @@ var CardsResource = class {
12
32
  * `failure_reason` on the result.
13
33
  */
14
34
  async create(input) {
15
- const { idempotencyKey, productId, name, designId, ...rest } = input;
16
- const body = { ...rest };
17
- if (productId !== void 0) body["product_id"] = productId;
18
- if (name !== void 0) body["name"] = name;
19
- if (designId !== void 0) body["design_id"] = designId;
35
+ const { idempotencyKey, ...card } = input;
20
36
  return this.http.post("/me/cards", {
21
- body,
37
+ body: cardRequestBody(card),
22
38
  idempotencyKey
23
39
  });
24
40
  }
25
41
  /**
26
- * The cards the caller can order, in the order the deployment offers them
27
- * (the default product first). Each item carries its name, description,
28
- * artwork, the issuance price after the caller's subscription discount,
29
- * and the currency. Pass an item's `id` as `productId` to {@link create}.
42
+ * The cards the caller can order, in the order the storefront shows them
43
+ * (`is_default` marks the one issued when none is chosen). Each item
44
+ * carries its product card (name, tagline, benefits, tile picture),
45
+ * artwork, and the issuance price after the caller's subscription
46
+ * discount, in the caller's wallet currency. Pass an item's `id` as
47
+ * `productId` to {@link create}.
30
48
  */
31
49
  async listProducts() {
32
50
  return this.http.get("/me/card-products");
@@ -103,6 +121,25 @@ var CardsResource = class {
103
121
  idempotencyKey
104
122
  });
105
123
  }
124
+ /**
125
+ * Move money from one of the caller's cards to another. Both must be
126
+ * theirs, active, in the same currency and of the same kind. The money
127
+ * travels through the wallet one leg at a time: when the second leg does
128
+ * not go through, the call still resolves, `transfer.status` is
129
+ * `on_wallet` and the money is on the wallet — never between two cards.
130
+ * Errors carry a sentence the user can read: 400 the same card twice,
131
+ * different currencies or different kinds · 402 the card holds less than
132
+ * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
133
+ * or still being issued, or the key was reused with a different body ·
134
+ * 501/502/503 the provider cannot or will not move it.
135
+ */
136
+ async transfer(fromCardId, input) {
137
+ const { toCardId, amount, idempotencyKey } = input;
138
+ return this.http.post(
139
+ `/me/cards/${encodeURIComponent(fromCardId)}/transfer`,
140
+ { body: { to_card_id: toCardId, amount }, idempotencyKey }
141
+ );
142
+ }
106
143
  /**
107
144
  * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
108
145
  * `reason` is recorded on the audit trail. Resolves to the updated card.
@@ -151,5 +188,6 @@ var CardsResource = class {
151
188
  };
152
189
 
153
190
  exports.CardsResource = CardsResource;
191
+ exports.cardRequestBody = cardRequestBody;
154
192
  //# sourceMappingURL=cards.cjs.map
155
193
  //# sourceMappingURL=cards.cjs.map