@codeqr/ts 0.9.0 → 0.24.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 (243) hide show
  1. package/CHANGELOG.md +509 -0
  2. package/LICENSE +1 -1
  3. package/README.md +12 -1
  4. package/api-promise.d.mts +1 -0
  5. package/api-promise.d.mts.map +1 -1
  6. package/api-promise.d.ts +1 -0
  7. package/api-promise.d.ts.map +1 -1
  8. package/api-promise.mjs +1 -0
  9. package/api-promise.mjs.map +1 -1
  10. package/client.d.mts +8 -7
  11. package/client.d.mts.map +1 -1
  12. package/client.d.ts +8 -7
  13. package/client.d.ts.map +1 -1
  14. package/client.js +43 -10
  15. package/client.js.map +1 -1
  16. package/client.mjs +43 -10
  17. package/client.mjs.map +1 -1
  18. package/core/api-promise.d.mts.map +1 -1
  19. package/core/api-promise.d.ts.map +1 -1
  20. package/core/api-promise.mjs.map +1 -1
  21. package/core/error.mjs.map +1 -1
  22. package/core/resource.d.mts.map +1 -1
  23. package/core/resource.d.ts.map +1 -1
  24. package/core/uploads.d.mts.map +1 -1
  25. package/core/uploads.d.ts.map +1 -1
  26. package/core/uploads.mjs.map +1 -1
  27. package/error.d.mts +1 -0
  28. package/error.d.mts.map +1 -1
  29. package/error.d.ts +1 -0
  30. package/error.d.ts.map +1 -1
  31. package/error.mjs +1 -0
  32. package/error.mjs.map +1 -1
  33. package/index.d.mts.map +1 -1
  34. package/index.d.ts.map +1 -1
  35. package/index.mjs.map +1 -1
  36. package/internal/detect-platform.mjs.map +1 -1
  37. package/internal/headers.mjs.map +1 -1
  38. package/internal/parse.d.mts.map +1 -1
  39. package/internal/parse.d.ts.map +1 -1
  40. package/internal/parse.js +5 -0
  41. package/internal/parse.js.map +1 -1
  42. package/internal/parse.mjs +5 -0
  43. package/internal/parse.mjs.map +1 -1
  44. package/internal/qs/formats.d.mts.map +1 -1
  45. package/internal/qs/formats.d.ts.map +1 -1
  46. package/internal/qs/index.d.mts +2 -2
  47. package/internal/qs/index.d.mts.map +1 -1
  48. package/internal/qs/index.d.ts +2 -2
  49. package/internal/qs/index.d.ts.map +1 -1
  50. package/internal/qs/index.mjs.map +1 -1
  51. package/internal/qs/stringify.d.mts.map +1 -1
  52. package/internal/qs/stringify.d.ts.map +1 -1
  53. package/internal/qs/stringify.mjs.map +1 -1
  54. package/internal/qs/utils.d.mts.map +1 -1
  55. package/internal/qs/utils.d.ts.map +1 -1
  56. package/internal/qs/utils.mjs.map +1 -1
  57. package/internal/request-options.d.mts.map +1 -1
  58. package/internal/request-options.d.ts.map +1 -1
  59. package/internal/shims.d.mts +6 -0
  60. package/internal/shims.d.mts.map +1 -1
  61. package/internal/shims.d.ts +6 -0
  62. package/internal/shims.d.ts.map +1 -1
  63. package/internal/to-file.d.mts.map +1 -1
  64. package/internal/to-file.d.ts.map +1 -1
  65. package/internal/to-file.mjs.map +1 -1
  66. package/internal/types.d.mts +10 -10
  67. package/internal/types.d.mts.map +1 -1
  68. package/internal/types.d.ts +10 -10
  69. package/internal/types.d.ts.map +1 -1
  70. package/internal/uploads.d.mts.map +1 -1
  71. package/internal/uploads.d.ts.map +1 -1
  72. package/internal/uploads.mjs.map +1 -1
  73. package/internal/utils/base64.mjs.map +1 -1
  74. package/internal/utils/env.js +2 -2
  75. package/internal/utils/env.js.map +1 -1
  76. package/internal/utils/env.mjs +2 -2
  77. package/internal/utils/env.mjs.map +1 -1
  78. package/internal/utils/log.d.mts.map +1 -1
  79. package/internal/utils/log.d.ts.map +1 -1
  80. package/internal/utils/log.js +2 -0
  81. package/internal/utils/log.js.map +1 -1
  82. package/internal/utils/log.mjs +2 -0
  83. package/internal/utils/log.mjs.map +1 -1
  84. package/internal/utils/path.mjs.map +1 -1
  85. package/internal/utils/query.d.mts +2 -0
  86. package/internal/utils/query.d.mts.map +1 -0
  87. package/internal/utils/query.d.ts +2 -0
  88. package/internal/utils/query.d.ts.map +1 -0
  89. package/internal/utils/query.js +10 -0
  90. package/internal/utils/query.js.map +1 -0
  91. package/internal/utils/query.mjs +6 -0
  92. package/internal/utils/query.mjs.map +1 -0
  93. package/internal/utils/values.mjs.map +1 -1
  94. package/internal/utils.d.mts +1 -0
  95. package/internal/utils.d.mts.map +1 -1
  96. package/internal/utils.d.ts +1 -0
  97. package/internal/utils.d.ts.map +1 -1
  98. package/internal/utils.js +1 -0
  99. package/internal/utils.js.map +1 -1
  100. package/internal/utils.mjs +1 -0
  101. package/internal/utils.mjs.map +1 -1
  102. package/package.json +12 -1
  103. package/resource.d.mts +1 -0
  104. package/resource.d.mts.map +1 -1
  105. package/resource.d.ts +1 -0
  106. package/resource.d.ts.map +1 -1
  107. package/resource.mjs +1 -0
  108. package/resource.mjs.map +1 -1
  109. package/resources/analytics.d.mts +23 -3
  110. package/resources/analytics.d.mts.map +1 -1
  111. package/resources/analytics.d.ts +23 -3
  112. package/resources/analytics.d.ts.map +1 -1
  113. package/resources/analytics.mjs.map +1 -1
  114. package/resources/domains.d.mts +27 -27
  115. package/resources/domains.d.mts.map +1 -1
  116. package/resources/domains.d.ts +27 -27
  117. package/resources/domains.d.ts.map +1 -1
  118. package/resources/domains.js +8 -8
  119. package/resources/domains.js.map +1 -1
  120. package/resources/domains.mjs +8 -8
  121. package/resources/domains.mjs.map +1 -1
  122. package/resources/events.d.mts +53 -137
  123. package/resources/events.d.mts.map +1 -1
  124. package/resources/events.d.ts +53 -137
  125. package/resources/events.d.ts.map +1 -1
  126. package/resources/events.mjs.map +1 -1
  127. package/resources/index.d.mts +4 -4
  128. package/resources/index.d.mts.map +1 -1
  129. package/resources/index.d.ts +4 -4
  130. package/resources/index.d.ts.map +1 -1
  131. package/resources/index.js.map +1 -1
  132. package/resources/index.mjs.map +1 -1
  133. package/resources/links/bulk.d.mts +16 -26
  134. package/resources/links/bulk.d.mts.map +1 -1
  135. package/resources/links/bulk.d.ts +16 -26
  136. package/resources/links/bulk.d.ts.map +1 -1
  137. package/resources/links/bulk.js +0 -14
  138. package/resources/links/bulk.js.map +1 -1
  139. package/resources/links/bulk.mjs +0 -14
  140. package/resources/links/bulk.mjs.map +1 -1
  141. package/resources/links/index.d.mts +2 -2
  142. package/resources/links/index.d.mts.map +1 -1
  143. package/resources/links/index.d.ts +2 -2
  144. package/resources/links/index.d.ts.map +1 -1
  145. package/resources/links/index.js.map +1 -1
  146. package/resources/links/index.mjs +1 -1
  147. package/resources/links/index.mjs.map +1 -1
  148. package/resources/links/links.d.mts +232 -988
  149. package/resources/links/links.d.mts.map +1 -1
  150. package/resources/links/links.d.ts +232 -988
  151. package/resources/links/links.d.ts.map +1 -1
  152. package/resources/links/links.js +16 -42
  153. package/resources/links/links.js.map +1 -1
  154. package/resources/links/links.mjs +16 -42
  155. package/resources/links/links.mjs.map +1 -1
  156. package/resources/links.d.mts.map +1 -1
  157. package/resources/links.d.ts.map +1 -1
  158. package/resources/links.mjs.map +1 -1
  159. package/resources/projects.d.mts +0 -4
  160. package/resources/projects.d.mts.map +1 -1
  161. package/resources/projects.d.ts +0 -4
  162. package/resources/projects.d.ts.map +1 -1
  163. package/resources/projects.js +0 -7
  164. package/resources/projects.js.map +1 -1
  165. package/resources/projects.mjs +0 -7
  166. package/resources/projects.mjs.map +1 -1
  167. package/resources/qrcodes/bulk.d.mts +111 -38
  168. package/resources/qrcodes/bulk.d.mts.map +1 -1
  169. package/resources/qrcodes/bulk.d.ts +111 -38
  170. package/resources/qrcodes/bulk.d.ts.map +1 -1
  171. package/resources/qrcodes/bulk.js +0 -14
  172. package/resources/qrcodes/bulk.js.map +1 -1
  173. package/resources/qrcodes/bulk.mjs +0 -14
  174. package/resources/qrcodes/bulk.mjs.map +1 -1
  175. package/resources/qrcodes/index.d.mts +2 -2
  176. package/resources/qrcodes/index.d.mts.map +1 -1
  177. package/resources/qrcodes/index.d.ts +2 -2
  178. package/resources/qrcodes/index.d.ts.map +1 -1
  179. package/resources/qrcodes/index.js.map +1 -1
  180. package/resources/qrcodes/index.mjs +1 -1
  181. package/resources/qrcodes/index.mjs.map +1 -1
  182. package/resources/qrcodes/qrcodes.d.mts +442 -855
  183. package/resources/qrcodes/qrcodes.d.mts.map +1 -1
  184. package/resources/qrcodes/qrcodes.d.ts +442 -855
  185. package/resources/qrcodes/qrcodes.d.ts.map +1 -1
  186. package/resources/qrcodes/qrcodes.js +12 -42
  187. package/resources/qrcodes/qrcodes.js.map +1 -1
  188. package/resources/qrcodes/qrcodes.mjs +12 -42
  189. package/resources/qrcodes/qrcodes.mjs.map +1 -1
  190. package/resources/qrcodes.d.mts.map +1 -1
  191. package/resources/qrcodes.d.ts.map +1 -1
  192. package/resources/qrcodes.mjs.map +1 -1
  193. package/resources/tags.d.mts +19 -15
  194. package/resources/tags.d.mts.map +1 -1
  195. package/resources/tags.d.ts +19 -15
  196. package/resources/tags.d.ts.map +1 -1
  197. package/resources/tags.js +7 -7
  198. package/resources/tags.js.map +1 -1
  199. package/resources/tags.mjs +7 -7
  200. package/resources/tags.mjs.map +1 -1
  201. package/resources/track.d.mts +10 -9
  202. package/resources/track.d.mts.map +1 -1
  203. package/resources/track.d.ts +10 -9
  204. package/resources/track.d.ts.map +1 -1
  205. package/resources/track.mjs.map +1 -1
  206. package/resources.d.mts.map +1 -1
  207. package/resources.d.ts.map +1 -1
  208. package/resources.mjs.map +1 -1
  209. package/src/client.ts +53 -29
  210. package/src/internal/parse.ts +6 -0
  211. package/src/internal/types.ts +6 -8
  212. package/src/internal/utils/env.ts +2 -2
  213. package/src/internal/utils/log.ts +2 -0
  214. package/src/internal/utils/query.ts +7 -0
  215. package/src/internal/utils.ts +1 -0
  216. package/src/resources/analytics.ts +33 -3
  217. package/src/resources/domains.ts +38 -38
  218. package/src/resources/events.ts +90 -143
  219. package/src/resources/index.ts +4 -10
  220. package/src/resources/links/bulk.ts +30 -37
  221. package/src/resources/links/index.ts +2 -11
  222. package/src/resources/links/links.ts +227 -1538
  223. package/src/resources/projects.ts +0 -8
  224. package/src/resources/qrcodes/bulk.ts +151 -50
  225. package/src/resources/qrcodes/index.ts +2 -11
  226. package/src/resources/qrcodes/qrcodes.ts +405 -1083
  227. package/src/resources/tags.ts +23 -18
  228. package/src/resources/track.ts +10 -9
  229. package/src/version.ts +1 -1
  230. package/uploads.d.mts +1 -0
  231. package/uploads.d.mts.map +1 -1
  232. package/uploads.d.ts +1 -0
  233. package/uploads.d.ts.map +1 -1
  234. package/uploads.mjs +1 -0
  235. package/uploads.mjs.map +1 -1
  236. package/version.d.mts +1 -1
  237. package/version.d.mts.map +1 -1
  238. package/version.d.ts +1 -1
  239. package/version.d.ts.map +1 -1
  240. package/version.js +1 -1
  241. package/version.js.map +1 -1
  242. package/version.mjs +1 -1
  243. package/version.mjs.map +1 -1
