dub 0.44.0 → 0.45.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 (263) hide show
  1. package/README.md +16 -45
  2. package/dist/commonjs/funcs/analyticsRetrieve.d.ts.map +1 -1
  3. package/dist/commonjs/funcs/analyticsRetrieve.js +9 -4
  4. package/dist/commonjs/funcs/analyticsRetrieve.js.map +1 -1
  5. package/dist/commonjs/funcs/domainsCreate.d.ts.map +1 -1
  6. package/dist/commonjs/funcs/domainsCreate.js +8 -4
  7. package/dist/commonjs/funcs/domainsCreate.js.map +1 -1
  8. package/dist/commonjs/funcs/domainsDelete.d.ts.map +1 -1
  9. package/dist/commonjs/funcs/domainsDelete.js +8 -4
  10. package/dist/commonjs/funcs/domainsDelete.js.map +1 -1
  11. package/dist/commonjs/funcs/domainsList.d.ts.map +1 -1
  12. package/dist/commonjs/funcs/domainsList.js +8 -4
  13. package/dist/commonjs/funcs/domainsList.js.map +1 -1
  14. package/dist/commonjs/funcs/domainsUpdate.d.ts.map +1 -1
  15. package/dist/commonjs/funcs/domainsUpdate.js +8 -4
  16. package/dist/commonjs/funcs/domainsUpdate.js.map +1 -1
  17. package/dist/commonjs/funcs/eventsList.d.ts.map +1 -1
  18. package/dist/commonjs/funcs/eventsList.js +9 -4
  19. package/dist/commonjs/funcs/eventsList.js.map +1 -1
  20. package/dist/commonjs/funcs/linksCount.d.ts.map +1 -1
  21. package/dist/commonjs/funcs/linksCount.js +8 -4
  22. package/dist/commonjs/funcs/linksCount.js.map +1 -1
  23. package/dist/commonjs/funcs/linksCreate.d.ts.map +1 -1
  24. package/dist/commonjs/funcs/linksCreate.js +8 -4
  25. package/dist/commonjs/funcs/linksCreate.js.map +1 -1
  26. package/dist/commonjs/funcs/linksCreateMany.d.ts.map +1 -1
  27. package/dist/commonjs/funcs/linksCreateMany.js +8 -4
  28. package/dist/commonjs/funcs/linksCreateMany.js.map +1 -1
  29. package/dist/commonjs/funcs/linksDelete.d.ts.map +1 -1
  30. package/dist/commonjs/funcs/linksDelete.js +8 -4
  31. package/dist/commonjs/funcs/linksDelete.js.map +1 -1
  32. package/dist/commonjs/funcs/linksDeleteMany.d.ts.map +1 -1
  33. package/dist/commonjs/funcs/linksDeleteMany.js +8 -4
  34. package/dist/commonjs/funcs/linksDeleteMany.js.map +1 -1
  35. package/dist/commonjs/funcs/linksGet.d.ts.map +1 -1
  36. package/dist/commonjs/funcs/linksGet.js +8 -4
  37. package/dist/commonjs/funcs/linksGet.js.map +1 -1
  38. package/dist/commonjs/funcs/linksList.d.ts.map +1 -1
  39. package/dist/commonjs/funcs/linksList.js +8 -4
  40. package/dist/commonjs/funcs/linksList.js.map +1 -1
  41. package/dist/commonjs/funcs/linksUpdate.d.ts.map +1 -1
  42. package/dist/commonjs/funcs/linksUpdate.js +8 -4
  43. package/dist/commonjs/funcs/linksUpdate.js.map +1 -1
  44. package/dist/commonjs/funcs/linksUpdateMany.d.ts.map +1 -1
  45. package/dist/commonjs/funcs/linksUpdateMany.js +8 -4
  46. package/dist/commonjs/funcs/linksUpdateMany.js.map +1 -1
  47. package/dist/commonjs/funcs/linksUpsert.d.ts.map +1 -1
  48. package/dist/commonjs/funcs/linksUpsert.js +8 -4
  49. package/dist/commonjs/funcs/linksUpsert.js.map +1 -1
  50. package/dist/commonjs/funcs/metatagsGet.d.ts.map +1 -1
  51. package/dist/commonjs/funcs/metatagsGet.js +8 -4
  52. package/dist/commonjs/funcs/metatagsGet.js.map +1 -1
  53. package/dist/commonjs/funcs/qrCodesGet.d.ts.map +1 -1
  54. package/dist/commonjs/funcs/qrCodesGet.js +8 -4
  55. package/dist/commonjs/funcs/qrCodesGet.js.map +1 -1
  56. package/dist/commonjs/funcs/tagsCreate.d.ts.map +1 -1
  57. package/dist/commonjs/funcs/tagsCreate.js +8 -4
  58. package/dist/commonjs/funcs/tagsCreate.js.map +1 -1
  59. package/dist/commonjs/funcs/tagsDelete.d.ts.map +1 -1
  60. package/dist/commonjs/funcs/tagsDelete.js +8 -4
  61. package/dist/commonjs/funcs/tagsDelete.js.map +1 -1
  62. package/dist/commonjs/funcs/tagsList.d.ts.map +1 -1
  63. package/dist/commonjs/funcs/tagsList.js +8 -4
  64. package/dist/commonjs/funcs/tagsList.js.map +1 -1
  65. package/dist/commonjs/funcs/tagsUpdate.d.ts.map +1 -1
  66. package/dist/commonjs/funcs/tagsUpdate.js +8 -4
  67. package/dist/commonjs/funcs/tagsUpdate.js.map +1 -1
  68. package/dist/commonjs/funcs/trackCustomer.d.ts.map +1 -1
  69. package/dist/commonjs/funcs/trackCustomer.js +8 -4
  70. package/dist/commonjs/funcs/trackCustomer.js.map +1 -1
  71. package/dist/commonjs/funcs/trackLead.d.ts.map +1 -1
  72. package/dist/commonjs/funcs/trackLead.js +8 -4
  73. package/dist/commonjs/funcs/trackLead.js.map +1 -1
  74. package/dist/commonjs/funcs/trackSale.d.ts.map +1 -1
  75. package/dist/commonjs/funcs/trackSale.js +8 -4
  76. package/dist/commonjs/funcs/trackSale.js.map +1 -1
  77. package/dist/commonjs/funcs/workspacesGet.d.ts.map +1 -1
  78. package/dist/commonjs/funcs/workspacesGet.js +8 -4
  79. package/dist/commonjs/funcs/workspacesGet.js.map +1 -1
  80. package/dist/commonjs/funcs/workspacesUpdate.d.ts.map +1 -1
  81. package/dist/commonjs/funcs/workspacesUpdate.js +8 -4
  82. package/dist/commonjs/funcs/workspacesUpdate.js.map +1 -1
  83. package/dist/commonjs/hooks/types.d.ts +4 -0
  84. package/dist/commonjs/hooks/types.d.ts.map +1 -1
  85. package/dist/commonjs/lib/config.d.ts +3 -3
  86. package/dist/commonjs/lib/config.js +3 -3
  87. package/dist/commonjs/lib/config.js.map +1 -1
  88. package/dist/commonjs/lib/primitives.d.ts +4 -0
  89. package/dist/commonjs/lib/primitives.d.ts.map +1 -1
  90. package/dist/commonjs/lib/primitives.js +13 -1
  91. package/dist/commonjs/lib/primitives.js.map +1 -1
  92. package/dist/commonjs/lib/retries.d.ts +20 -0
  93. package/dist/commonjs/lib/retries.d.ts.map +1 -1
  94. package/dist/commonjs/lib/retries.js +51 -27
  95. package/dist/commonjs/lib/retries.js.map +1 -1
  96. package/dist/commonjs/lib/sdks.d.ts +2 -2
  97. package/dist/commonjs/lib/sdks.d.ts.map +1 -1
  98. package/dist/commonjs/lib/sdks.js +14 -12
  99. package/dist/commonjs/lib/sdks.js.map +1 -1
  100. package/dist/commonjs/lib/security.d.ts +20 -1
  101. package/dist/commonjs/lib/security.d.ts.map +1 -1
  102. package/dist/commonjs/lib/security.js +11 -1
  103. package/dist/commonjs/lib/security.js.map +1 -1
  104. package/dist/commonjs/models/operations/getlinks.d.ts +1 -1
  105. package/dist/commonjs/models/operations/getlinkscount.d.ts +1 -1
  106. package/dist/commonjs/models/operations/listevents.d.ts +28 -1
  107. package/dist/commonjs/models/operations/listevents.d.ts.map +1 -1
  108. package/dist/commonjs/models/operations/listevents.js +18 -1
  109. package/dist/commonjs/models/operations/listevents.js.map +1 -1
  110. package/dist/commonjs/models/operations/retrieveanalytics.d.ts +28 -1
  111. package/dist/commonjs/models/operations/retrieveanalytics.d.ts.map +1 -1
  112. package/dist/commonjs/models/operations/retrieveanalytics.js +18 -1
  113. package/dist/commonjs/models/operations/retrieveanalytics.js.map +1 -1
  114. package/dist/esm/funcs/analyticsRetrieve.d.ts.map +1 -1
  115. package/dist/esm/funcs/analyticsRetrieve.js +9 -4
  116. package/dist/esm/funcs/analyticsRetrieve.js.map +1 -1
  117. package/dist/esm/funcs/domainsCreate.d.ts.map +1 -1
  118. package/dist/esm/funcs/domainsCreate.js +8 -4
  119. package/dist/esm/funcs/domainsCreate.js.map +1 -1
  120. package/dist/esm/funcs/domainsDelete.d.ts.map +1 -1
  121. package/dist/esm/funcs/domainsDelete.js +8 -4
  122. package/dist/esm/funcs/domainsDelete.js.map +1 -1
  123. package/dist/esm/funcs/domainsList.d.ts.map +1 -1
  124. package/dist/esm/funcs/domainsList.js +8 -4
  125. package/dist/esm/funcs/domainsList.js.map +1 -1
  126. package/dist/esm/funcs/domainsUpdate.d.ts.map +1 -1
  127. package/dist/esm/funcs/domainsUpdate.js +8 -4
  128. package/dist/esm/funcs/domainsUpdate.js.map +1 -1
  129. package/dist/esm/funcs/eventsList.d.ts.map +1 -1
  130. package/dist/esm/funcs/eventsList.js +9 -4
  131. package/dist/esm/funcs/eventsList.js.map +1 -1
  132. package/dist/esm/funcs/linksCount.d.ts.map +1 -1
  133. package/dist/esm/funcs/linksCount.js +8 -4
  134. package/dist/esm/funcs/linksCount.js.map +1 -1
  135. package/dist/esm/funcs/linksCreate.d.ts.map +1 -1
  136. package/dist/esm/funcs/linksCreate.js +8 -4
  137. package/dist/esm/funcs/linksCreate.js.map +1 -1
  138. package/dist/esm/funcs/linksCreateMany.d.ts.map +1 -1
  139. package/dist/esm/funcs/linksCreateMany.js +8 -4
  140. package/dist/esm/funcs/linksCreateMany.js.map +1 -1
  141. package/dist/esm/funcs/linksDelete.d.ts.map +1 -1
  142. package/dist/esm/funcs/linksDelete.js +8 -4
  143. package/dist/esm/funcs/linksDelete.js.map +1 -1
  144. package/dist/esm/funcs/linksDeleteMany.d.ts.map +1 -1
  145. package/dist/esm/funcs/linksDeleteMany.js +8 -4
  146. package/dist/esm/funcs/linksDeleteMany.js.map +1 -1
  147. package/dist/esm/funcs/linksGet.d.ts.map +1 -1
  148. package/dist/esm/funcs/linksGet.js +8 -4
  149. package/dist/esm/funcs/linksGet.js.map +1 -1
  150. package/dist/esm/funcs/linksList.d.ts.map +1 -1
  151. package/dist/esm/funcs/linksList.js +8 -4
  152. package/dist/esm/funcs/linksList.js.map +1 -1
  153. package/dist/esm/funcs/linksUpdate.d.ts.map +1 -1
  154. package/dist/esm/funcs/linksUpdate.js +8 -4
  155. package/dist/esm/funcs/linksUpdate.js.map +1 -1
  156. package/dist/esm/funcs/linksUpdateMany.d.ts.map +1 -1
  157. package/dist/esm/funcs/linksUpdateMany.js +8 -4
  158. package/dist/esm/funcs/linksUpdateMany.js.map +1 -1
  159. package/dist/esm/funcs/linksUpsert.d.ts.map +1 -1
  160. package/dist/esm/funcs/linksUpsert.js +8 -4
  161. package/dist/esm/funcs/linksUpsert.js.map +1 -1
  162. package/dist/esm/funcs/metatagsGet.d.ts.map +1 -1
  163. package/dist/esm/funcs/metatagsGet.js +8 -4
  164. package/dist/esm/funcs/metatagsGet.js.map +1 -1
  165. package/dist/esm/funcs/qrCodesGet.d.ts.map +1 -1
  166. package/dist/esm/funcs/qrCodesGet.js +8 -4
  167. package/dist/esm/funcs/qrCodesGet.js.map +1 -1
  168. package/dist/esm/funcs/tagsCreate.d.ts.map +1 -1
  169. package/dist/esm/funcs/tagsCreate.js +8 -4
  170. package/dist/esm/funcs/tagsCreate.js.map +1 -1
  171. package/dist/esm/funcs/tagsDelete.d.ts.map +1 -1
  172. package/dist/esm/funcs/tagsDelete.js +8 -4
  173. package/dist/esm/funcs/tagsDelete.js.map +1 -1
  174. package/dist/esm/funcs/tagsList.d.ts.map +1 -1
  175. package/dist/esm/funcs/tagsList.js +8 -4
  176. package/dist/esm/funcs/tagsList.js.map +1 -1
  177. package/dist/esm/funcs/tagsUpdate.d.ts.map +1 -1
  178. package/dist/esm/funcs/tagsUpdate.js +8 -4
  179. package/dist/esm/funcs/tagsUpdate.js.map +1 -1
  180. package/dist/esm/funcs/trackCustomer.d.ts.map +1 -1
  181. package/dist/esm/funcs/trackCustomer.js +8 -4
  182. package/dist/esm/funcs/trackCustomer.js.map +1 -1
  183. package/dist/esm/funcs/trackLead.d.ts.map +1 -1
  184. package/dist/esm/funcs/trackLead.js +8 -4
  185. package/dist/esm/funcs/trackLead.js.map +1 -1
  186. package/dist/esm/funcs/trackSale.d.ts.map +1 -1
  187. package/dist/esm/funcs/trackSale.js +8 -4
  188. package/dist/esm/funcs/trackSale.js.map +1 -1
  189. package/dist/esm/funcs/workspacesGet.d.ts.map +1 -1
  190. package/dist/esm/funcs/workspacesGet.js +8 -4
  191. package/dist/esm/funcs/workspacesGet.js.map +1 -1
  192. package/dist/esm/funcs/workspacesUpdate.d.ts.map +1 -1
  193. package/dist/esm/funcs/workspacesUpdate.js +8 -4
  194. package/dist/esm/funcs/workspacesUpdate.js.map +1 -1
  195. package/dist/esm/hooks/types.d.ts +4 -0
  196. package/dist/esm/hooks/types.d.ts.map +1 -1
  197. package/dist/esm/lib/config.d.ts +3 -3
  198. package/dist/esm/lib/config.js +3 -3
  199. package/dist/esm/lib/config.js.map +1 -1
  200. package/dist/esm/lib/primitives.d.ts +4 -0
  201. package/dist/esm/lib/primitives.d.ts.map +1 -1
  202. package/dist/esm/lib/primitives.js +11 -0
  203. package/dist/esm/lib/primitives.js.map +1 -1
  204. package/dist/esm/lib/retries.d.ts +20 -0
  205. package/dist/esm/lib/retries.d.ts.map +1 -1
  206. package/dist/esm/lib/retries.js +50 -28
  207. package/dist/esm/lib/retries.js.map +1 -1
  208. package/dist/esm/lib/sdks.d.ts +2 -2
  209. package/dist/esm/lib/sdks.d.ts.map +1 -1
  210. package/dist/esm/lib/sdks.js +14 -12
  211. package/dist/esm/lib/sdks.js.map +1 -1
  212. package/dist/esm/lib/security.d.ts +20 -1
  213. package/dist/esm/lib/security.d.ts.map +1 -1
  214. package/dist/esm/lib/security.js +11 -1
  215. package/dist/esm/lib/security.js.map +1 -1
  216. package/dist/esm/models/operations/getlinks.d.ts +1 -1
  217. package/dist/esm/models/operations/getlinkscount.d.ts +1 -1
  218. package/dist/esm/models/operations/listevents.d.ts +28 -1
  219. package/dist/esm/models/operations/listevents.d.ts.map +1 -1
  220. package/dist/esm/models/operations/listevents.js +17 -0
  221. package/dist/esm/models/operations/listevents.js.map +1 -1
  222. package/dist/esm/models/operations/retrieveanalytics.d.ts +28 -1
  223. package/dist/esm/models/operations/retrieveanalytics.d.ts.map +1 -1
  224. package/dist/esm/models/operations/retrieveanalytics.js +17 -0
  225. package/dist/esm/models/operations/retrieveanalytics.js.map +1 -1
  226. package/package.json +1 -1
  227. package/src/funcs/analyticsRetrieve.ts +12 -4
  228. package/src/funcs/domainsCreate.ts +11 -4
  229. package/src/funcs/domainsDelete.ts +11 -4
  230. package/src/funcs/domainsList.ts +11 -4
  231. package/src/funcs/domainsUpdate.ts +11 -4
  232. package/src/funcs/eventsList.ts +12 -4
  233. package/src/funcs/linksCount.ts +11 -4
  234. package/src/funcs/linksCreate.ts +11 -4
  235. package/src/funcs/linksCreateMany.ts +11 -4
  236. package/src/funcs/linksDelete.ts +11 -4
  237. package/src/funcs/linksDeleteMany.ts +11 -4
  238. package/src/funcs/linksGet.ts +11 -4
  239. package/src/funcs/linksList.ts +11 -4
  240. package/src/funcs/linksUpdate.ts +11 -4
  241. package/src/funcs/linksUpdateMany.ts +11 -4
  242. package/src/funcs/linksUpsert.ts +11 -4
  243. package/src/funcs/metatagsGet.ts +11 -4
  244. package/src/funcs/qrCodesGet.ts +11 -4
  245. package/src/funcs/tagsCreate.ts +11 -4
  246. package/src/funcs/tagsDelete.ts +11 -4
  247. package/src/funcs/tagsList.ts +11 -4
  248. package/src/funcs/tagsUpdate.ts +11 -4
  249. package/src/funcs/trackCustomer.ts +11 -4
  250. package/src/funcs/trackLead.ts +11 -4
  251. package/src/funcs/trackSale.ts +11 -4
  252. package/src/funcs/workspacesGet.ts +11 -4
  253. package/src/funcs/workspacesUpdate.ts +11 -4
  254. package/src/hooks/types.ts +4 -0
  255. package/src/lib/config.ts +3 -3
  256. package/src/lib/primitives.ts +20 -0
  257. package/src/lib/retries.ts +63 -31
  258. package/src/lib/sdks.ts +19 -15
  259. package/src/lib/security.ts +39 -3
  260. package/src/models/operations/getlinks.ts +1 -1
  261. package/src/models/operations/getlinkscount.ts +1 -1
  262. package/src/models/operations/listevents.ts +43 -1
  263. package/src/models/operations/retrieveanalytics.ts +44 -1