@@ -57,7 +57,7 @@ export interface TrackTrackSaleResponse {
57
57
  export interface TrackTrackLeadParams {
58
58
  /**
59
59
  * The unique ID of the click that the lead conversion event is attributed to. You
60
- * can read this value from `cd_id` cookie. If an empty string is provided, CodeQR
60
+ * can read this value from `cq_id` cookie. If an empty string is provided, CodeQR
61
61
  * will try to find an existing customer with the provided `customerExternalId` and
62
62
  * use the `clickId` from the customer if found.
63
63
  */
@@ -99,16 +99,16 @@ export interface TrackTrackLeadParams {
99
99
  } | null;
100
100
  /**
101
101
  * The mode to use for tracking the lead event. `async` will not block the request;
102
- * `wait` will block the request until the lead event is fully recorded in Dub;
102
+ * `wait` will block the request until the lead event is fully recorded in CodeQR;
103
103
  * `deferred` will defer the lead event creation to a subsequent request.
104
104
  */
105
105
  mode?: 'async' | 'wait' | 'deferred';
106
106
  }
107
107
  export interface TrackTrackSaleParams {
108
108
  /**
109
- * The amount of the sale in cents (for all two-decimal currencies). If the sale is
110
- * in a zero-decimal currency, pass the full integer value (e.g. `1437` JPY). Learn
111
- * more: https://d.to/currency
109
+ * The amount of the sale in the smallest unit of `currency` — cents for
110
+ * two-decimal currencies, the full integer for zero-decimal ones (e.g. `1437`
111
+ * JPY), thousandths for three-decimal ones (e.g. `1437` KWD fils).
112
112
  */
113
113
  amount: number;
114
114
  /**
@@ -118,13 +118,14 @@ export interface TrackTrackSaleParams {
118
118
  customerExternalId: string;
119
119
  /**
120
120
  * [For direct sale tracking]: The unique ID of the click that the sale conversion
121
- * event is attributed to. You can read this value from `dub_id` cookie.
121
+ * event is attributed to. You can read this value from `cq_id` cookie.
122
122
  */
123
123
  clickId?: string | null;
124
124
  /**
125
- * The currency of the sale. Accepts ISO 4217 currency codes. Sales will be
126
- * automatically converted and stored as USD at the latest exchange rates. Learn
127
- * more: https://d.to/currency
125
+ * The currency of the sale, as an ISO 4217 code. Reporting is always in USD:
126
+ * non-USD sales are converted at the exchange rate of the day the sale is
127
+ * recorded, and the original amount and currency are kept on the event. The rate
128
+ * is not re-applied later, so reported totals do not move with the exchange rate.
128
129
  */
129
130
  currency?: string;
130
131
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"track.d.mts","sourceRoot":"","sources":["../src/resources/track.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,sBAAsB,CAAC;IAInG;;;;;;;;;;OAUG;IACH,SAAS,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,sBAAsB,CAAC;CAGpG;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC;IAEpC,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,CAAC;CAC3C;AAED,yBAAiB,sBAAsB,CAAC;IACtC,UAAiB,KAAK;QACpB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,UAAiB,QAAQ;QACvB,EAAE,EAAE,MAAM,CAAC;QAEX,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEvB,KAA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AClD,CAAC;CACH"}
@@ -57,7 +57,7 @@ export interface TrackTrackSaleResponse {
57
57
  export interface TrackTrackLeadParams {
58
58
  /**
59
59
  * The unique ID of the click that the lead conversion event is attributed to. You
60
- * can read this value from `cd_id` cookie. If an empty string is provided, CodeQR
60
+ * can read this value from `cq_id` cookie. If an empty string is provided, CodeQR
61
61
  * will try to find an existing customer with the provided `customerExternalId` and
62
62
  * use the `clickId` from the customer if found.
63
63
  */
@@ -99,16 +99,16 @@ export interface TrackTrackLeadParams {
99
99
  } | null;
100
100
  /**
101
101
  * The mode to use for tracking the lead event. `async` will not block the request;
102
- * `wait` will block the request until the lead event is fully recorded in Dub;
102
+ * `wait` will block the request until the lead event is fully recorded in CodeQR;
103
103
  * `deferred` will defer the lead event creation to a subsequent request.
104
104
  */
105
105
  mode?: 'async' | 'wait' | 'deferred';
106
106
  }
107
107
  export interface TrackTrackSaleParams {
108
108
  /**
109
- * The amount of the sale in cents (for all two-decimal currencies). If the sale is
110
- * in a zero-decimal currency, pass the full integer value (e.g. `1437` JPY). Learn
111
- * more: https://d.to/currency
109
+ * The amount of the sale in the smallest unit of `currency` — cents for
110
+ * two-decimal currencies, the full integer for zero-decimal ones (e.g. `1437`
111
+ * JPY), thousandths for three-decimal ones (e.g. `1437` KWD fils).
112
112
  */
113
113
  amount: number;
114
114
  /**
@@ -118,13 +118,14 @@ export interface TrackTrackSaleParams {
118
118
  customerExternalId: string;
119
119
  /**
120
120
  * [For direct sale tracking]: The unique ID of the click that the sale conversion
121
- * event is attributed to. You can read this value from `dub_id` cookie.
121
+ * event is attributed to. You can read this value from `cq_id` cookie.
122
122
  */
123
123
  clickId?: string | null;
124
124
  /**
125
- * The currency of the sale. Accepts ISO 4217 currency codes. Sales will be
126
- * automatically converted and stored as USD at the latest exchange rates. Learn
127
- * more: https://d.to/currency
125
+ * The currency of the sale, as an ISO 4217 code. Reporting is always in USD:
126
+ * non-USD sales are converted at the exchange rate of the day the sale is
127
+ * recorded, and the original amount and currency are kept on the event. The rate
128
+ * is not re-applied later, so reported totals do not move with the exchange rate.
128
129
  */
129
130
  currency?: string;
130
131
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/resources/track.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,sBAAsB,CAAC;IAInG;;;;;;;;;;OAUG;IACH,SAAS,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,sBAAsB,CAAC;CAGpG;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC;IAEpC,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,CAAC;CAC3C;AAED,yBAAiB,sBAAsB,CAAC;IACtC,UAAiB,KAAK;QACpB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,UAAiB,QAAQ;QACvB,EAAE,EAAE,MAAM,CAAC;QAEX,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,EAAE,MAAM,CAAC;IAEnB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAE5C,gBAAgB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IAA0B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
1
+ {"version":3,"file":"track.mjs","sourceRoot":"","sources":["../src/resources/track.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAI/C,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,IAA0B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;;OAUG;IACH,SAAS,CAAC,IAA0B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.mts","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"resources.d.mts","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":"AAAA,sCAAkC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":"AAAA,qCAAkC"}
package/resources.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"resources.mjs","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"resources.mjs","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":"AAAA,sCAAkC"}
package/src/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
17
  import * as Uploads from './core/uploads';
@@ -53,28 +53,22 @@ import {
53
53
  } from './resources/track';
54
54
  import {
55
55
  Link,
56
- LinkCountParams,
57
- LinkCountResponse,
58
56
  LinkCreateParams,
59
57
  LinkDeleteResponse,
60
58
  LinkListParams,
61
59
  LinkListResponse,
62
60
  LinkRetrieveInfoParams,
63
61
  LinkUpdateParams,
64
- LinkUpsertParams,
65
62
  Links,
66
63
  } from './resources/links/links';
67
64
  import {
68
65
  QrCode,
69
- QrcodeCountParams,
70
- QrcodeCountResponse,
71
66
  QrcodeCreateParams,
72
67
  QrcodeDeleteResponse,
73
68
  QrcodeListParams,
74
69
  QrcodeListResponse,
75
70
  QrcodeRetrieveParams,
76
71
  QrcodeUpdateParams,
77
- QrcodeUpsertParams,
78
72
  Qrcodes,
79
73
  } from './resources/qrcodes/qrcodes';
80
74
  import { type Fetch } from './internal/builtin-types';
@@ -227,6 +221,18 @@ export class Codeqr {
227
221
  this.fetch = options.fetch ?? Shims.getDefaultFetch();
228
222
  this.#encoder = Opts.FallbackEncoder;
229
223
 
224
+ const customHeadersEnv = readEnv('CODEQR_CUSTOM_HEADERS');
225
+ if (customHeadersEnv) {
226
+ const parsed: Record<string, string> = {};
227
+ for (const line of customHeadersEnv.split('\n')) {
228
+ const colon = line.indexOf(':');
229
+ if (colon >= 0) {
230
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
231
+ }
232
+ }
233
+ options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
234
+ }
235
+
230
236
  this._options = options;
231
237
 
232
238
  this.apiKey = apiKey;
@@ -270,8 +276,8 @@ export class Codeqr {
270
276
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
271
277
  }
272
278
 
273
- protected stringifyQuery(query: Record<string, unknown>): string {
274
- return qs.stringify(query, { arrayFormat: 'comma' });
279
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
280
+ return stringifyQuery(query);
275
281
  }
276
282
 
277
283
  private getUserAgent(): string {
@@ -303,12 +309,13 @@ export class Codeqr {
303
309
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
304
310
 
305
311
  const defaultQuery = this.defaultQuery();
306
- if (!isEmptyObj(defaultQuery)) {
307
- query = { ...defaultQuery, ...query };
312
+ const pathQuery = Object.fromEntries(url.searchParams);
313
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
314
+ query = { ...pathQuery, ...defaultQuery, ...query };
308
315
  }
309
316
 
310
317
  if (typeof query === 'object' && query && !Array.isArray(query)) {
311
- url.search = this.stringifyQuery(query as Record<string, unknown>);
318
+ url.search = this.stringifyQuery(query);
312
319
  }
313
320
 
314
321
  return url.toString();
@@ -492,7 +499,7 @@ export class Codeqr {
492
499
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
493
500
 
494
501
  const errText = await response.text().catch((err: any) => castToError(err).message);
495
- const errJSON = safeJSON(errText);
502
+ const errJSON = safeJSON(errText) as any;
496
503
  const errMessage = errJSON ? undefined : errText;
497
504
 
498
505
  loggerFor(this).debug(
@@ -533,9 +540,10 @@ export class Codeqr {
533
540
  controller: AbortController,
534
541
  ): Promise<Response> {
535
542
  const { signal, method, ...options } = init || {};
536
- if (signal) signal.addEventListener('abort', () => controller.abort());
543
+ const abort = this._makeAbort(controller);
544
+ if (signal) signal.addEventListener('abort', abort, { once: true });
537
545
 
538
- const timeout = setTimeout(() => controller.abort(), ms);
546
+ const timeout = setTimeout(abort, ms);
539
547
 
540
548
  const isReadableBody =
541
549
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -612,9 +620,9 @@ export class Codeqr {
612
620
  }
613
621
  }
614
622
 
615
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
616
- // just do what it says, but otherwise calculate a default
617
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
623
+ // If the API asks us to wait a certain amount of time, just do what it
624
+ // says, but otherwise calculate a default
625
+ if (timeoutMillis === undefined) {
618
626
  const maxRetries = options.maxRetries ?? this.maxRetries;
619
627
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
620
628
  }
@@ -702,11 +710,25 @@ export class Codeqr {
702
710
  return headers.values;
703
711
  }
704
712
 
705
- private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
713
+ private _makeAbort(controller: AbortController) {
714
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
715
+ // would capture all request options, and cause a memory leak.
716
+ return () => controller.abort();
717
+ }
718
+
719
+ private buildBody({ options }: { options: FinalRequestOptions }): {
706
720
  bodyHeaders: HeadersLike;
707
721
  body: BodyInit | undefined;
708
722
  } {
723
+ const { body, headers: rawHeaders } = options;
709
724
  if (!body) {
725
+ // A resource method always passes a `body` key when its operation defines a
726
+ // request body, even if the caller omitted an optional body param. Keep the
727
+ // content-type for those, and only elide it for operations with no body at
728
+ // all (e.g. GET/DELETE).
729
+ if (body == null && 'body' in options) {
730
+ return this.#encoder({ body, headers: buildHeaders([rawHeaders]) });
731
+ }
710
732
  return { bodyHeaders: undefined, body: undefined };
711
733
  }
712
734
  const headers = buildHeaders([rawHeaders]);
@@ -734,6 +756,14 @@ export class Codeqr {
734
756
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
735
757
  ) {
736
758
  return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
759
+ } else if (
760
+ typeof body === 'object' &&
761
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded'
762
+ ) {
763
+ return {
764
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
765
+ body: this.stringifyQuery(body),
766
+ };
737
767
  } else {
738
768
  return this.#encoder({ body, headers });
739
769
  }
@@ -785,13 +815,10 @@ export declare namespace Codeqr {
785
815
  type Link as Link,
786
816
  type LinkListResponse as LinkListResponse,
787
817
  type LinkDeleteResponse as LinkDeleteResponse,
788
- type LinkCountResponse as LinkCountResponse,
789
818
  type LinkCreateParams as LinkCreateParams,
790
- type LinkUpdateParams as LinkUpdateParams,
791
819
  type LinkListParams as LinkListParams,
792
- type LinkCountParams as LinkCountParams,
793
820
  type LinkRetrieveInfoParams as LinkRetrieveInfoParams,
794
- type LinkUpsertParams as LinkUpsertParams,
821
+ type LinkUpdateParams as LinkUpdateParams,
795
822
  };
796
823
 
797
824
  export {
@@ -799,13 +826,10 @@ export declare namespace Codeqr {
799
826
  type QrCode as QrCode,
800
827
  type QrcodeListResponse as QrcodeListResponse,
801
828
  type QrcodeDeleteResponse as QrcodeDeleteResponse,
802
- type QrcodeCountResponse as QrcodeCountResponse,
803
829
  type QrcodeCreateParams as QrcodeCreateParams,
830
+ type QrcodeListParams as QrcodeListParams,
804
831
  type QrcodeRetrieveParams as QrcodeRetrieveParams,
805
832
  type QrcodeUpdateParams as QrcodeUpdateParams,
806
- type QrcodeListParams as QrcodeListParams,
807
- type QrcodeCountParams as QrcodeCountParams,
808
- type QrcodeUpsertParams as QrcodeUpsertParams,
809
833
  };
810
834
 
811
835
  export {
@@ -828,8 +852,8 @@ export declare namespace Codeqr {
828
852
  type TagListResponse as TagListResponse,
829
853
  type TagDeleteResponse as TagDeleteResponse,
830
854
  type TagCreateParams as TagCreateParams,
831
- type TagUpdateParams as TagUpdateParams,
832
855
  type TagListParams as TagListParams,
856
+ type TagUpdateParams as TagUpdateParams,
833
857
  };
834
858
 
835
859
  export {
@@ -838,8 +862,8 @@ export declare namespace Codeqr {
838
862
  type DomainListResponse as DomainListResponse,
839
863
  type DomainDeleteResponse as DomainDeleteResponse,
840
864
  type DomainCreateParams as DomainCreateParams,
841
- type DomainUpdateParams as DomainUpdateParams,
842
865
  type DomainListParams as DomainListParams,
866
+ type DomainUpdateParams as DomainUpdateParams,
843
867
  };
844
868
 
845
869
  export {
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Codeqr, props: APIResponse
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -40,7 +40,6 @@ type OverloadedParameters<T> =
40
40
  : T extends (...args: infer A) => unknown ? A
41
41
  : never;
42
42
 
43
- /* eslint-disable */
44
43
  /**
45
44
  * These imports attempt to get types from a parent package's dependencies.
46
45
  * Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which
@@ -63,19 +62,18 @@ type OverloadedParameters<T> =
63
62
  *
64
63
  * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition
65
64
  */
66
- /** @ts-ignore For users with \@types/node */
65
+ /** @ts-ignore For users with \@types/node */ /* prettier-ignore */
67
66
  type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit>;
68
- /** @ts-ignore For users with undici */
67
+ /** @ts-ignore For users with undici */ /* prettier-ignore */
69
68
  type UndiciRequestInit = NotAny<import('../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici/index.d.ts').RequestInit>;
70
- /** @ts-ignore For users with \@types/bun */
69
+ /** @ts-ignore For users with \@types/bun */ /* prettier-ignore */
71
70
  type BunRequestInit = globalThis.FetchRequestInit;
72
- /** @ts-ignore For users with node-fetch@2 */
71
+ /** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */
73
72
  type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit>;
74
- /** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
73
+ /** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */
75
74
  type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
76
- /** @ts-ignore For users who use Deno */
75
+ /** @ts-ignore For users who use Deno */ /* prettier-ignore */
77
76
  type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
78
- /* eslint-enable */
79
77
 
80
78
  type RequestInits =
81
79
  | NotAny<UndiciTypesRequestInit>
@@ -9,10 +9,10 @@
9
9
  */
10
10
  export const readEnv = (env: string): string | undefined => {
11
11
  if (typeof (globalThis as any).process !== 'undefined') {
12
- return (globalThis as any).process.env?.[env]?.trim() ?? undefined;
12
+ return (globalThis as any).process.env?.[env]?.trim() || undefined;
13
13
  }
14
14
  if (typeof (globalThis as any).Deno !== 'undefined') {
15
- return (globalThis as any).Deno.env?.get?.(env)?.trim();
15
+ return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
16
16
  }
17
17
  return undefined;
18
18
  };
@@ -107,6 +107,8 @@ export const formatRequestDetails = (details: {
107
107
  name,
108
108
  (
109
109
  name.toLowerCase() === 'authorization' ||
110
+ name.toLowerCase() === 'api-key' ||
111
+ name.toLowerCase() === 'x-api-key' ||
110
112
  name.toLowerCase() === 'cookie' ||
111
113
  name.toLowerCase() === 'set-cookie'
112
114
  ) ?
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -322,7 +322,7 @@ export namespace AnalyticsRetrieveResponse {
322
322
  /**
323
323
  * The total number of views
324
324
  */
325
- viwes: number;
325
+ views: number;
326
326
  }
327
327
 
328
328
  export interface AnalyticsTimesery {
@@ -679,7 +679,7 @@ export namespace AnalyticsRetrieveResponse {
679
679
  clicks: number;
680
680
 
681
681
  /**
682
- * The 2-letter country code of the region: https://d.to/geo
682
+ * The 2-letter ISO 3166-1 alpha-2 country code of the region.
683
683
  */
684
684
  country:
685
685
  | 'AF'
@@ -1532,7 +1532,12 @@ export interface AnalyticsRetrieveParams {
1532
1532
  | 'cities'
1533
1533
  | 'leads'
1534
1534
  | 'sales'
1535
- | 'composite';
1535
+ | 'composite'
1536
+ | 'utm_sources'
1537
+ | 'utm_mediums'
1538
+ | 'utm_campaigns'
1539
+ | 'utm_contents'
1540
+ | 'utm_terms';
1536
1541
 
1537
1542
  /**
1538
1543
  * The interval to retrieve analytics for. Takes precedence over start and end.
@@ -1605,6 +1610,31 @@ export interface AnalyticsRetrieveParams {
1605
1610
  * The URL to retrieve analytics for.
1606
1611
  */
1607
1612
  url?: string;
1613
+
1614
+ /**
1615
+ * UTM campaign to filter analytics by.
1616
+ */
1617
+ utm_campaign?: string;
1618
+
1619
+ /**
1620
+ * UTM content to filter analytics by.
1621
+ */
1622
+ utm_content?: string;
1623
+
1624
+ /**
1625
+ * UTM medium to filter analytics by.
1626
+ */
1627
+ utm_medium?: string;
1628
+
1629
+ /**
1630
+ * UTM source to filter analytics by.
1631
+ */
1632
+ utm_source?: string;
1633
+
1634
+ /**
1635
+ * UTM term to filter analytics by.
1636
+ */
1637
+ utm_term?: string;
1608
1638
  }
1609
1639
 
1610
1640
  export declare namespace Analytics {
@@ -21,34 +21,34 @@ export class Domains extends APIResource {
21
21
  }
22
22
 
23
23
  /**
24
- * Update a domain for the authenticated workspace.
24
+ * Retrieve a list of domains associated with the authenticated workspace.
25
25
  *
26
26
  * @example
27
27
  * ```ts
28
- * const domain = await client.domains.update('acme.com');
28
+ * const domains = await client.domains.list();
29
29
  * ```
30
30
  */
31
- update(
32
- pathSlug: string,
33
- body: DomainUpdateParams | null | undefined = {},
31
+ list(
32
+ query: DomainListParams | null | undefined = {},
34
33
  options?: RequestOptions,
35
- ): APIPromise<Domain> {
36
- return this._client.patch(path`/domains/${pathSlug}`, { body, ...options });
34
+ ): APIPromise<DomainListResponse> {
35
+ return this._client.get('/domains', { query, ...options });
37
36
  }
38
37
 
39
38
  /**
40
- * Retrieve a list of domains associated with the authenticated workspace.
39
+ * Update a domain for the authenticated workspace.
41
40
  *
42
41
  * @example
43
42
  * ```ts
44
- * const domains = await client.domains.list();
43
+ * const domain = await client.domains.update('acme.com');
45
44
  * ```
46
45
  */
47
- list(
48
- query: DomainListParams | null | undefined = {},
46
+ update(
47
+ slug: string,
48
+ body: DomainUpdateParams | null | undefined = {},
49
49
  options?: RequestOptions,
50
- ): APIPromise<DomainListResponse> {
51
- return this._client.get('/domains', { query, ...options });
50
+ ): APIPromise<Domain> {
51
+ return this._client.patch(path`/domains/${slug}`, { body, ...options });
52
52
  }
53
53
 
54
54
  /**
@@ -166,6 +166,29 @@ export interface DomainCreateParams {
166
166
  type?: 'redirect' | 'rewrite';
167
167
  }
168
168
 
169
+ export interface DomainListParams {
170
+ /**
171
+ * Whether to include archived domains in the response. Defaults to `false` if not
172
+ * provided.
173
+ */
174
+ archived?: boolean;
175
+
176
+ /**
177
+ * The page number for pagination.
178
+ */
179
+ page?: number;
180
+
181
+ /**
182
+ * The number of items per page.
183
+ */
184
+ pageSize?: number;
185
+
186
+ /**
187
+ * The search term to filter the domains by.
188
+ */
189
+ search?: string;
190
+ }
191
+
169
192
  export interface DomainUpdateParams {
170
193
  /**
171
194
  * Whether to archive this domain. `false` will unarchive a previously archived
@@ -187,7 +210,7 @@ export interface DomainUpdateParams {
187
210
  /**
188
211
  * Name of the domain.
189
212
  */
190
- body_slug?: string;
213
+ slug?: string;
191
214
 
192
215
  /**
193
216
  * The target URL to redirect to when accessing the domain root.
@@ -200,36 +223,13 @@ export interface DomainUpdateParams {
200
223
  type?: 'redirect' | 'rewrite';
201
224
  }
202
225
 
203
- export interface DomainListParams {
204
- /**
205
- * Whether to include archived domains in the response. Defaults to `false` if not
206
- * provided.
207
- */
208
- archived?: boolean;
209
-
210
- /**
211
- * The page number for pagination.
212
- */
213
- page?: number;
214
-
215
- /**
216
- * The number of items per page.
217
- */
218
- pageSize?: number;
219
-
220
- /**
221
- * The search term to filter the domains by.
222
- */
223
- search?: string;
224
- }
225
-
226
226
  export declare namespace Domains {
227
227
  export {
228
228
  type Domain as Domain,
229
229
  type DomainListResponse as DomainListResponse,
230
230
  type DomainDeleteResponse as DomainDeleteResponse,
231
231
  type DomainCreateParams as DomainCreateParams,
232
- type DomainUpdateParams as DomainUpdateParams,
233
232
  type DomainListParams as DomainListParams,
233
+ type DomainUpdateParams as DomainUpdateParams,
234
234
  };
235
235
  }