@@ -80,12 +80,20 @@ export async function workspacesGet(
80
80
 
81
81
  const secConfig = await extractSecurity(client._options.token);
82
82
  const securityInput = secConfig == null ? {} : { token: secConfig };
83
+ const requestSecurity = resolveGlobalSecurity(securityInput);
84
+
83
85
  const context = {
84
86
  operationID: "getWorkspace",
85
87
  oAuth2Scopes: [],
88
+
89
+ resolvedSecurity: requestSecurity,
90
+
86
91
  securitySource: client._options.token,
92
+ retryConfig: options?.retries
93
+ || client._options.retryConfig
94
+ || { strategy: "none" },
95
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
87
96
  };
88
- const requestSecurity = resolveGlobalSecurity(securityInput);
89
97
 
90
98
  const requestRes = client._createRequest(context, {
91
99
  security: requestSecurity,
@@ -115,9 +123,8 @@ export async function workspacesGet(
115
123
  "500",
116
124
  "5XX",
117
125
  ],
118
- retryConfig: options?.retries
119
- || client._options.retryConfig,
120
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
126
+ retryConfig: context.retryConfig,
127
+ retryCodes: context.retryCodes,
121
128
  });
122
129
  if (!doResult.ok) {
123
130
  return doResult;
@@ -87,12 +87,20 @@ export async function workspacesUpdate(
87
87
 
88
88
  const secConfig = await extractSecurity(client._options.token);
89
89
  const securityInput = secConfig == null ? {} : { token: secConfig };
90
+ const requestSecurity = resolveGlobalSecurity(securityInput);
91
+
90
92
  const context = {
91
93
  operationID: "updateWorkspace",
92
94
  oAuth2Scopes: [],
95
+
96
+ resolvedSecurity: requestSecurity,
97
+
93
98
  securitySource: client._options.token,
99
+ retryConfig: options?.retries
100
+ || client._options.retryConfig
101
+ || { strategy: "none" },
102
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
94
103
  };
95
- const requestSecurity = resolveGlobalSecurity(securityInput);
96
104
 
97
105
  const requestRes = client._createRequest(context, {
98
106
  security: requestSecurity,
@@ -122,9 +130,8 @@ export async function workspacesUpdate(
122
130
  "500",
123
131
  "5XX",
124
132
  ],
125
- retryConfig: options?.retries
126
- || client._options.retryConfig,
127
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
133
+ retryConfig: context.retryConfig,
134
+ retryCodes: context.retryCodes,
128
135
  });
129
136
  if (!doResult.ok) {
130
137
  return doResult;
@@ -3,11 +3,15 @@
3
3
  */
4
4
 
5
5
  import { HTTPClient, RequestInput } from "../lib/http.js";
6
+ import { RetryConfig } from "../lib/retries.js";
7
+ import { SecurityState } from "../lib/security.js";
6
8
 
7
9
  export type HookContext = {
8
10
  operationID: string;
9
11
  oAuth2Scopes?: string[];
10
12
  securitySource?: any | (() => Promise<any>);
13
+ retryConfig: RetryConfig;
14
+ resolvedSecurity: SecurityState | null;
11
15
  };
12
16
 
13
17
  export type Awaitable<T> = T | Promise<T>;
package/src/lib/config.ts CHANGED
@@ -57,7 +57,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
57
57
  export const SDK_METADATA = {
58
58
  language: "typescript",
59
59
  openapiDocVersion: "0.0.1",
60
- sdkVersion: "0.44.0",
61
- genVersion: "2.442.11",
62
- userAgent: "speakeasy-sdk/typescript 0.44.0 2.442.11 0.0.1 dub",
60
+ sdkVersion: "0.45.0",
61
+ genVersion: "2.457.2",
62
+ userAgent: "speakeasy-sdk/typescript 0.45.0 2.457.2 0.0.1 dub",
63
63
  } as const;
@@ -2,6 +2,26 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
+ class InvariantError extends Error {
6
+ constructor(message: string) {
7
+ super(message);
8
+ this.name = "InvariantError";
9
+ }
10
+ }
11
+
12
+ export function invariant(
13
+ condition: unknown,
14
+ message: string,
15
+ ): asserts condition {
16
+ if (!condition) {
17
+ throw new InvariantError(message);
18
+ }
19
+ }
20
+
21
+ export type ExactPartial<T> = {
22
+ [P in keyof T]?: T[P] | undefined;
23
+ };
24
+
5
25
  export type Remap<Inp, Mapping extends { [k in keyof Inp]?: string | null }> = {
6
26
  [k in keyof Inp as Mapping[k] extends string /* if we have a string mapping for this key then use it */
7
27
  ? Mapping[k]
@@ -26,23 +26,44 @@ export type RetryConfig =
26
26
  retryConnectionErrors?: boolean;
27
27
  };
28
28
 
29
- class PermanentError extends Error {
30
- inner: unknown;
29
+ /**
30
+ * PermanentError is an error that is not recoverable. Throwing this error will
31
+ * cause a retry loop to terminate.
32
+ */
33
+ export class PermanentError extends Error {
34
+ /** The underlying cause of the error. */
35
+ override readonly cause: unknown;
36
+
37
+ constructor(message: string, options?: { cause?: unknown }) {
38
+ let msg = message;
39
+ if (options?.cause) {
40
+ msg += `: ${options.cause}`;
41
+ }
31
42
 
32
- constructor(inner: unknown) {
33
- super("Permanent error");
34
- this.inner = inner;
43
+ super(msg, options);
44
+ this.name = "PermanentError";
45
+ // In older runtimes, the cause field would not have been assigned through
46
+ // the super() call.
47
+ if (typeof this.cause === "undefined") {
48
+ this.cause = options?.cause;
49
+ }
35
50
 
36
51
  Object.setPrototypeOf(this, PermanentError.prototype);
37
52
  }
38
53
  }
39
54
 
40
- class TemporaryError extends Error {
41
- res: Response;
55
+ /**
56
+ * TemporaryError is an error is used to signal that an HTTP request can be
57
+ * retried as part of a retry loop. If retry attempts are exhausted and this
58
+ * error is thrown, the response will be returned to the caller.
59
+ */
60
+ export class TemporaryError extends Error {
61
+ response: Response;
42
62
 
43
- constructor(res: Response) {
44
- super("Temporary error");
45
- this.res = res;
63
+ constructor(message: string, response: Response) {
64
+ super(message);
65
+ this.response = response;
66
+ this.name = "TemporaryError";
46
67
 
47
68
  Object.setPrototypeOf(this, TemporaryError.prototype);
48
69
  }
@@ -80,11 +101,14 @@ function wrapFetcher(
80
101
  try {
81
102
  const res = await fn();
82
103
  if (isRetryableResponse(res, options.statusCodes)) {
83
- throw new TemporaryError(res);
104
+ throw new TemporaryError(
105
+ "Response failed with retryable status code",
106
+ res,
107
+ );
84
108
  }
85
109
 
86
110
  return res;
87
- } catch (err) {
111
+ } catch (err: unknown) {
88
112
  if (err instanceof TemporaryError) {
89
113
  throw err;
90
114
  }
@@ -96,7 +120,7 @@ function wrapFetcher(
96
120
  throw err;
97
121
  }
98
122
 
99
- throw new PermanentError(err);
123
+ throw new PermanentError("Permanent error", { cause: err });
100
124
  }
101
125
  };
102
126
  }
@@ -139,37 +163,25 @@ async function retryBackoff(
139
163
  try {
140
164
  const res = await fn();
141
165
  return res;
142
- } catch (err) {
166
+ } catch (err: unknown) {
143
167
  if (err instanceof PermanentError) {
144
- throw err.inner;
168
+ throw err.cause;
145
169
  }
146
170
  const elapsed = Date.now() - start;
147
171
  if (elapsed > maxElapsedTime) {
148
172
  if (err instanceof TemporaryError) {
149
- return err.res;
173
+ return err.response;
150
174
  }
151
175
 
152
176
  throw err;
153
177
  }
154
178
 
155
179
  let retryInterval = 0;
156
- if (err instanceof TemporaryError && err.res && err.res.headers) {
157
- const retryVal = err.res.headers.get("retry-after") || "";
158
- if (retryVal != "") {
159
- const parsedNumber = Number(retryVal);
160
- if (!isNaN(parsedNumber) && Number.isInteger(parsedNumber)) {
161
- retryInterval = parsedNumber * 1000;
162
- } else {
163
- const parsedDate = Date.parse(retryVal);
164
- if (!isNaN(parsedDate)) {
165
- const deltaMS = parsedDate - Date.now();
166
- retryInterval = deltaMS > 0 ? Math.ceil(deltaMS) : 0;
167
- }
168
- }
169
- }
180
+ if (err instanceof TemporaryError) {
181
+ retryInterval = retryIntervalFromResponse(err.response);
170
182
  }
171
183
 
172
- if (retryInterval == 0) {
184
+ if (retryInterval <= 0) {
173
185
  retryInterval =
174
186
  initialInterval * Math.pow(x, exponent) + Math.random() * 1000;
175
187
  }
@@ -182,6 +194,26 @@ async function retryBackoff(
182
194
  }
183
195
  }
184
196
 
197
+ function retryIntervalFromResponse(res: Response): number {
198
+ const retryVal = res.headers.get("retry-after") || "";
199
+ if (!retryVal) {
200
+ return 0;
201
+ }
202
+
203
+ const parsedNumber = Number(retryVal);
204
+ if (Number.isInteger(parsedNumber)) {
205
+ return parsedNumber * 1000;
206
+ }
207
+
208
+ const parsedDate = Date.parse(retryVal);
209
+ if (Number.isInteger(parsedDate)) {
210
+ const deltaMS = parsedDate - Date.now();
211
+ return deltaMS > 0 ? Math.ceil(deltaMS) : 0;
212
+ }
213
+
214
+ return 0;
215
+ }
216
+
185
217
  async function delay(delay: number): Promise<void> {
186
218
  return new Promise((resolve) => setTimeout(resolve, delay));
187
219
  }
package/src/lib/sdks.ts CHANGED
@@ -220,8 +220,8 @@ export class ClientSDK {
220
220
  options: {
221
221
  context: HookContext;
222
222
  errorCodes: number | string | (number | string)[];
223
- retryConfig?: RetryConfig | undefined;
224
- retryCodes?: string[] | undefined;
223
+ retryConfig: RetryConfig;
224
+ retryCodes: string[];
225
225
  },
226
226
  ): Promise<
227
227
  Result<
@@ -233,8 +233,6 @@ export class ClientSDK {
233
233
  >
234
234
  > {
235
235
  const { context, errorCodes } = options;
236
- const retryConfig = options.retryConfig || { strategy: "none" };
237
- const retryCodes = options.retryCodes || [];
238
236
 
239
237
  return retry(
240
238
  async () => {
@@ -245,22 +243,28 @@ export class ClientSDK {
245
243
 
246
244
  let response = await this.#httpClient.request(req);
247
245
 
248
- if (matchStatusCode(response, errorCodes)) {
249
- const result = await this.#hooks.afterError(context, response, null);
250
- if (result.error) {
251
- throw result.error;
246
+ try {
247
+ if (matchStatusCode(response, errorCodes)) {
248
+ const result = await this.#hooks.afterError(
249
+ context,
250
+ response,
251
+ null,
252
+ );
253
+ if (result.error) {
254
+ throw result.error;
255
+ }
256
+ response = result.response || response;
257
+ } else {
258
+ response = await this.#hooks.afterSuccess(context, response);
252
259
  }
253
- response = result.response || response;
254
- } else {
255
- response = await this.#hooks.afterSuccess(context, response);
260
+ } finally {
261
+ await logResponse(this.#logger, response, req)
262
+ .catch(e => this.#logger?.log("Failed to log response:", e));
256
263
  }
257
264
 
258
- await logResponse(this.#logger, response, req)
259
- .catch(e => this.#logger?.log("Failed to log response:", e));
260
-
261
265
  return response;
262
266
  },
263
- { config: retryConfig, statusCodes: retryCodes },
267
+ { config: options.retryConfig, statusCodes: options.retryCodes },
264
268
  ).then(
265
269
  (r) => OK(r),
266
270
  (err) => {
@@ -4,6 +4,14 @@
4
4
 
5
5
  import * as components from "../models/components/index.js";
6
6
 
7
+ type OAuth2PasswordFlow = {
8
+ username: string;
9
+ password?: string | undefined;
10
+ clientID: string;
11
+ clientSecret?: string | undefined;
12
+ tokenURL: string;
13
+ };
14
+
7
15
  export enum SecurityErrorCode {
8
16
  Incomplete = "incomplete",
9
17
  UnrecognisedSecurityType = "unrecognized_security_type",
@@ -37,6 +45,7 @@ export type SecurityState = {
37
45
  headers: Record<string, string>;
38
46
  queryParams: Record<string, string>;
39
47
  cookies: Record<string, string>;
48
+ oauth2: ({ type: "password" } & OAuth2PasswordFlow) | { type: "none" };
40
49
  };
41
50
 
42
51
  type SecurityInputBasic = {
@@ -73,7 +82,18 @@ type SecurityInputOAuth2 = {
73
82
 
74
83
  type SecurityInputOAuth2ClientCredentials = {
75
84
  type: "oauth2:client_credentials";
76
- value: string | null | undefined;
85
+ value:
86
+ | { clientID?: string | undefined; clientSecret?: string | undefined }
87
+ | null
88
+ | undefined;
89
+ };
90
+
91
+ type SecurityInputOAuth2PasswordCredentials = {
92
+ type: "oauth2:password";
93
+ value:
94
+ | string
95
+ | null
96
+ | undefined;
77
97
  fieldName: string;
78
98
  };
79
99
 
@@ -89,6 +109,7 @@ export type SecurityInput =
89
109
  | SecurityInputAPIKey
90
110
  | SecurityInputOAuth2
91
111
  | SecurityInputOAuth2ClientCredentials
112
+ | SecurityInputOAuth2PasswordCredentials
92
113
  | SecurityInputOIDC
93
114
  | SecurityInputCustom;
94
115
 
@@ -100,6 +121,7 @@ export function resolveSecurity(
100
121
  headers: {},
101
122
  queryParams: {},
102
123
  cookies: {},
124
+ oauth2: { type: "none" },
103
125
  };
104
126
 
105
127
  const option = options.find((opts) => {
@@ -110,6 +132,12 @@ export function resolveSecurity(
110
132
  return o.value.username != null || o.value.password != null;
111
133
  } else if (o.type === "http:custom") {
112
134
  return null;
135
+ } else if (o.type === "oauth2:password") {
136
+ return (
137
+ typeof o.value === "string" && !!o.value
138
+ );
139
+ } else if (o.type === "oauth2:client_credentials") {
140
+ return o.value.clientID != null || o.value.clientSecret != null;
113
141
  } else if (typeof o.value === "string") {
114
142
  return !!o.value;
115
143
  } else {
@@ -152,6 +180,9 @@ export function resolveSecurity(
152
180
  case "oauth2":
153
181
  applyBearer(state, spec);
154
182
  break;
183
+ case "oauth2:password":
184
+ applyBearer(state, spec);
185
+ break;
155
186
  case "oauth2:client_credentials":
156
187
  break;
157
188
  case "openIdConnect":
@@ -179,9 +210,13 @@ function applyBasic(
179
210
 
180
211
  function applyBearer(
181
212
  state: SecurityState,
182
- spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC,
213
+ spec:
214
+ | SecurityInputBearer
215
+ | SecurityInputOAuth2
216
+ | SecurityInputOIDC
217
+ | SecurityInputOAuth2PasswordCredentials,
183
218
  ) {
184
- if (spec.value == null) {
219
+ if (typeof spec.value !== "string" || !spec.value) {
185
220
  return;
186
221
  }
187
222
 
@@ -192,6 +227,7 @@ function applyBearer(
192
227
 
193
228
  state.headers[spec.fieldName] = value;
194
229
  }
230
+
195
231
  export function resolveGlobalSecurity(
196
232
  security: Partial<components.Security> | null | undefined,
197
233
  ): SecurityState | null {
@@ -36,7 +36,7 @@ export type GetLinksRequest = {
36
36
  */
37
37
  domain?: string | undefined;
38
38
  /**
39
- * The tag ID to filter the links by. This field is deprecated – use `tagIds` instead.
39
+ * Deprecated. Use `tagIds` instead. The tag ID to filter the links by.
40
40
  */
41
41
  tagId?: string | undefined;
42
42
  /**
@@ -41,7 +41,7 @@ export type GetLinksCountRequest = {
41
41
  */
42
42
  domain?: string | undefined;
43
43
  /**
44
- * The tag ID to filter the links by. This field is deprecated – use `tagIds` instead.
44
+ * Deprecated. Use `tagIds` instead. The tag ID to filter the links by.
45
45
  */
46
46
  tagId?: string | undefined;
47
47
  /**
@@ -48,6 +48,11 @@ export const QueryParamTrigger = {
48
48
  */
49
49
  export type QueryParamTrigger = ClosedEnum<typeof QueryParamTrigger>;
50
50
 
51
+ /**
52
+ * The tag IDs to retrieve analytics for.
53
+ */
54
+ export type ListEventsQueryParamTagIds = string | Array<string>;
55
+
51
56
  export const Order = {
52
57
  Asc: "asc",
53
58
  Desc: "desc",
@@ -137,9 +142,13 @@ export type ListEventsRequest = {
137
142
  */
138
143
  url?: string | undefined;
139
144
  /**
140
- * The tag ID to retrieve analytics for.
145
+ * Deprecated. Use `tagIds` instead. The tag ID to retrieve analytics for.
141
146
  */
142
147
  tagId?: string | undefined;
148
+ /**
149
+ * The tag IDs to retrieve analytics for.
150
+ */
151
+ tagIds?: string | Array<string> | undefined;
143
152
  /**
144
153
  * Deprecated. Use the `trigger` field instead. Filter for QR code scans. If true, filter for QR codes only. If false, filter for links only. If undefined, return both.
145
154
  */
@@ -225,6 +234,36 @@ export namespace QueryParamTrigger$ {
225
234
  export const outboundSchema = QueryParamTrigger$outboundSchema;
226
235
  }
227
236
 
237
+ /** @internal */
238
+ export const ListEventsQueryParamTagIds$inboundSchema: z.ZodType<
239
+ ListEventsQueryParamTagIds,
240
+ z.ZodTypeDef,
241
+ unknown
242
+ > = z.union([z.string(), z.array(z.string())]);
243
+
244
+ /** @internal */
245
+ export type ListEventsQueryParamTagIds$Outbound = string | Array<string>;
246
+
247
+ /** @internal */
248
+ export const ListEventsQueryParamTagIds$outboundSchema: z.ZodType<
249
+ ListEventsQueryParamTagIds$Outbound,
250
+ z.ZodTypeDef,
251
+ ListEventsQueryParamTagIds
252
+ > = z.union([z.string(), z.array(z.string())]);
253
+
254
+ /**
255
+ * @internal
256
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
257
+ */
258
+ export namespace ListEventsQueryParamTagIds$ {
259
+ /** @deprecated use `ListEventsQueryParamTagIds$inboundSchema` instead. */
260
+ export const inboundSchema = ListEventsQueryParamTagIds$inboundSchema;
261
+ /** @deprecated use `ListEventsQueryParamTagIds$outboundSchema` instead. */
262
+ export const outboundSchema = ListEventsQueryParamTagIds$outboundSchema;
263
+ /** @deprecated use `ListEventsQueryParamTagIds$Outbound` instead. */
264
+ export type Outbound = ListEventsQueryParamTagIds$Outbound;
265
+ }
266
+
228
267
  /** @internal */
229
268
  export const Order$inboundSchema: z.ZodNativeEnum<typeof Order> = z.nativeEnum(
230
269
  Order,
@@ -290,6 +329,7 @@ export const ListEventsRequest$inboundSchema: z.ZodType<
290
329
  refererUrl: z.string().optional(),
291
330
  url: z.string().optional(),
292
331
  tagId: z.string().optional(),
332
+ tagIds: z.union([z.string(), z.array(z.string())]).optional(),
293
333
  qr: z.boolean().optional(),
294
334
  root: z.boolean().optional(),
295
335
  page: z.number().default(1),
@@ -320,6 +360,7 @@ export type ListEventsRequest$Outbound = {
320
360
  refererUrl?: string | undefined;
321
361
  url?: string | undefined;
322
362
  tagId?: string | undefined;
363
+ tagIds?: string | Array<string> | undefined;
323
364
  qr?: boolean | undefined;
324
365
  root?: boolean | undefined;
325
366
  page: number;
@@ -354,6 +395,7 @@ export const ListEventsRequest$outboundSchema: z.ZodType<
354
395
  refererUrl: z.string().optional(),
355
396
  url: z.string().optional(),
356
397
  tagId: z.string().optional(),
398
+ tagIds: z.union([z.string(), z.array(z.string())]).optional(),
357
399
  qr: z.boolean().optional(),
358
400
  root: z.boolean().optional(),
359
401
  page: z.number().default(1),
@@ -74,6 +74,11 @@ export const Trigger = {
74
74
  */
75
75
  export type Trigger = ClosedEnum<typeof Trigger>;
76
76
 
77
+ /**
78
+ * The tag IDs to retrieve analytics for.
79
+ */
80
+ export type RetrieveAnalyticsQueryParamTagIds = string | Array<string>;
81
+
77
82
  export type RetrieveAnalyticsRequest = {
78
83
  /**
79
84
  * The type of event to retrieve analytics for. Defaults to `clicks`.
@@ -156,9 +161,13 @@ export type RetrieveAnalyticsRequest = {
156
161
  */
157
162
  url?: string | undefined;
158
163
  /**
159
- * The tag ID to retrieve analytics for.
164
+ * Deprecated. Use `tagIds` instead. The tag ID to retrieve analytics for.
160
165
  */
161
166
  tagId?: string | undefined;
167
+ /**
168
+ * The tag IDs to retrieve analytics for.
169
+ */
170
+ tagIds?: string | Array<string> | undefined;
162
171
  /**
163
172
  * Deprecated. Use the `trigger` field instead. Filter for QR code scans. If true, filter for QR codes only. If false, filter for links only. If undefined, return both.
164
173
  */
@@ -266,6 +275,37 @@ export namespace Trigger$ {
266
275
  export const outboundSchema = Trigger$outboundSchema;
267
276
  }
268
277
 
278
+ /** @internal */
279
+ export const RetrieveAnalyticsQueryParamTagIds$inboundSchema: z.ZodType<
280
+ RetrieveAnalyticsQueryParamTagIds,
281
+ z.ZodTypeDef,
282
+ unknown
283
+ > = z.union([z.string(), z.array(z.string())]);
284
+
285
+ /** @internal */
286
+ export type RetrieveAnalyticsQueryParamTagIds$Outbound = string | Array<string>;
287
+
288
+ /** @internal */
289
+ export const RetrieveAnalyticsQueryParamTagIds$outboundSchema: z.ZodType<
290
+ RetrieveAnalyticsQueryParamTagIds$Outbound,
291
+ z.ZodTypeDef,
292
+ RetrieveAnalyticsQueryParamTagIds
293
+ > = z.union([z.string(), z.array(z.string())]);
294
+
295
+ /**
296
+ * @internal
297
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
298
+ */
299
+ export namespace RetrieveAnalyticsQueryParamTagIds$ {
300
+ /** @deprecated use `RetrieveAnalyticsQueryParamTagIds$inboundSchema` instead. */
301
+ export const inboundSchema = RetrieveAnalyticsQueryParamTagIds$inboundSchema;
302
+ /** @deprecated use `RetrieveAnalyticsQueryParamTagIds$outboundSchema` instead. */
303
+ export const outboundSchema =
304
+ RetrieveAnalyticsQueryParamTagIds$outboundSchema;
305
+ /** @deprecated use `RetrieveAnalyticsQueryParamTagIds$Outbound` instead. */
306
+ export type Outbound = RetrieveAnalyticsQueryParamTagIds$Outbound;
307
+ }
308
+
269
309
  /** @internal */
270
310
  export const RetrieveAnalyticsRequest$inboundSchema: z.ZodType<
271
311
  RetrieveAnalyticsRequest,
@@ -293,6 +333,7 @@ export const RetrieveAnalyticsRequest$inboundSchema: z.ZodType<
293
333
  refererUrl: z.string().optional(),
294
334
  url: z.string().optional(),
295
335
  tagId: z.string().optional(),
336
+ tagIds: z.union([z.string(), z.array(z.string())]).optional(),
296
337
  qr: z.boolean().optional(),
297
338
  root: z.boolean().optional(),
298
339
  });
@@ -320,6 +361,7 @@ export type RetrieveAnalyticsRequest$Outbound = {
320
361
  refererUrl?: string | undefined;
321
362
  url?: string | undefined;
322
363
  tagId?: string | undefined;
364
+ tagIds?: string | Array<string> | undefined;
323
365
  qr?: boolean | undefined;
324
366
  root?: boolean | undefined;
325
367
  };
@@ -351,6 +393,7 @@ export const RetrieveAnalyticsRequest$outboundSchema: z.ZodType<
351
393
  refererUrl: z.string().optional(),
352
394
  url: z.string().optional(),
353
395
  tagId: z.string().optional(),
396
+ tagIds: z.union([z.string(), z.array(z.string())]).optional(),
354
397
  qr: z.boolean().optional(),
355
398
  root: z.boolean().optional(),
356
399
  });